javonet-nodejs-sdk 2.5.20 → 2.6.1

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.
@@ -107,8 +107,8 @@ class Handler {
107
107
  }
108
108
  let response = handlers[command.commandType].handleCommand(command);
109
109
  return this.parseCommand(response, command.runtimeName);
110
- } catch (error) {
111
- return import_ExceptionSerializer.ExceptionSerializer.serializeException(error, command);
110
+ } catch (e) {
111
+ return import_ExceptionSerializer.ExceptionSerializer.serializeException(e, command);
112
112
  }
113
113
  }
114
114
  /**
@@ -23,6 +23,9 @@ __export(ResolveReferenceHandler_exports, {
23
23
  module.exports = __toCommonJS(ResolveReferenceHandler_exports);
24
24
  var import_ReferencesCache = require("../referenceCache/ReferencesCache.cjs");
25
25
  var import_AbstractHandler = require("./AbstractHandler.cjs");
26
+ var import_CommandType = require("../../utils/CommandType.cjs");
27
+ var import_RuntimeName = require("../../utils/RuntimeName.cjs");
28
+ var import_Command = require("../../utils/Command.cjs");
26
29
  class ResolveReferenceHandler extends import_AbstractHandler.AbstractHandler {
27
30
  constructor() {
28
31
  super();
@@ -32,7 +35,11 @@ class ResolveReferenceHandler extends import_AbstractHandler.AbstractHandler {
32
35
  * @returns {any}
33
36
  */
34
37
  process(command) {
35
- return import_ReferencesCache.ReferencesCache.getInstance().resolveReference(command.payload[0]);
38
+ if (command.runtimeName === import_RuntimeName.RuntimeName.Nodejs) {
39
+ return import_ReferencesCache.ReferencesCache.getInstance().resolveReference(command.payload[0]);
40
+ } else {
41
+ return new import_Command.Command(command.runtimeName, import_CommandType.CommandType.Reference, command.payload[0]);
42
+ }
36
43
  }
37
44
  }
38
45
  // Annotate the CommonJS export names for ESM import in node:
