@typescript-deploys/pr-build 6.0.0-pr-63539-32 → 7.1.0-pr.65064.3

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 (500) hide show
  1. package/{LICENSE.txt → LICENSE} +55 -55
  2. package/{ThirdPartyNoticeText.txt → NOTICE.txt} +405 -193
  3. package/README.md +10 -61
  4. package/bin/tsc +1 -1
  5. package/dist/api/async/api.d.ts +1064 -0
  6. package/dist/api/async/api.d.ts.map +1 -0
  7. package/dist/api/async/api.js +3304 -0
  8. package/dist/api/async/api.js.map +1 -0
  9. package/dist/api/async/client.d.ts +61 -0
  10. package/dist/api/async/client.d.ts.map +1 -0
  11. package/dist/api/async/client.js +418 -0
  12. package/dist/api/async/client.js.map +1 -0
  13. package/dist/api/async/jsonrpc.d.ts +14 -0
  14. package/dist/api/async/jsonrpc.d.ts.map +1 -0
  15. package/dist/api/async/jsonrpc.js +96 -0
  16. package/dist/api/async/jsonrpc.js.map +1 -0
  17. package/dist/api/async/transport.d.ts +23 -0
  18. package/dist/api/async/transport.d.ts.map +1 -0
  19. package/dist/api/async/transport.js +2 -0
  20. package/dist/api/async/transport.js.map +1 -0
  21. package/dist/api/async/transportClient.d.ts +37 -0
  22. package/dist/api/async/transportClient.d.ts.map +1 -0
  23. package/dist/api/async/transportClient.js +256 -0
  24. package/dist/api/async/transportClient.js.map +1 -0
  25. package/dist/api/async/types.d.ts +375 -0
  26. package/dist/api/async/types.d.ts.map +1 -0
  27. package/dist/api/async/types.js +2 -0
  28. package/dist/api/async/types.js.map +1 -0
  29. package/dist/api/compilerOptions.generated.d.ts +124 -0
  30. package/dist/api/compilerOptions.generated.d.ts.map +1 -0
  31. package/dist/api/compilerOptions.generated.js +8 -0
  32. package/dist/api/compilerOptions.generated.js.map +1 -0
  33. package/dist/api/diagnosticFormatter.d.ts +9 -0
  34. package/dist/api/diagnosticFormatter.d.ts.map +1 -0
  35. package/dist/api/diagnosticFormatter.js +169 -0
  36. package/dist/api/diagnosticFormatter.js.map +1 -0
  37. package/dist/api/fs.d.ts +71 -0
  38. package/dist/api/fs.d.ts.map +1 -0
  39. package/dist/api/fs.js +75 -0
  40. package/dist/api/fs.js.map +1 -0
  41. package/dist/api/fsCallbacks.d.ts +44 -0
  42. package/dist/api/fsCallbacks.d.ts.map +1 -0
  43. package/dist/api/fsCallbacks.js +122 -0
  44. package/dist/api/fsCallbacks.js.map +1 -0
  45. package/dist/api/node/encoder.d.ts +18 -0
  46. package/dist/api/node/encoder.d.ts.map +1 -0
  47. package/dist/api/node/encoder.generated.d.ts +5 -0
  48. package/dist/api/node/encoder.generated.d.ts.map +1 -0
  49. package/dist/api/node/encoder.generated.js +74 -0
  50. package/dist/api/node/encoder.generated.js.map +1 -0
  51. package/dist/api/node/encoder.js +306 -0
  52. package/dist/api/node/encoder.js.map +1 -0
  53. package/dist/api/node/msgpack.d.ts +32 -0
  54. package/dist/api/node/msgpack.d.ts.map +1 -0
  55. package/dist/api/node/msgpack.js +212 -0
  56. package/dist/api/node/msgpack.js.map +1 -0
  57. package/dist/api/node/node.d.ts +97 -0
  58. package/dist/api/node/node.d.ts.map +1 -0
  59. package/dist/api/node/node.generated.d.ts +189 -0
  60. package/dist/api/node/node.generated.d.ts.map +1 -0
  61. package/dist/api/node/node.generated.js +884 -0
  62. package/dist/api/node/node.generated.js.map +1 -0
  63. package/dist/api/node/node.infrastructure.d.ts +64 -0
  64. package/dist/api/node/node.infrastructure.d.ts.map +1 -0
  65. package/dist/api/node/node.infrastructure.js +102 -0
  66. package/dist/api/node/node.infrastructure.js.map +1 -0
  67. package/dist/api/node/node.js +496 -0
  68. package/dist/api/node/node.js.map +1 -0
  69. package/dist/api/node/protocol.d.ts +32 -0
  70. package/dist/api/node/protocol.d.ts.map +1 -0
  71. package/dist/api/node/protocol.generated.d.ts +4 -0
  72. package/dist/api/node/protocol.generated.d.ts.map +1 -0
  73. package/dist/api/node/protocol.generated.js +242 -0
  74. package/dist/api/node/protocol.generated.js.map +1 -0
  75. package/dist/api/node/protocol.js +33 -0
  76. package/dist/api/node/protocol.js.map +1 -0
  77. package/dist/api/node/wtf8.d.ts +10 -0
  78. package/dist/api/node/wtf8.d.ts.map +1 -0
  79. package/dist/api/node/wtf8.js +137 -0
  80. package/dist/api/node/wtf8.js.map +1 -0
  81. package/dist/api/nodeProcess.d.ts +8 -0
  82. package/dist/api/nodeProcess.d.ts.map +1 -0
  83. package/dist/api/nodeProcess.js +23 -0
  84. package/dist/api/nodeProcess.js.map +1 -0
  85. package/dist/api/options.d.ts +76 -0
  86. package/dist/api/options.d.ts.map +1 -0
  87. package/dist/api/options.js +34 -0
  88. package/dist/api/options.js.map +1 -0
  89. package/dist/api/path.d.ts +120 -0
  90. package/dist/api/path.d.ts.map +1 -0
  91. package/dist/api/path.js +884 -0
  92. package/dist/api/path.js.map +1 -0
  93. package/dist/api/prepareCompilerOptions.generated.d.ts +5 -0
  94. package/dist/api/prepareCompilerOptions.generated.d.ts.map +1 -0
  95. package/dist/api/prepareCompilerOptions.generated.js +24 -0
  96. package/dist/api/prepareCompilerOptions.generated.js.map +1 -0
  97. package/dist/api/proto.d.ts +80 -0
  98. package/dist/api/proto.d.ts.map +1 -0
  99. package/dist/api/proto.generated.d.ts +1489 -0
  100. package/dist/api/proto.generated.d.ts.map +1 -0
  101. package/dist/api/proto.generated.js +21 -0
  102. package/dist/api/proto.generated.js.map +1 -0
  103. package/dist/api/proto.js +50 -0
  104. package/dist/api/proto.js.map +1 -0
  105. package/dist/api/sourceFileCache.d.ts +110 -0
  106. package/dist/api/sourceFileCache.d.ts.map +1 -0
  107. package/dist/api/sourceFileCache.js +300 -0
  108. package/dist/api/sourceFileCache.js.map +1 -0
  109. package/dist/api/sync/api.d.ts +1771 -0
  110. package/dist/api/sync/api.d.ts.map +1 -0
  111. package/dist/api/sync/api.js +5728 -0
  112. package/dist/api/sync/api.js.map +1 -0
  113. package/dist/api/sync/client.d.ts +13 -0
  114. package/dist/api/sync/client.d.ts.map +1 -0
  115. package/dist/api/sync/client.js +80 -0
  116. package/dist/api/sync/client.js.map +1 -0
  117. package/dist/api/sync/generatorSupport.d.ts +32 -0
  118. package/dist/api/sync/generatorSupport.d.ts.map +1 -0
  119. package/dist/api/sync/generatorSupport.js +338 -0
  120. package/dist/api/sync/generatorSupport.js.map +1 -0
  121. package/dist/api/sync/transport.d.ts +21 -0
  122. package/dist/api/sync/transport.d.ts.map +1 -0
  123. package/dist/api/sync/transport.js +2 -0
  124. package/dist/api/sync/transport.js.map +1 -0
  125. package/dist/api/sync/transportClient.d.ts +23 -0
  126. package/dist/api/sync/transportClient.d.ts.map +1 -0
  127. package/dist/api/sync/transportClient.js +104 -0
  128. package/dist/api/sync/transportClient.js.map +1 -0
  129. package/dist/api/sync/types.d.ts +502 -0
  130. package/dist/api/sync/types.d.ts.map +1 -0
  131. package/dist/api/sync/types.js +2 -0
  132. package/dist/api/sync/types.js.map +1 -0
  133. package/dist/api/syncChannel.d.ts +119 -0
  134. package/dist/api/syncChannel.d.ts.map +1 -0
  135. package/dist/api/syncChannel.js +540 -0
  136. package/dist/api/syncChannel.js.map +1 -0
  137. package/dist/api/timing.d.ts +175 -0
  138. package/dist/api/timing.d.ts.map +1 -0
  139. package/dist/api/timing.js +149 -0
  140. package/dist/api/timing.js.map +1 -0
  141. package/dist/api/timingDump.d.ts +13 -0
  142. package/dist/api/timingDump.d.ts.map +1 -0
  143. package/dist/api/timingDump.js +40 -0
  144. package/dist/api/timingDump.js.map +1 -0
  145. package/dist/api/typedPaths.d.ts +3 -0
  146. package/dist/api/typedPaths.d.ts.map +1 -0
  147. package/dist/api/typedPaths.js +2 -0
  148. package/dist/api/typedPaths.js.map +1 -0
  149. package/dist/api/userPreferences.generated.d.ts +195 -0
  150. package/dist/api/userPreferences.generated.d.ts.map +1 -0
  151. package/dist/api/userPreferences.generated.js +3 -0
  152. package/dist/api/userPreferences.generated.js.map +1 -0
  153. package/dist/ast/ast.d.ts +183 -0
  154. package/dist/ast/ast.d.ts.map +1 -0
  155. package/dist/ast/ast.generated.d.ts +1168 -0
  156. package/dist/ast/ast.generated.d.ts.map +1 -0
  157. package/dist/ast/ast.generated.js +4 -0
  158. package/dist/ast/ast.generated.js.map +1 -0
  159. package/dist/ast/ast.js +8 -0
  160. package/dist/ast/ast.js.map +1 -0
  161. package/dist/ast/astnav.d.ts +20 -0
  162. package/dist/ast/astnav.d.ts.map +1 -0
  163. package/dist/ast/astnav.js +858 -0
  164. package/dist/ast/astnav.js.map +1 -0
  165. package/dist/ast/clone.d.ts +16 -0
  166. package/dist/ast/clone.d.ts.map +1 -0
  167. package/dist/ast/clone.js +104 -0
  168. package/dist/ast/clone.js.map +1 -0
  169. package/dist/ast/factory.generated.d.ts +374 -0
  170. package/dist/ast/factory.generated.d.ts.map +1 -0
  171. package/dist/ast/factory.generated.js +5754 -0
  172. package/dist/ast/factory.generated.js.map +1 -0
  173. package/dist/ast/index.d.ts +25 -0
  174. package/dist/ast/index.d.ts.map +1 -0
  175. package/dist/ast/index.js +25 -0
  176. package/dist/ast/index.js.map +1 -0
  177. package/dist/ast/is.d.ts +25 -0
  178. package/dist/ast/is.d.ts.map +1 -0
  179. package/dist/ast/is.generated.d.ts +1221 -0
  180. package/dist/ast/is.generated.d.ts.map +1 -0
  181. package/dist/ast/is.generated.js +1404 -0
  182. package/dist/ast/is.generated.js.map +1 -0
  183. package/dist/ast/is.js +456 -0
  184. package/dist/ast/is.js.map +1 -0
  185. package/dist/ast/jsdoc.d.ts +12 -0
  186. package/dist/ast/jsdoc.d.ts.map +1 -0
  187. package/dist/ast/jsdoc.js +208 -0
  188. package/dist/ast/jsdoc.js.map +1 -0
  189. package/dist/ast/modifiers.d.ts +4 -0
  190. package/dist/ast/modifiers.d.ts.map +1 -0
  191. package/dist/ast/modifiers.js +41 -0
  192. package/dist/ast/modifiers.js.map +1 -0
  193. package/dist/ast/scanner.d.ts +97 -0
  194. package/dist/ast/scanner.d.ts.map +1 -0
  195. package/dist/ast/scanner.js +2231 -0
  196. package/dist/ast/scanner.js.map +1 -0
  197. package/dist/ast/spanMap.d.ts +88 -0
  198. package/dist/ast/spanMap.d.ts.map +1 -0
  199. package/dist/ast/spanMap.js +417 -0
  200. package/dist/ast/spanMap.js.map +1 -0
  201. package/dist/ast/utils.d.ts +30 -0
  202. package/dist/ast/utils.d.ts.map +1 -0
  203. package/dist/ast/utils.js +318 -0
  204. package/dist/ast/utils.js.map +1 -0
  205. package/dist/ast/visitor.d.ts +16 -0
  206. package/dist/ast/visitor.d.ts.map +1 -0
  207. package/dist/ast/visitor.generated.d.ts +50 -0
  208. package/dist/ast/visitor.generated.d.ts.map +1 -0
  209. package/dist/ast/visitor.generated.js +978 -0
  210. package/dist/ast/visitor.generated.js.map +1 -0
  211. package/dist/ast/visitor.js +87 -0
  212. package/dist/ast/visitor.js.map +1 -0
  213. package/dist/internal/utils.d.ts +23 -0
  214. package/dist/internal/utils.d.ts.map +1 -0
  215. package/dist/internal/utils.js +25 -0
  216. package/dist/internal/utils.js.map +1 -0
  217. package/dist/vscode/extensionApi.d.ts +101 -0
  218. package/dist/vscode/extensionApi.d.ts.map +1 -0
  219. package/dist/vscode/extensionApi.js +2 -0
  220. package/dist/vscode/extensionApi.js.map +1 -0
  221. package/dist/vscode/moduleLoader.d.ts +14 -0
  222. package/dist/vscode/moduleLoader.d.ts.map +1 -0
  223. package/dist/vscode/moduleLoader.js +36 -0
  224. package/dist/vscode/moduleLoader.js.map +1 -0
  225. package/dist/vscode/protocol.generated.d.ts +2891 -0
  226. package/dist/vscode/protocol.generated.d.ts.map +1 -0
  227. package/dist/vscode/protocol.generated.js +4 -0
  228. package/dist/vscode/protocol.generated.js.map +1 -0
  229. package/dist/wasm/index.d.ts +9 -0
  230. package/dist/wasm/index.d.ts.map +1 -0
  231. package/dist/wasm/index.js +9 -0
  232. package/dist/wasm/index.js.map +1 -0
  233. package/dist/wasm/transport.d.ts +112 -0
  234. package/dist/wasm/transport.d.ts.map +1 -0
  235. package/dist/wasm/transport.js +333 -0
  236. package/dist/wasm/transport.js.map +1 -0
  237. package/dist/wasm/wasi.d.ts +35 -0
  238. package/dist/wasm/wasi.d.ts.map +1 -0
  239. package/dist/wasm/wasi.js +227 -0
  240. package/dist/wasm/wasi.js.map +1 -0
  241. package/enums/caseSensitivity.d.ts +6 -0
  242. package/enums/caseSensitivity.js +6 -0
  243. package/enums/characterCodes.d.ts +139 -0
  244. package/enums/characterCodes.js +129 -0
  245. package/enums/checkFlags.d.ts +35 -0
  246. package/enums/checkFlags.js +35 -0
  247. package/enums/commentDirectiveType.d.ts +4 -0
  248. package/enums/commentDirectiveType.js +5 -0
  249. package/enums/completionItemKind.d.ts +29 -0
  250. package/enums/completionItemKind.js +29 -0
  251. package/enums/diagnosticCategory.d.ts +8 -0
  252. package/enums/diagnosticCategory.js +8 -0
  253. package/enums/diagnosticDirectivePolicy.d.ts +6 -0
  254. package/enums/diagnosticDirectivePolicy.js +6 -0
  255. package/enums/elementFlags.d.ts +13 -0
  256. package/enums/elementFlags.js +13 -0
  257. package/enums/emitOnly.d.ts +7 -0
  258. package/enums/emitOnly.js +7 -0
  259. package/enums/indexKind.d.ts +6 -0
  260. package/enums/indexKind.js +6 -0
  261. package/enums/internalSymbolName.d.ts +24 -0
  262. package/enums/internalSymbolName.js +24 -0
  263. package/enums/jsDeclarationKind.d.ts +11 -0
  264. package/enums/jsDeclarationKind.js +11 -0
  265. package/enums/jsxEmit.d.ts +10 -0
  266. package/enums/jsxEmit.js +10 -0
  267. package/enums/languageVariant.d.ts +4 -0
  268. package/enums/languageVariant.js +5 -0
  269. package/enums/modifierFlags.d.ts +43 -0
  270. package/enums/modifierFlags.js +43 -0
  271. package/enums/moduleDetectionKind.d.ts +8 -0
  272. package/enums/moduleDetectionKind.js +8 -0
  273. package/enums/moduleKind.d.ts +18 -0
  274. package/enums/moduleKind.js +18 -0
  275. package/enums/moduleResolutionKind.d.ts +10 -0
  276. package/enums/moduleResolutionKind.js +10 -0
  277. package/enums/newLineKind.d.ts +7 -0
  278. package/enums/newLineKind.js +7 -0
  279. package/enums/nodeBuilderFlags.d.ts +37 -0
  280. package/enums/nodeBuilderFlags.js +37 -0
  281. package/enums/nodeFlags.d.ts +45 -0
  282. package/enums/nodeFlags.js +45 -0
  283. package/enums/objectFlags.d.ts +51 -0
  284. package/enums/objectFlags.js +51 -0
  285. package/enums/outerExpressionKinds.d.ts +17 -0
  286. package/enums/outerExpressionKinds.js +17 -0
  287. package/enums/regularExpressionFlags.d.ts +12 -0
  288. package/enums/regularExpressionFlags.js +13 -0
  289. package/enums/scriptKind.d.ts +10 -0
  290. package/enums/scriptKind.js +10 -0
  291. package/enums/scriptTarget.d.ts +19 -0
  292. package/enums/scriptTarget.js +19 -0
  293. package/enums/signatureFlags.d.ts +16 -0
  294. package/enums/signatureFlags.js +16 -0
  295. package/enums/signatureKind.d.ts +6 -0
  296. package/enums/signatureKind.js +6 -0
  297. package/enums/spanMapFeature.d.ts +26 -0
  298. package/enums/spanMapFeature.js +26 -0
  299. package/enums/spanMapFidelity.d.ts +8 -0
  300. package/enums/spanMapFidelity.js +8 -0
  301. package/enums/spanMapKind.d.ts +7 -0
  302. package/enums/spanMapKind.js +7 -0
  303. package/enums/symbolFlags.d.ts +72 -0
  304. package/enums/symbolFlags.js +72 -0
  305. package/enums/symbolOwnerKind.d.ts +6 -0
  306. package/enums/symbolOwnerKind.js +6 -0
  307. package/enums/syntaxKind.d.ts +391 -0
  308. package/enums/syntaxKind.js +391 -0
  309. package/enums/tokenFlags.d.ts +31 -0
  310. package/enums/tokenFlags.js +31 -0
  311. package/enums/typeFlags.d.ts +77 -0
  312. package/enums/typeFlags.js +77 -0
  313. package/enums/typeFormatFlags.d.ts +30 -0
  314. package/enums/typeFormatFlags.js +30 -0
  315. package/enums/typePredicateKind.d.ts +8 -0
  316. package/enums/typePredicateKind.js +8 -0
  317. package/lib/getExePath.d.ts +8 -0
  318. package/lib/getExePath.js +65 -0
  319. package/lib/tsc.js +32 -7
  320. package/lib/version.cjs +3 -0
  321. package/lib/version.d.cts +2 -0
  322. package/package.json +74 -117
  323. package/schemas/jsconfig.schema.json +2220 -0
  324. package/schemas/tsconfig.schema.json +2219 -0
  325. package/vendor/vscode-jsonrpc/License.txt +11 -0
  326. package/vendor/vscode-jsonrpc/README.md +59 -0
  327. package/vendor/vscode-jsonrpc/lib/browser/main.d.ts +17 -0
  328. package/vendor/vscode-jsonrpc/lib/browser/main.js +83 -0
  329. package/vendor/vscode-jsonrpc/lib/browser/ril.d.ts +22 -0
  330. package/vendor/vscode-jsonrpc/lib/browser/ril.js +218 -0
  331. package/vendor/vscode-jsonrpc/lib/common/api.d.ts +14 -0
  332. package/vendor/vscode-jsonrpc/lib/common/api.js +87 -0
  333. package/vendor/vscode-jsonrpc/lib/common/cancellation.d.ts +32 -0
  334. package/vendor/vscode-jsonrpc/lib/common/cancellation.js +132 -0
  335. package/vendor/vscode-jsonrpc/lib/common/connection.d.ts +367 -0
  336. package/vendor/vscode-jsonrpc/lib/common/connection.js +1276 -0
  337. package/vendor/vscode-jsonrpc/lib/common/disposable.d.ts +9 -0
  338. package/vendor/vscode-jsonrpc/lib/common/disposable.js +16 -0
  339. package/vendor/vscode-jsonrpc/lib/common/encoding.d.ts +52 -0
  340. package/vendor/vscode-jsonrpc/lib/common/encoding.js +70 -0
  341. package/vendor/vscode-jsonrpc/lib/common/events.d.ts +39 -0
  342. package/vendor/vscode-jsonrpc/lib/common/events.js +135 -0
  343. package/vendor/vscode-jsonrpc/lib/common/is.d.ts +7 -0
  344. package/vendor/vscode-jsonrpc/lib/common/is.js +34 -0
  345. package/vendor/vscode-jsonrpc/lib/common/linkedMap.d.ts +55 -0
  346. package/vendor/vscode-jsonrpc/lib/common/linkedMap.js +412 -0
  347. package/vendor/vscode-jsonrpc/lib/common/messageBuffer.d.ts +18 -0
  348. package/vendor/vscode-jsonrpc/lib/common/messageBuffer.js +155 -0
  349. package/vendor/vscode-jsonrpc/lib/common/messageReader.d.ts +77 -0
  350. package/vendor/vscode-jsonrpc/lib/common/messageReader.js +246 -0
  351. package/vendor/vscode-jsonrpc/lib/common/messageWriter.d.ts +60 -0
  352. package/vendor/vscode-jsonrpc/lib/common/messageWriter.js +157 -0
  353. package/vendor/vscode-jsonrpc/lib/common/messages.d.ts +369 -0
  354. package/vendor/vscode-jsonrpc/lib/common/messages.js +436 -0
  355. package/vendor/vscode-jsonrpc/lib/common/ral.d.ts +82 -0
  356. package/vendor/vscode-jsonrpc/lib/common/ral.js +23 -0
  357. package/vendor/vscode-jsonrpc/lib/common/semaphore.d.ts +10 -0
  358. package/vendor/vscode-jsonrpc/lib/common/semaphore.js +74 -0
  359. package/vendor/vscode-jsonrpc/lib/common/sharedArrayCancellation.d.ts +15 -0
  360. package/vendor/vscode-jsonrpc/lib/common/sharedArrayCancellation.js +77 -0
  361. package/vendor/vscode-jsonrpc/lib/node/main.d.ts +73 -0
  362. package/vendor/vscode-jsonrpc/lib/node/main.js +298 -0
  363. package/vendor/vscode-jsonrpc/lib/node/ril.d.ts +12 -0
  364. package/vendor/vscode-jsonrpc/lib/node/ril.js +167 -0
  365. package/vendor/vscode-jsonrpc/package.json +56 -0
  366. package/vendor/vscode-jsonrpc/typings/thenable.d.ts +5 -0
  367. package/SECURITY.md +0 -39
  368. package/bin/tsserver +0 -2
  369. package/lib/_tsc.js +0 -134465
  370. package/lib/_tsserver.js +0 -659
  371. package/lib/_typingsInstaller.js +0 -222
  372. package/lib/cs/diagnosticMessages.generated.json +0 -2129
  373. package/lib/de/diagnosticMessages.generated.json +0 -2125
  374. package/lib/es/diagnosticMessages.generated.json +0 -2129
  375. package/lib/fr/diagnosticMessages.generated.json +0 -2129
  376. package/lib/it/diagnosticMessages.generated.json +0 -2125
  377. package/lib/ja/diagnosticMessages.generated.json +0 -2129
  378. package/lib/ko/diagnosticMessages.generated.json +0 -2129
  379. package/lib/lib.d.ts +0 -20
  380. package/lib/lib.decorators.d.ts +0 -382
  381. package/lib/lib.decorators.legacy.d.ts +0 -20
  382. package/lib/lib.dom.asynciterable.d.ts +0 -18
  383. package/lib/lib.dom.d.ts +0 -45125
  384. package/lib/lib.dom.iterable.d.ts +0 -18
  385. package/lib/lib.es2015.collection.d.ts +0 -150
  386. package/lib/lib.es2015.core.d.ts +0 -595
  387. package/lib/lib.es2015.d.ts +0 -26
  388. package/lib/lib.es2015.generator.d.ts +0 -75
  389. package/lib/lib.es2015.iterable.d.ts +0 -603
  390. package/lib/lib.es2015.promise.d.ts +0 -79
  391. package/lib/lib.es2015.proxy.d.ts +0 -126
  392. package/lib/lib.es2015.reflect.d.ts +0 -142
  393. package/lib/lib.es2015.symbol.d.ts +0 -44
  394. package/lib/lib.es2015.symbol.wellknown.d.ts +0 -324
  395. package/lib/lib.es2016.array.include.d.ts +0 -114
  396. package/lib/lib.es2016.d.ts +0 -19
  397. package/lib/lib.es2016.full.d.ts +0 -21
  398. package/lib/lib.es2016.intl.d.ts +0 -29
  399. package/lib/lib.es2017.arraybuffer.d.ts +0 -19
  400. package/lib/lib.es2017.d.ts +0 -24
  401. package/lib/lib.es2017.date.d.ts +0 -29
  402. package/lib/lib.es2017.full.d.ts +0 -21
  403. package/lib/lib.es2017.intl.d.ts +0 -42
  404. package/lib/lib.es2017.object.d.ts +0 -47
  405. package/lib/lib.es2017.sharedmemory.d.ts +0 -133
  406. package/lib/lib.es2017.string.d.ts +0 -47
  407. package/lib/lib.es2017.typedarrays.d.ts +0 -51
  408. package/lib/lib.es2018.asyncgenerator.d.ts +0 -75
  409. package/lib/lib.es2018.asynciterable.d.ts +0 -51
  410. package/lib/lib.es2018.d.ts +0 -22
  411. package/lib/lib.es2018.full.d.ts +0 -22
  412. package/lib/lib.es2018.intl.d.ts +0 -81
  413. package/lib/lib.es2018.promise.d.ts +0 -28
  414. package/lib/lib.es2018.regexp.d.ts +0 -35
  415. package/lib/lib.es2019.array.d.ts +0 -77
  416. package/lib/lib.es2019.d.ts +0 -22
  417. package/lib/lib.es2019.full.d.ts +0 -22
  418. package/lib/lib.es2019.intl.d.ts +0 -21
  419. package/lib/lib.es2019.object.d.ts +0 -31
  420. package/lib/lib.es2019.string.d.ts +0 -35
  421. package/lib/lib.es2019.symbol.d.ts +0 -22
  422. package/lib/lib.es2020.bigint.d.ts +0 -763
  423. package/lib/lib.es2020.d.ts +0 -25
  424. package/lib/lib.es2020.date.d.ts +0 -40
  425. package/lib/lib.es2020.full.d.ts +0 -22
  426. package/lib/lib.es2020.intl.d.ts +0 -472
  427. package/lib/lib.es2020.number.d.ts +0 -26
  428. package/lib/lib.es2020.promise.d.ts +0 -45
  429. package/lib/lib.es2020.sharedmemory.d.ts +0 -97
  430. package/lib/lib.es2020.string.d.ts +0 -42
  431. package/lib/lib.es2020.symbol.wellknown.d.ts +0 -39
  432. package/lib/lib.es2021.d.ts +0 -21
  433. package/lib/lib.es2021.full.d.ts +0 -22
  434. package/lib/lib.es2021.intl.d.ts +0 -164
  435. package/lib/lib.es2021.promise.d.ts +0 -46
  436. package/lib/lib.es2021.string.d.ts +0 -31
  437. package/lib/lib.es2021.weakref.d.ts +0 -76
  438. package/lib/lib.es2022.array.d.ts +0 -119
  439. package/lib/lib.es2022.d.ts +0 -23
  440. package/lib/lib.es2022.error.d.ts +0 -73
  441. package/lib/lib.es2022.full.d.ts +0 -22
  442. package/lib/lib.es2022.intl.d.ts +0 -143
  443. package/lib/lib.es2022.object.d.ts +0 -24
  444. package/lib/lib.es2022.regexp.d.ts +0 -37
  445. package/lib/lib.es2022.string.d.ts +0 -23
  446. package/lib/lib.es2023.array.d.ts +0 -922
  447. package/lib/lib.es2023.collection.d.ts +0 -19
  448. package/lib/lib.es2023.d.ts +0 -20
  449. package/lib/lib.es2023.full.d.ts +0 -22
  450. package/lib/lib.es2023.intl.d.ts +0 -62
  451. package/lib/lib.es2024.arraybuffer.d.ts +0 -63
  452. package/lib/lib.es2024.collection.d.ts +0 -27
  453. package/lib/lib.es2024.d.ts +0 -24
  454. package/lib/lib.es2024.full.d.ts +0 -22
  455. package/lib/lib.es2024.object.d.ts +0 -27
  456. package/lib/lib.es2024.promise.d.ts +0 -33
  457. package/lib/lib.es2024.regexp.d.ts +0 -23
  458. package/lib/lib.es2024.sharedmemory.d.ts +0 -66
  459. package/lib/lib.es2024.string.d.ts +0 -27
  460. package/lib/lib.es2025.collection.d.ts +0 -94
  461. package/lib/lib.es2025.d.ts +0 -23
  462. package/lib/lib.es2025.float16.d.ts +0 -443
  463. package/lib/lib.es2025.full.d.ts +0 -22
  464. package/lib/lib.es2025.intl.d.ts +0 -200
  465. package/lib/lib.es2025.iterator.d.ts +0 -146
  466. package/lib/lib.es2025.promise.d.ts +0 -32
  467. package/lib/lib.es2025.regexp.d.ts +0 -30
  468. package/lib/lib.es5.d.ts +0 -4599
  469. package/lib/lib.es6.d.ts +0 -21
  470. package/lib/lib.esnext.array.d.ts +0 -33
  471. package/lib/lib.esnext.collection.d.ts +0 -47
  472. package/lib/lib.esnext.d.ts +0 -27
  473. package/lib/lib.esnext.date.d.ts +0 -21
  474. package/lib/lib.esnext.decorators.d.ts +0 -26
  475. package/lib/lib.esnext.disposable.d.ts +0 -191
  476. package/lib/lib.esnext.error.d.ts +0 -22
  477. package/lib/lib.esnext.full.d.ts +0 -22
  478. package/lib/lib.esnext.intl.d.ts +0 -107
  479. package/lib/lib.esnext.sharedmemory.d.ts +0 -23
  480. package/lib/lib.esnext.temporal.d.ts +0 -485
  481. package/lib/lib.esnext.typedarrays.d.ts +0 -90
  482. package/lib/lib.scripthost.d.ts +0 -320
  483. package/lib/lib.webworker.asynciterable.d.ts +0 -18
  484. package/lib/lib.webworker.d.ts +0 -15606
  485. package/lib/lib.webworker.importscripts.d.ts +0 -21
  486. package/lib/lib.webworker.iterable.d.ts +0 -18
  487. package/lib/pl/diagnosticMessages.generated.json +0 -2129
  488. package/lib/pt-br/diagnosticMessages.generated.json +0 -2129
  489. package/lib/ru/diagnosticMessages.generated.json +0 -2125
  490. package/lib/tr/diagnosticMessages.generated.json +0 -2129
  491. package/lib/tsserver.js +0 -8
  492. package/lib/tsserverlibrary.d.ts +0 -17
  493. package/lib/tsserverlibrary.js +0 -21
  494. package/lib/typesMap.json +0 -497
  495. package/lib/typescript.d.ts +0 -11448
  496. package/lib/typescript.js +0 -201039
  497. package/lib/typingsInstaller.js +0 -8
  498. package/lib/watchGuard.js +0 -53
  499. package/lib/zh-cn/diagnosticMessages.generated.json +0 -2129
  500. package/lib/zh-tw/diagnosticMessages.generated.json +0 -2125
