@codingame/monaco-vscode-api 12.0.1 → 13.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (229) hide show
  1. package/README.md +3 -4
  2. package/extensions.d.ts +2 -0
  3. package/extensions.js +6 -3
  4. package/missing-services.js +2 -2
  5. package/package.json +12 -335
  6. package/services.d.ts +5 -0
  7. package/services.js +6 -2
  8. package/vscode/src/vs/base/browser/dom.d.ts +1 -1
  9. package/vscode/src/vs/base/common/observableInternal/index.js +8 -0
  10. package/vscode/src/vs/editor/browser/gpu/gpuUtils.d.ts +1 -1
  11. package/vscode/src/vs/editor/common/tokens/contiguousTokensEditing.d.ts +1 -1
  12. package/vscode/src/vs/editor/contrib/snippet/browser/snippetParser.d.ts +1 -1
  13. package/vscode/src/vs/editor/contrib/snippet/browser/snippetSession.d.ts +1 -1
  14. package/vscode/src/vs/platform/accessibilitySignal/browser/accessibilitySignalService.service.d.ts +1 -1
  15. package/vscode/src/vs/platform/contextview/browser/contextView.service.d.ts +4 -5
  16. package/vscode/src/vs/platform/diagnostics/common/diagnostics.service.d.ts +1 -1
  17. package/vscode/src/vs/platform/dialogs/common/dialogs.service.d.ts +2 -3
  18. package/vscode/src/vs/platform/environment/common/environment.service.d.ts +1 -1
  19. package/vscode/src/vs/platform/extensionManagement/common/extensionManagement.service.d.ts +4 -6
  20. package/vscode/src/vs/platform/extensionManagement/common/extensionStorage.service.d.ts +1 -1
  21. package/vscode/src/vs/platform/extensionManagement/common/extensionsProfileScannerService.service.d.ts +1 -1
  22. package/vscode/src/vs/platform/extensionManagement/common/extensionsScannerService.service.d.ts +2 -2
  23. package/vscode/src/vs/platform/extensions/common/extensions.d.ts +1 -0
  24. package/vscode/src/vs/platform/hover/browser/hover.d.ts +1 -1
  25. package/vscode/src/vs/platform/hover/browser/hover.service.d.ts +1 -1
  26. package/vscode/src/vs/platform/instantiation/common/extensions.d.ts +1 -0
  27. package/vscode/src/vs/platform/ipc/common/services.d.ts +1 -1
  28. package/vscode/src/vs/platform/keybinding/common/keybinding.service.d.ts +2 -2
  29. package/vscode/src/vs/platform/keyboardLayout/common/keyboardLayout.service.d.ts +1 -1
  30. package/vscode/src/vs/platform/label/common/label.service.d.ts +1 -1
  31. package/vscode/src/vs/platform/log/common/log.d.ts +1 -2
  32. package/vscode/src/vs/platform/log/common/log.service.d.ts +3 -3
  33. package/vscode/src/vs/platform/progress/common/progress.service.d.ts +1 -2
  34. package/vscode/src/vs/platform/remote/common/remoteSocketFactoryService.service.d.ts +1 -1
  35. package/vscode/src/vs/platform/request/common/request.service.d.ts +1 -1
  36. package/vscode/src/vs/platform/sign/common/sign.service.d.ts +1 -1
  37. package/vscode/src/vs/platform/telemetry/common/commonProperties.js +15 -0
  38. package/vscode/src/vs/platform/telemetry/common/telemetry.js +4 -1
  39. package/vscode/src/vs/platform/telemetry/common/telemetry.service.d.ts +2 -3
  40. package/vscode/src/vs/platform/telemetry/common/telemetryUtils.js +82 -6
  41. package/vscode/src/vs/platform/terminal/common/terminal.service.d.ts +4 -5
  42. package/vscode/src/vs/platform/theme/common/colorUtils.js +2 -2
  43. package/vscode/src/vs/platform/theme/common/colors/baseColors.js +17 -17
  44. package/vscode/src/vs/platform/theme/common/colors/chartsColors.js +8 -8
  45. package/vscode/src/vs/platform/theme/common/colors/editorColors.js +94 -94
  46. package/vscode/src/vs/platform/theme/common/colors/inputColors.js +45 -45
  47. package/vscode/src/vs/platform/theme/common/colors/listColors.js +36 -36
  48. package/vscode/src/vs/platform/theme/common/colors/menuColors.js +7 -7
  49. package/vscode/src/vs/platform/theme/common/colors/minimapColors.js +11 -11
  50. package/vscode/src/vs/platform/theme/common/colors/miscColors.js +15 -15
  51. package/vscode/src/vs/platform/theme/common/colors/quickpickColors.js +9 -9
  52. package/vscode/src/vs/platform/theme/common/colors/searchColors.js +3 -3
  53. package/vscode/src/vs/platform/theme/common/iconRegistry.js +5 -5
  54. package/vscode/src/vs/platform/tunnel/common/tunnel.d.ts +1 -1
  55. package/vscode/src/vs/platform/tunnel/common/tunnel.service.d.ts +1 -1
  56. package/vscode/src/vs/platform/undoRedo/common/undoRedoService.js +20 -20
  57. package/vscode/src/vs/platform/uriIdentity/common/uriIdentity.service.d.ts +1 -1
  58. package/vscode/src/vs/platform/url/common/url.service.d.ts +1 -1
  59. package/vscode/src/vs/platform/userDataProfile/common/userDataProfile.js +1 -1
  60. package/vscode/src/vs/platform/userDataProfile/common/userDataProfileStorageService.service.d.ts +1 -1
  61. package/vscode/src/vs/platform/userDataSync/common/userDataSync.js +5 -5
  62. package/vscode/src/vs/platform/userDataSync/common/userDataSync.service.d.ts +8 -8
  63. package/vscode/src/vs/platform/workspace/common/editSessions.service.d.ts +1 -1
  64. package/vscode/src/vs/platform/workspace/common/workspace.js +1 -1
  65. package/vscode/src/vs/platform/workspace/common/workspaceTrust.service.d.ts +4 -5
  66. package/vscode/src/vs/workbench/api/common/extHost.protocol.d.ts +1 -1
  67. package/vscode/src/vs/workbench/api/common/extHostDiagnostics.js +1 -1
  68. package/vscode/src/vs/workbench/api/common/extHostExtensionService.js +2 -2
  69. package/vscode/src/vs/workbench/api/common/extHostLanguageFeatures.js +2 -2
  70. package/vscode/src/vs/workbench/api/common/extHostLanguageModels.js +1 -1
  71. package/vscode/src/vs/workbench/api/common/extHostLogService.js +1 -1
  72. package/vscode/src/vs/workbench/api/common/extHostNotebook.js +2 -2
  73. package/vscode/src/vs/workbench/api/common/extHostStatusBar.js +2 -2
  74. package/vscode/src/vs/workbench/api/common/extHostTelemetry.js +1 -1
  75. package/vscode/src/vs/workbench/api/common/extHostTerminalService.js +1 -1
  76. package/vscode/src/vs/workbench/api/common/extHostTesting.d.ts +1 -1
  77. package/vscode/src/vs/workbench/api/common/extHostTreeViews.js +1 -1
  78. package/vscode/src/vs/workbench/api/common/extHostTunnelService.js +2 -2
  79. package/vscode/src/vs/workbench/api/common/extHostWorkspace.js +1 -1
  80. package/vscode/src/vs/workbench/api/common/extensionHostMain.d.ts +1 -1
  81. package/vscode/src/vs/workbench/api/common/jsonValidationExtensionPoint.js +12 -12
  82. package/vscode/src/vs/workbench/browser/actions/developerActions.js +31 -31
  83. package/vscode/src/vs/workbench/browser/actions/textInputActions.js +6 -6
  84. package/vscode/src/vs/workbench/common/configuration.js +10 -10
  85. package/vscode/src/vs/workbench/common/contextkeys.js +70 -70
  86. package/vscode/src/vs/workbench/common/editor.js +4 -4
  87. package/vscode/src/vs/workbench/common/theme.js +158 -158
  88. package/vscode/src/vs/workbench/common/views.js +4 -4
  89. package/vscode/src/vs/workbench/contrib/accessibility/browser/accessibilityConfiguration.js +137 -137
  90. package/vscode/src/vs/workbench/contrib/accessibility/browser/accessibleViewActions.js +12 -12
  91. package/vscode/src/vs/workbench/contrib/chat/browser/chat.service.d.ts +3 -5
  92. package/vscode/src/vs/workbench/contrib/chat/common/chatAgents.d.ts +1 -2
  93. package/vscode/src/vs/workbench/contrib/chat/common/chatCodeMapperService.service.d.ts +1 -1
  94. package/vscode/src/vs/workbench/contrib/chat/common/chatContextKeys.js +24 -24
  95. package/vscode/src/vs/workbench/contrib/chat/common/chatEditingService.js +1 -1
  96. package/vscode/src/vs/workbench/contrib/chat/common/chatEditingService.service.d.ts +2 -2
  97. package/vscode/src/vs/workbench/contrib/chat/common/chatService.js +2 -1
  98. package/vscode/src/vs/workbench/contrib/chat/common/chatService.service.d.ts +1 -1
  99. package/vscode/src/vs/workbench/contrib/chat/common/chatSlashCommands.service.d.ts +2 -2
  100. package/vscode/src/vs/workbench/contrib/chat/common/chatVariables.service.d.ts +1 -1
  101. package/vscode/src/vs/workbench/contrib/chat/common/languageModels.js +6 -6
  102. package/vscode/src/vs/workbench/contrib/codeActions/browser/codeActionsContribution.js +13 -13
  103. package/vscode/src/vs/workbench/contrib/codeEditor/browser/dictation/editorDictation.js +4 -4
  104. package/vscode/src/vs/workbench/contrib/codeEditor/browser/diffEditorAccessibilityHelp.js +5 -5
  105. package/vscode/src/vs/workbench/contrib/codeEditor/browser/diffEditorHelper.js +3 -3
  106. package/vscode/src/vs/workbench/contrib/codeEditor/browser/largeFileOptimizations.js +3 -3
  107. package/vscode/src/vs/workbench/contrib/codeEditor/browser/saveParticipants.js +4 -4
  108. package/vscode/src/vs/workbench/contrib/codeEditor/browser/toggleMinimap.js +2 -2
  109. package/vscode/src/vs/workbench/contrib/codeEditor/browser/toggleMultiCursorModifier.js +4 -4
  110. package/vscode/src/vs/workbench/contrib/codeEditor/browser/toggleRenderControlCharacter.js +2 -2
  111. package/vscode/src/vs/workbench/contrib/codeEditor/browser/toggleRenderWhitespace.js +2 -2
  112. package/vscode/src/vs/workbench/contrib/codeEditor/browser/toggleWordWrap.js +5 -5
  113. package/vscode/src/vs/workbench/contrib/comments/browser/commentService.service.d.ts +3 -3
  114. package/vscode/src/vs/workbench/contrib/comments/browser/commentsAccessibility.js +12 -12
  115. package/vscode/src/vs/workbench/contrib/comments/common/commentContextKeys.js +10 -10
  116. package/vscode/src/vs/workbench/contrib/debug/common/abstractDebugAdapter.js +1 -1
  117. package/vscode/src/vs/workbench/contrib/debug/common/debug.js +64 -64
  118. package/vscode/src/vs/workbench/contrib/debug/common/debug.service.d.ts +1 -1
  119. package/vscode/src/vs/workbench/contrib/debug/common/debugVisualizers.service.d.ts +2 -2
  120. package/vscode/src/vs/workbench/contrib/editSessions/common/editSessions.service.d.ts +3 -3
  121. package/vscode/src/vs/workbench/contrib/extensions/common/extensions.service.d.ts +6 -6
  122. package/vscode/src/vs/workbench/contrib/files/browser/fileConstants.js +6 -6
  123. package/vscode/src/vs/workbench/contrib/files/browser/files.service.d.ts +3 -3
  124. package/vscode/src/vs/workbench/contrib/folding/browser/folding.contribution.js +3 -3
  125. package/vscode/src/vs/workbench/contrib/format/browser/formatActionsMultiple.js +20 -20
  126. package/vscode/src/vs/workbench/contrib/format/browser/formatActionsNone.js +4 -4
  127. package/vscode/src/vs/workbench/contrib/format/browser/formatModified.js +1 -1
  128. package/vscode/src/vs/workbench/contrib/inlayHints/browser/inlayHintsAccessibilty.js +4 -4
  129. package/vscode/src/vs/workbench/contrib/list/browser/listResizeColumnAction.js +2 -2
  130. package/vscode/src/vs/workbench/contrib/list/browser/tableColumnResizeQuickPick.js +5 -5
  131. package/vscode/src/vs/workbench/contrib/logs/common/defaultLogLevels.service.d.ts +1 -1
  132. package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/chatEdit/notebookOriginalCellModelFactory.service.d.ts +1 -1
  133. package/vscode/src/vs/workbench/contrib/notebook/browser/services/notebookEditorService.service.d.ts +5 -5
  134. package/vscode/src/vs/workbench/contrib/notebook/common/notebookCellStatusBarService.service.d.ts +1 -1
  135. package/vscode/src/vs/workbench/contrib/notebook/common/notebookCommon.d.ts +1 -1
  136. package/vscode/src/vs/workbench/contrib/notebook/common/notebookEditorModelResolverService.service.d.ts +3 -3
  137. package/vscode/src/vs/workbench/contrib/notebook/common/notebookExecutionService.d.ts +1 -1
  138. package/vscode/src/vs/workbench/contrib/notebook/common/notebookExecutionStateService.service.d.ts +1 -1
  139. package/vscode/src/vs/workbench/contrib/notebook/common/notebookService.service.d.ts +7 -7
  140. package/vscode/src/vs/workbench/contrib/output/common/outputChannelModelService.service.d.ts +1 -1
  141. package/vscode/src/vs/workbench/contrib/scm/browser/diff.service.d.ts +2 -2
  142. package/vscode/src/vs/workbench/contrib/scm/browser/dirtyDiffSwitcher.js +2 -2
  143. package/vscode/src/vs/workbench/contrib/scm/browser/dirtydiffDecorator.js +23 -23
  144. package/vscode/src/vs/workbench/contrib/scm/common/quickDiff.service.d.ts +2 -2
  145. package/vscode/src/vs/workbench/contrib/scm/common/scm.service.d.ts +3 -4
  146. package/vscode/src/vs/workbench/contrib/search/browser/replace.service.d.ts +1 -1
  147. package/vscode/src/vs/workbench/contrib/snippets/browser/snippetCompletionProvider.js +3 -3
  148. package/vscode/src/vs/workbench/contrib/snippets/browser/snippets.service.d.ts +1 -1
  149. package/vscode/src/vs/workbench/contrib/snippets/browser/snippetsFile.js +3 -3
  150. package/vscode/src/vs/workbench/contrib/snippets/browser/snippetsService.js +9 -9
  151. package/vscode/src/vs/workbench/contrib/speech/common/speechService.js +29 -29
  152. package/vscode/src/vs/workbench/contrib/tags/common/workspaceTags.service.d.ts +1 -1
  153. package/vscode/src/vs/workbench/contrib/tasks/common/taskDefinitionRegistry.js +5 -5
  154. package/vscode/src/vs/workbench/contrib/tasks/common/taskService.service.d.ts +3 -3
  155. package/vscode/src/vs/workbench/contrib/tasks/common/tasks.js +3 -3
  156. package/vscode/src/vs/workbench/contrib/terminal/browser/terminal.service.d.ts +10 -11
  157. package/vscode/src/vs/workbench/contrib/terminal/common/terminal.service.d.ts +4 -5
  158. package/vscode/src/vs/workbench/contrib/terminalContrib/links/browser/links.service.d.ts +1 -1
  159. package/vscode/src/vs/workbench/contrib/testing/common/constants.js +11 -11
  160. package/vscode/src/vs/workbench/contrib/testing/common/testCoverageService.service.d.ts +1 -1
  161. package/vscode/src/vs/workbench/contrib/testing/common/testExplorerFilterState.service.d.ts +1 -1
  162. package/vscode/src/vs/workbench/contrib/testing/common/testProfileService.service.d.ts +1 -1
  163. package/vscode/src/vs/workbench/contrib/testing/common/testResultService.service.d.ts +2 -2
  164. package/vscode/src/vs/workbench/contrib/testing/common/testService.service.d.ts +1 -1
  165. package/vscode/src/vs/workbench/contrib/testing/common/testTypes.js +3 -3
  166. package/vscode/src/vs/workbench/contrib/testing/common/testingDecorations.service.d.ts +1 -1
  167. package/vscode/src/vs/workbench/contrib/testing/common/testingPeekOpener.service.d.ts +2 -2
  168. package/vscode/src/vs/workbench/contrib/timeline/common/timeline.service.d.ts +1 -1
  169. package/vscode/src/vs/workbench/contrib/webview/browser/webview.service.d.ts +1 -1
  170. package/vscode/src/vs/workbench/contrib/webviewPanel/browser/webviewWorkbenchService.service.d.ts +3 -3
  171. package/vscode/src/vs/workbench/services/configurationResolver/common/configurationResolver.service.d.ts +2 -2
  172. package/vscode/src/vs/workbench/services/configurationResolver/common/variableResolver.js +15 -15
  173. package/vscode/src/vs/workbench/services/decorations/common/decorations.service.d.ts +1 -1
  174. package/vscode/src/vs/workbench/services/editor/common/editorGroupsService.service.d.ts +2 -2
  175. package/vscode/src/vs/workbench/services/editor/common/editorPaneService.service.d.ts +1 -1
  176. package/vscode/src/vs/workbench/services/editor/common/editorResolverService.js +1 -1
  177. package/vscode/src/vs/workbench/services/editor/common/editorResolverService.service.d.ts +2 -2
  178. package/vscode/src/vs/workbench/services/editor/common/editorService.service.d.ts +6 -6
  179. package/vscode/src/vs/workbench/services/environment/common/environmentService.service.d.ts +2 -2
  180. package/vscode/src/vs/workbench/services/environment/common/environmentService.service.js +1 -1
  181. package/vscode/src/vs/workbench/services/extensionManagement/common/extensionFeatures.service.d.ts +1 -1
  182. package/vscode/src/vs/workbench/services/extensionManagement/common/extensionManagement.service.d.ts +5 -9
  183. package/vscode/src/vs/workbench/services/extensionManagement/common/extensionManagement.service.js +1 -1
  184. package/vscode/src/vs/workbench/services/extensionRecommendations/common/extensionRecommendations.service.d.ts +1 -2
  185. package/vscode/src/vs/workbench/services/extensions/common/extensionManifestPropertiesService.service.d.ts +1 -1
  186. package/vscode/src/vs/workbench/services/extensions/common/extensions.d.ts +2 -1
  187. package/vscode/src/vs/workbench/services/extensions/common/extensions.service.d.ts +2 -2
  188. package/vscode/src/vs/workbench/services/extensions/common/extensionsRegistry.js +83 -83
  189. package/vscode/src/vs/workbench/services/extensions/common/rpcProtocol.d.ts +1 -1
  190. package/vscode/src/vs/workbench/services/files/common/elevatedFileService.service.d.ts +2 -2
  191. package/vscode/src/vs/workbench/services/filesConfiguration/common/filesConfigurationService.service.d.ts +3 -3
  192. package/vscode/src/vs/workbench/services/history/common/history.service.d.ts +1 -1
  193. package/vscode/src/vs/workbench/services/host/browser/host.service.d.ts +1 -1
  194. package/vscode/src/vs/workbench/services/language/common/languageService.js +28 -28
  195. package/vscode/src/vs/workbench/services/layout/browser/layoutService.service.d.ts +5 -4
  196. package/vscode/src/vs/workbench/services/panecomposite/browser/panecomposite.service.d.ts +1 -1
  197. package/vscode/src/vs/workbench/services/preferences/common/preferences.service.d.ts +1 -1
  198. package/vscode/src/vs/workbench/services/remote/common/remoteAgentService.service.d.ts +2 -2
  199. package/vscode/src/vs/workbench/services/remote/common/remoteExplorerService.js +8 -8
  200. package/vscode/src/vs/workbench/services/remote/common/remoteExplorerService.service.d.ts +3 -3
  201. package/vscode/src/vs/workbench/services/remote/common/tunnelModel.js +6 -6
  202. package/vscode/src/vs/workbench/services/search/common/queryBuilder.js +1 -1
  203. package/vscode/src/vs/workbench/services/statusbar/browser/statusbar.service.d.ts +1 -1
  204. package/vscode/src/vs/workbench/services/textMate/browser/textMateTokenizationFeature.service.d.ts +1 -1
  205. package/vscode/src/vs/workbench/services/textfile/common/textEditorService.service.d.ts +1 -1
  206. package/vscode/src/vs/workbench/services/textfile/common/textfiles.service.d.ts +4 -4
  207. package/vscode/src/vs/workbench/services/themes/common/colorExtensionPoint.js +22 -22
  208. package/vscode/src/vs/workbench/services/themes/common/iconExtensionPoint.js +14 -14
  209. package/vscode/src/vs/workbench/services/themes/common/productIconThemeSchema.js +8 -8
  210. package/vscode/src/vs/workbench/services/title/browser/titleService.service.d.ts +1 -1
  211. package/vscode/src/vs/workbench/services/userDataProfile/common/userDataProfile.service.d.ts +4 -6
  212. package/vscode/src/vs/workbench/services/userDataSync/common/userDataSync.js +11 -11
  213. package/vscode/src/vs/workbench/services/userDataSync/common/userDataSync.service.d.ts +1 -1
  214. package/vscode/src/vs/workbench/services/views/common/viewsService.service.d.ts +1 -1
  215. package/vscode/src/vs/workbench/services/workingCopy/common/workingCopyBackup.service.d.ts +1 -1
  216. package/vscode/src/vs/workbench/services/workingCopy/common/workingCopyEditorService.service.d.ts +1 -1
  217. package/vscode/src/vs/workbench/services/workingCopy/common/workingCopyFileService.service.d.ts +3 -3
  218. package/vscode/src/vs/workbench/services/workingCopy/common/workingCopyHistory.service.d.ts +1 -1
  219. package/vscode/src/vs/workbench/services/workingCopy/common/workingCopyService.service.d.ts +1 -1
  220. package/vscode/src/vs/workbench/services/workspaces/common/workspaceEditing.service.d.ts +1 -1
  221. package/api.js +0 -309
  222. package/localExtensionHost.d.ts +0 -42
  223. package/localExtensionHost.js +0 -224
  224. package/vscode/src/vs/base/parts/ipc/common/ipc.d.ts +0 -175
  225. package/vscode/src/vs/base/parts/ipc/common/ipc.js +0 -711
  226. package/vscode/src/vs/base/parts/ipc/common/ipc.net.d.ts +0 -195
  227. package/vscode/src/vs/base/parts/ipc/common/ipc.net.js +0 -799
  228. package/vscode/src/vs/workbench/services/environment/browser/environmentService.service.d.ts +0 -7
  229. package/vscode/src/vs/workbench/services/environment/browser/environmentService.service.js +0 -7
