@theia/core 1.27.0-next.9 → 1.27.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 +6 -7
- package/i18n/nls.cs.json +52 -6
- package/i18n/nls.de.json +52 -6
- package/i18n/nls.es.json +52 -6
- package/i18n/nls.fr.json +52 -6
- package/i18n/nls.hu.json +55 -9
- package/i18n/nls.it.json +52 -6
- package/i18n/nls.ja.json +52 -6
- package/i18n/nls.json +52 -6
- package/i18n/nls.pl.json +52 -6
- package/i18n/nls.pt-br.json +52 -6
- package/i18n/nls.pt-pt.json +52 -6
- package/i18n/nls.ru.json +52 -6
- package/i18n/nls.zh-cn.json +52 -6
- package/lib/browser/color-application-contribution.d.ts +2 -2
- package/lib/browser/color-application-contribution.d.ts.map +1 -1
- package/lib/browser/color-application-contribution.js +15 -16
- package/lib/browser/color-application-contribution.js.map +1 -1
- package/lib/browser/color-registry.d.ts +0 -4
- package/lib/browser/color-registry.d.ts.map +1 -1
- package/lib/browser/color-registry.js +0 -14
- package/lib/browser/color-registry.js.map +1 -1
- package/lib/browser/common-frontend-contribution.d.ts +4 -0
- package/lib/browser/common-frontend-contribution.d.ts.map +1 -1
- package/lib/browser/common-frontend-contribution.js +157 -163
- package/lib/browser/common-frontend-contribution.js.map +1 -1
- package/lib/browser/common-styling-participants.d.ts +28 -0
- package/lib/browser/common-styling-participants.d.ts.map +1 -0
- package/lib/browser/common-styling-participants.js +319 -0
- package/lib/browser/common-styling-participants.js.map +1 -0
- package/lib/browser/connection-status-service.d.ts.map +1 -1
- package/lib/browser/connection-status-service.js +2 -2
- package/lib/browser/connection-status-service.js.map +1 -1
- package/lib/browser/connection-status-service.spec.js +1 -2
- package/lib/browser/connection-status-service.spec.js.map +1 -1
- package/lib/browser/context-menu-renderer.d.ts +1 -5
- package/lib/browser/context-menu-renderer.d.ts.map +1 -1
- package/lib/browser/context-menu-renderer.js +10 -30
- package/lib/browser/context-menu-renderer.js.map +1 -1
- package/lib/browser/core-preferences.d.ts +1 -0
- package/lib/browser/core-preferences.d.ts.map +1 -1
- package/lib/browser/core-preferences.js +5 -0
- package/lib/browser/core-preferences.js.map +1 -1
- package/lib/browser/decoration-style.d.ts +1 -0
- package/lib/browser/decoration-style.d.ts.map +1 -1
- package/lib/browser/decoration-style.js +6 -2
- package/lib/browser/decoration-style.js.map +1 -1
- package/lib/browser/frontend-application-bindings.d.ts.map +1 -1
- package/lib/browser/frontend-application-bindings.js +1 -3
- package/lib/browser/frontend-application-bindings.js.map +1 -1
- package/lib/browser/frontend-application-config-provider.d.ts +1 -0
- package/lib/browser/frontend-application-config-provider.d.ts.map +1 -1
- package/lib/browser/frontend-application-config-provider.js +2 -1
- package/lib/browser/frontend-application-config-provider.js.map +1 -1
- package/lib/browser/frontend-application-module.d.ts.map +1 -1
- package/lib/browser/frontend-application-module.js +9 -3
- package/lib/browser/frontend-application-module.js.map +1 -1
- package/lib/browser/i18n/i18n-frontend-module.d.ts.map +1 -1
- package/lib/browser/i18n/i18n-frontend-module.js +2 -0
- package/lib/browser/i18n/i18n-frontend-module.js.map +1 -1
- package/lib/browser/i18n/language-quick-pick-service.d.ts +17 -0
- package/lib/browser/i18n/language-quick-pick-service.d.ts.map +1 -0
- package/lib/browser/i18n/language-quick-pick-service.js +142 -0
- package/lib/browser/i18n/language-quick-pick-service.js.map +1 -0
- package/lib/browser/index.d.ts +1 -0
- package/lib/browser/index.d.ts.map +1 -1
- package/lib/browser/index.js +1 -0
- package/lib/browser/index.js.map +1 -1
- package/lib/browser/keybinding.d.ts.map +1 -1
- package/lib/browser/keybinding.js +2 -1
- package/lib/browser/keybinding.js.map +1 -1
- package/lib/browser/keybinding.spec.js +18 -21
- package/lib/browser/keybinding.spec.js.map +1 -1
- package/lib/browser/label-provider.d.ts +0 -12
- package/lib/browser/label-provider.d.ts.map +1 -1
- package/lib/browser/label-provider.js +1 -13
- package/lib/browser/label-provider.js.map +1 -1
- package/lib/browser/logger-frontend-module.d.ts.map +1 -1
- package/lib/browser/logger-frontend-module.js +8 -1
- package/lib/browser/logger-frontend-module.js.map +1 -1
- package/lib/browser/messaging/ws-connection-provider.d.ts +5 -4
- package/lib/browser/messaging/ws-connection-provider.d.ts.map +1 -1
- package/lib/browser/messaging/ws-connection-provider.js +30 -23
- package/lib/browser/messaging/ws-connection-provider.js.map +1 -1
- package/lib/browser/preferences/preference-contribution.d.ts +2 -19
- package/lib/browser/preferences/preference-contribution.d.ts.map +1 -1
- package/lib/browser/preferences/preference-contribution.js +1 -24
- package/lib/browser/preferences/preference-contribution.js.map +1 -1
- package/lib/browser/preferences/preference-proxy.d.ts +0 -4
- package/lib/browser/preferences/preference-proxy.d.ts.map +1 -1
- package/lib/browser/preferences/preference-proxy.js.map +1 -1
- package/lib/browser/preferences/preference-proxy.spec.js +3 -102
- package/lib/browser/preferences/preference-proxy.spec.js.map +1 -1
- package/lib/browser/preferences/preference-schema-provider.spec.js +4 -3
- package/lib/browser/preferences/preference-schema-provider.spec.js.map +1 -1
- package/lib/browser/preferences/preference-service.spec.js +1 -2
- package/lib/browser/preferences/preference-service.spec.js.map +1 -1
- package/lib/browser/preferences/preference-validation-service.d.ts +2 -2
- package/lib/browser/preferences/preference-validation-service.d.ts.map +1 -1
- package/lib/browser/preferences/preference-validation-service.spec.js.map +1 -1
- package/lib/browser/preloader.d.ts.map +1 -1
- package/lib/browser/preloader.js +7 -1
- package/lib/browser/preloader.js.map +1 -1
- package/lib/browser/progress-status-bar-item.d.ts +1 -1
- package/lib/browser/progress-status-bar-item.d.ts.map +1 -1
- package/lib/browser/quick-input/quick-command-service.d.ts.map +1 -1
- package/lib/browser/quick-input/quick-command-service.js +2 -2
- package/lib/browser/quick-input/quick-command-service.js.map +1 -1
- package/lib/browser/saveable.d.ts.map +1 -1
- package/lib/browser/saveable.js +5 -4
- package/lib/browser/saveable.js.map +1 -1
- package/lib/browser/shell/application-shell.d.ts +4 -0
- package/lib/browser/shell/application-shell.d.ts.map +1 -1
- package/lib/browser/shell/application-shell.js +42 -36
- package/lib/browser/shell/application-shell.js.map +1 -1
- package/lib/browser/shell/shell-layout-restorer.d.ts +2 -0
- package/lib/browser/shell/shell-layout-restorer.d.ts.map +1 -1
- package/lib/browser/shell/shell-layout-restorer.js +5 -1
- package/lib/browser/shell/shell-layout-restorer.js.map +1 -1
- package/lib/browser/shell/side-panel-handler.d.ts.map +1 -1
- package/lib/browser/shell/side-panel-handler.js +3 -2
- package/lib/browser/shell/side-panel-handler.js.map +1 -1
- package/lib/browser/shell/tab-bars.d.ts +4 -2
- package/lib/browser/shell/tab-bars.d.ts.map +1 -1
- package/lib/browser/shell/tab-bars.js +12 -4
- package/lib/browser/shell/tab-bars.js.map +1 -1
- package/lib/browser/source-tree/source-tree-widget.js +1 -1
- package/lib/browser/source-tree/source-tree-widget.js.map +1 -1
- package/lib/browser/source-tree/tree-source.d.ts +2 -1
- package/lib/browser/source-tree/tree-source.d.ts.map +1 -1
- package/lib/browser/source-tree/tree-source.js.map +1 -1
- package/lib/browser/styling-service.d.ts +26 -0
- package/lib/browser/styling-service.d.ts.map +1 -0
- package/lib/browser/styling-service.js +76 -0
- package/lib/browser/styling-service.js.map +1 -0
- package/lib/browser/theming.d.ts +4 -8
- package/lib/browser/theming.d.ts.map +1 -1
- package/lib/browser/theming.js +38 -53
- package/lib/browser/theming.js.map +1 -1
- package/lib/browser/tree/search-box.d.ts.map +1 -1
- package/lib/browser/tree/search-box.js +5 -4
- package/lib/browser/tree/search-box.js.map +1 -1
- package/lib/browser/tree/test/tree-test-container.d.ts.map +1 -1
- package/lib/browser/tree/test/tree-test-container.js +2 -0
- package/lib/browser/tree/test/tree-test-container.js.map +1 -1
- package/lib/browser/tree/tree-compression/compressed-tree-model.d.ts +1 -1
- package/lib/browser/tree/tree-compression/compressed-tree-model.d.ts.map +1 -1
- package/lib/browser/tree/tree-compression/compressed-tree-model.js +4 -2
- package/lib/browser/tree/tree-compression/compressed-tree-model.js.map +1 -1
- package/lib/browser/tree/tree-compression/compressed-tree-widget.d.ts.map +1 -1
- package/lib/browser/tree/tree-compression/compressed-tree-widget.js +4 -2
- package/lib/browser/tree/tree-compression/compressed-tree-widget.js.map +1 -1
- package/lib/browser/tree/tree-container.d.ts +2 -0
- package/lib/browser/tree/tree-container.d.ts.map +1 -1
- package/lib/browser/tree/tree-container.js +3 -0
- package/lib/browser/tree/tree-container.js.map +1 -1
- package/lib/browser/tree/tree-focus-service.d.ts +20 -0
- package/lib/browser/tree/tree-focus-service.d.ts.map +1 -0
- package/lib/browser/tree/tree-focus-service.js +62 -0
- package/lib/browser/tree/tree-focus-service.js.map +1 -0
- package/lib/browser/tree/tree-model.d.ts +11 -2
- package/lib/browser/tree/tree-model.d.ts.map +1 -1
- package/lib/browser/tree/tree-model.js +29 -8
- package/lib/browser/tree/tree-model.js.map +1 -1
- package/lib/browser/tree/tree-selection-impl.d.ts +4 -1
- package/lib/browser/tree/tree-selection-impl.d.ts.map +1 -1
- package/lib/browser/tree/tree-selection-impl.js +13 -2
- package/lib/browser/tree/tree-selection-impl.js.map +1 -1
- package/lib/browser/tree/tree-selection-state.d.ts +1 -0
- package/lib/browser/tree/tree-selection-state.d.ts.map +1 -1
- package/lib/browser/tree/tree-selection-state.js +8 -2
- package/lib/browser/tree/tree-selection-state.js.map +1 -1
- package/lib/browser/tree/tree-selection.d.ts +9 -0
- package/lib/browser/tree/tree-selection.d.ts.map +1 -1
- package/lib/browser/tree/tree-selection.js +3 -0
- package/lib/browser/tree/tree-selection.js.map +1 -1
- package/lib/browser/tree/tree-widget-selection.d.ts.map +1 -1
- package/lib/browser/tree/tree-widget-selection.js +9 -1
- package/lib/browser/tree/tree-widget-selection.js.map +1 -1
- package/lib/browser/tree/tree-widget.d.ts +14 -0
- package/lib/browser/tree/tree-widget.d.ts.map +1 -1
- package/lib/browser/tree/tree-widget.js +80 -40
- package/lib/browser/tree/tree-widget.js.map +1 -1
- package/lib/browser/tree/tree.d.ts +2 -1
- package/lib/browser/tree/tree.d.ts.map +1 -1
- package/lib/browser/tree/tree.js +12 -2
- package/lib/browser/tree/tree.js.map +1 -1
- package/lib/browser/view-container.d.ts +9 -4
- package/lib/browser/view-container.d.ts.map +1 -1
- package/lib/browser/view-container.js +36 -6
- package/lib/browser/view-container.js.map +1 -1
- package/lib/common/cancellation.d.ts +1 -0
- package/lib/common/cancellation.d.ts.map +1 -1
- package/lib/common/cancellation.js +8 -0
- package/lib/common/cancellation.js.map +1 -1
- package/lib/common/command.d.ts +1 -1
- package/lib/common/command.d.ts.map +1 -1
- package/lib/common/command.js +13 -16
- package/lib/common/command.js.map +1 -1
- package/lib/common/index.d.ts +1 -0
- package/lib/common/index.d.ts.map +1 -1
- package/lib/common/index.js +1 -0
- package/lib/common/index.js.map +1 -1
- package/lib/common/message-rpc/channel.d.ts +106 -0
- package/lib/common/message-rpc/channel.d.ts.map +1 -0
- package/lib/common/message-rpc/channel.js +195 -0
- package/lib/common/message-rpc/channel.js.map +1 -0
- package/lib/common/message-rpc/channel.spec.d.ts +9 -0
- package/lib/common/message-rpc/channel.spec.d.ts.map +1 -0
- package/lib/common/message-rpc/channel.spec.js +80 -0
- package/lib/common/message-rpc/channel.spec.js.map +1 -0
- package/lib/common/message-rpc/index.d.ts +4 -0
- package/lib/common/message-rpc/index.d.ts.map +1 -0
- package/lib/{node/messaging/logger.js → common/message-rpc/index.js} +6 -19
- package/lib/common/message-rpc/index.js.map +1 -0
- package/lib/common/message-rpc/message-buffer.d.ts +50 -0
- package/lib/common/message-rpc/message-buffer.d.ts.map +1 -0
- package/lib/common/message-rpc/message-buffer.js +56 -0
- package/lib/common/message-rpc/message-buffer.js.map +1 -0
- package/lib/common/message-rpc/rpc-message-encoder.d.ts +171 -0
- package/lib/common/message-rpc/rpc-message-encoder.d.ts.map +1 -0
- package/lib/common/message-rpc/rpc-message-encoder.js +409 -0
- package/lib/common/message-rpc/rpc-message-encoder.js.map +1 -0
- package/lib/common/message-rpc/rpc-message-encoder.spec.d.ts +2 -0
- package/lib/common/message-rpc/rpc-message-encoder.spec.d.ts.map +1 -0
- package/lib/common/message-rpc/rpc-message-encoder.spec.js +49 -0
- package/lib/common/message-rpc/rpc-message-encoder.spec.js.map +1 -0
- package/lib/common/message-rpc/rpc-protocol.d.ts +61 -0
- package/lib/common/message-rpc/rpc-protocol.d.ts.map +1 -0
- package/lib/common/message-rpc/rpc-protocol.js +183 -0
- package/lib/common/message-rpc/rpc-protocol.js.map +1 -0
- package/lib/common/message-rpc/uint8-array-message-buffer.d.ts +52 -0
- package/lib/common/message-rpc/uint8-array-message-buffer.d.ts.map +1 -0
- package/lib/common/message-rpc/uint8-array-message-buffer.js +169 -0
- package/lib/common/message-rpc/uint8-array-message-buffer.js.map +1 -0
- package/lib/common/message-rpc/uint8-array-message-buffer.spec.d.ts +2 -0
- package/lib/common/message-rpc/uint8-array-message-buffer.spec.d.ts.map +1 -0
- package/lib/common/message-rpc/uint8-array-message-buffer.spec.js +39 -0
- package/lib/common/message-rpc/uint8-array-message-buffer.spec.js.map +1 -0
- package/lib/common/messaging/abstract-connection-provider.d.ts +9 -8
- package/lib/common/messaging/abstract-connection-provider.d.ts.map +1 -1
- package/lib/common/messaging/abstract-connection-provider.js +20 -35
- package/lib/common/messaging/abstract-connection-provider.js.map +1 -1
- package/lib/common/messaging/connection-error-handler.d.ts +1 -2
- package/lib/common/messaging/connection-error-handler.d.ts.map +1 -1
- package/lib/common/messaging/connection-error-handler.js +1 -1
- package/lib/common/messaging/connection-error-handler.js.map +1 -1
- package/lib/common/messaging/handler.d.ts +2 -2
- package/lib/common/messaging/handler.d.ts.map +1 -1
- package/lib/common/messaging/proxy-factory.d.ts +13 -7
- package/lib/common/messaging/proxy-factory.d.ts.map +1 -1
- package/lib/common/messaging/proxy-factory.js +18 -13
- package/lib/common/messaging/proxy-factory.js.map +1 -1
- package/lib/common/messaging/proxy-factory.spec.js +4 -15
- package/lib/common/messaging/proxy-factory.spec.js.map +1 -1
- package/lib/common/messaging/web-socket-channel.d.ts +54 -48
- package/lib/common/messaging/web-socket-channel.d.ts.map +1 -1
- package/lib/common/messaging/web-socket-channel.js +41 -105
- package/lib/common/messaging/web-socket-channel.js.map +1 -1
- package/lib/common/nls.d.ts +2 -0
- package/lib/common/nls.d.ts.map +1 -1
- package/lib/common/nls.js +11 -0
- package/lib/common/nls.js.map +1 -1
- package/lib/common/preferences/preference-schema.d.ts +1 -5
- package/lib/common/preferences/preference-schema.d.ts.map +1 -1
- package/lib/common/preferences/preference-schema.js.map +1 -1
- package/lib/common/promise-util.d.ts +2 -1
- package/lib/common/promise-util.d.ts.map +1 -1
- package/lib/common/promise-util.js +8 -13
- package/lib/common/promise-util.js.map +1 -1
- package/lib/common/resource.d.ts +5 -0
- package/lib/common/resource.d.ts.map +1 -1
- package/lib/common/resource.js +28 -1
- package/lib/common/resource.js.map +1 -1
- package/lib/common/theme.d.ts +3 -2
- package/lib/common/theme.d.ts.map +1 -1
- package/lib/common/theme.js +5 -0
- package/lib/common/theme.js.map +1 -1
- package/lib/electron-browser/messaging/electron-ipc-connection-provider.d.ts +2 -2
- package/lib/electron-browser/messaging/electron-ipc-connection-provider.d.ts.map +1 -1
- package/lib/electron-browser/messaging/electron-ipc-connection-provider.js +18 -7
- package/lib/electron-browser/messaging/electron-ipc-connection-provider.js.map +1 -1
- package/lib/electron-browser/messaging/electron-ws-connection-provider.d.ts +2 -2
- package/lib/electron-browser/messaging/electron-ws-connection-provider.d.ts.map +1 -1
- package/lib/electron-browser/messaging/electron-ws-connection-provider.js +5 -7
- package/lib/electron-browser/messaging/electron-ws-connection-provider.js.map +1 -1
- package/lib/electron-main/event-utils.d.ts +1 -1
- package/lib/electron-main/messaging/electron-messaging-contribution.d.ts +37 -9
- package/lib/electron-main/messaging/electron-messaging-contribution.d.ts.map +1 -1
- package/lib/electron-main/messaging/electron-messaging-contribution.js +83 -68
- package/lib/electron-main/messaging/electron-messaging-contribution.js.map +1 -1
- package/lib/electron-main/messaging/electron-messaging-service.d.ts +2 -8
- package/lib/electron-main/messaging/electron-messaging-service.d.ts.map +1 -1
- package/lib/electron-main/messaging/electron-messaging-service.js.map +1 -1
- package/lib/node/messaging/binary-message-pipe.d.ts +45 -0
- package/lib/node/messaging/binary-message-pipe.d.ts.map +1 -0
- package/lib/node/messaging/binary-message-pipe.js +152 -0
- package/lib/node/messaging/binary-message-pipe.js.map +1 -0
- package/lib/node/messaging/ipc-bootstrap.js +2 -11
- package/lib/node/messaging/ipc-bootstrap.js.map +1 -1
- package/lib/node/messaging/ipc-channel.d.ts +26 -0
- package/lib/node/messaging/ipc-channel.d.ts.map +1 -0
- package/lib/node/messaging/ipc-channel.js +86 -0
- package/lib/node/messaging/ipc-channel.js.map +1 -0
- package/lib/node/messaging/ipc-connection-provider.d.ts +3 -5
- package/lib/node/messaging/ipc-connection-provider.d.ts.map +1 -1
- package/lib/node/messaging/ipc-connection-provider.js +14 -31
- package/lib/node/messaging/ipc-connection-provider.js.map +1 -1
- package/lib/node/messaging/ipc-protocol.d.ts +2 -2
- package/lib/node/messaging/ipc-protocol.d.ts.map +1 -1
- package/lib/node/messaging/messaging-contribution.d.ts +6 -9
- package/lib/node/messaging/messaging-contribution.d.ts.map +1 -1
- package/lib/node/messaging/messaging-contribution.js +23 -68
- package/lib/node/messaging/messaging-contribution.js.map +1 -1
- package/lib/node/messaging/messaging-service.d.ts +4 -23
- package/lib/node/messaging/messaging-service.d.ts.map +1 -1
- package/lib/node/messaging/messaging-service.js +1 -15
- package/lib/node/messaging/messaging-service.js.map +1 -1
- package/lib/node/messaging/test/test-web-socket-channel.d.ts +4 -2
- package/lib/node/messaging/test/test-web-socket-channel.d.ts.map +1 -1
- package/lib/node/messaging/test/test-web-socket-channel.js +25 -12
- package/lib/node/messaging/test/test-web-socket-channel.js.map +1 -1
- package/lib/node/request/proxy-cli-contribution.js +1 -1
- package/lib/node/request/proxy-cli-contribution.js.map +1 -1
- package/package.json +7 -10
- package/src/browser/color-application-contribution.ts +10 -17
- package/src/browser/color-registry.ts +0 -5
- package/src/browser/common-frontend-contribution.ts +26 -33
- package/src/browser/common-styling-participants.ts +307 -0
- package/src/browser/connection-status-service.spec.ts +1 -4
- package/src/browser/connection-status-service.ts +3 -3
- package/src/browser/context-menu-renderer.ts +13 -29
- package/src/browser/core-preferences.ts +6 -0
- package/src/browser/decoration-style.ts +6 -2
- package/src/browser/frontend-application-bindings.ts +1 -3
- package/src/browser/frontend-application-config-provider.ts +2 -0
- package/src/browser/frontend-application-module.ts +11 -4
- package/src/browser/i18n/i18n-frontend-module.ts +2 -0
- package/src/browser/i18n/language-quick-pick-service.ts +128 -0
- package/src/browser/index.ts +1 -0
- package/src/browser/keybinding.spec.ts +22 -27
- package/src/browser/keybinding.ts +2 -1
- package/src/browser/label-provider.ts +0 -13
- package/src/browser/logger-frontend-module.ts +8 -1
- package/src/browser/messaging/ws-connection-provider.ts +34 -25
- package/src/browser/preferences/preference-contribution.ts +3 -28
- package/src/browser/preferences/preference-proxy.spec.ts +3 -113
- package/src/browser/preferences/preference-proxy.ts +0 -4
- package/src/browser/preferences/preference-schema-provider.spec.ts +1 -4
- package/src/browser/preferences/preference-service.spec.ts +1 -5
- package/src/browser/preferences/preference-validation-service.spec.ts +2 -2
- package/src/browser/preferences/preference-validation-service.ts +2 -2
- package/src/browser/preloader.ts +9 -2
- package/src/browser/progress-status-bar-item.ts +1 -1
- package/src/browser/quick-input/quick-command-service.ts +3 -3
- package/src/browser/saveable.ts +5 -4
- package/src/browser/shell/application-shell.ts +42 -35
- package/src/browser/shell/shell-layout-restorer.ts +4 -6
- package/src/browser/shell/side-panel-handler.ts +3 -2
- package/src/browser/shell/tab-bars.ts +14 -4
- package/src/browser/source-tree/source-tree-widget.tsx +1 -1
- package/src/browser/source-tree/tree-source.ts +2 -1
- package/src/browser/style/breadcrumbs.css +0 -1
- package/src/browser/style/index.css +66 -29
- package/src/browser/style/menus.css +4 -2
- package/src/browser/style/select-component.css +2 -0
- package/src/browser/style/sidepanel.css +11 -25
- package/src/browser/style/status-bar.css +8 -17
- package/src/browser/style/tabs.css +0 -16
- package/src/browser/style/tooltip.css +3 -3
- package/src/browser/style/tree.css +27 -11
- package/src/browser/style/view-container.css +4 -0
- package/src/browser/styling-service.ts +76 -0
- package/src/browser/theming.ts +18 -45
- package/src/browser/tree/search-box.ts +5 -4
- package/src/browser/tree/test/tree-test-container.ts +2 -0
- package/src/browser/tree/tree-compression/compressed-tree-model.ts +8 -2
- package/src/browser/tree/tree-compression/compressed-tree-widget.tsx +4 -2
- package/src/browser/tree/tree-container.ts +4 -0
- package/src/browser/tree/tree-focus-service.ts +55 -0
- package/src/browser/tree/tree-model.ts +32 -8
- package/src/browser/tree/tree-selection-impl.ts +13 -4
- package/src/browser/tree/tree-selection-state.ts +7 -2
- package/src/browser/tree/tree-selection.ts +10 -0
- package/src/browser/tree/tree-widget-selection.ts +10 -1
- package/src/browser/tree/tree-widget.tsx +83 -43
- package/src/browser/tree/tree.ts +8 -2
- package/src/browser/view-container.ts +41 -4
- package/src/common/cancellation.ts +8 -0
- package/src/common/command.ts +14 -16
- package/src/common/index.ts +1 -0
- package/src/common/message-rpc/channel.spec.ts +88 -0
- package/src/common/message-rpc/channel.ts +260 -0
- package/src/{node/messaging/logger.ts → common/message-rpc/index.ts} +4 -23
- package/src/common/message-rpc/message-buffer.ts +99 -0
- package/src/common/message-rpc/rpc-message-encoder.spec.ts +55 -0
- package/src/common/message-rpc/rpc-message-encoder.ts +552 -0
- package/src/common/message-rpc/rpc-protocol.ts +217 -0
- package/src/common/message-rpc/uint8-array-message-buffer.spec.ts +41 -0
- package/src/common/message-rpc/uint8-array-message-buffer.ts +206 -0
- package/src/common/messaging/abstract-connection-provider.ts +28 -37
- package/src/common/messaging/connection-error-handler.ts +1 -2
- package/src/common/messaging/handler.ts +2 -2
- package/src/common/messaging/proxy-factory.spec.ts +4 -17
- package/src/common/messaging/proxy-factory.ts +27 -16
- package/src/common/messaging/web-socket-channel.ts +79 -135
- package/src/common/nls.ts +11 -0
- package/src/common/preferences/preference-schema.ts +1 -6
- package/src/common/promise-util.ts +13 -14
- package/src/common/resource.ts +29 -2
- package/src/common/theme.ts +6 -2
- package/src/electron-browser/messaging/electron-ipc-connection-provider.ts +21 -7
- package/src/electron-browser/messaging/electron-ws-connection-provider.ts +5 -8
- package/src/electron-main/messaging/electron-messaging-contribution.ts +87 -65
- package/src/electron-main/messaging/electron-messaging-service.ts +2 -8
- package/src/node/messaging/binary-message-pipe.ts +168 -0
- package/src/node/messaging/ipc-bootstrap.ts +3 -11
- package/src/node/messaging/ipc-channel.ts +97 -0
- package/src/node/messaging/ipc-connection-provider.ts +18 -35
- package/src/node/messaging/ipc-protocol.ts +2 -2
- package/src/node/messaging/messaging-contribution.ts +29 -74
- package/src/node/messaging/messaging-service.ts +4 -31
- package/src/node/messaging/test/test-web-socket-channel.ts +26 -17
- package/src/node/request/proxy-cli-contribution.ts +1 -1
- package/lib/browser/preferences/validated-preference-proxy.d.ts +0 -21
- package/lib/browser/preferences/validated-preference-proxy.d.ts.map +0 -1
- package/lib/browser/preferences/validated-preference-proxy.js +0 -118
- package/lib/browser/preferences/validated-preference-proxy.js.map +0 -1
- package/lib/node/messaging/logger.d.ts +0 -8
- package/lib/node/messaging/logger.d.ts.map +0 -1
- package/lib/node/messaging/logger.js.map +0 -1
- package/shared/vscode-ws-jsonrpc/index.d.ts +0 -1
- package/shared/vscode-ws-jsonrpc/index.js +0 -1
- package/src/browser/preferences/validated-preference-proxy.ts +0 -111
- package/src/browser/style/variables-bright.useable.css +0 -93
- package/src/browser/style/variables-dark.useable.css +0 -93
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
// *****************************************************************************
|
|
2
|
+
// Copyright (C) 2021 Red Hat, Inc. and others.
|
|
3
|
+
//
|
|
4
|
+
// This program and the accompanying materials are made available under the
|
|
5
|
+
// terms of the Eclipse Public License v. 2.0 which is available at
|
|
6
|
+
// http://www.eclipse.org/legal/epl-2.0.
|
|
7
|
+
//
|
|
8
|
+
// This Source Code may also be made available under the following Secondary
|
|
9
|
+
// Licenses when the conditions for such availability set forth in the Eclipse
|
|
10
|
+
// Public License v. 2.0 are satisfied: GNU General Public License, version 2
|
|
11
|
+
// with the GNU Classpath Exception which is available at
|
|
12
|
+
// https://www.gnu.org/software/classpath/license.html.
|
|
13
|
+
//
|
|
14
|
+
// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
|
|
15
|
+
// *****************************************************************************
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* A buffer maintaining a write position capable of writing primitive values
|
|
19
|
+
*/
|
|
20
|
+
export interface WriteBuffer {
|
|
21
|
+
writeUint8(byte: number): this
|
|
22
|
+
writeUint16(value: number): this
|
|
23
|
+
writeUint32(value: number): this
|
|
24
|
+
writeString(value: string): this
|
|
25
|
+
writeBytes(value: Uint8Array): this
|
|
26
|
+
writeNumber(value: number): this
|
|
27
|
+
writeLength(value: number): this
|
|
28
|
+
/**
|
|
29
|
+
* Makes any writes to the buffer permanent, for example by sending the writes over a channel.
|
|
30
|
+
* You must obtain a new write buffer after committing
|
|
31
|
+
*/
|
|
32
|
+
commit(): void;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
export class ForwardingWriteBuffer implements WriteBuffer {
|
|
36
|
+
constructor(protected readonly underlying: WriteBuffer) {
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
writeUint8(byte: number): this {
|
|
40
|
+
this.underlying.writeUint8(byte);
|
|
41
|
+
return this;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
writeUint16(value: number): this {
|
|
45
|
+
this.underlying.writeUint16(value);
|
|
46
|
+
return this;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
writeUint32(value: number): this {
|
|
50
|
+
this.underlying.writeUint32(value);
|
|
51
|
+
return this;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
writeLength(value: number): this {
|
|
55
|
+
this.underlying.writeLength(value);
|
|
56
|
+
return this;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
writeString(value: string): this {
|
|
60
|
+
this.underlying.writeString(value);
|
|
61
|
+
return this;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
writeBytes(value: Uint8Array): this {
|
|
65
|
+
this.underlying.writeBytes(value);
|
|
66
|
+
return this;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
writeNumber(value: number): this {
|
|
70
|
+
this.underlying.writeNumber(value);
|
|
71
|
+
return this;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
commit(): void {
|
|
75
|
+
this.underlying.commit();
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
/**
|
|
80
|
+
* A buffer maintaining a read position in a buffer containing a received message capable of
|
|
81
|
+
* reading primitive values.
|
|
82
|
+
*/
|
|
83
|
+
export interface ReadBuffer {
|
|
84
|
+
readUint8(): number;
|
|
85
|
+
readUint16(): number;
|
|
86
|
+
readUint32(): number;
|
|
87
|
+
readString(): string;
|
|
88
|
+
readNumber(): number,
|
|
89
|
+
readLength(): number,
|
|
90
|
+
readBytes(): Uint8Array;
|
|
91
|
+
|
|
92
|
+
/**
|
|
93
|
+
* Returns a new read buffer whose starting read position is the current read position of this buffer.
|
|
94
|
+
* This is useful to create read buffers sub messages.
|
|
95
|
+
* (e.g. when using a multiplexer the beginning of the message might contain some protocol overhead which should not be part
|
|
96
|
+
* of the message reader that is sent to the target channel)
|
|
97
|
+
*/
|
|
98
|
+
sliceAtReadPosition(): ReadBuffer
|
|
99
|
+
}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
// *****************************************************************************
|
|
2
|
+
// Copyright (C) 2021 Red Hat, Inc. and others.
|
|
3
|
+
//
|
|
4
|
+
// This program and the accompanying materials are made available under the
|
|
5
|
+
// terms of the Eclipse Public License v. 2.0 which is available at
|
|
6
|
+
// http://www.eclipse.org/legal/epl-2.0.
|
|
7
|
+
//
|
|
8
|
+
// This Source Code may also be made available under the following Secondary
|
|
9
|
+
// Licenses when the conditions for such availability set forth in the Eclipse
|
|
10
|
+
// Public License v. 2.0 are satisfied: GNU General Public License, version 2
|
|
11
|
+
// with the GNU Classpath Exception which is available at
|
|
12
|
+
// https://www.gnu.org/software/classpath/license.html.
|
|
13
|
+
//
|
|
14
|
+
// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
|
|
15
|
+
// *****************************************************************************
|
|
16
|
+
|
|
17
|
+
import { expect } from 'chai';
|
|
18
|
+
import { Uint8ArrayReadBuffer, Uint8ArrayWriteBuffer } from './uint8-array-message-buffer';
|
|
19
|
+
import { EncodingError, RpcMessageDecoder, RpcMessageEncoder } from './rpc-message-encoder';
|
|
20
|
+
|
|
21
|
+
describe('PPC Message Codex', () => {
|
|
22
|
+
describe('RPC Message Encoder & Decoder', () => {
|
|
23
|
+
it('should encode object into binary message and decode the message back into the original object', () => {
|
|
24
|
+
const buffer = new Uint8Array(1024);
|
|
25
|
+
const writer = new Uint8ArrayWriteBuffer(buffer);
|
|
26
|
+
|
|
27
|
+
const encoder = new RpcMessageEncoder();
|
|
28
|
+
const jsonMangled = JSON.parse(JSON.stringify(encoder));
|
|
29
|
+
// The RpcMessageEncoder can decode/encode collections, whereas JSON.parse can't. => We have to manually restore the set
|
|
30
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
31
|
+
jsonMangled.registeredTags = (encoder as any).registeredTags;
|
|
32
|
+
|
|
33
|
+
encoder.writeTypedValue(writer, encoder, new WeakSet());
|
|
34
|
+
|
|
35
|
+
const written = writer.getCurrentContents();
|
|
36
|
+
|
|
37
|
+
const reader = new Uint8ArrayReadBuffer(written);
|
|
38
|
+
|
|
39
|
+
const decoder = new RpcMessageDecoder();
|
|
40
|
+
const decoded = decoder.readTypedValue(reader);
|
|
41
|
+
|
|
42
|
+
expect(decoded).deep.equal(jsonMangled);
|
|
43
|
+
});
|
|
44
|
+
it('should fail with an EncodingError when trying to encode the object ', () => {
|
|
45
|
+
const x = new Set();
|
|
46
|
+
const y = new Set();
|
|
47
|
+
x.add(y);
|
|
48
|
+
y.add(x);
|
|
49
|
+
const encoder = new RpcMessageEncoder();
|
|
50
|
+
|
|
51
|
+
const writer = new Uint8ArrayWriteBuffer();
|
|
52
|
+
expect(() => encoder.writeTypedValue(writer, x, new WeakSet())).to.throw(EncodingError);
|
|
53
|
+
});
|
|
54
|
+
});
|
|
55
|
+
});
|
|
@@ -0,0 +1,552 @@
|
|
|
1
|
+
// *****************************************************************************
|
|
2
|
+
// Copyright (C) 2022 Red Hat, Inc. and others.
|
|
3
|
+
//
|
|
4
|
+
// This program and the accompanying materials are made available under the
|
|
5
|
+
// terms of the Eclipse Public License v. 2.0 which is available at
|
|
6
|
+
// http://www.eclipse.org/legal/epl-2.0.
|
|
7
|
+
//
|
|
8
|
+
// This Source Code may also be made available under the following Secondary
|
|
9
|
+
// Licenses when the conditions for such availability set forth in the Eclipse
|
|
10
|
+
// Public License v. 2.0 are satisfied: GNU General Public License, version 2
|
|
11
|
+
// with the GNU Classpath Exception which is available at
|
|
12
|
+
// https://www.gnu.org/software/classpath/license.html.
|
|
13
|
+
//
|
|
14
|
+
// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
|
|
15
|
+
// *****************************************************************************
|
|
16
|
+
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
17
|
+
|
|
18
|
+
import { ReadBuffer, WriteBuffer } from './message-buffer';
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* This code lets you encode rpc protocol messages (request/reply/notification/error/cancel)
|
|
22
|
+
* into a channel write buffer and decode the same messages from a read buffer.
|
|
23
|
+
* Custom encoders/decoders can be registered to specially handling certain types of values
|
|
24
|
+
* to be encoded. Clients are responsible for ensuring that the set of tags for encoders
|
|
25
|
+
* is distinct and the same at both ends of a channel.
|
|
26
|
+
*/
|
|
27
|
+
|
|
28
|
+
export type RpcMessage = RequestMessage | ReplyMessage | ReplyErrMessage | CancelMessage | NotificationMessage;
|
|
29
|
+
|
|
30
|
+
export const enum RpcMessageType {
|
|
31
|
+
Request = 1,
|
|
32
|
+
Notification = 2,
|
|
33
|
+
Reply = 3,
|
|
34
|
+
ReplyErr = 4,
|
|
35
|
+
Cancel = 5,
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
export interface CancelMessage {
|
|
39
|
+
type: RpcMessageType.Cancel;
|
|
40
|
+
id: number;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
export interface RequestMessage {
|
|
44
|
+
type: RpcMessageType.Request;
|
|
45
|
+
id: number;
|
|
46
|
+
method: string;
|
|
47
|
+
args: any[];
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
export interface NotificationMessage {
|
|
51
|
+
type: RpcMessageType.Notification;
|
|
52
|
+
id: number;
|
|
53
|
+
method: string;
|
|
54
|
+
args: any[];
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
export interface ReplyMessage {
|
|
58
|
+
type: RpcMessageType.Reply;
|
|
59
|
+
id: number;
|
|
60
|
+
res: any;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
export interface ReplyErrMessage {
|
|
64
|
+
type: RpcMessageType.ReplyErr;
|
|
65
|
+
id: number;
|
|
66
|
+
err: any;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
export interface SerializedError {
|
|
70
|
+
readonly $isError: true;
|
|
71
|
+
readonly name: string;
|
|
72
|
+
readonly message: string;
|
|
73
|
+
readonly stack: string;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
/**
|
|
77
|
+
* A special error that can be returned in case a request
|
|
78
|
+
* has failed. Provides additional information i.e. an error code
|
|
79
|
+
* and additional error data.
|
|
80
|
+
*/
|
|
81
|
+
export class ResponseError extends Error {
|
|
82
|
+
constructor(readonly code: number, message: string, readonly data: any) {
|
|
83
|
+
super(message);
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
/**
|
|
88
|
+
* The tag values for the default {@link ValueEncoder}s & {@link ValueDecoder}s
|
|
89
|
+
*/
|
|
90
|
+
|
|
91
|
+
export enum ObjectType {
|
|
92
|
+
JSON = 0,
|
|
93
|
+
ByteArray = 1,
|
|
94
|
+
ObjectArray = 2,
|
|
95
|
+
Undefined = 3,
|
|
96
|
+
Object = 4,
|
|
97
|
+
String = 5,
|
|
98
|
+
Boolean = 6,
|
|
99
|
+
Number = 7,
|
|
100
|
+
// eslint-disable-next-line @typescript-eslint/no-shadow
|
|
101
|
+
ResponseError = 8,
|
|
102
|
+
Error = 9,
|
|
103
|
+
Map = 10,
|
|
104
|
+
Set = 11,
|
|
105
|
+
Function = 12
|
|
106
|
+
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
/**
|
|
110
|
+
* A value encoder writes javascript values to a write buffer. Encoders will be asked
|
|
111
|
+
* in turn (ordered by their tag value, descending) whether they can encode a given value
|
|
112
|
+
* This means encoders with higher tag values have priority. Since the default encoders
|
|
113
|
+
* have tag values from 1-12, they can be easily overridden.
|
|
114
|
+
*/
|
|
115
|
+
export interface ValueEncoder {
|
|
116
|
+
/**
|
|
117
|
+
* Returns true if this encoder wants to encode this value.
|
|
118
|
+
* @param value the value to be encoded
|
|
119
|
+
*/
|
|
120
|
+
is(value: any): boolean;
|
|
121
|
+
/**
|
|
122
|
+
* Write the given value to the buffer. Will only be called if {@link is(value)} returns true.
|
|
123
|
+
* @param buf The buffer to write to
|
|
124
|
+
* @param value The value to be written
|
|
125
|
+
* @param visitedObjects The collection of already visited (i.e. encoded) objects. Used to detect circular references
|
|
126
|
+
* @param recursiveEncode A function that will use the encoders registered on the {@link MessageEncoder}
|
|
127
|
+
* to write a value to the underlying buffer. This is used mostly to write structures like an array
|
|
128
|
+
* without having to know how to encode the values in the array
|
|
129
|
+
*/
|
|
130
|
+
write(buf: WriteBuffer, value: any, visitedObjects: WeakSet<object>, recursiveEncode?: (buf: WriteBuffer, value: any, visitedObjects: WeakSet<object>) => void): void;
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
/**
|
|
134
|
+
* Reads javascript values from a read buffer
|
|
135
|
+
*/
|
|
136
|
+
export interface ValueDecoder {
|
|
137
|
+
/**
|
|
138
|
+
* Reads a value from a read buffer. This method will be called for the decoder that is
|
|
139
|
+
* registered for the tag associated with the value encoder that encoded this value.
|
|
140
|
+
* @param buf The read buffer to read from
|
|
141
|
+
* @param recursiveDecode A function that will use the decoders registered on the {@link RpcMessageDecoder}
|
|
142
|
+
* to read values from the underlying read buffer. This is used mostly to decode structures like an array
|
|
143
|
+
* without having to know how to decode the values in the array.
|
|
144
|
+
*/
|
|
145
|
+
read(buf: ReadBuffer, recursiveDecode: (buf: ReadBuffer) => unknown): unknown;
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
/**
|
|
149
|
+
* Custom error thrown by the {@link RpcMessageEncoder} if an error occurred during the encoding and the
|
|
150
|
+
* object could not be written to the given {@link WriteBuffer}
|
|
151
|
+
*/
|
|
152
|
+
export class EncodingError extends Error {
|
|
153
|
+
constructor(msg: string) {
|
|
154
|
+
super(msg);
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
/**
|
|
159
|
+
* A `RpcMessageDecoder` parses a a binary message received via {@link ReadBuffer} into a {@link RpcMessage}
|
|
160
|
+
*/
|
|
161
|
+
export class RpcMessageDecoder {
|
|
162
|
+
|
|
163
|
+
protected decoders: Map<number, ValueDecoder> = new Map();
|
|
164
|
+
|
|
165
|
+
constructor() {
|
|
166
|
+
this.registerDecoders();
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
registerDecoders(): void {
|
|
170
|
+
this.registerDecoder(ObjectType.JSON, {
|
|
171
|
+
read: buf => {
|
|
172
|
+
const json = buf.readString();
|
|
173
|
+
return JSON.parse(json);
|
|
174
|
+
}
|
|
175
|
+
});
|
|
176
|
+
this.registerDecoder(ObjectType.Error, {
|
|
177
|
+
read: buf => {
|
|
178
|
+
const serializedError: SerializedError = JSON.parse(buf.readString());
|
|
179
|
+
const error = new Error(serializedError.message);
|
|
180
|
+
Object.assign(error, serializedError);
|
|
181
|
+
return error;
|
|
182
|
+
}
|
|
183
|
+
});
|
|
184
|
+
|
|
185
|
+
this.registerDecoder(ObjectType.ResponseError, {
|
|
186
|
+
read: buf => {
|
|
187
|
+
const error = JSON.parse(buf.readString());
|
|
188
|
+
return new ResponseError(error.code, error.message, error.data);
|
|
189
|
+
}
|
|
190
|
+
});
|
|
191
|
+
this.registerDecoder(ObjectType.ByteArray, {
|
|
192
|
+
read: buf => buf.readBytes()
|
|
193
|
+
});
|
|
194
|
+
|
|
195
|
+
this.registerDecoder(ObjectType.ObjectArray, {
|
|
196
|
+
read: buf => this.readArray(buf)
|
|
197
|
+
});
|
|
198
|
+
|
|
199
|
+
this.registerDecoder(ObjectType.Undefined, {
|
|
200
|
+
read: () => undefined
|
|
201
|
+
});
|
|
202
|
+
|
|
203
|
+
this.registerDecoder(ObjectType.Object, {
|
|
204
|
+
read: (buf, recursiveRead) => {
|
|
205
|
+
const propertyCount = buf.readLength();
|
|
206
|
+
const result = Object.create({});
|
|
207
|
+
for (let i = 0; i < propertyCount; i++) {
|
|
208
|
+
const key = buf.readString();
|
|
209
|
+
const value = recursiveRead(buf);
|
|
210
|
+
result[key] = value;
|
|
211
|
+
}
|
|
212
|
+
return result;
|
|
213
|
+
}
|
|
214
|
+
});
|
|
215
|
+
|
|
216
|
+
this.registerDecoder(ObjectType.String, {
|
|
217
|
+
read: (buf, recursiveRead) => buf.readString()
|
|
218
|
+
});
|
|
219
|
+
|
|
220
|
+
this.registerDecoder(ObjectType.Boolean, {
|
|
221
|
+
read: buf => buf.readUint8() === 1
|
|
222
|
+
});
|
|
223
|
+
|
|
224
|
+
this.registerDecoder(ObjectType.Number, {
|
|
225
|
+
read: buf => buf.readNumber()
|
|
226
|
+
});
|
|
227
|
+
|
|
228
|
+
this.registerDecoder(ObjectType.Map, {
|
|
229
|
+
read: buf => new Map(this.readArray(buf))
|
|
230
|
+
});
|
|
231
|
+
|
|
232
|
+
this.registerDecoder(ObjectType.Set, {
|
|
233
|
+
read: buf => new Set(this.readArray(buf))
|
|
234
|
+
});
|
|
235
|
+
|
|
236
|
+
this.registerDecoder(ObjectType.Function, {
|
|
237
|
+
read: () => ({})
|
|
238
|
+
});
|
|
239
|
+
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
/**
|
|
243
|
+
* Registers a new {@link ValueDecoder} for the given tag.
|
|
244
|
+
* After the successful registration the {@link tagIntType} is recomputed
|
|
245
|
+
* by retrieving the highest tag value and calculating the required Uint size to store it.
|
|
246
|
+
* @param tag the tag for which the decoder should be registered.
|
|
247
|
+
* @param decoder the decoder that should be registered.
|
|
248
|
+
*/
|
|
249
|
+
registerDecoder(tag: number, decoder: ValueDecoder): void {
|
|
250
|
+
if (this.decoders.has(tag)) {
|
|
251
|
+
throw new Error(`Decoder already registered: ${tag}`);
|
|
252
|
+
}
|
|
253
|
+
this.decoders.set(tag, decoder);
|
|
254
|
+
}
|
|
255
|
+
parse(buf: ReadBuffer): RpcMessage {
|
|
256
|
+
try {
|
|
257
|
+
const msgType = buf.readUint8();
|
|
258
|
+
|
|
259
|
+
switch (msgType) {
|
|
260
|
+
case RpcMessageType.Request:
|
|
261
|
+
return this.parseRequest(buf);
|
|
262
|
+
case RpcMessageType.Notification:
|
|
263
|
+
return this.parseNotification(buf);
|
|
264
|
+
case RpcMessageType.Reply:
|
|
265
|
+
return this.parseReply(buf);
|
|
266
|
+
case RpcMessageType.ReplyErr:
|
|
267
|
+
return this.parseReplyErr(buf);
|
|
268
|
+
case RpcMessageType.Cancel:
|
|
269
|
+
return this.parseCancel(buf);
|
|
270
|
+
}
|
|
271
|
+
throw new Error(`Unknown message type: ${msgType}`);
|
|
272
|
+
} catch (e) {
|
|
273
|
+
// exception does not show problematic content: log it!
|
|
274
|
+
console.log('failed to parse message: ' + buf);
|
|
275
|
+
throw e;
|
|
276
|
+
}
|
|
277
|
+
}
|
|
278
|
+
|
|
279
|
+
protected parseCancel(msg: ReadBuffer): CancelMessage {
|
|
280
|
+
const callId = msg.readUint32();
|
|
281
|
+
return {
|
|
282
|
+
type: RpcMessageType.Cancel,
|
|
283
|
+
id: callId
|
|
284
|
+
};
|
|
285
|
+
}
|
|
286
|
+
|
|
287
|
+
protected parseRequest(msg: ReadBuffer): RequestMessage {
|
|
288
|
+
const callId = msg.readUint32();
|
|
289
|
+
const method = msg.readString();
|
|
290
|
+
const args = this.readArray(msg);
|
|
291
|
+
|
|
292
|
+
return {
|
|
293
|
+
type: RpcMessageType.Request,
|
|
294
|
+
id: callId,
|
|
295
|
+
method: method,
|
|
296
|
+
args: args
|
|
297
|
+
};
|
|
298
|
+
}
|
|
299
|
+
|
|
300
|
+
protected parseNotification(msg: ReadBuffer): NotificationMessage {
|
|
301
|
+
const callId = msg.readUint32();
|
|
302
|
+
const method = msg.readString();
|
|
303
|
+
const args = this.readArray(msg);
|
|
304
|
+
|
|
305
|
+
return {
|
|
306
|
+
type: RpcMessageType.Notification,
|
|
307
|
+
id: callId,
|
|
308
|
+
method: method,
|
|
309
|
+
args: args
|
|
310
|
+
};
|
|
311
|
+
}
|
|
312
|
+
|
|
313
|
+
parseReply(msg: ReadBuffer): ReplyMessage {
|
|
314
|
+
const callId = msg.readUint32();
|
|
315
|
+
const value = this.readTypedValue(msg);
|
|
316
|
+
return {
|
|
317
|
+
type: RpcMessageType.Reply,
|
|
318
|
+
id: callId,
|
|
319
|
+
res: value
|
|
320
|
+
};
|
|
321
|
+
}
|
|
322
|
+
|
|
323
|
+
parseReplyErr(msg: ReadBuffer): ReplyErrMessage {
|
|
324
|
+
const callId = msg.readUint32();
|
|
325
|
+
|
|
326
|
+
const err = this.readTypedValue(msg);
|
|
327
|
+
|
|
328
|
+
return {
|
|
329
|
+
type: RpcMessageType.ReplyErr,
|
|
330
|
+
id: callId,
|
|
331
|
+
err
|
|
332
|
+
};
|
|
333
|
+
}
|
|
334
|
+
|
|
335
|
+
readArray(buf: ReadBuffer): any[] {
|
|
336
|
+
const length = buf.readLength();
|
|
337
|
+
const result = new Array(length);
|
|
338
|
+
for (let i = 0; i < length; i++) {
|
|
339
|
+
result[i] = this.readTypedValue(buf);
|
|
340
|
+
}
|
|
341
|
+
return result;
|
|
342
|
+
}
|
|
343
|
+
|
|
344
|
+
readTypedValue(buf: ReadBuffer): any {
|
|
345
|
+
const type = buf.readUint8();
|
|
346
|
+
const decoder = this.decoders.get(type);
|
|
347
|
+
if (!decoder) {
|
|
348
|
+
throw new Error(`No decoder for tag ${type}`);
|
|
349
|
+
}
|
|
350
|
+
return decoder.read(buf, innerBuffer => this.readTypedValue(innerBuffer));
|
|
351
|
+
}
|
|
352
|
+
}
|
|
353
|
+
|
|
354
|
+
/**
|
|
355
|
+
* A `RpcMessageEncoder` writes {@link RpcMessage} objects to a {@link WriteBuffer}. Note that it is
|
|
356
|
+
* up to clients to commit the message. This allows for multiple messages being
|
|
357
|
+
* encoded before sending.
|
|
358
|
+
*/
|
|
359
|
+
export class RpcMessageEncoder {
|
|
360
|
+
|
|
361
|
+
protected readonly encoders: [number, ValueEncoder][] = [];
|
|
362
|
+
protected readonly registeredTags: Set<number> = new Set();
|
|
363
|
+
|
|
364
|
+
constructor() {
|
|
365
|
+
this.registerEncoders();
|
|
366
|
+
}
|
|
367
|
+
|
|
368
|
+
protected registerEncoders(): void {
|
|
369
|
+
// encoders will be consulted in reverse order of registration, so the JSON fallback needs to be last
|
|
370
|
+
this.registerEncoder(ObjectType.JSON, {
|
|
371
|
+
is: () => true,
|
|
372
|
+
write: (buf, value) => {
|
|
373
|
+
buf.writeString(JSON.stringify(value));
|
|
374
|
+
}
|
|
375
|
+
});
|
|
376
|
+
|
|
377
|
+
this.registerEncoder(ObjectType.Function, {
|
|
378
|
+
is: value => typeof value === 'function',
|
|
379
|
+
write: () => { }
|
|
380
|
+
});
|
|
381
|
+
|
|
382
|
+
this.registerEncoder(ObjectType.Object, {
|
|
383
|
+
is: value => typeof value === 'object',
|
|
384
|
+
write: (buf, object, visitedObjects, recursiveEncode) => {
|
|
385
|
+
const properties = Object.keys(object);
|
|
386
|
+
const relevant = [];
|
|
387
|
+
for (const property of properties) {
|
|
388
|
+
const value = object[property];
|
|
389
|
+
if (typeof value !== 'function') {
|
|
390
|
+
relevant.push([property, value]);
|
|
391
|
+
}
|
|
392
|
+
}
|
|
393
|
+
|
|
394
|
+
buf.writeLength(relevant.length);
|
|
395
|
+
for (const [property, value] of relevant) {
|
|
396
|
+
buf.writeString(property);
|
|
397
|
+
recursiveEncode?.(buf, value, visitedObjects);
|
|
398
|
+
}
|
|
399
|
+
}
|
|
400
|
+
});
|
|
401
|
+
|
|
402
|
+
this.registerEncoder(ObjectType.Error, {
|
|
403
|
+
is: value => value instanceof Error,
|
|
404
|
+
write: (buf, error: Error) => {
|
|
405
|
+
const { name, message } = error;
|
|
406
|
+
const stack: string = (<any>error).stacktrace || error.stack;
|
|
407
|
+
const serializedError = {
|
|
408
|
+
$isError: true,
|
|
409
|
+
name,
|
|
410
|
+
message,
|
|
411
|
+
stack
|
|
412
|
+
};
|
|
413
|
+
buf.writeString(JSON.stringify(serializedError));
|
|
414
|
+
}
|
|
415
|
+
});
|
|
416
|
+
|
|
417
|
+
this.registerEncoder(ObjectType.ResponseError, {
|
|
418
|
+
is: value => value instanceof ResponseError,
|
|
419
|
+
write: (buf, value) => buf.writeString(JSON.stringify(value))
|
|
420
|
+
});
|
|
421
|
+
|
|
422
|
+
this.registerEncoder(ObjectType.Map, {
|
|
423
|
+
is: value => value instanceof Map,
|
|
424
|
+
write: (buf, value: Map<any, any>, visitedObjects) => this.writeArray(buf, Array.from(value.entries()), visitedObjects)
|
|
425
|
+
});
|
|
426
|
+
|
|
427
|
+
this.registerEncoder(ObjectType.Set, {
|
|
428
|
+
is: value => value instanceof Set,
|
|
429
|
+
write: (buf, value: Set<any>, visitedObjects) => this.writeArray(buf, [...value], visitedObjects)
|
|
430
|
+
});
|
|
431
|
+
|
|
432
|
+
this.registerEncoder(ObjectType.Undefined, {
|
|
433
|
+
// eslint-disable-next-line no-null/no-null
|
|
434
|
+
is: value => value == null,
|
|
435
|
+
write: () => { }
|
|
436
|
+
});
|
|
437
|
+
|
|
438
|
+
this.registerEncoder(ObjectType.ObjectArray, {
|
|
439
|
+
is: value => Array.isArray(value),
|
|
440
|
+
write: (buf, value, visitedObjects) => {
|
|
441
|
+
this.writeArray(buf, value, visitedObjects);
|
|
442
|
+
}
|
|
443
|
+
});
|
|
444
|
+
|
|
445
|
+
this.registerEncoder(ObjectType.ByteArray, {
|
|
446
|
+
is: value => value instanceof Uint8Array,
|
|
447
|
+
write: (buf, value) => {
|
|
448
|
+
buf.writeBytes(value);
|
|
449
|
+
}
|
|
450
|
+
});
|
|
451
|
+
|
|
452
|
+
this.registerEncoder(ObjectType.String, {
|
|
453
|
+
is: value => typeof value === 'string',
|
|
454
|
+
write: (buf, value) => {
|
|
455
|
+
buf.writeString(value);
|
|
456
|
+
}
|
|
457
|
+
});
|
|
458
|
+
|
|
459
|
+
this.registerEncoder(ObjectType.Boolean, {
|
|
460
|
+
is: value => typeof value === 'boolean',
|
|
461
|
+
write: (buf, value) => {
|
|
462
|
+
buf.writeUint8(value === true ? 1 : 0);
|
|
463
|
+
}
|
|
464
|
+
});
|
|
465
|
+
|
|
466
|
+
this.registerEncoder(ObjectType.Number, {
|
|
467
|
+
is: value => typeof value === 'number',
|
|
468
|
+
write: (buf, value) => {
|
|
469
|
+
buf.writeNumber(value);
|
|
470
|
+
}
|
|
471
|
+
});
|
|
472
|
+
}
|
|
473
|
+
|
|
474
|
+
/**
|
|
475
|
+
* Registers a new {@link ValueEncoder} for the given tag.
|
|
476
|
+
* After the successful registration the {@link tagIntType} is recomputed
|
|
477
|
+
* by retrieving the highest tag value and calculating the required Uint size to store it.
|
|
478
|
+
* @param tag the tag for which the encoder should be registered.
|
|
479
|
+
* @param decoder the encoder that should be registered.
|
|
480
|
+
*/
|
|
481
|
+
registerEncoder<T>(tag: number, encoder: ValueEncoder): void {
|
|
482
|
+
if (this.registeredTags.has(tag)) {
|
|
483
|
+
throw new Error(`Tag already registered: ${tag}`);
|
|
484
|
+
}
|
|
485
|
+
this.registeredTags.add(tag);
|
|
486
|
+
this.encoders.push([tag, encoder]);
|
|
487
|
+
}
|
|
488
|
+
|
|
489
|
+
cancel(buf: WriteBuffer, requestId: number): void {
|
|
490
|
+
buf.writeUint8(RpcMessageType.Cancel);
|
|
491
|
+
buf.writeUint32(requestId);
|
|
492
|
+
}
|
|
493
|
+
|
|
494
|
+
notification(buf: WriteBuffer, requestId: number, method: string, args: any[]): void {
|
|
495
|
+
buf.writeUint8(RpcMessageType.Notification);
|
|
496
|
+
buf.writeUint32(requestId);
|
|
497
|
+
buf.writeString(method);
|
|
498
|
+
this.writeArray(buf, args, new WeakSet());
|
|
499
|
+
}
|
|
500
|
+
|
|
501
|
+
request(buf: WriteBuffer, requestId: number, method: string, args: any[]): void {
|
|
502
|
+
buf.writeUint8(RpcMessageType.Request);
|
|
503
|
+
buf.writeUint32(requestId);
|
|
504
|
+
buf.writeString(method);
|
|
505
|
+
this.writeArray(buf, args, new WeakSet());
|
|
506
|
+
}
|
|
507
|
+
|
|
508
|
+
replyOK(buf: WriteBuffer, requestId: number, res: any): void {
|
|
509
|
+
buf.writeUint8(RpcMessageType.Reply);
|
|
510
|
+
buf.writeUint32(requestId);
|
|
511
|
+
this.writeTypedValue(buf, res, new WeakSet());
|
|
512
|
+
}
|
|
513
|
+
|
|
514
|
+
replyErr(buf: WriteBuffer, requestId: number, err: any): void {
|
|
515
|
+
buf.writeUint8(RpcMessageType.ReplyErr);
|
|
516
|
+
buf.writeUint32(requestId);
|
|
517
|
+
this.writeTypedValue(buf, err, new WeakSet());
|
|
518
|
+
}
|
|
519
|
+
|
|
520
|
+
writeTypedValue(buf: WriteBuffer, value: any, visitedObjects: WeakSet<object>): void {
|
|
521
|
+
if (value && typeof value === 'object') {
|
|
522
|
+
if (visitedObjects.has(value)) {
|
|
523
|
+
throw new EncodingError('Object to encode contains circular references!');
|
|
524
|
+
}
|
|
525
|
+
visitedObjects.add(value);
|
|
526
|
+
}
|
|
527
|
+
|
|
528
|
+
try {
|
|
529
|
+
for (let i: number = this.encoders.length - 1; i >= 0; i--) {
|
|
530
|
+
if (this.encoders[i][1].is(value)) {
|
|
531
|
+
buf.writeUint8(this.encoders[i][0]);
|
|
532
|
+
this.encoders[i][1].write(buf, value, visitedObjects, (innerBuffer, innerValue, _visitedObjects) => {
|
|
533
|
+
this.writeTypedValue(innerBuffer, innerValue, _visitedObjects);
|
|
534
|
+
});
|
|
535
|
+
return;
|
|
536
|
+
}
|
|
537
|
+
}
|
|
538
|
+
throw new EncodingError(`No suitable value encoder found for ${value}`);
|
|
539
|
+
} finally {
|
|
540
|
+
if (value && typeof value === 'object') {
|
|
541
|
+
visitedObjects.delete(value);
|
|
542
|
+
}
|
|
543
|
+
}
|
|
544
|
+
}
|
|
545
|
+
|
|
546
|
+
writeArray(buf: WriteBuffer, value: any[], visitedObjects: WeakSet<object>): void {
|
|
547
|
+
buf.writeLength(value.length);
|
|
548
|
+
for (let i = 0; i < value.length; i++) {
|
|
549
|
+
this.writeTypedValue(buf, value[i], visitedObjects);
|
|
550
|
+
}
|
|
551
|
+
}
|
|
552
|
+
}
|