javonet-nodejs-sdk 2.6.1 → 2.6.3

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 (104) hide show
  1. package/dist/core/handler/AddEventListenerHandler.cjs +36 -0
  2. package/dist/core/handler/ArrayReferenceHandler.cjs +36 -0
  3. package/dist/core/handler/AsKwargsHandler.cjs +36 -0
  4. package/dist/core/handler/AsOutHandler.cjs +36 -0
  5. package/dist/core/handler/AsRefHandler.cjs +36 -0
  6. package/dist/core/handler/CreateNullHandler.cjs +36 -0
  7. package/dist/core/handler/ExceptionHandler.cjs +36 -0
  8. package/dist/core/handler/GenerateLibHandler.cjs +36 -0
  9. package/dist/core/handler/GetAsyncOperationResultHandler.cjs +36 -0
  10. package/dist/core/handler/GetEnumItemHandler.cjs +36 -0
  11. package/dist/core/handler/GetEnumNameHandler.cjs +36 -0
  12. package/dist/core/handler/GetEnumValueHandler.cjs +36 -0
  13. package/dist/core/handler/GetGlobalFieldHandler.cjs +63 -0
  14. package/dist/core/handler/GetModuleHandler.cjs +36 -0
  15. package/dist/core/handler/GetRefValueHandler.cjs +36 -0
  16. package/dist/core/handler/GetResultTypeHandler.cjs +43 -0
  17. package/dist/core/handler/Handler.cjs +55 -11
  18. package/dist/core/handler/HeartBeatHandler.cjs +36 -0
  19. package/dist/core/handler/InvokeGenericMethodHandler.cjs +36 -0
  20. package/dist/core/handler/InvokeGenericStaticMethodHandler.cjs +36 -0
  21. package/dist/core/handler/OptimizeHandler.cjs +36 -0
  22. package/dist/core/handler/PluginWrapperHandler.cjs +36 -0
  23. package/dist/core/handler/RetrieveArrayHandler.cjs +36 -0
  24. package/dist/sdk/ActivatorDetails.cjs +37 -0
  25. package/dist/sdk/InvocationContext.cjs +83 -0
  26. package/dist/sdk/Javonet.cjs +0 -1
  27. package/dist/sdk/RuntimeContext.cjs +19 -0
  28. package/dist/sdk/tools/ComplexTypeResolver.cjs +114 -0
  29. package/dist/sdk/tools/typeParsingFunctions/JavaTypeParsingFunctions.cjs +44 -0
  30. package/dist/sdk/tools/typeParsingFunctions/NetcoreTypeParsingFunctions.cjs +44 -0
  31. package/dist/sdk/tools/typeParsingFunctions/NodejsTypeParsingFunctions.cjs +44 -0
  32. package/dist/sdk/tools/typeParsingFunctions/PythonTypeParsingFunctions.cjs +44 -0
  33. package/dist/sdk/tools/typeParsingFunctions/TypeParsingUtils.cjs +34 -0
  34. package/dist/types/core/handler/AddEventListenerHandler.d.ts +7 -0
  35. package/dist/types/core/handler/ArrayReferenceHandler.d.ts +7 -0
  36. package/dist/types/core/handler/AsKwargsHandler.d.ts +7 -0
  37. package/dist/types/core/handler/AsOutHandler.d.ts +7 -0
  38. package/dist/types/core/handler/AsRefHandler.d.ts +7 -0
  39. package/dist/types/core/handler/CreateNullHandler.d.ts +7 -0
  40. package/dist/types/core/handler/ExceptionHandler.d.ts +7 -0
  41. package/dist/types/core/handler/GenerateLibHandler.d.ts +7 -0
  42. package/dist/types/core/handler/GetAsyncOperationResultHandler.d.ts +7 -0
  43. package/dist/types/core/handler/GetEnumItemHandler.d.ts +7 -0
  44. package/dist/types/core/handler/GetEnumNameHandler.d.ts +7 -0
  45. package/dist/types/core/handler/GetEnumValueHandler.d.ts +7 -0
  46. package/dist/types/core/handler/GetGlobalFieldHandler.d.ts +13 -0
  47. package/dist/types/core/handler/GetModuleHandler.d.ts +7 -0
  48. package/dist/types/core/handler/GetRefValueHandler.d.ts +7 -0
  49. package/dist/types/core/handler/GetResultTypeHandler.d.ts +18 -0
  50. package/dist/types/core/handler/HeartBeatHandler.d.ts +7 -0
  51. package/dist/types/core/handler/InvokeGenericMethodHandler.d.ts +7 -0
  52. package/dist/types/core/handler/InvokeGenericStaticMethodHandler.d.ts +7 -0
  53. package/dist/types/core/handler/OptimizeHandler.d.ts +7 -0
  54. package/dist/types/core/handler/PluginWrapperHandler.d.ts +7 -0
  55. package/dist/types/core/handler/RetrieveArrayHandler.d.ts +7 -0
  56. package/dist/types/sdk/ActivatorDetails.d.ts +12 -0
  57. package/dist/types/sdk/InvocationContext.d.ts +22 -0
  58. package/dist/types/sdk/RuntimeContext.d.ts +8 -0
  59. package/dist/types/sdk/tools/ComplexTypeResolver.d.ts +28 -0
  60. package/dist/types/sdk/tools/typeParsingFunctions/JavaTypeParsingFunctions.d.ts +11 -0
  61. package/dist/types/sdk/tools/typeParsingFunctions/NetcoreTypeParsingFunctions.d.ts +11 -0
  62. package/dist/types/sdk/tools/typeParsingFunctions/NodejsTypeParsingFunctions.d.ts +11 -0
  63. package/dist/types/sdk/tools/typeParsingFunctions/PythonTypeParsingFunctions.d.ts +11 -0
  64. package/dist/types/sdk/tools/typeParsingFunctions/TypeParsingUtils.d.ts +1 -0
  65. package/dist/types/utils/CommandType.d.ts +3 -0
  66. package/dist/types/utils/IsThenable.d.ts +6 -0
  67. package/dist/utils/CommandType.cjs +4 -1
  68. package/dist/utils/IsThenable.cjs +30 -0
  69. package/lib/core/handler/AddEventListenerHandler.js +12 -0
  70. package/lib/core/handler/ArrayReferenceHandler.js +12 -0
  71. package/lib/core/handler/AsKwargsHandler.js +11 -0
  72. package/lib/core/handler/AsOutHandler.js +12 -0
  73. package/lib/core/handler/AsRefHandler.js +12 -0
  74. package/lib/core/handler/CreateNullHandler.js +12 -0
  75. package/lib/core/handler/ExceptionHandler.js +12 -0
  76. package/lib/core/handler/GenerateLibHandler.js +12 -0
  77. package/lib/core/handler/GetAsyncOperationResultHandler.js +12 -0
  78. package/lib/core/handler/GetEnumItemHandler.js +12 -0
  79. package/lib/core/handler/GetEnumNameHandler.js +11 -0
  80. package/lib/core/handler/GetEnumValueHandler.js +12 -0
  81. package/lib/core/handler/GetGlobalFieldHandler.js +44 -0
  82. package/lib/core/handler/GetModuleHandler.js +11 -0
  83. package/lib/core/handler/GetRefValueHandler.js +12 -0
  84. package/lib/core/handler/GetResultTypeHandler.js +29 -0
  85. package/lib/core/handler/Handler.js +61 -17
  86. package/lib/core/handler/HeartBeatHandler.js +12 -0
  87. package/lib/core/handler/InvokeGenericMethodHandler.js +13 -0
  88. package/lib/core/handler/InvokeGenericStaticMethodHandler.js +12 -0
  89. package/lib/core/handler/OptimizeHandler.js +12 -0
  90. package/lib/core/handler/PluginWrapperHandler.js +12 -0
  91. package/lib/core/handler/RetrieveArrayHandler.js +12 -0
  92. package/lib/sdk/ActivatorDetails.js +15 -0
  93. package/lib/sdk/InvocationContext.js +87 -0
  94. package/lib/sdk/Javonet.js +1 -2
  95. package/lib/sdk/RuntimeContext.js +21 -0
  96. package/lib/sdk/tools/ComplexTypeResolver.js +103 -0
  97. package/lib/sdk/tools/typeParsingFunctions/JavaTypeParsingFunctions.js +25 -0
  98. package/lib/sdk/tools/typeParsingFunctions/NetcoreTypeParsingFunctions.js +25 -0
  99. package/lib/sdk/tools/typeParsingFunctions/NodejsTypeParsingFunctions.js +25 -0
  100. package/lib/sdk/tools/typeParsingFunctions/PythonTypeParsingFunctions.js +25 -0
  101. package/lib/sdk/tools/typeParsingFunctions/TypeParsingUtils.js +10 -0
  102. package/lib/utils/CommandType.js +3 -0
  103. package/lib/utils/IsThenable.js +10 -0
  104. package/package.json +2 -2
