javonet-nodejs-sdk 2.6.4 → 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.
Files changed (49) hide show
  1. package/dist/core/handler/Handler.cjs +15 -4
  2. package/dist/core/handler/LoadLibraryHandler.cjs +10 -6
  3. package/dist/core/interpreter/Interpreter.cjs +42 -16
  4. package/dist/core/protocol/CommandDeserializer.cjs +4 -4
  5. package/dist/core/protocol/CommandSerializer.cjs +7 -2
  6. package/dist/core/protocol/TypeDeserializer.cjs +11 -11
  7. package/dist/core/receiver/Receiver.cjs +7 -8
  8. package/dist/core/receiver/ReceiverNative.cjs +4 -2
  9. package/dist/core/transmitter/Transmitter.cjs +2 -2
  10. package/dist/core/transmitter/TransmitterWebsocket.cjs +2 -2
  11. package/dist/core/transmitter/TransmitterWebsocketBrowser.cjs +2 -2
  12. package/dist/core/transmitter/TransmitterWrapper.cjs +2 -1
  13. package/dist/core/webSocketClient/WebSocketClient.cjs +4 -4
  14. package/dist/core/webSocketClient/WebSocketClientBrowser.cjs +7 -7
  15. package/dist/sdk/InvocationContext.cjs +47 -38
  16. package/dist/sdk/tools/ComplexTypeResolver.cjs +28 -3
  17. package/dist/types/core/handler/Handler.d.ts +3 -3
  18. package/dist/types/core/interpreter/Interpreter.d.ts +3 -3
  19. package/dist/types/core/protocol/CommandDeserializer.d.ts +3 -3
  20. package/dist/types/core/protocol/CommandSerializer.d.ts +3 -3
  21. package/dist/types/core/protocol/TypeDeserializer.d.ts +22 -22
  22. package/dist/types/core/receiver/Receiver.d.ts +6 -5
  23. package/dist/types/core/receiver/ReceiverNative.d.ts +6 -4
  24. package/dist/types/core/transmitter/Transmitter.d.ts +3 -3
  25. package/dist/types/core/transmitter/TransmitterWebsocket.d.ts +3 -3
  26. package/dist/types/core/transmitter/TransmitterWebsocketBrowser.d.ts +3 -3
  27. package/dist/types/core/transmitter/TransmitterWrapper.d.ts +3 -2
  28. package/dist/types/core/webSocketClient/WebSocketClient.d.ts +7 -7
  29. package/dist/types/core/webSocketClient/WebSocketClientBrowser.d.ts +9 -9
  30. package/dist/types/sdk/InvocationContext.d.ts +7 -11
  31. package/dist/types/sdk/tools/ComplexTypeResolver.d.ts +2 -2
  32. package/lib/core/handler/Handler.js +18 -4
  33. package/lib/core/handler/LoadLibraryHandler.js +15 -7
  34. package/lib/core/interpreter/Interpreter.js +47 -20
  35. package/lib/core/protocol/CommandDeserializer.js +4 -4
  36. package/lib/core/protocol/CommandSerializer.js +8 -2
  37. package/lib/core/protocol/TypeDeserializer.js +11 -11
  38. package/lib/core/receiver/Receiver.js +7 -8
  39. package/lib/core/receiver/ReceiverNative.js +4 -2
  40. package/lib/core/transmitter/Transmitter.js +2 -2
  41. package/lib/core/transmitter/TransmitterWebsocket.js +2 -2
  42. package/lib/core/transmitter/TransmitterWebsocketBrowser.js +2 -2
  43. package/lib/core/transmitter/TransmitterWrapper.js +2 -1
  44. package/lib/core/webSocketClient/WebSocketClient.js +5 -5
  45. package/lib/core/webSocketClient/WebSocketClientBrowser.js +8 -8
  46. package/lib/sdk/InvocationContext.js +48 -41
  47. package/lib/sdk/RuntimeContext.js +0 -7
  48. package/lib/sdk/tools/ComplexTypeResolver.js +22 -3
  49. package/package.json +4 -2
