@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.
- package/README.md +3 -4
- package/extensions.d.ts +2 -0
- package/extensions.js +6 -3
- package/missing-services.js +2 -2
- package/package.json +12 -335
- package/services.d.ts +5 -0
- package/services.js +6 -2
- package/vscode/src/vs/base/browser/dom.d.ts +1 -1
- package/vscode/src/vs/base/common/observableInternal/index.js +8 -0
- package/vscode/src/vs/editor/browser/gpu/gpuUtils.d.ts +1 -1
- package/vscode/src/vs/editor/common/tokens/contiguousTokensEditing.d.ts +1 -1
- package/vscode/src/vs/editor/contrib/snippet/browser/snippetParser.d.ts +1 -1
- package/vscode/src/vs/editor/contrib/snippet/browser/snippetSession.d.ts +1 -1
- package/vscode/src/vs/platform/accessibilitySignal/browser/accessibilitySignalService.service.d.ts +1 -1
- package/vscode/src/vs/platform/contextview/browser/contextView.service.d.ts +4 -5
- package/vscode/src/vs/platform/diagnostics/common/diagnostics.service.d.ts +1 -1
- package/vscode/src/vs/platform/dialogs/common/dialogs.service.d.ts +2 -3
- package/vscode/src/vs/platform/environment/common/environment.service.d.ts +1 -1
- package/vscode/src/vs/platform/extensionManagement/common/extensionManagement.service.d.ts +4 -6
- package/vscode/src/vs/platform/extensionManagement/common/extensionStorage.service.d.ts +1 -1
- package/vscode/src/vs/platform/extensionManagement/common/extensionsProfileScannerService.service.d.ts +1 -1
- package/vscode/src/vs/platform/extensionManagement/common/extensionsScannerService.service.d.ts +2 -2
- package/vscode/src/vs/platform/extensions/common/extensions.d.ts +1 -0
- package/vscode/src/vs/platform/hover/browser/hover.d.ts +1 -1
- package/vscode/src/vs/platform/hover/browser/hover.service.d.ts +1 -1
- package/vscode/src/vs/platform/instantiation/common/extensions.d.ts +1 -0
- package/vscode/src/vs/platform/ipc/common/services.d.ts +1 -1
- package/vscode/src/vs/platform/keybinding/common/keybinding.service.d.ts +2 -2
- package/vscode/src/vs/platform/keyboardLayout/common/keyboardLayout.service.d.ts +1 -1
- package/vscode/src/vs/platform/label/common/label.service.d.ts +1 -1
- package/vscode/src/vs/platform/log/common/log.d.ts +1 -2
- package/vscode/src/vs/platform/log/common/log.service.d.ts +3 -3
- package/vscode/src/vs/platform/progress/common/progress.service.d.ts +1 -2
- package/vscode/src/vs/platform/remote/common/remoteSocketFactoryService.service.d.ts +1 -1
- package/vscode/src/vs/platform/request/common/request.service.d.ts +1 -1
- package/vscode/src/vs/platform/sign/common/sign.service.d.ts +1 -1
- package/vscode/src/vs/platform/telemetry/common/commonProperties.js +15 -0
- package/vscode/src/vs/platform/telemetry/common/telemetry.js +4 -1
- package/vscode/src/vs/platform/telemetry/common/telemetry.service.d.ts +2 -3
- package/vscode/src/vs/platform/telemetry/common/telemetryUtils.js +82 -6
- package/vscode/src/vs/platform/terminal/common/terminal.service.d.ts +4 -5
- package/vscode/src/vs/platform/theme/common/colorUtils.js +2 -2
- package/vscode/src/vs/platform/theme/common/colors/baseColors.js +17 -17
- package/vscode/src/vs/platform/theme/common/colors/chartsColors.js +8 -8
- package/vscode/src/vs/platform/theme/common/colors/editorColors.js +94 -94
- package/vscode/src/vs/platform/theme/common/colors/inputColors.js +45 -45
- package/vscode/src/vs/platform/theme/common/colors/listColors.js +36 -36
- package/vscode/src/vs/platform/theme/common/colors/menuColors.js +7 -7
- package/vscode/src/vs/platform/theme/common/colors/minimapColors.js +11 -11
- package/vscode/src/vs/platform/theme/common/colors/miscColors.js +15 -15
- package/vscode/src/vs/platform/theme/common/colors/quickpickColors.js +9 -9
- package/vscode/src/vs/platform/theme/common/colors/searchColors.js +3 -3
- package/vscode/src/vs/platform/theme/common/iconRegistry.js +5 -5
- package/vscode/src/vs/platform/tunnel/common/tunnel.d.ts +1 -1
- package/vscode/src/vs/platform/tunnel/common/tunnel.service.d.ts +1 -1
- package/vscode/src/vs/platform/undoRedo/common/undoRedoService.js +20 -20
- package/vscode/src/vs/platform/uriIdentity/common/uriIdentity.service.d.ts +1 -1
- package/vscode/src/vs/platform/url/common/url.service.d.ts +1 -1
- package/vscode/src/vs/platform/userDataProfile/common/userDataProfile.js +1 -1
- package/vscode/src/vs/platform/userDataProfile/common/userDataProfileStorageService.service.d.ts +1 -1
- package/vscode/src/vs/platform/userDataSync/common/userDataSync.js +5 -5
- package/vscode/src/vs/platform/userDataSync/common/userDataSync.service.d.ts +8 -8
- package/vscode/src/vs/platform/workspace/common/editSessions.service.d.ts +1 -1
- package/vscode/src/vs/platform/workspace/common/workspace.js +1 -1
- package/vscode/src/vs/platform/workspace/common/workspaceTrust.service.d.ts +4 -5
- package/vscode/src/vs/workbench/api/common/extHost.protocol.d.ts +1 -1
- package/vscode/src/vs/workbench/api/common/extHostDiagnostics.js +1 -1
- package/vscode/src/vs/workbench/api/common/extHostExtensionService.js +2 -2
- package/vscode/src/vs/workbench/api/common/extHostLanguageFeatures.js +2 -2
- package/vscode/src/vs/workbench/api/common/extHostLanguageModels.js +1 -1
- package/vscode/src/vs/workbench/api/common/extHostLogService.js +1 -1
- package/vscode/src/vs/workbench/api/common/extHostNotebook.js +2 -2
- package/vscode/src/vs/workbench/api/common/extHostStatusBar.js +2 -2
- package/vscode/src/vs/workbench/api/common/extHostTelemetry.js +1 -1
- package/vscode/src/vs/workbench/api/common/extHostTerminalService.js +1 -1
- package/vscode/src/vs/workbench/api/common/extHostTesting.d.ts +1 -1
- package/vscode/src/vs/workbench/api/common/extHostTreeViews.js +1 -1
- package/vscode/src/vs/workbench/api/common/extHostTunnelService.js +2 -2
- package/vscode/src/vs/workbench/api/common/extHostWorkspace.js +1 -1
- package/vscode/src/vs/workbench/api/common/extensionHostMain.d.ts +1 -1
- package/vscode/src/vs/workbench/api/common/jsonValidationExtensionPoint.js +12 -12
- package/vscode/src/vs/workbench/browser/actions/developerActions.js +31 -31
- package/vscode/src/vs/workbench/browser/actions/textInputActions.js +6 -6
- package/vscode/src/vs/workbench/common/configuration.js +10 -10
- package/vscode/src/vs/workbench/common/contextkeys.js +70 -70
- package/vscode/src/vs/workbench/common/editor.js +4 -4
- package/vscode/src/vs/workbench/common/theme.js +158 -158
- package/vscode/src/vs/workbench/common/views.js +4 -4
- package/vscode/src/vs/workbench/contrib/accessibility/browser/accessibilityConfiguration.js +137 -137
- package/vscode/src/vs/workbench/contrib/accessibility/browser/accessibleViewActions.js +12 -12
- package/vscode/src/vs/workbench/contrib/chat/browser/chat.service.d.ts +3 -5
- package/vscode/src/vs/workbench/contrib/chat/common/chatAgents.d.ts +1 -2
- package/vscode/src/vs/workbench/contrib/chat/common/chatCodeMapperService.service.d.ts +1 -1
- package/vscode/src/vs/workbench/contrib/chat/common/chatContextKeys.js +24 -24
- package/vscode/src/vs/workbench/contrib/chat/common/chatEditingService.js +1 -1
- package/vscode/src/vs/workbench/contrib/chat/common/chatEditingService.service.d.ts +2 -2
- package/vscode/src/vs/workbench/contrib/chat/common/chatService.js +2 -1
- package/vscode/src/vs/workbench/contrib/chat/common/chatService.service.d.ts +1 -1
- package/vscode/src/vs/workbench/contrib/chat/common/chatSlashCommands.service.d.ts +2 -2
- package/vscode/src/vs/workbench/contrib/chat/common/chatVariables.service.d.ts +1 -1
- package/vscode/src/vs/workbench/contrib/chat/common/languageModels.js +6 -6
- package/vscode/src/vs/workbench/contrib/codeActions/browser/codeActionsContribution.js +13 -13
- package/vscode/src/vs/workbench/contrib/codeEditor/browser/dictation/editorDictation.js +4 -4
- package/vscode/src/vs/workbench/contrib/codeEditor/browser/diffEditorAccessibilityHelp.js +5 -5
- package/vscode/src/vs/workbench/contrib/codeEditor/browser/diffEditorHelper.js +3 -3
- package/vscode/src/vs/workbench/contrib/codeEditor/browser/largeFileOptimizations.js +3 -3
- package/vscode/src/vs/workbench/contrib/codeEditor/browser/saveParticipants.js +4 -4
- package/vscode/src/vs/workbench/contrib/codeEditor/browser/toggleMinimap.js +2 -2
- package/vscode/src/vs/workbench/contrib/codeEditor/browser/toggleMultiCursorModifier.js +4 -4
- package/vscode/src/vs/workbench/contrib/codeEditor/browser/toggleRenderControlCharacter.js +2 -2
- package/vscode/src/vs/workbench/contrib/codeEditor/browser/toggleRenderWhitespace.js +2 -2
- package/vscode/src/vs/workbench/contrib/codeEditor/browser/toggleWordWrap.js +5 -5
- package/vscode/src/vs/workbench/contrib/comments/browser/commentService.service.d.ts +3 -3
- package/vscode/src/vs/workbench/contrib/comments/browser/commentsAccessibility.js +12 -12
- package/vscode/src/vs/workbench/contrib/comments/common/commentContextKeys.js +10 -10
- package/vscode/src/vs/workbench/contrib/debug/common/abstractDebugAdapter.js +1 -1
- package/vscode/src/vs/workbench/contrib/debug/common/debug.js +64 -64
- package/vscode/src/vs/workbench/contrib/debug/common/debug.service.d.ts +1 -1
- package/vscode/src/vs/workbench/contrib/debug/common/debugVisualizers.service.d.ts +2 -2
- package/vscode/src/vs/workbench/contrib/editSessions/common/editSessions.service.d.ts +3 -3
- package/vscode/src/vs/workbench/contrib/extensions/common/extensions.service.d.ts +6 -6
- package/vscode/src/vs/workbench/contrib/files/browser/fileConstants.js +6 -6
- package/vscode/src/vs/workbench/contrib/files/browser/files.service.d.ts +3 -3
- package/vscode/src/vs/workbench/contrib/folding/browser/folding.contribution.js +3 -3
- package/vscode/src/vs/workbench/contrib/format/browser/formatActionsMultiple.js +20 -20
- package/vscode/src/vs/workbench/contrib/format/browser/formatActionsNone.js +4 -4
- package/vscode/src/vs/workbench/contrib/format/browser/formatModified.js +1 -1
- package/vscode/src/vs/workbench/contrib/inlayHints/browser/inlayHintsAccessibilty.js +4 -4
- package/vscode/src/vs/workbench/contrib/list/browser/listResizeColumnAction.js +2 -2
- package/vscode/src/vs/workbench/contrib/list/browser/tableColumnResizeQuickPick.js +5 -5
- package/vscode/src/vs/workbench/contrib/logs/common/defaultLogLevels.service.d.ts +1 -1
- package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/chatEdit/notebookOriginalCellModelFactory.service.d.ts +1 -1
- package/vscode/src/vs/workbench/contrib/notebook/browser/services/notebookEditorService.service.d.ts +5 -5
- package/vscode/src/vs/workbench/contrib/notebook/common/notebookCellStatusBarService.service.d.ts +1 -1
- package/vscode/src/vs/workbench/contrib/notebook/common/notebookCommon.d.ts +1 -1
- package/vscode/src/vs/workbench/contrib/notebook/common/notebookEditorModelResolverService.service.d.ts +3 -3
- package/vscode/src/vs/workbench/contrib/notebook/common/notebookExecutionService.d.ts +1 -1
- package/vscode/src/vs/workbench/contrib/notebook/common/notebookExecutionStateService.service.d.ts +1 -1
- package/vscode/src/vs/workbench/contrib/notebook/common/notebookService.service.d.ts +7 -7
- package/vscode/src/vs/workbench/contrib/output/common/outputChannelModelService.service.d.ts +1 -1
- package/vscode/src/vs/workbench/contrib/scm/browser/diff.service.d.ts +2 -2
- package/vscode/src/vs/workbench/contrib/scm/browser/dirtyDiffSwitcher.js +2 -2
- package/vscode/src/vs/workbench/contrib/scm/browser/dirtydiffDecorator.js +23 -23
- package/vscode/src/vs/workbench/contrib/scm/common/quickDiff.service.d.ts +2 -2
- package/vscode/src/vs/workbench/contrib/scm/common/scm.service.d.ts +3 -4
- package/vscode/src/vs/workbench/contrib/search/browser/replace.service.d.ts +1 -1
- package/vscode/src/vs/workbench/contrib/snippets/browser/snippetCompletionProvider.js +3 -3
- package/vscode/src/vs/workbench/contrib/snippets/browser/snippets.service.d.ts +1 -1
- package/vscode/src/vs/workbench/contrib/snippets/browser/snippetsFile.js +3 -3
- package/vscode/src/vs/workbench/contrib/snippets/browser/snippetsService.js +9 -9
- package/vscode/src/vs/workbench/contrib/speech/common/speechService.js +29 -29
- package/vscode/src/vs/workbench/contrib/tags/common/workspaceTags.service.d.ts +1 -1
- package/vscode/src/vs/workbench/contrib/tasks/common/taskDefinitionRegistry.js +5 -5
- package/vscode/src/vs/workbench/contrib/tasks/common/taskService.service.d.ts +3 -3
- package/vscode/src/vs/workbench/contrib/tasks/common/tasks.js +3 -3
- package/vscode/src/vs/workbench/contrib/terminal/browser/terminal.service.d.ts +10 -11
- package/vscode/src/vs/workbench/contrib/terminal/common/terminal.service.d.ts +4 -5
- package/vscode/src/vs/workbench/contrib/terminalContrib/links/browser/links.service.d.ts +1 -1
- package/vscode/src/vs/workbench/contrib/testing/common/constants.js +11 -11
- package/vscode/src/vs/workbench/contrib/testing/common/testCoverageService.service.d.ts +1 -1
- package/vscode/src/vs/workbench/contrib/testing/common/testExplorerFilterState.service.d.ts +1 -1
- package/vscode/src/vs/workbench/contrib/testing/common/testProfileService.service.d.ts +1 -1
- package/vscode/src/vs/workbench/contrib/testing/common/testResultService.service.d.ts +2 -2
- package/vscode/src/vs/workbench/contrib/testing/common/testService.service.d.ts +1 -1
- package/vscode/src/vs/workbench/contrib/testing/common/testTypes.js +3 -3
- package/vscode/src/vs/workbench/contrib/testing/common/testingDecorations.service.d.ts +1 -1
- package/vscode/src/vs/workbench/contrib/testing/common/testingPeekOpener.service.d.ts +2 -2
- package/vscode/src/vs/workbench/contrib/timeline/common/timeline.service.d.ts +1 -1
- package/vscode/src/vs/workbench/contrib/webview/browser/webview.service.d.ts +1 -1
- package/vscode/src/vs/workbench/contrib/webviewPanel/browser/webviewWorkbenchService.service.d.ts +3 -3
- package/vscode/src/vs/workbench/services/configurationResolver/common/configurationResolver.service.d.ts +2 -2
- package/vscode/src/vs/workbench/services/configurationResolver/common/variableResolver.js +15 -15
- package/vscode/src/vs/workbench/services/decorations/common/decorations.service.d.ts +1 -1
- package/vscode/src/vs/workbench/services/editor/common/editorGroupsService.service.d.ts +2 -2
- package/vscode/src/vs/workbench/services/editor/common/editorPaneService.service.d.ts +1 -1
- package/vscode/src/vs/workbench/services/editor/common/editorResolverService.js +1 -1
- package/vscode/src/vs/workbench/services/editor/common/editorResolverService.service.d.ts +2 -2
- package/vscode/src/vs/workbench/services/editor/common/editorService.service.d.ts +6 -6
- package/vscode/src/vs/workbench/services/environment/common/environmentService.service.d.ts +2 -2
- package/vscode/src/vs/workbench/services/environment/common/environmentService.service.js +1 -1
- package/vscode/src/vs/workbench/services/extensionManagement/common/extensionFeatures.service.d.ts +1 -1
- package/vscode/src/vs/workbench/services/extensionManagement/common/extensionManagement.service.d.ts +5 -9
- package/vscode/src/vs/workbench/services/extensionManagement/common/extensionManagement.service.js +1 -1
- package/vscode/src/vs/workbench/services/extensionRecommendations/common/extensionRecommendations.service.d.ts +1 -2
- package/vscode/src/vs/workbench/services/extensions/common/extensionManifestPropertiesService.service.d.ts +1 -1
- package/vscode/src/vs/workbench/services/extensions/common/extensions.d.ts +2 -1
- package/vscode/src/vs/workbench/services/extensions/common/extensions.service.d.ts +2 -2
- package/vscode/src/vs/workbench/services/extensions/common/extensionsRegistry.js +83 -83
- package/vscode/src/vs/workbench/services/extensions/common/rpcProtocol.d.ts +1 -1
- package/vscode/src/vs/workbench/services/files/common/elevatedFileService.service.d.ts +2 -2
- package/vscode/src/vs/workbench/services/filesConfiguration/common/filesConfigurationService.service.d.ts +3 -3
- package/vscode/src/vs/workbench/services/history/common/history.service.d.ts +1 -1
- package/vscode/src/vs/workbench/services/host/browser/host.service.d.ts +1 -1
- package/vscode/src/vs/workbench/services/language/common/languageService.js +28 -28
- package/vscode/src/vs/workbench/services/layout/browser/layoutService.service.d.ts +5 -4
- package/vscode/src/vs/workbench/services/panecomposite/browser/panecomposite.service.d.ts +1 -1
- package/vscode/src/vs/workbench/services/preferences/common/preferences.service.d.ts +1 -1
- package/vscode/src/vs/workbench/services/remote/common/remoteAgentService.service.d.ts +2 -2
- package/vscode/src/vs/workbench/services/remote/common/remoteExplorerService.js +8 -8
- package/vscode/src/vs/workbench/services/remote/common/remoteExplorerService.service.d.ts +3 -3
- package/vscode/src/vs/workbench/services/remote/common/tunnelModel.js +6 -6
- package/vscode/src/vs/workbench/services/search/common/queryBuilder.js +1 -1
- package/vscode/src/vs/workbench/services/statusbar/browser/statusbar.service.d.ts +1 -1
- package/vscode/src/vs/workbench/services/textMate/browser/textMateTokenizationFeature.service.d.ts +1 -1
- package/vscode/src/vs/workbench/services/textfile/common/textEditorService.service.d.ts +1 -1
- package/vscode/src/vs/workbench/services/textfile/common/textfiles.service.d.ts +4 -4
- package/vscode/src/vs/workbench/services/themes/common/colorExtensionPoint.js +22 -22
- package/vscode/src/vs/workbench/services/themes/common/iconExtensionPoint.js +14 -14
- package/vscode/src/vs/workbench/services/themes/common/productIconThemeSchema.js +8 -8
- package/vscode/src/vs/workbench/services/title/browser/titleService.service.d.ts +1 -1
- package/vscode/src/vs/workbench/services/userDataProfile/common/userDataProfile.service.d.ts +4 -6
- package/vscode/src/vs/workbench/services/userDataSync/common/userDataSync.js +11 -11
- package/vscode/src/vs/workbench/services/userDataSync/common/userDataSync.service.d.ts +1 -1
- package/vscode/src/vs/workbench/services/views/common/viewsService.service.d.ts +1 -1
- package/vscode/src/vs/workbench/services/workingCopy/common/workingCopyBackup.service.d.ts +1 -1
- package/vscode/src/vs/workbench/services/workingCopy/common/workingCopyEditorService.service.d.ts +1 -1
- package/vscode/src/vs/workbench/services/workingCopy/common/workingCopyFileService.service.d.ts +3 -3
- package/vscode/src/vs/workbench/services/workingCopy/common/workingCopyHistory.service.d.ts +1 -1
- package/vscode/src/vs/workbench/services/workingCopy/common/workingCopyService.service.d.ts +1 -1
- package/vscode/src/vs/workbench/services/workspaces/common/workspaceEditing.service.d.ts +1 -1
- package/api.js +0 -309
- package/localExtensionHost.d.ts +0 -42
- package/localExtensionHost.js +0 -224
- package/vscode/src/vs/base/parts/ipc/common/ipc.d.ts +0 -175
- package/vscode/src/vs/base/parts/ipc/common/ipc.js +0 -711
- package/vscode/src/vs/base/parts/ipc/common/ipc.net.d.ts +0 -195
- package/vscode/src/vs/base/parts/ipc/common/ipc.net.js +0 -799
- package/vscode/src/vs/workbench/services/environment/browser/environmentService.service.d.ts +0 -7
- package/vscode/src/vs/workbench/services/environment/browser/environmentService.service.js +0 -7
|
@@ -1,711 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
import { __decorate } from '../../../../../../../external/tslib/tslib.es6.js';
|
|
3
|
-
import '../../../common/arrays.js';
|
|
4
|
-
import { createCancelablePromise } from '../../../common/async.js';
|
|
5
|
-
import { VSBuffer } from '../../../common/buffer.js';
|
|
6
|
-
import { CancellationTokenSource, CancellationToken } from '../../../common/cancellation.js';
|
|
7
|
-
import { memoize } from '../../../common/decorators.js';
|
|
8
|
-
import { CancellationError, ErrorNoTelemetry } from '../../../common/errors.js';
|
|
9
|
-
import { Emitter, Event, Relay } from '../../../common/event.js';
|
|
10
|
-
import { createSingleCallFunction } from '../../../common/functional.js';
|
|
11
|
-
import { toDisposable, dispose } from '../../../common/lifecycle.js';
|
|
12
|
-
import { revive } from '../../../common/marshalling.js';
|
|
13
|
-
import { isUpperAsciiLetter } from '../../../common/strings.js';
|
|
14
|
-
import { isUndefinedOrNull } from '../../../common/types.js';
|
|
15
|
-
|
|
16
|
-
var RequestType;
|
|
17
|
-
(function (RequestType) {
|
|
18
|
-
RequestType[RequestType["Promise"] = 100] = "Promise";
|
|
19
|
-
RequestType[RequestType["PromiseCancel"] = 101] = "PromiseCancel";
|
|
20
|
-
RequestType[RequestType["EventListen"] = 102] = "EventListen";
|
|
21
|
-
RequestType[RequestType["EventDispose"] = 103] = "EventDispose";
|
|
22
|
-
})(RequestType || (RequestType = {}));
|
|
23
|
-
function requestTypeToStr(type) {
|
|
24
|
-
switch (type) {
|
|
25
|
-
case RequestType.Promise:
|
|
26
|
-
return 'req';
|
|
27
|
-
case RequestType.PromiseCancel:
|
|
28
|
-
return 'cancel';
|
|
29
|
-
case RequestType.EventListen:
|
|
30
|
-
return 'subscribe';
|
|
31
|
-
case RequestType.EventDispose:
|
|
32
|
-
return 'unsubscribe';
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
var ResponseType;
|
|
36
|
-
(function (ResponseType) {
|
|
37
|
-
ResponseType[ResponseType["Initialize"] = 200] = "Initialize";
|
|
38
|
-
ResponseType[ResponseType["PromiseSuccess"] = 201] = "PromiseSuccess";
|
|
39
|
-
ResponseType[ResponseType["PromiseError"] = 202] = "PromiseError";
|
|
40
|
-
ResponseType[ResponseType["PromiseErrorObj"] = 203] = "PromiseErrorObj";
|
|
41
|
-
ResponseType[ResponseType["EventFire"] = 204] = "EventFire";
|
|
42
|
-
})(ResponseType || (ResponseType = {}));
|
|
43
|
-
function responseTypeToStr(type) {
|
|
44
|
-
switch (type) {
|
|
45
|
-
case ResponseType.Initialize:
|
|
46
|
-
return `init`;
|
|
47
|
-
case ResponseType.PromiseSuccess:
|
|
48
|
-
return `reply:`;
|
|
49
|
-
case ResponseType.PromiseError:
|
|
50
|
-
case ResponseType.PromiseErrorObj:
|
|
51
|
-
return `replyErr:`;
|
|
52
|
-
case ResponseType.EventFire:
|
|
53
|
-
return `event:`;
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
var State;
|
|
57
|
-
(function (State) {
|
|
58
|
-
State[State["Uninitialized"] = 0] = "Uninitialized";
|
|
59
|
-
State[State["Idle"] = 1] = "Idle";
|
|
60
|
-
})(State || (State = {}));
|
|
61
|
-
function readIntVQL(reader) {
|
|
62
|
-
let value = 0;
|
|
63
|
-
for (let n = 0;; n += 7) {
|
|
64
|
-
const next = reader.read(1);
|
|
65
|
-
value |= (next.buffer[0] & 0b01111111) << n;
|
|
66
|
-
if (!(next.buffer[0] & 0b10000000)) {
|
|
67
|
-
return value;
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
const vqlZero = createOneByteBuffer(0);
|
|
72
|
-
function writeInt32VQL(writer, value) {
|
|
73
|
-
if (value === 0) {
|
|
74
|
-
writer.write(vqlZero);
|
|
75
|
-
return;
|
|
76
|
-
}
|
|
77
|
-
let len = 0;
|
|
78
|
-
for (let v2 = value; v2 !== 0; v2 = v2 >>> 7) {
|
|
79
|
-
len++;
|
|
80
|
-
}
|
|
81
|
-
const scratch = VSBuffer.alloc(len);
|
|
82
|
-
for (let i = 0; value !== 0; i++) {
|
|
83
|
-
scratch.buffer[i] = value & 0b01111111;
|
|
84
|
-
value = value >>> 7;
|
|
85
|
-
if (value > 0) {
|
|
86
|
-
scratch.buffer[i] |= 0b10000000;
|
|
87
|
-
}
|
|
88
|
-
}
|
|
89
|
-
writer.write(scratch);
|
|
90
|
-
}
|
|
91
|
-
class BufferReader {
|
|
92
|
-
constructor(buffer) {
|
|
93
|
-
this.buffer = buffer;
|
|
94
|
-
this.pos = 0;
|
|
95
|
-
}
|
|
96
|
-
read(bytes) {
|
|
97
|
-
const result = this.buffer.slice(this.pos, this.pos + bytes);
|
|
98
|
-
this.pos += result.byteLength;
|
|
99
|
-
return result;
|
|
100
|
-
}
|
|
101
|
-
}
|
|
102
|
-
class BufferWriter {
|
|
103
|
-
constructor() {
|
|
104
|
-
this.buffers = [];
|
|
105
|
-
}
|
|
106
|
-
get buffer() {
|
|
107
|
-
return VSBuffer.concat(this.buffers);
|
|
108
|
-
}
|
|
109
|
-
write(buffer) {
|
|
110
|
-
this.buffers.push(buffer);
|
|
111
|
-
}
|
|
112
|
-
}
|
|
113
|
-
var DataType;
|
|
114
|
-
(function (DataType) {
|
|
115
|
-
DataType[DataType["Undefined"] = 0] = "Undefined";
|
|
116
|
-
DataType[DataType["String"] = 1] = "String";
|
|
117
|
-
DataType[DataType["Buffer"] = 2] = "Buffer";
|
|
118
|
-
DataType[DataType["VSBuffer"] = 3] = "VSBuffer";
|
|
119
|
-
DataType[DataType["Array"] = 4] = "Array";
|
|
120
|
-
DataType[DataType["Object"] = 5] = "Object";
|
|
121
|
-
DataType[DataType["Int"] = 6] = "Int";
|
|
122
|
-
})(DataType || (DataType = {}));
|
|
123
|
-
function createOneByteBuffer(value) {
|
|
124
|
-
const result = VSBuffer.alloc(1);
|
|
125
|
-
result.writeUInt8(value, 0);
|
|
126
|
-
return result;
|
|
127
|
-
}
|
|
128
|
-
const BufferPresets = {
|
|
129
|
-
Undefined: createOneByteBuffer(DataType.Undefined),
|
|
130
|
-
String: createOneByteBuffer(DataType.String),
|
|
131
|
-
Buffer: createOneByteBuffer(DataType.Buffer),
|
|
132
|
-
VSBuffer: createOneByteBuffer(DataType.VSBuffer),
|
|
133
|
-
Array: createOneByteBuffer(DataType.Array),
|
|
134
|
-
Object: createOneByteBuffer(DataType.Object),
|
|
135
|
-
Uint: createOneByteBuffer(DataType.Int),
|
|
136
|
-
};
|
|
137
|
-
const hasBuffer = (typeof Buffer !== 'undefined');
|
|
138
|
-
function serialize(writer, data) {
|
|
139
|
-
if (typeof data === 'undefined') {
|
|
140
|
-
writer.write(BufferPresets.Undefined);
|
|
141
|
-
}
|
|
142
|
-
else if (typeof data === 'string') {
|
|
143
|
-
const buffer = VSBuffer.fromString(data);
|
|
144
|
-
writer.write(BufferPresets.String);
|
|
145
|
-
writeInt32VQL(writer, buffer.byteLength);
|
|
146
|
-
writer.write(buffer);
|
|
147
|
-
}
|
|
148
|
-
else if (hasBuffer && Buffer.isBuffer(data)) {
|
|
149
|
-
const buffer = VSBuffer.wrap(data);
|
|
150
|
-
writer.write(BufferPresets.Buffer);
|
|
151
|
-
writeInt32VQL(writer, buffer.byteLength);
|
|
152
|
-
writer.write(buffer);
|
|
153
|
-
}
|
|
154
|
-
else if (data instanceof VSBuffer) {
|
|
155
|
-
writer.write(BufferPresets.VSBuffer);
|
|
156
|
-
writeInt32VQL(writer, data.byteLength);
|
|
157
|
-
writer.write(data);
|
|
158
|
-
}
|
|
159
|
-
else if (Array.isArray(data)) {
|
|
160
|
-
writer.write(BufferPresets.Array);
|
|
161
|
-
writeInt32VQL(writer, data.length);
|
|
162
|
-
for (const el of data) {
|
|
163
|
-
serialize(writer, el);
|
|
164
|
-
}
|
|
165
|
-
}
|
|
166
|
-
else if (typeof data === 'number' && (data | 0) === data) {
|
|
167
|
-
writer.write(BufferPresets.Uint);
|
|
168
|
-
writeInt32VQL(writer, data);
|
|
169
|
-
}
|
|
170
|
-
else {
|
|
171
|
-
const buffer = VSBuffer.fromString(JSON.stringify(data));
|
|
172
|
-
writer.write(BufferPresets.Object);
|
|
173
|
-
writeInt32VQL(writer, buffer.byteLength);
|
|
174
|
-
writer.write(buffer);
|
|
175
|
-
}
|
|
176
|
-
}
|
|
177
|
-
function deserialize(reader) {
|
|
178
|
-
const type = reader.read(1).readUInt8(0);
|
|
179
|
-
switch (type) {
|
|
180
|
-
case DataType.Undefined: return undefined;
|
|
181
|
-
case DataType.String: return ( reader.read(readIntVQL(reader)).toString());
|
|
182
|
-
case DataType.Buffer: return reader.read(readIntVQL(reader)).buffer;
|
|
183
|
-
case DataType.VSBuffer: return reader.read(readIntVQL(reader));
|
|
184
|
-
case DataType.Array: {
|
|
185
|
-
const length = readIntVQL(reader);
|
|
186
|
-
const result = [];
|
|
187
|
-
for (let i = 0; i < length; i++) {
|
|
188
|
-
result.push(deserialize(reader));
|
|
189
|
-
}
|
|
190
|
-
return result;
|
|
191
|
-
}
|
|
192
|
-
case DataType.Object: return JSON.parse(( reader.read(readIntVQL(reader)).toString()));
|
|
193
|
-
case DataType.Int: return readIntVQL(reader);
|
|
194
|
-
}
|
|
195
|
-
}
|
|
196
|
-
class ChannelServer {
|
|
197
|
-
constructor(protocol, ctx, logger = null, timeoutDelay = 1000) {
|
|
198
|
-
this.protocol = protocol;
|
|
199
|
-
this.ctx = ctx;
|
|
200
|
-
this.logger = logger;
|
|
201
|
-
this.timeoutDelay = timeoutDelay;
|
|
202
|
-
this.channels = ( new Map());
|
|
203
|
-
this.activeRequests = ( new Map());
|
|
204
|
-
this.pendingRequests = ( new Map());
|
|
205
|
-
this.protocolListener = this.protocol.onMessage(msg => this.onRawMessage(msg));
|
|
206
|
-
this.sendResponse({ type: ResponseType.Initialize });
|
|
207
|
-
}
|
|
208
|
-
registerChannel(channelName, channel) {
|
|
209
|
-
this.channels.set(channelName, channel);
|
|
210
|
-
setTimeout(() => this.flushPendingRequests(channelName), 0);
|
|
211
|
-
}
|
|
212
|
-
sendResponse(response) {
|
|
213
|
-
switch (response.type) {
|
|
214
|
-
case ResponseType.Initialize: {
|
|
215
|
-
const msgLength = this.send([response.type]);
|
|
216
|
-
this.logger?.logOutgoing(msgLength, 0, RequestInitiator.OtherSide, responseTypeToStr(response.type));
|
|
217
|
-
return;
|
|
218
|
-
}
|
|
219
|
-
case ResponseType.PromiseSuccess:
|
|
220
|
-
case ResponseType.PromiseError:
|
|
221
|
-
case ResponseType.EventFire:
|
|
222
|
-
case ResponseType.PromiseErrorObj: {
|
|
223
|
-
const msgLength = this.send([response.type, response.id], response.data);
|
|
224
|
-
this.logger?.logOutgoing(msgLength, response.id, RequestInitiator.OtherSide, responseTypeToStr(response.type), response.data);
|
|
225
|
-
return;
|
|
226
|
-
}
|
|
227
|
-
}
|
|
228
|
-
}
|
|
229
|
-
send(header, body = undefined) {
|
|
230
|
-
const writer = ( new BufferWriter());
|
|
231
|
-
serialize(writer, header);
|
|
232
|
-
serialize(writer, body);
|
|
233
|
-
return this.sendBuffer(writer.buffer);
|
|
234
|
-
}
|
|
235
|
-
sendBuffer(message) {
|
|
236
|
-
try {
|
|
237
|
-
this.protocol.send(message);
|
|
238
|
-
return message.byteLength;
|
|
239
|
-
}
|
|
240
|
-
catch (err) {
|
|
241
|
-
return 0;
|
|
242
|
-
}
|
|
243
|
-
}
|
|
244
|
-
onRawMessage(message) {
|
|
245
|
-
const reader = ( new BufferReader(message));
|
|
246
|
-
const header = deserialize(reader);
|
|
247
|
-
const body = deserialize(reader);
|
|
248
|
-
const type = header[0];
|
|
249
|
-
switch (type) {
|
|
250
|
-
case RequestType.Promise:
|
|
251
|
-
this.logger?.logIncoming(message.byteLength, header[1], RequestInitiator.OtherSide, `${requestTypeToStr(type)}: ${header[2]}.${header[3]}`, body);
|
|
252
|
-
return this.onPromise({ type, id: header[1], channelName: header[2], name: header[3], arg: body });
|
|
253
|
-
case RequestType.EventListen:
|
|
254
|
-
this.logger?.logIncoming(message.byteLength, header[1], RequestInitiator.OtherSide, `${requestTypeToStr(type)}: ${header[2]}.${header[3]}`, body);
|
|
255
|
-
return this.onEventListen({ type, id: header[1], channelName: header[2], name: header[3], arg: body });
|
|
256
|
-
case RequestType.PromiseCancel:
|
|
257
|
-
this.logger?.logIncoming(message.byteLength, header[1], RequestInitiator.OtherSide, `${requestTypeToStr(type)}`);
|
|
258
|
-
return this.disposeActiveRequest({ type, id: header[1] });
|
|
259
|
-
case RequestType.EventDispose:
|
|
260
|
-
this.logger?.logIncoming(message.byteLength, header[1], RequestInitiator.OtherSide, `${requestTypeToStr(type)}`);
|
|
261
|
-
return this.disposeActiveRequest({ type, id: header[1] });
|
|
262
|
-
}
|
|
263
|
-
}
|
|
264
|
-
onPromise(request) {
|
|
265
|
-
const channel = this.channels.get(request.channelName);
|
|
266
|
-
if (!channel) {
|
|
267
|
-
this.collectPendingRequest(request);
|
|
268
|
-
return;
|
|
269
|
-
}
|
|
270
|
-
const cancellationTokenSource = ( new CancellationTokenSource());
|
|
271
|
-
let promise;
|
|
272
|
-
try {
|
|
273
|
-
promise = channel.call(this.ctx, request.name, request.arg, cancellationTokenSource.token);
|
|
274
|
-
}
|
|
275
|
-
catch (err) {
|
|
276
|
-
promise = Promise.reject(err);
|
|
277
|
-
}
|
|
278
|
-
const id = request.id;
|
|
279
|
-
promise.then(data => {
|
|
280
|
-
this.sendResponse({ id, data, type: ResponseType.PromiseSuccess });
|
|
281
|
-
}, err => {
|
|
282
|
-
if (err instanceof Error) {
|
|
283
|
-
this.sendResponse({
|
|
284
|
-
id, data: {
|
|
285
|
-
message: err.message,
|
|
286
|
-
name: err.name,
|
|
287
|
-
stack: err.stack ? err.stack.split('\n') : undefined
|
|
288
|
-
}, type: ResponseType.PromiseError
|
|
289
|
-
});
|
|
290
|
-
}
|
|
291
|
-
else {
|
|
292
|
-
this.sendResponse({ id, data: err, type: ResponseType.PromiseErrorObj });
|
|
293
|
-
}
|
|
294
|
-
}).finally(() => {
|
|
295
|
-
disposable.dispose();
|
|
296
|
-
this.activeRequests.delete(request.id);
|
|
297
|
-
});
|
|
298
|
-
const disposable = toDisposable(() => cancellationTokenSource.cancel());
|
|
299
|
-
this.activeRequests.set(request.id, disposable);
|
|
300
|
-
}
|
|
301
|
-
onEventListen(request) {
|
|
302
|
-
const channel = this.channels.get(request.channelName);
|
|
303
|
-
if (!channel) {
|
|
304
|
-
this.collectPendingRequest(request);
|
|
305
|
-
return;
|
|
306
|
-
}
|
|
307
|
-
const id = request.id;
|
|
308
|
-
const event = channel.listen(this.ctx, request.name, request.arg);
|
|
309
|
-
const disposable = event(data => this.sendResponse({ id, data, type: ResponseType.EventFire }));
|
|
310
|
-
this.activeRequests.set(request.id, disposable);
|
|
311
|
-
}
|
|
312
|
-
disposeActiveRequest(request) {
|
|
313
|
-
const disposable = this.activeRequests.get(request.id);
|
|
314
|
-
if (disposable) {
|
|
315
|
-
disposable.dispose();
|
|
316
|
-
this.activeRequests.delete(request.id);
|
|
317
|
-
}
|
|
318
|
-
}
|
|
319
|
-
collectPendingRequest(request) {
|
|
320
|
-
let pendingRequests = this.pendingRequests.get(request.channelName);
|
|
321
|
-
if (!pendingRequests) {
|
|
322
|
-
pendingRequests = [];
|
|
323
|
-
this.pendingRequests.set(request.channelName, pendingRequests);
|
|
324
|
-
}
|
|
325
|
-
const timer = setTimeout(() => {
|
|
326
|
-
console.error(`Unknown channel: ${request.channelName}`);
|
|
327
|
-
if (request.type === RequestType.Promise) {
|
|
328
|
-
this.sendResponse({
|
|
329
|
-
id: request.id,
|
|
330
|
-
data: { name: 'Unknown channel', message: `Channel name '${request.channelName}' timed out after ${this.timeoutDelay}ms`, stack: undefined },
|
|
331
|
-
type: ResponseType.PromiseError
|
|
332
|
-
});
|
|
333
|
-
}
|
|
334
|
-
}, this.timeoutDelay);
|
|
335
|
-
pendingRequests.push({ request, timeoutTimer: timer });
|
|
336
|
-
}
|
|
337
|
-
flushPendingRequests(channelName) {
|
|
338
|
-
const requests = this.pendingRequests.get(channelName);
|
|
339
|
-
if (requests) {
|
|
340
|
-
for (const request of requests) {
|
|
341
|
-
clearTimeout(request.timeoutTimer);
|
|
342
|
-
switch (request.request.type) {
|
|
343
|
-
case RequestType.Promise:
|
|
344
|
-
this.onPromise(request.request);
|
|
345
|
-
break;
|
|
346
|
-
case RequestType.EventListen:
|
|
347
|
-
this.onEventListen(request.request);
|
|
348
|
-
break;
|
|
349
|
-
}
|
|
350
|
-
}
|
|
351
|
-
this.pendingRequests.delete(channelName);
|
|
352
|
-
}
|
|
353
|
-
}
|
|
354
|
-
dispose() {
|
|
355
|
-
if (this.protocolListener) {
|
|
356
|
-
this.protocolListener.dispose();
|
|
357
|
-
this.protocolListener = null;
|
|
358
|
-
}
|
|
359
|
-
dispose(( this.activeRequests.values()));
|
|
360
|
-
this.activeRequests.clear();
|
|
361
|
-
}
|
|
362
|
-
}
|
|
363
|
-
var RequestInitiator;
|
|
364
|
-
(function (RequestInitiator) {
|
|
365
|
-
RequestInitiator[RequestInitiator["LocalSide"] = 0] = "LocalSide";
|
|
366
|
-
RequestInitiator[RequestInitiator["OtherSide"] = 1] = "OtherSide";
|
|
367
|
-
})(RequestInitiator || (RequestInitiator = {}));
|
|
368
|
-
class ChannelClient {
|
|
369
|
-
constructor(protocol, logger = null) {
|
|
370
|
-
this.protocol = protocol;
|
|
371
|
-
this.isDisposed = false;
|
|
372
|
-
this.state = State.Uninitialized;
|
|
373
|
-
this.activeRequests = ( new Set());
|
|
374
|
-
this.handlers = ( new Map());
|
|
375
|
-
this.lastRequestId = 0;
|
|
376
|
-
this._onDidInitialize = ( new Emitter());
|
|
377
|
-
this.onDidInitialize = this._onDidInitialize.event;
|
|
378
|
-
this.protocolListener = this.protocol.onMessage(msg => this.onBuffer(msg));
|
|
379
|
-
this.logger = logger;
|
|
380
|
-
}
|
|
381
|
-
getChannel(channelName) {
|
|
382
|
-
const that = this;
|
|
383
|
-
return {
|
|
384
|
-
call(command, arg, cancellationToken) {
|
|
385
|
-
if (that.isDisposed) {
|
|
386
|
-
return Promise.reject(( new CancellationError()));
|
|
387
|
-
}
|
|
388
|
-
return that.requestPromise(channelName, command, arg, cancellationToken);
|
|
389
|
-
},
|
|
390
|
-
listen(event, arg) {
|
|
391
|
-
if (that.isDisposed) {
|
|
392
|
-
return Event.None;
|
|
393
|
-
}
|
|
394
|
-
return that.requestEvent(channelName, event, arg);
|
|
395
|
-
}
|
|
396
|
-
};
|
|
397
|
-
}
|
|
398
|
-
requestPromise(channelName, name, arg, cancellationToken = CancellationToken.None) {
|
|
399
|
-
const id = this.lastRequestId++;
|
|
400
|
-
const type = RequestType.Promise;
|
|
401
|
-
const request = { id, type, channelName, name, arg };
|
|
402
|
-
if (cancellationToken.isCancellationRequested) {
|
|
403
|
-
return Promise.reject(( new CancellationError()));
|
|
404
|
-
}
|
|
405
|
-
let disposable;
|
|
406
|
-
let disposableWithRequestCancel;
|
|
407
|
-
const result = ( new Promise((c, e) => {
|
|
408
|
-
if (cancellationToken.isCancellationRequested) {
|
|
409
|
-
return e(( new CancellationError()));
|
|
410
|
-
}
|
|
411
|
-
const doRequest = () => {
|
|
412
|
-
const handler = response => {
|
|
413
|
-
switch (response.type) {
|
|
414
|
-
case ResponseType.PromiseSuccess:
|
|
415
|
-
this.handlers.delete(id);
|
|
416
|
-
c(response.data);
|
|
417
|
-
break;
|
|
418
|
-
case ResponseType.PromiseError: {
|
|
419
|
-
this.handlers.delete(id);
|
|
420
|
-
const error = ( new Error(response.data.message));
|
|
421
|
-
error.stack = Array.isArray(response.data.stack) ? response.data.stack.join('\n') : response.data.stack;
|
|
422
|
-
error.name = response.data.name;
|
|
423
|
-
e(error);
|
|
424
|
-
break;
|
|
425
|
-
}
|
|
426
|
-
case ResponseType.PromiseErrorObj:
|
|
427
|
-
this.handlers.delete(id);
|
|
428
|
-
e(response.data);
|
|
429
|
-
break;
|
|
430
|
-
}
|
|
431
|
-
};
|
|
432
|
-
this.handlers.set(id, handler);
|
|
433
|
-
this.sendRequest(request);
|
|
434
|
-
};
|
|
435
|
-
let uninitializedPromise = null;
|
|
436
|
-
if (this.state === State.Idle) {
|
|
437
|
-
doRequest();
|
|
438
|
-
}
|
|
439
|
-
else {
|
|
440
|
-
uninitializedPromise = createCancelablePromise(_ => this.whenInitialized());
|
|
441
|
-
uninitializedPromise.then(() => {
|
|
442
|
-
uninitializedPromise = null;
|
|
443
|
-
doRequest();
|
|
444
|
-
});
|
|
445
|
-
}
|
|
446
|
-
const cancel = () => {
|
|
447
|
-
if (uninitializedPromise) {
|
|
448
|
-
uninitializedPromise.cancel();
|
|
449
|
-
uninitializedPromise = null;
|
|
450
|
-
}
|
|
451
|
-
else {
|
|
452
|
-
this.sendRequest({ id, type: RequestType.PromiseCancel });
|
|
453
|
-
}
|
|
454
|
-
e(( new CancellationError()));
|
|
455
|
-
};
|
|
456
|
-
disposable = cancellationToken.onCancellationRequested(cancel);
|
|
457
|
-
disposableWithRequestCancel = {
|
|
458
|
-
dispose: createSingleCallFunction(() => {
|
|
459
|
-
cancel();
|
|
460
|
-
disposable.dispose();
|
|
461
|
-
})
|
|
462
|
-
};
|
|
463
|
-
this.activeRequests.add(disposableWithRequestCancel);
|
|
464
|
-
}));
|
|
465
|
-
return result.finally(() => {
|
|
466
|
-
disposable.dispose();
|
|
467
|
-
this.activeRequests.delete(disposableWithRequestCancel);
|
|
468
|
-
});
|
|
469
|
-
}
|
|
470
|
-
requestEvent(channelName, name, arg) {
|
|
471
|
-
const id = this.lastRequestId++;
|
|
472
|
-
const type = RequestType.EventListen;
|
|
473
|
-
const request = { id, type, channelName, name, arg };
|
|
474
|
-
let uninitializedPromise = null;
|
|
475
|
-
const emitter = ( new Emitter({
|
|
476
|
-
onWillAddFirstListener: () => {
|
|
477
|
-
const doRequest = () => {
|
|
478
|
-
this.activeRequests.add(emitter);
|
|
479
|
-
this.sendRequest(request);
|
|
480
|
-
};
|
|
481
|
-
if (this.state === State.Idle) {
|
|
482
|
-
doRequest();
|
|
483
|
-
}
|
|
484
|
-
else {
|
|
485
|
-
uninitializedPromise = createCancelablePromise(_ => this.whenInitialized());
|
|
486
|
-
uninitializedPromise.then(() => {
|
|
487
|
-
uninitializedPromise = null;
|
|
488
|
-
doRequest();
|
|
489
|
-
});
|
|
490
|
-
}
|
|
491
|
-
},
|
|
492
|
-
onDidRemoveLastListener: () => {
|
|
493
|
-
if (uninitializedPromise) {
|
|
494
|
-
uninitializedPromise.cancel();
|
|
495
|
-
uninitializedPromise = null;
|
|
496
|
-
}
|
|
497
|
-
else {
|
|
498
|
-
this.activeRequests.delete(emitter);
|
|
499
|
-
this.sendRequest({ id, type: RequestType.EventDispose });
|
|
500
|
-
}
|
|
501
|
-
}
|
|
502
|
-
}));
|
|
503
|
-
const handler = (res) => emitter.fire(res.data);
|
|
504
|
-
this.handlers.set(id, handler);
|
|
505
|
-
return emitter.event;
|
|
506
|
-
}
|
|
507
|
-
sendRequest(request) {
|
|
508
|
-
switch (request.type) {
|
|
509
|
-
case RequestType.Promise:
|
|
510
|
-
case RequestType.EventListen: {
|
|
511
|
-
const msgLength = this.send([request.type, request.id, request.channelName, request.name], request.arg);
|
|
512
|
-
this.logger?.logOutgoing(msgLength, request.id, RequestInitiator.LocalSide, `${requestTypeToStr(request.type)}: ${request.channelName}.${request.name}`, request.arg);
|
|
513
|
-
return;
|
|
514
|
-
}
|
|
515
|
-
case RequestType.PromiseCancel:
|
|
516
|
-
case RequestType.EventDispose: {
|
|
517
|
-
const msgLength = this.send([request.type, request.id]);
|
|
518
|
-
this.logger?.logOutgoing(msgLength, request.id, RequestInitiator.LocalSide, requestTypeToStr(request.type));
|
|
519
|
-
return;
|
|
520
|
-
}
|
|
521
|
-
}
|
|
522
|
-
}
|
|
523
|
-
send(header, body = undefined) {
|
|
524
|
-
const writer = ( new BufferWriter());
|
|
525
|
-
serialize(writer, header);
|
|
526
|
-
serialize(writer, body);
|
|
527
|
-
return this.sendBuffer(writer.buffer);
|
|
528
|
-
}
|
|
529
|
-
sendBuffer(message) {
|
|
530
|
-
try {
|
|
531
|
-
this.protocol.send(message);
|
|
532
|
-
return message.byteLength;
|
|
533
|
-
}
|
|
534
|
-
catch (err) {
|
|
535
|
-
return 0;
|
|
536
|
-
}
|
|
537
|
-
}
|
|
538
|
-
onBuffer(message) {
|
|
539
|
-
const reader = ( new BufferReader(message));
|
|
540
|
-
const header = deserialize(reader);
|
|
541
|
-
const body = deserialize(reader);
|
|
542
|
-
const type = header[0];
|
|
543
|
-
switch (type) {
|
|
544
|
-
case ResponseType.Initialize:
|
|
545
|
-
this.logger?.logIncoming(message.byteLength, 0, RequestInitiator.LocalSide, responseTypeToStr(type));
|
|
546
|
-
return this.onResponse({ type: header[0] });
|
|
547
|
-
case ResponseType.PromiseSuccess:
|
|
548
|
-
case ResponseType.PromiseError:
|
|
549
|
-
case ResponseType.EventFire:
|
|
550
|
-
case ResponseType.PromiseErrorObj:
|
|
551
|
-
this.logger?.logIncoming(message.byteLength, header[1], RequestInitiator.LocalSide, responseTypeToStr(type), body);
|
|
552
|
-
return this.onResponse({ type: header[0], id: header[1], data: body });
|
|
553
|
-
}
|
|
554
|
-
}
|
|
555
|
-
onResponse(response) {
|
|
556
|
-
if (response.type === ResponseType.Initialize) {
|
|
557
|
-
this.state = State.Idle;
|
|
558
|
-
this._onDidInitialize.fire();
|
|
559
|
-
return;
|
|
560
|
-
}
|
|
561
|
-
const handler = this.handlers.get(response.id);
|
|
562
|
-
handler?.(response);
|
|
563
|
-
}
|
|
564
|
-
get onDidInitializePromise() {
|
|
565
|
-
return Event.toPromise(this.onDidInitialize);
|
|
566
|
-
}
|
|
567
|
-
whenInitialized() {
|
|
568
|
-
if (this.state === State.Idle) {
|
|
569
|
-
return Promise.resolve();
|
|
570
|
-
}
|
|
571
|
-
else {
|
|
572
|
-
return this.onDidInitializePromise;
|
|
573
|
-
}
|
|
574
|
-
}
|
|
575
|
-
dispose() {
|
|
576
|
-
this.isDisposed = true;
|
|
577
|
-
if (this.protocolListener) {
|
|
578
|
-
this.protocolListener.dispose();
|
|
579
|
-
this.protocolListener = null;
|
|
580
|
-
}
|
|
581
|
-
dispose(( this.activeRequests.values()));
|
|
582
|
-
this.activeRequests.clear();
|
|
583
|
-
}
|
|
584
|
-
}
|
|
585
|
-
ChannelClient.__decorator = ( __decorate([
|
|
586
|
-
memoize
|
|
587
|
-
], ChannelClient.prototype, "onDidInitializePromise", null));
|
|
588
|
-
class IPCClient {
|
|
589
|
-
constructor(protocol, ctx, ipcLogger = null) {
|
|
590
|
-
const writer = ( new BufferWriter());
|
|
591
|
-
serialize(writer, ctx);
|
|
592
|
-
protocol.send(writer.buffer);
|
|
593
|
-
this.channelClient = ( new ChannelClient(protocol, ipcLogger));
|
|
594
|
-
this.channelServer = ( new ChannelServer(protocol, ctx, ipcLogger));
|
|
595
|
-
}
|
|
596
|
-
getChannel(channelName) {
|
|
597
|
-
return this.channelClient.getChannel(channelName);
|
|
598
|
-
}
|
|
599
|
-
registerChannel(channelName, channel) {
|
|
600
|
-
this.channelServer.registerChannel(channelName, channel);
|
|
601
|
-
}
|
|
602
|
-
dispose() {
|
|
603
|
-
this.channelClient.dispose();
|
|
604
|
-
this.channelServer.dispose();
|
|
605
|
-
}
|
|
606
|
-
}
|
|
607
|
-
function getDelayedChannel(promise) {
|
|
608
|
-
return {
|
|
609
|
-
call(command, arg, cancellationToken) {
|
|
610
|
-
return promise.then(c => c.call(command, arg, cancellationToken));
|
|
611
|
-
},
|
|
612
|
-
listen(event, arg) {
|
|
613
|
-
const relay = ( new Relay());
|
|
614
|
-
promise.then(c => relay.input = c.listen(event, arg));
|
|
615
|
-
return relay.event;
|
|
616
|
-
}
|
|
617
|
-
};
|
|
618
|
-
}
|
|
619
|
-
var ProxyChannel;
|
|
620
|
-
(function (ProxyChannel) {
|
|
621
|
-
function fromService(service, disposables, options) {
|
|
622
|
-
const handler = service;
|
|
623
|
-
const disableMarshalling = options && options.disableMarshalling;
|
|
624
|
-
const mapEventNameToEvent = ( new Map());
|
|
625
|
-
for (const key in handler) {
|
|
626
|
-
if (propertyIsEvent(key)) {
|
|
627
|
-
mapEventNameToEvent.set(key, Event.buffer(handler[key], true, undefined, disposables));
|
|
628
|
-
}
|
|
629
|
-
}
|
|
630
|
-
return new (class {
|
|
631
|
-
listen(_, event, arg) {
|
|
632
|
-
const eventImpl = mapEventNameToEvent.get(event);
|
|
633
|
-
if (eventImpl) {
|
|
634
|
-
return eventImpl;
|
|
635
|
-
}
|
|
636
|
-
const target = handler[event];
|
|
637
|
-
if (typeof target === 'function') {
|
|
638
|
-
if (propertyIsDynamicEvent(event)) {
|
|
639
|
-
return target.call(handler, arg);
|
|
640
|
-
}
|
|
641
|
-
if (propertyIsEvent(event)) {
|
|
642
|
-
mapEventNameToEvent.set(event, Event.buffer(handler[event], true, undefined, disposables));
|
|
643
|
-
return mapEventNameToEvent.get(event);
|
|
644
|
-
}
|
|
645
|
-
}
|
|
646
|
-
throw ( new ErrorNoTelemetry(`Event not found: ${event}`));
|
|
647
|
-
}
|
|
648
|
-
call(_, command, args) {
|
|
649
|
-
const target = handler[command];
|
|
650
|
-
if (typeof target === 'function') {
|
|
651
|
-
if (!disableMarshalling && Array.isArray(args)) {
|
|
652
|
-
for (let i = 0; i < args.length; i++) {
|
|
653
|
-
args[i] = revive(args[i]);
|
|
654
|
-
}
|
|
655
|
-
}
|
|
656
|
-
let res = target.apply(handler, args);
|
|
657
|
-
if (!(res instanceof Promise)) {
|
|
658
|
-
res = Promise.resolve(res);
|
|
659
|
-
}
|
|
660
|
-
return res;
|
|
661
|
-
}
|
|
662
|
-
throw ( new ErrorNoTelemetry(`Method not found: ${command}`));
|
|
663
|
-
}
|
|
664
|
-
});
|
|
665
|
-
}
|
|
666
|
-
ProxyChannel.fromService = fromService;
|
|
667
|
-
function toService(channel, options) {
|
|
668
|
-
const disableMarshalling = options && options.disableMarshalling;
|
|
669
|
-
return ( new Proxy({}, {
|
|
670
|
-
get(_target, propKey) {
|
|
671
|
-
if (typeof propKey === 'string') {
|
|
672
|
-
if (options?.properties?.has(propKey)) {
|
|
673
|
-
return options.properties.get(propKey);
|
|
674
|
-
}
|
|
675
|
-
if (propertyIsDynamicEvent(propKey)) {
|
|
676
|
-
return function (arg) {
|
|
677
|
-
return channel.listen(propKey, arg);
|
|
678
|
-
};
|
|
679
|
-
}
|
|
680
|
-
if (propertyIsEvent(propKey)) {
|
|
681
|
-
return channel.listen(propKey);
|
|
682
|
-
}
|
|
683
|
-
return async function (...args) {
|
|
684
|
-
let methodArgs;
|
|
685
|
-
if (options && !isUndefinedOrNull(options.context)) {
|
|
686
|
-
methodArgs = [options.context, ...args];
|
|
687
|
-
}
|
|
688
|
-
else {
|
|
689
|
-
methodArgs = args;
|
|
690
|
-
}
|
|
691
|
-
const result = await channel.call(propKey, methodArgs);
|
|
692
|
-
if (!disableMarshalling) {
|
|
693
|
-
return revive(result);
|
|
694
|
-
}
|
|
695
|
-
return result;
|
|
696
|
-
};
|
|
697
|
-
}
|
|
698
|
-
throw ( new ErrorNoTelemetry(`Property not found: ${String(propKey)}`));
|
|
699
|
-
}
|
|
700
|
-
}));
|
|
701
|
-
}
|
|
702
|
-
ProxyChannel.toService = toService;
|
|
703
|
-
function propertyIsEvent(name) {
|
|
704
|
-
return name[0] === 'o' && name[1] === 'n' && isUpperAsciiLetter(name.charCodeAt(2));
|
|
705
|
-
}
|
|
706
|
-
function propertyIsDynamicEvent(name) {
|
|
707
|
-
return /^onDynamic/.test(name) && isUpperAsciiLetter(name.charCodeAt(9));
|
|
708
|
-
}
|
|
709
|
-
})(ProxyChannel || (ProxyChannel = {}));
|
|
710
|
-
|
|
711
|
-
export { BufferReader, BufferWriter, ChannelClient, ChannelServer, IPCClient, ProxyChannel, RequestInitiator, deserialize, getDelayedChannel, serialize };
|