@@ -0,0 +1,12 @@
1
+ // @ts-check
2
+ import { AbstractHandler } from './AbstractHandler.js';
3
+
4
+ export class ArrayReferenceHandler extends AbstractHandler {
5
+ /**
6
+ * @param {any} command
7
+ */
8
+ handleCommand(command) {
9
+ throw new Error(`${this.constructor.name} is not implemented in Node.js`);
10
+ }
11
+ }
12
+
@@ -0,0 +1,11 @@
1
+ // @ts-check
2
+ import { AbstractHandler } from './AbstractHandler.js';
3
+
4
+ export class AsKwargsHandler extends AbstractHandler {
5
+ /**
6
+ * @param {any} command
7
+ */
8
+ handleCommand(command) {
9
+ throw new Error(`${this.constructor.name} is not implemented in Node.js`);
10
+ }
11
+ }
@@ -0,0 +1,12 @@
1
+ // @ts-check
2
+ import { AbstractHandler } from './AbstractHandler.js';
3
+
4
+ export class AsOutHandler extends AbstractHandler {
5
+ /**
6
+ * @param {any} command
7
+ */
8
+ handleCommand(command) {
9
+ throw new Error(`${this.constructor.name} is not implemented in Node.js`);
10
+ }
11
+ }
12
+
@@ -0,0 +1,12 @@
1
+ // @ts-check
2
+ import { AbstractHandler } from './AbstractHandler.js';
3
+
4
+ export class AsRefHandler extends AbstractHandler {
5
+ /**
6
+ * @param {any} command
7
+ */
8
+ handleCommand(command) {
9
+ throw new Error(`${this.constructor.name} is not implemented in Node.js`);
10
+ }
11
+ }
12
+
@@ -0,0 +1,12 @@
1
+ // @ts-check
2
+ import { AbstractHandler } from './AbstractHandler.js';
3
+
4
+ export class CreateNullHandler extends AbstractHandler {
5
+ /**
6
+ * @param {any} command
7
+ */
8
+ handleCommand(command) {
9
+ throw new Error(`${this.constructor.name} is not implemented in Node.js`);
10
+ }
11
+ }
12
+
@@ -0,0 +1,12 @@
1
+ // @ts-check
2
+ import { AbstractHandler } from './AbstractHandler.js';
3
+
4
+ export class ExceptionHandler extends AbstractHandler {
5
+ /**
6
+ * @param {any} command
7
+ */
8
+ handleCommand(command) {
9
+ throw new Error(`${this.constructor.name} is not implemented in Node.js`);
10
+ }
11
+ }
12
+
@@ -0,0 +1,12 @@
1
+ // @ts-check
2
+ import { AbstractHandler } from './AbstractHandler.js';
3
+
4
+ export class GenerateLibHandler extends AbstractHandler {
5
+ /**
6
+ * @param {any} command
7
+ */
8
+ handleCommand(command) {
9
+ throw new Error(`${this.constructor.name} is not implemented in Node.js`);
10
+ }
11
+ }
12
+
@@ -0,0 +1,12 @@
1
+ // @ts-check
2
+ import { AbstractHandler } from './AbstractHandler.js';
3
+
4
+ export class GetAsyncOperationResultHandler extends AbstractHandler {
5
+ /**
6
+ * @param {any} command
7
+ */
8
+ handleCommand(command) {
9
+ throw new Error(`${this.constructor.name} is not implemented in Node.js`);
10
+ }
11
+ }
12
+
@@ -0,0 +1,12 @@
1
+ // @ts-check
2
+ import { AbstractHandler } from './AbstractHandler.js';
3
+
4
+ export class GetEnumItemHandler extends AbstractHandler {
5
+ /**
6
+ * @param {any} command
7
+ */
8
+ handleCommand(command) {
9
+ throw new Error(`${this.constructor.name} is not implemented in Node.js`);
10
+ }
11
+ }
12
+
@@ -0,0 +1,11 @@
1
+ // @ts-check
2
+ import { AbstractHandler } from './AbstractHandler.js';
3
+
4
+ export class GetEnumNameHandler extends AbstractHandler {
5
+ /**
6
+ * @param {any} command
7
+ */
8
+ handleCommand(command) {
9
+ throw new Error(`${this.constructor.name} is not implemented in Node.js`);
10
+ }
11
+ }
@@ -0,0 +1,12 @@
1
+ // @ts-check
2
+ import { AbstractHandler } from './AbstractHandler.js';
3
+
4
+ export class GetEnumValueHandler extends AbstractHandler {
5
+ /**
6
+ * @param {any} command
7
+ */
8
+ handleCommand(command) {
9
+ throw new Error(`${this.constructor.name} is not implemented in Node.js`);
10
+ }
11
+ }
12
+
@@ -0,0 +1,44 @@
1
+ import { AbstractHandler } from './AbstractHandler.js'
2
+
3
+ /**
4
+ * @typedef {import('../../utils/Command.js').Command} Command
5
+ */
6
+
7
+ class GetGlobalFieldHandler extends AbstractHandler {
8
+ requiredParametersCount = 1
9
+
10
+ constructor() {
11
+ super()
12
+ }
13
+
14
+ /**
15
+ * @param {Command} command
16
+ * @returns {any}
17
+ */
18
+ process(command) {
19
+ try {
20
+ if (command.payload.length < this.requiredParametersCount) {
21
+ throw new Error('Invoke Global Field parameters mismatch')
22
+ }
23
+ const { payload } = command
24
+ const fieldName = payload[0]
25
+
26
+ if (fieldName in global && typeof global[fieldName] !== 'function') {
27
+ return global[fieldName]
28
+ } else {
29
+ const fields = Object.getOwnPropertyNames(global).filter(
30
+ (property) => typeof global[property] !== 'function'
31
+ )
32
+ let message = `Field ${fieldName} not found in global. Available fields:\n`
33
+ fields.forEach((field) => {
34
+ message += `${field}\n`
35
+ })
36
+ throw new Error(message)
37
+ }
38
+ } catch (error) {
39
+ throw this.process_stack_trace(error, this.constructor.name)
40
+ }
41
+ }
42
+ }
43
+
44
+ export { GetGlobalFieldHandler }
@@ -0,0 +1,11 @@
1
+ // @ts-check
2
+ import { AbstractHandler } from './AbstractHandler.js';
3
+
4
+ export class GetModuleHandler extends AbstractHandler {
5
+ /**
6
+ * @param {any} command
7
+ */
8
+ handleCommand(command) {
9
+ throw new Error(`${this.constructor.name} is not implemented in Node.js`);
10
+ }
11
+ }
@@ -0,0 +1,12 @@
1
+ // @ts-check
2
+ import { AbstractHandler } from './AbstractHandler.js';
3
+
4
+ export class GetRefValueHandler extends AbstractHandler {
5
+ /**
6
+ * @param {any} command
7
+ */
8
+ handleCommand(command) {
9
+ throw new Error(`${this.constructor.name} is not implemented in Node.js`);
10
+ }
11
+ }
12
+
@@ -0,0 +1,29 @@
1
+ // @ts-check
2
+ import { TypesHandler } from '../../utils/TypesHandler.js'
3
+ import { AbstractHandler } from './AbstractHandler.js'
4
+
5
+ /**
6
+ * @typedef {import('../../utils/Command.js').Command} Command
7
+ */
8
+
9
+ /**
10
+ * GetResultTypeHandler class handles the conversion of JType to Type.
11
+ */
12
+ class GetResultTypeHandler extends AbstractHandler {
13
+ constructor() {
14
+ super()
15
+ /** @type {number} */
16
+ this.requiredParametersCount = 1
17
+ }
18
+
19
+ /**
20
+ * Processes the given command to convert JType to Type.
21
+ * @param {Command} command - The command to process.
22
+ * @returns {any} The converted type.
23
+ */
24
+ process(command) {
25
+ return command.payload[0].constructor.name
26
+ }
27
+ }
28
+
29
+ export { GetResultTypeHandler }
@@ -2,34 +2,56 @@
2
2
  import { ReferencesCache } from '../referenceCache/ReferencesCache.js'
