java-bridge
Advanced tools
Comparing version 2.1.4 to 2.1.5-beta.1
@@ -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,u=null;function l(){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){u=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){u=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){u=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){u=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){u=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){u=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){u=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){u=e}break;case"linux":switch(s){case"x64":if(l()){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){u=e}}else{d=r(i(__dirname,"java.linux-x64-gnu.node"));try{c=d?a(388):require("java-bridge-linux-x64-gnu")}catch(e){u=e}}break;case"arm64":if(l()){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){u=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){u=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){u=e}break;default:throw new Error(`Unsupported architecture on Linux: ${s}`)}break;default:throw new Error(`Unsupported OS: ${o}, architecture: ${s}`)}if(!c){if(u)throw u;throw new Error("Failed to load native binding")}const{Java:f,getClassFields:p,getField:m,setField:v,getStaticField:h,setStaticField:y,JavaInterfaceProxy:b,StdoutRedirect:g,getJavaLibPath:w}=c;e.exports.Java=f,e.exports.getClassFields=p,e.exports.getField=m,e.exports.setField=v,e.exports.getStaticField=h,e.exports.setStaticField=y,e.exports.JavaInterfaceProxy=b,e.exports.StdoutRedirect=g,e.exports.getJavaLibPath=w},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)),u=o(a(17)),l=s.default.createSourceFile("source.ts","",s.default.ScriptTarget.Latest,!1,s.default.ScriptKind.TS);class f{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 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))),...r]}javaTypeToTypescriptType(e,t){switch(e){case"byte[]":case"java.lang.Byte[]":return s.default.factory.createTypeReferenceNode("Buffer")}if(e.endsWith("[]"))return s.default.factory.createArrayTypeNode(this.javaTypeToTypescriptType(e.substring(0,e.length-2),t));switch(e){case"int":case"java.lang.Integer":case"long":case"java.lang.Long":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 s.default.factory.createKeywordTypeNode(s.default.SyntaxKind.NumberKeyword);case"char":case"java.lang.Character":case"java.lang.String":return s.default.factory.createKeywordTypeNode(s.default.SyntaxKind.StringKeyword);case"boolean":case"java.lang.Boolean":return s.default.factory.createKeywordTypeNode(s.default.SyntaxKind.BooleanKeyword);case"void":case"java.lang.Void":return s.default.factory.createKeywordTypeNode(s.default.SyntaxKind.VoidKeyword);case"java.lang.Object":return this.usesBasicOrJavaType=!0,s.default.factory.createTypeReferenceNode("BasicOrJavaType");default: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(".","_"))}}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){const n=s.default.factory.createModifier(s.default.SyntaxKind.PublicKeyword),i=s.default.factory.createModifier(s.default.SyntaxKind.StaticKeyword),o=[n];e.isStatic&&o.push(i);let c=this.javaTypeToTypescriptType(e.returnType,!1);r||(c=s.default.factory.createTypeReferenceNode(s.default.factory.createIdentifier("Promise"),[c]));let d=s.default.factory.createMethodDeclaration(o,void 0,t+(r?"Sync":""),void 0,void 0,this.convertParameters(e),c,void 0);return 0===a&&(d=s.default.addSyntheticLeadingComment(d,s.default.SyntaxKind.SingleLineCommentTrivia,` ================== Method ${t} ==================`,!0)),s.default.addSyntheticLeadingComment(d,s.default.SyntaxKind.MultiLineCommentTrivia,f.createMethodComment(e),!0)}convertMethod(e,t){const a=[];for(let r=0;r<e.length;r++){const n=e[r];a.push(this.createMethod(n,t,r,!1),this.createMethod(n,t,r,!0))}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){const t=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)])],[]);return[s.default.addSyntheticLeadingComment(t,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,l)||"")).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.getDeclaredMethods(),r=[],n=await f.convertMethods(a);for(const e of Object.keys(n)){const t=n[e];r.push(...this.convertMethod(t,e))}const i=await e.getDeclaredConstructors(),o=await this.convertConstructors(i);r.push(...o);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)])],r);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 u=this.getText([this.getImports(),...this.getAdditionalImports(),null,d,null,...this.getExportStatement(t)]),l=[];for(const e of this.additionalImports){const t=new f(e,this.progressCallback,this.resolvedImports),a=await t.generate();l.push(...a)}return l.push({name:this.classname,contents:u}),l}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=u.default.join(t,...e);await d.default.promises.mkdir(u.default.dirname(r),{recursive:!0}),await d.default.promises.writeFile(r,a.contents,{encoding:"utf8"})}}}t.default=f},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.TypescriptDefinitionGenerator=t.getJavaLibPath=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}}),i(a(818),t);const d=o(a(818));t.default=d;var u=a(163);Object.defineProperty(t,"getJavaLibPath",{enumerable:!0,get:function(){return u.getJavaLibPath}});const l=s(a(248));t.TypescriptDefinitionGenerator=l.default},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.ensureJvm=void 0;const r=a(163),n=a(841);let i=null;function o(e){i||(i=new r.Java(e?.libPath,e?.version,e?.opts,e,(0,n.getJavaLibPath)(),(0,n.getNativeLibPath)()))}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){o(),i.appendClasspath(e)}var d;t.ensureJvm=o,t.importClass=function(e){o();const t=i.importClass(e);return s(t,!0),t.constructor=function(...e){const a=new t.prototype.constructor(...e);return s(a,!1),a},t},t.importClassAsync=async function(e){o();const t=await i.importClassAsync(e);return s(t,!0),t.constructor=function(...e){const a=new t.prototype.constructor(...e);return s(a,!1),a},t},t.appendClasspath=c,t.isInstanceOf=function(e,t){return o(),i.isInstanceOf(e,t)},(d=t.classpath||(t.classpath={})).append=function(e){c(e)},d.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:u,arch:l}=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: ${u} ${l}`)}t.getNativeLibPath=function(){switch(u){case"android":switch(l){case"arm64":return f("java.android-arm64");case"arm":return f("java.android-arm-eabi");default:throw p()}case"win32":return f(`java.win32-${l}-msvc`);case"darwin":return f(`java.darwin-${l}`);case"freebsd":return f(`java.freebsd-${l}`);case"linux":switch(l){case"x64":case"arm64":return f(`java.linux-${l}-${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])}},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,u=null;function l(){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){u=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){u=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){u=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){u=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){u=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){u=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){u=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){u=e}break;case"linux":switch(s){case"x64":if(l()){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){u=e}}else{d=r(i(__dirname,"java.linux-x64-gnu.node"));try{c=d?a(388):require("java-bridge-linux-x64-gnu")}catch(e){u=e}}break;case"arm64":if(l()){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){u=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){u=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){u=e}break;default:throw new Error(`Unsupported architecture on Linux: ${s}`)}break;default:throw new Error(`Unsupported OS: ${o}, architecture: ${s}`)}if(!c){if(u)throw u;throw new Error("Failed to load native binding")}const{Java:f,getClassFields:p,getField:v,setField:m,getStaticField:y,setStaticField:h,JavaInterfaceProxy:b,StdoutRedirect:g,getJavaLibPath:j}=c;e.exports.Java=f,e.exports.getClassFields=p,e.exports.getField=v,e.exports.setField=m,e.exports.getStaticField=y,e.exports.setStaticField=h,e.exports.JavaInterfaceProxy=b,e.exports.StdoutRedirect=g,e.exports.getJavaLibPath=j},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)),u=o(a(17)),l=s.default.createSourceFile("source.ts","",s.default.ScriptTarget.Latest,!1,s.default.ScriptKind.TS);class f{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 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))),...r]}javaTypeToTypescriptType(e,t){switch(e){case"byte[]":case"java.lang.Byte[]":return s.default.factory.createTypeReferenceNode("Buffer")}if(e.endsWith("[]"))return s.default.factory.createArrayTypeNode(this.javaTypeToTypescriptType(e.substring(0,e.length-2),t));switch(e){case"int":case"java.lang.Integer":case"long":case"java.lang.Long":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 s.default.factory.createKeywordTypeNode(s.default.SyntaxKind.NumberKeyword);case"char":case"java.lang.Character":case"java.lang.String":return s.default.factory.createKeywordTypeNode(s.default.SyntaxKind.StringKeyword);case"boolean":case"java.lang.Boolean":return s.default.factory.createKeywordTypeNode(s.default.SyntaxKind.BooleanKeyword);case"void":case"java.lang.Void":return s.default.factory.createKeywordTypeNode(s.default.SyntaxKind.VoidKeyword);case"java.lang.Object":return this.usesBasicOrJavaType=!0,s.default.factory.createTypeReferenceNode("BasicOrJavaType");default: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(".","_"))}}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){const n=s.default.factory.createModifier(s.default.SyntaxKind.PublicKeyword),i=s.default.factory.createModifier(s.default.SyntaxKind.StaticKeyword),o=[n];e.isStatic&&o.push(i);let c=this.javaTypeToTypescriptType(e.returnType,!1);r||(c=s.default.factory.createTypeReferenceNode(s.default.factory.createIdentifier("Promise"),[c]));let d=s.default.factory.createMethodDeclaration(o,void 0,t+(r?"Sync":""),void 0,void 0,this.convertParameters(e),c,void 0);return 0===a&&(d=s.default.addSyntheticLeadingComment(d,s.default.SyntaxKind.SingleLineCommentTrivia,` ================== Method ${t} ==================`,!0)),s.default.addSyntheticLeadingComment(d,s.default.SyntaxKind.MultiLineCommentTrivia,f.createMethodComment(e),!0)}convertMethod(e,t){const a=[];for(let r=0;r<e.length;r++){const n=e[r];a.push(this.createMethod(n,t,r,!1),this.createMethod(n,t,r,!0))}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){const t=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)])],[]);return[s.default.addSyntheticLeadingComment(t,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,l)||"")).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.getDeclaredMethods(),r=[],n=await f.convertMethods(a);for(const e of Object.keys(n)){const t=n[e];r.push(...this.convertMethod(t,e))}const i=await e.getDeclaredConstructors(),o=await this.convertConstructors(i);r.push(...o);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)])],r);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 u=this.getText([this.getImports(),...this.getAdditionalImports(),null,d,null,...this.getExportStatement(t)]),l=[];for(const e of this.additionalImports){const t=new f(e,this.progressCallback,this.resolvedImports),a=await t.generate();l.push(...a)}return l.push({name:this.classname,contents:u}),l}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=u.default.join(t,...e);await d.default.promises.mkdir(u.default.dirname(r),{recursive:!0}),await d.default.promises.writeFile(r,a.contents,{encoding:"utf8"})}}}t.default=f},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.TypescriptDefinitionGenerator=t.getJavaVersionSync=t.getJavaVersion=t.getJavaLibPath=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}}),i(a(818),t);const d=o(a(818));t.default=d;var u=a(163);Object.defineProperty(t,"getJavaLibPath",{enumerable:!0,get:function(){return u.getJavaLibPath}});var l=a(102);Object.defineProperty(t,"getJavaVersion",{enumerable:!0,get:function(){return l.getJavaVersion}}),Object.defineProperty(t,"getJavaVersionSync",{enumerable:!0,get:function(){return l.getJavaVersionSync}});const f=s(a(248));t.TypescriptDefinitionGenerator=f.default},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.ensureJvm=void 0;const r=a(163),n=a(841);let i=null;function o(e){i||(i=new r.Java(e?.libPath,e?.version,e?.opts,e,(0,n.getJavaLibPath)(),(0,n.getNativeLibPath)()))}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){o(),i.appendClasspath(e)}var d;t.ensureJvm=o,t.importClass=function(e){o();const t=i.importClass(e);return s(t,!0),t.constructor=function(...e){const a=new t.prototype.constructor(...e);return s(a,!1),a},t},t.importClassAsync=async function(e){o();const t=await i.importClassAsync(e);return s(t,!0),t.constructor=function(...e){const a=new t.prototype.constructor(...e);return s(a,!1),a},t},t.appendClasspath=c,t.isInstanceOf=function(e,t){return o(),i.isInstanceOf(e,t)},(d=t.classpath||(t.classpath={})).append=function(e){c(e)},d.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:u,arch:l}=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: ${u} ${l}`)}t.getNativeLibPath=function(){switch(u){case"android":switch(l){case"arm64":return f("java.android-arm64");case"arm":return f("java.android-arm-eabi");default:throw p()}case"win32":return f(`java.win32-${l}-msvc`);case"darwin":return f(`java.darwin-${l}`);case"freebsd":return f(`java.freebsd-${l}`);case"linux":switch(l){case"x64":case"arm64":return f(`java.linux-${l}-${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,u=null;function l(){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){u=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){u=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){u=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){u=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){u=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){u=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){u=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){u=e}break;case"linux":switch(s){case"x64":if(l()){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){u=e}}else{d=r(i(__dirname,"java.linux-x64-gnu.node"));try{c=d?a(388):require("java-bridge-linux-x64-gnu")}catch(e){u=e}}break;case"arm64":if(l()){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){u=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){u=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){u=e}break;default:throw new Error(`Unsupported architecture on Linux: ${s}`)}break;default:throw new Error(`Unsupported OS: ${o}, architecture: ${s}`)}if(!c){if(u)throw u;throw new Error("Failed to load native binding")}const{Java:p,getClassFields:f,getField:m,setField:h,getStaticField:v,setStaticField:_,JavaInterfaceProxy:b,StdoutRedirect:y,getJavaLibPath:g}=c;e.exports.Java=p,e.exports.getClassFields=f,e.exports.getField=m,e.exports.setField=h,e.exports.getStaticField=v,e.exports.setStaticField=_,e.exports.JavaInterfaceProxy=b,e.exports.StdoutRedirect=y,e.exports.getJavaLibPath=g},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)),u=o(a(17)),l=s.default.createSourceFile("source.ts","",s.default.ScriptTarget.Latest,!1,s.default.ScriptKind.TS);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 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))),...r]}javaTypeToTypescriptType(e,t){switch(e){case"byte[]":case"java.lang.Byte[]":return s.default.factory.createTypeReferenceNode("Buffer")}if(e.endsWith("[]"))return s.default.factory.createArrayTypeNode(this.javaTypeToTypescriptType(e.substring(0,e.length-2),t));switch(e){case"int":case"java.lang.Integer":case"long":case"java.lang.Long":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 s.default.factory.createKeywordTypeNode(s.default.SyntaxKind.NumberKeyword);case"char":case"java.lang.Character":case"java.lang.String":return s.default.factory.createKeywordTypeNode(s.default.SyntaxKind.StringKeyword);case"boolean":case"java.lang.Boolean":return s.default.factory.createKeywordTypeNode(s.default.SyntaxKind.BooleanKeyword);case"void":case"java.lang.Void":return s.default.factory.createKeywordTypeNode(s.default.SyntaxKind.VoidKeyword);case"java.lang.Object":return this.usesBasicOrJavaType=!0,s.default.factory.createTypeReferenceNode("BasicOrJavaType");default: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(".","_"))}}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){const n=s.default.factory.createModifier(s.default.SyntaxKind.PublicKeyword),i=s.default.factory.createModifier(s.default.SyntaxKind.StaticKeyword),o=[n];e.isStatic&&o.push(i);let c=this.javaTypeToTypescriptType(e.returnType,!1);r||(c=s.default.factory.createTypeReferenceNode(s.default.factory.createIdentifier("Promise"),[c]));let d=s.default.factory.createMethodDeclaration(o,void 0,t+(r?"Sync":""),void 0,void 0,this.convertParameters(e),c,void 0);return 0===a&&(d=s.default.addSyntheticLeadingComment(d,s.default.SyntaxKind.SingleLineCommentTrivia,` ================== Method ${t} ==================`,!0)),s.default.addSyntheticLeadingComment(d,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];a.push(this.createMethod(n,t,r,!1),this.createMethod(n,t,r,!0))}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){const t=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)])],[]);return[s.default.addSyntheticLeadingComment(t,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,l)||"")).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.getDeclaredMethods(),r=[],n=await p.convertMethods(a);for(const e of Object.keys(n)){const t=n[e];r.push(...this.convertMethod(t,e))}const i=await e.getDeclaredConstructors(),o=await this.convertConstructors(i);r.push(...o);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)])],r);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 u=this.getText([this.getImports(),...this.getAdditionalImports(),null,d,null,...this.getExportStatement(t)]),l=[];for(const e of this.additionalImports){const t=new p(e,this.progressCallback,this.resolvedImports),a=await t.generate();l.push(...a)}return l.push({name:this.classname,contents:u}),l}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=u.default.join(t,...e);await d.default.promises.mkdir(u.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.TypescriptDefinitionGenerator=t.getJavaLibPath=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}}),i(a(818),t);const d=o(a(818));t.default=d;var u=a(163);Object.defineProperty(t,"getJavaLibPath",{enumerable:!0,get:function(){return u.getJavaLibPath}});const l=s(a(248));t.TypescriptDefinitionGenerator=l.default},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.ensureJvm=void 0;const r=a(163),n=a(841);let i=null;function o(e){i||(i=new r.Java(e?.libPath,e?.version,e?.opts,e,(0,n.getJavaLibPath)(),(0,n.getNativeLibPath)()))}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){o(),i.appendClasspath(e)}var d;t.ensureJvm=o,t.importClass=function(e){o();const t=i.importClass(e);return s(t,!0),t.constructor=function(...e){const a=new t.prototype.constructor(...e);return s(a,!1),a},t},t.importClassAsync=async function(e){o();const t=await i.importClassAsync(e);return s(t,!0),t.constructor=function(...e){const a=new t.prototype.constructor(...e);return s(a,!1),a},t},t.appendClasspath=c,t.isInstanceOf=function(e,t){return o(),i.isInstanceOf(e,t)},(d=t.classpath||(t.classpath={})).append=function(e){c(e)},d.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:u,arch:l}=process;function p(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 f(){return new Error(`Unsupported platform: ${u} ${l}`)}t.getNativeLibPath=function(){switch(u){case"android":switch(l){case"arm64":return p("java.android-arm64");case"arm":return p("java.android-arm-eabi");default:throw f()}case"win32":return p(`java.win32-${l}-msvc`);case"darwin":return p(`java.darwin-${l}`);case"freebsd":return p(`java.freebsd-${l}`);case"linux":switch(l){case"x64":case"arm64":return p(`java.linux-${l}-${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 p("java.linux-arm-gnueabihf");default:throw f()}default:throw f()}},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 u=0,l=0,p=0,f="";const m=setInterval((()=>{p+=1,h()}),1e3),h=()=>{r.text=i.gray(`Elapsed time: ${i.yellow(p)} seconds ${i.white("|")} Converted ${i.cyanBright(u)} classes ${i.white("|")} Converting class ${i.magentaBright(f)}`)};for(const a of e){const e=new _1.TypescriptDefinitionGenerator(a,(e=>{f=e,u++,h()}),d),n=await e.generate();l+=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(l)} 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()},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.4","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"]}},"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":"mocha -r ts-node/register test/**/*.test.ts","testOnly":"mocha -r ts-node/register test/**/*.test.ts","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"},"dependencies":{"chalk":"^5.0.1","glob":"^8.0.3","ora":"^6.1.2","typescript":"^4.8.2","yargs":"^17.5.1"},"devDependencies":{"@napi-rs/cli":"^2.11.4","@types/chai":"^4.3.3","@types/glob":"^8.0.0","@types/mocha":"^9.1.1","@types/node":"^18.7.15","@types/semver":"^7.3.12","@types/webpack-node-externals":"^2.5.3","@types/yargs":"^17.0.12","chai":"^4.3.6","cpy-cli":"^4.2.0","expose-gc":"^1.0.0","mocha":"^10.0.0","nanobench":"^3.0.0","node-loader":"^2.0.0","prettier":"^2.7.1","rimraf":"^3.0.2","run-script-os":"^1.1.6","semver":"^7.3.7","string-replace-loader":"^3.1.0","ts-loader":"^9.3.1","ts-node":"^10.9.1","tslib":"^2.4.0","typedoc":"^0.23.14","webpack":"^5.74.0","webpack-cli":"^4.10.0","webpack-node-externals":"^3.0.0"},"optionalDependencies":{"java-bridge-win32-x64-msvc":"2.1.4","java-bridge-darwin-x64":"2.1.4","java-bridge-linux-x64-gnu":"2.1.4","java-bridge-darwin-arm64":"2.1.4","java-bridge-win32-ia32-msvc":"2.1.4"}}')}},__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,u=null;function l(){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){u=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){u=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){u=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){u=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){u=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){u=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){u=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){u=e}break;case"linux":switch(s){case"x64":if(l()){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){u=e}}else{d=r(i(__dirname,"java.linux-x64-gnu.node"));try{c=d?a(388):require("java-bridge-linux-x64-gnu")}catch(e){u=e}}break;case"arm64":if(l()){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){u=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){u=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){u=e}break;default:throw new Error(`Unsupported architecture on Linux: ${s}`)}break;default:throw new Error(`Unsupported OS: ${o}, architecture: ${s}`)}if(!c){if(u)throw u;throw new Error("Failed to load native binding")}const{Java:p,getClassFields:f,getField:m,setField:v,getStaticField:h,setStaticField:y,JavaInterfaceProxy:b,StdoutRedirect:_,getJavaLibPath:g}=c;e.exports.Java=p,e.exports.getClassFields=f,e.exports.getField=m,e.exports.setField=v,e.exports.getStaticField=h,e.exports.setStaticField=y,e.exports.JavaInterfaceProxy=b,e.exports.StdoutRedirect=_,e.exports.getJavaLibPath=g},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)),u=o(a(17)),l=s.default.createSourceFile("source.ts","",s.default.ScriptTarget.Latest,!1,s.default.ScriptKind.TS);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 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))),...r]}javaTypeToTypescriptType(e,t){switch(e){case"byte[]":case"java.lang.Byte[]":return s.default.factory.createTypeReferenceNode("Buffer")}if(e.endsWith("[]"))return s.default.factory.createArrayTypeNode(this.javaTypeToTypescriptType(e.substring(0,e.length-2),t));switch(e){case"int":case"java.lang.Integer":case"long":case"java.lang.Long":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 s.default.factory.createKeywordTypeNode(s.default.SyntaxKind.NumberKeyword);case"char":case"java.lang.Character":case"java.lang.String":return s.default.factory.createKeywordTypeNode(s.default.SyntaxKind.StringKeyword);case"boolean":case"java.lang.Boolean":return s.default.factory.createKeywordTypeNode(s.default.SyntaxKind.BooleanKeyword);case"void":case"java.lang.Void":return s.default.factory.createKeywordTypeNode(s.default.SyntaxKind.VoidKeyword);case"java.lang.Object":return this.usesBasicOrJavaType=!0,s.default.factory.createTypeReferenceNode("BasicOrJavaType");default: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(".","_"))}}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){const n=s.default.factory.createModifier(s.default.SyntaxKind.PublicKeyword),i=s.default.factory.createModifier(s.default.SyntaxKind.StaticKeyword),o=[n];e.isStatic&&o.push(i);let c=this.javaTypeToTypescriptType(e.returnType,!1);r||(c=s.default.factory.createTypeReferenceNode(s.default.factory.createIdentifier("Promise"),[c]));let d=s.default.factory.createMethodDeclaration(o,void 0,t+(r?"Sync":""),void 0,void 0,this.convertParameters(e),c,void 0);return 0===a&&(d=s.default.addSyntheticLeadingComment(d,s.default.SyntaxKind.SingleLineCommentTrivia,` ================== Method ${t} ==================`,!0)),s.default.addSyntheticLeadingComment(d,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];a.push(this.createMethod(n,t,r,!1),this.createMethod(n,t,r,!0))}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){const t=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)])],[]);return[s.default.addSyntheticLeadingComment(t,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,l)||"")).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.getDeclaredMethods(),r=[],n=await p.convertMethods(a);for(const e of Object.keys(n)){const t=n[e];r.push(...this.convertMethod(t,e))}const i=await e.getDeclaredConstructors(),o=await this.convertConstructors(i);r.push(...o);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)])],r);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 u=this.getText([this.getImports(),...this.getAdditionalImports(),null,d,null,...this.getExportStatement(t)]),l=[];for(const e of this.additionalImports){const t=new p(e,this.progressCallback,this.resolvedImports),a=await t.generate();l.push(...a)}return l.push({name:this.classname,contents:u}),l}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=u.default.join(t,...e);await d.default.promises.mkdir(u.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.TypescriptDefinitionGenerator=t.getJavaVersionSync=t.getJavaVersion=t.getJavaLibPath=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}}),i(a(818),t);const d=o(a(818));t.default=d;var u=a(163);Object.defineProperty(t,"getJavaLibPath",{enumerable:!0,get:function(){return u.getJavaLibPath}});var l=a(102);Object.defineProperty(t,"getJavaVersion",{enumerable:!0,get:function(){return l.getJavaVersion}}),Object.defineProperty(t,"getJavaVersionSync",{enumerable:!0,get:function(){return l.getJavaVersionSync}});const p=s(a(248));t.TypescriptDefinitionGenerator=p.default},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.ensureJvm=void 0;const r=a(163),n=a(841);let i=null;function o(e){i||(i=new r.Java(e?.libPath,e?.version,e?.opts,e,(0,n.getJavaLibPath)(),(0,n.getNativeLibPath)()))}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){o(),i.appendClasspath(e)}var d;t.ensureJvm=o,t.importClass=function(e){o();const t=i.importClass(e);return s(t,!0),t.constructor=function(...e){const a=new t.prototype.constructor(...e);return s(a,!1),a},t},t.importClassAsync=async function(e){o();const t=await i.importClassAsync(e);return s(t,!0),t.constructor=function(...e){const a=new t.prototype.constructor(...e);return s(a,!1),a},t},t.appendClasspath=c,t.isInstanceOf=function(e,t){return o(),i.isInstanceOf(e,t)},(d=t.classpath||(t.classpath={})).append=function(e){c(e)},d.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:u,arch:l}=process;function p(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 f(){return new Error(`Unsupported platform: ${u} ${l}`)}t.getNativeLibPath=function(){switch(u){case"android":switch(l){case"arm64":return p("java.android-arm64");case"arm":return p("java.android-arm-eabi");default:throw f()}case"win32":return p(`java.win32-${l}-msvc`);case"darwin":return p(`java.darwin-${l}`);case"freebsd":return p(`java.freebsd-${l}`);case"linux":switch(l){case"x64":case"arm64":return p(`java.linux-${l}-${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 p("java.linux-arm-gnueabihf");default:throw f()}default:throw f()}},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 u=0,l=0,p=0,f="";const m=setInterval((()=>{p+=1,v()}),1e3),v=()=>{r.text=i.gray(`Elapsed time: ${i.yellow(p)} seconds ${i.white("|")} Converted ${i.cyanBright(u)} classes ${i.white("|")} Converting class ${i.magentaBright(f)}`)};for(const a of e){const e=new _1.TypescriptDefinitionGenerator(a,(e=>{f=e,u++,v()}),d),n=await e.generate();l+=n.length,r.text="saving results",await _1.TypescriptDefinitionGenerator.save(n,t)}clearInterval(m);const h=((perf_hooks_1.performance.now()-n)/1e3).toFixed(1);r.succeed(`Success - Converted ${i.blueBright(l)} classes in ${i.blueBright(h)} 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.5-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","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"},"dependencies":{"chalk":"^5.1.2","glob":"^8.0.3","ora":"^6.1.2","typescript":"^4.8.4","yargs":"^17.6.1"},"devDependencies":{"@napi-rs/cli":"^2.12.0","@types/chai":"^4.3.3","@types/glob":"^8.0.0","@types/is-ci":"^3.0.0","@types/mocha":"^10.0.0","@types/node":"^18.11.9","@types/semver":"^7.3.13","@types/webpack-node-externals":"^2.5.3","@types/yargs":"^17.0.13","chai":"^4.3.6","cpy-cli":"^4.2.0","expose-gc":"^1.0.0","is-ci":"^3.0.1","mocha":"^10.1.0","nanobench":"^3.0.0","node-loader":"^2.0.0","prettier":"^2.7.1","rimraf":"^3.0.2","run-script-os":"^1.1.6","semver":"^7.3.8","string-replace-loader":"^3.1.0","ts-loader":"^9.4.1","ts-node":"^10.9.1","tslib":"^2.4.1","typedoc":"^0.23.20","webpack":"^5.74.0","webpack-cli":"^4.10.0","webpack-node-externals":"^3.0.0"},"optionalDependencies":{"java-bridge-darwin-arm64":"2.0.0","java-bridge-darwin-x64":"2.0.0","java-bridge-linux-x64-gnu":"2.0.0","java-bridge-win32-ia32-msvc":"2.0.0","java-bridge-win32-x64-msvc":"2.0.0","java-bridge-linux-arm64-gnu":"2.0.0"}}')}},__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 |
@@ -13,4 +13,5 @@ export { JavaVersion, JavaObject, JavaClassInstance, JavaClassProxy, JavaClass, JavaClassConstructor, JavaType, BasicOrJavaType, BasicType, JavaClassType, Constructor, UnknownJavaClassType, JavaClassConstructorType, } from './definitions'; | ||
export { getJavaLibPath } from '../native'; | ||
export { getJavaVersion, getJavaVersionSync } from './util'; | ||
import TypescriptDefinitionGenerator from './TypescriptDefinitionGenerator'; | ||
export { TypescriptDefinitionGenerator }; | ||
export { ModuleDeclaration, MethodDeclaration, ProgressCallback, } from './TypescriptDefinitionGenerator'; |
{ | ||
"name": "java-bridge", | ||
"version": "2.1.4", | ||
"version": "2.1.5-beta.1", | ||
"main": "dist/index.prod.min.js", | ||
@@ -27,3 +27,4 @@ "types": "dist/ts-src/index.d.ts", | ||
"aarch64-apple-darwin", | ||
"i686-pc-windows-msvc" | ||
"i686-pc-windows-msvc", | ||
"aarch64-unknown-linux-gnu" | ||
] | ||
@@ -58,3 +59,3 @@ } | ||
"prepublishOnly": "napi prepublish -t npm", | ||
"test": "mocha -r ts-node/register test/**/*.test.ts", | ||
"test": "npm run testOnly", | ||
"testOnly": "mocha -r ts-node/register test/**/*.test.ts", | ||
@@ -71,21 +72,23 @@ "pretest": "npm run build", | ||
"dependencies": { | ||
"chalk": "^5.0.1", | ||
"chalk": "^5.1.2", | ||
"glob": "^8.0.3", | ||
"ora": "^6.1.2", | ||
"typescript": "^4.8.2", | ||
"yargs": "^17.5.1" | ||
"typescript": "^4.8.4", | ||
"yargs": "^17.6.1" | ||
}, | ||
"devDependencies": { | ||
"@napi-rs/cli": "^2.11.4", | ||
"@napi-rs/cli": "^2.12.0", | ||
"@types/chai": "^4.3.3", | ||
"@types/glob": "^8.0.0", | ||
"@types/mocha": "^9.1.1", | ||
"@types/node": "^18.7.15", | ||
"@types/semver": "^7.3.12", | ||
"@types/is-ci": "^3.0.0", | ||
"@types/mocha": "^10.0.0", | ||
"@types/node": "^18.11.9", | ||
"@types/semver": "^7.3.13", | ||
"@types/webpack-node-externals": "^2.5.3", | ||
"@types/yargs": "^17.0.12", | ||
"@types/yargs": "^17.0.13", | ||
"chai": "^4.3.6", | ||
"cpy-cli": "^4.2.0", | ||
"expose-gc": "^1.0.0", | ||
"mocha": "^10.0.0", | ||
"is-ci": "^3.0.1", | ||
"mocha": "^10.1.0", | ||
"nanobench": "^3.0.0", | ||
@@ -96,8 +99,8 @@ "node-loader": "^2.0.0", | ||
"run-script-os": "^1.1.6", | ||
"semver": "^7.3.7", | ||
"semver": "^7.3.8", | ||
"string-replace-loader": "^3.1.0", | ||
"ts-loader": "^9.3.1", | ||
"ts-loader": "^9.4.1", | ||
"ts-node": "^10.9.1", | ||
"tslib": "^2.4.0", | ||
"typedoc": "^0.23.14", | ||
"tslib": "^2.4.1", | ||
"typedoc": "^0.23.20", | ||
"webpack": "^5.74.0", | ||
@@ -108,8 +111,9 @@ "webpack-cli": "^4.10.0", | ||
"optionalDependencies": { | ||
"java-bridge-win32-x64-msvc": "2.1.4", | ||
"java-bridge-darwin-x64": "2.1.4", | ||
"java-bridge-linux-x64-gnu": "2.1.4", | ||
"java-bridge-darwin-arm64": "2.1.4", | ||
"java-bridge-win32-ia32-msvc": "2.1.4" | ||
"java-bridge-win32-x64-msvc": "2.1.5-beta.1", | ||
"java-bridge-darwin-x64": "2.1.5-beta.1", | ||
"java-bridge-linux-x64-gnu": "2.1.5-beta.1", | ||
"java-bridge-darwin-arm64": "2.1.5-beta.1", | ||
"java-bridge-win32-ia32-msvc": "2.1.5-beta.1", | ||
"java-bridge-linux-arm64-gnu": "2.1.5-beta.1" | ||
} | ||
} |
@@ -0,1 +1,7 @@ | ||
# node-java | ||
[![Test](https://github.com/MarkusJx/node-java-bridge/actions/workflows/test.yml/badge.svg)](https://github.com/MarkusJx/node-java-bridge/actions/workflows/test.yml) | ||
[![Check-style](https://github.com/MarkusJx/node-java-bridge/actions/workflows/check-style.yml/badge.svg)](https://github.com/MarkusJx/node-java-bridge/actions/workflows/check-style.yml) | ||
[![SystemTest](https://github.com/MarkusJx/node-java-bridge/actions/workflows/system_test.yml/badge.svg)](https://github.com/MarkusJx/node-java-bridge/actions/workflows/system_test.yml) | ||
A bridge between Node.js programs and Java APIs written in Rust using [napi-rs](https://napi.rs/) | ||
@@ -20,2 +26,19 @@ to provide a fast and memory-safe interface between the two languages. | ||
## Build instructions | ||
In order to build this project, you should install | ||
- Node.js | ||
- npm | ||
- rustc, the rust compiler | ||
- cargo | ||
- Java JDK 8+ | ||
Then, to build the project, run: | ||
```sh | ||
npm install | ||
npm run build | ||
``` | ||
## Usage | ||
@@ -22,0 +45,0 @@ |
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
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
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
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
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
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
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
312
8
273404
11
28
16
1132
3
+ Addedjava-bridge-darwin-arm64@2.1.5-beta.1(transitive)
+ Addedjava-bridge-darwin-x64@2.1.5-beta.1(transitive)
+ Addedjava-bridge-linux-arm64-gnu@2.1.5-beta.1(transitive)
+ Addedjava-bridge-linux-x64-gnu@2.1.5-beta.1(transitive)
+ Addedjava-bridge-win32-ia32-msvc@2.1.5-beta.1(transitive)
+ Addedjava-bridge-win32-x64-msvc@2.1.5-beta.1(transitive)
- Removedjava-bridge-darwin-arm64@2.1.4(transitive)
- Removedjava-bridge-darwin-x64@2.1.4(transitive)
- Removedjava-bridge-linux-x64-gnu@2.1.4(transitive)
- Removedjava-bridge-win32-ia32-msvc@2.1.4(transitive)
- Removedjava-bridge-win32-x64-msvc@2.1.4(transitive)
Updatedchalk@^5.1.2
Updatedtypescript@^4.8.4
Updatedyargs@^17.6.1