javonet-nodejs-sdk 2.6.9 → 2.6.11

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (46) hide show
  1. package/dist/core/handler/CreateClassInstanceHandler.cjs +1 -35
  2. package/dist/core/handler/Handler.cjs +38 -22
  3. package/dist/core/handler/InvokeInstanceMethodHandler.cjs +1 -1
  4. package/dist/core/handler/InvokeStaticMethodHandler.cjs +1 -1
  5. package/dist/core/handler/PassDelegateHandler.cjs +13 -5
  6. package/dist/core/handler/RegisterForUpdateHandler.cjs +60 -0
  7. package/dist/core/handler/ValueForUpdateHandler.cjs +36 -0
  8. package/dist/core/interpreter/Interpreter.cjs +4 -13
  9. package/dist/core/protocol/CommandDeserializer.cjs +1 -1
  10. package/dist/core/protocol/CommandSerializer.cjs +5 -5
  11. package/dist/core/receiver/Receiver.cjs +4 -7
  12. package/dist/sdk/InvocationContext.cjs +95 -65
  13. package/dist/sdk/Javonet.cjs +3 -1
  14. package/dist/sdk/RuntimeContext.cjs +30 -12
  15. package/dist/sdk/RuntimeFactory.cjs +0 -22
  16. package/dist/types/core/handler/CreateClassInstanceHandler.d.ts +0 -8
  17. package/dist/types/core/handler/Handler.d.ts +12 -5
  18. package/dist/types/core/handler/PassDelegateHandler.d.ts +0 -5
  19. package/dist/types/core/handler/RegisterForUpdateHandler.d.ts +17 -0
  20. package/dist/types/core/handler/ValueForUpdateHandler.d.ts +7 -0
  21. package/dist/types/core/interpreter/Interpreter.d.ts +2 -7
  22. package/dist/types/core/protocol/CommandSerializer.d.ts +2 -2
  23. package/dist/types/core/receiver/Receiver.d.ts +0 -1
  24. package/dist/types/sdk/InvocationContext.d.ts +1 -5
  25. package/dist/types/sdk/Javonet.d.ts +2 -2
  26. package/dist/types/sdk/RuntimeContext.d.ts +8 -3
  27. package/dist/types/sdk/RuntimeFactory.d.ts +0 -8
  28. package/dist/types/utils/CommandType.d.ts +2 -1
  29. package/dist/utils/CommandType.cjs +2 -1
  30. package/lib/core/handler/CreateClassInstanceHandler.js +1 -46
  31. package/lib/core/handler/Handler.js +47 -28
  32. package/lib/core/handler/InvokeInstanceMethodHandler.js +1 -1
  33. package/lib/core/handler/InvokeStaticMethodHandler.js +1 -1
  34. package/lib/core/handler/PassDelegateHandler.js +3 -7
  35. package/lib/core/handler/RegisterForUpdateHandler.js +40 -0
  36. package/lib/core/handler/ValueForUpdateHandler.js +11 -0
  37. package/lib/core/interpreter/Interpreter.js +4 -14
  38. package/lib/core/protocol/CommandDeserializer.js +1 -1
  39. package/lib/core/protocol/CommandSerializer.js +5 -5
  40. package/lib/core/receiver/Receiver.js +4 -6
  41. package/lib/sdk/InvocationContext.js +114 -79
  42. package/lib/sdk/Javonet.js +2 -1
  43. package/lib/sdk/RuntimeContext.js +43 -14
  44. package/lib/sdk/RuntimeFactory.js +0 -34
  45. package/lib/utils/CommandType.js +2 -1
  46. package/package.json +1 -1
@@ -24,23 +24,9 @@ module.exports = __toCommonJS(CreateClassInstanceHandler_exports);
24
24
  var import_AbstractHandler = require("./AbstractHandler.cjs");