3
3
  import { ValueHandler } from './ValueHandler.js'
4
4
  import { LoadLibraryHandler } from './LoadLibraryHandler.js'
5
- import { GetTypeHandler } from './GetTypeHandler.js'
6
5
  import { InvokeStaticMethodHandler } from './InvokeStaticMethodHandler.js'
7
6
  import { GetStaticFieldHandler } from './GetStaticFieldHandler.js'
8
7
  import { SetStaticFieldHandler } from './SetStaticFieldHandler.js'
9
- import { ResolveReferenceHandler } from './ResolveReferenceHandler.js'
10
8
  import { CreateClassInstanceHandler } from './CreateClassInstanceHandler.js'
11
- import { GetInstanceFieldHandler } from './GetInstanceFieldHandler.js'
12
- import { SetInstanceFieldHandler } from './SetInstanceFieldHandler.js'
9
+ import { GetTypeHandler } from './GetTypeHandler.js'
10
+ import { ResolveReferenceHandler } from './ResolveReferenceHandler.js'
11
+ import { GetModuleHandler } from './GetModuleHandler.js';
13
12
  import { InvokeInstanceMethodHandler } from './InvokeInstanceMethodHandler.js'
14
- import { DestructReferenceHandler } from './DestructReferenceHandler.js'
13
+ import { ExceptionHandler } from './ExceptionHandler.js';
14
+ import { HeartBeatHandler } from './HeartBeatHandler.js';
15
15
  import { CastingHandler } from './CastingHandler.js'
