java-bridge
Advanced tools
Comparing version 2.1.8-beta.1 to 2.1.8-beta.2
@@ -1,2 +0,2 @@ | ||
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.java=t():e.java=t()}(global,(()=>(()=>{var e={388:(e,t,a)=>{e=a.nmd(e);try{process.dlopen(e,__dirname+a(17).sep+a.p+"java.linux-x64-gnu.node")}catch(e){throw new Error("node-loader:\n"+e)}},163:(e,t,a)=>{const{existsSync:r,readFileSync:n}=a(147),{join:i}=a(17),{platform:o,arch:s}=process;let c=null,d=!1,l=null;function u(){if(process.report&&"function"==typeof process.report.getReport){const{glibcVersionRuntime:e}=process.report.getReport().header;return!e}try{return n("/usr/bin/ldd","utf8").includes("musl")}catch(e){return!0}}switch(o){case"android":switch(s){case"arm64":d=r(i(__dirname,"java.android-arm64.node"));try{c=d?a(Object(function(){var e=new Error("Cannot find module './java.android-arm64.node'");throw e.code="MODULE_NOT_FOUND",e}())):require("java-bridge-android-arm64")}catch(e){l=e}break;case"arm":d=r(i(__dirname,"java.android-arm-eabi.node"));try{c=d?a(Object(function(){var e=new Error("Cannot find module './java.android-arm-eabi.node'");throw e.code="MODULE_NOT_FOUND",e}())):require("java-bridge-android-arm-eabi")}catch(e){l=e}break;default:throw new Error(`Unsupported architecture on Android ${s}`)}break;case"win32":switch(s){case"x64":d=r(i(__dirname,"java.win32-x64-msvc.node"));try{c=d?a(Object(function(){var e=new Error("Cannot find module './java.win32-x64-msvc.node'");throw e.code="MODULE_NOT_FOUND",e}())):require("java-bridge-win32-x64-msvc")}catch(e){l=e}break;case"ia32":d=r(i(__dirname,"java.win32-ia32-msvc.node"));try{c=d?a(Object(function(){var e=new Error("Cannot find module './java.win32-ia32-msvc.node'");throw e.code="MODULE_NOT_FOUND",e}())):require("java-bridge-win32-ia32-msvc")}catch(e){l=e}break;case"arm64":d=r(i(__dirname,"java.win32-arm64-msvc.node"));try{c=d?a(Object(function(){var e=new Error("Cannot find module './java.win32-arm64-msvc.node'");throw e.code="MODULE_NOT_FOUND",e}())):require("java-bridge-win32-arm64-msvc")}catch(e){l=e}break;default:throw new Error(`Unsupported architecture on Windows: ${s}`)}break;case"darwin":switch(s){case"x64":d=r(i(__dirname,"java.darwin-x64.node"));try{c=d?a(Object(function(){var e=new Error("Cannot find module './java.darwin-x64.node'");throw e.code="MODULE_NOT_FOUND",e}())):require("java-bridge-darwin-x64")}catch(e){l=e}break;case"arm64":d=r(i(__dirname,"java.darwin-arm64.node"));try{c=d?a(Object(function(){var e=new Error("Cannot find module './java.darwin-arm64.node'");throw e.code="MODULE_NOT_FOUND",e}())):require("java-bridge-darwin-arm64")}catch(e){l=e}break;default:throw new Error(`Unsupported architecture on macOS: ${s}`)}break;case"freebsd":if("x64"!==s)throw new Error(`Unsupported architecture on FreeBSD: ${s}`);d=r(i(__dirname,"java.freebsd-x64.node"));try{c=d?a(Object(function(){var e=new Error("Cannot find module './java.freebsd-x64.node'");throw e.code="MODULE_NOT_FOUND",e}())):require("java-bridge-freebsd-x64")}catch(e){l=e}break;case"linux":switch(s){case"x64":if(u()){d=r(i(__dirname,"java.linux-x64-musl.node"));try{c=d?a(Object(function(){var e=new Error("Cannot find module './java.linux-x64-musl.node'");throw e.code="MODULE_NOT_FOUND",e}())):require("java-bridge-linux-x64-musl")}catch(e){l=e}}else{d=r(i(__dirname,"java.linux-x64-gnu.node"));try{c=d?a(388):require("java-bridge-linux-x64-gnu")}catch(e){l=e}}break;case"arm64":if(u()){d=r(i(__dirname,"java.linux-arm64-musl.node"));try{c=d?a(Object(function(){var e=new Error("Cannot find module './java.linux-arm64-musl.node'");throw e.code="MODULE_NOT_FOUND",e}())):require("java-bridge-linux-arm64-musl")}catch(e){l=e}}else{d=r(i(__dirname,"java.linux-arm64-gnu.node"));try{c=d?a(Object(function(){var e=new Error("Cannot find module './java.linux-arm64-gnu.node'");throw e.code="MODULE_NOT_FOUND",e}())):require("java-bridge-linux-arm64-gnu")}catch(e){l=e}}break;case"arm":d=r(i(__dirname,"java.linux-arm-gnueabihf.node"));try{c=d?a(Object(function(){var e=new Error("Cannot find module './java.linux-arm-gnueabihf.node'");throw e.code="MODULE_NOT_FOUND",e}())):require("java-bridge-linux-arm-gnueabihf")}catch(e){l=e}break;default:throw new Error(`Unsupported architecture on Linux: ${s}`)}break;default:throw new Error(`Unsupported OS: ${o}, architecture: ${s}`)}if(!c){if(l)throw l;throw new Error("Failed to load native binding")}const{Java:f,getClassFields:p,getField:y,setField:v,getStaticField:m,setStaticField:h,JavaInterfaceProxy:g,StdoutRedirect:b,getJavaLibPath:w}=c;e.exports.Java=f,e.exports.getClassFields=p,e.exports.getField=y,e.exports.setField=v,e.exports.getStaticField=m,e.exports.setStaticField=h,e.exports.JavaInterfaceProxy=g,e.exports.StdoutRedirect=b,e.exports.getJavaLibPath=w},238:function(e,t,a){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.TypescriptBulkDefinitionGenerator=void 0;const n=r(a(248));t.TypescriptBulkDefinitionGenerator=class{constructor(){this.declarations=[],this.resolvedImports=[]}async generate(e,t=null){let a=0;for(const r of e){const e=new n.default(r,t,this.resolvedImports),i=await e.generate();a+=i.length,this.declarations.push(...i)}return a}async save(e){await n.default.save(this.declarations,e)}get moduleDeclarations(){return this.declarations}}},248:function(e,t,a){"use strict";var r=this&&this.__createBinding||(Object.create?function(e,t,a,r){void 0===r&&(r=a);var n=Object.getOwnPropertyDescriptor(t,a);n&&!("get"in n?!t.__esModule:n.writable||n.configurable)||(n={enumerable:!0,get:function(){return t[a]}}),Object.defineProperty(e,r,n)}:function(e,t,a,r){void 0===r&&(r=a),e[r]=t[a]}),n=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),i=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var a in e)"default"!==a&&Object.prototype.hasOwnProperty.call(e,a)&&r(t,e,a);return n(t,e),t},o=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});const s=i(a(7)),c=a(236),d=o(a(147)),l=o(a(17)),u=s.default.createSourceFile("source.ts","",s.default.ScriptTarget.Latest,!1,s.default.ScriptKind.TS),f=["toString","wait","getClass","hashCode","notify","notifyAll","equals"];class p{constructor(e,t=null,a=[]){this.classname=e,this.progressCallback=t,this.resolvedImports=a,this.usesBasicOrJavaType=!1,this.additionalImports=[],this.importsToResolve=[]}static async convertMethods(e){const t=await(0,c.importClassAsync)("java.lang.reflect.Modifier"),a={};for(const r of e){const e=await r.getModifiers();if(await t.isPublic(e)){const n=await r.getName(),i=await r.getReturnType(),o=await r.getParameterTypes(),s={returnType:await i.getTypeName(),parameters:await Promise.all(o.map((e=>e.getTypeName()))),isStatic:await t.isStatic(e)};Object.hasOwn(a,n)?a[n].push(s):a[n]=[s]}}return a}async convertFields(e){const t=await(0,c.importClassAsync)("java.lang.reflect.Modifier"),a=[];for(const r of e){const e=await r.getModifiers();if(await t.isPublic(e)){const n=await r.getName(),i=await r.getType(),o=await i.getTypeName(),c=[s.default.factory.createModifier(s.SyntaxKind.PublicKeyword)];await t.isStatic(e)&&c.push(s.default.factory.createModifier(s.SyntaxKind.StaticKeyword)),await t.isFinal(e)&&c.push(s.default.factory.createModifier(s.SyntaxKind.ReadonlyKeyword));let d=s.default.factory.createPropertyDeclaration(c,n,void 0,this.javaTypeToTypescriptType(o,!0),void 0);d=s.default.addSyntheticLeadingComment(d,s.default.SyntaxKind.SingleLineCommentTrivia,` ================== Field ${n} ==================`,!0),a.push(s.default.addSyntheticLeadingComment(d,s.default.SyntaxKind.MultiLineCommentTrivia,`*\n * Original type: '${await i.getTypeName()}'\n `,!0))}}return a}async isAbstractOrInterface(e){const t=await(0,c.importClassAsync)("java.lang.reflect.Modifier");return await e.isInterface()||await t.isAbstract(await e.getModifiers())}createPrivateConstructor(){const e=s.default.factory.createConstructorDeclaration([s.default.factory.createModifier(s.default.SyntaxKind.PrivateKeyword)],[],s.default.factory.createBlock([s.default.factory.createExpressionStatement(s.default.factory.createCallExpression(s.default.factory.createSuper(),[],[]))],!0));return s.default.addSyntheticLeadingComment(e,s.default.SyntaxKind.MultiLineCommentTrivia,"*\n * Private constructor to prevent instantiation\n * as this is either an abstract class or an interface\n ",!0)}async convertConstructors(e){const t=await(0,c.importClassAsync)("java.lang.reflect.Modifier"),a=[];for(const r of e){const e=await r.getModifiers();if(await t.isPublic(e)){const e=await r.getParameterTypes();a.push(await Promise.all(e.map((e=>e.getTypeName()))))}}const r=a.map(((e,t)=>{const a=e.map(this.convertParameter.bind(this));let r=s.default.factory.createConstructorDeclaration([s.default.factory.createModifier(s.default.SyntaxKind.PublicKeyword)],a,void 0);return 0===t&&(r=s.default.addSyntheticLeadingComment(r,s.default.SyntaxKind.SingleLineCommentTrivia," ================== Constructors ==================",!0)),e.length>0&&(r=s.default.addSyntheticLeadingComment(r,s.default.SyntaxKind.MultiLineCommentTrivia,"*\n"+e.map(((e,t)=>` * @param var${t} original type: '${e}'\n`)).join("")+" ",!0)),r}));return[...a.map(((e,t)=>this.createMethod({returnType:this.classname,parameters:e,isStatic:!0},"newInstance",t,!1,!0))),...r]}primitiveToClassType(e){switch(e){case"boolean":return"java.lang.Boolean";case"byte":return"java.lang.Byte";case"char":return"java.lang.Character";case"short":return"java.lang.Short";case"int":return"java.lang.Integer";case"long":return"java.lang.Long";case"float":return"java.lang.Float";case"double":return"java.lang.Double";default:return e}}isPrimitive(e){return["boolean","byte","char","short","int","long","float","double"].includes(e)}javaTypeToTypescriptType(e,t,a=!0){const r=e=>a?s.default.factory.createUnionTypeNode([e,s.default.factory.createLiteralTypeNode(s.default.factory.createNull())]):e;switch(e){case"byte[]":case"java.lang.Byte[]":return r(s.default.factory.createTypeReferenceNode("Buffer"))}if(e.endsWith("[]"))return r(s.default.factory.createArrayTypeNode(this.javaTypeToTypescriptType(e.substring(0,e.length-2),t)));const n=e=>{this.resolvedImports.includes(e)||this.additionalImports.push(e),this.importsToResolve.push(e);const a=e===this.classname&&t;return s.default.factory.createTypeReferenceNode(e===this.classname?e.substring(e.lastIndexOf(".")+1)+(a?"Class":""):e.replaceAll(".","_"))},i=(r,...i)=>{const o=[s.default.factory.createKeywordTypeNode(r)];return!this.isPrimitive(e)&&a&&o.push(s.default.factory.createLiteralTypeNode(s.default.factory.createNull())),t?s.default.factory.createUnionTypeNode([n(this.primitiveToClassType(e)),...i.map((e=>s.default.factory.createKeywordTypeNode(e))),...o]):s.default.factory.createUnionTypeNode(o)};switch(e){case"int":case"java.lang.Integer":case"float":case"java.lang.Float":case"double":case"java.lang.Double":case"byte":case"java.lang.Byte":case"short":case"java.lang.Short":return i(s.SyntaxKind.NumberKeyword);case"long":case"java.lang.Long":return i(s.SyntaxKind.NumberKeyword,s.SyntaxKind.BigIntKeyword);case"char":case"java.lang.Character":case"java.lang.String":return r(s.default.factory.createKeywordTypeNode(s.SyntaxKind.StringKeyword));case"boolean":case"java.lang.Boolean":return i(s.SyntaxKind.BooleanKeyword);case"void":case"java.lang.Void":return s.default.factory.createKeywordTypeNode(s.SyntaxKind.VoidKeyword);case"java.lang.Object":return this.usesBasicOrJavaType=!0,r(s.default.factory.createTypeReferenceNode("BasicOrJavaType"));default:return r(n(e))}}convertParameter(e,t){const a="var"+t,r=this.javaTypeToTypescriptType(e,!0);return s.default.factory.createParameterDeclaration(void 0,void 0,a,void 0,r)}convertParameters(e){return e.parameters.map(this.convertParameter.bind(this))}static createMethodComment(e){return"*\n"+e.parameters.map(((e,t)=>` * @param var${t} original type: '${e}'\n`)).join("")+` * @return original return type: '${e.returnType}'\n `}createMethod(e,t,a,r,n){const i=s.default.factory.createModifier(s.default.SyntaxKind.PublicKeyword),o=s.default.factory.createModifier(s.default.SyntaxKind.StaticKeyword),c=[i];e.isStatic&&c.push(o);let d=this.javaTypeToTypescriptType(e.returnType,!1,!n);r||(d=s.default.factory.createTypeReferenceNode(s.default.factory.createIdentifier("Promise"),[d]));let l=s.default.factory.createMethodDeclaration(c,void 0,t+(r?"Sync":""),void 0,void 0,this.convertParameters(e),d,void 0);return 0===a&&(l=s.default.addSyntheticLeadingComment(l,s.default.SyntaxKind.SingleLineCommentTrivia,` ================== Method ${t} ==================`,!0)),s.default.addSyntheticLeadingComment(l,s.default.SyntaxKind.MultiLineCommentTrivia,p.createMethodComment(e),!0)}convertMethod(e,t){const a=[];for(let r=0;r<e.length;r++){const n=e[r],i=f.includes(t);a.push(this.createMethod(n,t,r,!1,i),this.createMethod(n,t,r,!0,i))}return a}getAdditionalImports(){const e=e=>{const t=this.classname.split("."),a=e.split(".");for(let e=0;e<t.length&&a[e]===t[e];e++)t[e]=null,a[e]=null;return"./"+t.filter((e=>!!e)).map((()=>"")).join("../")+a.filter((e=>!!e)).join("/")};return this.importsToResolve.filter((e=>e!=this.classname)).filter(((e,t,a)=>a.indexOf(e)===t)).map((t=>s.default.factory.createImportDeclaration(void 0,s.default.factory.createImportClause(!1,void 0,s.default.factory.createNamedImports([s.default.factory.createImportSpecifier(!1,s.default.factory.createIdentifier(t.substring(t.lastIndexOf(".")+1)),s.default.factory.createIdentifier(t.replaceAll(".","_")))])),s.default.factory.createStringLiteral(e(t)))))}getImports(){const e=[s.default.factory.createImportSpecifier(!1,void 0,s.default.factory.createIdentifier("importClass")),s.default.factory.createImportSpecifier(!1,void 0,s.default.factory.createIdentifier("JavaClass"))];this.usesBasicOrJavaType&&e.push(s.default.factory.createImportSpecifier(!1,void 0,s.default.factory.createIdentifier("BasicOrJavaType")));const t=s.default.factory.createNamedImports(e);return s.default.factory.createImportDeclaration(void 0,s.default.factory.createImportClause(!1,void 0,t),s.default.factory.createStringLiteral("java-bridge"))}getExportStatement(e,t){const a=s.default.factory.createClassDeclaration([s.default.factory.createModifier(s.default.SyntaxKind.ExportKeyword)],e,void 0,[s.default.factory.createHeritageClause(s.default.SyntaxKind.ExtendsKeyword,[s.default.factory.createExpressionWithTypeArguments(s.default.factory.createIdentifier(`importClass<typeof ${e}Class>("${this.classname}")`),void 0)])],t?[this.createPrivateConstructor()]:[]);return[s.default.addSyntheticLeadingComment(a,s.SyntaxKind.MultiLineCommentTrivia,`*\n * Class ${this.classname}.\n *\n * This actually imports the java class for further use.\n * The class ${e}Class only defines types, this is the class you should actually import.\n * Please note that this statement imports the underlying java class at runtime, which may take a while.\n * This was generated by java-bridge.\n * You should probably not edit this.\n `,!0),s.default.factory.createExportDefault(s.default.factory.createIdentifier(e))]}getText(e){return e.map((e=>e&&s.default.createPrinter({newLine:s.default.NewLineKind.LineFeed}).printNode(s.default.EmitHint.Unspecified,e,u)||"")).join("\n")}async generate(){if(this.resolvedImports.includes(this.classname))return[];this.resolvedImports.push(this.classname),this.progressCallback&&this.progressCallback(this.classname);const e=(await(0,c.importClassAsync)(this.classname)).class,t=this.classname.substring(this.classname.lastIndexOf(".")+1),a=(await e.getFields()).filter((function(e,t,a){return a.findIndex((t=>e.getNameSync()===t.getNameSync()))===t})),r=await e.getMethods(),n=await this.convertFields(a),i=await p.convertMethods(r);for(const[e,t]of Object.entries(i))n.push(...this.convertMethod(t,e));const o=await this.isAbstractOrInterface(e);if(!o){const t=await e.getDeclaredConstructors(),a=await this.convertConstructors(t);n.push(...a)}let d=s.default.factory.createClassDeclaration([s.default.factory.createModifier(s.default.SyntaxKind.ExportKeyword),s.default.factory.createModifier(s.default.SyntaxKind.DeclareKeyword)],t+"Class",void 0,[s.default.factory.createHeritageClause(s.default.SyntaxKind.ExtendsKeyword,[s.default.factory.createExpressionWithTypeArguments(s.default.factory.createIdentifier("JavaClass"),void 0)])],n);d=s.default.addSyntheticLeadingComment(d,s.default.SyntaxKind.MultiLineCommentTrivia,`*\n * This class just defines types, you should import ${t} instead of this.\n * This was generated by java-bridge.\n * You should probably not edit this.\n `,!0);const l=this.getText([this.getImports(),...this.getAdditionalImports(),null,d,null,...this.getExportStatement(t,o)]),u=[];for(const e of this.additionalImports){const t=new p(e,this.progressCallback,this.resolvedImports),a=await t.generate();u.push(...a)}return u.push({name:this.classname,contents:l}),u}static async save(e,t){for(const a of e){const e=a.name.split(".");e[e.length-1]=e[e.length-1]+".ts";const r=l.default.join(t,...e);await d.default.promises.mkdir(l.default.dirname(r),{recursive:!0}),await d.default.promises.writeFile(r,a.contents,{encoding:"utf8"})}}}t.default=p},91:(e,t)=>{"use strict";var a;Object.defineProperty(t,"__esModule",{value:!0}),t.JavaObject=t.JavaVersion=void 0,function(e){e.VER_1_1="1.1",e.VER_1_2="1.2",e.VER_1_4="1.4",e.VER_1_6="1.6",e.VER_1_8="1.8",e.VER_9="9",e.VER_10="10"}(a=t.JavaVersion||(t.JavaVersion={})),Object.freeze(a),t.JavaObject=class{}},236:function(e,t,a){"use strict";var r=this&&this.__createBinding||(Object.create?function(e,t,a,r){void 0===r&&(r=a);var n=Object.getOwnPropertyDescriptor(t,a);n&&!("get"in n?!t.__esModule:n.writable||n.configurable)||(n={enumerable:!0,get:function(){return t[a]}}),Object.defineProperty(e,r,n)}:function(e,t,a,r){void 0===r&&(r=a),e[r]=t[a]}),n=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),i=this&&this.__exportStar||function(e,t){for(var a in e)"default"===a||Object.prototype.hasOwnProperty.call(t,a)||r(t,e,a)},o=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var a in e)"default"!==a&&Object.prototype.hasOwnProperty.call(e,a)&&r(t,e,a);return n(t,e),t},s=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.TypescriptBulkDefinitionGenerator=t.TypescriptDefinitionGenerator=t.getJavaVersionSync=t.getJavaVersion=t.getJavaLibPath=t.UnknownJavaClass=t.JavaClassConstructor=t.JavaClass=t.JavaClassProxy=t.JavaClassInstance=t.JavaObject=t.JavaVersion=void 0;var c=a(91);Object.defineProperty(t,"JavaVersion",{enumerable:!0,get:function(){return c.JavaVersion}}),Object.defineProperty(t,"JavaObject",{enumerable:!0,get:function(){return c.JavaObject}}),Object.defineProperty(t,"JavaClassInstance",{enumerable:!0,get:function(){return c.JavaClassInstance}}),Object.defineProperty(t,"JavaClassProxy",{enumerable:!0,get:function(){return c.JavaClassProxy}}),Object.defineProperty(t,"JavaClass",{enumerable:!0,get:function(){return c.JavaClass}}),Object.defineProperty(t,"JavaClassConstructor",{enumerable:!0,get:function(){return c.JavaClassConstructor}}),Object.defineProperty(t,"UnknownJavaClass",{enumerable:!0,get:function(){return c.UnknownJavaClass}}),i(a(818),t);const d=o(a(818));t.default=d;var l=a(163);Object.defineProperty(t,"getJavaLibPath",{enumerable:!0,get:function(){return l.getJavaLibPath}});var u=a(102);Object.defineProperty(t,"getJavaVersion",{enumerable:!0,get:function(){return u.getJavaVersion}}),Object.defineProperty(t,"getJavaVersionSync",{enumerable:!0,get:function(){return u.getJavaVersionSync}});const f=s(a(248));t.TypescriptDefinitionGenerator=f.default;var p=a(238);Object.defineProperty(t,"TypescriptBulkDefinitionGenerator",{enumerable:!0,get:function(){return p.TypescriptBulkDefinitionGenerator}})},818:(e,t,a)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.getJavaInstance=t.newProxy=t.stdout=t.classpath=t.isInstanceOf=t.appendClasspathAny=t.appendClasspath=t.importClassAsync=t.importClass=t.setClassLoader=t.getClassLoader=t.ensureJvm=void 0;const r=a(163),n=a(841);let i=null;function o(e){return!i&&(i=new r.Java(e?.libPath,e?.version,e?.opts,e,(0,n.getJavaLibPath)(),(0,n.getNativeLibPath)()),!0)}function s(e,t){for(const a of(0,r.getClassFields)(e["class.proxy"],t)){const n=()=>t?(0,r.getStaticField)(e,a.name):(0,r.getField)(e,a.name);a.isFinal?Object.defineProperty(e,a.name,{get:n,enumerable:!0}):Object.defineProperty(e,a.name,{get:n,set:n=>t?(0,r.setStaticField)(e,a.name,n):(0,r.setField)(e,a.name,n),enumerable:!0})}}function c(e){return s(e,!0),class extends e{constructor(...e){super(...e),s(this,!1)}static async newInstanceAsync(...e){const t=await super.newInstanceAsync(...e);return s(t,!1),t}}}function d(e){o(),i.appendClasspath(e)}function l(e,t){o(),i.appendAnyToClasspath(e,t)}var u;t.ensureJvm=o,t.getClassLoader=function(){return o(),i.classLoader},t.setClassLoader=function(e){o(),i.classLoader=e},t.importClass=function(e){return o(),c(i.importClass(e))},t.importClassAsync=async function(e){return o(),c(await i.importClassAsync(e))},t.appendClasspath=d,t.appendClasspathAny=l,t.isInstanceOf=function(e,t){return o(),i.isInstanceOf(e,t)},(u=t.classpath||(t.classpath={})).append=function(e){d(e)},u.appendAny=function(e,t){l(e,t)},u.get=function(){return o(),i.loadedJars},(t.stdout||(t.stdout={})).enableRedirect=function(e,t){return o(),i.setStdoutCallbacks(e,t)},t.newProxy=function(e,t){o();const a=Object.create(null);for(const[e,r]of Object.entries(t))a[e]=(e,t,...a)=>{if(e)throw e;try{t(null,r(...a))}catch(e){e instanceof Error?t(e):t(new Error(e.toString()))}};return i.createInterfaceProxy(e,a)},t.getJavaInstance=function(){return i}},841:function(e,t,a){"use strict";var r=this&&this.__createBinding||(Object.create?function(e,t,a,r){void 0===r&&(r=a);var n=Object.getOwnPropertyDescriptor(t,a);n&&!("get"in n?!t.__esModule:n.writable||n.configurable)||(n={enumerable:!0,get:function(){return t[a]}}),Object.defineProperty(e,r,n)}:function(e,t,a,r){void 0===r&&(r=a),e[r]=t[a]}),n=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),i=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var a in e)"default"!==a&&Object.prototype.hasOwnProperty.call(e,a)&&r(t,e,a);return n(t,e),t},o=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.getJavaLibPath=t.getNativeLibPath=void 0;const s=o(a(17)),c=i(a(147)),d=o(a(230)),{platform:l,arch:u}=process;function f(e){const t=s.default.join(__dirname,e+".node");if(c.default.existsSync(t))return t;{const t=e.replaceAll(".","-").replace("java","java-bridge");return require&&require.resolve?require.resolve(t):a(955).resolve(t)}}function p(){return new Error(`Unsupported platform: ${l} ${u}`)}t.getNativeLibPath=function(){switch(l){case"android":switch(u){case"arm64":return f("java.android-arm64");case"arm":return f("java.android-arm-eabi");default:throw p()}case"win32":return f(`java.win32-${u}-msvc`);case"darwin":return f(`java.darwin-${u}`);case"freebsd":return f(`java.freebsd-${u}`);case"linux":switch(u){case"x64":case"arm64":return f(`java.linux-${u}-${function(){if(process.report&&"function"==typeof process.report.getReport){const{glibcVersionRuntime:e}=process.report.getReport().header;return!e}try{return(0,c.readFileSync)("/usr/bin/ldd","utf8").includes("musl")}catch(e){return!0}}()?"musl":"gnu"}`);case"arm":return f("java.linux-arm-gnueabihf");default:throw p()}default:throw p()}},t.getJavaLibPath=function(){const e=s.default.join(__dirname,"..","java-src","build","libs");let t=d.default.sync("*.jar",{cwd:e});if(0===t.length)throw new Error(`No java lib found in ${e}`);return s.default.join(e,t[0])}},102:(e,t,a)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.getJavaVersionSync=t.getJavaVersion=void 0;const r=a(818);t.getJavaVersion=async function(){const e=await(0,r.importClassAsync)("java.lang.System");return await e.getProperty("java.version")},t.getJavaVersionSync=function(){return(0,r.importClass)("java.lang.System").getPropertySync("java.version")}},955:e=>{function t(e){var t=new Error("Cannot find module '"+e+"'");throw t.code="MODULE_NOT_FOUND",t}t.keys=()=>[],t.resolve=t,t.id=955,e.exports=t},230:e=>{"use strict";e.exports=require("glob")},7:e=>{"use strict";e.exports=require("typescript")},147:e=>{"use strict";e.exports=require("fs")},17:e=>{"use strict";e.exports=require("path")}},t={};function a(r){var n=t[r];if(void 0!==n)return n.exports;var i=t[r]={id:r,loaded:!1,exports:{}};return e[r].call(i.exports,i,i.exports,a),i.loaded=!0,i.exports}return a.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),a.nmd=e=>(e.paths=[],e.children||(e.children=[]),e),a.p="",a(236)})())); | ||
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.java=t():e.java=t()}(global,(()=>(()=>{var e={388:(e,t,a)=>{e=a.nmd(e);try{process.dlopen(e,__dirname+a(17).sep+a.p+"java.linux-x64-gnu.node")}catch(e){throw new Error("node-loader:\n"+e)}},163:(e,t,a)=>{const{existsSync:r,readFileSync:n}=a(147),{join:i}=a(17),{platform:o,arch:s}=process;let c=null,d=!1,l=null;function u(){if(process.report&&"function"==typeof process.report.getReport){const{glibcVersionRuntime:e}=process.report.getReport().header;return!e}try{return n("/usr/bin/ldd","utf8").includes("musl")}catch(e){return!0}}switch(o){case"android":switch(s){case"arm64":d=r(i(__dirname,"java.android-arm64.node"));try{c=d?a(Object(function(){var e=new Error("Cannot find module './java.android-arm64.node'");throw e.code="MODULE_NOT_FOUND",e}())):require("java-bridge-android-arm64")}catch(e){l=e}break;case"arm":d=r(i(__dirname,"java.android-arm-eabi.node"));try{c=d?a(Object(function(){var e=new Error("Cannot find module './java.android-arm-eabi.node'");throw e.code="MODULE_NOT_FOUND",e}())):require("java-bridge-android-arm-eabi")}catch(e){l=e}break;default:throw new Error(`Unsupported architecture on Android ${s}`)}break;case"win32":switch(s){case"x64":d=r(i(__dirname,"java.win32-x64-msvc.node"));try{c=d?a(Object(function(){var e=new Error("Cannot find module './java.win32-x64-msvc.node'");throw e.code="MODULE_NOT_FOUND",e}())):require("java-bridge-win32-x64-msvc")}catch(e){l=e}break;case"ia32":d=r(i(__dirname,"java.win32-ia32-msvc.node"));try{c=d?a(Object(function(){var e=new Error("Cannot find module './java.win32-ia32-msvc.node'");throw e.code="MODULE_NOT_FOUND",e}())):require("java-bridge-win32-ia32-msvc")}catch(e){l=e}break;case"arm64":d=r(i(__dirname,"java.win32-arm64-msvc.node"));try{c=d?a(Object(function(){var e=new Error("Cannot find module './java.win32-arm64-msvc.node'");throw e.code="MODULE_NOT_FOUND",e}())):require("java-bridge-win32-arm64-msvc")}catch(e){l=e}break;default:throw new Error(`Unsupported architecture on Windows: ${s}`)}break;case"darwin":switch(s){case"x64":d=r(i(__dirname,"java.darwin-x64.node"));try{c=d?a(Object(function(){var e=new Error("Cannot find module './java.darwin-x64.node'");throw e.code="MODULE_NOT_FOUND",e}())):require("java-bridge-darwin-x64")}catch(e){l=e}break;case"arm64":d=r(i(__dirname,"java.darwin-arm64.node"));try{c=d?a(Object(function(){var e=new Error("Cannot find module './java.darwin-arm64.node'");throw e.code="MODULE_NOT_FOUND",e}())):require("java-bridge-darwin-arm64")}catch(e){l=e}break;default:throw new Error(`Unsupported architecture on macOS: ${s}`)}break;case"freebsd":if("x64"!==s)throw new Error(`Unsupported architecture on FreeBSD: ${s}`);d=r(i(__dirname,"java.freebsd-x64.node"));try{c=d?a(Object(function(){var e=new Error("Cannot find module './java.freebsd-x64.node'");throw e.code="MODULE_NOT_FOUND",e}())):require("java-bridge-freebsd-x64")}catch(e){l=e}break;case"linux":switch(s){case"x64":if(u()){d=r(i(__dirname,"java.linux-x64-musl.node"));try{c=d?a(Object(function(){var e=new Error("Cannot find module './java.linux-x64-musl.node'");throw e.code="MODULE_NOT_FOUND",e}())):require("java-bridge-linux-x64-musl")}catch(e){l=e}}else{d=r(i(__dirname,"java.linux-x64-gnu.node"));try{c=d?a(388):require("java-bridge-linux-x64-gnu")}catch(e){l=e}}break;case"arm64":if(u()){d=r(i(__dirname,"java.linux-arm64-musl.node"));try{c=d?a(Object(function(){var e=new Error("Cannot find module './java.linux-arm64-musl.node'");throw e.code="MODULE_NOT_FOUND",e}())):require("java-bridge-linux-arm64-musl")}catch(e){l=e}}else{d=r(i(__dirname,"java.linux-arm64-gnu.node"));try{c=d?a(Object(function(){var e=new Error("Cannot find module './java.linux-arm64-gnu.node'");throw e.code="MODULE_NOT_FOUND",e}())):require("java-bridge-linux-arm64-gnu")}catch(e){l=e}}break;case"arm":d=r(i(__dirname,"java.linux-arm-gnueabihf.node"));try{c=d?a(Object(function(){var e=new Error("Cannot find module './java.linux-arm-gnueabihf.node'");throw e.code="MODULE_NOT_FOUND",e}())):require("java-bridge-linux-arm-gnueabihf")}catch(e){l=e}break;default:throw new Error(`Unsupported architecture on Linux: ${s}`)}break;default:throw new Error(`Unsupported OS: ${o}, architecture: ${s}`)}if(!c){if(l)throw l;throw new Error("Failed to load native binding")}const{Java:f,getClassFields:p,getField:y,setField:v,getStaticField:m,setStaticField:h,JavaInterfaceProxy:g,StdoutRedirect:b,getJavaLibPath:w}=c;e.exports.Java=f,e.exports.getClassFields=p,e.exports.getField=y,e.exports.setField=v,e.exports.getStaticField=m,e.exports.setStaticField=h,e.exports.JavaInterfaceProxy=g,e.exports.StdoutRedirect=b,e.exports.getJavaLibPath=w},238:function(e,t,a){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.TypescriptBulkDefinitionGenerator=void 0;const n=r(a(248));t.TypescriptBulkDefinitionGenerator=class{constructor(){this.declarations=[],this.resolvedImports=[]}async generate(e,t=null){let a=0;for(const r of e){const e=new n.default(r,t,this.resolvedImports),i=await e.generate();a+=i.length,this.declarations.push(...i)}return a}async save(e){await n.default.save(this.declarations,e)}get moduleDeclarations(){return this.declarations}}},248:function(e,t,a){"use strict";var r=this&&this.__createBinding||(Object.create?function(e,t,a,r){void 0===r&&(r=a);var n=Object.getOwnPropertyDescriptor(t,a);n&&!("get"in n?!t.__esModule:n.writable||n.configurable)||(n={enumerable:!0,get:function(){return t[a]}}),Object.defineProperty(e,r,n)}:function(e,t,a,r){void 0===r&&(r=a),e[r]=t[a]}),n=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),i=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var a in e)"default"!==a&&Object.prototype.hasOwnProperty.call(e,a)&&r(t,e,a);return n(t,e),t},o=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});const s=i(a(7)),c=a(236),d=o(a(147)),l=o(a(17)),u=s.default.createSourceFile("source.ts","",s.default.ScriptTarget.Latest,!1,s.default.ScriptKind.TS),f=["toString","wait","getClass","hashCode","notify","notifyAll","equals"];class p{constructor(e,t=null,a=[]){this.classname=e,this.progressCallback=t,this.resolvedImports=a,this.usesBasicOrJavaType=!1,this.additionalImports=[],this.importsToResolve=[]}static async convertMethods(e){const t=await(0,c.importClassAsync)("java.lang.reflect.Modifier"),a={};for(const r of e){const e=await r.getModifiers();if(await t.isPublic(e)){const n=await r.getName(),i=await r.getReturnType(),o=await r.getParameterTypes(),s={returnType:await i.getTypeName(),parameters:await Promise.all(o.map((e=>e.getTypeName()))),isStatic:await t.isStatic(e)};Object.hasOwn(a,n)?a[n].push(s):a[n]=[s]}}return a}async convertFields(e){const t=await(0,c.importClassAsync)("java.lang.reflect.Modifier"),a=[];for(const r of e){const e=await r.getModifiers();if(await t.isPublic(e)){const n=await r.getName(),i=await r.getType(),o=await i.getTypeName(),c=[s.default.factory.createModifier(s.SyntaxKind.PublicKeyword)];await t.isStatic(e)&&c.push(s.default.factory.createModifier(s.SyntaxKind.StaticKeyword)),await t.isFinal(e)&&c.push(s.default.factory.createModifier(s.SyntaxKind.ReadonlyKeyword));let d=s.default.factory.createPropertyDeclaration(c,n,void 0,this.javaTypeToTypescriptType(o,!0),void 0);d=s.default.addSyntheticLeadingComment(d,s.default.SyntaxKind.SingleLineCommentTrivia,` ================== Field ${n} ==================`,!0),a.push(s.default.addSyntheticLeadingComment(d,s.default.SyntaxKind.MultiLineCommentTrivia,`*\n * Original type: '${await i.getTypeName()}'\n `,!0))}}return a}async isAbstractOrInterface(e){const t=await(0,c.importClassAsync)("java.lang.reflect.Modifier");return await e.isInterface()||await t.isAbstract(await e.getModifiers())}createPrivateConstructor(){const e=s.default.factory.createConstructorDeclaration([s.default.factory.createModifier(s.default.SyntaxKind.PrivateKeyword)],[],s.default.factory.createBlock([s.default.factory.createExpressionStatement(s.default.factory.createCallExpression(s.default.factory.createSuper(),[],[]))],!0));return s.default.addSyntheticLeadingComment(e,s.default.SyntaxKind.MultiLineCommentTrivia,"*\n * Private constructor to prevent instantiation\n * as this is either an abstract class or an interface\n ",!0)}async convertConstructors(e){const t=await(0,c.importClassAsync)("java.lang.reflect.Modifier"),a=[];for(const r of e){const e=await r.getModifiers();if(await t.isPublic(e)){const e=await r.getParameterTypes();a.push(await Promise.all(e.map((e=>e.getTypeName()))))}}const r=a.map(((e,t)=>{const a=e.map(this.convertParameter.bind(this));let r=s.default.factory.createConstructorDeclaration([s.default.factory.createModifier(s.default.SyntaxKind.PublicKeyword)],a,void 0);return 0===t&&(r=s.default.addSyntheticLeadingComment(r,s.default.SyntaxKind.SingleLineCommentTrivia," ================== Constructors ==================",!0)),e.length>0&&(r=s.default.addSyntheticLeadingComment(r,s.default.SyntaxKind.MultiLineCommentTrivia,"*\n"+e.map(((e,t)=>` * @param var${t} original type: '${e}'\n`)).join("")+" ",!0)),r}));return[...a.map(((e,t)=>this.createMethod({returnType:this.classname,parameters:e,isStatic:!0},"newInstance",t,!1,!0))),...r]}primitiveToClassType(e){switch(e){case"boolean":return"java.lang.Boolean";case"byte":return"java.lang.Byte";case"char":return"java.lang.Character";case"short":return"java.lang.Short";case"int":return"java.lang.Integer";case"long":return"java.lang.Long";case"float":return"java.lang.Float";case"double":return"java.lang.Double";default:return e}}isPrimitive(e){return["boolean","byte","char","short","int","long","float","double"].includes(e)}javaTypeToTypescriptType(e,t,a=!0){const r=e=>a?s.default.factory.createUnionTypeNode([e,s.default.factory.createLiteralTypeNode(s.default.factory.createNull())]):e;switch(e){case"byte[]":case"java.lang.Byte[]":return r(s.default.factory.createTypeReferenceNode("Buffer"))}if(e.endsWith("[]"))return r(s.default.factory.createArrayTypeNode(this.javaTypeToTypescriptType(e.substring(0,e.length-2),t)));const n=e=>{this.resolvedImports.includes(e)||this.additionalImports.push(e),this.importsToResolve.push(e);const a=e===this.classname&&t;return s.default.factory.createTypeReferenceNode(e===this.classname?e.substring(e.lastIndexOf(".")+1)+(a?"Class":""):e.replaceAll(".","_"))},i=(r,...i)=>{const o=[s.default.factory.createKeywordTypeNode(r)];return!this.isPrimitive(e)&&a&&o.push(s.default.factory.createLiteralTypeNode(s.default.factory.createNull())),t?s.default.factory.createUnionTypeNode([n(this.primitiveToClassType(e)),...i.map((e=>s.default.factory.createKeywordTypeNode(e))),...o]):s.default.factory.createUnionTypeNode(o)};switch(e){case"int":case"java.lang.Integer":case"float":case"java.lang.Float":case"double":case"java.lang.Double":case"byte":case"java.lang.Byte":case"short":case"java.lang.Short":return i(s.SyntaxKind.NumberKeyword);case"long":case"java.lang.Long":return i(s.SyntaxKind.NumberKeyword,s.SyntaxKind.BigIntKeyword);case"char":case"java.lang.Character":case"java.lang.String":return r(s.default.factory.createKeywordTypeNode(s.SyntaxKind.StringKeyword));case"boolean":case"java.lang.Boolean":return i(s.SyntaxKind.BooleanKeyword);case"void":case"java.lang.Void":return s.default.factory.createKeywordTypeNode(s.SyntaxKind.VoidKeyword);case"java.lang.Object":return this.usesBasicOrJavaType=!0,r(s.default.factory.createTypeReferenceNode("BasicOrJavaType"));default:return r(n(e))}}convertParameter(e,t){const a="var"+t,r=this.javaTypeToTypescriptType(e,!0);return s.default.factory.createParameterDeclaration(void 0,void 0,a,void 0,r)}convertParameters(e){return e.parameters.map(this.convertParameter.bind(this))}static createMethodComment(e){return"*\n"+e.parameters.map(((e,t)=>` * @param var${t} original type: '${e}'\n`)).join("")+` * @return original return type: '${e.returnType}'\n `}createMethod(e,t,a,r,n){const i=s.default.factory.createModifier(s.default.SyntaxKind.PublicKeyword),o=s.default.factory.createModifier(s.default.SyntaxKind.StaticKeyword),c=[i];e.isStatic&&c.push(o);let d=this.javaTypeToTypescriptType(e.returnType,!1,!n);r||(d=s.default.factory.createTypeReferenceNode(s.default.factory.createIdentifier("Promise"),[d]));let l=s.default.factory.createMethodDeclaration(c,void 0,t+(r?"Sync":""),void 0,void 0,this.convertParameters(e),d,void 0);return 0===a&&(l=s.default.addSyntheticLeadingComment(l,s.default.SyntaxKind.SingleLineCommentTrivia,` ================== Method ${t} ==================`,!0)),s.default.addSyntheticLeadingComment(l,s.default.SyntaxKind.MultiLineCommentTrivia,p.createMethodComment(e),!0)}convertMethod(e,t){const a=[];for(let r=0;r<e.length;r++){const n=e[r],i=f.includes(t);a.push(this.createMethod(n,t,r,!1,i),this.createMethod(n,t,r,!0,i))}return a}getAdditionalImports(){const e=e=>{const t=this.classname.split("."),a=e.split(".");for(let e=0;e<t.length&&a[e]===t[e];e++)t[e]=null,a[e]=null;return"./"+t.filter((e=>!!e)).map((()=>"")).join("../")+a.filter((e=>!!e)).join("/")};return this.importsToResolve.filter((e=>e!=this.classname)).filter(((e,t,a)=>a.indexOf(e)===t)).map((t=>s.default.factory.createImportDeclaration(void 0,s.default.factory.createImportClause(!1,void 0,s.default.factory.createNamedImports([s.default.factory.createImportSpecifier(!1,s.default.factory.createIdentifier(t.substring(t.lastIndexOf(".")+1)),s.default.factory.createIdentifier(t.replaceAll(".","_")))])),s.default.factory.createStringLiteral(e(t)))))}getImports(){const e=[s.default.factory.createImportSpecifier(!1,void 0,s.default.factory.createIdentifier("importClass")),s.default.factory.createImportSpecifier(!1,void 0,s.default.factory.createIdentifier("JavaClass"))];this.usesBasicOrJavaType&&e.push(s.default.factory.createImportSpecifier(!1,void 0,s.default.factory.createIdentifier("BasicOrJavaType")));const t=s.default.factory.createNamedImports(e);return s.default.factory.createImportDeclaration(void 0,s.default.factory.createImportClause(!1,void 0,t),s.default.factory.createStringLiteral("java-bridge"))}getExportStatement(e,t){const a=s.default.factory.createClassDeclaration([s.default.factory.createModifier(s.default.SyntaxKind.ExportKeyword)],e,void 0,[s.default.factory.createHeritageClause(s.default.SyntaxKind.ExtendsKeyword,[s.default.factory.createExpressionWithTypeArguments(s.default.factory.createIdentifier(`importClass<typeof ${e}Class>("${this.classname}")`),void 0)])],t?[this.createPrivateConstructor()]:[]);return[s.default.addSyntheticLeadingComment(a,s.SyntaxKind.MultiLineCommentTrivia,`*\n * Class ${this.classname}.\n *\n * This actually imports the java class for further use.\n * The class ${e}Class only defines types, this is the class you should actually import.\n * Please note that this statement imports the underlying java class at runtime, which may take a while.\n * This was generated by java-bridge.\n * You should probably not edit this.\n `,!0),s.default.factory.createExportDefault(s.default.factory.createIdentifier(e))]}getText(e){return e.map((e=>e&&s.default.createPrinter({newLine:s.default.NewLineKind.LineFeed}).printNode(s.default.EmitHint.Unspecified,e,u)||"")).join("\n")}async generate(){if(this.resolvedImports.includes(this.classname))return[];this.resolvedImports.push(this.classname),this.progressCallback&&this.progressCallback(this.classname);const e=(await(0,c.importClassAsync)(this.classname)).class,t=this.classname.substring(this.classname.lastIndexOf(".")+1),a=(await e.getFields()).filter((function(e,t,a){return a.findIndex((t=>e.getNameSync()===t.getNameSync()))===t})),r=await e.getMethods(),n=await this.convertFields(a),i=await p.convertMethods(r);for(const[e,t]of Object.entries(i))n.push(...this.convertMethod(t,e));const o=await this.isAbstractOrInterface(e);if(!o){const t=await e.getDeclaredConstructors(),a=await this.convertConstructors(t);n.push(...a)}let d=s.default.factory.createClassDeclaration([s.default.factory.createModifier(s.default.SyntaxKind.ExportKeyword),s.default.factory.createModifier(s.default.SyntaxKind.DeclareKeyword)],t+"Class",void 0,[s.default.factory.createHeritageClause(s.default.SyntaxKind.ExtendsKeyword,[s.default.factory.createExpressionWithTypeArguments(s.default.factory.createIdentifier("JavaClass"),void 0)])],n);d=s.default.addSyntheticLeadingComment(d,s.default.SyntaxKind.MultiLineCommentTrivia,`*\n * This class just defines types, you should import ${t} instead of this.\n * This was generated by java-bridge.\n * You should probably not edit this.\n `,!0);const l=this.getText([this.getImports(),...this.getAdditionalImports(),null,d,null,...this.getExportStatement(t,o)]),u=[];for(const e of this.additionalImports){const t=new p(e,this.progressCallback,this.resolvedImports),a=await t.generate();u.push(...a)}return u.push({name:this.classname,contents:l}),u}static async save(e,t){for(const a of e){const e=a.name.split(".");e[e.length-1]=e[e.length-1]+".ts";const r=l.default.join(t,...e);await d.default.promises.mkdir(l.default.dirname(r),{recursive:!0}),await d.default.promises.writeFile(r,a.contents,{encoding:"utf8"})}}}t.default=p},91:(e,t)=>{"use strict";var a;Object.defineProperty(t,"__esModule",{value:!0}),t.JavaObject=t.JavaVersion=void 0,function(e){e.VER_1_1="1.1",e.VER_1_2="1.2",e.VER_1_4="1.4",e.VER_1_6="1.6",e.VER_1_8="1.8",e.VER_9="9",e.VER_10="10"}(a=t.JavaVersion||(t.JavaVersion={})),Object.freeze(a),t.JavaObject=class{}},236:function(e,t,a){"use strict";var r=this&&this.__createBinding||(Object.create?function(e,t,a,r){void 0===r&&(r=a);var n=Object.getOwnPropertyDescriptor(t,a);n&&!("get"in n?!t.__esModule:n.writable||n.configurable)||(n={enumerable:!0,get:function(){return t[a]}}),Object.defineProperty(e,r,n)}:function(e,t,a,r){void 0===r&&(r=a),e[r]=t[a]}),n=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),i=this&&this.__exportStar||function(e,t){for(var a in e)"default"===a||Object.prototype.hasOwnProperty.call(t,a)||r(t,e,a)},o=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var a in e)"default"!==a&&Object.prototype.hasOwnProperty.call(e,a)&&r(t,e,a);return n(t,e),t},s=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.TypescriptBulkDefinitionGenerator=t.TypescriptDefinitionGenerator=t.getJavaVersionSync=t.getJavaVersion=t.getJavaLibPath=t.UnknownJavaClass=t.JavaClassConstructor=t.JavaClass=t.JavaClassProxy=t.JavaClassInstance=t.JavaObject=t.JavaVersion=void 0;var c=a(91);Object.defineProperty(t,"JavaVersion",{enumerable:!0,get:function(){return c.JavaVersion}}),Object.defineProperty(t,"JavaObject",{enumerable:!0,get:function(){return c.JavaObject}}),Object.defineProperty(t,"JavaClassInstance",{enumerable:!0,get:function(){return c.JavaClassInstance}}),Object.defineProperty(t,"JavaClassProxy",{enumerable:!0,get:function(){return c.JavaClassProxy}}),Object.defineProperty(t,"JavaClass",{enumerable:!0,get:function(){return c.JavaClass}}),Object.defineProperty(t,"JavaClassConstructor",{enumerable:!0,get:function(){return c.JavaClassConstructor}}),Object.defineProperty(t,"UnknownJavaClass",{enumerable:!0,get:function(){return c.UnknownJavaClass}}),i(a(818),t);const d=o(a(818));t.default=d;var l=a(163);Object.defineProperty(t,"getJavaLibPath",{enumerable:!0,get:function(){return l.getJavaLibPath}});var u=a(102);Object.defineProperty(t,"getJavaVersion",{enumerable:!0,get:function(){return u.getJavaVersion}}),Object.defineProperty(t,"getJavaVersionSync",{enumerable:!0,get:function(){return u.getJavaVersionSync}});const f=s(a(248));t.TypescriptDefinitionGenerator=f.default;var p=a(238);Object.defineProperty(t,"TypescriptBulkDefinitionGenerator",{enumerable:!0,get:function(){return p.TypescriptBulkDefinitionGenerator}})},818:(e,t,a)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.getJavaInstance=t.newProxy=t.stdout=t.classpath=t.isInstanceOf=t.appendClasspath=t.importClassAsync=t.importClass=t.setClassLoader=t.getClassLoader=t.ensureJvm=void 0;const r=a(163),n=a(841);let i=null;function o(e){return!i&&(i=new r.Java(e?.libPath,e?.version,e?.opts,e,(0,n.getJavaLibPath)(),(0,n.getNativeLibPath)()),!0)}function s(e,t){for(const a of(0,r.getClassFields)(e["class.proxy"],t)){const n=()=>t?(0,r.getStaticField)(e,a.name):(0,r.getField)(e,a.name);a.isFinal?Object.defineProperty(e,a.name,{get:n,enumerable:!0}):Object.defineProperty(e,a.name,{get:n,set:n=>t?(0,r.setStaticField)(e,a.name,n):(0,r.setField)(e,a.name,n),enumerable:!0})}}function c(e){return s(e,!0),class extends e{constructor(...e){super(...e),s(this,!1)}static async newInstanceAsync(...e){const t=await super.newInstanceAsync(...e);return s(t,!1),t}}}function d(e){o(),i.appendClasspath(e)}var l;t.ensureJvm=o,t.getClassLoader=function(){return o(),i.classLoader},t.setClassLoader=function(e){o(),i.classLoader=e},t.importClass=function(e){return o(),c(i.importClass(e))},t.importClassAsync=async function(e){return o(),c(await i.importClassAsync(e))},t.appendClasspath=d,t.isInstanceOf=function(e,t){return o(),i.isInstanceOf(e,t)},(l=t.classpath||(t.classpath={})).append=function(e){d(e)},l.get=function(){return o(),i.loadedJars},(t.stdout||(t.stdout={})).enableRedirect=function(e,t){return o(),i.setStdoutCallbacks(e,t)},t.newProxy=function(e,t){o();const a=Object.create(null);for(const[e,r]of Object.entries(t))a[e]=(e,t,...a)=>{if(e)throw e;try{t(null,r(...a))}catch(e){e instanceof Error?t(e):t(new Error(e.toString()))}};return i.createInterfaceProxy(e,a)},t.getJavaInstance=function(){return i}},841:function(e,t,a){"use strict";var r=this&&this.__createBinding||(Object.create?function(e,t,a,r){void 0===r&&(r=a);var n=Object.getOwnPropertyDescriptor(t,a);n&&!("get"in n?!t.__esModule:n.writable||n.configurable)||(n={enumerable:!0,get:function(){return t[a]}}),Object.defineProperty(e,r,n)}:function(e,t,a,r){void 0===r&&(r=a),e[r]=t[a]}),n=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),i=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var a in e)"default"!==a&&Object.prototype.hasOwnProperty.call(e,a)&&r(t,e,a);return n(t,e),t},o=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.getJavaLibPath=t.getNativeLibPath=void 0;const s=o(a(17)),c=i(a(147)),d=o(a(230)),{platform:l,arch:u}=process;function f(e){const t=s.default.join(__dirname,e+".node");if(c.default.existsSync(t))return t;{const t=e.replaceAll(".","-").replace("java","java-bridge");return require&&require.resolve?require.resolve(t):a(955).resolve(t)}}function p(){return new Error(`Unsupported platform: ${l} ${u}`)}t.getNativeLibPath=function(){switch(l){case"android":switch(u){case"arm64":return f("java.android-arm64");case"arm":return f("java.android-arm-eabi");default:throw p()}case"win32":return f(`java.win32-${u}-msvc`);case"darwin":return f(`java.darwin-${u}`);case"freebsd":return f(`java.freebsd-${u}`);case"linux":switch(u){case"x64":case"arm64":return f(`java.linux-${u}-${function(){if(process.report&&"function"==typeof process.report.getReport){const{glibcVersionRuntime:e}=process.report.getReport().header;return!e}try{return(0,c.readFileSync)("/usr/bin/ldd","utf8").includes("musl")}catch(e){return!0}}()?"musl":"gnu"}`);case"arm":return f("java.linux-arm-gnueabihf");default:throw p()}default:throw p()}},t.getJavaLibPath=function(){const e=s.default.join(__dirname,"..","java-src","build","libs");let t=d.default.sync("*.jar",{cwd:e});if(0===t.length)throw new Error(`No java lib found in ${e}`);return s.default.join(e,t[0])}},102:(e,t,a)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.getJavaVersionSync=t.getJavaVersion=void 0;const r=a(818);t.getJavaVersion=async function(){const e=await(0,r.importClassAsync)("java.lang.System");return await e.getProperty("java.version")},t.getJavaVersionSync=function(){return(0,r.importClass)("java.lang.System").getPropertySync("java.version")}},955:e=>{function t(e){var t=new Error("Cannot find module '"+e+"'");throw t.code="MODULE_NOT_FOUND",t}t.keys=()=>[],t.resolve=t,t.id=955,e.exports=t},230:e=>{"use strict";e.exports=require("glob")},7:e=>{"use strict";e.exports=require("typescript")},147:e=>{"use strict";e.exports=require("fs")},17:e=>{"use strict";e.exports=require("path")}},t={};function a(r){var n=t[r];if(void 0!==n)return n.exports;var i=t[r]={id:r,loaded:!1,exports:{}};return e[r].call(i.exports,i,i.exports,a),i.loaded=!0,i.exports}return a.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),a.nmd=e=>(e.paths=[],e.children||(e.children=[]),e),a.p="",a(236)})())); | ||
//# sourceMappingURL=index.prod.min.js.map |
#!/usr/bin/env node | ||
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.java=t():e.java=t()}(global,(()=>(()=>{var __webpack_modules__={388:(e,t,a)=>{e=a.nmd(e);try{process.dlopen(e,__dirname+a(17).sep+a.p+"java.linux-x64-gnu.node")}catch(e){throw new Error("node-loader:\n"+e)}},163:(e,t,a)=>{const{existsSync:r,readFileSync:n}=a(147),{join:i}=a(17),{platform:o,arch:s}=process;let c=null,d=!1,l=null;function u(){if(process.report&&"function"==typeof process.report.getReport){const{glibcVersionRuntime:e}=process.report.getReport().header;return!e}try{return n("/usr/bin/ldd","utf8").includes("musl")}catch(e){return!0}}switch(o){case"android":switch(s){case"arm64":d=r(i(__dirname,"java.android-arm64.node"));try{c=d?a(Object(function(){var e=new Error("Cannot find module './java.android-arm64.node'");throw e.code="MODULE_NOT_FOUND",e}())):require("java-bridge-android-arm64")}catch(e){l=e}break;case"arm":d=r(i(__dirname,"java.android-arm-eabi.node"));try{c=d?a(Object(function(){var e=new Error("Cannot find module './java.android-arm-eabi.node'");throw e.code="MODULE_NOT_FOUND",e}())):require("java-bridge-android-arm-eabi")}catch(e){l=e}break;default:throw new Error(`Unsupported architecture on Android ${s}`)}break;case"win32":switch(s){case"x64":d=r(i(__dirname,"java.win32-x64-msvc.node"));try{c=d?a(Object(function(){var e=new Error("Cannot find module './java.win32-x64-msvc.node'");throw e.code="MODULE_NOT_FOUND",e}())):require("java-bridge-win32-x64-msvc")}catch(e){l=e}break;case"ia32":d=r(i(__dirname,"java.win32-ia32-msvc.node"));try{c=d?a(Object(function(){var e=new Error("Cannot find module './java.win32-ia32-msvc.node'");throw e.code="MODULE_NOT_FOUND",e}())):require("java-bridge-win32-ia32-msvc")}catch(e){l=e}break;case"arm64":d=r(i(__dirname,"java.win32-arm64-msvc.node"));try{c=d?a(Object(function(){var e=new Error("Cannot find module './java.win32-arm64-msvc.node'");throw e.code="MODULE_NOT_FOUND",e}())):require("java-bridge-win32-arm64-msvc")}catch(e){l=e}break;default:throw new Error(`Unsupported architecture on Windows: ${s}`)}break;case"darwin":switch(s){case"x64":d=r(i(__dirname,"java.darwin-x64.node"));try{c=d?a(Object(function(){var e=new Error("Cannot find module './java.darwin-x64.node'");throw e.code="MODULE_NOT_FOUND",e}())):require("java-bridge-darwin-x64")}catch(e){l=e}break;case"arm64":d=r(i(__dirname,"java.darwin-arm64.node"));try{c=d?a(Object(function(){var e=new Error("Cannot find module './java.darwin-arm64.node'");throw e.code="MODULE_NOT_FOUND",e}())):require("java-bridge-darwin-arm64")}catch(e){l=e}break;default:throw new Error(`Unsupported architecture on macOS: ${s}`)}break;case"freebsd":if("x64"!==s)throw new Error(`Unsupported architecture on FreeBSD: ${s}`);d=r(i(__dirname,"java.freebsd-x64.node"));try{c=d?a(Object(function(){var e=new Error("Cannot find module './java.freebsd-x64.node'");throw e.code="MODULE_NOT_FOUND",e}())):require("java-bridge-freebsd-x64")}catch(e){l=e}break;case"linux":switch(s){case"x64":if(u()){d=r(i(__dirname,"java.linux-x64-musl.node"));try{c=d?a(Object(function(){var e=new Error("Cannot find module './java.linux-x64-musl.node'");throw e.code="MODULE_NOT_FOUND",e}())):require("java-bridge-linux-x64-musl")}catch(e){l=e}}else{d=r(i(__dirname,"java.linux-x64-gnu.node"));try{c=d?a(388):require("java-bridge-linux-x64-gnu")}catch(e){l=e}}break;case"arm64":if(u()){d=r(i(__dirname,"java.linux-arm64-musl.node"));try{c=d?a(Object(function(){var e=new Error("Cannot find module './java.linux-arm64-musl.node'");throw e.code="MODULE_NOT_FOUND",e}())):require("java-bridge-linux-arm64-musl")}catch(e){l=e}}else{d=r(i(__dirname,"java.linux-arm64-gnu.node"));try{c=d?a(Object(function(){var e=new Error("Cannot find module './java.linux-arm64-gnu.node'");throw e.code="MODULE_NOT_FOUND",e}())):require("java-bridge-linux-arm64-gnu")}catch(e){l=e}}break;case"arm":d=r(i(__dirname,"java.linux-arm-gnueabihf.node"));try{c=d?a(Object(function(){var e=new Error("Cannot find module './java.linux-arm-gnueabihf.node'");throw e.code="MODULE_NOT_FOUND",e}())):require("java-bridge-linux-arm-gnueabihf")}catch(e){l=e}break;default:throw new Error(`Unsupported architecture on Linux: ${s}`)}break;default:throw new Error(`Unsupported OS: ${o}, architecture: ${s}`)}if(!c){if(l)throw l;throw new Error("Failed to load native binding")}const{Java:f,getClassFields:p,getField:m,setField:y,getStaticField:v,setStaticField:h,JavaInterfaceProxy:g,StdoutRedirect:b,getJavaLibPath:_}=c;e.exports.Java=f,e.exports.getClassFields=p,e.exports.getField=m,e.exports.setField=y,e.exports.getStaticField=v,e.exports.setStaticField=h,e.exports.JavaInterfaceProxy=g,e.exports.StdoutRedirect=b,e.exports.getJavaLibPath=_},238:function(e,t,a){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.TypescriptBulkDefinitionGenerator=void 0;const n=r(a(248));t.TypescriptBulkDefinitionGenerator=class{constructor(){this.declarations=[],this.resolvedImports=[]}async generate(e,t=null){let a=0;for(const r of e){const e=new n.default(r,t,this.resolvedImports),i=await e.generate();a+=i.length,this.declarations.push(...i)}return a}async save(e){await n.default.save(this.declarations,e)}get moduleDeclarations(){return this.declarations}}},248:function(e,t,a){"use strict";var r=this&&this.__createBinding||(Object.create?function(e,t,a,r){void 0===r&&(r=a);var n=Object.getOwnPropertyDescriptor(t,a);n&&!("get"in n?!t.__esModule:n.writable||n.configurable)||(n={enumerable:!0,get:function(){return t[a]}}),Object.defineProperty(e,r,n)}:function(e,t,a,r){void 0===r&&(r=a),e[r]=t[a]}),n=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),i=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var a in e)"default"!==a&&Object.prototype.hasOwnProperty.call(e,a)&&r(t,e,a);return n(t,e),t},o=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});const s=i(a(7)),c=a(236),d=o(a(147)),l=o(a(17)),u=s.default.createSourceFile("source.ts","",s.default.ScriptTarget.Latest,!1,s.default.ScriptKind.TS),f=["toString","wait","getClass","hashCode","notify","notifyAll","equals"];class p{constructor(e,t=null,a=[]){this.classname=e,this.progressCallback=t,this.resolvedImports=a,this.usesBasicOrJavaType=!1,this.additionalImports=[],this.importsToResolve=[]}static async convertMethods(e){const t=await(0,c.importClassAsync)("java.lang.reflect.Modifier"),a={};for(const r of e){const e=await r.getModifiers();if(await t.isPublic(e)){const n=await r.getName(),i=await r.getReturnType(),o=await r.getParameterTypes(),s={returnType:await i.getTypeName(),parameters:await Promise.all(o.map((e=>e.getTypeName()))),isStatic:await t.isStatic(e)};Object.hasOwn(a,n)?a[n].push(s):a[n]=[s]}}return a}async convertFields(e){const t=await(0,c.importClassAsync)("java.lang.reflect.Modifier"),a=[];for(const r of e){const e=await r.getModifiers();if(await t.isPublic(e)){const n=await r.getName(),i=await r.getType(),o=await i.getTypeName(),c=[s.default.factory.createModifier(s.SyntaxKind.PublicKeyword)];await t.isStatic(e)&&c.push(s.default.factory.createModifier(s.SyntaxKind.StaticKeyword)),await t.isFinal(e)&&c.push(s.default.factory.createModifier(s.SyntaxKind.ReadonlyKeyword));let d=s.default.factory.createPropertyDeclaration(c,n,void 0,this.javaTypeToTypescriptType(o,!0),void 0);d=s.default.addSyntheticLeadingComment(d,s.default.SyntaxKind.SingleLineCommentTrivia,` ================== Field ${n} ==================`,!0),a.push(s.default.addSyntheticLeadingComment(d,s.default.SyntaxKind.MultiLineCommentTrivia,`*\n * Original type: '${await i.getTypeName()}'\n `,!0))}}return a}async isAbstractOrInterface(e){const t=await(0,c.importClassAsync)("java.lang.reflect.Modifier");return await e.isInterface()||await t.isAbstract(await e.getModifiers())}createPrivateConstructor(){const e=s.default.factory.createConstructorDeclaration([s.default.factory.createModifier(s.default.SyntaxKind.PrivateKeyword)],[],s.default.factory.createBlock([s.default.factory.createExpressionStatement(s.default.factory.createCallExpression(s.default.factory.createSuper(),[],[]))],!0));return s.default.addSyntheticLeadingComment(e,s.default.SyntaxKind.MultiLineCommentTrivia,"*\n * Private constructor to prevent instantiation\n * as this is either an abstract class or an interface\n ",!0)}async convertConstructors(e){const t=await(0,c.importClassAsync)("java.lang.reflect.Modifier"),a=[];for(const r of e){const e=await r.getModifiers();if(await t.isPublic(e)){const e=await r.getParameterTypes();a.push(await Promise.all(e.map((e=>e.getTypeName()))))}}const r=a.map(((e,t)=>{const a=e.map(this.convertParameter.bind(this));let r=s.default.factory.createConstructorDeclaration([s.default.factory.createModifier(s.default.SyntaxKind.PublicKeyword)],a,void 0);return 0===t&&(r=s.default.addSyntheticLeadingComment(r,s.default.SyntaxKind.SingleLineCommentTrivia," ================== Constructors ==================",!0)),e.length>0&&(r=s.default.addSyntheticLeadingComment(r,s.default.SyntaxKind.MultiLineCommentTrivia,"*\n"+e.map(((e,t)=>` * @param var${t} original type: '${e}'\n`)).join("")+" ",!0)),r}));return[...a.map(((e,t)=>this.createMethod({returnType:this.classname,parameters:e,isStatic:!0},"newInstance",t,!1,!0))),...r]}primitiveToClassType(e){switch(e){case"boolean":return"java.lang.Boolean";case"byte":return"java.lang.Byte";case"char":return"java.lang.Character";case"short":return"java.lang.Short";case"int":return"java.lang.Integer";case"long":return"java.lang.Long";case"float":return"java.lang.Float";case"double":return"java.lang.Double";default:return e}}isPrimitive(e){return["boolean","byte","char","short","int","long","float","double"].includes(e)}javaTypeToTypescriptType(e,t,a=!0){const r=e=>a?s.default.factory.createUnionTypeNode([e,s.default.factory.createLiteralTypeNode(s.default.factory.createNull())]):e;switch(e){case"byte[]":case"java.lang.Byte[]":return r(s.default.factory.createTypeReferenceNode("Buffer"))}if(e.endsWith("[]"))return r(s.default.factory.createArrayTypeNode(this.javaTypeToTypescriptType(e.substring(0,e.length-2),t)));const n=e=>{this.resolvedImports.includes(e)||this.additionalImports.push(e),this.importsToResolve.push(e);const a=e===this.classname&&t;return s.default.factory.createTypeReferenceNode(e===this.classname?e.substring(e.lastIndexOf(".")+1)+(a?"Class":""):e.replaceAll(".","_"))},i=(r,...i)=>{const o=[s.default.factory.createKeywordTypeNode(r)];return!this.isPrimitive(e)&&a&&o.push(s.default.factory.createLiteralTypeNode(s.default.factory.createNull())),t?s.default.factory.createUnionTypeNode([n(this.primitiveToClassType(e)),...i.map((e=>s.default.factory.createKeywordTypeNode(e))),...o]):s.default.factory.createUnionTypeNode(o)};switch(e){case"int":case"java.lang.Integer":case"float":case"java.lang.Float":case"double":case"java.lang.Double":case"byte":case"java.lang.Byte":case"short":case"java.lang.Short":return i(s.SyntaxKind.NumberKeyword);case"long":case"java.lang.Long":return i(s.SyntaxKind.NumberKeyword,s.SyntaxKind.BigIntKeyword);case"char":case"java.lang.Character":case"java.lang.String":return r(s.default.factory.createKeywordTypeNode(s.SyntaxKind.StringKeyword));case"boolean":case"java.lang.Boolean":return i(s.SyntaxKind.BooleanKeyword);case"void":case"java.lang.Void":return s.default.factory.createKeywordTypeNode(s.SyntaxKind.VoidKeyword);case"java.lang.Object":return this.usesBasicOrJavaType=!0,r(s.default.factory.createTypeReferenceNode("BasicOrJavaType"));default:return r(n(e))}}convertParameter(e,t){const a="var"+t,r=this.javaTypeToTypescriptType(e,!0);return s.default.factory.createParameterDeclaration(void 0,void 0,a,void 0,r)}convertParameters(e){return e.parameters.map(this.convertParameter.bind(this))}static createMethodComment(e){return"*\n"+e.parameters.map(((e,t)=>` * @param var${t} original type: '${e}'\n`)).join("")+` * @return original return type: '${e.returnType}'\n `}createMethod(e,t,a,r,n){const i=s.default.factory.createModifier(s.default.SyntaxKind.PublicKeyword),o=s.default.factory.createModifier(s.default.SyntaxKind.StaticKeyword),c=[i];e.isStatic&&c.push(o);let d=this.javaTypeToTypescriptType(e.returnType,!1,!n);r||(d=s.default.factory.createTypeReferenceNode(s.default.factory.createIdentifier("Promise"),[d]));let l=s.default.factory.createMethodDeclaration(c,void 0,t+(r?"Sync":""),void 0,void 0,this.convertParameters(e),d,void 0);return 0===a&&(l=s.default.addSyntheticLeadingComment(l,s.default.SyntaxKind.SingleLineCommentTrivia,` ================== Method ${t} ==================`,!0)),s.default.addSyntheticLeadingComment(l,s.default.SyntaxKind.MultiLineCommentTrivia,p.createMethodComment(e),!0)}convertMethod(e,t){const a=[];for(let r=0;r<e.length;r++){const n=e[r],i=f.includes(t);a.push(this.createMethod(n,t,r,!1,i),this.createMethod(n,t,r,!0,i))}return a}getAdditionalImports(){const e=e=>{const t=this.classname.split("."),a=e.split(".");for(let e=0;e<t.length&&a[e]===t[e];e++)t[e]=null,a[e]=null;return"./"+t.filter((e=>!!e)).map((()=>"")).join("../")+a.filter((e=>!!e)).join("/")};return this.importsToResolve.filter((e=>e!=this.classname)).filter(((e,t,a)=>a.indexOf(e)===t)).map((t=>s.default.factory.createImportDeclaration(void 0,s.default.factory.createImportClause(!1,void 0,s.default.factory.createNamedImports([s.default.factory.createImportSpecifier(!1,s.default.factory.createIdentifier(t.substring(t.lastIndexOf(".")+1)),s.default.factory.createIdentifier(t.replaceAll(".","_")))])),s.default.factory.createStringLiteral(e(t)))))}getImports(){const e=[s.default.factory.createImportSpecifier(!1,void 0,s.default.factory.createIdentifier("importClass")),s.default.factory.createImportSpecifier(!1,void 0,s.default.factory.createIdentifier("JavaClass"))];this.usesBasicOrJavaType&&e.push(s.default.factory.createImportSpecifier(!1,void 0,s.default.factory.createIdentifier("BasicOrJavaType")));const t=s.default.factory.createNamedImports(e);return s.default.factory.createImportDeclaration(void 0,s.default.factory.createImportClause(!1,void 0,t),s.default.factory.createStringLiteral("java-bridge"))}getExportStatement(e,t){const a=s.default.factory.createClassDeclaration([s.default.factory.createModifier(s.default.SyntaxKind.ExportKeyword)],e,void 0,[s.default.factory.createHeritageClause(s.default.SyntaxKind.ExtendsKeyword,[s.default.factory.createExpressionWithTypeArguments(s.default.factory.createIdentifier(`importClass<typeof ${e}Class>("${this.classname}")`),void 0)])],t?[this.createPrivateConstructor()]:[]);return[s.default.addSyntheticLeadingComment(a,s.SyntaxKind.MultiLineCommentTrivia,`*\n * Class ${this.classname}.\n *\n * This actually imports the java class for further use.\n * The class ${e}Class only defines types, this is the class you should actually import.\n * Please note that this statement imports the underlying java class at runtime, which may take a while.\n * This was generated by java-bridge.\n * You should probably not edit this.\n `,!0),s.default.factory.createExportDefault(s.default.factory.createIdentifier(e))]}getText(e){return e.map((e=>e&&s.default.createPrinter({newLine:s.default.NewLineKind.LineFeed}).printNode(s.default.EmitHint.Unspecified,e,u)||"")).join("\n")}async generate(){if(this.resolvedImports.includes(this.classname))return[];this.resolvedImports.push(this.classname),this.progressCallback&&this.progressCallback(this.classname);const e=(await(0,c.importClassAsync)(this.classname)).class,t=this.classname.substring(this.classname.lastIndexOf(".")+1),a=(await e.getFields()).filter((function(e,t,a){return a.findIndex((t=>e.getNameSync()===t.getNameSync()))===t})),r=await e.getMethods(),n=await this.convertFields(a),i=await p.convertMethods(r);for(const[e,t]of Object.entries(i))n.push(...this.convertMethod(t,e));const o=await this.isAbstractOrInterface(e);if(!o){const t=await e.getDeclaredConstructors(),a=await this.convertConstructors(t);n.push(...a)}let d=s.default.factory.createClassDeclaration([s.default.factory.createModifier(s.default.SyntaxKind.ExportKeyword),s.default.factory.createModifier(s.default.SyntaxKind.DeclareKeyword)],t+"Class",void 0,[s.default.factory.createHeritageClause(s.default.SyntaxKind.ExtendsKeyword,[s.default.factory.createExpressionWithTypeArguments(s.default.factory.createIdentifier("JavaClass"),void 0)])],n);d=s.default.addSyntheticLeadingComment(d,s.default.SyntaxKind.MultiLineCommentTrivia,`*\n * This class just defines types, you should import ${t} instead of this.\n * This was generated by java-bridge.\n * You should probably not edit this.\n `,!0);const l=this.getText([this.getImports(),...this.getAdditionalImports(),null,d,null,...this.getExportStatement(t,o)]),u=[];for(const e of this.additionalImports){const t=new p(e,this.progressCallback,this.resolvedImports),a=await t.generate();u.push(...a)}return u.push({name:this.classname,contents:l}),u}static async save(e,t){for(const a of e){const e=a.name.split(".");e[e.length-1]=e[e.length-1]+".ts";const r=l.default.join(t,...e);await d.default.promises.mkdir(l.default.dirname(r),{recursive:!0}),await d.default.promises.writeFile(r,a.contents,{encoding:"utf8"})}}}t.default=p},91:(e,t)=>{"use strict";var a;Object.defineProperty(t,"__esModule",{value:!0}),t.JavaObject=t.JavaVersion=void 0,function(e){e.VER_1_1="1.1",e.VER_1_2="1.2",e.VER_1_4="1.4",e.VER_1_6="1.6",e.VER_1_8="1.8",e.VER_9="9",e.VER_10="10"}(a=t.JavaVersion||(t.JavaVersion={})),Object.freeze(a),t.JavaObject=class{}},236:function(e,t,a){"use strict";var r=this&&this.__createBinding||(Object.create?function(e,t,a,r){void 0===r&&(r=a);var n=Object.getOwnPropertyDescriptor(t,a);n&&!("get"in n?!t.__esModule:n.writable||n.configurable)||(n={enumerable:!0,get:function(){return t[a]}}),Object.defineProperty(e,r,n)}:function(e,t,a,r){void 0===r&&(r=a),e[r]=t[a]}),n=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),i=this&&this.__exportStar||function(e,t){for(var a in e)"default"===a||Object.prototype.hasOwnProperty.call(t,a)||r(t,e,a)},o=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var a in e)"default"!==a&&Object.prototype.hasOwnProperty.call(e,a)&&r(t,e,a);return n(t,e),t},s=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.TypescriptBulkDefinitionGenerator=t.TypescriptDefinitionGenerator=t.getJavaVersionSync=t.getJavaVersion=t.getJavaLibPath=t.UnknownJavaClass=t.JavaClassConstructor=t.JavaClass=t.JavaClassProxy=t.JavaClassInstance=t.JavaObject=t.JavaVersion=void 0;var c=a(91);Object.defineProperty(t,"JavaVersion",{enumerable:!0,get:function(){return c.JavaVersion}}),Object.defineProperty(t,"JavaObject",{enumerable:!0,get:function(){return c.JavaObject}}),Object.defineProperty(t,"JavaClassInstance",{enumerable:!0,get:function(){return c.JavaClassInstance}}),Object.defineProperty(t,"JavaClassProxy",{enumerable:!0,get:function(){return c.JavaClassProxy}}),Object.defineProperty(t,"JavaClass",{enumerable:!0,get:function(){return c.JavaClass}}),Object.defineProperty(t,"JavaClassConstructor",{enumerable:!0,get:function(){return c.JavaClassConstructor}}),Object.defineProperty(t,"UnknownJavaClass",{enumerable:!0,get:function(){return c.UnknownJavaClass}}),i(a(818),t);const d=o(a(818));t.default=d;var l=a(163);Object.defineProperty(t,"getJavaLibPath",{enumerable:!0,get:function(){return l.getJavaLibPath}});var u=a(102);Object.defineProperty(t,"getJavaVersion",{enumerable:!0,get:function(){return u.getJavaVersion}}),Object.defineProperty(t,"getJavaVersionSync",{enumerable:!0,get:function(){return u.getJavaVersionSync}});const f=s(a(248));t.TypescriptDefinitionGenerator=f.default;var p=a(238);Object.defineProperty(t,"TypescriptBulkDefinitionGenerator",{enumerable:!0,get:function(){return p.TypescriptBulkDefinitionGenerator}})},818:(e,t,a)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.getJavaInstance=t.newProxy=t.stdout=t.classpath=t.isInstanceOf=t.appendClasspathAny=t.appendClasspath=t.importClassAsync=t.importClass=t.setClassLoader=t.getClassLoader=t.ensureJvm=void 0;const r=a(163),n=a(841);let i=null;function o(e){return!i&&(i=new r.Java(e?.libPath,e?.version,e?.opts,e,(0,n.getJavaLibPath)(),(0,n.getNativeLibPath)()),!0)}function s(e,t){for(const a of(0,r.getClassFields)(e["class.proxy"],t)){const n=()=>t?(0,r.getStaticField)(e,a.name):(0,r.getField)(e,a.name);a.isFinal?Object.defineProperty(e,a.name,{get:n,enumerable:!0}):Object.defineProperty(e,a.name,{get:n,set:n=>t?(0,r.setStaticField)(e,a.name,n):(0,r.setField)(e,a.name,n),enumerable:!0})}}function c(e){return s(e,!0),class extends e{constructor(...e){super(...e),s(this,!1)}static async newInstanceAsync(...e){const t=await super.newInstanceAsync(...e);return s(t,!1),t}}}function d(e){o(),i.appendClasspath(e)}function l(e,t){o(),i.appendAnyToClasspath(e,t)}var u;t.ensureJvm=o,t.getClassLoader=function(){return o(),i.classLoader},t.setClassLoader=function(e){o(),i.classLoader=e},t.importClass=function(e){return o(),c(i.importClass(e))},t.importClassAsync=async function(e){return o(),c(await i.importClassAsync(e))},t.appendClasspath=d,t.appendClasspathAny=l,t.isInstanceOf=function(e,t){return o(),i.isInstanceOf(e,t)},(u=t.classpath||(t.classpath={})).append=function(e){d(e)},u.appendAny=function(e,t){l(e,t)},u.get=function(){return o(),i.loadedJars},(t.stdout||(t.stdout={})).enableRedirect=function(e,t){return o(),i.setStdoutCallbacks(e,t)},t.newProxy=function(e,t){o();const a=Object.create(null);for(const[e,r]of Object.entries(t))a[e]=(e,t,...a)=>{if(e)throw e;try{t(null,r(...a))}catch(e){e instanceof Error?t(e):t(new Error(e.toString()))}};return i.createInterfaceProxy(e,a)},t.getJavaInstance=function(){return i}},841:function(e,t,a){"use strict";var r=this&&this.__createBinding||(Object.create?function(e,t,a,r){void 0===r&&(r=a);var n=Object.getOwnPropertyDescriptor(t,a);n&&!("get"in n?!t.__esModule:n.writable||n.configurable)||(n={enumerable:!0,get:function(){return t[a]}}),Object.defineProperty(e,r,n)}:function(e,t,a,r){void 0===r&&(r=a),e[r]=t[a]}),n=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),i=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var a in e)"default"!==a&&Object.prototype.hasOwnProperty.call(e,a)&&r(t,e,a);return n(t,e),t},o=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.getJavaLibPath=t.getNativeLibPath=void 0;const s=o(a(17)),c=i(a(147)),d=o(a(230)),{platform:l,arch:u}=process;function f(e){const t=s.default.join(__dirname,e+".node");if(c.default.existsSync(t))return t;{const t=e.replaceAll(".","-").replace("java","java-bridge");return require&&require.resolve?require.resolve(t):a(955).resolve(t)}}function p(){return new Error(`Unsupported platform: ${l} ${u}`)}t.getNativeLibPath=function(){switch(l){case"android":switch(u){case"arm64":return f("java.android-arm64");case"arm":return f("java.android-arm-eabi");default:throw p()}case"win32":return f(`java.win32-${u}-msvc`);case"darwin":return f(`java.darwin-${u}`);case"freebsd":return f(`java.freebsd-${u}`);case"linux":switch(u){case"x64":case"arm64":return f(`java.linux-${u}-${function(){if(process.report&&"function"==typeof process.report.getReport){const{glibcVersionRuntime:e}=process.report.getReport().header;return!e}try{return(0,c.readFileSync)("/usr/bin/ldd","utf8").includes("musl")}catch(e){return!0}}()?"musl":"gnu"}`);case"arm":return f("java.linux-arm-gnueabihf");default:throw p()}default:throw p()}},t.getJavaLibPath=function(){const e=s.default.join(__dirname,"..","java-src","build","libs");let t=d.default.sync("*.jar",{cwd:e});if(0===t.length)throw new Error(`No java lib found in ${e}`);return s.default.join(e,t[0])}},764:function(__unused_webpack_module,exports,__webpack_require__){"use strict";var __createBinding=this&&this.__createBinding||(Object.create?function(e,t,a,r){void 0===r&&(r=a);var n=Object.getOwnPropertyDescriptor(t,a);n&&!("get"in n?!t.__esModule:n.writable||n.configurable)||(n={enumerable:!0,get:function(){return t[a]}}),Object.defineProperty(e,r,n)}:function(e,t,a,r){void 0===r&&(r=a),e[r]=t[a]}),__setModuleDefault=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),__importStar=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var a in e)"default"!==a&&Object.prototype.hasOwnProperty.call(e,a)&&__createBinding(t,e,a);return __setModuleDefault(t,e),t},__importDefault=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(exports,"__esModule",{value:!0});const yargs_1=__importDefault(__webpack_require__(760)),perf_hooks_1=__webpack_require__(74),path_1=__importDefault(__webpack_require__(17)),_1=__importStar(__webpack_require__(236)),package_json_1=__webpack_require__(598),importOra=()=>eval("import('ora').then(ora => ora.default)"),importChalk=()=>eval("import('chalk').then(chalk => chalk.default)"),builder=e=>{e.positional("classnames",{describe:"The fully qualified class name(s) to convert",type:"string"}),e.positional("output",{describe:"The output file",type:"string"}),e.option("classpath",{alias:"cp",type:"string",describe:"The classpath to use"})},handler=async({classnames:e,output:t,classpath:a})=>{let r=null;try{const n=perf_hooks_1.performance.now();(0,_1.ensureJvm)({useDaemonThreads:!0}),a&&_1.default.classpath.append(a);const i=await importChalk(),o=await importOra();console.log(`Starting ${i.cyanBright("java-bridge")} ${i.greenBright("v"+package_json_1.version)} Java definition generator`);const s=(0,_1.getJavaInstance)(),c=_1.default.classpath.get();c.length>0&&console.log(`Started JVM with version ${i.cyanBright(s.version)} and classpath '${c.map((e=>i.cyanBright(e))).join(";")}'`),console.log(`Converting classes ${e.map((e=>i.magentaBright(e))).join(", ")} to typescript and saving result to ${i.cyanBright(path_1.default.normalize(t))}`),r=o().start();const d=[];let l=0,u=0,f=0,p="";const m=setInterval((()=>{f+=1,y()}),1e3),y=()=>{r.text=i.gray(`Elapsed time: ${i.yellow(f)} seconds ${i.white("|")} Converted ${i.cyanBright(l)} classes ${i.white("|")} Converting class ${i.magentaBright(p)}`)};for(const a of e){const e=new _1.TypescriptDefinitionGenerator(a,(e=>{p=e,l++,y()}),d),n=await e.generate();u+=n.length,r.text="saving results",await _1.TypescriptDefinitionGenerator.save(n,t)}clearInterval(m);const v=((perf_hooks_1.performance.now()-n)/1e3).toFixed(1);r.succeed(`Success - Converted ${i.blueBright(u)} classes in ${i.blueBright(v)} seconds`)}catch(e){r?.fail("Failed to convert classes"),console.error(e),process.exit(1)}};yargs_1.default.command("* <output> <classnames..>",!1,builder,handler).parse()},102:(e,t,a)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.getJavaVersionSync=t.getJavaVersion=void 0;const r=a(818);t.getJavaVersion=async function(){const e=await(0,r.importClassAsync)("java.lang.System");return await e.getProperty("java.version")},t.getJavaVersionSync=function(){return(0,r.importClass)("java.lang.System").getPropertySync("java.version")}},955:e=>{function t(e){var t=new Error("Cannot find module '"+e+"'");throw t.code="MODULE_NOT_FOUND",t}t.keys=()=>[],t.resolve=t,t.id=955,e.exports=t},230:e=>{"use strict";e.exports=require("glob")},7:e=>{"use strict";e.exports=require("typescript")},760:e=>{"use strict";e.exports=require("yargs")},147:e=>{"use strict";e.exports=require("fs")},17:e=>{"use strict";e.exports=require("path")},74:e=>{"use strict";e.exports=require("perf_hooks")},598:e=>{"use strict";e.exports=JSON.parse('{"name":"java-bridge","version":"2.1.8-beta.1","main":"dist/index.prod.min.js","types":"dist/ts-src/index.d.ts","description":"A bridge between Node.js and Java APIs","repository":{"type":"git","url":"git+https://github.com/MarkusJx/node-java-bridge.git"},"author":"MarkusJx","bugs":{"url":"https://github.com/MarkusJx/node-java-bridge/issues"},"homepage":"https://github.com/MarkusJx/node-java-bridge#readme","files":["dist/*.js","dist/*.map","dist/**/*.d.ts","java-src/build/libs/*.jar"],"napi":{"name":"java","triples":{"additional":["aarch64-apple-darwin","i686-pc-windows-msvc","aarch64-unknown-linux-gnu"]}},"bin":{"java-ts-gen":"./dist/java-ts-gen.js"},"license":"MIT","prettier":{"printWidth":80,"semi":true,"singleQuote":true,"tabWidth":4,"trailingComma":"es5"},"engines":{"node":">= 15"},"scripts":{"artifacts":"napi artifacts","build":"npm run build:napi","build:debug":"npm run build:napi:debug && npm run build:ts && npm run build:java","postbuild":"npm run build:ts && npm run build:java","build:napi":"napi build --platform --release --js native.js --dts native.d.ts","build:napi:debug":"napi build --platform --js native.js --dts native.d.ts","build:ts":"webpack build && cpy native.d.ts dist","build:java":"run-script-os","build:java:darwin:linux":"cd java-src && chmod +x gradlew && ./gradlew shadowJar","build:java:win32":"cd java-src && .\\\\gradlew.bat shadowJar","prepublishOnly":"napi prepublish -t npm","test":"npm run testOnly","testOnly":"mocha -r ts-node/register test/*.test.ts --reporter mocha-multi-reporters --reporter-options configFile=mocha-reporter-config.json","pretestOnly":"npm run generateTestTypes","pretest":"npm run build","version":"napi version","prettier":"prettier --write .","prebuild":"rimraf dist","prebuild:debug":"rimraf dist","benchmark":"ts-node -P test/tsconfig.json test/benchmark/benchmark.ts && ts-node -P test/tsconfig.json test/benchmark/benchmarkDaemonThreads.ts","prebenchmark":"npm run build","docs":"typedoc --out docs ts-src/index.ts","generateTestTypes":"ts-node -P test/tsconfig.json test/generateTestTypes.ts"},"dependencies":{"chalk":"^5.1.2","glob":"^8.0.3","ora":"^6.1.2","typescript":"^4.9.3","yargs":"^17.6.2"},"devDependencies":{"@napi-rs/cli":"^2.13.0","@types/chai":"^4.3.4","@types/glob":"^8.0.0","@types/is-ci":"^3.0.0","@types/mocha":"^10.0.1","@types/node":"^18.11.10","@types/semver":"^7.3.13","@types/webpack-node-externals":"^2.5.3","@types/yargs":"^17.0.15","chai":"^4.3.7","cpy-cli":"^4.2.0","expose-gc":"^1.0.0","is-ci":"^3.0.1","mocha":"^10.1.0","mocha-junit-reporter":"^2.2.0","mocha-multi-reporters":"^1.5.1","nanobench":"^3.0.0","node-loader":"^2.0.0","prettier":"^2.8.0","rimraf":"^3.0.2","run-script-os":"^1.1.6","semver":"^7.3.8","string-replace-loader":"^3.1.0","ts-loader":"^9.4.2","ts-node":"^10.9.1","tslib":"^2.4.1","typedoc":"^0.23.21","webpack":"^5.75.0","webpack-cli":"^5.0.0","webpack-node-externals":"^3.0.0"},"optionalDependencies":{"java-bridge-darwin-arm64":"2.1.5","java-bridge-darwin-x64":"2.1.5","java-bridge-linux-arm64-gnu":"2.1.5","java-bridge-linux-x64-gnu":"2.1.5","java-bridge-win32-ia32-msvc":"2.1.5","java-bridge-win32-x64-msvc":"2.1.5"}}')}},__webpack_module_cache__={};function __webpack_require__(e){var t=__webpack_module_cache__[e];if(void 0!==t)return t.exports;var a=__webpack_module_cache__[e]={id:e,loaded:!1,exports:{}};return __webpack_modules__[e].call(a.exports,a,a.exports,__webpack_require__),a.loaded=!0,a.exports}__webpack_require__.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),__webpack_require__.nmd=e=>(e.paths=[],e.children||(e.children=[]),e),__webpack_require__.p="";var __webpack_exports__=__webpack_require__(764);return __webpack_exports__})())); | ||
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.java=t():e.java=t()}(global,(()=>(()=>{var __webpack_modules__={388:(e,t,a)=>{e=a.nmd(e);try{process.dlopen(e,__dirname+a(17).sep+a.p+"java.linux-x64-gnu.node")}catch(e){throw new Error("node-loader:\n"+e)}},163:(e,t,a)=>{const{existsSync:r,readFileSync:n}=a(147),{join:i}=a(17),{platform:o,arch:s}=process;let c=null,d=!1,l=null;function u(){if(process.report&&"function"==typeof process.report.getReport){const{glibcVersionRuntime:e}=process.report.getReport().header;return!e}try{return n("/usr/bin/ldd","utf8").includes("musl")}catch(e){return!0}}switch(o){case"android":switch(s){case"arm64":d=r(i(__dirname,"java.android-arm64.node"));try{c=d?a(Object(function(){var e=new Error("Cannot find module './java.android-arm64.node'");throw e.code="MODULE_NOT_FOUND",e}())):require("java-bridge-android-arm64")}catch(e){l=e}break;case"arm":d=r(i(__dirname,"java.android-arm-eabi.node"));try{c=d?a(Object(function(){var e=new Error("Cannot find module './java.android-arm-eabi.node'");throw e.code="MODULE_NOT_FOUND",e}())):require("java-bridge-android-arm-eabi")}catch(e){l=e}break;default:throw new Error(`Unsupported architecture on Android ${s}`)}break;case"win32":switch(s){case"x64":d=r(i(__dirname,"java.win32-x64-msvc.node"));try{c=d?a(Object(function(){var e=new Error("Cannot find module './java.win32-x64-msvc.node'");throw e.code="MODULE_NOT_FOUND",e}())):require("java-bridge-win32-x64-msvc")}catch(e){l=e}break;case"ia32":d=r(i(__dirname,"java.win32-ia32-msvc.node"));try{c=d?a(Object(function(){var e=new Error("Cannot find module './java.win32-ia32-msvc.node'");throw e.code="MODULE_NOT_FOUND",e}())):require("java-bridge-win32-ia32-msvc")}catch(e){l=e}break;case"arm64":d=r(i(__dirname,"java.win32-arm64-msvc.node"));try{c=d?a(Object(function(){var e=new Error("Cannot find module './java.win32-arm64-msvc.node'");throw e.code="MODULE_NOT_FOUND",e}())):require("java-bridge-win32-arm64-msvc")}catch(e){l=e}break;default:throw new Error(`Unsupported architecture on Windows: ${s}`)}break;case"darwin":switch(s){case"x64":d=r(i(__dirname,"java.darwin-x64.node"));try{c=d?a(Object(function(){var e=new Error("Cannot find module './java.darwin-x64.node'");throw e.code="MODULE_NOT_FOUND",e}())):require("java-bridge-darwin-x64")}catch(e){l=e}break;case"arm64":d=r(i(__dirname,"java.darwin-arm64.node"));try{c=d?a(Object(function(){var e=new Error("Cannot find module './java.darwin-arm64.node'");throw e.code="MODULE_NOT_FOUND",e}())):require("java-bridge-darwin-arm64")}catch(e){l=e}break;default:throw new Error(`Unsupported architecture on macOS: ${s}`)}break;case"freebsd":if("x64"!==s)throw new Error(`Unsupported architecture on FreeBSD: ${s}`);d=r(i(__dirname,"java.freebsd-x64.node"));try{c=d?a(Object(function(){var e=new Error("Cannot find module './java.freebsd-x64.node'");throw e.code="MODULE_NOT_FOUND",e}())):require("java-bridge-freebsd-x64")}catch(e){l=e}break;case"linux":switch(s){case"x64":if(u()){d=r(i(__dirname,"java.linux-x64-musl.node"));try{c=d?a(Object(function(){var e=new Error("Cannot find module './java.linux-x64-musl.node'");throw e.code="MODULE_NOT_FOUND",e}())):require("java-bridge-linux-x64-musl")}catch(e){l=e}}else{d=r(i(__dirname,"java.linux-x64-gnu.node"));try{c=d?a(388):require("java-bridge-linux-x64-gnu")}catch(e){l=e}}break;case"arm64":if(u()){d=r(i(__dirname,"java.linux-arm64-musl.node"));try{c=d?a(Object(function(){var e=new Error("Cannot find module './java.linux-arm64-musl.node'");throw e.code="MODULE_NOT_FOUND",e}())):require("java-bridge-linux-arm64-musl")}catch(e){l=e}}else{d=r(i(__dirname,"java.linux-arm64-gnu.node"));try{c=d?a(Object(function(){var e=new Error("Cannot find module './java.linux-arm64-gnu.node'");throw e.code="MODULE_NOT_FOUND",e}())):require("java-bridge-linux-arm64-gnu")}catch(e){l=e}}break;case"arm":d=r(i(__dirname,"java.linux-arm-gnueabihf.node"));try{c=d?a(Object(function(){var e=new Error("Cannot find module './java.linux-arm-gnueabihf.node'");throw e.code="MODULE_NOT_FOUND",e}())):require("java-bridge-linux-arm-gnueabihf")}catch(e){l=e}break;default:throw new Error(`Unsupported architecture on Linux: ${s}`)}break;default:throw new Error(`Unsupported OS: ${o}, architecture: ${s}`)}if(!c){if(l)throw l;throw new Error("Failed to load native binding")}const{Java:f,getClassFields:p,getField:m,setField:y,getStaticField:v,setStaticField:h,JavaInterfaceProxy:g,StdoutRedirect:b,getJavaLibPath:_}=c;e.exports.Java=f,e.exports.getClassFields=p,e.exports.getField=m,e.exports.setField=y,e.exports.getStaticField=v,e.exports.setStaticField=h,e.exports.JavaInterfaceProxy=g,e.exports.StdoutRedirect=b,e.exports.getJavaLibPath=_},238:function(e,t,a){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.TypescriptBulkDefinitionGenerator=void 0;const n=r(a(248));t.TypescriptBulkDefinitionGenerator=class{constructor(){this.declarations=[],this.resolvedImports=[]}async generate(e,t=null){let a=0;for(const r of e){const e=new n.default(r,t,this.resolvedImports),i=await e.generate();a+=i.length,this.declarations.push(...i)}return a}async save(e){await n.default.save(this.declarations,e)}get moduleDeclarations(){return this.declarations}}},248:function(e,t,a){"use strict";var r=this&&this.__createBinding||(Object.create?function(e,t,a,r){void 0===r&&(r=a);var n=Object.getOwnPropertyDescriptor(t,a);n&&!("get"in n?!t.__esModule:n.writable||n.configurable)||(n={enumerable:!0,get:function(){return t[a]}}),Object.defineProperty(e,r,n)}:function(e,t,a,r){void 0===r&&(r=a),e[r]=t[a]}),n=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),i=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var a in e)"default"!==a&&Object.prototype.hasOwnProperty.call(e,a)&&r(t,e,a);return n(t,e),t},o=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});const s=i(a(7)),c=a(236),d=o(a(147)),l=o(a(17)),u=s.default.createSourceFile("source.ts","",s.default.ScriptTarget.Latest,!1,s.default.ScriptKind.TS),f=["toString","wait","getClass","hashCode","notify","notifyAll","equals"];class p{constructor(e,t=null,a=[]){this.classname=e,this.progressCallback=t,this.resolvedImports=a,this.usesBasicOrJavaType=!1,this.additionalImports=[],this.importsToResolve=[]}static async convertMethods(e){const t=await(0,c.importClassAsync)("java.lang.reflect.Modifier"),a={};for(const r of e){const e=await r.getModifiers();if(await t.isPublic(e)){const n=await r.getName(),i=await r.getReturnType(),o=await r.getParameterTypes(),s={returnType:await i.getTypeName(),parameters:await Promise.all(o.map((e=>e.getTypeName()))),isStatic:await t.isStatic(e)};Object.hasOwn(a,n)?a[n].push(s):a[n]=[s]}}return a}async convertFields(e){const t=await(0,c.importClassAsync)("java.lang.reflect.Modifier"),a=[];for(const r of e){const e=await r.getModifiers();if(await t.isPublic(e)){const n=await r.getName(),i=await r.getType(),o=await i.getTypeName(),c=[s.default.factory.createModifier(s.SyntaxKind.PublicKeyword)];await t.isStatic(e)&&c.push(s.default.factory.createModifier(s.SyntaxKind.StaticKeyword)),await t.isFinal(e)&&c.push(s.default.factory.createModifier(s.SyntaxKind.ReadonlyKeyword));let d=s.default.factory.createPropertyDeclaration(c,n,void 0,this.javaTypeToTypescriptType(o,!0),void 0);d=s.default.addSyntheticLeadingComment(d,s.default.SyntaxKind.SingleLineCommentTrivia,` ================== Field ${n} ==================`,!0),a.push(s.default.addSyntheticLeadingComment(d,s.default.SyntaxKind.MultiLineCommentTrivia,`*\n * Original type: '${await i.getTypeName()}'\n `,!0))}}return a}async isAbstractOrInterface(e){const t=await(0,c.importClassAsync)("java.lang.reflect.Modifier");return await e.isInterface()||await t.isAbstract(await e.getModifiers())}createPrivateConstructor(){const e=s.default.factory.createConstructorDeclaration([s.default.factory.createModifier(s.default.SyntaxKind.PrivateKeyword)],[],s.default.factory.createBlock([s.default.factory.createExpressionStatement(s.default.factory.createCallExpression(s.default.factory.createSuper(),[],[]))],!0));return s.default.addSyntheticLeadingComment(e,s.default.SyntaxKind.MultiLineCommentTrivia,"*\n * Private constructor to prevent instantiation\n * as this is either an abstract class or an interface\n ",!0)}async convertConstructors(e){const t=await(0,c.importClassAsync)("java.lang.reflect.Modifier"),a=[];for(const r of e){const e=await r.getModifiers();if(await t.isPublic(e)){const e=await r.getParameterTypes();a.push(await Promise.all(e.map((e=>e.getTypeName()))))}}const r=a.map(((e,t)=>{const a=e.map(this.convertParameter.bind(this));let r=s.default.factory.createConstructorDeclaration([s.default.factory.createModifier(s.default.SyntaxKind.PublicKeyword)],a,void 0);return 0===t&&(r=s.default.addSyntheticLeadingComment(r,s.default.SyntaxKind.SingleLineCommentTrivia," ================== Constructors ==================",!0)),e.length>0&&(r=s.default.addSyntheticLeadingComment(r,s.default.SyntaxKind.MultiLineCommentTrivia,"*\n"+e.map(((e,t)=>` * @param var${t} original type: '${e}'\n`)).join("")+" ",!0)),r}));return[...a.map(((e,t)=>this.createMethod({returnType:this.classname,parameters:e,isStatic:!0},"newInstance",t,!1,!0))),...r]}primitiveToClassType(e){switch(e){case"boolean":return"java.lang.Boolean";case"byte":return"java.lang.Byte";case"char":return"java.lang.Character";case"short":return"java.lang.Short";case"int":return"java.lang.Integer";case"long":return"java.lang.Long";case"float":return"java.lang.Float";case"double":return"java.lang.Double";default:return e}}isPrimitive(e){return["boolean","byte","char","short","int","long","float","double"].includes(e)}javaTypeToTypescriptType(e,t,a=!0){const r=e=>a?s.default.factory.createUnionTypeNode([e,s.default.factory.createLiteralTypeNode(s.default.factory.createNull())]):e;switch(e){case"byte[]":case"java.lang.Byte[]":return r(s.default.factory.createTypeReferenceNode("Buffer"))}if(e.endsWith("[]"))return r(s.default.factory.createArrayTypeNode(this.javaTypeToTypescriptType(e.substring(0,e.length-2),t)));const n=e=>{this.resolvedImports.includes(e)||this.additionalImports.push(e),this.importsToResolve.push(e);const a=e===this.classname&&t;return s.default.factory.createTypeReferenceNode(e===this.classname?e.substring(e.lastIndexOf(".")+1)+(a?"Class":""):e.replaceAll(".","_"))},i=(r,...i)=>{const o=[s.default.factory.createKeywordTypeNode(r)];return!this.isPrimitive(e)&&a&&o.push(s.default.factory.createLiteralTypeNode(s.default.factory.createNull())),t?s.default.factory.createUnionTypeNode([n(this.primitiveToClassType(e)),...i.map((e=>s.default.factory.createKeywordTypeNode(e))),...o]):s.default.factory.createUnionTypeNode(o)};switch(e){case"int":case"java.lang.Integer":case"float":case"java.lang.Float":case"double":case"java.lang.Double":case"byte":case"java.lang.Byte":case"short":case"java.lang.Short":return i(s.SyntaxKind.NumberKeyword);case"long":case"java.lang.Long":return i(s.SyntaxKind.NumberKeyword,s.SyntaxKind.BigIntKeyword);case"char":case"java.lang.Character":case"java.lang.String":return r(s.default.factory.createKeywordTypeNode(s.SyntaxKind.StringKeyword));case"boolean":case"java.lang.Boolean":return i(s.SyntaxKind.BooleanKeyword);case"void":case"java.lang.Void":return s.default.factory.createKeywordTypeNode(s.SyntaxKind.VoidKeyword);case"java.lang.Object":return this.usesBasicOrJavaType=!0,r(s.default.factory.createTypeReferenceNode("BasicOrJavaType"));default:return r(n(e))}}convertParameter(e,t){const a="var"+t,r=this.javaTypeToTypescriptType(e,!0);return s.default.factory.createParameterDeclaration(void 0,void 0,a,void 0,r)}convertParameters(e){return e.parameters.map(this.convertParameter.bind(this))}static createMethodComment(e){return"*\n"+e.parameters.map(((e,t)=>` * @param var${t} original type: '${e}'\n`)).join("")+` * @return original return type: '${e.returnType}'\n `}createMethod(e,t,a,r,n){const i=s.default.factory.createModifier(s.default.SyntaxKind.PublicKeyword),o=s.default.factory.createModifier(s.default.SyntaxKind.StaticKeyword),c=[i];e.isStatic&&c.push(o);let d=this.javaTypeToTypescriptType(e.returnType,!1,!n);r||(d=s.default.factory.createTypeReferenceNode(s.default.factory.createIdentifier("Promise"),[d]));let l=s.default.factory.createMethodDeclaration(c,void 0,t+(r?"Sync":""),void 0,void 0,this.convertParameters(e),d,void 0);return 0===a&&(l=s.default.addSyntheticLeadingComment(l,s.default.SyntaxKind.SingleLineCommentTrivia,` ================== Method ${t} ==================`,!0)),s.default.addSyntheticLeadingComment(l,s.default.SyntaxKind.MultiLineCommentTrivia,p.createMethodComment(e),!0)}convertMethod(e,t){const a=[];for(let r=0;r<e.length;r++){const n=e[r],i=f.includes(t);a.push(this.createMethod(n,t,r,!1,i),this.createMethod(n,t,r,!0,i))}return a}getAdditionalImports(){const e=e=>{const t=this.classname.split("."),a=e.split(".");for(let e=0;e<t.length&&a[e]===t[e];e++)t[e]=null,a[e]=null;return"./"+t.filter((e=>!!e)).map((()=>"")).join("../")+a.filter((e=>!!e)).join("/")};return this.importsToResolve.filter((e=>e!=this.classname)).filter(((e,t,a)=>a.indexOf(e)===t)).map((t=>s.default.factory.createImportDeclaration(void 0,s.default.factory.createImportClause(!1,void 0,s.default.factory.createNamedImports([s.default.factory.createImportSpecifier(!1,s.default.factory.createIdentifier(t.substring(t.lastIndexOf(".")+1)),s.default.factory.createIdentifier(t.replaceAll(".","_")))])),s.default.factory.createStringLiteral(e(t)))))}getImports(){const e=[s.default.factory.createImportSpecifier(!1,void 0,s.default.factory.createIdentifier("importClass")),s.default.factory.createImportSpecifier(!1,void 0,s.default.factory.createIdentifier("JavaClass"))];this.usesBasicOrJavaType&&e.push(s.default.factory.createImportSpecifier(!1,void 0,s.default.factory.createIdentifier("BasicOrJavaType")));const t=s.default.factory.createNamedImports(e);return s.default.factory.createImportDeclaration(void 0,s.default.factory.createImportClause(!1,void 0,t),s.default.factory.createStringLiteral("java-bridge"))}getExportStatement(e,t){const a=s.default.factory.createClassDeclaration([s.default.factory.createModifier(s.default.SyntaxKind.ExportKeyword)],e,void 0,[s.default.factory.createHeritageClause(s.default.SyntaxKind.ExtendsKeyword,[s.default.factory.createExpressionWithTypeArguments(s.default.factory.createIdentifier(`importClass<typeof ${e}Class>("${this.classname}")`),void 0)])],t?[this.createPrivateConstructor()]:[]);return[s.default.addSyntheticLeadingComment(a,s.SyntaxKind.MultiLineCommentTrivia,`*\n * Class ${this.classname}.\n *\n * This actually imports the java class for further use.\n * The class ${e}Class only defines types, this is the class you should actually import.\n * Please note that this statement imports the underlying java class at runtime, which may take a while.\n * This was generated by java-bridge.\n * You should probably not edit this.\n `,!0),s.default.factory.createExportDefault(s.default.factory.createIdentifier(e))]}getText(e){return e.map((e=>e&&s.default.createPrinter({newLine:s.default.NewLineKind.LineFeed}).printNode(s.default.EmitHint.Unspecified,e,u)||"")).join("\n")}async generate(){if(this.resolvedImports.includes(this.classname))return[];this.resolvedImports.push(this.classname),this.progressCallback&&this.progressCallback(this.classname);const e=(await(0,c.importClassAsync)(this.classname)).class,t=this.classname.substring(this.classname.lastIndexOf(".")+1),a=(await e.getFields()).filter((function(e,t,a){return a.findIndex((t=>e.getNameSync()===t.getNameSync()))===t})),r=await e.getMethods(),n=await this.convertFields(a),i=await p.convertMethods(r);for(const[e,t]of Object.entries(i))n.push(...this.convertMethod(t,e));const o=await this.isAbstractOrInterface(e);if(!o){const t=await e.getDeclaredConstructors(),a=await this.convertConstructors(t);n.push(...a)}let d=s.default.factory.createClassDeclaration([s.default.factory.createModifier(s.default.SyntaxKind.ExportKeyword),s.default.factory.createModifier(s.default.SyntaxKind.DeclareKeyword)],t+"Class",void 0,[s.default.factory.createHeritageClause(s.default.SyntaxKind.ExtendsKeyword,[s.default.factory.createExpressionWithTypeArguments(s.default.factory.createIdentifier("JavaClass"),void 0)])],n);d=s.default.addSyntheticLeadingComment(d,s.default.SyntaxKind.MultiLineCommentTrivia,`*\n * This class just defines types, you should import ${t} instead of this.\n * This was generated by java-bridge.\n * You should probably not edit this.\n `,!0);const l=this.getText([this.getImports(),...this.getAdditionalImports(),null,d,null,...this.getExportStatement(t,o)]),u=[];for(const e of this.additionalImports){const t=new p(e,this.progressCallback,this.resolvedImports),a=await t.generate();u.push(...a)}return u.push({name:this.classname,contents:l}),u}static async save(e,t){for(const a of e){const e=a.name.split(".");e[e.length-1]=e[e.length-1]+".ts";const r=l.default.join(t,...e);await d.default.promises.mkdir(l.default.dirname(r),{recursive:!0}),await d.default.promises.writeFile(r,a.contents,{encoding:"utf8"})}}}t.default=p},91:(e,t)=>{"use strict";var a;Object.defineProperty(t,"__esModule",{value:!0}),t.JavaObject=t.JavaVersion=void 0,function(e){e.VER_1_1="1.1",e.VER_1_2="1.2",e.VER_1_4="1.4",e.VER_1_6="1.6",e.VER_1_8="1.8",e.VER_9="9",e.VER_10="10"}(a=t.JavaVersion||(t.JavaVersion={})),Object.freeze(a),t.JavaObject=class{}},236:function(e,t,a){"use strict";var r=this&&this.__createBinding||(Object.create?function(e,t,a,r){void 0===r&&(r=a);var n=Object.getOwnPropertyDescriptor(t,a);n&&!("get"in n?!t.__esModule:n.writable||n.configurable)||(n={enumerable:!0,get:function(){return t[a]}}),Object.defineProperty(e,r,n)}:function(e,t,a,r){void 0===r&&(r=a),e[r]=t[a]}),n=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),i=this&&this.__exportStar||function(e,t){for(var a in e)"default"===a||Object.prototype.hasOwnProperty.call(t,a)||r(t,e,a)},o=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var a in e)"default"!==a&&Object.prototype.hasOwnProperty.call(e,a)&&r(t,e,a);return n(t,e),t},s=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.TypescriptBulkDefinitionGenerator=t.TypescriptDefinitionGenerator=t.getJavaVersionSync=t.getJavaVersion=t.getJavaLibPath=t.UnknownJavaClass=t.JavaClassConstructor=t.JavaClass=t.JavaClassProxy=t.JavaClassInstance=t.JavaObject=t.JavaVersion=void 0;var c=a(91);Object.defineProperty(t,"JavaVersion",{enumerable:!0,get:function(){return c.JavaVersion}}),Object.defineProperty(t,"JavaObject",{enumerable:!0,get:function(){return c.JavaObject}}),Object.defineProperty(t,"JavaClassInstance",{enumerable:!0,get:function(){return c.JavaClassInstance}}),Object.defineProperty(t,"JavaClassProxy",{enumerable:!0,get:function(){return c.JavaClassProxy}}),Object.defineProperty(t,"JavaClass",{enumerable:!0,get:function(){return c.JavaClass}}),Object.defineProperty(t,"JavaClassConstructor",{enumerable:!0,get:function(){return c.JavaClassConstructor}}),Object.defineProperty(t,"UnknownJavaClass",{enumerable:!0,get:function(){return c.UnknownJavaClass}}),i(a(818),t);const d=o(a(818));t.default=d;var l=a(163);Object.defineProperty(t,"getJavaLibPath",{enumerable:!0,get:function(){return l.getJavaLibPath}});var u=a(102);Object.defineProperty(t,"getJavaVersion",{enumerable:!0,get:function(){return u.getJavaVersion}}),Object.defineProperty(t,"getJavaVersionSync",{enumerable:!0,get:function(){return u.getJavaVersionSync}});const f=s(a(248));t.TypescriptDefinitionGenerator=f.default;var p=a(238);Object.defineProperty(t,"TypescriptBulkDefinitionGenerator",{enumerable:!0,get:function(){return p.TypescriptBulkDefinitionGenerator}})},818:(e,t,a)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.getJavaInstance=t.newProxy=t.stdout=t.classpath=t.isInstanceOf=t.appendClasspath=t.importClassAsync=t.importClass=t.setClassLoader=t.getClassLoader=t.ensureJvm=void 0;const r=a(163),n=a(841);let i=null;function o(e){return!i&&(i=new r.Java(e?.libPath,e?.version,e?.opts,e,(0,n.getJavaLibPath)(),(0,n.getNativeLibPath)()),!0)}function s(e,t){for(const a of(0,r.getClassFields)(e["class.proxy"],t)){const n=()=>t?(0,r.getStaticField)(e,a.name):(0,r.getField)(e,a.name);a.isFinal?Object.defineProperty(e,a.name,{get:n,enumerable:!0}):Object.defineProperty(e,a.name,{get:n,set:n=>t?(0,r.setStaticField)(e,a.name,n):(0,r.setField)(e,a.name,n),enumerable:!0})}}function c(e){return s(e,!0),class extends e{constructor(...e){super(...e),s(this,!1)}static async newInstanceAsync(...e){const t=await super.newInstanceAsync(...e);return s(t,!1),t}}}function d(e){o(),i.appendClasspath(e)}var l;t.ensureJvm=o,t.getClassLoader=function(){return o(),i.classLoader},t.setClassLoader=function(e){o(),i.classLoader=e},t.importClass=function(e){return o(),c(i.importClass(e))},t.importClassAsync=async function(e){return o(),c(await i.importClassAsync(e))},t.appendClasspath=d,t.isInstanceOf=function(e,t){return o(),i.isInstanceOf(e,t)},(l=t.classpath||(t.classpath={})).append=function(e){d(e)},l.get=function(){return o(),i.loadedJars},(t.stdout||(t.stdout={})).enableRedirect=function(e,t){return o(),i.setStdoutCallbacks(e,t)},t.newProxy=function(e,t){o();const a=Object.create(null);for(const[e,r]of Object.entries(t))a[e]=(e,t,...a)=>{if(e)throw e;try{t(null,r(...a))}catch(e){e instanceof Error?t(e):t(new Error(e.toString()))}};return i.createInterfaceProxy(e,a)},t.getJavaInstance=function(){return i}},841:function(e,t,a){"use strict";var r=this&&this.__createBinding||(Object.create?function(e,t,a,r){void 0===r&&(r=a);var n=Object.getOwnPropertyDescriptor(t,a);n&&!("get"in n?!t.__esModule:n.writable||n.configurable)||(n={enumerable:!0,get:function(){return t[a]}}),Object.defineProperty(e,r,n)}:function(e,t,a,r){void 0===r&&(r=a),e[r]=t[a]}),n=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),i=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var a in e)"default"!==a&&Object.prototype.hasOwnProperty.call(e,a)&&r(t,e,a);return n(t,e),t},o=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.getJavaLibPath=t.getNativeLibPath=void 0;const s=o(a(17)),c=i(a(147)),d=o(a(230)),{platform:l,arch:u}=process;function f(e){const t=s.default.join(__dirname,e+".node");if(c.default.existsSync(t))return t;{const t=e.replaceAll(".","-").replace("java","java-bridge");return require&&require.resolve?require.resolve(t):a(955).resolve(t)}}function p(){return new Error(`Unsupported platform: ${l} ${u}`)}t.getNativeLibPath=function(){switch(l){case"android":switch(u){case"arm64":return f("java.android-arm64");case"arm":return f("java.android-arm-eabi");default:throw p()}case"win32":return f(`java.win32-${u}-msvc`);case"darwin":return f(`java.darwin-${u}`);case"freebsd":return f(`java.freebsd-${u}`);case"linux":switch(u){case"x64":case"arm64":return f(`java.linux-${u}-${function(){if(process.report&&"function"==typeof process.report.getReport){const{glibcVersionRuntime:e}=process.report.getReport().header;return!e}try{return(0,c.readFileSync)("/usr/bin/ldd","utf8").includes("musl")}catch(e){return!0}}()?"musl":"gnu"}`);case"arm":return f("java.linux-arm-gnueabihf");default:throw p()}default:throw p()}},t.getJavaLibPath=function(){const e=s.default.join(__dirname,"..","java-src","build","libs");let t=d.default.sync("*.jar",{cwd:e});if(0===t.length)throw new Error(`No java lib found in ${e}`);return s.default.join(e,t[0])}},764:function(__unused_webpack_module,exports,__webpack_require__){"use strict";var __createBinding=this&&this.__createBinding||(Object.create?function(e,t,a,r){void 0===r&&(r=a);var n=Object.getOwnPropertyDescriptor(t,a);n&&!("get"in n?!t.__esModule:n.writable||n.configurable)||(n={enumerable:!0,get:function(){return t[a]}}),Object.defineProperty(e,r,n)}:function(e,t,a,r){void 0===r&&(r=a),e[r]=t[a]}),__setModuleDefault=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),__importStar=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var a in e)"default"!==a&&Object.prototype.hasOwnProperty.call(e,a)&&__createBinding(t,e,a);return __setModuleDefault(t,e),t},__importDefault=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(exports,"__esModule",{value:!0});const yargs_1=__importDefault(__webpack_require__(760)),perf_hooks_1=__webpack_require__(74),path_1=__importDefault(__webpack_require__(17)),_1=__importStar(__webpack_require__(236)),package_json_1=__webpack_require__(598),importOra=()=>eval("import('ora').then(ora => ora.default)"),importChalk=()=>eval("import('chalk').then(chalk => chalk.default)"),builder=e=>{e.positional("classnames",{describe:"The fully qualified class name(s) to convert",type:"string"}),e.positional("output",{describe:"The output file",type:"string"}),e.option("classpath",{alias:"cp",type:"string",describe:"The classpath to use"})},handler=async({classnames:e,output:t,classpath:a})=>{let r=null;try{const n=perf_hooks_1.performance.now();(0,_1.ensureJvm)({useDaemonThreads:!0}),a&&_1.default.classpath.append(a);const i=await importChalk(),o=await importOra();console.log(`Starting ${i.cyanBright("java-bridge")} ${i.greenBright("v"+package_json_1.version)} Java definition generator`);const s=(0,_1.getJavaInstance)(),c=_1.default.classpath.get();c.length>0&&console.log(`Started JVM with version ${i.cyanBright(s.version)} and classpath '${c.map((e=>i.cyanBright(e))).join(";")}'`),console.log(`Converting classes ${e.map((e=>i.magentaBright(e))).join(", ")} to typescript and saving result to ${i.cyanBright(path_1.default.normalize(t))}`),r=o().start();const d=[];let l=0,u=0,f=0,p="";const m=setInterval((()=>{f+=1,y()}),1e3),y=()=>{r.text=i.gray(`Elapsed time: ${i.yellow(f)} seconds ${i.white("|")} Converted ${i.cyanBright(l)} classes ${i.white("|")} Converting class ${i.magentaBright(p)}`)};for(const a of e){const e=new _1.TypescriptDefinitionGenerator(a,(e=>{p=e,l++,y()}),d),n=await e.generate();u+=n.length,r.text="saving results",await _1.TypescriptDefinitionGenerator.save(n,t)}clearInterval(m);const v=((perf_hooks_1.performance.now()-n)/1e3).toFixed(1);r.succeed(`Success - Converted ${i.blueBright(u)} classes in ${i.blueBright(v)} seconds`)}catch(e){r?.fail("Failed to convert classes"),console.error(e),process.exit(1)}};yargs_1.default.command("* <output> <classnames..>",!1,builder,handler).parse()},102:(e,t,a)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.getJavaVersionSync=t.getJavaVersion=void 0;const r=a(818);t.getJavaVersion=async function(){const e=await(0,r.importClassAsync)("java.lang.System");return await e.getProperty("java.version")},t.getJavaVersionSync=function(){return(0,r.importClass)("java.lang.System").getPropertySync("java.version")}},955:e=>{function t(e){var t=new Error("Cannot find module '"+e+"'");throw t.code="MODULE_NOT_FOUND",t}t.keys=()=>[],t.resolve=t,t.id=955,e.exports=t},230:e=>{"use strict";e.exports=require("glob")},7:e=>{"use strict";e.exports=require("typescript")},760:e=>{"use strict";e.exports=require("yargs")},147:e=>{"use strict";e.exports=require("fs")},17:e=>{"use strict";e.exports=require("path")},74:e=>{"use strict";e.exports=require("perf_hooks")},598:e=>{"use strict";e.exports=JSON.parse('{"name":"java-bridge","version":"2.1.8-beta.2","main":"dist/index.prod.min.js","types":"dist/ts-src/index.d.ts","description":"A bridge between Node.js and Java APIs","repository":{"type":"git","url":"git+https://github.com/MarkusJx/node-java-bridge.git"},"author":"MarkusJx","bugs":{"url":"https://github.com/MarkusJx/node-java-bridge/issues"},"homepage":"https://github.com/MarkusJx/node-java-bridge#readme","files":["dist/*.js","dist/*.map","dist/**/*.d.ts","java-src/build/libs/*.jar"],"napi":{"name":"java","triples":{"additional":["aarch64-apple-darwin","i686-pc-windows-msvc","aarch64-unknown-linux-gnu"]}},"bin":{"java-ts-gen":"./dist/java-ts-gen.js"},"license":"MIT","prettier":{"printWidth":80,"semi":true,"singleQuote":true,"tabWidth":4,"trailingComma":"es5"},"engines":{"node":">= 15"},"scripts":{"artifacts":"napi artifacts","build":"npm run build:napi","build:debug":"npm run build:napi:debug && npm run build:ts && npm run build:java","postbuild":"npm run build:ts && npm run build:java","build:napi":"napi build --platform --release --js native.js --dts native.d.ts","build:napi:debug":"napi build --platform --js native.js --dts native.d.ts","build:ts":"webpack build && cpy native.d.ts dist","build:java":"run-script-os","build:java:darwin:linux":"cd java-src && chmod +x gradlew && ./gradlew shadowJar","build:java:win32":"cd java-src && .\\\\gradlew.bat shadowJar","prepublishOnly":"napi prepublish -t npm","test":"npm run testOnly","testOnly":"mocha -r ts-node/register test/*.test.ts --reporter mocha-multi-reporters --reporter-options configFile=mocha-reporter-config.json","pretestOnly":"npm run generateTestTypes","pretest":"npm run build","version":"napi version","prettier":"prettier --write .","prebuild":"rimraf dist","prebuild:debug":"rimraf dist","benchmark":"ts-node -P test/tsconfig.json test/benchmark/benchmark.ts && ts-node -P test/tsconfig.json test/benchmark/benchmarkDaemonThreads.ts","prebenchmark":"npm run build","docs":"typedoc --out docs ts-src/index.ts","generateTestTypes":"ts-node -P test/tsconfig.json test/generateTestTypes.ts"},"dependencies":{"chalk":"^5.1.2","glob":"^8.0.3","ora":"^6.1.2","typescript":"^4.9.3","yargs":"^17.6.2"},"devDependencies":{"@napi-rs/cli":"^2.13.0","@types/chai":"^4.3.4","@types/glob":"^8.0.0","@types/is-ci":"^3.0.0","@types/mocha":"^10.0.1","@types/node":"^18.11.10","@types/semver":"^7.3.13","@types/webpack-node-externals":"^2.5.3","@types/yargs":"^17.0.15","chai":"^4.3.7","cpy-cli":"^4.2.0","expose-gc":"^1.0.0","is-ci":"^3.0.1","mocha":"^10.1.0","mocha-junit-reporter":"^2.2.0","mocha-multi-reporters":"^1.5.1","nanobench":"^3.0.0","node-loader":"^2.0.0","prettier":"^2.8.0","rimraf":"^3.0.2","run-script-os":"^1.1.6","semver":"^7.3.8","string-replace-loader":"^3.1.0","ts-loader":"^9.4.2","ts-node":"^10.9.1","tslib":"^2.4.1","typedoc":"^0.23.21","webpack":"^5.75.0","webpack-cli":"^5.0.0","webpack-node-externals":"^3.0.0"},"optionalDependencies":{"java-bridge-darwin-arm64":"2.1.5","java-bridge-darwin-x64":"2.1.5","java-bridge-linux-arm64-gnu":"2.1.5","java-bridge-linux-x64-gnu":"2.1.5","java-bridge-win32-ia32-msvc":"2.1.5","java-bridge-win32-x64-msvc":"2.1.5"}}')}},__webpack_module_cache__={};function __webpack_require__(e){var t=__webpack_module_cache__[e];if(void 0!==t)return t.exports;var a=__webpack_module_cache__[e]={id:e,loaded:!1,exports:{}};return __webpack_modules__[e].call(a.exports,a,a.exports,__webpack_require__),a.loaded=!0,a.exports}__webpack_require__.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),__webpack_require__.nmd=e=>(e.paths=[],e.children||(e.children=[]),e),__webpack_require__.p="";var __webpack_exports__=__webpack_require__(764);return __webpack_exports__})())); | ||
//# sourceMappingURL=java-ts-gen.js.map |
@@ -47,4 +47,10 @@ /* tslint:disable */ | ||
useDaemonThreads?: boolean | ||
/** Additional paths to add to the class path */ | ||
/** | ||
* Additional items to add to the class path. This does allow for wildcard imports | ||
* using glob patterns. If a path is unreadable, an error will be thrown. | ||
* This behaviour can be changed by setting `ignore_unreadable_class_path_entries` to true. | ||
*/ | ||
classpath?: Array<string> | ||
/** Whether to ignore unreadable class path entries */ | ||
ignoreUnreadableClassPathEntries?: boolean | ||
} | ||
@@ -95,3 +101,2 @@ /** | ||
appendClasspath(classpath: string | string[]): void | ||
appendAnyToClasspath(path: string | string[], recursive?: boolean | undefined | null): void | ||
/** Set the stdout/stderr callbacks */ | ||
@@ -98,0 +103,0 @@ setStdoutCallbacks(stdoutCallback?: ((err: Error | null, data?: string) => void) | undefined | null, stderrCallback?: ((err: Error | null, data?: string) => void) | undefined | null): StdoutRedirect |
@@ -19,7 +19,2 @@ import { Java, JavaOptions } from '../native'; | ||
opts?: Array<string> | null; | ||
/** | ||
* Additional items to add to the class path. | ||
* This also allows wildcard imports, e.g. `/lib/*` | ||
*/ | ||
classpath?: string[]; | ||
} | ||
@@ -190,5 +185,6 @@ /** | ||
* | ||
* **Note: This can only import single files, not directories.** | ||
* If you want to import whole directories, you can use glob patterns. | ||
* | ||
* ## Example | ||
* ### Append single files | ||
* ```ts | ||
@@ -211,26 +207,15 @@ * import { appendClasspath } from 'java-bridge'; | ||
* | ||
* @param path the path(s) to add | ||
*/ | ||
export declare function appendClasspath(path: string | string[]): void; | ||
/** | ||
* Append either a single or multiple jars or directories to the class path. | ||
* This will check if the path(s) passed are directories and will | ||
* add a trailing slash to the path if it doesn't already have one | ||
* so the class loader will treat it as a directory. This will | ||
* check if the file or directory exists and throw an error if it doesn't exist. | ||
* | ||
* ## Example | ||
* ### Append a directory to the class path | ||
* ```ts | ||
* appendClasspathAny('/path/to/dir'); | ||
* ``` | ||
* import { appendClasspath } from 'java-bridge'; | ||
* | ||
* Pass multiple paths: | ||
* ```ts | ||
* appendClasspathAny(['/path/to/dir1', '/path/to/my.jar']); | ||
* // Append a directory to the class path | ||
* appendClasspath('/path/to/dir/*'); | ||
* // Append just the jar files in the directory | ||
* appendClasspath('/path/to/dir/*.jar'); | ||
* ``` | ||
* | ||
* @param path the file(s) or directory(s) to add | ||
* @param recursive whether to recursively add all files in the directory | ||
* @param path the path(s) to add | ||
*/ | ||
export declare function appendClasspathAny(path: string | string[], recursive?: boolean): void; | ||
export declare function appendClasspath(path: string | string[]): void; | ||
/** | ||
@@ -288,6 +273,2 @@ * Check if `this_obj` is instance of `other`. | ||
/** | ||
* @inheritDoc appendClasspathAny | ||
*/ | ||
function appendAny(path: string | string[], recursive?: boolean): void; | ||
/** | ||
* Get the loaded files or directories in the class path | ||
@@ -294,0 +275,0 @@ * |
{ | ||
"name": "java-bridge", | ||
"version": "2.1.8-beta.1", | ||
"version": "2.1.8-beta.2", | ||
"main": "dist/index.prod.min.js", | ||
@@ -111,9 +111,9 @@ "types": "dist/ts-src/index.d.ts", | ||
"optionalDependencies": { | ||
"java-bridge-win32-x64-msvc": "2.1.8-beta.1", | ||
"java-bridge-darwin-x64": "2.1.8-beta.1", | ||
"java-bridge-linux-x64-gnu": "2.1.8-beta.1", | ||
"java-bridge-darwin-arm64": "2.1.8-beta.1", | ||
"java-bridge-win32-ia32-msvc": "2.1.8-beta.1", | ||
"java-bridge-linux-arm64-gnu": "2.1.8-beta.1" | ||
"java-bridge-win32-x64-msvc": "2.1.8-beta.2", | ||
"java-bridge-darwin-x64": "2.1.8-beta.2", | ||
"java-bridge-linux-x64-gnu": "2.1.8-beta.2", | ||
"java-bridge-darwin-arm64": "2.1.8-beta.2", | ||
"java-bridge-win32-ia32-msvc": "2.1.8-beta.2", | ||
"java-bridge-linux-arm64-gnu": "2.1.8-beta.2" | ||
} | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Long strings
Supply chain riskContains long string literals, which may be a sign of obfuscated or packed code.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Long strings
Supply chain riskContains long string literals, which may be a sign of obfuscated or packed code.
Found 1 instance in 1 package
317425
1250