@@ -1,799 +0,0 @@
1
-
2
- import { VSBuffer } from '../../../common/buffer.js';
3
- import { Emitter } from '../../../common/event.js';
4
- import { Disposable, DisposableStore } from '../../../common/lifecycle.js';
5
- import { IPCClient } from './ipc.js';
6
-
7
- var SocketDiagnosticsEventType;
8
- (function (SocketDiagnosticsEventType) {
9
- SocketDiagnosticsEventType["Created"] = "created";
10
- SocketDiagnosticsEventType["Read"] = "read";
11
- SocketDiagnosticsEventType["Write"] = "write";
12
- SocketDiagnosticsEventType["Open"] = "open";
13
- SocketDiagnosticsEventType["Error"] = "error";
14
- SocketDiagnosticsEventType["Close"] = "close";
15
- SocketDiagnosticsEventType["BrowserWebSocketBlobReceived"] = "browserWebSocketBlobReceived";
16
- SocketDiagnosticsEventType["NodeEndReceived"] = "nodeEndReceived";
17
- SocketDiagnosticsEventType["NodeEndSent"] = "nodeEndSent";
18
- SocketDiagnosticsEventType["NodeDrainBegin"] = "nodeDrainBegin";
19
- SocketDiagnosticsEventType["NodeDrainEnd"] = "nodeDrainEnd";
20
- SocketDiagnosticsEventType["zlibInflateError"] = "zlibInflateError";
21
- SocketDiagnosticsEventType["zlibInflateData"] = "zlibInflateData";
22
- SocketDiagnosticsEventType["zlibInflateInitialWrite"] = "zlibInflateInitialWrite";
23
- SocketDiagnosticsEventType["zlibInflateInitialFlushFired"] = "zlibInflateInitialFlushFired";
24
- SocketDiagnosticsEventType["zlibInflateWrite"] = "zlibInflateWrite";
25
- SocketDiagnosticsEventType["zlibInflateFlushFired"] = "zlibInflateFlushFired";
26
- SocketDiagnosticsEventType["zlibDeflateError"] = "zlibDeflateError";
27
- SocketDiagnosticsEventType["zlibDeflateData"] = "zlibDeflateData";
28
- SocketDiagnosticsEventType["zlibDeflateWrite"] = "zlibDeflateWrite";
29
- SocketDiagnosticsEventType["zlibDeflateFlushFired"] = "zlibDeflateFlushFired";
30
- SocketDiagnosticsEventType["WebSocketNodeSocketWrite"] = "webSocketNodeSocketWrite";
31
- SocketDiagnosticsEventType["WebSocketNodeSocketPeekedHeader"] = "webSocketNodeSocketPeekedHeader";
32
- SocketDiagnosticsEventType["WebSocketNodeSocketReadHeader"] = "webSocketNodeSocketReadHeader";
33
- SocketDiagnosticsEventType["WebSocketNodeSocketReadData"] = "webSocketNodeSocketReadData";
34
- SocketDiagnosticsEventType["WebSocketNodeSocketUnmaskedData"] = "webSocketNodeSocketUnmaskedData";
35
- SocketDiagnosticsEventType["WebSocketNodeSocketDrainBegin"] = "webSocketNodeSocketDrainBegin";
36
- SocketDiagnosticsEventType["WebSocketNodeSocketDrainEnd"] = "webSocketNodeSocketDrainEnd";
37
- SocketDiagnosticsEventType["ProtocolHeaderRead"] = "protocolHeaderRead";
38
- SocketDiagnosticsEventType["ProtocolMessageRead"] = "protocolMessageRead";
39
- SocketDiagnosticsEventType["ProtocolHeaderWrite"] = "protocolHeaderWrite";
40
- SocketDiagnosticsEventType["ProtocolMessageWrite"] = "protocolMessageWrite";
41
- SocketDiagnosticsEventType["ProtocolWrite"] = "protocolWrite";
42
- })(SocketDiagnosticsEventType || (SocketDiagnosticsEventType = {}));
43
- var SocketDiagnostics;
44
- (function (SocketDiagnostics) {
45
- SocketDiagnostics.enableDiagnostics = false;
46
- SocketDiagnostics.records = [];
47
- const socketIds = ( new WeakMap());
48
- let lastUsedSocketId = 0;
49
- function getSocketId(nativeObject, label) {
50
- if (!( socketIds.has(nativeObject))) {
51
- const id = String(++lastUsedSocketId);
52
- socketIds.set(nativeObject, id);
53
- }
54
- return socketIds.get(nativeObject);
55
- }
56
- function traceSocketEvent(nativeObject, socketDebugLabel, type, data) {
57
- if (!SocketDiagnostics.enableDiagnostics) {
58
- return;
59
- }
60
- const id = getSocketId(nativeObject);
61
- if (data instanceof VSBuffer || data instanceof Uint8Array || data instanceof ArrayBuffer || ArrayBuffer.isView(data)) {
62
- const copiedData = VSBuffer.alloc(data.byteLength);
63
- copiedData.set(data);
64
- SocketDiagnostics.records.push({ timestamp: Date.now(), id, label: socketDebugLabel, type, buff: copiedData });
65
- }
66
- else {
67
- SocketDiagnostics.records.push({ timestamp: Date.now(), id, label: socketDebugLabel, type, data: data });
68
- }
69
- }
70
- SocketDiagnostics.traceSocketEvent = traceSocketEvent;
71
- })(SocketDiagnostics || (SocketDiagnostics = {}));
72
- var SocketCloseEventType;
73
- (function (SocketCloseEventType) {
74
- SocketCloseEventType[SocketCloseEventType["NodeSocketCloseEvent"] = 0] = "NodeSocketCloseEvent";
75
- SocketCloseEventType[SocketCloseEventType["WebSocketCloseEvent"] = 1] = "WebSocketCloseEvent";
76
- })(SocketCloseEventType || (SocketCloseEventType = {}));
77
- let emptyBuffer = null;
78
- function getEmptyBuffer() {
79
- if (!emptyBuffer) {
80
- emptyBuffer = VSBuffer.alloc(0);
81
- }
82
- return emptyBuffer;
83
- }
84
- class ChunkStream {
85
- get byteLength() {
86
- return this._totalLength;
87
- }
88
- constructor() {
89
- this._chunks = [];
90
- this._totalLength = 0;
91
- }
92
- acceptChunk(buff) {
93
- this._chunks.push(buff);
94
- this._totalLength += buff.byteLength;
95
- }
96
- read(byteCount) {
97
- return this._read(byteCount, true);
98
- }
99
- peek(byteCount) {
100
- return this._read(byteCount, false);
101
- }
102
- _read(byteCount, advance) {
103
- if (byteCount === 0) {
104
- return getEmptyBuffer();
105
- }
106
- if (byteCount > this._totalLength) {
107
- throw ( new Error(`Cannot read so many bytes!`));
108
- }
109
- if (this._chunks[0].byteLength === byteCount) {
110
- const result = this._chunks[0];
111
- if (advance) {
112
- this._chunks.shift();
113
- this._totalLength -= byteCount;
114
- }
115
- return result;
116
- }
117
- if (this._chunks[0].byteLength > byteCount) {
118
- const result = this._chunks[0].slice(0, byteCount);
119
- if (advance) {
120
- this._chunks[0] = this._chunks[0].slice(byteCount);
121
- this._totalLength -= byteCount;
122
- }
123
- return result;
124
- }
125
- const result = VSBuffer.alloc(byteCount);
126
- let resultOffset = 0;
127
- let chunkIndex = 0;
128
- while (byteCount > 0) {
129
- const chunk = this._chunks[chunkIndex];
130
- if (chunk.byteLength > byteCount) {
131
- const chunkPart = chunk.slice(0, byteCount);
132
- result.set(chunkPart, resultOffset);
133
- resultOffset += byteCount;
134
- if (advance) {
135
- this._chunks[chunkIndex] = chunk.slice(byteCount);
136
- this._totalLength -= byteCount;
137
- }
138
- byteCount -= byteCount;
139
- }
140
- else {
141
- result.set(chunk, resultOffset);
142
- resultOffset += chunk.byteLength;
143
- if (advance) {
144
- this._chunks.shift();
145
- this._totalLength -= chunk.byteLength;
146
- }
147
- else {
148
- chunkIndex++;
149
- }
150
- byteCount -= chunk.byteLength;
151
- }
152
- }
153
- return result;
154
- }
155
- }
156
- var ProtocolMessageType;
157
- (function (ProtocolMessageType) {
158
- ProtocolMessageType[ProtocolMessageType["None"] = 0] = "None";
159
- ProtocolMessageType[ProtocolMessageType["Regular"] = 1] = "Regular";
160
- ProtocolMessageType[ProtocolMessageType["Control"] = 2] = "Control";
161
- ProtocolMessageType[ProtocolMessageType["Ack"] = 3] = "Ack";
162
- ProtocolMessageType[ProtocolMessageType["Disconnect"] = 5] = "Disconnect";
163
- ProtocolMessageType[ProtocolMessageType["ReplayRequest"] = 6] = "ReplayRequest";
164
- ProtocolMessageType[ProtocolMessageType["Pause"] = 7] = "Pause";
165
- ProtocolMessageType[ProtocolMessageType["Resume"] = 8] = "Resume";
166
- ProtocolMessageType[ProtocolMessageType["KeepAlive"] = 9] = "KeepAlive";
167
- })(ProtocolMessageType || (ProtocolMessageType = {}));
168
- function protocolMessageTypeToString(messageType) {
169
- switch (messageType) {
170
- case ProtocolMessageType.None: return 'None';
171
- case ProtocolMessageType.Regular: return 'Regular';
172
- case ProtocolMessageType.Control: return 'Control';
173
- case ProtocolMessageType.Ack: return 'Ack';
174
- case ProtocolMessageType.Disconnect: return 'Disconnect';
175
- case ProtocolMessageType.ReplayRequest: return 'ReplayRequest';
176
- case ProtocolMessageType.Pause: return 'PauseWriting';
177
- case ProtocolMessageType.Resume: return 'ResumeWriting';
178
- case ProtocolMessageType.KeepAlive: return 'KeepAlive';
179
- }
180
- }
181
- var ProtocolConstants;
182
- (function (ProtocolConstants) {
183
- ProtocolConstants[ProtocolConstants["HeaderLength"] = 13] = "HeaderLength";
184
- ProtocolConstants[ProtocolConstants["AcknowledgeTime"] = 2000] = "AcknowledgeTime";
185
- ProtocolConstants[ProtocolConstants["TimeoutTime"] = 20000] = "TimeoutTime";
186
- ProtocolConstants[ProtocolConstants["ReconnectionGraceTime"] = 10800000] = "ReconnectionGraceTime";
187
- ProtocolConstants[ProtocolConstants["ReconnectionShortGraceTime"] = 300000] = "ReconnectionShortGraceTime";
188
- ProtocolConstants[ProtocolConstants["KeepAliveSendTime"] = 5000] = "KeepAliveSendTime";
189
- })(ProtocolConstants || (ProtocolConstants = {}));
190
- class ProtocolMessage {
191
- constructor(type, id, ack, data) {
192
- this.type = type;
193
- this.id = id;
194
- this.ack = ack;
195
- this.data = data;
196
- this.writtenTime = 0;
197
- }
198
- get size() {
199
- return this.data.byteLength;
200
- }
201
- }
202
- class ProtocolReader extends Disposable {
203
- constructor(socket) {
204
- super();
205
- this._onMessage = this._register(( new Emitter()));
206
- this.onMessage = this._onMessage.event;
207
- this._state = {
208
- readHead: true,
209
- readLen: ProtocolConstants.HeaderLength,
210
- messageType: ProtocolMessageType.None,
211
- id: 0,
212
- ack: 0
213
- };
214
- this._socket = socket;
215
- this._isDisposed = false;
216
- this._incomingData = ( new ChunkStream());
217
- this._register(this._socket.onData(data => this.acceptChunk(data)));
218
- this.lastReadTime = Date.now();
219
- }
220
- acceptChunk(data) {
221
- if (!data || data.byteLength === 0) {
222
- return;
223
- }
224
- this.lastReadTime = Date.now();
225
- this._incomingData.acceptChunk(data);
226
- while (this._incomingData.byteLength >= this._state.readLen) {
227
- const buff = this._incomingData.read(this._state.readLen);
228
- if (this._state.readHead) {
229
- this._state.readHead = false;
230
- this._state.readLen = buff.readUInt32BE(9);
231
- this._state.messageType = buff.readUInt8(0);
232
- this._state.id = buff.readUInt32BE(1);
233
- this._state.ack = buff.readUInt32BE(5);
234
- this._socket.traceSocketEvent(SocketDiagnosticsEventType.ProtocolHeaderRead, { messageType: protocolMessageTypeToString(this._state.messageType), id: this._state.id, ack: this._state.ack, messageSize: this._state.readLen });
235
- }
236
- else {
237
- const messageType = this._state.messageType;
238
- const id = this._state.id;
239
- const ack = this._state.ack;
240
- this._state.readHead = true;
241
- this._state.readLen = ProtocolConstants.HeaderLength;
242
- this._state.messageType = ProtocolMessageType.None;
243
- this._state.id = 0;
244
- this._state.ack = 0;
245
- this._socket.traceSocketEvent(SocketDiagnosticsEventType.ProtocolMessageRead, buff);
246
- this._onMessage.fire(( new ProtocolMessage(messageType, id, ack, buff)));
247
- if (this._isDisposed) {
248
- break;
249
- }
250
- }
251
- }
252
- }
253
- readEntireBuffer() {
254
- return this._incomingData.read(this._incomingData.byteLength);
255
- }
256
- dispose() {
257
- this._isDisposed = true;
258
- super.dispose();
259
- }
260
- }
261
- class ProtocolWriter {
262
- constructor(socket) {
263
- this._writeNowTimeout = null;
264
- this._isDisposed = false;
265
- this._isPaused = false;
266
- this._socket = socket;
267
- this._data = [];
268
- this._totalLength = 0;
269
- this.lastWriteTime = 0;
270
- }
271
- dispose() {
272
- try {
273
- this.flush();
274
- }
275
- catch (err) {
276
- }
277
- this._isDisposed = true;
278
- }
279
- drain() {
280
- this.flush();
281
- return this._socket.drain();
282
- }
283
- flush() {
284
- this._writeNow();
285
- }
286
- pause() {
287
- this._isPaused = true;
288
- }
289
- resume() {
290
- this._isPaused = false;
291
- this._scheduleWriting();
292
- }
293
- write(msg) {
294
- if (this._isDisposed) {
295
- return;
296
- }
297
- msg.writtenTime = Date.now();
298
- this.lastWriteTime = Date.now();
299
- const header = VSBuffer.alloc(ProtocolConstants.HeaderLength);
300
- header.writeUInt8(msg.type, 0);
301
- header.writeUInt32BE(msg.id, 1);
302
- header.writeUInt32BE(msg.ack, 5);
303
- header.writeUInt32BE(msg.data.byteLength, 9);
304
- this._socket.traceSocketEvent(SocketDiagnosticsEventType.ProtocolHeaderWrite, { messageType: protocolMessageTypeToString(msg.type), id: msg.id, ack: msg.ack, messageSize: msg.data.byteLength });
305
- this._socket.traceSocketEvent(SocketDiagnosticsEventType.ProtocolMessageWrite, msg.data);
306
- this._writeSoon(header, msg.data);
307
- }
308
- _bufferAdd(head, body) {
309
- const wasEmpty = this._totalLength === 0;
310
- this._data.push(head, body);
311
- this._totalLength += head.byteLength + body.byteLength;
312
- return wasEmpty;
313
- }
314
- _bufferTake() {
315
- const ret = VSBuffer.concat(this._data, this._totalLength);
316
- this._data.length = 0;
317
- this._totalLength = 0;
318
- return ret;
319
- }
320
- _writeSoon(header, data) {
321
- if (this._bufferAdd(header, data)) {
322
- this._scheduleWriting();
323
- }
324
- }
325
- _scheduleWriting() {
326
- if (this._writeNowTimeout) {
327
- return;
328
- }
329
- this._writeNowTimeout = setTimeout(() => {
330
- this._writeNowTimeout = null;
331
- this._writeNow();
332
- });
333
- }
334
- _writeNow() {
335
- if (this._totalLength === 0) {
336
- return;
337
- }
338
- if (this._isPaused) {
339
- return;
340
- }
341
- const data = this._bufferTake();
342
- this._socket.traceSocketEvent(SocketDiagnosticsEventType.ProtocolWrite, { byteLength: data.byteLength });
343
- this._socket.write(data);
344
- }
345
- }
346
- class Protocol extends Disposable {
347
- constructor(socket) {
348
- super();
349
- this._onMessage = ( new Emitter());
350
- this.onMessage = this._onMessage.event;
351
- this._onDidDispose = ( new Emitter());
352
- this.onDidDispose = this._onDidDispose.event;
353
- this._socket = socket;
354
- this._socketWriter = this._register(( new ProtocolWriter(this._socket)));
355
- this._socketReader = this._register(( new ProtocolReader(this._socket)));
356
- this._register(this._socketReader.onMessage((msg) => {
357
- if (msg.type === ProtocolMessageType.Regular) {
358
- this._onMessage.fire(msg.data);
359
- }
360
- }));
361
- this._register(this._socket.onClose(() => this._onDidDispose.fire()));
362
- }
363
- drain() {
364
- return this._socketWriter.drain();
365
- }
366
- getSocket() {
367
- return this._socket;
368
- }
369
- sendDisconnect() {
370
- }
371
- send(buffer) {
372
- this._socketWriter.write(( new ProtocolMessage(ProtocolMessageType.Regular, 0, 0, buffer)));
373
- }
374
- }
375
- class Client extends IPCClient {
376
- static fromSocket(socket, id) {
377
- return ( new Client(( new Protocol(socket)), id));
378
- }
379
- get onDidDispose() { return this.protocol.onDidDispose; }
380
- constructor(protocol, id, ipcLogger = null) {
381
- super(protocol, id, ipcLogger);
382
- this.protocol = protocol;
383
- }
384
- dispose() {
385
- super.dispose();
386
- const socket = this.protocol.getSocket();
387
- this.protocol.sendDisconnect();
388
- this.protocol.dispose();
389
- socket.end();
390
- }
391
- }
392
- class BufferedEmitter {
393
- constructor() {
394
- this._hasListeners = false;
395
- this._isDeliveringMessages = false;
396
- this._bufferedMessages = [];
397
- this._emitter = ( new Emitter({
398
- onWillAddFirstListener: () => {
399
- this._hasListeners = true;
400
- queueMicrotask(() => this._deliverMessages());
401
- },
402
- onDidRemoveLastListener: () => {
403
- this._hasListeners = false;
404
- }
405
- }));
406
- this.event = this._emitter.event;
407
- }
408
- _deliverMessages() {
409
- if (this._isDeliveringMessages) {
410
- return;
411
- }
412
- this._isDeliveringMessages = true;
413
- while (this._hasListeners && this._bufferedMessages.length > 0) {
414
- this._emitter.fire(this._bufferedMessages.shift());
415
- }
416
- this._isDeliveringMessages = false;
417
- }
418
- fire(event) {
419
- if (this._hasListeners) {
420
- if (this._bufferedMessages.length > 0) {
421
- this._bufferedMessages.push(event);
422
- }
423
- else {
424
- this._emitter.fire(event);
425
- }
426
- }
427
- else {
428
- this._bufferedMessages.push(event);
429
- }
430
- }
431
- flushBuffer() {
432
- this._bufferedMessages = [];
433
- }
434
- }
435
- class QueueElement {
436
- constructor(data) {
437
- this.data = data;
438
- this.next = null;
439
- }
440
- }
441
- class Queue {
442
- constructor() {
443
- this._first = null;
444
- this._last = null;
445
- }
446
- length() {
447
- let result = 0;
448
- let current = this._first;
449
- while (current) {
450
- current = current.next;
451
- result++;
452
- }
453
- return result;
454
- }
455
- peek() {
456
- if (!this._first) {
457
- return null;
458
- }
459
- return this._first.data;
460
- }
461
- toArray() {
462
- const result = [];
463
- let resultLen = 0;
464
- let it = this._first;
465
- while (it) {
466
- result[resultLen++] = it.data;
467
- it = it.next;
468
- }
469
- return result;
470
- }
471
- pop() {
472
- if (!this._first) {
473
- return;
474
- }
475
- if (this._first === this._last) {
476
- this._first = null;
477
- this._last = null;
478
- return;
479
- }
480
- this._first = this._first.next;
481
- }
482
- push(item) {
483
- const element = ( new QueueElement(item));
484
- if (!this._first) {
485
- this._first = element;
486
- this._last = element;
487
- return;
488
- }
489
- this._last.next = element;
490
- this._last = element;
491
- }
492
- }
493
- class LoadEstimator {
494
- static { this._HISTORY_LENGTH = 10; }
495
- static { this._INSTANCE = null; }
496
- static getInstance() {
497
- if (!LoadEstimator._INSTANCE) {
498
- LoadEstimator._INSTANCE = ( new LoadEstimator());
499
- }
500
- return LoadEstimator._INSTANCE;
501
- }
502
- constructor() {
503
- this.lastRuns = [];
504
- const now = Date.now();
505
- for (let i = 0; i < LoadEstimator._HISTORY_LENGTH; i++) {
506
- this.lastRuns[i] = now - 1000 * i;
507
- }
508
- setInterval(() => {
509
- for (let i = LoadEstimator._HISTORY_LENGTH; i >= 1; i--) {
510
- this.lastRuns[i] = this.lastRuns[i - 1];
511
- }
512
- this.lastRuns[0] = Date.now();
513
- }, 1000);
514
- }
515
- load() {
516
- const now = Date.now();
517
- const historyLimit = (1 + LoadEstimator._HISTORY_LENGTH) * 1000;
518
- let score = 0;
519
- for (let i = 0; i < LoadEstimator._HISTORY_LENGTH; i++) {
520
- if (now - this.lastRuns[i] <= historyLimit) {
521
- score++;
522
- }
523
- }
524
- return 1 - score / LoadEstimator._HISTORY_LENGTH;
525
- }
526
- hasHighLoad() {
527
- return this.load() >= 0.5;
528
- }
529
- }
530
- class PersistentProtocol {
531
- get unacknowledgedCount() {
532
- return this._outgoingMsgId - this._outgoingAckId;
533
- }
534
- constructor(opts) {
535
- this._onControlMessage = ( new BufferedEmitter());
536
- this.onControlMessage = this._onControlMessage.event;
537
- this._onMessage = ( new BufferedEmitter());
538
- this.onMessage = this._onMessage.event;
539
- this._onDidDispose = ( new BufferedEmitter());
540
- this.onDidDispose = this._onDidDispose.event;
541
- this._onSocketClose = ( new BufferedEmitter());
542
- this.onSocketClose = this._onSocketClose.event;
543
- this._onSocketTimeout = ( new BufferedEmitter());
544
- this.onSocketTimeout = this._onSocketTimeout.event;
545
- this._loadEstimator = opts.loadEstimator ?? LoadEstimator.getInstance();
546
- this._shouldSendKeepAlive = opts.sendKeepAlive ?? true;
547
- this._isReconnecting = false;
548
- this._outgoingUnackMsg = ( new Queue());
549
- this._outgoingMsgId = 0;
550
- this._outgoingAckId = 0;
551
- this._outgoingAckTimeout = null;
552
- this._incomingMsgId = 0;
553
- this._incomingAckId = 0;
554
- this._incomingMsgLastTime = 0;
555
- this._incomingAckTimeout = null;
556
- this._lastReplayRequestTime = 0;
557
- this._lastSocketTimeoutTime = Date.now();
558
- this._socketDisposables = ( new DisposableStore());
559
- this._socket = opts.socket;
560
- this._socketWriter = this._socketDisposables.add(( new ProtocolWriter(this._socket)));
561
- this._socketReader = this._socketDisposables.add(( new ProtocolReader(this._socket)));
562
- this._socketDisposables.add(this._socketReader.onMessage(msg => this._receiveMessage(msg)));
563
- this._socketDisposables.add(this._socket.onClose(e => this._onSocketClose.fire(e)));
564
- if (opts.initialChunk) {
565
- this._socketReader.acceptChunk(opts.initialChunk);
566
- }
567
- if (this._shouldSendKeepAlive) {
568
- this._keepAliveInterval = setInterval(() => {
569
- this._sendKeepAlive();
570
- }, ProtocolConstants.KeepAliveSendTime);
571
- }
572
- else {
573
- this._keepAliveInterval = null;
574
- }
575
- }
576
- dispose() {
577
- if (this._outgoingAckTimeout) {
578
- clearTimeout(this._outgoingAckTimeout);
579
- this._outgoingAckTimeout = null;
580
- }
581
- if (this._incomingAckTimeout) {
582
- clearTimeout(this._incomingAckTimeout);
583
- this._incomingAckTimeout = null;
584
- }
585
- if (this._keepAliveInterval) {
586
- clearInterval(this._keepAliveInterval);
587
- this._keepAliveInterval = null;
588
- }
589
- this._socketDisposables.dispose();
590
- }
591
- drain() {
592
- return this._socketWriter.drain();
593
- }
594
- sendDisconnect() {
595
- if (!this._didSendDisconnect) {
596
- this._didSendDisconnect = true;
597
- const msg = ( new ProtocolMessage(ProtocolMessageType.Disconnect, 0, 0, getEmptyBuffer()));
598
- this._socketWriter.write(msg);
599
- this._socketWriter.flush();
600
- }
601
- }
602
- sendPause() {
603
- const msg = ( new ProtocolMessage(ProtocolMessageType.Pause, 0, 0, getEmptyBuffer()));
604
- this._socketWriter.write(msg);
605
- }
606
- sendResume() {
607
- const msg = ( new ProtocolMessage(ProtocolMessageType.Resume, 0, 0, getEmptyBuffer()));
608
- this._socketWriter.write(msg);
609
- }
610
- pauseSocketWriting() {
611
- this._socketWriter.pause();
612
- }
613
- getSocket() {
614
- return this._socket;
615
- }
616
- getMillisSinceLastIncomingData() {
617
- return Date.now() - this._socketReader.lastReadTime;
618
- }
619
- beginAcceptReconnection(socket, initialDataChunk) {
620
- this._isReconnecting = true;
621
- this._socketDisposables.dispose();
622
- this._socketDisposables = ( new DisposableStore());
623
- this._onControlMessage.flushBuffer();
624
- this._onSocketClose.flushBuffer();
625
- this._onSocketTimeout.flushBuffer();
626
- this._socket.dispose();
627
- this._lastReplayRequestTime = 0;
628
- this._lastSocketTimeoutTime = Date.now();
629
- this._socket = socket;
630
- this._socketWriter = this._socketDisposables.add(( new ProtocolWriter(this._socket)));
631
- this._socketReader = this._socketDisposables.add(( new ProtocolReader(this._socket)));
632
- this._socketDisposables.add(this._socketReader.onMessage(msg => this._receiveMessage(msg)));
633
- this._socketDisposables.add(this._socket.onClose(e => this._onSocketClose.fire(e)));
634
- this._socketReader.acceptChunk(initialDataChunk);
635
- }
636
- endAcceptReconnection() {
637
- this._isReconnecting = false;
638
- this._incomingAckId = this._incomingMsgId;
639
- const msg = ( new ProtocolMessage(ProtocolMessageType.Ack, 0, this._incomingAckId, getEmptyBuffer()));
640
- this._socketWriter.write(msg);
641
- const toSend = this._outgoingUnackMsg.toArray();
642
- for (let i = 0, len = toSend.length; i < len; i++) {
643
- this._socketWriter.write(toSend[i]);
644
- }
645
- this._recvAckCheck();
646
- }
647
- acceptDisconnect() {
648
- this._onDidDispose.fire();
649
- }
650
- _receiveMessage(msg) {
651
- if (msg.ack > this._outgoingAckId) {
652
- this._outgoingAckId = msg.ack;
653
- do {
654
- const first = this._outgoingUnackMsg.peek();
655
- if (first && first.id <= msg.ack) {
656
- this._outgoingUnackMsg.pop();
657
- }
658
- else {
659
- break;
660
- }
661
- } while (true);
662
- }
663
- switch (msg.type) {
664
- case ProtocolMessageType.None: {
665
- break;
666
- }
667
- case ProtocolMessageType.Regular: {
668
- if (msg.id > this._incomingMsgId) {
669
- if (msg.id !== this._incomingMsgId + 1) {
670
- const now = Date.now();
671
- if (now - this._lastReplayRequestTime > 10000) {
672
- this._lastReplayRequestTime = now;
673
- this._socketWriter.write(( new ProtocolMessage(ProtocolMessageType.ReplayRequest, 0, 0, getEmptyBuffer())));
674
- }
675
- }
676
- else {
677
- this._incomingMsgId = msg.id;
678
- this._incomingMsgLastTime = Date.now();
679
- this._sendAckCheck();
680
- this._onMessage.fire(msg.data);
681
- }
682
- }
683
- break;
684
- }
685
- case ProtocolMessageType.Control: {
686
- this._onControlMessage.fire(msg.data);
687
- break;
688
- }
689
- case ProtocolMessageType.Ack: {
690
- break;
691
- }
692
- case ProtocolMessageType.Disconnect: {
693
- this._onDidDispose.fire();
694
- break;
695
- }
696
- case ProtocolMessageType.ReplayRequest: {
697
- const toSend = this._outgoingUnackMsg.toArray();
698
- for (let i = 0, len = toSend.length; i < len; i++) {
699
- this._socketWriter.write(toSend[i]);
700
- }
701
- this._recvAckCheck();
702
- break;
703
- }
704
- case ProtocolMessageType.Pause: {
705
- this._socketWriter.pause();
706
- break;
707
- }
708
- case ProtocolMessageType.Resume: {
709
- this._socketWriter.resume();
710
- break;
711
- }
712
- }
713
- }
714
- readEntireBuffer() {
715
- return this._socketReader.readEntireBuffer();
716
- }
717
- flush() {
718
- this._socketWriter.flush();
719
- }
720
- send(buffer) {
721
- const myId = ++this._outgoingMsgId;
722
- this._incomingAckId = this._incomingMsgId;
723
- const msg = ( new ProtocolMessage(ProtocolMessageType.Regular, myId, this._incomingAckId, buffer));
724
- this._outgoingUnackMsg.push(msg);
725
- if (!this._isReconnecting) {
726
- this._socketWriter.write(msg);
727
- this._recvAckCheck();
728
- }
729
- }
730
- sendControl(buffer) {
731
- const msg = ( new ProtocolMessage(ProtocolMessageType.Control, 0, 0, buffer));
732
- this._socketWriter.write(msg);
733
- }
734
- _sendAckCheck() {
735
- if (this._incomingMsgId <= this._incomingAckId) {
736
- return;
737
- }
738
- if (this._incomingAckTimeout) {
739
- return;
740
- }
741
- const timeSinceLastIncomingMsg = Date.now() - this._incomingMsgLastTime;
742
- if (timeSinceLastIncomingMsg >= ProtocolConstants.AcknowledgeTime) {
743
- this._sendAck();
744
- return;
745
- }
746
- this._incomingAckTimeout = setTimeout(() => {
747
- this._incomingAckTimeout = null;
748
- this._sendAckCheck();
749
- }, ProtocolConstants.AcknowledgeTime - timeSinceLastIncomingMsg + 5);
750
- }
751
- _recvAckCheck() {
752
- if (this._outgoingMsgId <= this._outgoingAckId) {
753
- return;
754
- }
755
- if (this._outgoingAckTimeout) {
756
- return;
757
- }
758
- if (this._isReconnecting) {
759
- return;
760
- }
761
- const oldestUnacknowledgedMsg = this._outgoingUnackMsg.peek();
762
- const timeSinceOldestUnacknowledgedMsg = Date.now() - oldestUnacknowledgedMsg.writtenTime;
763
- const timeSinceLastReceivedSomeData = Date.now() - this._socketReader.lastReadTime;
764
- const timeSinceLastTimeout = Date.now() - this._lastSocketTimeoutTime;
765
- if (timeSinceOldestUnacknowledgedMsg >= ProtocolConstants.TimeoutTime
766
- && timeSinceLastReceivedSomeData >= ProtocolConstants.TimeoutTime
767
- && timeSinceLastTimeout >= ProtocolConstants.TimeoutTime) {
768
- if (!this._loadEstimator.hasHighLoad()) {
769
- this._lastSocketTimeoutTime = Date.now();
770
- this._onSocketTimeout.fire({
771
- unacknowledgedMsgCount: this._outgoingUnackMsg.length(),
772
- timeSinceOldestUnacknowledgedMsg,
773
- timeSinceLastReceivedSomeData
774
- });
775
- return;
776
- }
777
- }
778
- const minimumTimeUntilTimeout = Math.max(ProtocolConstants.TimeoutTime - timeSinceOldestUnacknowledgedMsg, ProtocolConstants.TimeoutTime - timeSinceLastReceivedSomeData, ProtocolConstants.TimeoutTime - timeSinceLastTimeout, 500);
779
- this._outgoingAckTimeout = setTimeout(() => {
780
- this._outgoingAckTimeout = null;
781
- this._recvAckCheck();
782
- }, minimumTimeUntilTimeout);
783
- }
784
- _sendAck() {
785
- if (this._incomingMsgId <= this._incomingAckId) {
786
- return;
787
- }
788
- this._incomingAckId = this._incomingMsgId;
789
- const msg = ( new ProtocolMessage(ProtocolMessageType.Ack, 0, this._incomingAckId, getEmptyBuffer()));
790
- this._socketWriter.write(msg);
791
- }
792
- _sendKeepAlive() {
793
- this._incomingAckId = this._incomingMsgId;
794
- const msg = ( new ProtocolMessage(ProtocolMessageType.KeepAlive, 0, this._incomingAckId, getEmptyBuffer()));
795
- this._socketWriter.write(msg);
796
- }
797
- }
798
-
799
- export { BufferedEmitter, ChunkStream, Client, PersistentProtocol, Protocol, ProtocolConstants, SocketCloseEventType, SocketDiagnostics, SocketDiagnosticsEventType };