16
+ import { GetInstanceFieldHandler } from './GetInstanceFieldHandler.js'
17
+ import { OptimizeHandler } from './OptimizeHandler.js';
18
+ import { GenerateLibHandler } from './GenerateLibHandler.js';
19
+ import { InvokeGlobalFunctionHandler } from './InvokeGlobalFunctionHandler.js'
20
+ import { DestructReferenceHandler } from './DestructReferenceHandler.js'
21
+ import { ArrayReferenceHandler } from './ArrayReferenceHandler.js';
16
22
  import { ArrayGetItemHandler } from './ArrayGetItemHandler.js'
17
23
  import { ArrayGetSizeHandler } from './ArrayGetSizeHandler.js'
18
24
  import { ArrayGetRankHandler } from './ArrayGetRankHandler.js'
19
25
  import { ArraySetItemHandler } from './ArraySetItemHandler.js'
20
26
  import { ArrayHandler } from './ArrayHandler.js'
21
- import { EnableNamespaceHandler } from './EnableNamespaceHandler.js'
22
- import { EnableTypeHandler } from './EnableTypeHandler.js'
23
- import { GetStaticMethodAsDelegateHandler } from './GetStaticMethodAsDelegateHandler.js'
24
- import { GetInstanceMethodAsDelegateHandler } from './GetInstanceMethodAsDelegateHandler.js'
25
- import { PassDelegateHandler } from './PassDelegateHandler.js'
26
- import { InvokeDelegateHandler } from './InvokeDelegateHandler.js'
27
- import { InvokeGlobalFunctionHandler } from './InvokeGlobalFunctionHandler.js'
27
+ import { RetrieveArrayHandler } from './RetrieveArrayHandler.js';
28
+ import { SetInstanceFieldHandler } from './SetInstanceFieldHandler.js'
29
+ import { InvokeGenericStaticMethodHandler } from './InvokeGenericStaticMethodHandler.js';
30
+ import { InvokeGenericMethodHandler } from './InvokeGenericMethodHandler.js';
31
+ import { GetEnumItemHandler } from './GetEnumItemHandler.js';
32
+ import { GetEnumNameHandler } from './GetEnumNameHandler.js';
33
+ import { GetEnumValueHandler } from './GetEnumValueHandler.js';
34
+ import { AsRefHandler } from './AsRefHandler.js';
35
+ import { AsOutHandler } from './AsOutHandler.js';
36
+ import { GetRefValueHandler } from './GetRefValueHandler.js';
37
+ import { EnableNamespaceHandler } from './EnableNamespaceHandler.js';
38
+ import { EnableTypeHandler } from './EnableTypeHandler.js';
39
+ import { CreateNullHandler } from './CreateNullHandler.js';
40
+ import { GetStaticMethodAsDelegateHandler } from './GetStaticMethodAsDelegateHandler.js';
41
+ import { GetInstanceMethodAsDelegateHandler } from './GetInstanceMethodAsDelegateHandler.js';
42
+ import { PassDelegateHandler } from './PassDelegateHandler.js';
43
+ import { InvokeDelegateHandler } from './InvokeDelegateHandler.js';
44
+ import { ConvertTypeHandler } from './ConvertTypeHandler.js';
45
+ import { AddEventListenerHandler } from './AddEventListenerHandler.js';
46
+ import { PluginWrapperHandler } from './PluginWrapperHandler.js';
47
+ import { GetAsyncOperationResultHandler } from './GetAsyncOperationResultHandler.js';
48
+ import { AsKwargsHandler } from './AsKwargsHandler.js';
49
+ import { GetResultTypeHandler } from './GetResultTypeHandler.js';
50
+ import { GetGlobalFieldHandler } from './GetGlobalFieldHandler.js';
28
51
  import { CommandType } from '../../utils/CommandType.js'
