if(lastPathComponent==coreBridge_rootContainerDirectory){// typical node or electron-main process
fullPath=path.format({
dir:this_scriptDirectory,
base:filename
})
}else{
console.warn(`MyMoneroBridge_utils/locateFile() on node.js didn't find "${coreBridge_rootContainerDirectory}" (or possibly MyMoneroCoreBridge.js) itself in the expected location in the following path. The function may need to be expanded but it might in normal situations be likely to be another bug. ${pathTo_cryptonoteUtilsDir}`)
}
}elseif(ENVIRONMENT_IS_WEB){
varpathTo_cryptonoteUtilsDir;
if(typeof__dirname!==undefined&&__dirname!=="/"){// looks like node running in browser.. (but not going to assume it's electron-renderer since that should be taken care of by monero_utils.js itself)
// but just in case it is... here's an attempt to support it
// have to check != "/" b/c webpack (I think) replaces __dirname
pathTo_cryptonoteUtilsDir="file://"+__dirname+"/"// prepending "file://" because it's going to try to stream it
}else{// actual web browser
pathTo_cryptonoteUtilsDir=this_scriptDirectory+`/${coreBridge_browserBuildContainerDirName}/${coreBridge_rootContainerDirectory}/`// this works for the MyMonero browser build, and is quite general, at least
}
fullPath=pathTo_cryptonoteUtilsDir+filename
}
if(fullPath==null){
throw"Unable to derive fullPath. Please pass locateFile() to bridge obj init."
{// it's an option to move this over to fetch, but, fetch requires a polyfill for these older browsers anyway - making fetch an automatic dep just for asmjs fallback - and the github/fetch polyfill does not appear to actually support mode (for 'same-origin' policy) anyway - probably not worth it yet
// TODO: verify content - for now, relying on same-origin and tls/ssl
varModule={}
try{
eval(content)// I do not believe this is a safety concern, because content is server-controlled; https://humanwhocodes.com/blog/2013/06/25/eval-isnt-evil-just-misunderstood/
}catch(e){
reject(e)
return
}
setTimeout(function()
{// "delaying even 1ms is enough to allow compilation memory to be reclaimed"
if(lastPathComponent=="monero_utils"){// typical node or electron-main process
fullPath=path.format({
dir:this_scriptDirectory,
base:filename
})
}else{
console.warn(`MyMoneroCoreBridge/locateFile() on node.js didn't find "monero_utils" (or possibly MyMoneroCoreBridge.js) itself in the expected location in the following path. The function may need to be expanded but it might in normal situations be likely to be another bug. ${pathTo_cryptonoteUtilsDir}`)
}
}elseif(ENVIRONMENT_IS_WEB){
varpathTo_cryptonoteUtilsDir;
if(typeof__dirname!==undefined&&__dirname!=="/"){// looks like node running in browser.. (but not going to assume it's electron-renderer since that should be taken care of by monero_utils.js itself)
// but just in case it is... here's an attempt to support it
// have to check != "/" b/c webpack (I think) replaces __dirname
pathTo_cryptonoteUtilsDir="file://"+__dirname+"/"// prepending "file://" because it's going to try to stream it
}else{// actual web browser
pathTo_cryptonoteUtilsDir=this_scriptDirectory+`/mymonero_core_js/monero_utils/`// this works for the MyMonero browser build, and is quite general, at least
}
fullPath=pathTo_cryptonoteUtilsDir+filename
}
if(fullPath==null){
throw"Unable to derive fullPath. Please pass locateFile() to bridge obj init."
{// it's an option to move this over to fetch, but, fetch requires a polyfill for these older browsers anyway - making fetch an automatic dep just for asmjs fallback - and the github/fetch polyfill does not appear to actually support mode (for 'same-origin' policy) anyway - probably not worth it yet
// TODO: verify content - for now, relying on same-origin and tls/ssl
varModule={}
try{
eval(content)// I do not believe this is a safety concern, because content is server-controlled; https://humanwhocodes.com/blog/2013/06/25/eval-isnt-evil-just-misunderstood/
}catch(e){
reject(e)
return
}
setTimeout(function()
{// "delaying even 1ms is enough to allow compilation memory to be reclaimed"