java-bridge 2.2.3-beta.2 → 2.2.3-beta.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.
- 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 +18 -4
- package/dist/ts-src/index.d.ts +1 -1
- package/dist/ts-src/java.d.ts +57 -3
- package/java-src/build/libs/JavaBridge-2.1.1.jar +0 -0
- package/package.json +15 -15
package/dist/ts-src/java.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import { Java, JavaOptions } from '../native';
|
|
1
|
+
import { InterfaceProxyOptions, Java, JavaOptions } from '../native';
|
|
2
2
|
import { JavaClass, JavaClassConstructorType, JavaVersion, UnknownJavaClass, UnknownJavaClassType } from './definitions';
|
|
3
|
+
export { clearDaemonProxies } from '../native';
|
|
3
4
|
/**
|
|
4
5
|
* Options for creating the Java VM.
|
|
5
6
|
*/
|
|
@@ -442,8 +443,11 @@ export interface JavaInterfaceProxy {
|
|
|
442
443
|
* specifically implementing methods that will be called
|
|
443
444
|
* from another (java) thread.
|
|
444
445
|
* Throws an error if the proxy has already been destroyed.
|
|
446
|
+
*
|
|
447
|
+
* @param force whether to force the destruction of the proxy
|
|
448
|
+
* if it should be kept alive as a daemon
|
|
445
449
|
*/
|
|
446
|
-
reset(): void;
|
|
450
|
+
reset(force?: boolean): void;
|
|
447
451
|
}
|
|
448
452
|
/**
|
|
449
453
|
* An interface proxy method.
|
|
@@ -551,16 +555,66 @@ export type ProxyMethod = (...args: any[]) => any;
|
|
|
551
555
|
* an exception will be thrown in the java process.
|
|
552
556
|
* * Any errors thrown in the javascript process will be rethrown in the java process.
|
|
553
557
|
*
|
|
558
|
+
* ### Possible deadlock warning
|
|
559
|
+
* When calling a java method that uses an interface defined by this, you must call
|
|
560
|
+
* that method using the interface asynchronously as Node.js is single threaded
|
|
561
|
+
* and can't wait for the java method to return while calling the proxy method at the
|
|
562
|
+
* same time.
|
|
563
|
+
*
|
|
564
|
+
* If you still want to call everything in a synchronous manner, make sure to enable
|
|
565
|
+
* running the event loop while waiting for a java method to return by setting
|
|
566
|
+
* {@link config.runEventLoopWhenInterfaceProxyIsActive} to true.
|
|
567
|
+
* **This may cause application crashes, so it is strongly recommended to just use async methods.**
|
|
568
|
+
*
|
|
569
|
+
* ### Keeping the proxy alive
|
|
570
|
+
* If you want to keep the proxy alive, you must keep this instance in scope.
|
|
571
|
+
* If that is not an option for you, you can manually keep the proxy alive
|
|
572
|
+
* by setting the {@link InterfaceProxyOptions.keepAsDaemon} option to true.
|
|
573
|
+
*
|
|
574
|
+
* This will keep the proxy alive internally, thus the instance can be moved
|
|
575
|
+
* out of scope. However, this will also keep the JVM alive, so you should
|
|
576
|
+
* only use this if you are sure that you want to keep the JVM alive.
|
|
577
|
+
*
|
|
578
|
+
* If you want to destroy the proxy, you must call {@link clearDaemonProxies}.
|
|
579
|
+
* This will destroy all proxies which are kept alive by this option.
|
|
580
|
+
* Calling {@link JavaInterfaceProxy.reset} will not destroy a proxy
|
|
581
|
+
* kept alive by this option unless the force option is set to true.
|
|
582
|
+
*
|
|
554
583
|
* ## See also
|
|
555
584
|
* * {@link JavaInterfaceProxy}
|
|
585
|
+
* * {@link InterfaceProxyOptions}
|
|
556
586
|
*
|
|
557
587
|
* @param interfaceName the name of the java interface to implement
|
|
558
588
|
* @param methods the methods to implement.
|
|
589
|
+
* @param opts the options to use
|
|
559
590
|
* @returns a proxy class to pass back to the java process
|
|
560
591
|
*/
|
|
561
|
-
export declare function newProxy(interfaceName: string, methods: Record<string, ProxyMethod
|
|
592
|
+
export declare function newProxy(interfaceName: string, methods: Record<string, ProxyMethod>, opts?: InterfaceProxyOptions): JavaInterfaceProxy;
|
|
562
593
|
/**
|
|
563
594
|
* Get the static java instance.
|
|
564
595
|
* This has no real use, all important methods are exported explicitly.
|
|
565
596
|
*/
|
|
566
597
|
export declare function getJavaInstance(): Java | null;
|
|
598
|
+
/**
|
|
599
|
+
* Configuration options for the java bridge.
|
|
600
|
+
*/
|
|
601
|
+
export declare class config {
|
|
602
|
+
/**
|
|
603
|
+
* Set whether to run the event loop when an interface proxy is active.
|
|
604
|
+
* This is disabled by default. Enabling this will cause the bridge
|
|
605
|
+
* to run the event loop when an interface proxy either as direct
|
|
606
|
+
* proxy or as daemon proxy is active. This is only required if the
|
|
607
|
+
* proxied method calls back into the javascript process in the same thread.
|
|
608
|
+
* If the proxy is used either in an async method or in a different thread,
|
|
609
|
+
* this is not required.
|
|
610
|
+
*
|
|
611
|
+
* **Note:** Enabling this may cause the application to crash. Use with caution.
|
|
612
|
+
*
|
|
613
|
+
* @param value whether to run the event loop when an interface proxy is active
|
|
614
|
+
*/
|
|
615
|
+
static set runEventLoopWhenInterfaceProxyIsActive(value: boolean);
|
|
616
|
+
/**
|
|
617
|
+
* Get whether to run the event loop when an interface proxy is active.
|
|
618
|
+
*/
|
|
619
|
+
static get runEventLoopWhenInterfaceProxyIsActive(): boolean;
|
|
620
|
+
}
|
|
Binary file
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "java-bridge",
|
|
3
|
-
"version": "2.2.3-beta.
|
|
3
|
+
"version": "2.2.3-beta.3",
|
|
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",
|
|
@@ -73,18 +73,18 @@
|
|
|
73
73
|
"glob": "^8.1.0",
|
|
74
74
|
"ora": "^6.1.2",
|
|
75
75
|
"typescript": "^4.9.5",
|
|
76
|
-
"yargs": "^17.
|
|
76
|
+
"yargs": "^17.7.1"
|
|
77
77
|
},
|
|
78
78
|
"devDependencies": {
|
|
79
|
-
"@napi-rs/cli": "^2.14.
|
|
79
|
+
"@napi-rs/cli": "^2.14.8",
|
|
80
80
|
"@types/chai": "^4.3.4",
|
|
81
|
-
"@types/glob": "^8.0
|
|
81
|
+
"@types/glob": "^8.1.0",
|
|
82
82
|
"@types/is-ci": "^3.0.0",
|
|
83
83
|
"@types/mocha": "^10.0.1",
|
|
84
|
-
"@types/node": "^18.
|
|
84
|
+
"@types/node": "^18.14.1",
|
|
85
85
|
"@types/semver": "^7.3.13",
|
|
86
|
-
"@types/webpack-node-externals": "^
|
|
87
|
-
"@types/which": "^2.0.
|
|
86
|
+
"@types/webpack-node-externals": "^3.0.0",
|
|
87
|
+
"@types/which": "^2.0.2",
|
|
88
88
|
"@types/yargs": "^17.0.22",
|
|
89
89
|
"chai": "^4.3.7",
|
|
90
90
|
"cpy-cli": "^4.2.0",
|
|
@@ -95,7 +95,7 @@
|
|
|
95
95
|
"mocha-multi-reporters": "^1.5.1",
|
|
96
96
|
"nanobench": "^3.0.0",
|
|
97
97
|
"node-loader": "^2.0.0",
|
|
98
|
-
"prettier": "^2.8.
|
|
98
|
+
"prettier": "^2.8.4",
|
|
99
99
|
"rimraf": "^4.1.2",
|
|
100
100
|
"run-script-os": "^1.1.6",
|
|
101
101
|
"semver": "^7.3.8",
|
|
@@ -103,18 +103,18 @@
|
|
|
103
103
|
"ts-loader": "^9.4.2",
|
|
104
104
|
"ts-node": "^10.9.1",
|
|
105
105
|
"tslib": "^2.5.0",
|
|
106
|
-
"typedoc": "^0.23.
|
|
106
|
+
"typedoc": "^0.23.25",
|
|
107
107
|
"webpack": "^5.75.0",
|
|
108
108
|
"webpack-cli": "^5.0.1",
|
|
109
109
|
"webpack-node-externals": "^3.0.0",
|
|
110
110
|
"which": "^3.0.0"
|
|
111
111
|
},
|
|
112
112
|
"optionalDependencies": {
|
|
113
|
-
"java-bridge-win32-x64-msvc": "2.2.3-beta.
|
|
114
|
-
"java-bridge-darwin-x64": "2.2.3-beta.
|
|
115
|
-
"java-bridge-linux-x64-gnu": "2.2.3-beta.
|
|
116
|
-
"java-bridge-darwin-arm64": "2.2.3-beta.
|
|
117
|
-
"java-bridge-win32-ia32-msvc": "2.2.3-beta.
|
|
118
|
-
"java-bridge-linux-arm64-gnu": "2.2.3-beta.
|
|
113
|
+
"java-bridge-win32-x64-msvc": "2.2.3-beta.3",
|
|
114
|
+
"java-bridge-darwin-x64": "2.2.3-beta.3",
|
|
115
|
+
"java-bridge-linux-x64-gnu": "2.2.3-beta.3",
|
|
116
|
+
"java-bridge-darwin-arm64": "2.2.3-beta.3",
|
|
117
|
+
"java-bridge-win32-ia32-msvc": "2.2.3-beta.3",
|
|
118
|
+
"java-bridge-linux-arm64-gnu": "2.2.3-beta.3"
|
|
119
119
|
}
|
|
120
120
|
}
|