29
52
  import { Command } from '../../utils/Command.js'
30
53
  import { TypesHandler } from '../../utils/TypesHandler.js'
31
54
  import { ExceptionSerializer } from '../../utils/exception/ExceptionSerializer.js'
32
- import { ConvertTypeHandler } from './ConvertTypeHandler.js'
33
55
  import { AbstractHandler } from './AbstractHandler.js'
34
56
 
35
57
  /**
@@ -43,29 +65,51 @@ const handlers = {
43
65
  [CommandType.Value]: new ValueHandler(),
44
66
  [CommandType.LoadLibrary]: new LoadLibraryHandler(),
45
67
  [CommandType.InvokeStaticMethod]: new InvokeStaticMethodHandler(),
46
- [CommandType.GetType]: new GetTypeHandler(),
47
68
  [CommandType.GetStaticField]: new GetStaticFieldHandler(),
48
69
  [CommandType.SetStaticField]: new SetStaticFieldHandler(),
49
70
  [CommandType.CreateClassInstance]: new CreateClassInstanceHandler(),
71
+ [CommandType.GetType]: new GetTypeHandler(),
50
72
  [CommandType.Reference]: new ResolveReferenceHandler(),
73
+ [CommandType.GetModule]: new GetModuleHandler(),
74
+ [CommandType.InvokeInstanceMethod]: new InvokeInstanceMethodHandler(),
75
+ [CommandType.Exception]: new ExceptionHandler(),
76
+ [CommandType.HeartBeat]: new HeartBeatHandler(),
51
77
  [CommandType.Cast]: new CastingHandler(),
52
78
  [CommandType.GetInstanceField]: new GetInstanceFieldHandler(),
53
- [CommandType.SetInstanceField]: new SetInstanceFieldHandler(),
54
- [CommandType.InvokeInstanceMethod]: new InvokeInstanceMethodHandler(),
79
+ [CommandType.Optimize]: new OptimizeHandler(),
80
+ [CommandType.GenerateLib]: new GenerateLibHandler(),
81
+ [CommandType.InvokeGlobalFunction]: new InvokeGlobalFunctionHandler(),
55
82
  [CommandType.DestructReference]: new DestructReferenceHandler(),
83
+ [CommandType.ArrayReference]: new ArrayReferenceHandler(),
56
84
  [CommandType.ArrayGetItem]: new ArrayGetItemHandler(),
57
85
  [CommandType.ArrayGetSize]: new ArrayGetSizeHandler(),
58
86
  [CommandType.ArrayGetRank]: new ArrayGetRankHandler(),
59
87
  [CommandType.ArraySetItem]: new ArraySetItemHandler(),
60
88
  [CommandType.Array]: new ArrayHandler(),
89
+ [CommandType.RetrieveArray]: new RetrieveArrayHandler(),
90
+ [CommandType.SetInstanceField]: new SetInstanceFieldHandler(),
91
+ [CommandType.InvokeGenericStaticMethod]: new InvokeGenericStaticMethodHandler(),
92
+ [CommandType.InvokeGenericMethod]: new InvokeGenericMethodHandler(),
93
+ [CommandType.GetEnumItem]: new GetEnumItemHandler(),
94
+ [CommandType.GetEnumName]: new GetEnumNameHandler(),
95
+ [CommandType.GetEnumValue]: new GetEnumValueHandler(),
96
+ [CommandType.AsRef]: new AsRefHandler(),
97
+ [CommandType.AsOut]: new AsOutHandler(),
98
+ [CommandType.GetRefValue]: new GetRefValueHandler(),
61
99
  [CommandType.EnableNamespace]: new EnableNamespaceHandler(),
62
100
  [CommandType.EnableType]: new EnableTypeHandler(),
101
+ [CommandType.CreateNull]: new CreateNullHandler(),
63
102
  [CommandType.GetStaticMethodAsDelegate]: new GetStaticMethodAsDelegateHandler(),
64
103
  [CommandType.GetInstanceMethodAsDelegate]: new GetInstanceMethodAsDelegateHandler(),
65
104
  [CommandType.PassDelegate]: new PassDelegateHandler(),
66
105
  [CommandType.InvokeDelegate]: new InvokeDelegateHandler(),
67
106
  [CommandType.ConvertType]: new ConvertTypeHandler(),
68
- [CommandType.InvokeGlobalFunction]: new InvokeGlobalFunctionHandler(),
107
+ [CommandType.AddEventListener]: new AddEventListenerHandler(),
108
+ [CommandType.PluginWrapper]: new PluginWrapperHandler(),
109
+ [CommandType.GetAsyncOperationResult]: new GetAsyncOperationResultHandler(),
110
+ [CommandType.AsKwargs]: new AsKwargsHandler(),
111
+ [CommandType.GetResultType]: new GetResultTypeHandler(),
112
+ [CommandType.GetGlobalField]: new GetGlobalFieldHandler(),
69
113
  }
70
114
 
71
115
  class Handler {
@@ -0,0 +1,12 @@
1
+ // @ts-check
2
+ import { AbstractHandler } from './AbstractHandler.js';
3
+
4
+ export class HeartBeatHandler extends AbstractHandler {
5
+ /**
6
+ * @param {any} command
7
+ */
8
+ handleCommand(command) {
9
+ throw new Error(`${this.constructor.name} is not implemented in Node.js`);
10
+ }
11
+ }
12
+
@@ -0,0 +1,13 @@
1
+ // @ts-check
2
+ import { AbstractHandler } from './AbstractHandler.js';
3
+
4
+ export class InvokeGenericMethodHandler extends AbstractHandler {
5
+ /**
6
+ * @param {any} command
7
+ */
8
+ handleCommand(command) {
9
+ throw new Error(`${this.constructor.name} is not implemented in Node.js`);
10
+ }
11
+ }
12
+
13
+
@@ -0,0 +1,12 @@
1
+ // @ts-check
2
+ import { AbstractHandler } from './AbstractHandler.js';
3
+
4
+ export class InvokeGenericStaticMethodHandler extends AbstractHandler {
5
+ /**
6
+ * @param {any} command
7
+ */
8
+ handleCommand(command) {
9
+ throw new Error(`${this.constructor.name} is not implemented in Node.js`);
10
+ }
11
+ }
12
+
@@ -0,0 +1,12 @@
1
+ // @ts-check
2
+ import { AbstractHandler } from './AbstractHandler.js';
3
+
4
+ export class OptimizeHandler extends AbstractHandler {
5
+ /**
6
+ * @param {any} command
7
+ */
8
+ handleCommand(command) {
9
+ throw new Error(`${this.constructor.name} is not implemented in Node.js`);
10
+ }
11
+ }
12
+
@@ -0,0 +1,12 @@
1
+ // @ts-check
2
+ import { AbstractHandler } from './AbstractHandler.js';
3
+
4
+ export class PluginWrapperHandler extends AbstractHandler {
5
+ /**
6
+ * @param {any} command
7
+ */
8
+ handleCommand(command) {
9
+ throw new Error(`${this.constructor.name} is not implemented in Node.js`);
10
+ }
11
+ }
12
+
@@ -0,0 +1,12 @@
1
+ // @ts-check
2
+ import { AbstractHandler } from './AbstractHandler.js';
3
+
4
+ export class RetrieveArrayHandler extends AbstractHandler {
5
+ /**
6
+ * @param {any} command
7
+ */
8
+ handleCommand(command) {
9
+ throw new Error(`${this.constructor.name} is not implemented in Node.js`);
10
+ }
11
+ }
12
+
@@ -0,0 +1,15 @@
1
+ /**
2
+ * Details for activating a type with constructor arguments
3
+ */
4
+ class ActivatorDetails {
5
+ /**
6
+ * @param {Function} type - The constructor function/class
7
+ * @param {any[]} [args] - Arguments to pass to constructor
8
+ */
9
+ constructor(type, args = []) {
10
+ this.type = type
11
+ this.arguments = args
12
+ }
13
+ }
14
+
15
+ export { ActivatorDetails }
@@ -395,6 +395,29 @@ class InvocationContext {
395
395
  return this.#createInstanceContext(localCommand)
396
396
  }