25
25
  class CreateClassInstanceHandler extends import_AbstractHandler.AbstractHandler {
26
26
  requiredParametersCount = 1;
27
- // Add a simple invocation contexts store (Map GUID -> object)
28
- static _invocationContexts = /* @__PURE__ */ new Map();
29
- static getOrCreateContextDictionary() {
30
- return CreateClassInstanceHandler._invocationContexts;
31
- }
32
27
  constructor() {
33
28
  super();
34
29
  }
35
- // Helper to detect GUID in payload (standard format)
36
- /**
37
- * @param {{ toString: () => any; } | null} value
38
- */
39
- static isGuid(value) {
40
- if (value == null) return false;
41
- const s = value.toString();
42
- return /^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$/.test(s);
43
- }
44
30
  /**
45
31
  * @param {Command} command
46
32
  */
@@ -50,23 +36,7 @@ class CreateClassInstanceHandler extends import_AbstractHandler.AbstractHandler
50
36
  throw new Error("Create Class Instance parameters mismatch");
51
37
  }
52
38
  let clazz = command.payload[0];
53
- let payloadLength = command.payload.length;
54
- let contextGuid = null;
55
- let constructorArguments = [];
56
- if (payloadLength > 1 && CreateClassInstanceHandler.isGuid(command.payload[1])) {
57
- contextGuid = command.payload[1].toString();
58
- if (payloadLength > 2) {
59
- constructorArguments = command.payload.slice(2);
60
- } else {
61
- constructorArguments = [];
62
- }
63
- } else {
64
- if (payloadLength > 1) {
65
- constructorArguments = command.payload.slice(1);
66
- } else {
67
- constructorArguments = [];
68
- }
69
- }
39
+ let constructorArguments = command.payload.slice(1);
70
40
  let instance = new clazz(...constructorArguments);
71
41
  if (typeof instance === "undefined") {
72
42
  let methods = Object.getOwnPropertyNames(clazz).filter(function(property) {
@@ -80,10 +50,6 @@ class CreateClassInstanceHandler extends import_AbstractHandler.AbstractHandler
80
50
  });
81
51
  throw new Error(message);
82
52
  } else {
83
- if (contextGuid) {
84
- const contextDict = CreateClassInstanceHandler.getOrCreateContextDictionary();
85
- contextDict.set(contextGuid, instance);
86
- }
87
53
  return instance;
88
54
  }
