java-bridge 2.1.6 → 2.1.8-beta.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.
- package/README.md +2 -0
- 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 +3 -0
- package/dist/ts-src/TypescriptBulkDefinitionGenerator.d.ts +8 -0
- package/dist/ts-src/TypescriptDefinitionGenerator.d.ts +6 -1
- package/dist/ts-src/definitions.d.ts +7 -7
- package/dist/ts-src/index.d.ts +2 -1
- package/dist/ts-src/java.d.ts +59 -6
- package/java-src/build/libs/JavaBridge-2.1.1.jar +0 -0
- package/package.json +26 -22
package/dist/ts-src/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { JavaVersion, JavaObject, JavaClassInstance, JavaClassProxy, JavaClass, JavaClassConstructor, JavaType, BasicOrJavaType, BasicType, JavaClassType, Constructor, UnknownJavaClassType, JavaClassConstructorType, } from './definitions';
|
|
1
|
+
export { JavaVersion, JavaObject, JavaClassInstance, JavaClassProxy, JavaClass, JavaClassConstructor, UnknownJavaClass, JavaType, BasicOrJavaType, BasicType, JavaClassType, Constructor, UnknownJavaClassType, JavaClassConstructorType, } from './definitions';
|
|
2
2
|
import type * as internal from '../native';
|
|
3
3
|
/**
|
|
4
4
|
* A namespace containing any internal type definitions.
|
|
@@ -13,4 +13,5 @@ export { getJavaLibPath } from '../native';
|
|
|
13
13
|
export { getJavaVersion, getJavaVersionSync } from './util';
|
|
14
14
|
import TypescriptDefinitionGenerator from './TypescriptDefinitionGenerator';
|
|
15
15
|
export { TypescriptDefinitionGenerator };
|
|
16
|
+
export { TypescriptBulkDefinitionGenerator } from './TypescriptBulkDefinitionGenerator';
|
|
16
17
|
export { ModuleDeclaration, MethodDeclaration, ProgressCallback, } from './TypescriptDefinitionGenerator';
|
package/dist/ts-src/java.d.ts
CHANGED
|
@@ -16,6 +16,11 @@ export interface JVMOptions extends JavaOptions {
|
|
|
16
16
|
* Additional arguments to pass to the JVM
|
|
17
17
|
*/
|
|
18
18
|
opts?: Array<string> | null;
|
|
19
|
+
/**
|
|
20
|
+
* Additional items to add to the class path.
|
|
21
|
+
* This also allows wildcard imports, e.g. `/lib/*`
|
|
22
|
+
*/
|
|
23
|
+
classpath?: string[];
|
|
19
24
|
}
|
|
20
25
|
/**
|
|
21
26
|
* Ensure the java vm is created.
|
|
@@ -50,9 +55,30 @@ export interface JVMOptions extends JavaOptions {
|
|
|
50
55
|
* ensureJvm();
|
|
51
56
|
* ```
|
|
52
57
|
*
|
|
58
|
+
* ## Notes on the `classpath` option
|
|
59
|
+
*
|
|
60
|
+
* If you need to set the class path *before* jvm startup, for example
|
|
61
|
+
* when using libraries with custom class loaders, you'd need to call
|
|
62
|
+
* `ensureJvm` *before* making any other call to `java-bridge` as those
|
|
63
|
+
* methods may themselves call `ensureJvm` with no arguments
|
|
64
|
+
* (see comment above). Altering the startup classpath after jvm boot is
|
|
65
|
+
* not possible, you can only alter the runtime classpath using
|
|
66
|
+
* `appendClasspath` or `appendClasspathAny` which may not reflect
|
|
67
|
+
* in an altered classpath in your java application/library if your
|
|
68
|
+
* application is using a custom classpath (e.g. Spring Boot).
|
|
69
|
+
*
|
|
70
|
+
* Also, it is not possible to restart the jvm after is has been started
|
|
71
|
+
* once, in order to alter the startup classpath. This is due to some
|
|
72
|
+
* limitations with the destructor feature of the node.js native api,
|
|
73
|
+
* which may not call the destructor in time and having two jvm instances
|
|
74
|
+
* in the same application is not allowed by java. Additionally, destroying
|
|
75
|
+
* the jvm instance may cause *undefined behaviour*, which may or may not
|
|
76
|
+
* cause the application to crash. Let's not do that.
|
|
77
|
+
*
|
|
53
78
|
* @param options the options to use when creating the jvm
|
|
79
|
+
* @return true if the jvm was created and false if the jvm already existed and was not created
|
|
54
80
|
*/
|
|
55
|
-
export declare function ensureJvm(options?: JVMOptions):
|
|
81
|
+
export declare function ensureJvm(options?: JVMOptions): boolean;
|
|
56
82
|
/**
|
|
57
83
|
* Get the addon's internal class loader.
|
|
58
84
|
* This may be used in combination with {@link setClassLoader}
|
|
@@ -160,6 +186,8 @@ export declare function importClassAsync<T extends JavaClassConstructorType = Un
|
|
|
160
186
|
* This doesn't check if the jars are valid and/or even exist.
|
|
161
187
|
* The new classpath will be available to all classes imported after this call.
|
|
162
188
|
*
|
|
189
|
+
* **Note: This can only import single files, not directories.**
|
|
190
|
+
*
|
|
163
191
|
* ## Example
|
|
164
192
|
* ```ts
|
|
165
193
|
* import { appendClasspath } from 'java-bridge';
|
|
@@ -181,6 +209,27 @@ export declare function importClassAsync<T extends JavaClassConstructorType = Un
|
|
|
181
209
|
* @param path the path(s) to add
|
|
182
210
|
*/
|
|
183
211
|
export declare function appendClasspath(path: string | string[]): void;
|
|
212
|
+
/**
|
|
213
|
+
* Append either a single or multiple jars or directories to the class path.
|
|
214
|
+
* This will check if the path(s) passed are directories and will
|
|
215
|
+
* add a trailing slash to the path if it doesn't already have one
|
|
216
|
+
* so the class loader will treat it as a directory. This will
|
|
217
|
+
* check if the file or directory exists and throw an error if it doesn't exist.
|
|
218
|
+
*
|
|
219
|
+
* ## Example
|
|
220
|
+
* ```ts
|
|
221
|
+
* appendClasspathAny('/path/to/dir');
|
|
222
|
+
* ```
|
|
223
|
+
*
|
|
224
|
+
* Pass multiple paths:
|
|
225
|
+
* ```ts
|
|
226
|
+
* appendClasspathAny(['/path/to/dir1', '/path/to/my.jar']);
|
|
227
|
+
* ```
|
|
228
|
+
*
|
|
229
|
+
* @param path the file(s) or directory(s) to add
|
|
230
|
+
* @param recursive whether to recursively add all files in the directory
|
|
231
|
+
*/
|
|
232
|
+
export declare function appendClasspathAny(path: string | string[], recursive?: boolean): void;
|
|
184
233
|
/**
|
|
185
234
|
* Check if `this_obj` is instance of `other`.
|
|
186
235
|
* This uses the native java `instanceof` operator.
|
|
@@ -215,7 +264,7 @@ export declare function appendClasspath(path: string | string[]): void;
|
|
|
215
264
|
* @param other the class or class name to check against
|
|
216
265
|
* @return true if `this_obj` is an instance of `other`
|
|
217
266
|
*/
|
|
218
|
-
export declare function isInstanceOf<T extends
|
|
267
|
+
export declare function isInstanceOf<T extends object>(this_obj: JavaClass, other: string | T): boolean;
|
|
219
268
|
/**
|
|
220
269
|
* Methods for altering and querying the class path.
|
|
221
270
|
* @example
|
|
@@ -233,9 +282,13 @@ export declare namespace classpath {
|
|
|
233
282
|
*/
|
|
234
283
|
function append(path: string | string[]): void;
|
|
235
284
|
/**
|
|
236
|
-
*
|
|
285
|
+
* @inheritDoc appendClasspathAny
|
|
286
|
+
*/
|
|
287
|
+
function appendAny(path: string | string[], recursive?: boolean): void;
|
|
288
|
+
/**
|
|
289
|
+
* Get the loaded files or directories in the class path
|
|
237
290
|
*
|
|
238
|
-
* @returns a list of the loaded
|
|
291
|
+
* @returns a list of the loaded files
|
|
239
292
|
*/
|
|
240
293
|
function get(): string[];
|
|
241
294
|
}
|
|
@@ -246,7 +299,7 @@ export declare namespace classpath {
|
|
|
246
299
|
* This is null if the output was valid. This will probably never be set.
|
|
247
300
|
* @param data the data that was converted. This is unset if <code>err</code> is set.
|
|
248
301
|
*/
|
|
249
|
-
export
|
|
302
|
+
export type StdoutCallback = (err: Error | null, data?: string) => void;
|
|
250
303
|
/**
|
|
251
304
|
* The class guarding the stdout redirect.
|
|
252
305
|
* Keep this instance in scope to not lose the redirect.
|
|
@@ -417,7 +470,7 @@ export interface JavaInterfaceProxy {
|
|
|
417
470
|
* @param args the arguments passed from the java process
|
|
418
471
|
* @return the value to pass back to the java process
|
|
419
472
|
*/
|
|
420
|
-
export
|
|
473
|
+
export type ProxyMethod = (...args: any[]) => any;
|
|
421
474
|
/**
|
|
422
475
|
* Create a new java interface proxy.
|
|
423
476
|
* This allows you to implement java interfaces in javascript.
|
|
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.1",
|
|
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,51 +65,54 @@
|
|
|
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",
|
|
71
73
|
"glob": "^8.0.3",
|
|
72
74
|
"ora": "^6.1.2",
|
|
73
|
-
"typescript": "^4.
|
|
74
|
-
"yargs": "^17.6.
|
|
75
|
+
"typescript": "^4.9.3",
|
|
76
|
+
"yargs": "^17.6.2"
|
|
75
77
|
},
|
|
76
78
|
"devDependencies": {
|
|
77
|
-
"@napi-rs/cli": "^2.
|
|
78
|
-
"@types/chai": "^4.3.
|
|
79
|
+
"@napi-rs/cli": "^2.13.0",
|
|
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.
|
|
86
|
-
"chai": "^4.3.
|
|
87
|
+
"@types/yargs": "^17.0.15",
|
|
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
|
-
"typedoc": "^0.23.
|
|
102
|
-
"webpack": "^5.
|
|
103
|
-
"webpack-cli": "^
|
|
105
|
+
"typedoc": "^0.23.21",
|
|
106
|
+
"webpack": "^5.75.0",
|
|
107
|
+
"webpack-cli": "^5.0.0",
|
|
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.1",
|
|
112
|
+
"java-bridge-darwin-x64": "2.1.8-beta.1",
|
|
113
|
+
"java-bridge-linux-x64-gnu": "2.1.8-beta.1",
|
|
114
|
+
"java-bridge-darwin-arm64": "2.1.8-beta.1",
|
|
115
|
+
"java-bridge-win32-ia32-msvc": "2.1.8-beta.1",
|
|
116
|
+
"java-bridge-linux-arm64-gnu": "2.1.8-beta.1"
|
|
113
117
|
}
|
|
114
118
|
}
|