397
397
 
398
+ /**
399
+ * Retrieves the type of the object from the target runtime.
400
+ * @returns {string} The type of the object.
401
+ * @see [Javonet Guides](https://www.javonet.com/guides/v2/javascript/type-handling/getting-object-type)
402
+ * @method
403
+ */
404
+ getResultType() {
405
+ const localCommand = new Command(this.#runtimeName, CommandType.GetResultType, [])
406
+ const invocationContext = new InvocationContext(this.#runtimeName, this.#connectionData, this.#buildCommand(localCommand))
407
+ const result = invocationContext.execute().getValue()
408
+ return /** @type {string} */ (result)
409
+ }
410
+
411
+ /**
412
+ * Retrieves the name of the runtime where the command is executed.
413
+ * @returns {number} The name of the runtime.
414
+ * @see [Javonet Guides](https://www.javonet.com/guides/v2/javascript/runtime-name)
415
+ * @method
416
+ */
417
+ getRuntimeName() {
418
+ return this.#runtimeName
419
+ }
420
+
398
421
  /**
399
422
  * Retrieves an array from the target runtime.
400
423
  * @returns {InvocationContext} A new InvocationContext instance that wraps the command to retrieve the array.
@@ -556,6 +579,70 @@ class InvocationWsContext extends InvocationContext {
556
579
 
557
580
  return new InvocationWsContext(this.#runtimeName, this.#connectionData, this.#responseCommand, true)
558
581
  }
582
+
583
+ /**
584
+ * Retrieves the type of the object from the target runtime.
585
+ * @returns {Promise<string>} The type of the object.
586
+ * @see [Javonet Guides](https://www.javonet.com/guides/v2/javascript/type-handling/getting-object-type)
587
+ * @async
588
+ * @method
589
+ */
590
+ // @ts-expect-error
591
+ async getResultType() {
592
+ const localCommand = new Command(this.#runtimeName, CommandType.GetResultType, [])
593
+ const invocationContext = new InvocationWsContext(this.#runtimeName, this.#connectionData, this.#buildCommand(localCommand))
594
+ const result = await invocationContext.execute()
595
+ return /** @type {string} */ (result.getValue())
596
+ }
597
+
598
+ /**
599
+ * @param {Command} command
600
+ * @returns {Command}
601
+ */
602
+ #buildCommand(command) {
603
+ for (let i = 0; i < command.payload.length; i++) {
604
+ command.payload[i] = this.#encapsulatePayloadItem(command.payload[i])
605
+ }
606
+ return command.prependArgToPayload(this.#currentCommand)
607
+ }
608
+
609
+ /**
610
+ * @param {unknown} payloadItem
611
+ * @returns {Command|null}
612
+ */
613
+ #encapsulatePayloadItem(payloadItem) {
614
+ // eslint-disable-next-line valid-typeof
615
+ if (payloadItem instanceof Command) {
616
+ for (let i = 0; i < payloadItem.payload.length; i++) {
617
+ payloadItem.payload[i] = this.#encapsulatePayloadItem(payloadItem.payload[i])
618
+ }
619
+ return payloadItem
620
+ // eslint-disable-next-line valid-typeof
621
+ } else if (payloadItem instanceof InvocationContext || payloadItem instanceof InvocationWsContext) {
622
+ return payloadItem.get_current_command()
623
+ } else if (payloadItem instanceof Array) {
624
+ const copiedArray = payloadItem.map((item) => this.#encapsulatePayloadItem(item))
625
+ return new Command(this.#runtimeName, CommandType.Array, copiedArray)
626
+ } else if (typeof payloadItem === 'function') {
627
+ let newArray = new Array(payloadItem.length + 1)
628
+ for (let i = 0; i < newArray.length; i++) {
629
+ newArray[i] = typeof Object
630
+ }
631
+ const args = [delegatesCacheInstance.addDelegate(payloadItem), RuntimeName.Nodejs].push(
632
+ ...newArray
633
+ )
634
+ return new Command(this.#runtimeName, CommandType.PassDelegate, args)
635
+ } else if (TypesHandler.isPrimitiveOrNullOrUndefined(payloadItem)) {
636
+ return new Command(this.#runtimeName, CommandType.Value, [payloadItem])
637
+ } else {
638
+ throw Error(
639
+ 'Unsupported payload item type: ' +
640
+ (payloadItem?.constructor?.name || typeof payloadItem) +
641
+ ' for payload item: ' +
642
+ payloadItem
643
+ )
644
+ }
645
+ }
559
646
  }
560
647
 
561
648
  export { InvocationContext, InvocationWsContext }
@@ -2,13 +2,12 @@
2
2
  import { ConfigRuntimeFactory } from './ConfigRuntimeFactory.js'
3
3
  import { RuntimeFactory } from './RuntimeFactory.js'
4
4
  import { InMemoryConnectionData } from '../utils/connectionData/InMemoryConnectionData.js'
5
- import { isNodejsRuntime, getRuntimeExtension, getRequire } from '../utils/Runtime.js'
5
+ import { isNodejsRuntime, getRequire } from '../utils/Runtime.js'
6
6
  import { CommandSerializer } from '../core/protocol/CommandSerializer.js'
7
7
  import { CommandDeserializer } from '../core/protocol/CommandDeserializer.js'
8
8
  import { RuntimeLogger } from '../utils/RuntimeLogger.js'
9
9
  import { TcpConnectionData } from '../utils/nodejs/connectionData/TcpConnectionData.js'
10
10
  import { WsConnectionData } from '../utils/connectionData/WsConnectionData.js'
11
- import { ActivationHelper } from './tools/ActivationHelper.js'
12
11
  import { UtilsConst } from '../utils/UtilsConst.js'
13
12
 
14
13
  /** @typedef {import('../types.d.ts').ConfigSource} ConfigSource */
@@ -284,6 +284,27 @@ class RuntimeContext {
284
284
  return new InvocationContext(this.runtimeName, this.connectionData, this.#buildCommand(localCommand))
285
285
  }
286
286
 
287
+ /**
288
+ * Retrieves the value of an global field from the target runtime.
289
+ * @param {string} fieldName - The name of the field to get.
290
+ * @returns {InvocationContext} A new InvocationContext instance that wraps the command to get the global field.
291
+ * @see [Javonet Guides](https://www.javonet.com/guides/v2/javascript/fields-and-properties/getting-values-for-global-fields)
292
+ * @method
293
+ */
294
+ getGlobalField(fieldName) {
295
+ let localCommand = new Command(this.runtimeName, CommandType.GetGlobalField, [fieldName])
296
+ this.#currentCommand = null
297
+ if (this.connectionData.connectionType === ConnectionType.WEB_SOCKET) {
298
+ // @ts-expect-error
299
+ return new InvocationWsContext(
300
+ this.runtimeName,
301
+ this.connectionData,
302
+ this.#buildCommand(localCommand)
303
+ )
304
+ }
305
+ return new InvocationContext(this.runtimeName, this.connectionData, this.#buildCommand(localCommand))
306
+ }
307
+
287
308
  /**
288
309
  * Invokes a function from the called runtime. This method is used when working with functions from the called runtime.
289
310
  * The arguments include the function name and the arguments to be passed to the function.