89
55
  } catch (error) {
@@ -22,6 +22,11 @@ __export(Handler_exports, {
22
22
  handlers: () => handlers
23
23
  });
24
24
  module.exports = __toCommonJS(Handler_exports);
25
+ var import_CommandType = require("../../utils/CommandType.cjs");
26
+ var import_Command = require("../../utils/Command.cjs");
27
+ var import_TypesHandler = require("../../utils/TypesHandler.cjs");
28
+ var import_ExceptionSerializer = require("../../utils/exception/ExceptionSerializer.cjs");
29
+ var import_AbstractHandler = require("./AbstractHandler.cjs");
25
30
  var import_ReferencesCache = require("../referenceCache/ReferencesCache.cjs");
26
31
  var import_ValueHandler = require("./ValueHandler.cjs");
27
32
  var import_LoadLibraryHandler = require("./LoadLibraryHandler.cjs");
@@ -71,11 +76,8 @@ var import_GetAsyncOperationResultHandler = require("./GetAsyncOperationResultHa
71
76
  var import_AsKwargsHandler = require("./AsKwargsHandler.cjs");
72
77
  var import_GetResultTypeHandler = require("./GetResultTypeHandler.cjs");
73
78
  var import_GetGlobalFieldHandler = require("./GetGlobalFieldHandler.cjs");
74
- var import_CommandType = require("../../utils/CommandType.cjs");
75
- var import_Command = require("../../utils/Command.cjs");
76
- var import_TypesHandler = require("../../utils/TypesHandler.cjs");
77
- var import_ExceptionSerializer = require("../../utils/exception/ExceptionSerializer.cjs");
78
- var import_AbstractHandler = require("./AbstractHandler.cjs");
79
+ var import_RegisterForUpdateHandler = require("./RegisterForUpdateHandler.cjs");
80
+ var import_ValueForUpdateHandler = require("./ValueForUpdateHandler.cjs");
79
81
  const handlers = {
80
82
  [import_CommandType.CommandType.Value]: new import_ValueHandler.ValueHandler(),
81
83
  [import_CommandType.CommandType.LoadLibrary]: new import_LoadLibraryHandler.LoadLibraryHandler(),
@@ -124,65 +126,79 @@ const handlers = {
124
126
  [import_CommandType.CommandType.GetAsyncOperationResult]: new import_GetAsyncOperationResultHandler.GetAsyncOperationResultHandler(),
125
127
  [import_CommandType.CommandType.AsKwargs]: new import_AsKwargsHandler.AsKwargsHandler(),
126
128
  [import_CommandType.CommandType.GetResultType]: new import_GetResultTypeHandler.GetResultTypeHandler(),
127
- [import_CommandType.CommandType.GetGlobalField]: new import_GetGlobalFieldHandler.GetGlobalFieldHandler()
129
+ [import_CommandType.CommandType.GetGlobalField]: new import_GetGlobalFieldHandler.GetGlobalFieldHandler(),
130
+ [import_CommandType.CommandType.RegisterForUpdate]: new import_RegisterForUpdateHandler.RegisterForUpdateHandler(),
131
+ [import_CommandType.CommandType.ValueForUpdate]: new import_ValueForUpdateHandler.ValueForUpdateHandler()
128
132
  };
129
133
  class Handler {
134
+ static _initialized = false;
130
135
  /**
131
- * @param {import('../interpreter/Interpreter.js').Interpreter} interpreter
136
+ * Initializes the handlers map. This is called lazily on first use.
132
137
  */
133
- constructor(interpreter) {
134
- this.interpreter = interpreter;
135
- if (!this.interpreter) {
136
- throw new Error("interpreter is undefined in Handler constructor");
138
+ static _initialize() {
139
+ if (Handler._initialized) {
140
+ return;
137
141
  }
138
- handlers[import_CommandType.CommandType.PassDelegate] = new import_PassDelegateHandler.PassDelegateHandler(this.interpreter);
142
+ handlers[import_CommandType.CommandType.PassDelegate] = new import_PassDelegateHandler.PassDelegateHandler();
139
143
  Object.keys(handlers).forEach((commandTypeHandler) => {
140
144
  handlers[commandTypeHandler].handlers = handlers;
141
145
  });
146
+ Handler._initialized = true;
142
147
  }
143
148
  /**
144
149
  * @param {Command} command
145
150
  * @returns {Promise<Command> | Command}
146
151
  */
147
- handleCommand(command) {
152
+ static handleCommand(command) {
153
+ Handler._initialize();
148
154
  try {
149
155
  if (command.commandType === import_CommandType.CommandType.RetrieveArray) {
150
156
  const responseArray = handlers[import_CommandType.CommandType.Reference].handleCommand(command.payload[0]);
151
157
  return import_Command.Command.createArrayResponse(responseArray, command.runtimeName);
152
158
  }
153
159
  const response = handlers[command.commandType].handleCommand(command);
154
- return this.parseCommand(response, command.runtimeName);
160
+ return Handler.parseCommand(response, command.runtimeName);
155
161
  } catch (e) {
156
- return import_ExceptionSerializer.ExceptionSerializer.serializeException(e, command);
162
+ return Handler.resolveException(e, command);
157
163
  }
158
164
  }
165
+ /**
166
+ * Prefer innerException (or cause) when available.
167
+ * @param {any} error
168
+ * @param {Command} command
169
+ * @returns {Command}
170
+ */
171
+ static resolveException(error, command) {
172
+ const inner = error?.cause;
173
+ return import_ExceptionSerializer.ExceptionSerializer.serializeException(inner ?? error, command);
174
+ }
159
175
  /**
160
176
  * @param {any} response
161
177
  * @param {RuntimeName} runtimeName
162
178
  * @returns {Promise<Command> | Command}
163
179
  */
164
- parseCommand(response, runtimeName) {
180
+ static parseCommand(response, runtimeName) {
165
181
  if (response instanceof Promise) {
166
182
  return response.then((resolvedResponse) => {
167
- return this.parseCommand(resolvedResponse, runtimeName);
183
+ return Handler.parseCommand(resolvedResponse, runtimeName);
168
184
  });
169
185
  }
170
186
  let responseCommand;
171
187
  if (import_TypesHandler.TypesHandler.isPrimitiveOrNullOrUndefined(response)) {
172
188
  responseCommand = import_Command.Command.createResponse(response, runtimeName);
173
189
  } else {
174
- let cache = import_ReferencesCache.ReferencesCache.getInstance();
175
- let uuid = cache.cacheReference(response);
190
+ const refCache = import_ReferencesCache.ReferencesCache.getInstance();
191
+ const uuid = refCache.cacheReference(response);
176
192
  responseCommand = import_Command.Command.createReference(uuid, runtimeName);
177
193
  }
178
- const invocationContexts = import_CreateClassInstanceHandler.CreateClassInstanceHandler._invocationContexts;
179
- if (invocationContexts && typeof invocationContexts.size === "number" && invocationContexts.size > 0) {
194
+ const invocationContexts = import_RegisterForUpdateHandler.RegisterForUpdateHandler._invocationContexts.Value;
195
+ if (invocationContexts && invocationContexts.size > 0) {
180
196
  const refCache = import_ReferencesCache.ReferencesCache.getInstance();
181
197
  for (const [contextKey, instance] of invocationContexts.entries()) {
182
198
  const instanceGuid = refCache.cacheReference(instance);
183
199
  const updateContextCommand = new import_Command.Command(
184
200
  runtimeName,
185
- import_CommandType.CommandType.UpdateInvocationContext,
201
+ import_CommandType.CommandType.ValueForUpdate,
186
202
  [
187
203
  contextKey.toString(),
188
204
  instanceGuid
@@ -44,7 +44,7 @@ class InvokeInstanceMethodHandler extends import_AbstractHandler.AbstractHandler
44
44
  let methods = Object.getOwnPropertyNames(instance.__proto__).filter(function(property) {
45
45
  return typeof instance.__proto__[property] === "function";
46
46
  });
47
- let message = `Method ${methodName} not found in object. Available methods:
47
+ let message = `Method ${methodName} not found in object ${instance.constructor.name}. Available methods:
48
48
  `;
49
49
  methods.forEach((methodIter) => {
50
50
  message += `${methodIter}
@@ -44,7 +44,7 @@ class InvokeStaticMethodHandler extends import_AbstractHandler.AbstractHandler {
44
44
  let methods = Object.getOwnPropertyNames(type).filter(function(property) {
45
45
  return typeof type[property] === "function";
46
46
  });
47
- let message = `Method ${methodName} not found in class. Available methods:
47
+ let message = `Method ${methodName} not found in class ${type.name}. Available methods:
48
48
  `;
49
49
  methods.forEach((methodIter) => {
50
50
  message += `${methodIter}
@@ -1,7 +1,9 @@
1
1
  "use strict";
2
+ var __create = Object.create;
2
3
  var __defProp = Object.defineProperty;
3
4
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
5
  var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
5
7
  var __hasOwnProp = Object.prototype.hasOwnProperty;
6
8
  var __export = (target, all) => {
7
9
  for (var name in all)
@@ -15,6 +17,14 @@ var __copyProps = (to, from, except, desc) => {
15
17
  }
16
18
  return to;
17
19
  };
20
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
+ // If the importer is in node compatibility mode or this is not an ESM
22
+ // file that has been converted to a CommonJS file using a Babel-
23
+ // compatible transform (i.e. "__esModule" has not been set), then set
24
+ // "default" to the CommonJS "module.exports" for node compatibility.
25
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
+ mod
27
+ ));
18
28
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
29
  var PassDelegateHandler_exports = {};
20
30
  __export(PassDelegateHandler_exports, {
@@ -26,12 +36,9 @@ var import_InMemoryConnectionData = require("../../utils/connectionData/InMemory
26
36
  var import_DelegatesCache = require("../delegatesCache/DelegatesCache.cjs");
27
37
  var import_AbstractHandler = require("./AbstractHandler.cjs");
28
38
  class PassDelegateHandler extends import_AbstractHandler.AbstractHandler {
29
- /** @type {Interpreter | null | undefined} */
30
- interpreter = null;
31
- constructor(interpreter = null) {
39
+ constructor() {
32
40
  super();
33
41
  this.requiredParametersCount = 1;
34
- this.interpreter = interpreter;
35
42
  }
36
43
  /**S
37
44
  * Processes the given command to create and compile a delegate.
@@ -113,7 +120,8 @@ class PassDelegateHandler extends import_AbstractHandler.AbstractHandler {
113
120
  * @returns {Promise<any>} The response object.
114
121
  */
115
122
  async createExecuteCall(command) {
116
- return this.interpreter?.execute(command, new import_InMemoryConnectionData.InMemoryConnectionData());
123
+ const { Interpreter } = await import("../interpreter/Interpreter.js");
124
+ return Interpreter.execute(command, new import_InMemoryConnectionData.InMemoryConnectionData());
117
125
  }
118
126
  /**
119
127
  * Retrieves the response payload from the execution call.
@@ -0,0 +1,60 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+ var RegisterForUpdateHandler_exports = {};
20
+ __export(RegisterForUpdateHandler_exports, {
21
+ RegisterForUpdateHandler: () => RegisterForUpdateHandler
22
+ });
23
+ module.exports = __toCommonJS(RegisterForUpdateHandler_exports);
24
+ var import_AbstractHandler = require("./AbstractHandler.cjs");
25
+ class RegisterForUpdateHandler extends import_AbstractHandler.AbstractHandler {
26
+ requiredParametersCount = 2;
27
+ /* type {Map<string, any>} */
28
+ static _invocationContexts = { Value: /* @__PURE__ */ new Map() };
29
+ /**
30
+ * Ensure context map exists and return it.
31
+ * @returns {Map<string, any>}
32
+ */
33
+ static getOrCreateContextMap() {
34
+ const container = RegisterForUpdateHandler._invocationContexts;
35
+ if (!container.Value) {
36
+ container.Value = /* @__PURE__ */ new Map();
37
+ }
38
+ return container.Value;
39
+ }
40
+ /**
41
+ * @param {any} command
42
+ * @returns {any}
43
+ */
44
+ process(command) {
45
+ if (command.payload.length < this.requiredParametersCount) {
46
+ throw new Error("RegisterForUpdateHandler parameters mismatch");
47
+ }
48
+ const objectToRegister = command.payload[0];
49
+ const guidToRegister = command.payload.length > 1 && typeof command.payload[1] === "string" ? command.payload[1] : "";
50
+ const contextMap = RegisterForUpdateHandler.getOrCreateContextMap();
51
+ if (!contextMap.has(guidToRegister)) {
52
+ contextMap.set(guidToRegister, objectToRegister);
53
+ }
54
+ return objectToRegister;
55
+ }
56
+ }
57
+ // Annotate the CommonJS export names for ESM import in node:
58
+ 0 && (module.exports = {
59
+ RegisterForUpdateHandler
60
+ });
@@ -0,0 +1,36 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+ var ValueForUpdateHandler_exports = {};
20
+ __export(ValueForUpdateHandler_exports, {
21
+ ValueForUpdateHandler: () => ValueForUpdateHandler
22
+ });
23
+ module.exports = __toCommonJS(ValueForUpdateHandler_exports);
24
+ var import_AbstractHandler = require("./AbstractHandler.cjs");
25
+ class ValueForUpdateHandler extends import_AbstractHandler.AbstractHandler {
26
+ /**
27
+ * @param {any} command
28
+ */
29
+ process(command) {
30
+ throw new Error(`${this.constructor.name} is not implemented in Node.js`);
31
+ }
32
+ }
33
+ // Annotate the CommonJS export names for ESM import in node:
34
+ 0 && (module.exports = {
35
+ ValueForUpdateHandler
36
+ });
@@ -35,24 +35,15 @@ let _Transmitter;
35
35
  let _TransmitterWebsocket = (0, import_Runtime.isNodejsRuntime)() ? import_TransmitterWebsocket.TransmitterWebsocket : import_TransmitterWebsocketBrowser.TransmitterWebsocketBrowser;
36
36
  const requireDynamic = (0, import_Runtime.getRequire)(import_meta.url);
37
37
  class Interpreter {
38
- /** @type {Handler | null} */
39
- _handler = null;
40
- /** @type {Handler} */
41
- get handler() {
42
- if (!this._handler) {
43
- this._handler = new import_Handler.Handler(this);
44
- }
45
- return this._handler;
46
- }
47
38
  /**
48
39
  *
49
40
  * @param {Command} command
50
41
  * @param {IConnectionData} connectionData
51
42
  * @returns {Promise<Command>}
52
43
  */
53
- async execute(command, connectionData) {
44
+ static async execute(command, connectionData) {
54
45
  try {
55
- let messageByteArray = new import_CommandSerializer.CommandSerializer().serialize(command, connectionData);
46
+ let messageByteArray = import_CommandSerializer.CommandSerializer.serialize(command, connectionData);
56
47
  if (!(messageByteArray instanceof Uint8Array)) {
57
48
  throw new Error("Serialized message is not Uint8Array");
58
49
  }
@@ -96,10 +87,10 @@ class Interpreter {
96
87
  * @param {Uint8Array} messageByteArray
97
88
  * @returns {Promise<Command> | Command}
98
89
  */
99
- process(messageByteArray) {
90
+ static process(messageByteArray) {
100
91
  try {
101
92
  const receivedCommand = new import_CommandDeserializer.CommandDeserializer(messageByteArray).deserialize();
102
- return this.handler?.handleCommand(receivedCommand);
93
+ return import_Handler.Handler.handleCommand(receivedCommand);
103
94
  } catch (error) {
104
95
  throw error;
105
96
  }
@@ -73,7 +73,7 @@ class CommandDeserializer {
73
73
  case "JAVONET_DOUBLE":
74
74
  return this.readDouble();
75
75
  case "JAVONET_UNSIGNED_LONG_LONG":
76
- return this.readUllong;
76
+ return this.readUllong();
77
77
  case "JAVONET_UNSIGNED_INTEGER":
78
78
  return this.readUInt();
79
79
  case "JAVONET_NULL":
@@ -35,7 +35,7 @@ class CommandSerializer {
35
35
  * @param {number} runtimeVersion
36
36
  * @returns {Uint8Array}
37
37
  */
38
- serialize(rootCommand, connectionData, runtimeVersion = 0) {
38
+ static serialize(rootCommand, connectionData, runtimeVersion = 0) {
39
39
  const buffers = [];
40
40
  buffers.push(Uint8Array.of(rootCommand.runtimeName, runtimeVersion));
41
41
  if (connectionData) {
@@ -44,7 +44,7 @@ class CommandSerializer {
44
44
  buffers.push(Uint8Array.of(0, 0, 0, 0, 0, 0, 0));
45
45
  }
46
46
  buffers.push(Uint8Array.of(import_RuntimeName.RuntimeName.Python, rootCommand.commandType));
47
- this.serializeRecursively(rootCommand, buffers);
47
+ CommandSerializer.serializeRecursively(rootCommand, buffers);
48
48
  return concatenateUint8Arrays(buffers);
49
49
  }
50
50
  /**
@@ -52,18 +52,18 @@ class CommandSerializer {
52
52
  * @param {Command} command
53
53
  * @param {Array<Uint8Array>} buffers
54
54
  */
55
- serializeRecursively(command, buffers) {
55
+ static serializeRecursively(command, buffers) {
56
56
  for (const item of command.payload) {
57
57
  if (item instanceof import_Command.Command) {
58
58
  buffers.push(import_TypeSerializer.TypeSerializer.serializeCommand(item));
59
- this.serializeRecursively(item, buffers);
59
+ CommandSerializer.serializeRecursively(item, buffers);
60
60
  } else if (import_TypesHandler.TypesHandler.isPrimitiveOrNullOrUndefined(item)) {
61
61
  buffers.push(import_TypeSerializer.TypeSerializer.serializePrimitive(item));
62
62
  } else {
63
63
  const cachedReference = import_ReferencesCache.ReferencesCache.getInstance().cacheReference(item);
64
64
  const refCommand = new import_Command.Command(import_RuntimeName.RuntimeName.Nodejs, import_CommandType.CommandType.Reference, cachedReference);
65
65
  buffers.push(import_TypeSerializer.TypeSerializer.serializeCommand(refCommand));
66
- this.serializeRecursively(refCommand, buffers);
66
+ CommandSerializer.serializeRecursively(refCommand, buffers);
67
67
  }
68
68
  }
69
69
  }
@@ -21,19 +21,16 @@ __export(Receiver_exports, {
21
21
  Receiver: () => Receiver
22
22
  });
23
23
  module.exports = __toCommonJS(Receiver_exports);
24
- var import_Interpreter = require("../interpreter/Interpreter.cjs");
25
24
  var import_CommandSerializer = require("../protocol/CommandSerializer.cjs");
26
- var import_Runtime = require("../../utils/Runtime.cjs");
27
25
  var import_InMemoryConnectionData = require("../../utils/connectionData/InMemoryConnectionData.cjs");
28
26
  var import_ExceptionSerializer = require("../../utils/exception/ExceptionSerializer.cjs");
29
27
  var import_Command = require("../../utils/Command.cjs");
30
28
  var import_CommandType = require("../../utils/CommandType.cjs");
31
29
  var import_RuntimeName = require("../../utils/RuntimeName.cjs");
32
30
  var import_RuntimeLogger = require("../../utils/RuntimeLogger.cjs");
31
+ var import_Interpreter = require("./../interpreter/Interpreter.cjs");
33
32
  class Receiver {
34
33
  static connectionData = new import_InMemoryConnectionData.InMemoryConnectionData();
35
- Receiver() {
36
- }
37
34
  static getRuntimeInfo() {
38
35
  return import_RuntimeLogger.RuntimeLogger.getRuntimeInfo();
39
36
  }
@@ -43,14 +40,14 @@ class Receiver {
43
40
  */
44
41
  static async sendCommand(messageByteArray) {
45
42
  try {
46
- let command = await new import_Interpreter.Interpreter().process(messageByteArray);
47
- return new import_CommandSerializer.CommandSerializer().serialize(command, this.connectionData);
43
+ let command = await import_Interpreter.Interpreter.process(messageByteArray);
44
+ return import_CommandSerializer.CommandSerializer.serialize(command, this.connectionData);
48
45
  } catch (error) {
49
46
  const exceptionCommand = import_ExceptionSerializer.ExceptionSerializer.serializeException(
50
47
  error,
51
48
  new import_Command.Command(import_RuntimeName.RuntimeName.Nodejs, import_CommandType.CommandType.Exception, [])
52
49
  );
53
- return new import_CommandSerializer.CommandSerializer().serialize(exceptionCommand, this.connectionData);
50
+ return import_CommandSerializer.CommandSerializer.serialize(exceptionCommand, this.connectionData);
54
51
  }
55
52
  }
56
53
  /**