|
| 1 | +/* eslint-disable @typescript-eslint/no-unsafe-function-type */ |
| 2 | +/* eslint-disable @typescript-eslint/no-explicit-any */ |
| 3 | +// eslint-disable-next-line no-var |
| 4 | +declare var NodeJavaCore: NodeJavaCore.NodeAPI; |
| 5 | +export = NodeJavaCore; |
| 6 | + |
| 7 | +declare namespace NodeJavaCore { |
| 8 | + type JavaObject = any; |
| 9 | + type JavaError = Error & { cause?: JavaObject }; |
| 10 | + |
| 11 | + export interface Callback<T> { |
| 12 | + (err?: Error, result?: T): void; |
| 13 | + } |
| 14 | + |
| 15 | + export interface JavaCallback<T> { |
| 16 | + (err?: JavaError, result?: T): void; |
| 17 | + } |
| 18 | + |
| 19 | + interface Promisify { |
| 20 | + (fn: Function, receiver?: any): Function; |
| 21 | + } |
| 22 | + |
| 23 | + interface AsyncOptions { |
| 24 | + syncSuffix: string; |
| 25 | + asyncSuffix?: string | undefined; |
| 26 | + promiseSuffix?: string | undefined; |
| 27 | + promisify?: Promisify | undefined; |
| 28 | + ifReadOnlySuffix?: string | undefined; |
| 29 | + } |
| 30 | + |
| 31 | + interface ProxyFunctions { |
| 32 | + [index: string]: Function; |
| 33 | + } |
| 34 | + |
| 35 | + interface Java { |
| 36 | + classpath: string[]; |
| 37 | + options: string[]; |
| 38 | + asyncOptions: AsyncOptions; |
| 39 | + nativeBindingLocation: string; |
| 40 | + |
| 41 | + callMethod(instance: any, methodName: string, args: any[], callback: JavaError<any>): void; |
| 42 | + callMethodSync(instance: any, methodName: string, ...args: any[]): any; |
| 43 | + callStaticMethod(className: string, methodName: string, ...args: Array<any | JavaError<any>>): void; |
| 44 | + callStaticMethodSync(className: string, methodName: string, ...args: any[]): any; |
| 45 | + getStaticFieldValue(className: string, fieldName: string): any; |
| 46 | + setStaticFieldValue(className: string, fieldName: string, newValue: any): void; |
| 47 | + instanceOf(javaObject: any, className: string): boolean; |
| 48 | + registerClient( |
| 49 | + before: ((cb: Callback<void>) => void) | undefined | null, |
| 50 | + after?: (cb: Callback<void>) => void |
| 51 | + ): void; |
| 52 | + registerClientP(beforeP: (() => Promise<void>) | undefined | null, afterP?: () => Promise<void>): void; |
| 53 | + ensureJvm(done: Callback<void>): void; |
| 54 | + ensureJvm(): Promise<void>; |
| 55 | + isJvmCreated(): boolean; |
| 56 | + |
| 57 | + newByte(val: number): any; |
| 58 | + newChar(val: string | number): any; |
| 59 | + newDouble(val: number): any; |
| 60 | + newShort(val: number): any; |
| 61 | + newLong(val: number): any; |
| 62 | + newFloat(val: number): any; |
| 63 | + newDouble(val: number): any; |
| 64 | + |
| 65 | + import(className: string): any; |
| 66 | + newInstance(className: string, ...args: any[]): void; |
| 67 | + newInstanceSync(className: string, ...args: any[]): any; |
| 68 | + newInstanceP(className: string, ...args: any[]): Promise<any>; |
| 69 | + newArray(className: string, arg: any[]): any; |
| 70 | + getClassLoader(): any; |
| 71 | + |
| 72 | + newProxy(interfaceName: string, functions: ProxyFunctions): any; |
| 73 | + } |
| 74 | +} |
0 commit comments