javonet-nodejs-sdk 2.6.3 → 2.6.5
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/dist/core/handler/AbstractHandler.cjs +4 -4
- package/dist/core/handler/GetInstanceMethodAsDelegateHandler.cjs +2 -4
- package/dist/core/handler/GetStaticMethodAsDelegateHandler.cjs +4 -2
- package/dist/core/handler/GetTypeHandler.cjs +3 -3
- package/dist/core/handler/Handler.cjs +15 -4
- package/dist/core/handler/LoadLibraryHandler.cjs +10 -6
- package/dist/core/interpreter/Interpreter.cjs +42 -16
- package/dist/core/protocol/CommandDeserializer.cjs +4 -4
- package/dist/core/protocol/CommandSerializer.cjs +7 -2
- package/dist/core/protocol/TypeDeserializer.cjs +11 -11
- package/dist/core/receiver/Receiver.cjs +7 -8
- package/dist/core/receiver/ReceiverNative.cjs +4 -2
- package/dist/core/transmitter/Transmitter.cjs +6 -6
- package/dist/core/transmitter/TransmitterWebsocket.cjs +2 -2
- package/dist/core/transmitter/TransmitterWebsocketBrowser.cjs +2 -2
- package/dist/core/transmitter/TransmitterWrapper.cjs +2 -1
- package/dist/core/webSocketClient/WebSocketClient.cjs +4 -4
- package/dist/core/webSocketClient/WebSocketClientBrowser.cjs +7 -7
- package/dist/sdk/ConfigRuntimeFactory.cjs +50 -47
- package/dist/sdk/InvocationContext.cjs +57 -40
- package/dist/sdk/Javonet.cjs +22 -0
- package/dist/sdk/RuntimeFactory.cjs +33 -1
- package/dist/sdk/configuration/Config.cjs +55 -0
- package/dist/sdk/configuration/ConfigPriority.cjs +38 -0
- package/dist/sdk/configuration/ConfigSourceResolver.cjs +100 -0
- package/dist/sdk/configuration/ConfigsDictionary.cjs +121 -0
- package/dist/sdk/configuration/configResolvers/ConfigResolver.cjs +121 -0
- package/dist/sdk/configuration/configResolvers/ConnectionStringConfigResolver.cjs +123 -0
- package/dist/sdk/configuration/configResolvers/JsonConfigResolver.cjs +125 -0
- package/dist/sdk/configuration/configResolvers/YamlConfigResolver.cjs +125 -0
- package/dist/sdk/tools/ComplexTypeResolver.cjs +28 -3
- package/dist/sdk/tools/JsonResolver.cjs +4 -1
- package/dist/types/core/handler/Handler.d.ts +3 -3
- package/dist/types/core/interpreter/Interpreter.d.ts +3 -3
- package/dist/types/core/protocol/CommandDeserializer.d.ts +3 -3
- package/dist/types/core/protocol/CommandSerializer.d.ts +3 -3
- package/dist/types/core/protocol/TypeDeserializer.d.ts +22 -22
- package/dist/types/core/receiver/Receiver.d.ts +6 -5
- package/dist/types/core/receiver/ReceiverNative.d.ts +6 -4
- package/dist/types/core/transmitter/Transmitter.d.ts +4 -4
- package/dist/types/core/transmitter/TransmitterWebsocket.d.ts +3 -3
- package/dist/types/core/transmitter/TransmitterWebsocketBrowser.d.ts +3 -3
- package/dist/types/core/transmitter/TransmitterWrapper.d.ts +3 -2
- package/dist/types/core/webSocketClient/WebSocketClient.d.ts +7 -7
- package/dist/types/core/webSocketClient/WebSocketClientBrowser.d.ts +9 -9
- package/dist/types/sdk/ConfigRuntimeFactory.d.ts +3 -0
- package/dist/types/sdk/InvocationContext.d.ts +7 -11
- package/dist/types/sdk/Javonet.d.ts +15 -1
- package/dist/types/sdk/RuntimeFactory.d.ts +14 -0
- package/dist/types/sdk/configuration/Config.d.ts +14 -0
- package/dist/types/sdk/configuration/ConfigPriority.d.ts +8 -0
- package/dist/types/sdk/configuration/ConfigSourceResolver.d.ts +7 -0
- package/dist/types/sdk/configuration/ConfigsDictionary.d.ts +30 -0
- package/dist/types/sdk/configuration/configResolvers/ConfigResolver.d.ts +30 -0
- package/dist/types/sdk/configuration/configResolvers/ConnectionStringConfigResolver.d.ts +23 -0
- package/dist/types/sdk/configuration/configResolvers/JsonConfigResolver.d.ts +26 -0
- package/dist/types/sdk/configuration/configResolvers/YamlConfigResolver.d.ts +32 -0
- package/dist/types/sdk/tools/ComplexTypeResolver.d.ts +2 -2
- package/dist/types/sdk/tools/JsonResolver.d.ts +4 -2
- package/dist/types/utils/Runtime.d.ts +4 -3
- package/dist/types/utils/RuntimeNameHandler.d.ts +5 -0
- package/dist/utils/RuntimeNameHandler.cjs +34 -0
- package/dist/utils/connectionData/InMemoryConnectionData.cjs +7 -1
- package/dist/utils/connectionData/WsConnectionData.cjs +6 -0
- package/dist/utils/exception/ExceptionSerializer.cjs +6 -2
- package/dist/utils/nodejs/connectionData/TcpConnectionData.cjs +15 -6
- package/lib/core/handler/AbstractHandler.js +7 -5
- package/lib/core/handler/AddEventListenerHandler.js +2 -3
- package/lib/core/handler/ArrayReferenceHandler.js +2 -3
- package/lib/core/handler/AsKwargsHandler.js +2 -2
- package/lib/core/handler/AsOutHandler.js +2 -3
- package/lib/core/handler/AsRefHandler.js +2 -3
- package/lib/core/handler/CreateNullHandler.js +2 -3
- package/lib/core/handler/ExceptionHandler.js +2 -3
- package/lib/core/handler/GenerateLibHandler.js +2 -3
- package/lib/core/handler/GetAsyncOperationResultHandler.js +2 -3
- package/lib/core/handler/GetEnumItemHandler.js +2 -3
- package/lib/core/handler/GetEnumNameHandler.js +2 -2
- package/lib/core/handler/GetEnumValueHandler.js +2 -3
- package/lib/core/handler/GetInstanceMethodAsDelegateHandler.js +3 -3
- package/lib/core/handler/GetModuleHandler.js +2 -2
- package/lib/core/handler/GetRefValueHandler.js +2 -3
- package/lib/core/handler/GetStaticFieldHandler.js +0 -1
- package/lib/core/handler/GetStaticMethodAsDelegateHandler.js +3 -1
- package/lib/core/handler/GetTypeHandler.js +3 -3
- package/lib/core/handler/Handler.js +47 -33
- package/lib/core/handler/HeartBeatHandler.js +2 -3
- package/lib/core/handler/InvokeGenericMethodHandler.js +2 -4
- package/lib/core/handler/InvokeGenericStaticMethodHandler.js +2 -3
- package/lib/core/handler/InvokeStaticMethodHandler.js +1 -1
- package/lib/core/handler/LoadLibraryHandler.js +15 -7
- package/lib/core/handler/OptimizeHandler.js +2 -3
- package/lib/core/handler/PluginWrapperHandler.js +2 -3
- package/lib/core/handler/ResolveReferenceHandler.js +1 -3
- package/lib/core/handler/RetrieveArrayHandler.js +2 -3
- package/lib/core/interpreter/Interpreter.js +47 -20
- package/lib/core/protocol/CommandDeserializer.js +4 -4
- package/lib/core/protocol/CommandSerializer.js +8 -2
- package/lib/core/protocol/TypeDeserializer.js +11 -11
- package/lib/core/receiver/Receiver.js +10 -13
- package/lib/core/receiver/ReceiverNative.js +4 -2
- package/lib/core/transmitter/Transmitter.js +7 -7
- package/lib/core/transmitter/TransmitterWebsocket.js +2 -2
- package/lib/core/transmitter/TransmitterWebsocketBrowser.js +2 -2
- package/lib/core/transmitter/TransmitterWrapper.js +2 -1
- package/lib/core/webSocketClient/WebSocketClient.js +5 -5
- package/lib/core/webSocketClient/WebSocketClientBrowser.js +10 -10
- package/lib/sdk/ActivatorDetails.js +1 -1
- package/lib/sdk/ConfigRuntimeFactory.js +65 -48
- package/lib/sdk/InvocationContext.js +58 -43
- package/lib/sdk/Javonet.js +31 -2
- package/lib/sdk/RuntimeContext.js +0 -7
- package/lib/sdk/RuntimeFactory.js +49 -1
- package/lib/sdk/configuration/Config.js +37 -0
- package/lib/sdk/configuration/ConfigPriority.js +9 -0
- package/lib/sdk/configuration/ConfigSourceResolver.js +84 -0
- package/lib/sdk/configuration/ConfigsDictionary.js +118 -0
- package/lib/sdk/configuration/configResolvers/ConfigResolver.js +109 -0
- package/lib/sdk/configuration/configResolvers/ConnectionStringConfigResolver.js +119 -0
- package/lib/sdk/configuration/configResolvers/JsonConfigResolver.js +99 -0
- package/lib/sdk/configuration/configResolvers/YamlConfigResolver.js +109 -0
- package/lib/sdk/tools/ActivationHelper.js +1 -1
- package/lib/sdk/tools/ComplexTypeResolver.js +22 -3
- package/lib/sdk/tools/JsonResolver.js +5 -1
- package/lib/sdk/tools/typeParsingFunctions/NetcoreTypeParsingFunctions.js +1 -1
- package/lib/sdk/tools/typeParsingFunctions/NodejsTypeParsingFunctions.js +1 -1
- package/lib/sdk/tools/typeParsingFunctions/TypeParsingUtils.js +4 -1
- package/lib/utils/CommandType.js +1 -1
- package/lib/utils/CustomError.js +1 -1
- package/lib/utils/Runtime.js +11 -4
- package/lib/utils/RuntimeLoggerBrowser.js +0 -1
- package/lib/utils/RuntimeNameHandler.js +37 -0
- package/lib/utils/TypesHandler.js +11 -5
- package/lib/utils/connectionData/InMemoryConnectionData.js +8 -1
- package/lib/utils/connectionData/WsConnectionData.js +7 -0
- package/lib/utils/exception/ExceptionSerializer.js +6 -2
- package/lib/utils/nodejs/connectionData/TcpConnectionData.js +16 -6
- package/lib/utils/nodejs/uuid/v4.js +0 -1
- package/package.json +6 -2
|
@@ -55,10 +55,10 @@ class AbstractHandler {
|
|
|
55
55
|
}
|
|
56
56
|
}
|
|
57
57
|
/**
|
|
58
|
-
*
|
|
59
|
-
* @param {*} error
|
|
60
|
-
* @param {*} class_name
|
|
61
|
-
* @returns
|
|
58
|
+
*
|
|
59
|
+
* @param {*} error
|
|
60
|
+
* @param {*} class_name
|
|
61
|
+
* @returns
|
|
62
62
|
*/
|
|
63
63
|
process_stack_trace(error, class_name) {
|
|
64
64
|
let stackTraceArray = error.stack.split("\n").map((frame) => frame.trim());
|
|
@@ -77,10 +77,8 @@ class GetInstanceMethodAsDelegateHandler extends import_AbstractHandler.Abstract
|
|
|
77
77
|
const methods = Object.getOwnPropertyNames(
|
|
78
78
|
/** @type {{prototype: Object}} */
|
|
79
79
|
type.prototype
|
|
80
|
-
).filter(
|
|
81
|
-
|
|
82
|
-
type.prototype[key] === "function"
|
|
83
|
-
);
|
|
80
|
+
).filter((key) => typeof /** @type {any} */
|
|
81
|
+
type.prototype[key] === "function");
|
|
84
82
|
const availableMethods = methods.map((name) => `${name}()`);
|
|
85
83
|
const message = `Method ${methodName} not found in class ${/** @type {{name: string}} */
|
|
86
84
|
type.name}. Available instance public methods:
|
|
@@ -70,8 +70,10 @@ class GetStaticMethodAsDelegateHandler extends import_AbstractHandler.AbstractHa
|
|
|
70
70
|
* @returns {Error} The error with detailed message.
|
|
71
71
|
*/
|
|
72
72
|
createMethodNotFoundError(type, methodName) {
|
|
73
|
-
const methods = Object.keys(type).filter(
|
|
74
|
-
|
|
73
|
+
const methods = Object.keys(type).filter(
|
|
74
|
+
(key) => typeof /** @type {any} */
|
|
75
|
+
type[key] === "function"
|
|
76
|
+
);
|
|
75
77
|
const availableMethods = methods.map((name) => `${name}()`);
|
|
76
78
|
const message = `Method ${methodName} not found in class ${/** @type {{name: string}} */
|
|
77
79
|
type.name}. Available public static methods:
|
|
@@ -36,9 +36,9 @@ class GetTypeHandler extends import_AbstractHandler.AbstractHandler {
|
|
|
36
36
|
this.loadLibaryHandler = new import_LoadLibraryHandler.LoadLibraryHandler();
|
|
37
37
|
}
|
|
38
38
|
/**
|
|
39
|
-
*
|
|
40
|
-
* @param {Command} command
|
|
41
|
-
* @returns
|
|
39
|
+
*
|
|
40
|
+
* @param {Command} command
|
|
41
|
+
* @returns
|
|
42
42
|
*/
|
|
43
43
|
process(command) {
|
|
44
44
|
try {
|
|
@@ -146,10 +146,16 @@ class Handler {
|
|
|
146
146
|
handleCommand(command) {
|
|
147
147
|
try {
|
|
148
148
|
if (command.commandType === import_CommandType.CommandType.RetrieveArray) {
|
|
149
|
-
|
|
150
|
-
|
|
149
|
+
const responseArray = handlers[import_CommandType.CommandType.Reference].handleCommand(command.payload[0]);
|
|
150
|
+
if (responseArray instanceof Promise) {
|
|
151
|
+
return responseArray.then((resolvedResponseArray) => {
|
|
152
|
+
return import_Command.Command.createArrayResponse(resolvedResponseArray, command.runtimeName);
|
|
153
|
+
});
|
|
154
|
+
} else {
|
|
155
|
+
return import_Command.Command.createArrayResponse(responseArray, command.runtimeName);
|
|
156
|
+
}
|
|
151
157
|
}
|
|
152
|
-
|
|
158
|
+
const response = handlers[command.commandType].handleCommand(command);
|
|
153
159
|
return this.parseCommand(response, command.runtimeName);
|
|
154
160
|
} catch (e) {
|
|
155
161
|
return import_ExceptionSerializer.ExceptionSerializer.serializeException(e, command);
|
|
@@ -158,9 +164,14 @@ class Handler {
|
|
|
158
164
|
/**
|
|
159
165
|
* @param {any} response
|
|
160
166
|
* @param {RuntimeName} runtimeName
|
|
161
|
-
* @returns {Command}
|
|
167
|
+
* @returns {Promise<Command> | Command}
|
|
162
168
|
*/
|
|
163
169
|
parseCommand(response, runtimeName) {
|
|
170
|
+
if (response instanceof Promise) {
|
|
171
|
+
return response.then((resolvedResponse) => {
|
|
172
|
+
return this.parseCommand(resolvedResponse, runtimeName);
|
|
173
|
+
});
|
|
174
|
+
}
|
|
164
175
|
if (import_TypesHandler.TypesHandler.isPrimitiveOrNullOrUndefined(response)) {
|
|
165
176
|
return import_Command.Command.createResponse(response, runtimeName);
|
|
166
177
|
} else {
|
|
@@ -23,6 +23,8 @@ __export(LoadLibraryHandler_exports, {
|
|
|
23
23
|
module.exports = __toCommonJS(LoadLibraryHandler_exports);
|
|
24
24
|
var import_Runtime = require("../../utils/Runtime.cjs");
|
|
25
25
|
var import_AbstractHandler = require("./AbstractHandler.cjs");
|
|
26
|
+
var import_fs = require("fs");
|
|
27
|
+
var import_path = require("path");
|
|
26
28
|
const import_meta = {};
|
|
27
29
|
const dynamicImport = (0, import_Runtime.getRequire)(import_meta.url);
|
|
28
30
|
class LoadLibraryHandler extends import_AbstractHandler.AbstractHandler {
|
|
@@ -41,6 +43,13 @@ class LoadLibraryHandler extends import_AbstractHandler.AbstractHandler {
|
|
|
41
43
|
}
|
|
42
44
|
let { payload } = command;
|
|
43
45
|
let [lib] = payload;
|
|
46
|
+
if (!lib) {
|
|
47
|
+
throw new Error("Cannot load module: Library path is required but was not provided");
|
|
48
|
+
}
|
|
49
|
+
const absolutePath = (0, import_path.resolve)(lib);
|
|
50
|
+
if (!(0, import_fs.existsSync)(lib) && !(0, import_fs.existsSync)(absolutePath)) {
|
|
51
|
+
throw new Error(`Cannot load module: Library not found: ${lib}`);
|
|
52
|
+
}
|
|
44
53
|
let pathArray = lib.split(/[/\\]/);
|
|
45
54
|
let libraryName = pathArray.length > 1 ? pathArray[pathArray.length - 1] : pathArray[0];
|
|
46
55
|
libraryName = libraryName.replace(".js", "");
|
|
@@ -49,12 +58,7 @@ class LoadLibraryHandler extends import_AbstractHandler.AbstractHandler {
|
|
|
49
58
|
moduleExports = dynamicImport(lib);
|
|
50
59
|
LoadLibraryHandler.loadedLibraries.push(lib);
|
|
51
60
|
} catch (error) {
|
|
52
|
-
|
|
53
|
-
const modulePath = `${process.cwd()}/${lib}`;
|
|
54
|
-
moduleExports = dynamicImport(modulePath);
|
|
55
|
-
} catch (error2) {
|
|
56
|
-
throw this.process_stack_trace(error2, this.constructor.name);
|
|
57
|
-
}
|
|
61
|
+
throw Error("Cannot load module: " + lib + "\n" + error);
|
|
58
62
|
}
|
|
59
63
|
global[libraryName] = moduleExports;
|
|
60
64
|
for (const [key, value] of Object.entries(moduleExports)) {
|
|
@@ -30,8 +30,8 @@ var import_TransmitterWebsocketBrowser = require("../transmitter/TransmitterWebs
|
|
|
30
30
|
var import_TransmitterWebsocket = require("../transmitter/TransmitterWebsocket.cjs");
|
|
31
31
|
var import_Handler = require("../handler/Handler.cjs");
|
|
32
32
|
const import_meta = {};
|
|
33
|
-
let _Receiver
|
|
34
|
-
let _Transmitter
|
|
33
|
+
let _Receiver;
|
|
34
|
+
let _Transmitter;
|
|
35
35
|
let _TransmitterWebsocket = null;
|
|
36
36
|
if (!_TransmitterWebsocket) {
|
|
37
37
|
_TransmitterWebsocket = (0, import_Runtime.isNodejsRuntime)() ? import_TransmitterWebsocket.TransmitterWebsocket : import_TransmitterWebsocketBrowser.TransmitterWebsocketBrowser;
|
|
@@ -58,7 +58,10 @@ class Interpreter {
|
|
|
58
58
|
let messageByteArray = new import_CommandSerializer.CommandSerializer().serialize(command, connectionData);
|
|
59
59
|
let responseByteArray = void 0;
|
|
60
60
|
if (connectionData.connectionType === import_ConnectionType.ConnectionType.WEB_SOCKET) {
|
|
61
|
-
const _response = await _TransmitterWebsocket?.sendCommand(
|
|
61
|
+
const _response = await _TransmitterWebsocket?.sendCommand(
|
|
62
|
+
await messageByteArray,
|
|
63
|
+
connectionData
|
|
64
|
+
);
|
|
62
65
|
if (_response) {
|
|
63
66
|
const command2 = new import_CommandDeserializer.CommandDeserializer(_response).deserialize();
|
|
64
67
|
return command2;
|
|
@@ -74,13 +77,13 @@ class Interpreter {
|
|
|
74
77
|
const { Receiver } = require("../receiver/Receiver.cjs");
|
|
75
78
|
_Receiver = Receiver;
|
|
76
79
|
}
|
|
77
|
-
responseByteArray = await _Receiver?.sendCommand(messageByteArray);
|
|
80
|
+
responseByteArray = await _Receiver?.sendCommand(await messageByteArray);
|
|
78
81
|
} else {
|
|
79
82
|
if (!_Transmitter) {
|
|
80
83
|
const { Transmitter } = require("../transmitter/Transmitter.cjs");
|
|
81
84
|
_Transmitter = Transmitter;
|
|
82
85
|
}
|
|
83
|
-
responseByteArray = await _Transmitter?.sendCommand(messageByteArray);
|
|
86
|
+
responseByteArray = await _Transmitter?.sendCommand(await messageByteArray);
|
|
84
87
|
}
|
|
85
88
|
}
|
|
86
89
|
if (!responseByteArray) {
|
|
@@ -103,37 +106,60 @@ class Interpreter {
|
|
|
103
106
|
let responseByteArray = void 0;
|
|
104
107
|
if (connectionData.connectionType === import_ConnectionType.ConnectionType.WEB_SOCKET) {
|
|
105
108
|
throw new Error("Not supported");
|
|
106
|
-
}
|
|
107
|
-
if (connectionData.connectionType === import_ConnectionType.ConnectionType.IN_MEMORY) {
|
|
109
|
+
} else {
|
|
108
110
|
if (!(0, import_Runtime.isNodejsRuntime)()) {
|
|
109
111
|
throw new Error("InMemory is only allowed in Nodejs runtime");
|
|
110
112
|
}
|
|
111
|
-
if (command.runtimeName === import_RuntimeName.RuntimeName.Nodejs) {
|
|
113
|
+
if (command.runtimeName === import_RuntimeName.RuntimeName.Nodejs && connectionData.connectionType === import_ConnectionType.ConnectionType.IN_MEMORY) {
|
|
112
114
|
if (!_Receiver) {
|
|
113
115
|
const { Receiver } = require("../receiver/Receiver.cjs");
|
|
114
116
|
_Receiver = Receiver;
|
|
115
117
|
}
|
|
116
|
-
|
|
118
|
+
if (!_Receiver) {
|
|
119
|
+
throw new Error("Receiver is undefined");
|
|
120
|
+
}
|
|
121
|
+
if (messageByteArray instanceof Uint8Array) {
|
|
122
|
+
responseByteArray = _Receiver.sendCommand(messageByteArray);
|
|
123
|
+
} else {
|
|
124
|
+
responseByteArray = messageByteArray.then((resolvedMessage) => {
|
|
125
|
+
return _Receiver.sendCommand(resolvedMessage);
|
|
126
|
+
});
|
|
127
|
+
}
|
|
117
128
|
} else {
|
|
118
129
|
if (!_Transmitter) {
|
|
119
130
|
const { Transmitter } = require("../transmitter/Transmitter.cjs");
|
|
120
131
|
_Transmitter = Transmitter;
|
|
121
132
|
}
|
|
122
|
-
|
|
133
|
+
if (!_Transmitter) {
|
|
134
|
+
throw new Error("Transmitter is undefined");
|
|
135
|
+
}
|
|
136
|
+
if (messageByteArray instanceof Uint8Array) {
|
|
137
|
+
responseByteArray = _Transmitter.sendCommand(messageByteArray);
|
|
138
|
+
} else {
|
|
139
|
+
responseByteArray = messageByteArray.then((resolvedMessage) => {
|
|
140
|
+
return _Transmitter.sendCommand(resolvedMessage);
|
|
141
|
+
});
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
if (!responseByteArray) {
|
|
145
|
+
throw new Error("No response received from Transmitter");
|
|
146
|
+
}
|
|
147
|
+
if (responseByteArray instanceof Promise) {
|
|
148
|
+
return responseByteArray.then((resolvedResponse) => {
|
|
149
|
+
return new import_CommandDeserializer.CommandDeserializer(resolvedResponse).deserialize();
|
|
150
|
+
});
|
|
151
|
+
} else {
|
|
152
|
+
return new import_CommandDeserializer.CommandDeserializer(responseByteArray).deserialize();
|
|
123
153
|
}
|
|
124
154
|
}
|
|
125
|
-
if (!responseByteArray) {
|
|
126
|
-
throw new Error("No response received from Transmitter");
|
|
127
|
-
}
|
|
128
|
-
return new import_CommandDeserializer.CommandDeserializer(responseByteArray).deserialize();
|
|
129
155
|
} catch (error) {
|
|
130
156
|
throw error;
|
|
131
157
|
}
|
|
132
158
|
}
|
|
133
159
|
/**
|
|
134
160
|
*
|
|
135
|
-
* @param {
|
|
136
|
-
* @returns {Command}
|
|
161
|
+
* @param {Uint8Array} messageByteArray
|
|
162
|
+
* @returns {Promise<Command> | Command}
|
|
137
163
|
*/
|
|
138
164
|
process(messageByteArray) {
|
|
139
165
|
try {
|
|
@@ -26,11 +26,11 @@ var import_Type = require("../../utils/Type.cjs");
|
|
|
26
26
|
var import_TypeDeserializer = require("./TypeDeserializer.cjs");
|
|
27
27
|
class CommandDeserializer {
|
|
28
28
|
/**
|
|
29
|
-
* @param {
|
|
29
|
+
* @param {Uint8Array} byteArray
|
|
30
30
|
*/
|
|
31
|
-
constructor(
|
|
32
|
-
this.buffer =
|
|
33
|
-
this.command = new import_Command.Command(buffer[0], buffer[10], []);
|
|
31
|
+
constructor(byteArray) {
|
|
32
|
+
this.buffer = byteArray;
|
|
33
|
+
this.command = new import_Command.Command(this.buffer[0], this.buffer[10], []);
|
|
34
34
|
this.position = 11;
|
|
35
35
|
}
|
|
36
36
|
/**
|
|
@@ -30,13 +30,18 @@ var import_TypesHandler = require("../../utils/TypesHandler.cjs");
|
|
|
30
30
|
class CommandSerializer {
|
|
31
31
|
/**
|
|
32
32
|
* Serializes the root command with connection data and optional runtime version.
|
|
33
|
-
* @param {Command} rootCommand
|
|
33
|
+
* @param {Promise<Command> | Command} rootCommand
|
|
34
34
|
* @param {IConnectionData} connectionData
|
|
35
35
|
* @param {number} runtimeVersion
|
|
36
|
-
* @returns {
|
|
36
|
+
* @returns {Promise<Uint8Array> | Uint8Array}
|
|
37
37
|
*/
|
|
38
38
|
serialize(rootCommand, connectionData, runtimeVersion = 0) {
|
|
39
39
|
const buffers = [];
|
|
40
|
+
if (rootCommand instanceof Promise) {
|
|
41
|
+
return rootCommand.then((resolvedCommand) => {
|
|
42
|
+
return this.serialize(resolvedCommand, connectionData, runtimeVersion);
|
|
43
|
+
});
|
|
44
|
+
}
|
|
40
45
|
buffers.push(Uint8Array.of(rootCommand.runtimeName, runtimeVersion));
|
|
41
46
|
if (connectionData) {
|
|
42
47
|
buffers.push(connectionData.serializeConnectionData());
|
|
@@ -26,7 +26,7 @@ var import_buffer = require("buffer");
|
|
|
26
26
|
var import_StringEncodingMode = require("../../utils/StringEncodingMode.cjs");
|
|
27
27
|
class TypeDeserializer {
|
|
28
28
|
/**
|
|
29
|
-
* @param {
|
|
29
|
+
* @param {Uint8Array} encodedCommand
|
|
30
30
|
* @returns {Command}
|
|
31
31
|
*/
|
|
32
32
|
static deserializeCommand(encodedCommand) {
|
|
@@ -34,7 +34,7 @@ class TypeDeserializer {
|
|
|
34
34
|
}
|
|
35
35
|
/**
|
|
36
36
|
* @param {number} stringEncodingMode
|
|
37
|
-
* @param {
|
|
37
|
+
* @param {Uint8Array} encodedString
|
|
38
38
|
*/
|
|
39
39
|
static deserializeString(stringEncodingMode, encodedString) {
|
|
40
40
|
switch (stringEncodingMode) {
|
|
@@ -62,55 +62,55 @@ class TypeDeserializer {
|
|
|
62
62
|
}
|
|
63
63
|
}
|
|
64
64
|
/**
|
|
65
|
-
* @param {
|
|
65
|
+
* @param {Uint8Array} encodedInt
|
|
66
66
|
*/
|
|
67
67
|
static deserializeInt(encodedInt) {
|
|
68
68
|
return encodedInt[0] & 255 | (encodedInt[1] & 255) << 8 | (encodedInt[2] & 255) << 16 | (encodedInt[3] & 255) << 24;
|
|
69
69
|
}
|
|
70
70
|
/**
|
|
71
|
-
* @param {
|
|
71
|
+
* @param {Uint8Array} encodedBool
|
|
72
72
|
*/
|
|
73
73
|
static deserializeBool(encodedBool) {
|
|
74
74
|
return encodedBool[0] === 1;
|
|
75
75
|
}
|
|
76
76
|
/**
|
|
77
|
-
* @param {
|
|
77
|
+
* @param {Uint8Array} encodedFloat
|
|
78
78
|
*/
|
|
79
79
|
static deserializeFloat(encodedFloat) {
|
|
80
80
|
return import_buffer.Buffer.from(encodedFloat).readFloatLE();
|
|
81
81
|
}
|
|
82
82
|
/**
|
|
83
|
-
* @param {
|
|
83
|
+
* @param {Uint8Array} encodedByte
|
|
84
84
|
*/
|
|
85
85
|
static deserializeByte(encodedByte) {
|
|
86
86
|
return import_buffer.Buffer.from(encodedByte).readUint8();
|
|
87
87
|
}
|
|
88
88
|
/**
|
|
89
|
-
* @param {
|
|
89
|
+
* @param {Uint8Array} encodedChar
|
|
90
90
|
*/
|
|
91
91
|
static deserializeChar(encodedChar) {
|
|
92
92
|
return import_buffer.Buffer.from(encodedChar).readUint8();
|
|
93
93
|
}
|
|
94
94
|
/**
|
|
95
|
-
* @param {
|
|
95
|
+
* @param {Uint8Array} encodedLongLong
|
|
96
96
|
*/
|
|
97
97
|
static deserializeLongLong(encodedLongLong) {
|
|
98
98
|
return import_buffer.Buffer.from(encodedLongLong).readBigInt64LE();
|
|
99
99
|
}
|
|
100
100
|
/**
|
|
101
|
-
* @param {
|
|
101
|
+
* @param {Uint8Array} encodedDouble
|
|
102
102
|
*/
|
|
103
103
|
static deserializeDouble(encodedDouble) {
|
|
104
104
|
return import_buffer.Buffer.from(encodedDouble).readDoubleLE();
|
|
105
105
|
}
|
|
106
106
|
/**
|
|
107
|
-
* @param {
|
|
107
|
+
* @param {Uint8Array} encodedULLong
|
|
108
108
|
*/
|
|
109
109
|
static deserializeULLong(encodedULLong) {
|
|
110
110
|
return import_buffer.Buffer.from(encodedULLong).readBigUInt64LE();
|
|
111
111
|
}
|
|
112
112
|
/**
|
|
113
|
-
* @param {
|
|
113
|
+
* @param {Uint8Array} encodedUInt
|
|
114
114
|
*/
|
|
115
115
|
static deserializeUInt(encodedUInt) {
|
|
116
116
|
return import_buffer.Buffer.from(encodedUInt).readUIntLE(0, 4);
|
|
@@ -38,14 +38,13 @@ class Receiver {
|
|
|
38
38
|
return import_RuntimeLogger.RuntimeLogger.getRuntimeInfo();
|
|
39
39
|
}
|
|
40
40
|
/**
|
|
41
|
-
* @param {
|
|
41
|
+
* @param {Uint8Array} messageByteArray
|
|
42
|
+
* @returns {Promise<Uint8Array> | Uint8Array}
|
|
42
43
|
*/
|
|
43
44
|
static sendCommand(messageByteArray) {
|
|
44
45
|
try {
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
this.connectionData
|
|
48
|
-
);
|
|
46
|
+
let command = new import_Interpreter.Interpreter().process(messageByteArray);
|
|
47
|
+
return new import_CommandSerializer.CommandSerializer().serialize(command, this.connectionData);
|
|
49
48
|
} catch (error) {
|
|
50
49
|
const exceptionCommand = import_ExceptionSerializer.ExceptionSerializer.serializeException(
|
|
51
50
|
error,
|
|
@@ -55,11 +54,11 @@ class Receiver {
|
|
|
55
54
|
}
|
|
56
55
|
}
|
|
57
56
|
/**
|
|
58
|
-
* @param {
|
|
59
|
-
* @returns {
|
|
57
|
+
* @param {Uint8Array} messageByteArray
|
|
58
|
+
* @returns {Promise<Uint8Array> | Uint8Array}
|
|
60
59
|
*/
|
|
61
60
|
static heartBeat(messageByteArray) {
|
|
62
|
-
let response = new
|
|
61
|
+
let response = new Uint8Array(2);
|
|
63
62
|
response[0] = messageByteArray[11];
|
|
64
63
|
response[1] = messageByteArray[12] - 2;
|
|
65
64
|
return response;
|
|
@@ -24,13 +24,15 @@ module.exports = __toCommonJS(ReceiverNative_exports);
|
|
|
24
24
|
var import_Receiver = require("./Receiver.cjs");
|
|
25
25
|
class ReceiverNative {
|
|
26
26
|
/**
|
|
27
|
-
* @param {
|
|
27
|
+
* @param {Uint8Array} messageByteArray
|
|
28
|
+
* @returns {Promise<Uint8Array> | Uint8Array}
|
|
28
29
|
*/
|
|
29
30
|
static sendCommand(messageByteArray) {
|
|
30
31
|
return import_Receiver.Receiver.sendCommand(messageByteArray);
|
|
31
32
|
}
|
|
32
33
|
/**
|
|
33
|
-
* @param {
|
|
34
|
+
* @param {Uint8Array} messageByteArray
|
|
35
|
+
* @returns {Uint8Array | Promise<Uint8Array>}
|
|
34
36
|
*/
|
|
35
37
|
static heartBeat(messageByteArray) {
|
|
36
38
|
return import_Receiver.Receiver.heartBeat(messageByteArray);
|
|
@@ -24,14 +24,14 @@ module.exports = __toCommonJS(Transmitter_exports);
|
|
|
24
24
|
var import_TransmitterWrapper = require("./TransmitterWrapper.cjs");
|
|
25
25
|
class Transmitter {
|
|
26
26
|
/**
|
|
27
|
-
* @param {
|
|
28
|
-
* @returns {
|
|
27
|
+
* @param {Uint8Array} messageArray
|
|
28
|
+
* @returns {Uint8Array}
|
|
29
29
|
*/
|
|
30
30
|
static sendCommand(messageArray) {
|
|
31
31
|
return import_TransmitterWrapper.TransmitterWrapper.sendCommand(messageArray);
|
|
32
32
|
}
|
|
33
33
|
/**
|
|
34
|
-
* @param {string} licenseKey
|
|
34
|
+
* @param {string} licenseKey
|
|
35
35
|
* @returns {void}
|
|
36
36
|
*/
|
|
37
37
|
static activate(licenseKey) {
|
|
@@ -40,13 +40,13 @@ class Transmitter {
|
|
|
40
40
|
/**
|
|
41
41
|
* @param {string} configSource
|
|
42
42
|
* @returns {void}
|
|
43
|
-
|
|
43
|
+
*/
|
|
44
44
|
static setConfigSource(configSource) {
|
|
45
45
|
return import_TransmitterWrapper.TransmitterWrapper.setConfigSource(configSource);
|
|
46
46
|
}
|
|
47
47
|
/**
|
|
48
|
-
* @param {string} workingDirectory
|
|
49
|
-
* @returns
|
|
48
|
+
* @param {string} workingDirectory
|
|
49
|
+
* @returns
|
|
50
50
|
*/
|
|
51
51
|
static setJavonetWorkingDirectory(workingDirectory) {
|
|
52
52
|
return import_TransmitterWrapper.TransmitterWrapper.setJavonetWorkingDirectory(workingDirectory);
|
|
@@ -40,9 +40,9 @@ class TransmitterWebsocket {
|
|
|
40
40
|
}
|
|
41
41
|
/**
|
|
42
42
|
* @async
|
|
43
|
-
* @param {
|
|
43
|
+
* @param {Uint8Array} messageByteArray
|
|
44
44
|
* @param {IConnectionData} connectionData
|
|
45
|
-
* @returns {Promise<
|
|
45
|
+
* @returns {Promise<Uint8Array>} responseByteArray
|
|
46
46
|
*/
|
|
47
47
|
static sendCommand(messageByteArray, connectionData) {
|
|
48
48
|
const { hostname } = connectionData;
|
|
@@ -35,9 +35,9 @@ class TransmitterWebsocketBrowser {
|
|
|
35
35
|
}
|
|
36
36
|
/**
|
|
37
37
|
* @async
|
|
38
|
-
* @param {
|
|
38
|
+
* @param {Uint8Array} messageByteArray
|
|
39
39
|
* @param {IConnectionData} connectionData
|
|
40
|
-
* @returns {Promise<
|
|
40
|
+
* @returns {Promise<Uint8Array>} responseByteArray
|
|
41
41
|
*/
|
|
42
42
|
static async sendCommand(messageByteArray, connectionData) {
|
|
43
43
|
const { hostname } = connectionData;
|
|
@@ -62,8 +62,8 @@ class WebSocketClient {
|
|
|
62
62
|
/**
|
|
63
63
|
* Sends messageArray through websocket connection with guaranteed order preservation
|
|
64
64
|
* @async
|
|
65
|
-
* @param {
|
|
66
|
-
* @returns {Promise<
|
|
65
|
+
* @param {Uint8Array} messageArray
|
|
66
|
+
* @returns {Promise<Uint8Array>}
|
|
67
67
|
*/
|
|
68
68
|
send(messageArray) {
|
|
69
69
|
return new Promise((resolve, reject) => {
|
|
@@ -104,8 +104,8 @@ class WebSocketClient {
|
|
|
104
104
|
* Sends a single message through websocket connection
|
|
105
105
|
* @private
|
|
106
106
|
* @async
|
|
107
|
-
* @param {
|
|
108
|
-
* @returns {Promise<
|
|
107
|
+
* @param {Uint8Array} messageArray
|
|
108
|
+
* @returns {Promise<Uint8Array>}
|
|
109
109
|
*/
|
|
110
110
|
_send(messageArray) {
|
|
111
111
|
return new Promise((resolve, reject) => {
|
|
@@ -60,8 +60,8 @@ class WebSocketClientBrowser {
|
|
|
60
60
|
/**
|
|
61
61
|
* Sends messageArray through websocket connection with guaranteed order preservation
|
|
62
62
|
* @async
|
|
63
|
-
* @param {
|
|
64
|
-
* @returns {Promise<
|
|
63
|
+
* @param {Uint8Array} messageArray
|
|
64
|
+
* @returns {Promise<Uint8Array>}
|
|
65
65
|
*/
|
|
66
66
|
send(messageArray) {
|
|
67
67
|
return new Promise((resolve, reject) => {
|
|
@@ -102,8 +102,8 @@ class WebSocketClientBrowser {
|
|
|
102
102
|
* Sends a single message through websocket connection
|
|
103
103
|
* @private
|
|
104
104
|
* @async
|
|
105
|
-
* @param {
|
|
106
|
-
* @returns {Promise<
|
|
105
|
+
* @param {Uint8Array} messageArray
|
|
106
|
+
* @returns {Promise<Uint8Array>}
|
|
107
107
|
*/
|
|
108
108
|
_sendSingle(messageArray) {
|
|
109
109
|
return new Promise((resolve, reject) => {
|
|
@@ -162,8 +162,8 @@ class WebSocketClientBrowser {
|
|
|
162
162
|
* Sends the data to the WebSocket server and listens for a response.
|
|
163
163
|
* @private
|
|
164
164
|
* @param {WebSocket} client
|
|
165
|
-
* @param {
|
|
166
|
-
* @param {(value:
|
|
165
|
+
* @param {Uint8Array} data
|
|
166
|
+
* @param {(value: Uint8Array) => void} resolve
|
|
167
167
|
* @param {(reason?: any) => void} reject
|
|
168
168
|
*/
|
|
169
169
|
_sendMessage(client, data, resolve, reject) {
|
|
@@ -174,7 +174,7 @@ class WebSocketClientBrowser {
|
|
|
174
174
|
if (!message?.data) {
|
|
175
175
|
return reject(new Error("Invalid message received"));
|
|
176
176
|
}
|
|
177
|
-
const byteArray = new
|
|
177
|
+
const byteArray = new Uint8Array(message?.data);
|
|
178
178
|
resolve(byteArray);
|
|
179
179
|
if (this.isDisconnectedAfterMessage) {
|
|
180
180
|
this.disconnect();
|