@@ -0,0 +1,1276 @@
1
+ "use strict";
2
+ /* --------------------------------------------------------------------------------------------
3
+ * Copyright (c) Microsoft Corporation. All rights reserved.
4
+ * Licensed under the MIT License. See License.txt in the project root for license information.
5
+ * ------------------------------------------------------------------------------------------ */
6
+ /// <reference path="../../typings/thenable.d.ts" preserve="true"/>
7
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
8
+ if (k2 === undefined) k2 = k;
9
+ var desc = Object.getOwnPropertyDescriptor(m, k);
10
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
11
+ desc = { enumerable: true, get: function() { return m[k]; } };
12
+ }
13
+ Object.defineProperty(o, k2, desc);
14
+ }) : (function(o, m, k, k2) {
15
+ if (k2 === undefined) k2 = k;
16
+ o[k2] = m[k];
17
+ }));
18
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
19
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
20
+ }) : function(o, v) {
21
+ o["default"] = v;
22
+ });
23
+ var __importStar = (this && this.__importStar) || (function () {
24
+ var ownKeys = function(o) {
25
+ ownKeys = Object.getOwnPropertyNames || function (o) {
26
+ var ar = [];
27
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
28
+ return ar;
29
+ };
30
+ return ownKeys(o);
31
+ };
32
+ return function (mod) {
33
+ if (mod && mod.__esModule) return mod;
34
+ var result = {};
35
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
36
+ __setModuleDefault(result, mod);
37
+ return result;
38
+ };
39
+ })();
40
+ var __importDefault = (this && this.__importDefault) || function (mod) {
41
+ return (mod && mod.__esModule) ? mod : { "default": mod };
42
+ };
43
+ Object.defineProperty(exports, "__esModule", { value: true });
44
+ exports.ConnectionOptions = exports.MessageStrategy = exports.CancellationStrategy = exports.CancellationSenderStrategy = exports.CancellationReceiverStrategy = exports.RequestCancellationReceiverStrategy = exports.IdCancellationReceiverStrategy = exports.ConnectionStrategy = exports.ConnectionError = exports.ConnectionErrors = exports.LogTraceNotification = exports.SetTraceNotification = exports.TraceFormat = exports.TraceValues = exports.TraceValue = exports.Trace = exports.NullLogger = exports.ProgressType = exports.ProgressToken = void 0;
45
+ exports.createMessageConnection = createMessageConnection;
46
+ const ral_1 = __importDefault(require("./ral"));
47
+ const Is = __importStar(require("./is"));
48
+ const messages_1 = require("./messages");
49
+ const linkedMap_1 = require("./linkedMap");
50
+ const events_1 = require("./events");
51
+ const cancellation_1 = require("./cancellation");
52
+ var CancelNotification;
53
+ (function (CancelNotification) {
54
+ CancelNotification.type = new messages_1.NotificationType('$/cancelRequest');
55
+ })(CancelNotification || (CancelNotification = {}));
56
+ var ProgressToken;
57
+ (function (ProgressToken) {
58
+ function is(value) {
59
+ return typeof value === 'string' || typeof value === 'number';
60
+ }
61
+ ProgressToken.is = is;
62
+ })(ProgressToken || (exports.ProgressToken = ProgressToken = {}));
63
+ var ProgressNotification;
64
+ (function (ProgressNotification) {
65
+ ProgressNotification.type = new messages_1.NotificationType('$/progress');
66
+ })(ProgressNotification || (ProgressNotification = {}));
67
+ class ProgressType {
68
+ /**
69
+ * Clients must not use these properties. They are here to ensure correct typing.
70
+ * in TypeScript
71
+ */
72
+ __;
73
+ _pr;
74
+ constructor() {
75
+ }
76
+ }
77
+ exports.ProgressType = ProgressType;
78
+ var StarRequestHandler;
79
+ (function (StarRequestHandler) {
80
+ function is(value) {
81
+ return Is.func(value);
82
+ }
83
+ StarRequestHandler.is = is;
84
+ })(StarRequestHandler || (StarRequestHandler = {}));
85
+ exports.NullLogger = Object.freeze({
86
+ error: () => { },
87
+ warn: () => { },
88
+ info: () => { },
89
+ log: () => { }
90
+ });
91
+ var Trace;
92
+ (function (Trace) {
93
+ Trace[Trace["Off"] = 0] = "Off";
94
+ Trace[Trace["Messages"] = 1] = "Messages";
95
+ Trace[Trace["Compact"] = 2] = "Compact";
96
+ Trace[Trace["Verbose"] = 3] = "Verbose";
97
+ })(Trace || (exports.Trace = Trace = {}));
98
+ var TraceValue;
99
+ (function (TraceValue) {
100
+ /**
101
+ * Turn tracing off.
102
+ */
103
+ TraceValue.Off = 'off';
104
+ /**
105
+ * Trace messages only.
106
+ */
107
+ TraceValue.Messages = 'messages';
108
+ /**
109
+ * Compact message tracing.
110
+ */
111
+ TraceValue.Compact = 'compact';
112
+ /**
113
+ * Verbose message tracing.
114
+ */
115
+ TraceValue.Verbose = 'verbose';
116
+ })(TraceValue || (exports.TraceValue = TraceValue = {}));
117
+ /**
118
+ * @deprecated Use TraceValue instead
119
+ */
120
+ exports.TraceValues = TraceValue;
121
+ (function (Trace) {
122
+ function fromString(value) {
123
+ if (!Is.string(value)) {
124
+ return Trace.Off;
125
+ }
126
+ value = value.toLowerCase();
127
+ switch (value) {
128
+ case 'off':
129
+ return Trace.Off;
130
+ case 'messages':
131
+ return Trace.Messages;
132
+ case 'compact':
133
+ return Trace.Compact;
134
+ case 'verbose':
135
+ return Trace.Verbose;
136
+ default:
137
+ return Trace.Off;
138
+ }
139
+ }
140
+ Trace.fromString = fromString;
141
+ function toString(value) {
142
+ switch (value) {
143
+ case Trace.Off:
144
+ return 'off';
145
+ case Trace.Messages:
146
+ return 'messages';
147
+ case Trace.Compact:
148
+ return 'compact';
149
+ case Trace.Verbose:
150
+ return 'verbose';
151
+ default:
152
+ return 'off';
153
+ }
154
+ }
155
+ Trace.toString = toString;
156
+ })(Trace || (exports.Trace = Trace = {}));
157
+ var TraceFormat;
158
+ (function (TraceFormat) {
159
+ TraceFormat["Text"] = "text";
160
+ TraceFormat["JSON"] = "json";
161
+ })(TraceFormat || (exports.TraceFormat = TraceFormat = {}));
162
+ (function (TraceFormat) {
163
+ function fromString(value) {
164
+ if (!Is.string(value)) {
165
+ return TraceFormat.Text;
166
+ }
167
+ value = value.toLowerCase();
168
+ if (value === 'json') {
169
+ return TraceFormat.JSON;
170
+ }
171
+ else {
172
+ return TraceFormat.Text;
173
+ }
174
+ }
175
+ TraceFormat.fromString = fromString;
176
+ })(TraceFormat || (exports.TraceFormat = TraceFormat = {}));
177
+ var SetTraceNotification;
178
+ (function (SetTraceNotification) {
179
+ SetTraceNotification.type = new messages_1.NotificationType('$/setTrace');
180
+ })(SetTraceNotification || (exports.SetTraceNotification = SetTraceNotification = {}));
181
+ var LogTraceNotification;
182
+ (function (LogTraceNotification) {
183
+ LogTraceNotification.type = new messages_1.NotificationType('$/logTrace');
184
+ })(LogTraceNotification || (exports.LogTraceNotification = LogTraceNotification = {}));
185
+ var ConnectionErrors;
186
+ (function (ConnectionErrors) {
187
+ /**
188
+ * The connection is closed.
189
+ */
190
+ ConnectionErrors[ConnectionErrors["Closed"] = 1] = "Closed";
191
+ /**
192
+ * The connection got disposed.
193
+ */
194
+ ConnectionErrors[ConnectionErrors["Disposed"] = 2] = "Disposed";
195
+ /**
196
+ * The connection is already in listening mode.
197
+ */
198
+ ConnectionErrors[ConnectionErrors["AlreadyListening"] = 3] = "AlreadyListening";
199
+ })(ConnectionErrors || (exports.ConnectionErrors = ConnectionErrors = {}));
200
+ class ConnectionError extends Error {
201
+ code;
202
+ constructor(code, message) {
203
+ super(message);
204
+ this.code = code;
205
+ Object.setPrototypeOf(this, ConnectionError.prototype);
206
+ }
207
+ }
208
+ exports.ConnectionError = ConnectionError;
209
+ var ConnectionStrategy;
210
+ (function (ConnectionStrategy) {
211
+ function is(value) {
212
+ const candidate = value;
213
+ return candidate && Is.func(candidate.cancelUndispatched);
214
+ }
215
+ ConnectionStrategy.is = is;
216
+ })(ConnectionStrategy || (exports.ConnectionStrategy = ConnectionStrategy = {}));
217
+ var IdCancellationReceiverStrategy;
218
+ (function (IdCancellationReceiverStrategy) {
219
+ function is(value) {
220
+ const candidate = value;
221
+ return candidate && (candidate.kind === undefined || candidate.kind === 'id') && Is.func(candidate.createCancellationTokenSource) && (candidate.dispose === undefined || Is.func(candidate.dispose));
222
+ }
223
+ IdCancellationReceiverStrategy.is = is;
224
+ })(IdCancellationReceiverStrategy || (exports.IdCancellationReceiverStrategy = IdCancellationReceiverStrategy = {}));
225
+ var RequestCancellationReceiverStrategy;
226
+ (function (RequestCancellationReceiverStrategy) {
227
+ function is(value) {
228
+ const candidate = value;
229
+ return candidate && candidate.kind === 'request' && Is.func(candidate.createCancellationTokenSource) && (candidate.dispose === undefined || Is.func(candidate.dispose));
230
+ }
231
+ RequestCancellationReceiverStrategy.is = is;
232
+ })(RequestCancellationReceiverStrategy || (exports.RequestCancellationReceiverStrategy = RequestCancellationReceiverStrategy = {}));
233
+ var CancellationReceiverStrategy;
234
+ (function (CancellationReceiverStrategy) {
235
+ CancellationReceiverStrategy.Message = Object.freeze({
236
+ createCancellationTokenSource(_) {
237
+ return new cancellation_1.CancellationTokenSource();
238
+ }
239
+ });
240
+ function is(value) {
241
+ return IdCancellationReceiverStrategy.is(value) || RequestCancellationReceiverStrategy.is(value);
242
+ }
243
+ CancellationReceiverStrategy.is = is;
244
+ })(CancellationReceiverStrategy || (exports.CancellationReceiverStrategy = CancellationReceiverStrategy = {}));
245
+ var CancellationSenderStrategy;
246
+ (function (CancellationSenderStrategy) {
247
+ CancellationSenderStrategy.Message = Object.freeze({
248
+ sendCancellation(conn, id) {
249
+ return conn.sendNotification(CancelNotification.type, { id });
250
+ },
251
+ cleanup(_) { }
252
+ });
253
+ function is(value) {
254
+ const candidate = value;
255
+ return candidate && Is.func(candidate.sendCancellation) && Is.func(candidate.cleanup);
256
+ }
257
+ CancellationSenderStrategy.is = is;
258
+ })(CancellationSenderStrategy || (exports.CancellationSenderStrategy = CancellationSenderStrategy = {}));
259
+ var CancellationStrategy;
260
+ (function (CancellationStrategy) {
261
+ CancellationStrategy.Message = Object.freeze({
262
+ receiver: CancellationReceiverStrategy.Message,
263
+ sender: CancellationSenderStrategy.Message
264
+ });
265
+ function is(value) {
266
+ const candidate = value;
267
+ return candidate && CancellationReceiverStrategy.is(candidate.receiver) && CancellationSenderStrategy.is(candidate.sender);
268
+ }
269
+ CancellationStrategy.is = is;
270
+ })(CancellationStrategy || (exports.CancellationStrategy = CancellationStrategy = {}));
271
+ var MessageStrategy;
272
+ (function (MessageStrategy) {
273
+ function is(value) {
274
+ const candidate = value;
275
+ return candidate && Is.func(candidate.handleMessage);
276
+ }
277
+ MessageStrategy.is = is;
278
+ })(MessageStrategy || (exports.MessageStrategy = MessageStrategy = {}));
279
+ var ConnectionOptions;
280
+ (function (ConnectionOptions) {
281
+ function is(value) {
282
+ const candidate = value;
283
+ return candidate
284
+ && (CancellationStrategy.is(candidate.cancellationStrategy) || ConnectionStrategy.is(candidate.connectionStrategy) || MessageStrategy.is(candidate.messageStrategy) || Is.number(candidate.maxParallelism));
285
+ }
286
+ ConnectionOptions.is = is;
287
+ })(ConnectionOptions || (exports.ConnectionOptions = ConnectionOptions = {}));
288
+ var ConnectionState;
289
+ (function (ConnectionState) {
290
+ ConnectionState[ConnectionState["New"] = 1] = "New";
291
+ ConnectionState[ConnectionState["Listening"] = 2] = "Listening";
292
+ ConnectionState[ConnectionState["Closed"] = 3] = "Closed";
293
+ ConnectionState[ConnectionState["Disposed"] = 4] = "Disposed";
294
+ })(ConnectionState || (ConnectionState = {}));
295
+ function createMessageConnection(messageReader, messageWriter, _logger, options) {
296
+ const logger = _logger !== undefined ? _logger : exports.NullLogger;
297
+ let sequenceNumber = 0;
298
+ let notificationSequenceNumber = 0;
299
+ let unknownResponseSequenceNumber = 0;
300
+ const version = '2.0';
301
+ const maxParallelism = options?.maxParallelism ?? -1;
302
+ let inFlight = 0;
303
+ let starRequestHandler = undefined;
304
+ const requestHandlers = new Map();
305
+ let starNotificationHandler = undefined;
306
+ const notificationHandlers = new Map();
307
+ const progressHandlers = new Map();
308
+ let timer;
309
+ let messageQueue = new linkedMap_1.LinkedMap();
310
+ let responsePromises = new Map();
311
+ let knownCanceledRequests = new Set();
312
+ let requestTokens = new Map();
313
+ let trace = Trace.Off;
314
+ let traceFormat = TraceFormat.Text;
315
+ let tracer;
316
+ let state = ConnectionState.New;
317
+ const errorEmitter = new events_1.Emitter();
318
+ const closeEmitter = new events_1.Emitter();
319
+ const unhandledNotificationEmitter = new events_1.Emitter();
320
+ const unhandledProgressEmitter = new events_1.Emitter();
321
+ const disposeEmitter = new events_1.Emitter();
322
+ const cancellationStrategy = (options && options.cancellationStrategy) ? options.cancellationStrategy : CancellationStrategy.Message;
323
+ function cancelUndispatched(_message) {
324
+ return undefined;
325
+ }
326
+ function isListening() {
327
+ return state === ConnectionState.Listening;
328
+ }
329
+ function isClosed() {
330
+ return state === ConnectionState.Closed;
331
+ }
332
+ function isDisposed() {
333
+ return state === ConnectionState.Disposed;
334
+ }
335
+ function closeHandler() {
336
+ if (state === ConnectionState.New || state === ConnectionState.Listening) {
337
+ state = ConnectionState.Closed;
338
+ closeEmitter.fire(undefined);
339
+ }
340
+ // If the connection is disposed don't sent close events.
341
+ }
342
+ function readErrorHandler(error) {
343
+ errorEmitter.fire([error, undefined, undefined]);
344
+ }
345
+ function writeErrorHandler(data) {
346
+ errorEmitter.fire(data);
347
+ }
348
+ messageReader.onClose(closeHandler);
349
+ messageReader.onError(readErrorHandler);
350
+ messageWriter.onClose(closeHandler);
351
+ messageWriter.onError(writeErrorHandler);
352
+ function createRequestQueueKey(id) {
353
+ if (id === null) {
354
+ throw new Error(`Can't send requests with id null since the response can't be correlated.`);
355
+ }
356
+ return 'req-' + id.toString();
357
+ }
358
+ function createResponseQueueKey(id) {
359
+ if (id === null) {
360
+ return 'res-unknown-' + (++unknownResponseSequenceNumber).toString();
361
+ }
362
+ else {
363
+ return 'res-' + id.toString();
364
+ }
365
+ }
366
+ function createNotificationQueueKey() {
367
+ return 'not-' + (++notificationSequenceNumber).toString();
368
+ }
369
+ function addMessageToQueue(queue, message) {
370
+ if (messages_1.Message.isRequest(message)) {
371
+ queue.set(createRequestQueueKey(message.id), message);
372
+ }
373
+ else if (messages_1.Message.isResponse(message)) {
374
+ // If we have unlimited parallelism we queue the response to keep
375
+ // the previous semantics.
376
+ if (maxParallelism === -1) {
377
+ queue.set(createResponseQueueKey(message.id), message);
378
+ }
379
+ else {
380
+ // If we have limited parallelism we resolve responses to avoid
381
+ // dead locks.
382
+ handleResponse(message);
383
+ }
384
+ }
385
+ else {
386
+ queue.set(createNotificationQueueKey(), message);
387
+ }
388
+ }
389
+ function triggerMessageQueue() {
390
+ if (timer || messageQueue.size === 0) {
391
+ return;
392
+ }
393
+ if (maxParallelism !== -1 && inFlight >= maxParallelism) {
394
+ return;
395
+ }
396
+ timer = (0, ral_1.default)().timer.setImmediate(async () => {
397
+ timer = undefined;
398
+ if (messageQueue.size === 0) {
399
+ return;
400
+ }
401
+ if (maxParallelism !== -1 && inFlight >= maxParallelism) {
402
+ return;
403
+ }
404
+ const message = messageQueue.shift();
405
+ let result;
406
+ try {
407
+ inFlight++;
408
+ const messageStrategy = options?.messageStrategy;
409
+ if (MessageStrategy.is(messageStrategy)) {
410
+ result = messageStrategy.handleMessage(message, handleMessage);
411
+ }
412
+ else {
413
+ result = handleMessage(message);
414
+ }
415
+ }
416
+ catch (error) {
417
+ logger.error(`Processing message queue failed: ${error.toString()}`);
418
+ }
419
+ finally {
420
+ if (result instanceof Promise) {
421
+ // Both settlements must release the parallelism slot. Written as
422
+ // .then(...).catch(...) the rejection path skipped the decrement, so
423
+ // one failed dispatch left `inFlight` permanently elevated and
424
+ // triggerMessageQueue() bailed out forever after.
425
+ result.then(() => {
426
+ }).catch((error) => {
427
+ logger.error(`Processing message queue failed: ${error.toString()}`);
428
+ }).finally(() => {
429
+ inFlight--;
430
+ triggerMessageQueue();
431
+ });
432
+ }
433
+ else {
434
+ inFlight--;
435
+ }
436
+ triggerMessageQueue();
437
+ }
438
+ });
439
+ }
440
+ async function handleMessage(message) {
441
+ if (messages_1.Message.isRequest(message)) {
442
+ return handleRequest(message);
443
+ }
444
+ else if (messages_1.Message.isNotification(message)) {
445
+ return handleNotification(message);
446
+ }
447
+ else if (messages_1.Message.isResponse(message)) {
448
+ return handleResponse(message);
449
+ }
450
+ else {
451
+ return handleInvalidMessage(message);
452
+ }
453
+ }
454
+ const callback = (message) => {
455
+ try {
456
+ // We have received a cancellation message. Check if the message is still in the queue
457
+ // and cancel it if allowed to do so.
458
+ if (messages_1.Message.isNotification(message) && message.method === CancelNotification.type.method) {
459
+ const cancelId = message.params.id;
460
+ const key = createRequestQueueKey(cancelId);
461
+ const toCancel = messageQueue.get(key);
462
+ if (messages_1.Message.isRequest(toCancel)) {
463
+ const strategy = options?.connectionStrategy;
464
+ const response = (strategy && strategy.cancelUndispatched) ? strategy.cancelUndispatched(toCancel, cancelUndispatched) : cancelUndispatched(toCancel);
465
+ if (response && (response.error !== undefined || response.result !== undefined)) {
466
+ messageQueue.delete(key);
467
+ requestTokens.delete(cancelId);
468
+ response.id = toCancel.id;
469
+ traceSendingResponse(response, message.method, Date.now());
470
+ messageWriter.write(response).catch(() => logger.error(`Sending response for canceled message failed.`));
471
+ return;
472
+ }
473
+ }
474
+ const cancellationToken = requestTokens.get(cancelId);
475
+ // The request is already running. Cancel the token
476
+ if (cancellationToken !== undefined) {
477
+ cancellationToken.cancel();
478
+ traceReceivedNotification(message);
479
+ return;
480
+ }
481
+ else {
482
+ // Remember the cancel but still queue the message to
483
+ // clean up state in process message.
484
+ knownCanceledRequests.add(cancelId);
485
+ }
486
+ }
487
+ addMessageToQueue(messageQueue, message);
488
+ }
489
+ finally {
490
+ triggerMessageQueue();
491
+ }
492
+ };
493
+ async function handleRequest(requestMessage) {
494
+ if (isDisposed()) {
495
+ // we return here silently since we fired an event when the
496
+ // connection got disposed.
497
+ return Promise.resolve();
498
+ }
499
+ function reply(resultOrError, method, startTime) {
500
+ const message = {
501
+ jsonrpc: version,
502
+ id: requestMessage.id
503
+ };
504
+ if (resultOrError instanceof messages_1.ResponseError) {
505
+ message.error = resultOrError.toJson();
506
+ }
507
+ else {
508
+ message.result = resultOrError === undefined ? null : resultOrError;
509
+ }
510
+ traceSendingResponse(message, method, startTime);
511
+ return messageWriter.write(message);
512
+ }
513
+ function replyError(error, method, startTime) {
514
+ const message = {
515
+ jsonrpc: version,
516
+ id: requestMessage.id,
517
+ error: error.toJson()
518
+ };
519
+ traceSendingResponse(message, method, startTime);
520
+ return messageWriter.write(message);
521
+ }
522
+ traceReceivedRequest(requestMessage);
523
+ const element = requestHandlers.get(requestMessage.method);
524
+ let type;
525
+ let requestHandler;
526
+ if (element) {
527
+ type = element.type;
528
+ requestHandler = element.handler;
529
+ }
530
+ const startTime = Date.now();
531
+ if (requestHandler || starRequestHandler) {
532
+ const tokenKey = requestMessage.id ?? String(Date.now()); //
533
+ const cancellationSource = IdCancellationReceiverStrategy.is(cancellationStrategy.receiver)
534
+ ? cancellationStrategy.receiver.createCancellationTokenSource(tokenKey)
535
+ : cancellationStrategy.receiver.createCancellationTokenSource(requestMessage);
536
+ if (requestMessage.id !== null && knownCanceledRequests.has(requestMessage.id)) {
537
+ cancellationSource.cancel();
538
+ }
539
+ if (requestMessage.id !== null) {
540
+ requestTokens.set(tokenKey, cancellationSource);
541
+ }
542
+ try {
543
+ let handlerResult;
544
+ if (requestHandler) {
545
+ if (requestMessage.params === undefined) {
546
+ if (type !== undefined && type.numberOfParams !== 0) {
547
+ return replyError(new messages_1.ResponseError(messages_1.ErrorCodes.InvalidParams, `Request ${requestMessage.method} defines ${type.numberOfParams} params but received none.`), requestMessage.method, startTime);
548
+ }
549
+ handlerResult = requestHandler(cancellationSource.token);
550
+ }
551
+ else if (Array.isArray(requestMessage.params)) {
552
+ if (type !== undefined && type.parameterStructures === messages_1.ParameterStructures.byName) {
553
+ return replyError(new messages_1.ResponseError(messages_1.ErrorCodes.InvalidParams, `Request ${requestMessage.method} defines parameters by name but received parameters by position`), requestMessage.method, startTime);
554
+ }
555
+ handlerResult = requestHandler(...requestMessage.params, cancellationSource.token);
556
+ }
557
+ else {
558
+ if (type !== undefined && type.parameterStructures === messages_1.ParameterStructures.byPosition) {
559
+ return replyError(new messages_1.ResponseError(messages_1.ErrorCodes.InvalidParams, `Request ${requestMessage.method} defines parameters by position but received parameters by name`), requestMessage.method, startTime);
560
+ }
561
+ handlerResult = requestHandler(requestMessage.params, cancellationSource.token);
562
+ }
563
+ }
564
+ else if (starRequestHandler) {
565
+ handlerResult = starRequestHandler(requestMessage.method, requestMessage.params, cancellationSource.token);
566
+ }
567
+ const resultOrError = await handlerResult;
568
+ await reply(resultOrError, requestMessage.method, startTime);
569
+ }
570
+ catch (error) {
571
+ if (error instanceof messages_1.ResponseError) {
572
+ await reply(error, requestMessage.method, startTime);
573
+ }
574
+ else if (error && Is.string(error.message)) {
575
+ await replyError(new messages_1.ResponseError(messages_1.ErrorCodes.InternalError, `Request ${requestMessage.method} failed with message: ${error.message}`), requestMessage.method, startTime);
576
+ }
577
+ else {
578
+ await replyError(new messages_1.ResponseError(messages_1.ErrorCodes.InternalError, `Request ${requestMessage.method} failed unexpectedly without providing any details.`), requestMessage.method, startTime);
579
+ }
580
+ }
581
+ finally {
582
+ requestTokens.delete(tokenKey);
583
+ }
584
+ }
585
+ else {
586
+ await replyError(new messages_1.ResponseError(messages_1.ErrorCodes.MethodNotFound, `Unhandled method ${requestMessage.method}`), requestMessage.method, startTime);
587
+ }
588
+ }
589
+ function handleResponse(responseMessage) {
590
+ if (isDisposed()) {
591
+ // See handle request.
592
+ return;
593
+ }
594
+ if (responseMessage.id === null) {
595
+ if (responseMessage.error) {
596
+ logger.error(`Received response message without id: Error is: \n${JSON.stringify(responseMessage.error, undefined, 4)}`);
597
+ }
598
+ else {
599
+ logger.error(`Received response message without id. No further error information provided.`);
600
+ }
601
+ }
602
+ else {
603
+ const key = responseMessage.id;
604
+ const responsePromise = responsePromises.get(key);
605
+ traceReceivedResponse(responseMessage, responsePromise);
606
+ if (responsePromise !== undefined) {
607
+ responsePromises.delete(key);
608
+ try {
609
+ if (responseMessage.error) {
610
+ const error = responseMessage.error;
611
+ responsePromise.reject(new messages_1.ResponseError(error.code, error.message, error.data));
612
+ }
613
+ else if (responseMessage.result !== undefined) {
614
+ responsePromise.resolve(responseMessage.result);
615
+ }
616
+ else {
617
+ throw new Error('Should never happen.');
618
+ }
619
+ }
620
+ catch (error) {
621
+ if (error.message) {
622
+ logger.error(`Response handler '${responsePromise.method}' failed with message: ${error.message}`);
623
+ }
624
+ else {
625
+ logger.error(`Response handler '${responsePromise.method}' failed unexpectedly.`);
626
+ }
627
+ }
628
+ }
629
+ }
630
+ }
631
+ async function handleNotification(message) {
632
+ if (isDisposed()) {
633
+ // See handle request.
634
+ return;
635
+ }
636
+ let type = undefined;
637
+ let notificationHandler;
638
+ if (message.method === CancelNotification.type.method) {
639
+ const cancelId = message.params.id;
640
+ knownCanceledRequests.delete(cancelId);
641
+ traceReceivedNotification(message);
642
+ return;
643
+ }
644
+ else {
645
+ const element = notificationHandlers.get(message.method);
646
+ if (element) {
647
+ notificationHandler = element.handler;
648
+ type = element.type;
649
+ }
650
+ }
651
+ if (notificationHandler || starNotificationHandler) {
652
+ try {
653
+ traceReceivedNotification(message);
654
+ if (notificationHandler) {
655
+ if (message.params === undefined) {
656
+ if (type !== undefined) {
657
+ if (type.numberOfParams !== 0 && type.parameterStructures !== messages_1.ParameterStructures.byName) {
658
+ logger.error(`Notification ${message.method} defines ${type.numberOfParams} params but received none.`);
659
+ }
660
+ }
661
+ await notificationHandler();
662
+ }
663
+ else if (Array.isArray(message.params)) {
664
+ // There are JSON-RPC libraries that send progress message as positional params although
665
+ // specified as named. So convert them if this is the case.
666
+ const params = message.params;
667
+ if (message.method === ProgressNotification.type.method && params.length === 2 && ProgressToken.is(params[0])) {
668
+ await notificationHandler({ token: params[0], value: params[1] });
669
+ }
670
+ else {
671
+ if (type !== undefined) {
672
+ if (type.parameterStructures === messages_1.ParameterStructures.byName) {
673
+ logger.error(`Notification ${message.method} defines parameters by name but received parameters by position`);
674
+ }
675
+ if (type.numberOfParams !== message.params.length) {
676
+ logger.error(`Notification ${message.method} defines ${type.numberOfParams} params but received ${params.length} arguments`);
677
+ }
678
+ }
679
+ await notificationHandler(...params);
680
+ }
681
+ }
682
+ else {
683
+ if (type !== undefined && type.parameterStructures === messages_1.ParameterStructures.byPosition) {
684
+ logger.error(`Notification ${message.method} defines parameters by position but received parameters by name`);
685
+ }
686
+ await notificationHandler(message.params);
687
+ }
688
+ }
689
+ else if (starNotificationHandler) {
690
+ await starNotificationHandler(message.method, message.params);
691
+ }
692
+ }
693
+ catch (error) {
694
+ if (error.message) {
695
+ logger.error(`Notification handler '${message.method}' failed with message: ${error.message}`);
696
+ }
697
+ else {
698
+ logger.error(`Notification handler '${message.method}' failed unexpectedly.`);
699
+ }
700
+ }
701
+ }
702
+ else {
703
+ unhandledNotificationEmitter.fire(message);
704
+ }
705
+ }
706
+ function handleInvalidMessage(message) {
707
+ if (!message) {
708
+ logger.error('Received empty message.');
709
+ return;
710
+ }
711
+ logger.error(`Received message which is neither a response nor a notification message:\n${JSON.stringify(message, null, 4)}`);
712
+ // Test whether we find an id to reject the promise
713
+ const responseMessage = message;
714
+ if (Is.string(responseMessage.id) || Is.number(responseMessage.id)) {
715
+ const key = responseMessage.id;
716
+ const responseHandler = responsePromises.get(key);
717
+ if (responseHandler) {
718
+ responseHandler.reject(new Error('The received response has neither a result nor an error property.'));
719
+ }
720
+ }
721
+ }
722
+ function stringifyTrace(params) {
723
+ if (params === undefined || params === null) {
724
+ return undefined;
725
+ }
726
+ switch (trace) {
727
+ case Trace.Verbose:
728
+ return JSON.stringify(params, null, 4);
729
+ case Trace.Compact:
730
+ return JSON.stringify(params);
731
+ default:
732
+ return undefined;
733
+ }
734
+ }
735
+ function traceSendingRequest(message) {
736
+ if (trace === Trace.Off || !tracer) {
737
+ return;
738
+ }
739
+ if (traceFormat === TraceFormat.Text) {
740
+ let data = undefined;
741
+ if ((trace === Trace.Verbose || trace === Trace.Compact) && message.params) {
742
+ data = `Params: ${stringifyTrace(message.params)}`;
743
+ }
744
+ tracer.log(`Sending request '${message.method} - (${message.id})'.`, data);
745
+ }
746
+ else {
747
+ logLSPMessage('send-request', message);
748
+ }
749
+ }
750
+ function traceSendingNotification(message) {
751
+ if (trace === Trace.Off || !tracer) {
752
+ return;
753
+ }
754
+ if (traceFormat === TraceFormat.Text) {
755
+ let data = undefined;
756
+ if (trace === Trace.Verbose || trace === Trace.Compact) {
757
+ if (message.params) {
758
+ data = `Params: ${stringifyTrace(message.params)}`;
759
+ }
760
+ else {
761
+ data = 'No parameters provided.';
762
+ }
763
+ }
764
+ tracer.log(`Sending notification '${message.method}'.`, data);
765
+ }
766
+ else {
767
+ logLSPMessage('send-notification', message);
768
+ }
769
+ }
770
+ function traceSendingResponse(message, method, startTime) {
771
+ if (trace === Trace.Off || !tracer) {
772
+ return;
773
+ }
774
+ if (traceFormat === TraceFormat.Text) {
775
+ let data = undefined;
776
+ if (trace === Trace.Verbose || trace === Trace.Compact) {
777
+ if (message.error && message.error.data) {
778
+ data = `Error data: ${stringifyTrace(message.error.data)}`;
779
+ }
780
+ else {
781
+ if (message.result) {
782
+ data = `Result: ${stringifyTrace(message.result)}`;
783
+ }
784
+ else if (message.error === undefined) {
785
+ data = 'No result returned.';
786
+ }
787
+ }
788
+ }
789
+ const error = message.error ? ` Request failed: ${message.error.message} (${message.error.code}).` : '';
790
+ tracer.log(`Sending response '${method} - (${message.id})'. Processing request took ${Date.now() - startTime}ms.${error}`, data);
791
+ }
792
+ else {
793
+ logLSPMessage('send-response', message);
794
+ }
795
+ }
796
+ function traceReceivedRequest(message) {
797
+ if (trace === Trace.Off || !tracer) {
798
+ return;
799
+ }
800
+ if (traceFormat === TraceFormat.Text) {
801
+ let data = undefined;
802
+ if ((trace === Trace.Verbose || trace === Trace.Compact) && message.params) {
803
+ data = `Params: ${stringifyTrace(message.params)}`;
804
+ }
805
+ tracer.log(`Received request '${message.method} - (${message.id})'.`, data);
806
+ }
807
+ else {
808
+ logLSPMessage('receive-request', message);
809
+ }
810
+ }
811
+ function traceReceivedNotification(message) {
812
+ if (trace === Trace.Off || !tracer || message.method === LogTraceNotification.type.method) {
813
+ return;
814
+ }
815
+ if (traceFormat === TraceFormat.Text) {
816
+ let data = undefined;
817
+ if (trace === Trace.Verbose || trace === Trace.Compact) {
818
+ if (message.params) {
819
+ data = `Params: ${stringifyTrace(message.params)}`;
820
+ }
821
+ else {
822
+ data = 'No parameters provided.';
823
+ }
824
+ }
825
+ tracer.log(`Received notification '${message.method}'.`, data);
826
+ }
827
+ else {
828
+ logLSPMessage('receive-notification', message);
829
+ }
830
+ }
831
+ function traceReceivedResponse(message, responsePromise) {
832
+ if (trace === Trace.Off || !tracer) {
833
+ return;
834
+ }
835
+ if (traceFormat === TraceFormat.Text) {
836
+ let data = undefined;
837
+ if (trace === Trace.Verbose || trace === Trace.Compact) {
838
+ if (message.error && message.error.data) {
839
+ data = `Error data: ${stringifyTrace(message.error.data)}`;
840
+ }
841
+ else {
842
+ if (message.result) {
843
+ data = `Result: ${stringifyTrace(message.result)}`;
844
+ }
845
+ else if (message.error === undefined) {
846
+ data = 'No result returned.';
847
+ }
848
+ }
849
+ }
850
+ if (responsePromise) {
851
+ const error = message.error ? ` Request failed: ${message.error.message} (${message.error.code}).` : '';
852
+ tracer.log(`Received response '${responsePromise.method} - (${message.id})' in ${Date.now() - responsePromise.timerStart}ms.${error}`, data);
853
+ }
854
+ else {
855
+ tracer.log(`Received response ${message.id} without active response promise.`, data);
856
+ }
857
+ }
858
+ else {
859
+ logLSPMessage('receive-response', message);
860
+ }
861
+ }
862
+ function logLSPMessage(type, message) {
863
+ if (!tracer || trace === Trace.Off) {
864
+ return;
865
+ }
866
+ const lspMessage = {
867
+ isLSPMessage: true,
868
+ type,
869
+ message,
870
+ timestamp: Date.now()
871
+ };
872
+ tracer.log(lspMessage);
873
+ }
874
+ function throwIfClosedOrDisposed() {
875
+ if (isClosed()) {
876
+ throw new ConnectionError(ConnectionErrors.Closed, 'Connection is closed.');
877
+ }
878
+ if (isDisposed()) {
879
+ throw new ConnectionError(ConnectionErrors.Disposed, 'Connection is disposed.');
880
+ }
881
+ }
882
+ function throwIfListening() {
883
+ if (isListening()) {
884
+ throw new ConnectionError(ConnectionErrors.AlreadyListening, 'Connection is already listening');
885
+ }
886
+ }
887
+ function throwIfNotListening() {
888
+ if (!isListening()) {
889
+ throw new Error('Call listen() first.');
890
+ }
891
+ }
892
+ function undefinedToNull(param) {
893
+ if (param === undefined) {
894
+ return null;
895
+ }
896
+ else {
897
+ return param;
898
+ }
899
+ }
900
+ function nullToUndefined(param) {
901
+ if (param === null) {
902
+ return undefined;
903
+ }
904
+ else {
905
+ return param;
906
+ }
907
+ }
908
+ function isNamedParam(param) {
909
+ return param !== undefined && param !== null && !Array.isArray(param) && typeof param === 'object';
910
+ }
911
+ function computeSingleParam(parameterStructures, param) {
912
+ switch (parameterStructures) {
913
+ case messages_1.ParameterStructures.auto:
914
+ if (isNamedParam(param)) {
915
+ return nullToUndefined(param);
916
+ }
917
+ else {
918
+ return [undefinedToNull(param)];
919
+ }
920
+ case messages_1.ParameterStructures.byName:
921
+ if (!isNamedParam(param)) {
922
+ throw new Error(`Received parameters by name but param is not an object literal.`);
923
+ }
924
+ return nullToUndefined(param);
925
+ case messages_1.ParameterStructures.byPosition:
926
+ return [undefinedToNull(param)];
927
+ default:
928
+ throw new Error(`Unknown parameter structure ${parameterStructures.toString()}`);
929
+ }
930
+ }
931
+ function computeMessageParams(type, params) {
932
+ let result;
933
+ const numberOfParams = type.numberOfParams;
934
+ switch (numberOfParams) {
935
+ case 0:
936
+ result = undefined;
937
+ break;
938
+ case 1:
939
+ result = computeSingleParam(type.parameterStructures, params[0]);
940
+ break;
941
+ default:
942
+ result = [];
943
+ for (let i = 0; i < params.length && i < numberOfParams; i++) {
944
+ result.push(undefinedToNull(params[i]));
945
+ }
946
+ if (params.length < numberOfParams) {
947
+ for (let i = params.length; i < numberOfParams; i++) {
948
+ result.push(null);
949
+ }
950
+ }
951
+ break;
952
+ }
953
+ return result;
954
+ }
955
+ const connection = {
956
+ sendNotification: (type, ...args) => {
957
+ throwIfClosedOrDisposed();
958
+ let method;
959
+ let messageParams;
960
+ if (Is.string(type)) {
961
+ method = type;
962
+ const first = args[0];
963
+ let paramStart = 0;
964
+ let parameterStructures = messages_1.ParameterStructures.auto;
965
+ if (messages_1.ParameterStructures.is(first)) {
966
+ paramStart = 1;
967
+ parameterStructures = first;
968
+ }
969
+ const paramEnd = args.length;
970
+ const numberOfParams = paramEnd - paramStart;
971
+ switch (numberOfParams) {
972
+ case 0:
973
+ messageParams = undefined;
974
+ break;
975
+ case 1:
976
+ messageParams = computeSingleParam(parameterStructures, args[paramStart]);
977
+ break;
978
+ default:
979
+ if (parameterStructures === messages_1.ParameterStructures.byName) {
980
+ throw new Error(`Received ${numberOfParams} parameters for 'by Name' notification parameter structure.`);
981
+ }
982
+ messageParams = args.slice(paramStart, paramEnd).map(value => undefinedToNull(value));
983
+ break;
984
+ }
985
+ }
986
+ else {
987
+ const params = args;
988
+ method = type.method;
989
+ messageParams = computeMessageParams(type, params);
990
+ }
991
+ const notificationMessage = {
992
+ jsonrpc: version,
993
+ method: method,
994
+ params: messageParams
995
+ };
996
+ traceSendingNotification(notificationMessage);
997
+ return messageWriter.write(notificationMessage).catch((error) => {
998
+ logger.error(`Sending notification failed.`);
999
+ throw error;
1000
+ });
1001
+ },
1002
+ onNotification: (type, handler) => {
1003
+ throwIfClosedOrDisposed();
1004
+ let method;
1005
+ if (Is.func(type)) {
1006
+ starNotificationHandler = type;
1007
+ }
1008
+ else if (handler) {
1009
+ if (Is.string(type)) {
1010
+ method = type;
1011
+ notificationHandlers.set(type, { type: undefined, handler });
1012
+ }
1013
+ else {
1014
+ method = type.method;
1015
+ notificationHandlers.set(type.method, { type, handler });
1016
+ }
1017
+ }
1018
+ return {
1019
+ dispose: () => {
1020
+ if (method !== undefined) {
1021
+ if (notificationHandlers.get(method)?.handler === handler) {
1022
+ notificationHandlers.delete(method);
1023
+ }
1024
+ }
1025
+ else if (starNotificationHandler === type) {
1026
+ starNotificationHandler = undefined;
1027
+ }
1028
+ }
1029
+ };
1030
+ },
1031
+ onProgress: (_type, token, handler) => {
1032
+ if (progressHandlers.has(token)) {
1033
+ throw new Error(`Progress handler for token ${token} already registered`);
1034
+ }
1035
+ progressHandlers.set(token, handler);
1036
+ return {
1037
+ dispose: () => {
1038
+ if (progressHandlers.get(token) === handler) {
1039
+ progressHandlers.delete(token);
1040
+ }
1041
+ }
1042
+ };
1043
+ },
1044
+ sendProgress: (_type, token, value) => {
1045
+ // This should not await but simple return to ensure that we don't have another
1046
+ // async scheduling. Otherwise one send could overtake another send.
1047
+ return connection.sendNotification(ProgressNotification.type, { token, value });
1048
+ },
1049
+ onUnhandledProgress: unhandledProgressEmitter.event,
1050
+ sendRequest: (type, ...args) => {
1051
+ throwIfClosedOrDisposed();
1052
+ throwIfNotListening();
1053
+ function sendCancellation(connection, id) {
1054
+ const p = cancellationStrategy.sender.sendCancellation(connection, id);
1055
+ if (p === undefined) {
1056
+ logger.log(`Received no promise from cancellation strategy when cancelling id ${id}`);
1057
+ }
1058
+ else {
1059
+ p.catch(() => {
1060
+ logger.log(`Sending cancellation messages for id ${id} failed.`);
1061
+ });
1062
+ }
1063
+ }
1064
+ let method;
1065
+ let messageParams;
1066
+ let token = undefined;
1067
+ if (Is.string(type)) {
1068
+ method = type;
1069
+ const first = args[0];
1070
+ const last = args[args.length - 1];
1071
+ let paramStart = 0;
1072
+ let parameterStructures = messages_1.ParameterStructures.auto;
1073
+ if (messages_1.ParameterStructures.is(first)) {
1074
+ paramStart = 1;
1075
+ parameterStructures = first;
1076
+ }
1077
+ let paramEnd = args.length;
1078
+ if (cancellation_1.CancellationToken.is(last)) {
1079
+ paramEnd = paramEnd - 1;
1080
+ token = last;
1081
+ }
1082
+ const numberOfParams = paramEnd - paramStart;
1083
+ switch (numberOfParams) {
1084
+ case 0:
1085
+ messageParams = undefined;
1086
+ break;
1087
+ case 1:
1088
+ messageParams = computeSingleParam(parameterStructures, args[paramStart]);
1089
+ break;
1090
+ default:
1091
+ if (parameterStructures === messages_1.ParameterStructures.byName) {
1092
+ throw new Error(`Received ${numberOfParams} parameters for 'by Name' request parameter structure.`);
1093
+ }
1094
+ messageParams = args.slice(paramStart, paramEnd).map(value => undefinedToNull(value));
1095
+ break;
1096
+ }
1097
+ }
1098
+ else {
1099
+ const params = args;
1100
+ method = type.method;
1101
+ messageParams = computeMessageParams(type, params);
1102
+ const numberOfParams = type.numberOfParams;
1103
+ token = cancellation_1.CancellationToken.is(params[numberOfParams]) ? params[numberOfParams] : undefined;
1104
+ }
1105
+ const id = sequenceNumber++;
1106
+ let disposable;
1107
+ let tokenWasCancelled = false;
1108
+ if (token !== undefined) {
1109
+ if (token.isCancellationRequested) {
1110
+ tokenWasCancelled = true;
1111
+ }
1112
+ else {
1113
+ disposable = token.onCancellationRequested(() => {
1114
+ sendCancellation(connection, id);
1115
+ });
1116
+ }
1117
+ }
1118
+ const requestMessage = {
1119
+ jsonrpc: version,
1120
+ id: id,
1121
+ method: method,
1122
+ params: messageParams
1123
+ };
1124
+ traceSendingRequest(requestMessage);
1125
+ if (typeof cancellationStrategy.sender.enableCancellation === 'function') {
1126
+ cancellationStrategy.sender.enableCancellation(requestMessage);
1127
+ }
1128
+ // eslint-disable-next-line no-async-promise-executor
1129
+ return new Promise(async (resolve, reject) => {
1130
+ const resolveWithCleanup = (r) => {
1131
+ resolve(r);
1132
+ cancellationStrategy.sender.cleanup(id);
1133
+ disposable?.dispose();
1134
+ };
1135
+ const rejectWithCleanup = (r) => {
1136
+ reject(r);
1137
+ cancellationStrategy.sender.cleanup(id);
1138
+ disposable?.dispose();
1139
+ };
1140
+ const responsePromise = { method: method, timerStart: Date.now(), resolve: resolveWithCleanup, reject: rejectWithCleanup };
1141
+ try {
1142
+ responsePromises.set(id, responsePromise);
1143
+ await messageWriter.write(requestMessage);
1144
+ if (tokenWasCancelled) {
1145
+ sendCancellation(connection, id);
1146
+ }
1147
+ }
1148
+ catch (error) {
1149
+ // Writing the message failed. So we need to delete it from the response promises and
1150
+ // reject it.
1151
+ responsePromises.delete(id);
1152
+ responsePromise.reject(new messages_1.ResponseError(messages_1.ErrorCodes.MessageWriteError, error.message ? error.message : 'Unknown reason'));
1153
+ logger.error(`Sending request failed.`);
1154
+ }
1155
+ });
1156
+ },
1157
+ onRequest: (type, handler) => {
1158
+ throwIfClosedOrDisposed();
1159
+ let method = null;
1160
+ if (StarRequestHandler.is(type)) {
1161
+ method = undefined;
1162
+ starRequestHandler = type;
1163
+ }
1164
+ else if (Is.string(type)) {
1165
+ method = null;
1166
+ if (handler !== undefined) {
1167
+ method = type;
1168
+ requestHandlers.set(type, { handler: handler, type: undefined });
1169
+ }
1170
+ }
1171
+ else {
1172
+ if (handler !== undefined) {
1173
+ method = type.method;
1174
+ requestHandlers.set(type.method, { type, handler });
1175
+ }
1176
+ }
1177
+ return {
1178
+ dispose: () => {
1179
+ if (method === null) {
1180
+ return;
1181
+ }
1182
+ if (method !== undefined) {
1183
+ if (requestHandlers.get(method)?.handler === handler) {
1184
+ requestHandlers.delete(method);
1185
+ }
1186
+ }
1187
+ else if (starRequestHandler === type) {
1188
+ starRequestHandler = undefined;
1189
+ }
1190
+ }
1191
+ };
1192
+ },
1193
+ hasPendingResponse: () => {
1194
+ return responsePromises.size > 0;
1195
+ },
1196
+ trace: async (_value, _tracer, sendNotificationOrTraceOptions) => {
1197
+ let _sendNotification = false;
1198
+ let _traceFormat = TraceFormat.Text;
1199
+ if (sendNotificationOrTraceOptions !== undefined) {
1200
+ if (Is.boolean(sendNotificationOrTraceOptions)) {
1201
+ _sendNotification = sendNotificationOrTraceOptions;
1202
+ }
1203
+ else {
1204
+ _sendNotification = sendNotificationOrTraceOptions.sendNotification || false;
1205
+ _traceFormat = sendNotificationOrTraceOptions.traceFormat || TraceFormat.Text;
1206
+ }
1207
+ }
1208
+ trace = _value;
1209
+ traceFormat = _traceFormat;
1210
+ if (trace === Trace.Off) {
1211
+ tracer = undefined;
1212
+ }
1213
+ else {
1214
+ tracer = _tracer;
1215
+ }
1216
+ if (_sendNotification && !isClosed() && !isDisposed()) {
1217
+ await connection.sendNotification(SetTraceNotification.type, { value: Trace.toString(_value) });
1218
+ }
1219
+ },
1220
+ onError: errorEmitter.event,
1221
+ onClose: closeEmitter.event,
1222
+ onUnhandledNotification: unhandledNotificationEmitter.event,
1223
+ onDispose: disposeEmitter.event,
1224
+ end: () => {
1225
+ messageWriter.end();
1226
+ },
1227
+ dispose: () => {
1228
+ if (isDisposed()) {
1229
+ return;
1230
+ }
1231
+ state = ConnectionState.Disposed;
1232
+ disposeEmitter.fire(undefined);
1233
+ const error = new messages_1.ResponseError(messages_1.ErrorCodes.PendingResponseRejected, 'Pending response rejected since connection got disposed');
1234
+ for (const promise of responsePromises.values()) {
1235
+ promise.reject(error);
1236
+ }
1237
+ responsePromises = new Map();
1238
+ requestTokens = new Map();
1239
+ knownCanceledRequests = new Set();
1240
+ messageQueue = new linkedMap_1.LinkedMap();
1241
+ // Test for backwards compatibility
1242
+ if (Is.func(messageWriter.dispose)) {
1243
+ messageWriter.dispose();
1244
+ }
1245
+ if (Is.func(messageReader.dispose)) {
1246
+ messageReader.dispose();
1247
+ }
1248
+ },
1249
+ listen: () => {
1250
+ throwIfClosedOrDisposed();
1251
+ throwIfListening();
1252
+ state = ConnectionState.Listening;
1253
+ messageReader.listen(callback);
1254
+ },
1255
+ inspect: () => {
1256
+ (0, ral_1.default)().console.log('inspect');
1257
+ }
1258
+ };
1259
+ connection.onNotification(LogTraceNotification.type, (params) => {
1260
+ if (trace === Trace.Off || !tracer) {
1261
+ return;
1262
+ }
1263
+ const verbose = trace === Trace.Verbose || trace === Trace.Compact;
1264
+ tracer.log(params.message, verbose ? params.verbose : undefined);
1265
+ });
1266
+ connection.onNotification(ProgressNotification.type, async (params) => {
1267
+ const handler = progressHandlers.get(params.token);
1268
+ if (handler) {
1269
+ await handler(params.value);
1270
+ }
1271
+ else {
1272
+ unhandledProgressEmitter.fire(params);
1273
+ }
1274
+ });
1275
+ return connection;
1276
+ }