java-bridge 2.1.7 → 2.1.8-beta.2
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.
- package/dist/index.prod.min.js +1 -1
- package/dist/index.prod.min.js.map +1 -1
- package/dist/java-ts-gen.js +1 -1
- package/dist/java-ts-gen.js.map +1 -1
- package/dist/native.d.ts +8 -0
- package/dist/ts-src/TypescriptBulkDefinitionGenerator.d.ts +8 -0
- package/dist/ts-src/TypescriptDefinitionGenerator.d.ts +4 -0
- package/dist/ts-src/definitions.d.ts +1 -1
- package/dist/ts-src/index.d.ts +1 -0
- package/dist/ts-src/java.d.ts +38 -4
- package/java-src/build/libs/JavaBridge-2.1.1.jar +0 -0
- package/package.json +19 -15
package/dist/ts-src/java.d.ts
CHANGED
|
@@ -50,9 +50,30 @@ export interface JVMOptions extends JavaOptions {
|
|
|
50
50
|
* ensureJvm();
|
|
51
51
|
* ```
|
|
52
52
|
*
|
|
53
|
+
* ## Notes on the `classpath` option
|
|
54
|
+
*
|
|
55
|
+
* If you need to set the class path *before* jvm startup, for example
|
|
56
|
+
* when using libraries with custom class loaders, you'd need to call
|
|
57
|
+
* `ensureJvm` *before* making any other call to `java-bridge` as those
|
|
58
|
+
* methods may themselves call `ensureJvm` with no arguments
|
|
59
|
+
* (see comment above). Altering the startup classpath after jvm boot is
|
|
60
|
+
* not possible, you can only alter the runtime classpath using
|
|
61
|
+
* `appendClasspath` or `appendClasspathAny` which may not reflect
|
|
62
|
+
* in an altered classpath in your java application/library if your
|
|
63
|
+
* application is using a custom classpath (e.g. Spring Boot).
|
|
64
|
+
*
|
|
65
|
+
* Also, it is not possible to restart the jvm after is has been started
|
|
66
|
+
* once, in order to alter the startup classpath. This is due to some
|
|
67
|
+
* limitations with the destructor feature of the node.js native api,
|
|
68
|
+
* which may not call the destructor in time and having two jvm instances
|
|
69
|
+
* in the same application is not allowed by java. Additionally, destroying
|
|
70
|
+
* the jvm instance may cause *undefined behaviour*, which may or may not
|
|
71
|
+
* cause the application to crash. Let's not do that.
|
|
72
|
+
*
|
|
53
73
|
* @param options the options to use when creating the jvm
|
|
74
|
+
* @return true if the jvm was created and false if the jvm already existed and was not created
|
|
54
75
|
*/
|
|
55
|
-
export declare function ensureJvm(options?: JVMOptions):
|
|
76
|
+
export declare function ensureJvm(options?: JVMOptions): boolean;
|
|
56
77
|
/**
|
|
57
78
|
* Get the addon's internal class loader.
|
|
58
79
|
* This may be used in combination with {@link setClassLoader}
|
|
@@ -160,7 +181,10 @@ export declare function importClassAsync<T extends JavaClassConstructorType = Un
|
|
|
160
181
|
* This doesn't check if the jars are valid and/or even exist.
|
|
161
182
|
* The new classpath will be available to all classes imported after this call.
|
|
162
183
|
*
|
|
184
|
+
* If you want to import whole directories, you can use glob patterns.
|
|
185
|
+
*
|
|
163
186
|
* ## Example
|
|
187
|
+
* ### Append single files
|
|
164
188
|
* ```ts
|
|
165
189
|
* import { appendClasspath } from 'java-bridge';
|
|
166
190
|
*
|
|
@@ -178,6 +202,16 @@ export declare function importClassAsync<T extends JavaClassConstructorType = Un
|
|
|
178
202
|
* classpath.append('/path/to/jar.jar');
|
|
179
203
|
* ```
|
|
180
204
|
*
|
|
205
|
+
* ### Append a directory to the class path
|
|
206
|
+
* ```ts
|
|
207
|
+
* import { appendClasspath } from 'java-bridge';
|
|
208
|
+
*
|
|
209
|
+
* // Append a directory to the class path
|
|
210
|
+
* appendClasspath('/path/to/dir/*');
|
|
211
|
+
* // Append just the jar files in the directory
|
|
212
|
+
* appendClasspath('/path/to/dir/*.jar');
|
|
213
|
+
* ```
|
|
214
|
+
*
|
|
181
215
|
* @param path the path(s) to add
|
|
182
216
|
*/
|
|
183
217
|
export declare function appendClasspath(path: string | string[]): void;
|
|
@@ -215,7 +249,7 @@ export declare function appendClasspath(path: string | string[]): void;
|
|
|
215
249
|
* @param other the class or class name to check against
|
|
216
250
|
* @return true if `this_obj` is an instance of `other`
|
|
217
251
|
*/
|
|
218
|
-
export declare function isInstanceOf<T extends
|
|
252
|
+
export declare function isInstanceOf<T extends object>(this_obj: JavaClass, other: string | T): boolean;
|
|
219
253
|
/**
|
|
220
254
|
* Methods for altering and querying the class path.
|
|
221
255
|
* @example
|
|
@@ -233,9 +267,9 @@ export declare namespace classpath {
|
|
|
233
267
|
*/
|
|
234
268
|
function append(path: string | string[]): void;
|
|
235
269
|
/**
|
|
236
|
-
* Get the loaded
|
|
270
|
+
* Get the loaded files or directories in the class path
|
|
237
271
|
*
|
|
238
|
-
* @returns a list of the loaded
|
|
272
|
+
* @returns a list of the loaded files
|
|
239
273
|
*/
|
|
240
274
|
function get(): string[];
|
|
241
275
|
}
|
|
Binary file
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "java-bridge",
|
|
3
|
-
"version": "2.1.
|
|
3
|
+
"version": "2.1.8-beta.2",
|
|
4
4
|
"main": "dist/index.prod.min.js",
|
|
5
5
|
"types": "dist/ts-src/index.d.ts",
|
|
6
6
|
"description": "A bridge between Node.js and Java APIs",
|
|
@@ -56,7 +56,8 @@
|
|
|
56
56
|
"build:java:win32": "cd java-src && .\\gradlew.bat shadowJar",
|
|
57
57
|
"prepublishOnly": "napi prepublish -t npm",
|
|
58
58
|
"test": "npm run testOnly",
|
|
59
|
-
"testOnly": "mocha -r ts-node/register test
|
|
59
|
+
"testOnly": "mocha -r ts-node/register test/*.test.ts --reporter mocha-multi-reporters --reporter-options configFile=mocha-reporter-config.json",
|
|
60
|
+
"pretestOnly": "npm run generateTestTypes",
|
|
60
61
|
"pretest": "npm run build",
|
|
61
62
|
"version": "napi version",
|
|
62
63
|
"prettier": "prettier --write .",
|
|
@@ -64,7 +65,8 @@
|
|
|
64
65
|
"prebuild:debug": "rimraf dist",
|
|
65
66
|
"benchmark": "ts-node -P test/tsconfig.json test/benchmark/benchmark.ts && ts-node -P test/tsconfig.json test/benchmark/benchmarkDaemonThreads.ts",
|
|
66
67
|
"prebenchmark": "npm run build",
|
|
67
|
-
"docs": "typedoc --out docs ts-src/index.ts"
|
|
68
|
+
"docs": "typedoc --out docs ts-src/index.ts",
|
|
69
|
+
"generateTestTypes": "ts-node -P test/tsconfig.json test/generateTestTypes.ts"
|
|
68
70
|
},
|
|
69
71
|
"dependencies": {
|
|
70
72
|
"chalk": "^5.1.2",
|
|
@@ -74,28 +76,30 @@
|
|
|
74
76
|
"yargs": "^17.6.2"
|
|
75
77
|
},
|
|
76
78
|
"devDependencies": {
|
|
77
|
-
"@napi-rs/cli": "^2.
|
|
79
|
+
"@napi-rs/cli": "^2.13.0",
|
|
78
80
|
"@types/chai": "^4.3.4",
|
|
79
81
|
"@types/glob": "^8.0.0",
|
|
80
82
|
"@types/is-ci": "^3.0.0",
|
|
81
|
-
"@types/mocha": "^10.0.
|
|
82
|
-
"@types/node": "^18.11.
|
|
83
|
+
"@types/mocha": "^10.0.1",
|
|
84
|
+
"@types/node": "^18.11.10",
|
|
83
85
|
"@types/semver": "^7.3.13",
|
|
84
86
|
"@types/webpack-node-externals": "^2.5.3",
|
|
85
|
-
"@types/yargs": "^17.0.
|
|
87
|
+
"@types/yargs": "^17.0.15",
|
|
86
88
|
"chai": "^4.3.7",
|
|
87
89
|
"cpy-cli": "^4.2.0",
|
|
88
90
|
"expose-gc": "^1.0.0",
|
|
89
91
|
"is-ci": "^3.0.1",
|
|
90
92
|
"mocha": "^10.1.0",
|
|
93
|
+
"mocha-junit-reporter": "^2.2.0",
|
|
94
|
+
"mocha-multi-reporters": "^1.5.1",
|
|
91
95
|
"nanobench": "^3.0.0",
|
|
92
96
|
"node-loader": "^2.0.0",
|
|
93
|
-
"prettier": "^2.
|
|
97
|
+
"prettier": "^2.8.0",
|
|
94
98
|
"rimraf": "^3.0.2",
|
|
95
99
|
"run-script-os": "^1.1.6",
|
|
96
100
|
"semver": "^7.3.8",
|
|
97
101
|
"string-replace-loader": "^3.1.0",
|
|
98
|
-
"ts-loader": "^9.4.
|
|
102
|
+
"ts-loader": "^9.4.2",
|
|
99
103
|
"ts-node": "^10.9.1",
|
|
100
104
|
"tslib": "^2.4.1",
|
|
101
105
|
"typedoc": "^0.23.21",
|
|
@@ -104,11 +108,11 @@
|
|
|
104
108
|
"webpack-node-externals": "^3.0.0"
|
|
105
109
|
},
|
|
106
110
|
"optionalDependencies": {
|
|
107
|
-
"java-bridge-win32-x64-msvc": "2.1.
|
|
108
|
-
"java-bridge-darwin-x64": "2.1.
|
|
109
|
-
"java-bridge-linux-x64-gnu": "2.1.
|
|
110
|
-
"java-bridge-darwin-arm64": "2.1.
|
|
111
|
-
"java-bridge-win32-ia32-msvc": "2.1.
|
|
112
|
-
"java-bridge-linux-arm64-gnu": "2.1.
|
|
111
|
+
"java-bridge-win32-x64-msvc": "2.1.8-beta.2",
|
|
112
|
+
"java-bridge-darwin-x64": "2.1.8-beta.2",
|
|
113
|
+
"java-bridge-linux-x64-gnu": "2.1.8-beta.2",
|
|
114
|
+
"java-bridge-darwin-arm64": "2.1.8-beta.2",
|
|
115
|
+
"java-bridge-win32-ia32-msvc": "2.1.8-beta.2",
|
|
116
|
+
"java-bridge-linux-arm64-gnu": "2.1.8-beta.2"
|
|
113
117
|
}
|
|
114
118
|
}
|