Skip to content
This repository has been archived by the owner on Jan 13, 2024. It is now read-only.

Commit

Permalink
Update bootstrap, fix AliuFS.mkdir logic
Browse files Browse the repository at this point in the history
Co-authored-by: TymanWasTaken <[email protected]>
  • Loading branch information
js6pak and TymanWasTaken committed Jul 10, 2022
1 parent ab7d3a4 commit 5415412
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion API/hermes/hermes.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1446,7 +1446,7 @@ jsi::Value HermesRuntimeImpl::evaluateJavaScript(
::hermes::hermesLog("AliuHermes", "Injecting bootstrap");
evaluateJavaScript(
// TODO move bootstrap to this repo and call it with cmake?
std::make_unique<jsi::StringBuffer>(std::string("(()=>{function asyncGeneratorStep(gen,resolve,reject,_next,_throw,key,arg){try{var info=gen[key](arg);var value=info.value;}catch(error){reject(error);return}if(info.done){resolve(value);}else {Promise.resolve(value).then(_next,_throw);}}function _asyncToGenerator(fn){return function(){var self=this,args=arguments;return new Promise(function(resolve,reject){var gen=fn.apply(self,args);function _next(value){asyncGeneratorStep(gen,resolve,reject,_next,_throw,'next',value);}function _throw(err){asyncGeneratorStep(gen,resolve,reject,_next,_throw,'throw',err);}_next(undefined);})}}_asyncToGenerator(function*(){var{externalStorageDirectory,requestPermissions,download,checkPermissions}=nativeModuleProxy.AliucordNative;function downloadAliucord(){return _downloadAliucord.apply(this,arguments)}function _downloadAliucord(){_downloadAliucord=_asyncToGenerator(function*(){var bundlePath=externalStorageDirectory+'/AliucordRN/Aliucord.js.bundle';if(!AliuFS.exists(bundlePath)){try{yield download('https://raw.githubusercontent.com/Aliucord/AliucordRN/builds/Aliucord.js.bundle',bundlePath);}catch(error){alert('Failed to download Aliucord.js.bundle');throw error}}(globalThis._globals\?\?={}).aliucord=AliuHermes.run(bundlePath);});return _downloadAliucord.apply(this,arguments)}try{var granted=yield checkPermissions();var constants=nativeModuleProxy.DialogManagerAndroid.getConstants();if(!granted){var dialogResult=yield new Promise((res,rej)=>{nativeModuleProxy.DialogManagerAndroid.showAlert({title:'Storage Permissions',message:'Aliucord needs access to your storage to load plugins and themes.',cancelable:true,buttonPositive:'Ok',buttonNegative:'Cancel'},rej,(action,key)=>{if(action===constants.buttonClicked&&key===constants.buttonPositive)res(true);else res(false);});});if(!(dialogResult&&(yield requestPermissions()))){nativeModuleProxy.DialogManagerAndroid.showAlert({title:'Storage Permissions',message:'Access to your storage is required for aliucord to load.',cancelable:false},()=>{},()=>{});return}}yield downloadAliucord();}catch(error){nativeModuleProxy.DialogManagerAndroid.showAlert({title:'Error',message:'Something went wrong while loading aliucord, check logs for the specific error.',cancelable:false},()=>{},()=>{});console.error(error.stack);}})();})();")),
std::make_unique<jsi::StringBuffer>(std::string("(()=>{function asyncGeneratorStep(gen,resolve,reject,_next,_throw,key,arg){try{var info=gen[key](arg);var value=info.value;}catch(error){reject(error);return}if(info.done){resolve(value);}else {Promise.resolve(value).then(_next,_throw);}}function _asyncToGenerator(fn){return function(){var self=this,args=arguments;return new Promise(function(resolve,reject){var gen=fn.apply(self,args);function _next(value){asyncGeneratorStep(gen,resolve,reject,_next,_throw,'next',value);}function _throw(err){asyncGeneratorStep(gen,resolve,reject,_next,_throw,'throw',err);}_next(undefined);})}}_asyncToGenerator(function*(){var{externalStorageDirectory,requestPermissions,download,checkPermissions}=nativeModuleProxy.AliucordNative;try{var granted=yield checkPermissions();var constants=nativeModuleProxy.DialogManagerAndroid.getConstants();if(!granted){var dialogResult=yield new Promise((res,rej)=>{nativeModuleProxy.DialogManagerAndroid.showAlert({title:'Storage Permissions',message:'Aliucord needs access to your storage to load plugins and themes.',cancelable:true,buttonPositive:'Ok',buttonNegative:'Cancel'},rej,(action,key)=>{if(action===constants.buttonClicked&&key===constants.buttonPositive)res(true);else res(false);});});if(!(dialogResult&&(yield requestPermissions()))){nativeModuleProxy.DialogManagerAndroid.showAlert({title:'Storage Permissions',message:'Access to your storage is required for aliucord to load.',cancelable:true,buttonPositive:'Ok'},()=>null,()=>null);return}}var aliucordDir=externalStorageDirectory+'/AliucordRN';AliuFS.mkdir(aliucordDir);var bundlePath=aliucordDir+'/Aliucord.js.bundle';if(!AliuFS.exists(bundlePath))yield download('https://raw.githubusercontent.com/Aliucord/AliucordRN/builds/Aliucord.js.bundle',bundlePath);(globalThis._globals\?\?={}).aliucord=AliuHermes.run(bundlePath);}catch(error){nativeModuleProxy.DialogManagerAndroid.showAlert({title:'Error',message:'Something went wrong while loading aliucord, check logs for the specific error.',cancelable:true,buttonPositive:'Ok'},()=>null,()=>null);console.error(error.stack);}})();})();")),
"bootstrap"
);
}
Expand Down
2 changes: 1 addition & 1 deletion lib/VM/JSLib/AliuFS.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ CallResult<HermesValue> aliuFSmkdir(void *, Runtime *runtime, NativeArgs args) {

::hermes::hermesLog("AliuHermes", "AliuFS.mkdir %s", path.c_str());

if (!mkdir(path.c_str(), S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH)) {
if (mkdir(path.c_str(), S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH) != 0) {
if (errno != EEXIST)
return runtime->raiseError(strerror(errno));
}
Expand Down

0 comments on commit 5415412

Please sign in to comment.