@@ -182,7 +182,6 @@ class RuntimeContext {
182
182
  let localCommand = new Command(this.runtimeName, CommandType.GetType, [typeName, ...args])
183
183
  this.#currentCommand = null
184
184
  if (this.connectionData.connectionType === ConnectionType.WEB_SOCKET) {
185
- // @ts-expect-error
186
185
  return new InvocationWsContext(
187
186
  this.runtimeName,
188
187
  this.connectionData,
@@ -205,7 +204,6 @@ class RuntimeContext {
205
204
  let localCommand = new Command(this.runtimeName, CommandType.Cast, args)
206
205
  this.#currentCommand = null
207
206
  if (this.connectionData.connectionType === ConnectionType.WEB_SOCKET) {
208
- // @ts-expect-error
209
207
  return new InvocationWsContext(
210
208
  this.runtimeName,
211
209
  this.connectionData,
@@ -228,7 +226,6 @@ class RuntimeContext {
228
226
  let localCommand = new Command(this.runtimeName, CommandType.GetEnumItem, args)
229
227
  this.#currentCommand = null
230
228
  if (this.connectionData.connectionType === ConnectionType.WEB_SOCKET) {
231
- // @ts-expect-error
232
229
  return new InvocationWsContext(
233
230
  this.runtimeName,
234
231
  this.connectionData,
@@ -251,7 +248,6 @@ class RuntimeContext {
251
248
  let localCommand = new Command(this.runtimeName, CommandType.AsRef, args)
252
249
  this.#currentCommand = null
253
250
  if (this.connectionData.connectionType === ConnectionType.WEB_SOCKET) {
254
- // @ts-expect-error
255
251
  return new InvocationWsContext(
256
252
  this.runtimeName,
257
253
  this.connectionData,
@@ -274,7 +270,6 @@ class RuntimeContext {
274
270
  let localCommand = new Command(this.runtimeName, CommandType.AsOut, args)
275
271
  this.#currentCommand = null
276
272
  if (this.connectionData.connectionType === ConnectionType.WEB_SOCKET) {
277
- // @ts-expect-error
278
273
  return new InvocationWsContext(
279
274
  this.runtimeName,
280
275
  this.connectionData,
@@ -295,7 +290,6 @@ class RuntimeContext {
295
290
  let localCommand = new Command(this.runtimeName, CommandType.GetGlobalField, [fieldName])
296
291
  this.#currentCommand = null
297
292
  if (this.connectionData.connectionType === ConnectionType.WEB_SOCKET) {
298
- // @ts-expect-error
299
293
  return new InvocationWsContext(
300
294
  this.runtimeName,
301
295
  this.connectionData,
@@ -322,7 +316,6 @@ class RuntimeContext {
322
316
  ])
323
317
  this.#currentCommand = null
324
318
  if (this.connectionData.connectionType === ConnectionType.WEB_SOCKET) {
325
- // @ts-expect-error
326
319
  return new InvocationWsContext(
327
320
  this.runtimeName,
328
321
  this.connectionData,
@@ -7,6 +7,7 @@ import { JavaTypeParsingFunctions } from './typeParsingFunctions/JavaTypeParsing
7
7
  import { NetcoreTypeParsingFunctions } from './typeParsingFunctions/NetcoreTypeParsingFunctions.js'
8
8
  import { NodejsTypeParsingFunctions } from './typeParsingFunctions/NodejsTypeParsingFunctions.js'
9
9
  import { PythonTypeParsingFunctions } from './typeParsingFunctions/PythonTypeParsingFunctions.js'
10
+ import * as util from 'node:util'
10
11
 
11
12
  const dynamicImport = getRequire(import.meta.url)
12
13
 
@@ -42,7 +43,7 @@ class ComplexTypeResolver {
42
43
  /**
43
44
  * Convert InvocationContext result to appropriate JavaScript type
44
45
  * @param {InvocationContext} ic - The invocation context
45
- * @returns {any} The converted result
46
+ * @returns {Promise<any> | any} The converted result
46
47
  */
47
48
  convertResult(ic) {
48
49
  const runtimeName = ic.getRuntimeName()
@@ -51,18 +52,36 @@ class ComplexTypeResolver {
51
52
  // Try built-in type parsing functions first
52
53
  const runtimeDict = this.#typeParsingFunctions.get(runtimeName)
53
54
  if (runtimeDict) {
54
- const parsingFunc = runtimeDict.get(resultType)
55
+ let parsingFunc = null;
56
+ if (resultType instanceof Promise) {
57
+ parsingFunc = resultType.then(result => {
58
+ parsingFunc = runtimeDict.get(result);
59
+ })
60
+ } else {
61
+ parsingFunc = runtimeDict.get(resultType);
62
+ }
63
+
55
64
  if (parsingFunc) {
65
+ // @ts-ignore
56
66
  return parsingFunc(ic)
57
67
  }
58
68
  }
59
69
 
60
70
  // Try registered custom types
61
- const activatorDetails = this.#typeMap.get(resultType)
71
+ let activatorDetails = null;
72
+ if (resultType instanceof Promise) {
73
+ activatorDetails = resultType.then(result => {
74
+ activatorDetails = this.#typeMap.get(result);
75
+ })
76
+ } else {
77
+ activatorDetails = this.#typeMap.get(resultType);
78
+ }
79
+
62
80
  if (!activatorDetails) {
63
81
  throw new Error(`No type registered for key '${resultType}'.`)
64
82
  }
65
83
 
84
+ // @ts-ignore
66
85
  return new /** @type {any} */ (activatorDetails.type)(...activatorDetails.arguments)
67
86
  }
68
87
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "javonet-nodejs-sdk",
3
- "version": "2.6.4",
3
+ "version": "2.6.5",
4
4
  "description": "Javonet allows you to reference and use modules or packages written in (Java/Kotlin/Groovy/Clojure, C#/VB.NET, Ruby, Perl, Python, JavaScript/TypeScript) like they were created in your technology. It works on Linux/Windows and MacOS for applications created in JVM, CLR/Netcore, Perl, Python, Ruby, NodeJS, C++ or GoLang and gives you unparalleled freedom and flexibility with native performance in building your mixed-technologies products. Let it be accessing best AI or cryptography libraries, devices SDKs, legacy client modules, internal custom packages or anything from public repositories available on NPM, Nuget, PyPI, Maven/Gradle, RubyGems or GitHub. Get free from programming languages barriers today! For more information check out our guides at https://www.javonet.com/guides/v2/",
5
5
  "keywords": [],
6
6
  "author": "SdNCenter Sp. z o. o.",
@@ -43,6 +43,7 @@
43
43
  },
44
44
  "scripts": {
45
45
  "test": "cross-env NODE_OPTIONS=--experimental-vm-modules jest tests/unitTests tests/functional -t=\"(Unit|Functional)\" --maxWorkers=3 --colors --coverage",
46
+ "webserviceTests": "cross-env NODE_OPTIONS=--experimental-vm-modules jest tests/webSocketClientTests --maxWorkers=3 --colors",
46
47
  "build:types": "tsc --project tsconfig.declarations.json",
47
48
  "build:cjs": "tsup && node scripts/resolve-dist-imports.js",
48
49
  "build": "npm run build:cjs && npm run build:types",
@@ -54,7 +55,8 @@
54
55
  "buffer": "^6.0.3",
55
56
  "glob": "^10.4.5",
56
57
  "js-yaml": "^4.1.0",
57
- "uuid": "^10.0.0"
58
+ "uuid": "^10.0.0",
59
+ "ws": "^8.13.0"
58
60
  },
59
61
  "devDependencies": {
60
62
  "@babel/cli": "^7.25.9",