@adminide-stack/extension-api 0.0.2-alpha.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/LICENSE +39 -0
- package/README.md +9 -0
- package/lib/connections/jsonrpc2/connection.d.ts +55 -0
- package/lib/connections/jsonrpc2/connection.js +575 -0
- package/lib/connections/jsonrpc2/connection.js.map +1 -0
- package/lib/connections/jsonrpc2/connection.test.d.ts +1 -0
- package/lib/connections/jsonrpc2/connection.test.js +443 -0
- package/lib/connections/jsonrpc2/connection.test.js.map +1 -0
- package/lib/connections/jsonrpc2/events.d.ts +24 -0
- package/lib/connections/jsonrpc2/events.js +117 -0
- package/lib/connections/jsonrpc2/events.js.map +1 -0
- package/lib/connections/jsonrpc2/index.d.ts +5 -0
- package/lib/connections/jsonrpc2/index.js +24 -0
- package/lib/connections/jsonrpc2/index.js.map +1 -0
- package/lib/connections/jsonrpc2/linkedMap.d.ts +29 -0
- package/lib/connections/jsonrpc2/linkedMap.js +254 -0
- package/lib/connections/jsonrpc2/linkedMap.js.map +1 -0
- package/lib/connections/jsonrpc2/linkedMap.test.d.ts +1 -0
- package/lib/connections/jsonrpc2/linkedMap.test.js +62 -0
- package/lib/connections/jsonrpc2/linkedMap.test.js.map +1 -0
- package/lib/connections/jsonrpc2/messages.d.ts +117 -0
- package/lib/connections/jsonrpc2/messages.js +72 -0
- package/lib/connections/jsonrpc2/messages.js.map +1 -0
- package/lib/connections/jsonrpc2/test-helper.d.ts +8 -0
- package/lib/connections/jsonrpc2/test-helper.js +36 -0
- package/lib/connections/jsonrpc2/test-helper.js.map +1 -0
- package/lib/connections/jsonrpc2/trace.d.ts +30 -0
- package/lib/connections/jsonrpc2/trace.js +96 -0
- package/lib/connections/jsonrpc2/trace.js.map +1 -0
- package/lib/connections/jsonrpc2/transport.d.ts +36 -0
- package/lib/connections/jsonrpc2/transport.js +66 -0
- package/lib/connections/jsonrpc2/transport.js.map +1 -0
- package/lib/connections/jsonrpc2/transports/browser-websocket.d.ts +0 -0
- package/lib/connections/jsonrpc2/transports/browser-websocket.js +189 -0
- package/lib/connections/jsonrpc2/transports/browser-websocket.js.map +1 -0
- package/lib/connections/jsonrpc2/transports/merged.d.ts +0 -0
- package/lib/connections/jsonrpc2/transports/merged.js +239 -0
- package/lib/connections/jsonrpc2/transports/merged.js.map +1 -0
- package/lib/connections/jsonrpc2/transports/webSocket.d.ts +0 -0
- package/lib/connections/jsonrpc2/transports/webSocket.js +138 -0
- package/lib/connections/jsonrpc2/transports/webSocket.js.map +1 -0
- package/lib/connections/jsonrpc2/transports/webWorker.d.ts +22 -0
- package/lib/connections/jsonrpc2/transports/webWorker.js +111 -0
- package/lib/connections/jsonrpc2/transports/webWorker.js.map +1 -0
- package/lib/connections/proxy/index.d.ts +1 -0
- package/lib/connections/proxy/index.js +18 -0
- package/lib/connections/proxy/index.js.map +1 -0
- package/lib/connections/proxy/proxy.d.ts +49 -0
- package/lib/connections/proxy/proxy.js +108 -0
- package/lib/connections/proxy/proxy.js.map +1 -0
- package/lib/connections/proxy/proxy.test.d.ts +1 -0
- package/lib/connections/proxy/proxy.test.js +55 -0
- package/lib/connections/proxy/proxy.test.js.map +1 -0
- package/lib/connections/remote-rpc/browser-remote-rpc.d.ts +12 -0
- package/lib/connections/remote-rpc/browser-remote-rpc.js +62 -0
- package/lib/connections/remote-rpc/browser-remote-rpc.js.map +1 -0
- package/lib/connections/remote-rpc/browser-server-rpc.test.d.ts +0 -0
- package/lib/connections/remote-rpc/browser-server-rpc.test.js +317 -0
- package/lib/connections/remote-rpc/browser-server-rpc.test.js.map +1 -0
- package/lib/connections/remote-rpc/index.d.ts +1 -0
- package/lib/connections/remote-rpc/index.js +18 -0
- package/lib/connections/remote-rpc/index.js.map +1 -0
- package/lib/connections/remote-rpc/old-browser-remote-rpc.d.ts +12 -0
- package/lib/connections/remote-rpc/old-browser-remote-rpc.js +41 -0
- package/lib/connections/remote-rpc/old-browser-remote-rpc.js.map +1 -0
- package/lib/connections/remote-rpc/rxjs-websockets.d.ts +18 -0
- package/lib/connections/remote-rpc/rxjs-websockets.js +80 -0
- package/lib/connections/remote-rpc/rxjs-websockets.js.map +1 -0
- package/lib/constants/action-types.d.ts +30 -0
- package/lib/constants/action-types.js +38 -0
- package/lib/constants/action-types.js.map +1 -0
- package/lib/constants/index.d.ts +2 -0
- package/lib/constants/index.js +19 -0
- package/lib/constants/index.js.map +1 -0
- package/lib/constants/types.d.ts +8 -0
- package/lib/constants/types.js +12 -0
- package/lib/constants/types.js.map +1 -0
- package/lib/core/expr/evaluator.d.ts +27 -0
- package/lib/core/expr/evaluator.js +144 -0
- package/lib/core/expr/evaluator.js.map +1 -0
- package/lib/core/expr/evaluator.test.d.ts +1 -0
- package/lib/core/expr/evaluator.test.js +52 -0
- package/lib/core/expr/evaluator.test.js.map +1 -0
- package/lib/core/expr/index.d.ts +3 -0
- package/lib/core/expr/index.js +20 -0
- package/lib/core/expr/index.js.map +1 -0
- package/lib/core/expr/lexer.d.ts +114 -0
- package/lib/core/expr/lexer.js +418 -0
- package/lib/core/expr/lexer.js.map +1 -0
- package/lib/core/expr/parser.d.ts +52 -0
- package/lib/core/expr/parser.js +242 -0
- package/lib/core/expr/parser.js.map +1 -0
- package/lib/core/index.d.ts +2 -0
- package/lib/core/index.js +19 -0
- package/lib/core/index.js.map +1 -0
- package/lib/core/types/ext-host-types-bk.d.ts +0 -0
- package/lib/core/types/ext-host-types-bk.js +1275 -0
- package/lib/core/types/ext-host-types-bk.js.map +1 -0
- package/lib/core/types/ext-host-types.d.ts +32 -0
- package/lib/core/types/ext-host-types.js +71 -0
- package/lib/core/types/ext-host-types.js.map +1 -0
- package/lib/core/types/index.d.ts +1 -0
- package/lib/core/types/index.js +18 -0
- package/lib/core/types/index.js.map +1 -0
- package/lib/errors/errors.d.ts +1 -0
- package/lib/errors/errors.js +13 -0
- package/lib/errors/errors.js.map +1 -0
- package/lib/errors/index.d.ts +1 -0
- package/lib/errors/index.js +18 -0
- package/lib/errors/index.js.map +1 -0
- package/lib/index.d.ts +7 -0
- package/lib/index.js +24 -0
- package/lib/index.js.map +1 -0
- package/lib/interfaces/command.d.ts +28 -0
- package/lib/interfaces/command.js +3 -0
- package/lib/interfaces/command.js.map +1 -0
- package/lib/interfaces/configuration.d.ts +36 -0
- package/lib/interfaces/configuration.js +3 -0
- package/lib/interfaces/configuration.js.map +1 -0
- package/lib/interfaces/connection.d.ts +12 -0
- package/lib/interfaces/connection.js +3 -0
- package/lib/interfaces/connection.js.map +1 -0
- package/lib/interfaces/context.d.ts +12 -0
- package/lib/interfaces/context.js +3 -0
- package/lib/interfaces/context.js.map +1 -0
- package/lib/interfaces/contributions/contribution-service.d.ts +20 -0
- package/lib/interfaces/contributions/contribution-service.js +3 -0
- package/lib/interfaces/contributions/contribution-service.js.map +1 -0
- package/lib/interfaces/contributions/contribution.d.ts +383 -0
- package/lib/interfaces/contributions/contribution.js +49 -0
- package/lib/interfaces/contributions/contribution.js.map +1 -0
- package/lib/interfaces/contributions/index.d.ts +2 -0
- package/lib/interfaces/contributions/index.js +19 -0
- package/lib/interfaces/contributions/index.js.map +1 -0
- package/lib/interfaces/controller.d.ts +30 -0
- package/lib/interfaces/controller.js +3 -0
- package/lib/interfaces/controller.js.map +1 -0
- package/lib/interfaces/errors.d.ts +5 -0
- package/lib/interfaces/errors.js +3 -0
- package/lib/interfaces/errors.js.map +1 -0
- package/lib/interfaces/ext-services/contributon-registry.d.ts +45 -0
- package/lib/interfaces/ext-services/contributon-registry.js +3 -0
- package/lib/interfaces/ext-services/contributon-registry.js.map +1 -0
- package/lib/interfaces/ext-services/ext-services.d.ts +23 -0
- package/lib/interfaces/ext-services/ext-services.js +3 -0
- package/lib/interfaces/ext-services/ext-services.js.map +1 -0
- package/lib/interfaces/ext-services/extension-service.d.ts +8 -0
- package/lib/interfaces/ext-services/extension-service.js +3 -0
- package/lib/interfaces/ext-services/extension-service.js.map +1 -0
- package/lib/interfaces/ext-services/index.d.ts +8 -0
- package/lib/interfaces/ext-services/index.js +25 -0
- package/lib/interfaces/ext-services/index.js.map +1 -0
- package/lib/interfaces/ext-services/model-service.d.ts +89 -0
- package/lib/interfaces/ext-services/model-service.js +3 -0
- package/lib/interfaces/ext-services/model-service.js.map +1 -0
- package/lib/interfaces/ext-services/panel-view-registry.d.ts +21 -0
- package/lib/interfaces/ext-services/panel-view-registry.js +3 -0
- package/lib/interfaces/ext-services/panel-view-registry.js.map +1 -0
- package/lib/interfaces/ext-services/settings-service.d.ts +18 -0
- package/lib/interfaces/ext-services/settings-service.js +3 -0
- package/lib/interfaces/ext-services/settings-service.js.map +1 -0
- package/lib/interfaces/ext-services/view-service.d.ts +65 -0
- package/lib/interfaces/ext-services/view-service.js +4 -0
- package/lib/interfaces/ext-services/view-service.js.map +1 -0
- package/lib/interfaces/ext-services/viewer-service.d.ts +125 -0
- package/lib/interfaces/ext-services/viewer-service.js +5 -0
- package/lib/interfaces/ext-services/viewer-service.js.map +1 -0
- package/lib/interfaces/extension-manifest.d.ts +8 -0
- package/lib/interfaces/extension-manifest.js +3 -0
- package/lib/interfaces/extension-manifest.js.map +1 -0
- package/lib/interfaces/extension.d.ts +72 -0
- package/lib/interfaces/extension.js +3 -0
- package/lib/interfaces/extension.js.map +1 -0
- package/lib/interfaces/generated-models.d.ts +3716 -0
- package/lib/interfaces/generated-models.js +648 -0
- package/lib/interfaces/generated-models.js.map +1 -0
- package/lib/interfaces/graphql.d.ts +17 -0
- package/lib/interfaces/graphql.js +5 -0
- package/lib/interfaces/graphql.js.map +1 -0
- package/lib/interfaces/index.d.ts +21 -0
- package/lib/interfaces/index.js +38 -0
- package/lib/interfaces/index.js.map +1 -0
- package/lib/interfaces/languages-types.d.ts +65 -0
- package/lib/interfaces/languages-types.js +3 -0
- package/lib/interfaces/languages-types.js.map +1 -0
- package/lib/interfaces/model.d.ts +51 -0
- package/lib/interfaces/model.js +9 -0
- package/lib/interfaces/model.js.map +1 -0
- package/lib/interfaces/plain-types.d.ts +4 -0
- package/lib/interfaces/plain-types.js +6 -0
- package/lib/interfaces/plain-types.js.map +1 -0
- package/lib/interfaces/plainTypes.d.ts +68 -0
- package/lib/interfaces/plainTypes.js +3 -0
- package/lib/interfaces/plainTypes.js.map +1 -0
- package/lib/interfaces/platform-context.d.ts +82 -0
- package/lib/interfaces/platform-context.js +3 -0
- package/lib/interfaces/platform-context.js.map +1 -0
- package/lib/interfaces/react-props/action-item.d.ts +20 -0
- package/lib/interfaces/react-props/action-item.js +3 -0
- package/lib/interfaces/react-props/action-item.js.map +1 -0
- package/lib/interfaces/react-props/extension-controller.d.ts +11 -0
- package/lib/interfaces/react-props/extension-controller.js +3 -0
- package/lib/interfaces/react-props/extension-controller.js.map +1 -0
- package/lib/interfaces/react-props/index.d.ts +3 -0
- package/lib/interfaces/react-props/index.js +20 -0
- package/lib/interfaces/react-props/index.js.map +1 -0
- package/lib/interfaces/react-props/platform-context.d.ts +7 -0
- package/lib/interfaces/react-props/platform-context.js +3 -0
- package/lib/interfaces/react-props/platform-context.js.map +1 -0
- package/lib/interfaces/registry-extension.d.ts +21 -0
- package/lib/interfaces/registry-extension.js +3 -0
- package/lib/interfaces/registry-extension.js.map +1 -0
- package/lib/interfaces/settings.d.ts +51 -0
- package/lib/interfaces/settings.js +3 -0
- package/lib/interfaces/settings.js.map +1 -0
- package/lib/interfaces/text-document.d.ts +57 -0
- package/lib/interfaces/text-document.js +119 -0
- package/lib/interfaces/text-document.js.map +1 -0
- package/lib/interfaces/webview/index.d.ts +3 -0
- package/lib/interfaces/webview/index.js +20 -0
- package/lib/interfaces/webview/index.js.map +1 -0
- package/lib/interfaces/webview/webview-manager-service.d.ts +22 -0
- package/lib/interfaces/webview/webview-manager-service.js +3 -0
- package/lib/interfaces/webview/webview-manager-service.js.map +1 -0
- package/lib/interfaces/webview/webview-port-mapping.d.ts +4 -0
- package/lib/interfaces/webview/webview-port-mapping.js +3 -0
- package/lib/interfaces/webview/webview-port-mapping.js.map +1 -0
- package/lib/interfaces/webview/webview.d.ts +99 -0
- package/lib/interfaces/webview/webview.js +9 -0
- package/lib/interfaces/webview/webview.js.map +1 -0
- package/lib/main.d.ts +0 -0
- package/lib/main.js +3 -0
- package/lib/main.js.map +1 -0
- package/lib/protocol/client.protocol.d.ts +99 -0
- package/lib/protocol/client.protocol.js +8 -0
- package/lib/protocol/client.protocol.js.map +1 -0
- package/lib/protocol/common.protocol.d.ts +289 -0
- package/lib/protocol/common.protocol.js +68 -0
- package/lib/protocol/common.protocol.js.map +1 -0
- package/lib/protocol/editor-missing-types.d.ts +87 -0
- package/lib/protocol/editor-missing-types.js +10 -0
- package/lib/protocol/editor-missing-types.js.map +1 -0
- package/lib/protocol/index.d.ts +6 -0
- package/lib/protocol/index.js +24 -0
- package/lib/protocol/index.js.map +1 -0
- package/lib/protocol/proxy-identifier.d.ts +51 -0
- package/lib/protocol/proxy-identifier.js +59 -0
- package/lib/protocol/proxy-identifier.js.map +1 -0
- package/lib/protocol/rpc-logger.d.ts +8 -0
- package/lib/protocol/rpc-logger.js +60 -0
- package/lib/protocol/rpc-logger.js.map +1 -0
- package/lib/protocol/rpc-protocol.d.ts +148 -0
- package/lib/protocol/rpc-protocol.js +750 -0
- package/lib/protocol/rpc-protocol.js.map +1 -0
- package/lib/protocol/rpc-protocol.test.d.ts +1 -0
- package/lib/protocol/rpc-protocol.test.js +171 -0
- package/lib/protocol/rpc-protocol.test.js.map +1 -0
- package/lib/protocol/server.protocol-bk.d.ts +0 -0
- package/lib/protocol/server.protocol-bk.js +719 -0
- package/lib/protocol/server.protocol-bk.js.map +1 -0
- package/lib/protocol/server.protocol.d.ts +91 -0
- package/lib/protocol/server.protocol.js +31 -0
- package/lib/protocol/server.protocol.js.map +1 -0
- package/lib/protocol/shared/editor.d.ts +4 -0
- package/lib/protocol/shared/editor.js +28 -0
- package/lib/protocol/shared/editor.js.map +1 -0
- package/lib/protocol/shared/tasks.d.ts +104 -0
- package/lib/protocol/shared/tasks.js +4 -0
- package/lib/protocol/shared/tasks.js.map +1 -0
- package/lib/protocol/temporary-types.d.ts +198 -0
- package/lib/protocol/temporary-types.js +30 -0
- package/lib/protocol/temporary-types.js.map +1 -0
- package/lib/protocol/utils/index.d.ts +1 -0
- package/lib/protocol/utils/index.js +18 -0
- package/lib/protocol/utils/index.js.map +1 -0
- package/lib/protocol/utils/lazy-promise.d.ts +18 -0
- package/lib/protocol/utils/lazy-promise.js +69 -0
- package/lib/protocol/utils/lazy-promise.js.map +1 -0
- package/lib/utils/errors.d.ts +6 -0
- package/lib/utils/errors.js +19 -0
- package/lib/utils/errors.js.map +1 -0
- package/lib/utils/extensions.d.ts +9 -0
- package/lib/utils/extensions.js +25 -0
- package/lib/utils/extensions.js.map +1 -0
- package/lib/utils/helper.test.d.ts +9 -0
- package/lib/utils/helper.test.js +15 -0
- package/lib/utils/helper.test.js.map +1 -0
- package/lib/utils/index.d.ts +7 -0
- package/lib/utils/index.js +25 -0
- package/lib/utils/index.js.map +1 -0
- package/lib/utils/paths-util.d.ts +27 -0
- package/lib/utils/paths-util.js +127 -0
- package/lib/utils/paths-util.js.map +1 -0
- package/lib/utils/rxjs/combineLatestOrDefault.d.ts +28 -0
- package/lib/utils/rxjs/combineLatestOrDefault.js +111 -0
- package/lib/utils/rxjs/combineLatestOrDefault.js.map +1 -0
- package/lib/utils/rxjs/combineLatestOrDefault.test.d.ts +1 -0
- package/lib/utils/rxjs/combineLatestOrDefault.test.js +52 -0
- package/lib/utils/rxjs/combineLatestOrDefault.test.js.map +1 -0
- package/lib/utils/rxjs/index.d.ts +1 -0
- package/lib/utils/rxjs/index.js +18 -0
- package/lib/utils/rxjs/index.js.map +1 -0
- package/lib/utils/util.d.ts +19 -0
- package/lib/utils/util.js +57 -0
- package/lib/utils/util.js.map +1 -0
- package/lib/worker-lib/MessageTypes.d.ts +5 -0
- package/lib/worker-lib/MessageTypes.js +9 -0
- package/lib/worker-lib/MessageTypes.js.map +1 -0
- package/lib/worker-lib/index.d.ts +2 -0
- package/lib/worker-lib/index.js +19 -0
- package/lib/worker-lib/index.js.map +1 -0
- package/lib/worker-lib/webWorkerLink.d.ts +12 -0
- package/lib/worker-lib/webWorkerLink.js +96 -0
- package/lib/worker-lib/webWorkerLink.js.map +1 -0
- package/lib/worker-lib/workerUtils.d.ts +11 -0
- package/lib/worker-lib/workerUtils.js +178 -0
- package/lib/worker-lib/workerUtils.js.map +1 -0
- package/package.json +60 -0
|
@@ -0,0 +1,239 @@
|
|
|
1
|
+
// import { logger as baseLogger } from '@cdm-logger/client';
|
|
2
|
+
// import { Message } from '../messages'
|
|
3
|
+
// import { MessageTransports } from '../connection'
|
|
4
|
+
// import {
|
|
5
|
+
// AbstractMessageReader, AbstractMessageWriter,
|
|
6
|
+
// DataCallback, MessageReader, MessageWriter
|
|
7
|
+
// } from '../transport';
|
|
8
|
+
// // import { MessageBuffer, MessageIO } from '../../../protocol/browser-message-io';
|
|
9
|
+
// import { MessageType, MessageBuffer, MessageIO } from '../../../protocol/rpc-protocol';
|
|
10
|
+
// const logger = baseLogger.child({ 'childName': 'webWorker' });
|
|
11
|
+
// interface WorkerEventMap {
|
|
12
|
+
// error: any
|
|
13
|
+
// message: MessageEvent
|
|
14
|
+
// }
|
|
15
|
+
// interface Worker {
|
|
16
|
+
// postMessage(message: any): void
|
|
17
|
+
// addEventListener<K extends keyof WorkerEventMap>(
|
|
18
|
+
// type: K,
|
|
19
|
+
// listener: (this: Worker, ev: WorkerEventMap[K]) => any
|
|
20
|
+
// ): void
|
|
21
|
+
// close?(): void
|
|
22
|
+
// terminate?(): void
|
|
23
|
+
// }
|
|
24
|
+
// class MergedMessageReader extends AbstractMessageReader implements MessageReader {
|
|
25
|
+
// private pending: Message[] = []
|
|
26
|
+
// private callback: DataCallback | null = null
|
|
27
|
+
// public static deserialize(buff: MessageBuffer, type: any, req: any) {
|
|
28
|
+
// const id = buff.readUInt8();
|
|
29
|
+
// const method = buff.readShortString();
|
|
30
|
+
// try {
|
|
31
|
+
// const args = buff.readLongString();
|
|
32
|
+
// const params = JSON.parse(args) || [];
|
|
33
|
+
// return {
|
|
34
|
+
// id,
|
|
35
|
+
// req,
|
|
36
|
+
// type,
|
|
37
|
+
// method: method,
|
|
38
|
+
// params: params,
|
|
39
|
+
// jsonrpc: "2.0",
|
|
40
|
+
// };
|
|
41
|
+
// } catch (e) {
|
|
42
|
+
// return {
|
|
43
|
+
// id,
|
|
44
|
+
// req,
|
|
45
|
+
// type,
|
|
46
|
+
// params: [],
|
|
47
|
+
// method: method,
|
|
48
|
+
// jsonrpc: "2.0",
|
|
49
|
+
// };
|
|
50
|
+
// }
|
|
51
|
+
// }
|
|
52
|
+
// private _onmessage = (decode = false) => (e) => {
|
|
53
|
+
// try {
|
|
54
|
+
// let msg = decode
|
|
55
|
+
// ? this._receiveOneMessage(e.data as Buffer)
|
|
56
|
+
// : e;
|
|
57
|
+
// if (msg) {
|
|
58
|
+
// this.processMessage(msg);
|
|
59
|
+
// }
|
|
60
|
+
// } catch (err) {
|
|
61
|
+
// this.fireError(err)
|
|
62
|
+
// }
|
|
63
|
+
// }
|
|
64
|
+
// private _onerror = (err) => {
|
|
65
|
+
// logger.info(err, '(addEventListener error) e: ');
|
|
66
|
+
// this.fireError(err)
|
|
67
|
+
// if (err.cancelable) {
|
|
68
|
+
// err.preventDefault()
|
|
69
|
+
// } else {
|
|
70
|
+
// terminateWorker(this.worker);
|
|
71
|
+
// terminateSocket(this.socket);
|
|
72
|
+
// this.fireClose()
|
|
73
|
+
// }
|
|
74
|
+
// }
|
|
75
|
+
// constructor(
|
|
76
|
+
// private worker: Worker,
|
|
77
|
+
// private socket: WebSocket,
|
|
78
|
+
// ) {
|
|
79
|
+
// super();
|
|
80
|
+
// logger.info(socket, '(MergedMessageReader) merged: ');
|
|
81
|
+
// // Read messages from ws
|
|
82
|
+
// socket.onerror = this._onerror;
|
|
83
|
+
// socket.onmessage = this._onmessage(true);
|
|
84
|
+
// // Read messages from webworker
|
|
85
|
+
// worker!.addEventListener('error', this._onerror);
|
|
86
|
+
// worker!.addEventListener('message', this._onmessage());
|
|
87
|
+
// }
|
|
88
|
+
// private _receiveOneMessage(rawmsg: Buffer): any {
|
|
89
|
+
// const msgLength = rawmsg.length;
|
|
90
|
+
// const buff = MessageBuffer.read(new DataView(rawmsg), 0);
|
|
91
|
+
// const messageType = <MessageType>buff.readUInt8();
|
|
92
|
+
// const req = buff.readUInt32();
|
|
93
|
+
// console.log({ messageType, req });
|
|
94
|
+
// switch (messageType) {
|
|
95
|
+
// case MessageType.RequestJSONArgs:
|
|
96
|
+
// case MessageType.RequestJSONArgsWithCancellation: {
|
|
97
|
+
// return MergedMessageReader.deserialize(buff, messageType, req);
|
|
98
|
+
// }
|
|
99
|
+
// case MessageType.RequestMixedArgs:
|
|
100
|
+
// case MessageType.RequestMixedArgsWithCancellation: {
|
|
101
|
+
// let { rpcId, method, args } = MessageIO.deserializeRequestMixedArgs(buff);
|
|
102
|
+
// // this._receiveRequest(msgLength, req, rpcId, method, args, (messageType === MessageType.RequestMixedArgsWithCancellation));
|
|
103
|
+
// break;
|
|
104
|
+
// }
|
|
105
|
+
// case MessageType.Acknowledged: {
|
|
106
|
+
// // this._onDidReceiveAcknowledge(req);
|
|
107
|
+
// break;
|
|
108
|
+
// }
|
|
109
|
+
// case MessageType.Cancel: {
|
|
110
|
+
// // this._receiveCancel(msgLength, req);
|
|
111
|
+
// break;
|
|
112
|
+
// }
|
|
113
|
+
// case MessageType.ReplyOKEmpty: {
|
|
114
|
+
// return this._receiveReply(msgLength, req, undefined);
|
|
115
|
+
// }
|
|
116
|
+
// case MessageType.ReplyOKJSON: {
|
|
117
|
+
// let value = MessageIO.deserializeReplyOKJSON(buff);
|
|
118
|
+
// return this._receiveReply(msgLength, req, value);
|
|
119
|
+
// }
|
|
120
|
+
// case MessageType.ReplyOKBuffer: {
|
|
121
|
+
// let value = MessageIO.deserializeReplyOKBuffer(buff);
|
|
122
|
+
// this._receiveReply(msgLength, req, value);
|
|
123
|
+
// break;
|
|
124
|
+
// }
|
|
125
|
+
// case MessageType.ReplyErrError: {
|
|
126
|
+
// let err = MessageIO.deserializeReplyErrError(buff);
|
|
127
|
+
// this._receiveReplyErr(msgLength, req, err);
|
|
128
|
+
// break;
|
|
129
|
+
// }
|
|
130
|
+
// case MessageType.ReplyErrEmpty: {
|
|
131
|
+
// this._receiveReplyErr(msgLength, req, undefined);
|
|
132
|
+
// break;
|
|
133
|
+
// }
|
|
134
|
+
// }
|
|
135
|
+
// }
|
|
136
|
+
// private _receiveReplyErr(msgLength: number, req: number, value: any): any {
|
|
137
|
+
// let err: Error | null = null;
|
|
138
|
+
// if (value && value.$isError) {
|
|
139
|
+
// err = new Error();
|
|
140
|
+
// err.name = value.name;
|
|
141
|
+
// err.message = value.message;
|
|
142
|
+
// err.stack = value.stack;
|
|
143
|
+
// }
|
|
144
|
+
// return { req, id: null, error: err, jsonrpc: "2.0", complete: true };
|
|
145
|
+
// }
|
|
146
|
+
// private _receiveReply(msgLength: number, req: number, result: any): any {
|
|
147
|
+
// return { req, id: 0, result, jsonrpc: "2.0", complete: true };
|
|
148
|
+
// }
|
|
149
|
+
// private processMessage(e: MessageEvent): void {
|
|
150
|
+
// logger.info(e, '(processMessage) e: ');
|
|
151
|
+
// const message: Message = e.data
|
|
152
|
+
// if (this.callback) {
|
|
153
|
+
// this.callback(message)
|
|
154
|
+
// } else {
|
|
155
|
+
// this.pending.push(message)
|
|
156
|
+
// }
|
|
157
|
+
// }
|
|
158
|
+
// public listen(callback: DataCallback): void {
|
|
159
|
+
// if (this.callback) {
|
|
160
|
+
// throw new Error('callback is already set')
|
|
161
|
+
// }
|
|
162
|
+
// this.callback = callback
|
|
163
|
+
// while (this.pending.length !== 0) {
|
|
164
|
+
// callback(this.pending.pop()!)
|
|
165
|
+
// }
|
|
166
|
+
// }
|
|
167
|
+
// public unsubscribe(): void {
|
|
168
|
+
// super.unsubscribe()
|
|
169
|
+
// this.callback = null
|
|
170
|
+
// terminateWorker(this.worker);
|
|
171
|
+
// terminateSocket(this.socket);
|
|
172
|
+
// }
|
|
173
|
+
// }
|
|
174
|
+
// class MergedMessageWriter extends AbstractMessageWriter implements MessageWriter {
|
|
175
|
+
// private errorCount = 0
|
|
176
|
+
// constructor(
|
|
177
|
+
// private worker: any,
|
|
178
|
+
// private socket: WebSocket,
|
|
179
|
+
// ) { super(); }
|
|
180
|
+
// public write(message: Message | any, toSocket: boolean = false): void {
|
|
181
|
+
// try {
|
|
182
|
+
// if (toSocket) {
|
|
183
|
+
// const [rpcId, method] = message.method.split('/');
|
|
184
|
+
// this.socket.send(
|
|
185
|
+
// MessageIO.serializeRequest(message.id, rpcId, method, message.params, false, null)
|
|
186
|
+
// )
|
|
187
|
+
// } else {
|
|
188
|
+
// this.worker.postMessage(message)
|
|
189
|
+
// }
|
|
190
|
+
// } catch (error) {
|
|
191
|
+
// this.fireError(error, message, ++this.errorCount)
|
|
192
|
+
// }
|
|
193
|
+
// }
|
|
194
|
+
// public unsubscribe(): void {
|
|
195
|
+
// super.unsubscribe();
|
|
196
|
+
// terminateWorker(this.worker);
|
|
197
|
+
// terminateSocket(this.socket);
|
|
198
|
+
// }
|
|
199
|
+
// }
|
|
200
|
+
// function terminateSocket(socket: WebSocket): void {
|
|
201
|
+
// if (socket.close) {
|
|
202
|
+
// socket.close() // in worker scope
|
|
203
|
+
// }
|
|
204
|
+
// }
|
|
205
|
+
// function terminateWorker(worker: Worker): void {
|
|
206
|
+
// if (worker.terminate) {
|
|
207
|
+
// worker.terminate() // in window (worker parent) scope
|
|
208
|
+
// } else if (worker.close) {
|
|
209
|
+
// worker.close() // in worker scope
|
|
210
|
+
// }
|
|
211
|
+
// }
|
|
212
|
+
// /**
|
|
213
|
+
// * Creates JSON-RPC2 message transports for the Web Worker message communication interface.
|
|
214
|
+
// *
|
|
215
|
+
// * @param worker The Worker to communicate with (e.g., created with `new Worker(...)`), or the global scope (i.e.,
|
|
216
|
+
// * `self`) if the current execution context is in a Worker. Defaults to the global scope.
|
|
217
|
+
// */
|
|
218
|
+
// export function createMergedMessageTransports(worker: Worker = globalWorkerScope(), socket: WebSocket): MessageTransports {
|
|
219
|
+
// console.log('createMergedMessageTransports: ', { worker, socket });
|
|
220
|
+
// const reader = new MergedMessageReader(worker, socket);
|
|
221
|
+
// const writer = new MergedMessageWriter(worker, socket);
|
|
222
|
+
// reader.onError(err => console.error(err));
|
|
223
|
+
// writer.onError(err => console.error(err));
|
|
224
|
+
// return { reader, writer };
|
|
225
|
+
// }
|
|
226
|
+
// function globalWorkerScope(): Worker {
|
|
227
|
+
// var globalObject =
|
|
228
|
+
// typeof window !== 'undefined' ? window :
|
|
229
|
+
// typeof self !== 'undefined' ? self :
|
|
230
|
+
// typeof global !== 'undefined' ? global :
|
|
231
|
+
// {};
|
|
232
|
+
// const worker: Worker = globalObject as any
|
|
233
|
+
// // tslint:disable-next-line no-unbound-method
|
|
234
|
+
// if (!worker.postMessage || 'document' in worker) {
|
|
235
|
+
// throw new Error('global scope is not a Worker')
|
|
236
|
+
// }
|
|
237
|
+
// return worker
|
|
238
|
+
// }
|
|
239
|
+
//# sourceMappingURL=merged.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"merged.js","sourceRoot":"","sources":["../../../../src/connections/jsonrpc2/transports/merged.ts"],"names":[],"mappings":"AAAA,6DAA6D;AAE7D,wCAAwC;AACxC,oDAAoD;AACpD,WAAW;AACX,oDAAoD;AACpD,iDAAiD;AACjD,yBAAyB;AACzB,sFAAsF;AAEtF,2FAA2F;AAG3F,iEAAiE;AAGjE,6BAA6B;AAC7B,iBAAiB;AACjB,4BAA4B;AAC5B,IAAI;AAEJ,qBAAqB;AACrB,sCAAsC;AACtC,wDAAwD;AACxD,mBAAmB;AACnB,iEAAiE;AACjE,cAAc;AACd,qBAAqB;AACrB,yBAAyB;AACzB,IAAI;AAEJ,qFAAqF;AACrF,sCAAsC;AACtC,mDAAmD;AAEnD,4EAA4E;AAC5E,uCAAuC;AACvC,iDAAiD;AAEjD,gBA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AA0B;AAC1B,4CAA4C;AAC5C,QAAQ;AACR,IAAI;AAEJ,mDAAmD;AACnD,8BAA8B;AAC9B,gEAAgE;AAChE,iCAAiC;AACjC,4CAA4C;AAC5C,QAAQ;AACR,IAAI;AAEJ,MAAM;AACN,8FAA8F;AAC9F,KAAK;AACL,qHAAqH;AACrH,0GAA0G;AAC1G,MAAM;AACN,8HAA8H;AAC9H,0EAA0E;AAE1E,8DAA8D;AAC9D,8DAA8D;AAE9D,iDAAiD;AACjD,iDAAiD;AAEjD,iCAAiC;AACjC,IAAI;AAEJ,yCAAyC;AACzC,yBAAyB;AACzB,mDAAmD;AACnD,mDAAmD;AACnD,2DAA2D;AAC3D,0BAA0B;AAE1B,iDAAiD;AACjD,oDAAoD;AACpD,yDAAyD;AACzD,0DAA0D;AAC1D,QAAQ;AACR,oBAAoB;AACpB,IAAI"}
|
|
File without changes
|
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
// import { logger as baseLogger } from '@cdm-logger/client';
|
|
2
|
+
// import { Message } from '../messages'
|
|
3
|
+
// import { MessageTransports } from '../connection'
|
|
4
|
+
// import {
|
|
5
|
+
// AbstractMessageReader, AbstractMessageWriter,
|
|
6
|
+
// DataCallback, MessageReader, MessageWriter
|
|
7
|
+
// } from '../transport'
|
|
8
|
+
// import { IMessagePassingProtocol } from '@vscode-alt/monaco-editor/esm/vs/base/parts/ipc/node/ipc';
|
|
9
|
+
// import { ReplaySubject, Subject } from 'rxjs';
|
|
10
|
+
// import { Event, Emitter, filterEvent } from '@vscode-alt/monaco-editor/esm/vs/base/common/event';
|
|
11
|
+
// import { MessageBuffer as BrowserMessageBuffer, MessageIO as BrowserMessageIO } from '../../../protocol/browser-message-io';
|
|
12
|
+
// import { RPCProtocol } from '../../../protocol/rpc-protocol';
|
|
13
|
+
// const logger = baseLogger.child({ 'childName': 'webWorker' });
|
|
14
|
+
// interface MessageEvent {
|
|
15
|
+
// data: any
|
|
16
|
+
// }
|
|
17
|
+
// interface WorkerEventMap {
|
|
18
|
+
// error: any
|
|
19
|
+
// message: MessageEvent
|
|
20
|
+
// }
|
|
21
|
+
// class WebSocketMessageReader extends AbstractMessageReader implements MessageReader {
|
|
22
|
+
// private pending: Message[] = []
|
|
23
|
+
// private callback: DataCallback | null = null
|
|
24
|
+
// constructor(private worker: RPCProtocol) {
|
|
25
|
+
// super();
|
|
26
|
+
// worker.
|
|
27
|
+
// }
|
|
28
|
+
// private processMessage(e: MessageEvent): void {
|
|
29
|
+
// logger.info(e, '(processMessage) e: ');
|
|
30
|
+
// const message: Message = e.data
|
|
31
|
+
// if (this.callback) {
|
|
32
|
+
// this.callback(message)
|
|
33
|
+
// } else {
|
|
34
|
+
// this.pending.push(message)
|
|
35
|
+
// }
|
|
36
|
+
// }
|
|
37
|
+
// public listen(callback: DataCallback): void {
|
|
38
|
+
// if (this.callback) {
|
|
39
|
+
// throw new Error('callback is already set')
|
|
40
|
+
// }
|
|
41
|
+
// this.callback = callback
|
|
42
|
+
// while (this.pending.length !== 0) {
|
|
43
|
+
// callback(this.pending.pop()!)
|
|
44
|
+
// }
|
|
45
|
+
// }
|
|
46
|
+
// public unsubscribe(): void {
|
|
47
|
+
// super.unsubscribe()
|
|
48
|
+
// this.callback = null
|
|
49
|
+
// closeIfOpen(this.socket);
|
|
50
|
+
// }
|
|
51
|
+
// }
|
|
52
|
+
// function closeIfOpen(socket: WebSocket): void {
|
|
53
|
+
// if (socket.readyState === socket.OPEN) {
|
|
54
|
+
// // 1000 means normal closure. See
|
|
55
|
+
// // https://www.iana.org/assignments/websocket/websocket.xml#close-code-number.
|
|
56
|
+
// socket.close(1000);
|
|
57
|
+
// }
|
|
58
|
+
// }
|
|
59
|
+
// export class BrowserWebSocket implements IMessagePassingProtocol {
|
|
60
|
+
// private _$queue: Subject<any> = new ReplaySubject<any>();
|
|
61
|
+
// private _onMessage = new Emitter<ArrayBuffer>();
|
|
62
|
+
// public onMessage(event, fn) {
|
|
63
|
+
// return this._onMessage.event(event, fn);
|
|
64
|
+
// }
|
|
65
|
+
// public connect(socket: WebSocket) {
|
|
66
|
+
// const subscription = this._$queue.subscribe(msg => socket.send(msg));
|
|
67
|
+
// socket.onmessage = (msg: MessageEvent) => {
|
|
68
|
+
// // receives data as ArrayBuffer
|
|
69
|
+
// this._onMessage.fire(msg.data as ArrayBuffer);
|
|
70
|
+
// };
|
|
71
|
+
// socket.onclose = event => {
|
|
72
|
+
// subscription.unsubscribe();
|
|
73
|
+
// };
|
|
74
|
+
// }
|
|
75
|
+
// public send(msg: Buffer) {
|
|
76
|
+
// // converts to ArrayBuffer and sends data
|
|
77
|
+
// this._$queue.next(msg.buffer.slice(msg.byteOffset, msg.byteOffset + msg.byteLength));
|
|
78
|
+
// }
|
|
79
|
+
// }
|
|
80
|
+
// class WebSocketMessageWriter extends AbstractMessageWriter implements MessageWriter {
|
|
81
|
+
// private errorCount = 0
|
|
82
|
+
// constructor(private worker: RPCProtocol) {
|
|
83
|
+
// super()
|
|
84
|
+
// }
|
|
85
|
+
// public write(message): void {
|
|
86
|
+
// try {
|
|
87
|
+
// const [ rpcId, method ] = message.method.split('/');
|
|
88
|
+
// const cl = this.worker.getProxy(rpcId);
|
|
89
|
+
// cl[method](message.params);
|
|
90
|
+
// } catch (error) {
|
|
91
|
+
// this.fireError(error, message, ++this.errorCount)
|
|
92
|
+
// }
|
|
93
|
+
// }
|
|
94
|
+
// public unsubscribe(): void {
|
|
95
|
+
// super.unsubscribe()
|
|
96
|
+
// // terminateWorker(this.worker)
|
|
97
|
+
// }
|
|
98
|
+
// }
|
|
99
|
+
// function terminateWorker(worker: WebSocket): void {
|
|
100
|
+
// if (worker.close) {
|
|
101
|
+
// worker.close() // in worker scope
|
|
102
|
+
// }
|
|
103
|
+
// }
|
|
104
|
+
// /**
|
|
105
|
+
// * Creates JSON-RPC2 message transports for the Web Worker message communication interface.
|
|
106
|
+
// *
|
|
107
|
+
// * @param worker The Worker to communicate with (e.g., created with `new Worker(...)`), or the global scope (i.e.,
|
|
108
|
+
// * `self`) if the current execution context is in a Worker. Defaults to the global scope.
|
|
109
|
+
// */
|
|
110
|
+
// export function createWebSocketMessageTransports(socket: WebSocket): MessageTransports {
|
|
111
|
+
// // const reader = new WebSocketMessageReader(worker);
|
|
112
|
+
// // const writer = new WebSocketMessageWriter(worker);
|
|
113
|
+
// let b_protocol = new BrowserWebSocket();
|
|
114
|
+
// b_protocol.connect(socket);
|
|
115
|
+
// let B = new RPCProtocol(b_protocol, null, null, BrowserMessageIO, BrowserMessageBuffer, (buffer) => new DataView(buffer));
|
|
116
|
+
// const writer = new WebSocketMessageWriter(B);
|
|
117
|
+
// reader.onError(err => console.error(err));
|
|
118
|
+
// writer.onError(err => console.error(err));
|
|
119
|
+
// return {
|
|
120
|
+
// reader,
|
|
121
|
+
// writer,
|
|
122
|
+
// };
|
|
123
|
+
// }
|
|
124
|
+
// // Add impl for connection from webworker
|
|
125
|
+
// function globalWorkerScope(): Worker {
|
|
126
|
+
// var globalObject =
|
|
127
|
+
// typeof window !== 'undefined' ? window :
|
|
128
|
+
// typeof self !== 'undefined' ? self :
|
|
129
|
+
// typeof global !== 'undefined' ? global :
|
|
130
|
+
// {};
|
|
131
|
+
// const worker: Worker = globalObject as any
|
|
132
|
+
// // tslint:disable-next-line no-unbound-method
|
|
133
|
+
// if (!worker.postMessage || 'document' in worker) {
|
|
134
|
+
// throw new Error('global scope is not a Worker')
|
|
135
|
+
// }
|
|
136
|
+
// return worker
|
|
137
|
+
// }
|
|
138
|
+
//# sourceMappingURL=webSocket.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"webSocket.js","sourceRoot":"","sources":["../../../../src/connections/jsonrpc2/transports/webSocket.ts"],"names":[],"mappings":"AAAA,6DAA6D;AAE7D,wCAAwC;AACxC,oDAAoD;AACpD,WAAW;AACX,oDAAoD;AACpD,iDAAiD;AACjD,wBAAwB;AACxB,sGAAsG;AACtG,iDAAiD;AACjD,oGAAoG;AACpG,+HAA+H;AAC/H,gE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,sDAAsD;AACtD,0BAA0B;AAC1B,4CAA4C;AAC5C,QAAQ;AACR,IAAI;AAEJ,MAAM;AACN,8FAA8F;AAC9F,KAAK;AACL,qHAAqH;AACrH,0GAA0G;AAC1G,MAAM;AACN,2FAA2F;AAC3F,4DAA4D;AAC5D,4DAA4D;AAC5D,+CAA+C;AAC/C,kCAAkC;AAClC,iIAAiI;AAEjI,oDAAoD;AACpD,iDAAiD;AACjD,iDAAiD;AAEjD,eAAe;AACf,kBAAkB;AAClB,kBAAkB;AAClB,SAAS;AACT,IAAI;AAEJ,4CAA4C;AAC5C,yCAAyC;AACzC,yBAAyB;AACzB,mDAAmD;AACnD,mDAAmD;AACnD,2DAA2D;AAC3D,0BAA0B;AAE1B,iDAAiD;AACjD,oDAAoD;AACpD,yDAAyD;AACzD,0DAA0D;AAC1D,QAAQ;AACR,oBAAoB;AACpB,IAAI"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { MessageTransports } from '../connection';
|
|
2
|
+
interface MessageEvent {
|
|
3
|
+
data: any;
|
|
4
|
+
}
|
|
5
|
+
interface WorkerEventMap {
|
|
6
|
+
error: any;
|
|
7
|
+
message: MessageEvent;
|
|
8
|
+
}
|
|
9
|
+
interface Worker {
|
|
10
|
+
postMessage(message: any): void;
|
|
11
|
+
addEventListener<K extends keyof WorkerEventMap>(type: K, listener: (this: Worker, ev: WorkerEventMap[K]) => any): void;
|
|
12
|
+
close?(): void;
|
|
13
|
+
terminate?(): void;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Creates JSON-RPC2 message transports for the Web Worker message communication interface.
|
|
17
|
+
*
|
|
18
|
+
* @param worker The Worker to communicate with (e.g., created with `new Worker(...)`), or the global scope (i.e.,
|
|
19
|
+
* `self`) if the current execution context is in a Worker. Defaults to the global scope.
|
|
20
|
+
*/
|
|
21
|
+
export declare function createWebWorkerMessageTransports(worker?: Worker): MessageTransports;
|
|
22
|
+
export {};
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.createWebWorkerMessageTransports = void 0;
|
|
4
|
+
const transport_1 = require("../transport");
|
|
5
|
+
class WebWorkerMessageReader extends transport_1.AbstractMessageReader {
|
|
6
|
+
constructor(worker) {
|
|
7
|
+
super();
|
|
8
|
+
this.worker = worker;
|
|
9
|
+
this.pending = [];
|
|
10
|
+
this.callback = null;
|
|
11
|
+
worker.addEventListener('message', (e) => {
|
|
12
|
+
try {
|
|
13
|
+
this.processMessage(e);
|
|
14
|
+
}
|
|
15
|
+
catch (err) {
|
|
16
|
+
this.fireError(err);
|
|
17
|
+
}
|
|
18
|
+
});
|
|
19
|
+
worker.addEventListener('error', (err) => {
|
|
20
|
+
this.fireError(err);
|
|
21
|
+
if (err.cancelable) {
|
|
22
|
+
err.preventDefault();
|
|
23
|
+
}
|
|
24
|
+
else {
|
|
25
|
+
terminateWorker(worker);
|
|
26
|
+
this.fireClose();
|
|
27
|
+
}
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
processMessage(e) {
|
|
31
|
+
const message = e.data;
|
|
32
|
+
if (this.callback) {
|
|
33
|
+
this.callback(message);
|
|
34
|
+
}
|
|
35
|
+
else {
|
|
36
|
+
this.pending.push(message);
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
listen(callback) {
|
|
40
|
+
if (this.callback) {
|
|
41
|
+
throw new Error('callback is already set');
|
|
42
|
+
}
|
|
43
|
+
this.callback = callback;
|
|
44
|
+
while (this.pending.length !== 0) {
|
|
45
|
+
callback(this.pending.pop());
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
unsubscribe() {
|
|
49
|
+
super.unsubscribe();
|
|
50
|
+
this.callback = null;
|
|
51
|
+
terminateWorker(this.worker);
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
class WebWorkerMessageWriter extends transport_1.AbstractMessageWriter {
|
|
55
|
+
constructor(worker) {
|
|
56
|
+
super();
|
|
57
|
+
this.worker = worker;
|
|
58
|
+
this.errorCount = 0;
|
|
59
|
+
}
|
|
60
|
+
write(message) {
|
|
61
|
+
try {
|
|
62
|
+
this.worker.postMessage(message);
|
|
63
|
+
}
|
|
64
|
+
catch (error) {
|
|
65
|
+
this.fireError(error, message, ++this.errorCount);
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
unsubscribe() {
|
|
69
|
+
super.unsubscribe();
|
|
70
|
+
terminateWorker(this.worker);
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
function terminateWorker(worker) {
|
|
74
|
+
if (worker.terminate) {
|
|
75
|
+
worker.terminate(); // in window (worker parent) scope
|
|
76
|
+
}
|
|
77
|
+
else if (worker.close) {
|
|
78
|
+
worker.close(); // in worker scope
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* Creates JSON-RPC2 message transports for the Web Worker message communication interface.
|
|
83
|
+
*
|
|
84
|
+
* @param worker The Worker to communicate with (e.g., created with `new Worker(...)`), or the global scope (i.e.,
|
|
85
|
+
* `self`) if the current execution context is in a Worker. Defaults to the global scope.
|
|
86
|
+
*/
|
|
87
|
+
function createWebWorkerMessageTransports(worker = globalWorkerScope()) {
|
|
88
|
+
const reader = new WebWorkerMessageReader(worker);
|
|
89
|
+
const writer = new WebWorkerMessageWriter(worker);
|
|
90
|
+
reader.onError(err => console.error(err));
|
|
91
|
+
writer.onError(err => console.error(err));
|
|
92
|
+
return {
|
|
93
|
+
reader,
|
|
94
|
+
writer,
|
|
95
|
+
};
|
|
96
|
+
}
|
|
97
|
+
exports.createWebWorkerMessageTransports = createWebWorkerMessageTransports;
|
|
98
|
+
function globalWorkerScope() {
|
|
99
|
+
var globalObject = typeof window !== 'undefined' ? window :
|
|
100
|
+
typeof self !== 'undefined' ? self :
|
|
101
|
+
typeof global !== 'undefined' ? global :
|
|
102
|
+
{};
|
|
103
|
+
const worker = globalObject;
|
|
104
|
+
// tslint:disable-next-line no-unbound-method
|
|
105
|
+
if (!worker.postMessage || 'document' in worker) {
|
|
106
|
+
// throw new Error('global scope is not a Worker')
|
|
107
|
+
console.warn('global scope is not a Worker');
|
|
108
|
+
}
|
|
109
|
+
return worker;
|
|
110
|
+
}
|
|
111
|
+
//# sourceMappingURL=webWorker.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"webWorker.js","sourceRoot":"","sources":["../../../../src/connections/jsonrpc2/transports/webWorker.ts"],"names":[],"mappings":";;;AAEA,4CAAuH;AAuBvH,MAAM,sBAAuB,SAAQ,iCAAqB;IAItD,YAAoB,MAAc;QAC9B,KAAK,EAAE,CAAA;QADS,WAAM,GAAN,MAAM,CAAQ;QAH1B,YAAO,GAAc,EAAE,CAAA;QACvB,aAAQ,GAAwB,IAAI,CAAA;QAKxC,MAAM,CAAC,gBAAgB,CAAC,SAAS,EAAE,CAAC,CAAe,EAAE,EAAE;YAEnD,IAAI;gBACA,IAAI,CAAC,cAAc,CAAC,CAAC,CAAC,CAAA;aACzB;YAAC,OAAO,GAAG,EAAE;gBACV,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,CAAA;aACtB;QACL,CAAC,CAAC,CAAA;QACF,MAAM,CAAC,gBAAgB,CAAC,OAAO,EAAE,CAAC,GAAe,EAAE,EAAE;YAEjD,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,CAAA;YACnB,IAAI,GAAG,CAAC,UAAU,EAAE;gBAChB,GAAG,CAAC,cAAc,EAAE,CAAA;aACvB;iBAAM;gBACH,eAAe,CAAC,MAAM,CAAC,CAAA;gBACvB,IAAI,CAAC,SAAS,EAAE,CAAA;aACnB;QACL,CAAC,CAAC,CAAA;IACN,CAAC;IAEO,cAAc,CAAC,CAAe;QAClC,MAAM,OAAO,GAAY,CAAC,CAAC,IAAI,CAAA;QAC/B,IAAI,IAAI,CAAC,QAAQ,EAAE;YACf,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAA;SAC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,EAAE,CAAA,CAAC,kBAAkB;KACpC;AACL,CAAC;AAED;;;;;GAKG;AACH,SAAgB,gCAAgC,CAAC,SAAiB,iBAAiB,EAAE;IACjF,MAAM,MAAM,GAAG,IAAI,sBAAsB,CAAC,MAAM,CAAC,CAAA;IACjD,MAAM,MAAM,GAAG,IAAI,sBAAsB,CAAC,MAAM,CAAC,CAAA;IACjD,MAAM,CAAC,OAAO,CAAC,GAAG,CAAC,EAAE,CAAC,OAAO,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAA;IACzC,MAAM,CAAC,OAAO,CAAC,GAAG,CAAC,EAAE,CAAC,OAAO,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAA;IACzC,OAAO;QACH,MAAM;QACN,MAAM;KACT,CAAA;AACL,CAAC;AATD,4EASC;AAED,SAAS,iBAAiB;IACtB,IAAI,YAAY,GAChB,OAAO,MAAM,KAAK,WAAW,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC;QACxC,OAAO,IAAI,KAAK,WAAW,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC;YACpC,OAAO,MAAM,KAAK,WAAW,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC;gBACxC,EAAE,CAAC;IAEH,MAAM,MAAM,GAAW,YAAmB,CAAA;IAC1C,6CAA6C;IAC7C,IAAI,CAAC,MAAM,CAAC,WAAW,IAAI,UAAU,IAAI,MAAM,EAAE;QAC7C,kDAAkD;QAClD,OAAO,CAAC,IAAI,CAAC,8BAA8B,CAAC,CAAA;KAC/C;IACD,OAAO,MAAM,CAAA;AACjB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './proxy';
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./proxy"), exports);
|
|
18
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/connections/proxy/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,0CAAwB"}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { Connection } from '../jsonrpc2/connection';
|
|
2
|
+
import { IRPCProtocol, ProxyIdentifier } from '../../protocol/proxy-identifier';
|
|
3
|
+
/**
|
|
4
|
+
*
|
|
5
|
+
* @param prefix
|
|
6
|
+
* @param connection
|
|
7
|
+
* @param handler
|
|
8
|
+
* @return A proxy that translates method calls on itself to requests sent on the {@link connection}.
|
|
9
|
+
*/
|
|
10
|
+
export declare function createProxyAndHandleRequests(prefix: string, connection: Connection, handler: any): any;
|
|
11
|
+
export declare function createExtensionProxy(connection: Connection, rpcId: number): any;
|
|
12
|
+
/**
|
|
13
|
+
* Creates a Proxy that translates method calls (whose name begins with "$") on the returned object to messages
|
|
14
|
+
* named `${prefix}/${name}` on the connectino.
|
|
15
|
+
*
|
|
16
|
+
* @param connection - The connection to send messages on when proxy methods are called.
|
|
17
|
+
* @param prefix - The name prefix for connection methods.
|
|
18
|
+
*/
|
|
19
|
+
export declare function createProxy(connection: Connection | any, prefix: string): any;
|
|
20
|
+
/**
|
|
21
|
+
* Forwards all requests received on the connection to the corresponding method on the handler object. The
|
|
22
|
+
* connection method `${prefix}/${name}` corresponds to `${name}` method on the handler object.
|
|
23
|
+
*
|
|
24
|
+
*
|
|
25
|
+
* @param connection - connection
|
|
26
|
+
* @param prefix - connection prefix
|
|
27
|
+
* @param handler - An instance of a class whose methods should be called when the connection receives
|
|
28
|
+
* corresponding requests, or an object created with Object.create(null) (or otherwise with a null
|
|
29
|
+
* prototype) whose properties contain functions to be called.
|
|
30
|
+
*/
|
|
31
|
+
export declare function handleRequests(connection: Connection, prefix: string, handler: any): void;
|
|
32
|
+
/**
|
|
33
|
+
* Forwards all requests received on the connection to the corresponding method on the server side.
|
|
34
|
+
*
|
|
35
|
+
* @param connection - connection
|
|
36
|
+
* @param extContext - Remote Context, usually for connecting to Server side providers
|
|
37
|
+
* @param identifier - Remote Actor Identifier.
|
|
38
|
+
*/
|
|
39
|
+
export declare function handleServerProxyRequest<T>(connection: Connection, remoteProtocol: IRPCProtocol, identifier: ProxyIdentifier<T>): void;
|
|
40
|
+
/**
|
|
41
|
+
* Forwards all requests received on the connection to the corresponding method on the server side.
|
|
42
|
+
*
|
|
43
|
+
* @param connection - connection
|
|
44
|
+
* @param extContext - Remote Context, usually for connecting to Server side providers
|
|
45
|
+
* @param identifier - Remote Actor Identifier.
|
|
46
|
+
*/
|
|
47
|
+
export declare function handleServerProxyRequests(connection: Connection, remoteProtocol: IRPCProtocol, identifiers: {
|
|
48
|
+
[key: string]: ProxyIdentifier<any>;
|
|
49
|
+
}): void;
|