java-bridge
Advanced tools
Comparing version 2.1.0 to 2.1.1
#!/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(void 0,[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.createIdentifier("Buffer"),_typeNodeBrand:""}}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.createIdentifier("BasicOrJavaType"),_typeNodeBrand:""};default:this.resolvedImports.includes(e)||this.additionalImports.push(e),this.importsToResolve.push(e);const a=e===this.classname&&t;return{...s.default.factory.createIdentifier(e===this.classname?e.substring(e.lastIndexOf(".")+1)+(a?"Class":""):e.replaceAll(".","_")),_typeNodeBrand:""}}}convertParameter(e,t){const a="var"+t,r=this.javaTypeToTypescriptType(e,!0);return s.default.factory.createParameterDeclaration(void 0,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(void 0,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,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("JavaClassInstance"))];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,void 0,s.default.factory.createImportClause(!1,void 0,t),s.default.factory.createStringLiteral("java-bridge"))}getExportStatement(e){const t=s.default.factory.createClassDeclaration(void 0,[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(void 0,[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("JavaClassInstance"),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};Object.defineProperty(t,"__esModule",{value:!0}),t.getJavaLibPath=t.JavaClassProxy=t.JavaClassInstance=t.JavaObject=t.JavaVersion=void 0;var s=a(91);Object.defineProperty(t,"JavaVersion",{enumerable:!0,get:function(){return s.JavaVersion}}),Object.defineProperty(t,"JavaObject",{enumerable:!0,get:function(){return s.JavaObject}}),Object.defineProperty(t,"JavaClassInstance",{enumerable:!0,get:function(){return s.JavaClassInstance}}),Object.defineProperty(t,"JavaClassProxy",{enumerable:!0,get:function(){return s.JavaClassProxy}}),i(a(818),t);const c=o(a(818));t.default=c;var d=a(163);Object.defineProperty(t,"getJavaLibPath",{enumerable:!0,get:function(){return d.getJavaLibPath}})},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=__importDefault(__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})=>{try{const r=perf_hooks_1.performance.now();a&&__1.default.classpath.append(a);const n=await importChalk(),i=await importOra();console.log(`Starting ${n.cyanBright("java-bridge")} ${n.greenBright("v"+package_json_1.version)} Java definition generator`);const o=__1.default.getJavaInstance(),s=__1.default.classpath.get();s.length>0&&console.log(`Started JVM with version ${n.cyanBright(o.version)} and classpath '${s.map((e=>n.cyanBright(e))).join(";")}'`),console.log(`Converting classes ${e.map((e=>n.magentaBright(e))).join(", ")} to typescript and saving result to ${n.cyanBright(path_1.default.normalize(t))}`);const c=i().start(),d=[];let u=0,l=0,p=0,f="";const m=setInterval((()=>{p+=1,h()}),1e3),h=()=>{c.text=n.gray(`Elapsed time: ${n.yellow(p)} seconds ${n.white("|")} Converted ${n.cyanBright(u)} classes ${n.white("|")} Converting class ${n.magentaBright(f)}`)},v=(await Promise.resolve().then((()=>__importStar(__webpack_require__(248))))).default;for(const a of e){const e=new v(a,(e=>{f=e,u++,h()}),d),r=await e.generate();l+=r.length,c.text="saving results",await v.save(r,t)}clearInterval(m);const _=((perf_hooks_1.performance.now()-r)/1e3).toFixed(1);c.succeed(`Success - Converted ${n.blueBright(l)} classes in ${n.blueBright(_)} seconds`)}catch(e){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.0","main":"dist/index.prod.min.js","typings":"ts-src/index.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":["ts-src","dist/*.js","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","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","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/webpack-node-externals":"^2.5.3","@types/yargs":"^17.0.12","chai":"^4.3.6","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","string-replace-loader":"^3.1.0","ts-loader":"^9.3.1","ts-node":"^10.9.1","tslib":"^2.4.0","typedoc":"^0.23.12","webpack":"^5.74.0","webpack-cli":"^4.10.0","webpack-node-externals":"^3.0.0"},"optionalDependencies":{"java-bridge-darwin-arm64":"2.1.0","java-bridge-darwin-x64":"2.1.0","java-bridge-linux-x64-gnu":"2.1.0","java-bridge-win32-ia32-msvc":"2.1.0","java-bridge-win32-x64-msvc":"^2.1.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__})())); | ||
!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(void 0,[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.createIdentifier("Buffer"),_typeNodeBrand:""}}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.createIdentifier("BasicOrJavaType"),_typeNodeBrand:""};default:this.resolvedImports.includes(e)||this.additionalImports.push(e),this.importsToResolve.push(e);const a=e===this.classname&&t;return{...s.default.factory.createIdentifier(e===this.classname?e.substring(e.lastIndexOf(".")+1)+(a?"Class":""):e.replaceAll(".","_")),_typeNodeBrand:""}}}convertParameter(e,t){const a="var"+t,r=this.javaTypeToTypescriptType(e,!0);return s.default.factory.createParameterDeclaration(void 0,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(void 0,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,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("JavaClassInstance"))];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,void 0,s.default.factory.createImportClause(!1,void 0,t),s.default.factory.createStringLiteral("java-bridge"))}getExportStatement(e){const t=s.default.factory.createClassDeclaration(void 0,[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(void 0,[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("JavaClassInstance"),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};Object.defineProperty(t,"__esModule",{value:!0}),t.getJavaLibPath=t.JavaClassProxy=t.JavaClassInstance=t.JavaObject=t.JavaVersion=void 0;var s=a(91);Object.defineProperty(t,"JavaVersion",{enumerable:!0,get:function(){return s.JavaVersion}}),Object.defineProperty(t,"JavaObject",{enumerable:!0,get:function(){return s.JavaObject}}),Object.defineProperty(t,"JavaClassInstance",{enumerable:!0,get:function(){return s.JavaClassInstance}}),Object.defineProperty(t,"JavaClassProxy",{enumerable:!0,get:function(){return s.JavaClassProxy}}),i(a(818),t);const c=o(a(818));t.default=c;var d=a(163);Object.defineProperty(t,"getJavaLibPath",{enumerable:!0,get:function(){return d.getJavaLibPath}})},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=__importDefault(__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})=>{try{const r=perf_hooks_1.performance.now();a&&__1.default.classpath.append(a);const n=await importChalk(),i=await importOra();console.log(`Starting ${n.cyanBright("java-bridge")} ${n.greenBright("v"+package_json_1.version)} Java definition generator`);const o=__1.default.getJavaInstance(),s=__1.default.classpath.get();s.length>0&&console.log(`Started JVM with version ${n.cyanBright(o.version)} and classpath '${s.map((e=>n.cyanBright(e))).join(";")}'`),console.log(`Converting classes ${e.map((e=>n.magentaBright(e))).join(", ")} to typescript and saving result to ${n.cyanBright(path_1.default.normalize(t))}`);const c=i().start(),d=[];let u=0,l=0,p=0,f="";const m=setInterval((()=>{p+=1,h()}),1e3),h=()=>{c.text=n.gray(`Elapsed time: ${n.yellow(p)} seconds ${n.white("|")} Converted ${n.cyanBright(u)} classes ${n.white("|")} Converting class ${n.magentaBright(f)}`)},v=(await Promise.resolve().then((()=>__importStar(__webpack_require__(248))))).default;for(const a of e){const e=new v(a,(e=>{f=e,u++,h()}),d),r=await e.generate();l+=r.length,c.text="saving results",await v.save(r,t)}clearInterval(m);const _=((perf_hooks_1.performance.now()-r)/1e3).toFixed(1);c.succeed(`Success - Converted ${n.blueBright(l)} classes in ${n.blueBright(_)} seconds`)}catch(e){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.1","main":"dist/index.prod.min.js","typings":"ts-src/index.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":["ts-src","dist/*.js","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","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","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.14","@types/semver":"^7.3.12","@types/webpack-node-externals":"^2.5.3","@types/yargs":"^17.0.12","chai":"^4.3.6","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.13","webpack":"^5.74.0","webpack-cli":"^4.10.0","webpack-node-externals":"^3.0.0"},"optionalDependencies":{"java-bridge-darwin-arm64":"2.1.0","java-bridge-darwin-x64":"2.1.0","java-bridge-linux-x64-gnu":"2.1.0","java-bridge-win32-ia32-msvc":"2.1.0","java-bridge-win32-x64-msvc":"^2.1.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 |
{ | ||
"name": "java-bridge", | ||
"version": "2.1.0", | ||
"version": "2.1.1", | ||
"main": "dist/index.prod.min.js", | ||
@@ -78,2 +78,4 @@ "typings": "ts-src/index.ts", | ||
"@types/mocha": "^9.1.1", | ||
"@types/node": "^18.7.14", | ||
"@types/semver": "^7.3.12", | ||
"@types/webpack-node-externals": "^2.5.3", | ||
@@ -89,2 +91,3 @@ "@types/yargs": "^17.0.12", | ||
"run-script-os": "^1.1.6", | ||
"semver": "^7.3.7", | ||
"string-replace-loader": "^3.1.0", | ||
@@ -94,3 +97,3 @@ "ts-loader": "^9.3.1", | ||
"tslib": "^2.4.0", | ||
"typedoc": "^0.23.12", | ||
"typedoc": "^0.23.13", | ||
"webpack": "^5.74.0", | ||
@@ -101,8 +104,8 @@ "webpack-cli": "^4.10.0", | ||
"optionalDependencies": { | ||
"java-bridge-win32-x64-msvc": "2.1.0", | ||
"java-bridge-darwin-x64": "2.1.0", | ||
"java-bridge-linux-x64-gnu": "2.1.0", | ||
"java-bridge-darwin-arm64": "2.1.0", | ||
"java-bridge-win32-ia32-msvc": "2.1.0" | ||
"java-bridge-win32-x64-msvc": "2.1.1", | ||
"java-bridge-darwin-x64": "2.1.1", | ||
"java-bridge-linux-x64-gnu": "2.1.1", | ||
"java-bridge-darwin-arm64": "2.1.1", | ||
"java-bridge-win32-ia32-msvc": "2.1.1" | ||
} | ||
} |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Long strings
Supply chain riskContains long string literals, which may be a sign of obfuscated or packed code.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Long strings
Supply chain riskContains long string literals, which may be a sign of obfuscated or packed code.
Found 1 instance in 1 package
148131
25