@@ -39,7 +39,14 @@ if (!_TransmitterWebsocket) {
39
39
  const requireDynamic = (0, import_Runtime.getRequire)(import_meta.url);
40
40
  class Interpreter {
41
41
  /** @type {Handler | null} */
42
- handler = null;
42
+ _handler = null;
43
+ /** @type {Handler} */
44
+ get handler() {
45
+ if (!this._handler) {
46
+ this._handler = new import_Handler.Handler(this);
47
+ }
48
+ return this._handler;
49
+ }
43
50
  /**
44
51
  *
45
52
  * @param {Command} command
@@ -48,45 +55,32 @@ class Interpreter {
48
55
  */
49
56
  async executeAsync(command, connectionData) {
50
57
  try {
51
- if (!this.handler) {
52
- this.handler = new import_Handler.Handler(this);
53
- }
54
58
  let messageByteArray = new import_CommandSerializer.CommandSerializer().serialize(command, connectionData);
55
59
  let responseByteArray = void 0;
56
- if (command.runtimeName === import_RuntimeName.RuntimeName.Nodejs && connectionData.connectionType === import_ConnectionType.ConnectionType.IN_MEMORY) {
57
- if ((0, import_Runtime.isNodejsRuntime)()) {
60
+ if (connectionData.connectionType === import_ConnectionType.ConnectionType.WEB_SOCKET) {
61
+ const _response = await _TransmitterWebsocket?.sendCommand(messageByteArray, connectionData);
62
+ if (_response) {
63
+ const command2 = new import_CommandDeserializer.CommandDeserializer(_response).deserialize();
64
+ return command2;
65
+ } else {
66
+ throw new Error("Response not received from TransmitterWebsocket");
67
+ }
68
+ } else {
69
+ if (!(0, import_Runtime.isNodejsRuntime)()) {
70
+ throw new Error("InMemory is only allowed in Nodejs runtime");
71
+ }
72
+ if (command.runtimeName === import_RuntimeName.RuntimeName.Nodejs) {
58
73
  if (!_Receiver) {
59
74
  const { Receiver } = require("../receiver/Receiver.cjs");
60
75
  _Receiver = Receiver;
61
76
  }
62
- responseByteArray = _Receiver?.sendCommand(messageByteArray);
77
+ responseByteArray = await _Receiver?.sendCommand(messageByteArray);
63
78
  } else {
64
- throw new Error("Node.js runtime not found");
65
- }
66
- } else if (connectionData.connectionType === import_ConnectionType.ConnectionType.WEB_SOCKET) {
67
- try {
68
- const _response = await _TransmitterWebsocket?.sendCommand(
69
- messageByteArray,
70
- connectionData
71
- );
72
- if (_response) {
73
- const command2 = new import_CommandDeserializer.CommandDeserializer(_response).deserialize();
74
- return command2;
75
- } else {
76
- throw new Error("Response not received from TransmitterWebsocket");
77
- }
78
- } catch (error) {
79
- throw error;
80
- }
81
- } else {
82
- if ((0, import_Runtime.isNodejsRuntime)()) {
83
79
  if (!_Transmitter) {
84
80
  const { Transmitter } = require("../transmitter/Transmitter.cjs");
85
81
  _Transmitter = Transmitter;
86
82
  }
87
83
  responseByteArray = await _Transmitter?.sendCommand(messageByteArray);
88
- } else {
89
- throw new Error("Allowed only to run in nodejs runtime");
90
84
  }
91
85
  }
92
86
  if (!responseByteArray) {
@@ -105,43 +99,27 @@ class Interpreter {
105
99
  */
106
100
  execute(command, connectionData) {
107
101
  try {
108
- if (!this.handler) {
109
- this.handler = new import_Handler.Handler(this);
110
- }
111
102
  let messageByteArray = new import_CommandSerializer.CommandSerializer().serialize(command, connectionData);
112
103
  let responseByteArray = void 0;
113
- if (command.runtimeName === import_RuntimeName.RuntimeName.Nodejs && connectionData.connectionType === import_ConnectionType.ConnectionType.IN_MEMORY) {
114
- if ((0, import_Runtime.isNodejsRuntime)()) {
104
+ if (connectionData.connectionType === import_ConnectionType.ConnectionType.WEB_SOCKET) {
105
+ throw new Error("Not supported");
106
+ }
107
+ if (connectionData.connectionType === import_ConnectionType.ConnectionType.IN_MEMORY) {
108
+ if (!(0, import_Runtime.isNodejsRuntime)()) {
109
+ throw new Error("InMemory is only allowed in Nodejs runtime");
110
+ }
111
+ if (command.runtimeName === import_RuntimeName.RuntimeName.Nodejs) {
115
112
  if (!_Receiver) {
116
113
  const { Receiver } = require("../receiver/Receiver.cjs");
117
114
  _Receiver = Receiver;
118
115
  }
119
116
  responseByteArray = _Receiver?.sendCommand(messageByteArray);
120
- }
121
- } else if (connectionData.connectionType === import_ConnectionType.ConnectionType.WEB_SOCKET) {
122
- const promise = _TransmitterWebsocket?.sendCommand(messageByteArray, connectionData);
123
- if (!promise) {
124
- throw new Error("TransmitterWebsocket not found");
125
- }
126
- return promise.then((_response) => {
127
- if (_response) {
128
- const command2 = new import_CommandDeserializer.CommandDeserializer(_response).deserialize();
129
- return command2;
130
- } else {
131
- throw new Error("Response not received from TransmitterWebsocket");
132
- }
133
- }).catch((error) => {
134
- throw error;
135
- });
136
- } else {
137
- if ((0, import_Runtime.isNodejsRuntime)()) {
117
+ } else {
138
118
  if (!_Transmitter) {
139
119
  const { Transmitter } = require("../transmitter/Transmitter.cjs");
140
120
  _Transmitter = Transmitter;
141
121
  }
142
122
  responseByteArray = _Transmitter?.sendCommand(messageByteArray);
143
- } else {
144
- throw new Error("Allowed only to run in nodejs runtime");
145
123
  }
146
124
  }
147
125
  if (!responseByteArray) {
@@ -159,9 +137,6 @@ class Interpreter {
159
137
  */
160
138
  process(messageByteArray) {
161
139
  try {
162
- if (!this.handler) {
163
- this.handler = new import_Handler.Handler(this);
164
- }
165
140
  const receivedCommand = new import_CommandDeserializer.CommandDeserializer(messageByteArray).deserialize();
166
141
  return this.handler?.handleCommand(receivedCommand);
167
142
  } catch (error) {
@@ -25,26 +25,34 @@ var import_Interpreter = require("../interpreter/Interpreter.cjs");
25
25
  var import_CommandSerializer = require("../protocol/CommandSerializer.cjs");
26
26
  var import_Runtime = require("../../utils/Runtime.cjs");
27
27
  var import_InMemoryConnectionData = require("../../utils/connectionData/InMemoryConnectionData.cjs");
28
- const import_meta = {};
29
- let _RuntimeLogger = null;
30
- const requireDynamic = (0, import_Runtime.getRequire)(import_meta.url);
28
+ var import_ExceptionSerializer = require("../../utils/exception/ExceptionSerializer.cjs");
29
+ var import_Command = require("../../utils/Command.cjs");
30
+ var import_CommandType = require("../../utils/CommandType.cjs");
31
+ var import_RuntimeName = require("../../utils/RuntimeName.cjs");
32
+ var import_RuntimeLogger = require("../../utils/RuntimeLogger.cjs");
31
33
  class Receiver {
32
34
  static connectionData = new import_InMemoryConnectionData.InMemoryConnectionData();
33
35
  Receiver() {
34
- if (!_RuntimeLogger) {
35
- const { RuntimeLogger } = require("../../utils/RuntimeLogger.cjs");
36
- _RuntimeLogger = RuntimeLogger;
37
- }
38
- _RuntimeLogger?.printRuntimeInfo();
36
+ }
37
+ static getRuntimeInfo() {
38
+ return import_RuntimeLogger.RuntimeLogger.getRuntimeInfo();
39
39
  }
40
40
  /**
41
41
  * @param {Int8Array} messageByteArray
42
42
  */
43
43
  static sendCommand(messageByteArray) {
44
- return new import_CommandSerializer.CommandSerializer().serialize(
45
- new import_Interpreter.Interpreter().process(messageByteArray),
46
- this.connectionData
47
- );
44
+ try {
45
+ return new import_CommandSerializer.CommandSerializer().serialize(
46
+ new import_Interpreter.Interpreter().process(messageByteArray),
47
+ this.connectionData
48
+ );
49
+ } catch (error) {
50
+ const exceptionCommand = import_ExceptionSerializer.ExceptionSerializer.serializeException(
51
+ error,
52
+ new import_Command.Command(import_RuntimeName.RuntimeName.Nodejs, import_CommandType.CommandType.Exception, [])
53
+ );
54
+ return new import_CommandSerializer.CommandSerializer().serialize(exceptionCommand, this.connectionData);
55
+ }
48
56
  }
49
57
  /**
50
58
  * @param {Int8Array} messageByteArray
@@ -19,7 +19,9 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
19
19
  var WebSocketClient_exports = {};
20
20
  __export(WebSocketClient_exports, {
21
21
  WebSocketClient: () => WebSocketClient,
22
- clients: () => clients
22
+ clients: () => clients,
23
+ messageQueue: () => messageQueue,
24
+ processingQueues: () => processingQueues
23
25
  });
24
26
  module.exports = __toCommonJS(WebSocketClient_exports);
25
27
  var import_Runtime = require("../../utils/Runtime.cjs");
@@ -39,6 +41,8 @@ const WebSocketStateEvent = {
39
41
  };
40
42
  let WebSocket = null;
41
43
  const clients = {};
44
+ const messageQueue = {};
45
+ const processingQueues = {};
42
46
  class WebSocketClient {
43
47
  /**
44
48
  * @param {string} url
@@ -56,15 +60,57 @@ class WebSocketClient {
56
60
  return this.instance ? this.instance?.readyState === WebSocketStateEnum.OPEN : false;
57
61
  }
58
62
  /**
59
- * Sends messageArray through websocket connection
63
+ * Sends messageArray through websocket connection with guaranteed order preservation
60
64
  * @async
61
65
  * @param {Int8Array} messageArray
62
66
  * @returns {Promise<Int8Array>}
63
67
  */
64
68
  send(messageArray) {
69
+ return new Promise((resolve, reject) => {
70
+ if (!messageQueue[this.url]) {
71
+ messageQueue[this.url] = [];
72
+ }
73
+ messageQueue[this.url].push({ resolve, reject, messageArray });
74
+ this._processMessage();
75
+ });
76
+ }
77
+ /**
78
+ * Processes message queue sequentially to maintain order
79
+ * @private
80
+ * @async
81
+ */
82
+ async _processMessage() {
83
+ if (processingQueues[this.url]) {
84
+ return;
85
+ }
86
+ processingQueues[this.url] = true;
87
+ try {
88
+ while (messageQueue[this.url] && messageQueue[this.url].length > 0) {
89
+ const item = messageQueue[this.url].shift();
90
+ if (!item) break;
91
+ const { resolve, reject, messageArray } = item;
92
+ try {
93
+ const response = await this._send(messageArray);
94
+ resolve(response);
95
+ } catch (error) {
96
+ reject(error);
97
+ }
98
+ }
99
+ } finally {
100
+ processingQueues[this.url] = false;
101
+ }
102
+ }
103
+ /**
104
+ * Sends a single message through websocket connection
105
+ * @private
106
+ * @async
107
+ * @param {Int8Array} messageArray
108
+ * @returns {Promise<Int8Array>}
109
+ */
110
+ _send(messageArray) {
65
111
  return new Promise((resolve, reject) => {
66
112
  const client = this.instance;
67
- if (client) {
113
+ if (client && this.isConnected) {
68
114
  client.send(
69
115
  /** @type {any} */
70
116
  messageArray
@@ -78,8 +124,8 @@ class WebSocketClient {
78
124
  };
79
125
  client.on(WebSocketStateEvent.MESSAGE, messageHandler);
80
126
  } else {
81
- this._connect().then((ws) => {
82
- ws.send(
127
+ this._connect().then((client2) => {
128
+ client2.send(
83
129
  /** @type {any} */
84
130
  messageArray
85
131
  );
@@ -88,21 +134,28 @@ class WebSocketClient {
88
134
  if (this.isDisconnectedAfterMessage) {
89
135
  this.disconnect();
90
136
  }
91
- ws.removeListener(WebSocketStateEvent.MESSAGE, messageHandler);
137
+ client2.removeListener(WebSocketStateEvent.MESSAGE, messageHandler);
92
138
  };
93
- ws.on(WebSocketStateEvent.MESSAGE, messageHandler);
139
+ client2.on(WebSocketStateEvent.MESSAGE, messageHandler);
94
140
  }).catch(reject);
95
141
  }
96
142
  });
97
143
  }
98
144
  /**
99
- * Disconnects the WebSocket by terminating the connection.
145
+ * Disconnects the WebSocket by terminating the connection and cleans up queues.
100
146
  */
101
147
  disconnect() {
102
148
  if (this.instance) {
103
149
  this.instance.close();
104
150
  delete clients[this.url];
105
151
  }
152
+ if (messageQueue[this.url]) {
153
+ messageQueue[this.url].forEach(({ reject }) => {
154
+ reject(new Error("WebSocket disconnected"));
155
+ });
156
+ delete messageQueue[this.url];
157
+ }
158
+ delete processingQueues[this.url];
106
159
  }
107
160
  /**
108
161
  * Connects to the WebSocket server.
@@ -144,5 +197,7 @@ class WebSocketClient {
144
197
  // Annotate the CommonJS export names for ESM import in node:
145
198
  0 && (module.exports = {
146
199
  WebSocketClient,
147
- clients
200
+ clients,
201
+ messageQueue,
202
+ processingQueues
148
203
  });
@@ -19,7 +19,9 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
19
19
  var WebSocketClientBrowser_exports = {};
20
20
  __export(WebSocketClientBrowser_exports, {
21
21
  WebSocketClientBrowser: () => WebSocketClientBrowser,
22
- clients: () => clients
22
+ clients: () => clients,
23
+ messageQueue: () => messageQueue,
24
+ processingQueues: () => processingQueues
23
25
  });
24
26
  module.exports = __toCommonJS(WebSocketClientBrowser_exports);
25
27
  var import_Runtime = require("../../utils/Runtime.cjs");
@@ -37,6 +39,8 @@ if ((0, import_Runtime.isBrowserRuntime)()) {
37
39
  WsClient = WebSocket;
38
40
  }
39
41
  const clients = {};
42
+ const messageQueue = {};
43
+ const processingQueues = {};
40
44
  class WebSocketClientBrowser {
41
45
  /**
42
46
  * @param {string} url
@@ -54,12 +58,54 @@ class WebSocketClientBrowser {
54
58
  return this.instance ? this.instance.readyState === WebSocket.OPEN : false;
55
59
  }
56
60
  /**
57
- * Sends messageArray through websocket connection
61
+ * Sends messageArray through websocket connection with guaranteed order preservation
58
62
  * @async
59
63
  * @param {Int8Array} messageArray
60
64
  * @returns {Promise<Int8Array>}
61
65
  */
62
66
  send(messageArray) {
67
+ return new Promise((resolve, reject) => {
68
+ if (!messageQueue[this.url]) {
69
+ messageQueue[this.url] = [];
70
+ }
71
+ messageQueue[this.url].push({ resolve, reject, messageArray });
72
+ this._processMessage();
73
+ });
74
+ }
75
+ /**
76
+ * Processes message queue sequentially to maintain order
77
+ * @private
78
+ * @async
79
+ */
80
+ async _processMessage() {
81
+ if (processingQueues[this.url]) {
82
+ return;
83
+ }
84
+ processingQueues[this.url] = true;
85
+ try {
86
+ while (messageQueue[this.url] && messageQueue[this.url].length > 0) {
87
+ const item = messageQueue[this.url].shift();
88
+ if (!item) break;
89
+ const { resolve, reject, messageArray } = item;
90
+ try {
91
+ const response = await this._sendSingle(messageArray);
92
+ resolve(response);
93
+ } catch (error) {
94
+ reject(error);
95
+ }
96
+ }
97
+ } finally {
98
+ processingQueues[this.url] = false;
99
+ }
100
+ }
101
+ /**
102
+ * Sends a single message through websocket connection
103
+ * @private
104
+ * @async
105
+ * @param {Int8Array} messageArray
106
+ * @returns {Promise<Int8Array>}
107
+ */
108
+ _sendSingle(messageArray) {
63
109
  return new Promise((resolve, reject) => {
64
110
  const client = this.instance;
65
111
  if (client && this.isConnected) {
@@ -72,7 +118,7 @@ class WebSocketClientBrowser {
72
118
  });
73
119
  }
74
120
  /**
75
- * Disconnects the WebSocket by terminating the connection.
121
+ * Disconnects the WebSocket by terminating the connection and cleans up queues.
76
122
  */
77
123
  disconnect() {
78
124
  const client = this.instance;
@@ -80,6 +126,13 @@ class WebSocketClientBrowser {
80
126
  client.close();
81
127
  delete clients[this.url];
82
128
  }
129
+ if (messageQueue[this.url]) {
130
+ messageQueue[this.url].forEach(({ reject }) => {
131
+ reject(new Error("WebSocket disconnected"));
132
+ });
133
+ delete messageQueue[this.url];
134
+ }
135
+ delete processingQueues[this.url];
83
136
  }
84
137
  /**
85
138
  * Connects to the WebSocket server.
@@ -144,5 +197,7 @@ class WebSocketClientBrowser {
144
197
  // Annotate the CommonJS export names for ESM import in node:
145
198
  0 && (module.exports = {
146
199
  WebSocketClientBrowser,
147
- clients
200
+ clients,
201
+ messageQueue,
202
+ processingQueues
148
203
  });
@@ -123,7 +123,9 @@ class InvocationContext {
123
123
  if (this.#currentCommand === null) {
124
124
  throw new Error("currentCommand is undefined in Invocation Context execute method");
125
125
  }
126
- this.#interpreter = new import_Interpreter.Interpreter();
126
+ if (!this.#interpreter) {
127
+ this.#interpreter = new import_Interpreter.Interpreter();
128
+ }
127
129
  this.#responseCommand = this.#interpreter.execute(this.#currentCommand, this.#connectionData);
128
130
  if (!this.#responseCommand) {
129
131
  throw new Error("responseCommand is undefined in Invocation Context execute method");
@@ -495,7 +497,9 @@ class InvocationWsContext extends InvocationContext {
495
497
  if (this.#currentCommand === null) {
496
498
  throw new Error("currentCommand is undefined in Invocation Context execute method");
497
499
  }
498
- this.#interpreter = new import_Interpreter.Interpreter();
500
+ if (!this.#interpreter) {
501
+ this.#interpreter = new import_Interpreter.Interpreter();
502
+ }
499
503
  this.#responseCommand = await this.#interpreter.executeAsync(
500
504
  this.#currentCommand,
501
505
  this.#connectionData
@@ -1,7 +1,3 @@
1
- export type Command = import("../../utils/Command.js").Command;
2
- /**
3
- * @typedef {import('../../utils/Command.js').Command} Command
4
- */
5
1
  export class ResolveReferenceHandler extends AbstractHandler {
6
2
  /**
7
3
  * @param {Command} command
@@ -10,3 +6,4 @@ export class ResolveReferenceHandler extends AbstractHandler {
10
6
  process(command: Command): any;
11
7
  }
12
8
  import { AbstractHandler } from './AbstractHandler.js';
9
+ import { Command } from '../../utils/Command.js';
@@ -1,6 +1,8 @@
1
1
  export class Interpreter {
2
2
  /** @type {Handler | null} */
3
- handler: Handler | null;
3
+ _handler: Handler | null;
4
+ /** @type {Handler} */
5
+ get handler(): Handler;
4
6
  /**
5
7
  *
6
8
  * @param {Command} command
@@ -1,5 +1,6 @@
1
1
  export class Receiver {
2
2
  static connectionData: InMemoryConnectionData;
3
+ static getRuntimeInfo(): string;
3
4
  /**
4
5
  * @param {Int8Array} messageByteArray
5
6
  */
@@ -1,5 +1,13 @@
1
1
  /** @type {Record<string, wsClient>} */
2
2
  export const clients: Record<string, wsClient>;
3
+ /** @type {Record<string, Array<{resolve: Function, reject: Function, messageArray: Int8Array}>>} */
4
+ export const messageQueue: Record<string, Array<{
5
+ resolve: Function;
6
+ reject: Function;
7
+ messageArray: Int8Array;
8
+ }>>;
9
+ /** @type {Record<string, boolean>} */
10
+ export const processingQueues: Record<string, boolean>;
3
11
  export type wsClient = import("ws").WebSocket;
4
12
  export type WebSocketClass = typeof import("ws").WebSocket;
5
13
  /**
@@ -21,14 +29,28 @@ export class WebSocketClient {
21
29
  get instance(): wsClient | null;
22
30
  get isConnected(): boolean;
23
31
  /**
24
- * Sends messageArray through websocket connection
32
+ * Sends messageArray through websocket connection with guaranteed order preservation
25
33
  * @async
26
34
  * @param {Int8Array} messageArray
27
35
  * @returns {Promise<Int8Array>}
28
36
  */
29
37
  send(messageArray: Int8Array): Promise<Int8Array>;
30
38
  /**
31
- * Disconnects the WebSocket by terminating the connection.
39
+ * Processes message queue sequentially to maintain order
40
+ * @private
41
+ * @async
42
+ */
43
+ private _processMessage;
44
+ /**
45
+ * Sends a single message through websocket connection
46
+ * @private
47
+ * @async
48
+ * @param {Int8Array} messageArray
49
+ * @returns {Promise<Int8Array>}
50
+ */
51
+ private _send;
52
+ /**
53
+ * Disconnects the WebSocket by terminating the connection and cleans up queues.
32
54
  */
33
55
  disconnect(): void;
34
56
  /**
@@ -4,6 +4,14 @@
4
4
  */
5
5
  /** @type {Record<string, WebSocket>} */
6
6
  export const clients: Record<string, WebSocket>;
7
+ /** @type {Record<string, Array<{resolve: Function, reject: Function, messageArray: Int8Array}>>} */
8
+ export const messageQueue: Record<string, Array<{
9
+ resolve: Function;
10
+ reject: Function;
11
+ messageArray: Int8Array;
12
+ }>>;
13
+ /** @type {Record<string, boolean>} */
14
+ export const processingQueues: Record<string, boolean>;
7
15
  export type Options = {
8
16
  isDisconnectedAfterMessage?: boolean | undefined;
9
17
  };
@@ -24,14 +32,28 @@ export class WebSocketClientBrowser {
24
32
  get instance(): WebSocket | null;
25
33
  get isConnected(): boolean;
26
34
  /**
27
- * Sends messageArray through websocket connection
35
+ * Sends messageArray through websocket connection with guaranteed order preservation
28
36
  * @async
29
37
  * @param {Int8Array} messageArray
30
38
  * @returns {Promise<Int8Array>}
31
39
  */
32
40
  send(messageArray: Int8Array): Promise<Int8Array>;
33
41
  /**
34
- * Disconnects the WebSocket by terminating the connection.
42
+ * Processes message queue sequentially to maintain order
43
+ * @private
44
+ * @async
45
+ */
46
+ private _processMessage;
47
+ /**
48
+ * Sends a single message through websocket connection
49
+ * @private
50
+ * @async
51
+ * @param {Int8Array} messageArray
52
+ * @returns {Promise<Int8Array>}
53
+ */
54
+ private _sendSingle;
55
+ /**
56
+ * Disconnects the WebSocket by terminating the connection and cleans up queues.
35
57
  */
36
58
  disconnect(): void;
37
59
  /**
@@ -41,4 +41,7 @@ export namespace CommandType {
41
41
  let PassDelegate: 39;
42
42
  let InvokeDelegate: 40;
43
43
  let ConvertType: 41;
44
+ let AddEventListener: 42;
45
+ let PluginWrapper: 43;
46
+ let GetAsyncOperationResult: 44;
44
47
  }
@@ -65,7 +65,10 @@ const CommandType = (
65
65
  GetInstanceMethodAsDelegate: 38,
66
66
  PassDelegate: 39,
67
67
  InvokeDelegate: 40,
68
- ConvertType: 41
68
+ ConvertType: 41,
69
+ AddEventListener: 42,
70
+ PluginWrapper: 43,
71
+ GetAsyncOperationResult: 44
69
72
  }
70
73
  );
71
74
  // Annotate the CommonJS export names for ESM import in node: