javonet-nodejs-sdk 2.5.16 → 2.5.17

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 (41) hide show
  1. package/dist/core/delegatesCache/DelegatesCache.cjs +1 -5
  2. package/dist/core/handler/AbstractHandler.cjs +1 -3
  3. package/dist/core/handler/ArrayGetItemHandler.cjs +1 -3
  4. package/dist/core/handler/ArrayGetRankHandler.cjs +1 -3
  5. package/dist/core/handler/ArrayGetSizeHandler.cjs +1 -3
  6. package/dist/core/handler/ArraySetItemHandler.cjs +1 -3
  7. package/dist/core/handler/CreateClassInstanceHandler.cjs +1 -3
  8. package/dist/core/handler/EnableTypeHandler.cjs +1 -3
  9. package/dist/core/handler/GetGlobalStaticFieldHandler.cjs +1 -3
  10. package/dist/core/handler/GetInstanceFieldHandler.cjs +1 -3
  11. package/dist/core/handler/GetStaticFieldHandler.cjs +1 -3
  12. package/dist/core/handler/GetStaticMethodAsDelegateHandler.cjs +2 -4
  13. package/dist/core/handler/InvokeGlobalFunctionHandler.cjs +1 -3
  14. package/dist/core/handler/InvokeInstanceMethodHandler.cjs +1 -3
  15. package/dist/core/handler/InvokeStaticMethodHandler.cjs +1 -3
  16. package/dist/core/handler/LoadLibraryHandler.cjs +7 -10
  17. package/dist/core/handler/PassDelegateHandler.cjs +2 -4
  18. package/dist/core/handler/SetGlobalStaticFieldHandler.cjs +1 -3
  19. package/dist/core/handler/SetInstanceFieldHandler.cjs +1 -3
  20. package/dist/core/handler/SetStaticFieldHandler.cjs +1 -3
  21. package/dist/core/interpreter/Interpreter.cjs +2 -6
  22. package/dist/core/namespaceCache/NamespaceCache.cjs +7 -10
  23. package/dist/core/receiver/Receiver.cjs +2 -4
  24. package/dist/core/transmitter/Transmitter.cjs +3 -5
  25. package/dist/core/typeCache/TypeCache.cjs +7 -10
  26. package/dist/sdk/ConfigRuntimeFactory.cjs +78 -89
  27. package/dist/sdk/InvocationContext.cjs +170 -202
  28. package/dist/sdk/RuntimeContext.cjs +78 -94
  29. package/dist/types/utils/CreateRequire.browser.d.ts +1 -0
  30. package/dist/types/utils/CreateRequire.node.d.ts +2 -0
  31. package/dist/types/utils/Runtime.d.ts +2 -2
  32. package/dist/utils/CreateRequire.browser.cjs +30 -0
  33. package/dist/utils/CreateRequire.node.cjs +28 -0
  34. package/dist/utils/Runtime.cjs +24 -18
  35. package/dist/utils/RuntimeLogger.cjs +2 -4
  36. package/dist/utils/RuntimeLoggerBrowser.cjs +1 -3
  37. package/dist/utils/nodejs/connectionData/TcpConnectionData.cjs +12 -22
  38. package/lib/utils/CreateRequire.browser.js +5 -0
  39. package/lib/utils/CreateRequire.node.js +3 -0
  40. package/lib/utils/Runtime.js +24 -5
  41. package/package.json +10 -1
@@ -1,6 +1,11 @@
1
- import { createRequire } from 'module'
2
- import path from 'path'
3
- import { fileURLToPath, pathToFileURL } from 'url'
1
+ import { createRequire } from './CreateRequire.node.js'
2
+
3
+ /** @type {import('url').pathToFileURL | null} */
4
+ let pathToFileURL = null
5
+ /** @type {import('url').fileURLToPath | null} */
6
+ let fileURLToPath = null
7
+ /** @type {import('path').path | null} */
8
+ let path = null
4
9
 
5
10
  /**
6
11
  * Validate if the runtime is Node.js
@@ -45,11 +50,9 @@ export const getRequire = (callerPath) => {
45
50
  if (typeof require !== 'undefined') {
46
51
  return require
47
52
  }
48
-
49
53
  if (callerPath === undefined) {
50
54
  return createRequire(import.meta.url)
51
55
  }
52
-
53
56
  const baseUrl = callerPath?.startsWith('file:') ? callerPath : pathToFileURL(callerPath).href
54
57
  return createRequire(baseUrl)
55
58
  }
@@ -60,6 +63,9 @@ export const getRequire = (callerPath) => {
60
63
  }
61
64
 
62
65
  export const getDirname = () => {
66
+ if (isBrowserRuntime()) {
67
+ return new Error('Runtime not supported')
68
+ }
63
69
  // when esm runtime, __dirname is undefined
64
70
  if (isEsmRuntime()) {
65
71
  const __filename = fileURLToPath(import.meta.url)
@@ -92,3 +98,16 @@ export const getDependency = (dependencyName, callerPathOrUrl) => {
92
98
  )
93
99
  }
94
100
  }
101
+
102
+ if (isNodejsRuntime()) {
103
+ const requireDynamic = getRequire(import.meta.url)
104
+ if (fileURLToPath === null) {
105
+ fileURLToPath = requireDynamic('url').fileURLToPath
106
+ }
107
+ if (path === null) {
108
+ path = requireDynamic('path')
109
+ }
110
+ if (pathToFileURL === null) {
111
+ pathToFileURL = requireDynamic('url').pathToFileURL
112
+ }
113
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "javonet-nodejs-sdk",
3
- "version": "2.5.16",
3
+ "version": "2.5.17",
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.",
@@ -8,6 +8,9 @@
8
8
  "main": "./dist/sdk/Javonet.cjs",
9
9
  "module": "./lib/sdk/Javonet.js",
10
10
  "types": "./dist/types/sdk/Javonet.d.ts",
11
+ "browser": {
12
+ "./lib/utils/CreateRequire.node.js": "./lib/utils/CreateRequire.browser.js"
13
+ },
11
14
  "type": "module",
12
15
  "files": [
13
16
  "dist",
@@ -18,7 +21,13 @@
18
21
  ".": {
19
22
  "types": "./dist/types/sdk/Javonet.d.ts",
20
23
  "import": "./lib/sdk/Javonet.js",
24
+ "browser": "./lib/sdk/Javonet.js",
21
25
  "require": "./dist/sdk/Javonet.cjs"
26
+ },
27
+ "./lib/utils/CreateRequire.node.js": {
28
+ "browser": "./lib/utils/CreateRequire.browser.js",
29
+ "node": "./lib/utils/CreateRequire.node.js",
30
+ "default": "./lib/utils/CreateRequire.node.js"
22
31
  }
23
32
  },
24
33
  "scripts": {