@ -21,6 +21,26 @@ var __reExport = (target, module2, desc) => {
var _ _toModule = ( module2 ) => {
return _ _reExport ( _ _markAsModule ( _ _defProp ( module2 != null ? _ _create ( _ _getProtoOf ( module2 ) ) : { } , "default" , module2 && module2 . _ _esModule && "default" in module2 ? { get : ( ) => module2 . default , enumerable : true } : { value : module2 , enumerable : true } ) ) , module2 ) ;
} ;
var _ _async = ( _ _this , _ _arguments , generator ) => {
return new Promise ( ( resolve , reject ) => {
var fulfilled = ( value ) => {
try {
step ( generator . next ( value ) ) ;
} catch ( e ) {
reject ( e ) ;
}
} ;
var rejected = ( value ) => {
try {
step ( generator . throw ( value ) ) ;
} catch ( e ) {
reject ( e ) ;
}
} ;
var step = ( x ) => x . done ? resolve ( x . value ) : Promise . resolve ( x . value ) . then ( fulfilled , rejected ) ;
step ( ( generator = generator . apply ( _ _this , _ _arguments ) ) . next ( ) ) ;
} ) ;
} ;
// src/main.ts
_ _export ( exports , {
@ -41,10 +61,10 @@ var SettingsTab = class extends import_obsidian.PluginSettingTab {
containerEl . createEl ( "h2" , { text : this . plugin . appName } ) ;
new import _obsidian . Setting ( containerEl ) . setName ( "Auto-update at startup" ) . setDesc ( "If enabled all beta plugins will be checked for updates each time Obsidian starts." ) . addToggle ( ( cb ) => {
cb . setValue ( this . plugin . settings . updateAtStartup ) ;
cb . onChange ( async ( value ) => {
cb . onChange ( ( value ) => _ _async ( this , null , function * ( ) {
this . plugin . settings . updateAtStartup = value ;
await this . plugin . saveSettings ( ) ;
} ) ;
yield this . plugin . saveSettings ( ) ;
} ) ) ;
} ) ;
containerEl . createEl ( "hr" ) ;
containerEl . createEl ( "h2" , { text : "Beta Plugin List" } ) ;
@ -56,23 +76,23 @@ var SettingsTab = class extends import_obsidian.PluginSettingTab {
containerEl . createSpan ( { text : "This does not delete the plugin, this should be done from the Community Plugins tab in Settings." } ) ;
new import _obsidian . Setting ( containerEl ) . addButton ( ( cb ) => {
cb . setButtonText ( "Add Beta plugin" ) ;
cb . onClick ( async ( ) => {
cb . onClick ( ( ) => _ _async ( this , null , function * ( ) {
this . plugin . app . setting . close ( ) ;
await this . plugin . betaPlugins . displayAddNewPluginModal ( true ) ;
} ) ;
yield this . plugin . betaPlugins . displayAddNewPluginModal ( true ) ;
} ) ) ;
} ) ;
for ( const bp of this . plugin . settings . pluginList ) {
new import _obsidian . Setting ( containerEl ) . setName ( bp ) . addButton ( ( btn ) => {
btn . setIcon ( "cross" ) ;
btn . setTooltip ( "Delete this beta plugin" ) ;
btn . onClick ( async ( ) => {
btn . onClick ( ( ) => _ _async ( this , null , function * ( ) {
if ( btn . buttonEl . textContent === "" )
btn . setButtonText ( "Click once more to confirm removal" ) ;
else {
btn . buttonEl . parentElement . parentElement . remove ( ) ;
await this . plugin . betaPlugins . deletePlugin ( bp ) ;
yield this . plugin . betaPlugins . deletePlugin ( bp ) ;
}
} ) ;
} ) ) ;
} ) ;
}
}
@ -83,14 +103,18 @@ var DEFAULT_SETTINGS = {
pluginList : [ ] ,
updateAtStartup : false
} ;
async function addBetaPluginToList ( plugin , repositoryPath ) {
function addBetaPluginToList ( plugin , repositoryPath ) {
return _ _async ( this , null , function * ( ) {
if ( ! plugin . settings . pluginList . contains ( repositoryPath ) ) {
plugin . settings . pluginList . unshift ( repositoryPath ) ;
plugin . saveSettings ( ) ;
}
} ) ;
}
async function existBetaPluginInList ( plugin , repositoryPath ) {
function existBetaPluginInList ( plugin , repositoryPath ) {
return _ _async ( this , null , function * ( ) {
return plugin . settings . pluginList . contains ( repositoryPath ) ;
} ) ;
}
// src/AddNewPluginModal.ts
@ -103,19 +127,21 @@ var AddNewPluginModal = class extends import_obsidian2.Modal {
this . address = "" ;
this . openSettingsTabAfterwards = openSettingsTabAfterwards ;
}
async submitForm ( ) {
submitForm ( ) {
return _ _async ( this , null , function * ( ) {
if ( this . address === "" )
return ;
const scrubbedAddress = this . address . replace ( "https://github.com/" , "" ) ;
if ( await existBetaPluginInList ( this . plugin , scrubbedAddress ) ) {
if ( yield existBetaPluginInList ( this . plugin , scrubbedAddress ) ) {
new import _obsidian2 . Notice ( ` BRAT
This plugin is already in the list for beta testing ` , 1e4);
return ;
}
const result = await this . betaPlugins . addPlugin ( scrubbedAddress ) ;
const result = yield this . betaPlugins . addPlugin ( scrubbedAddress ) ;
if ( result ) {
this . close ( ) ;
}
} ) ;
}
onOpen ( ) {
this . contentEl . createEl ( "h4" , { text : "Github repository for beta plugin:" } ) ;
@ -125,12 +151,12 @@ This plugin is already in the list for beta testing`, 1e4);
textEl . onChange ( ( value ) => {
this . address = value . trim ( ) ;
} ) ;
textEl . inputEl . addEventListener ( "keydown" , async ( e ) => {
textEl . inputEl . addEventListener ( "keydown" , ( e ) => _ _async ( this , null , function * ( ) {
if ( e . key === "Enter" && this . address !== " " ) {
e . preventDefault ( ) ;
await this . submitForm ( ) ;
yield this . submitForm ( ) ;
}
} ) ;
} ) ) ;
textEl . inputEl . style . width = "100%" ;
window . setTimeout ( ( ) => {
const title = document . querySelector ( ".setting-item-info" ) ;
@ -147,51 +173,53 @@ This plugin is already in the list for beta testing`, 1e4);
text : "Add Plugin"
} ) ;
} ) ;
formEl . addEventListener ( "submit" , async ( e ) => {
formEl . addEventListener ( "submit" , ( e ) => _ _async ( this , null , function * ( ) {
e . preventDefault ( ) ;
if ( this . address !== "" )
await this . submitForm ( ) ;
} ) ;
yield this . submitForm ( ) ;
} ) ) ;
} ) ;
}
async onClose ( ) {
onClose ( ) {
return _ _async ( this , null , function * ( ) {
if ( this . openSettingsTabAfterwards ) {
await this . plugin . app . setting . open ( ) ;
await this . plugin . app . setting . openTabById ( "obsidian42-brat" ) ;
yield this . plugin . app . setting . open ( ) ;
yield this . plugin . app . setting . openTabById ( "obsidian42-brat" ) ;
}
} ) ;
}
} ;
// src/githubUtils.ts
var import _obsidian3 = _ _toModule ( require ( "obsidian" ) ) ;
var GITHUB _RAW _USERCONTENT _PATH = "https://raw.githubusercontent.com/" ;
var grabReleaseFileFromRepository = async ( repository , version , fileName ) => {
var grabReleaseFileFromRepository = ( repository , version , fileName ) => _ _async ( void 0 , null , function * ( ) {
const URL = ` https://github.com/ ${ repository } /releases/download/ ${ version } / ${ fileName } ` ;
try {
const download = await ( 0 , import _obsidian3 . request ) ( { url : URL } ) ;
const download = yield ( 0 , import _obsidian3 . request ) ( { url : URL } ) ;
return download === "Not Found" || download === ` {"error":"Not Found"} ` ? null : download ;
} catch ( error ) {
console . log ( "error in grabReleaseFileFromRepository" , URL , error ) ;
}
} ;
var grabManifestJsonFromRepository = async ( repositoryPath , rootManifest = true ) => {
} ) ;
var grabManifestJsonFromRepository = ( repositoryPath , rootManifest = true ) => _ _async ( void 0 , null , function * ( ) {
const manifestJsonPath = GITHUB _RAW _USERCONTENT _PATH + repositoryPath + ( rootManifest === true ? "/HEAD/manifest.json" : "/HEAD/manifest-beta.json" ) ;
try {
const response = await ( 0 , import _obsidian3 . request ) ( { url : manifestJsonPath } ) ;
return response === "404: Not Found" ? null : await JSON . parse ( response ) ;
const response = yield ( 0 , import _obsidian3 . request ) ( { url : manifestJsonPath } ) ;
return response === "404: Not Found" ? null : yield JSON . parse ( response ) ;
} catch ( error ) {
console . log ( "error in grabManifestJsonFromRepository" , error ) ;
console . log ( ` error in grabManifestJsonFromRepository for ${ manifestJsonPath } ` , error ) ;
}
} ;
var grabCommmunityPluginList = async ( ) => {
} ) ;
var grabCommmunityPluginList = ( ) => _ _async ( void 0 , null , function * ( ) {
const pluginListURL = ` https://raw.githubusercontent.com/obsidianmd/obsidian-releases/HEAD/community-plugins.json ` ;
try {
const response = await ( 0 , import _obsidian3 . request ) ( { url : pluginListURL } ) ;
return response === "404: Not Found" ? null : await JSON . parse ( response ) ;
const response = yield ( 0 , import _obsidian3 . request ) ( { url : pluginListURL } ) ;
return response === "404: Not Found" ? null : yield JSON . parse ( response ) ;
} catch ( error ) {
console . log ( "error in grabCommmunityPluginList" , error ) ;
}
} ;
} ) ;
// src/BetaPlugins.ts
var import _obsidian4 = _ _toModule ( require ( "obsidian" ) ) ;
@ -199,13 +227,16 @@ var BetaPlugins = class {
constructor ( plugin ) {
this . plugin = plugin ;
}
async displayAddNewPluginModal ( openSettingsTabAfterwards = false ) {
displayAddNewPluginModal ( openSettingsTabAfterwards = false ) {
return _ _async ( this , null , function * ( ) {
const newPlugin = new AddNewPluginModal ( this . plugin , this , openSettingsTabAfterwards ) ;
newPlugin . open ( ) ;
} ) ;
}
async validateRepository ( repositoryPath , getBetaManifest = false , reportIsues = false ) {
const noticeTimeout = 1e4 ;
const manifestJson = await grabManifestJsonFromRepository ( repositoryPath , ! getBetaManifest ) ;
validateRepository ( repositoryPath , getBetaManifest = false , reportIsues = false ) {
return _ _async ( this , null , function * ( ) {
const noticeTimeout = 15e3 ;
const manifestJson = yield grabManifestJsonFromRepository ( repositoryPath , ! getBetaManifest ) ;
if ( ! manifestJson ) {
if ( reportIsues )
new import _obsidian4 . Notice ( ` BRAT
@ -228,31 +259,38 @@ The version attribute for the release is missing from the manifest file`, notice
return null ;
}
return manifestJson ;
} ) ;
}
async getAllReleaseFiles ( repositoryPath , manifest , getManifest ) {
getAllReleaseFiles ( repositoryPath , manifest , getManifest ) {
return _ _async ( this , null , function * ( ) {
return {
mainJs : await grabReleaseFileFromRepository ( repositoryPath , manifest . version , "main.js" ) ,
manifest : getManifest ? await grabReleaseFileFromRepository ( repositoryPath , manifest . version , "manifest.json" ) : null ,
styles : await grabReleaseFileFromRepository ( repositoryPath , manifest . version , "styles.css" )
mainJs : yield grabReleaseFileFromRepository ( repositoryPath , manifest . version , "main.js" ) ,
manifest : getManifest ? yield grabReleaseFileFromRepository ( repositoryPath , manifest . version , "manifest.json" ) : null ,
styles : yield grabReleaseFileFromRepository ( repositoryPath , manifest . version , "styles.css" )
} ;
} ) ;
}
async writeReleaseFilesToPluginFolder ( betaPluginID , relFiles ) {
writeReleaseFilesToPluginFolder ( betaPluginID , relFiles ) {
return _ _async ( this , null , function * ( ) {
const pluginTargetFolderPath = ( 0 , import _obsidian4 . normalizePath ) ( this . plugin . app . vault . configDir + "/plugins/" + betaPluginID ) + "/" ;
const adapter = this . plugin . app . vault . adapter ;
if ( await adapter . exists ( pluginTargetFolderPath ) === false || ! await adapter . exists ( pluginTargetFolderPath + "manifest.json" ) ) {
await adapter . mkdir ( pluginTargetFolderPath ) ;
if ( ( yield adapter . exists ( pluginTargetFolderPath ) ) === false || ! ( yield adapter . exists ( pluginTargetFolderPath + "manifest.json" ) ) ) {
yield adapter . mkdir ( pluginTargetFolderPath ) ;
}
await adapter . write ( pluginTargetFolderPath + "main.js" , relFiles . mainJs ) ;
await adapter . write ( pluginTargetFolderPath + "manifest.json" , relFiles . manifest ) ;
yield adapter . write ( pluginTargetFolderPath + "main.js" , relFiles . mainJs ) ;
yield adapter . write ( pluginTargetFolderPath + "manifest.json" , relFiles . manifest ) ;
if ( relFiles . styles )
await adapter . write ( pluginTargetFolderPath + "styles.css" , relFiles . styles ) ;
yield adapter . write ( pluginTargetFolderPath + "styles.css" , relFiles . styles ) ;
} ) ;
}
async addPlugin ( repositoryPath , updatePluginFiles = false , seeIfUpdatedOnly = false , reportIfNotUpdted = false ) {
addPlugin ( repositoryPath , updatePluginFiles = false , seeIfUpdatedOnly = false , reportIfNotUpdted = false ) {
return _ _async ( this , null , function * ( ) {
var _a ;
const noticeTimeout = 1e4 ;
let primaryManifest = await this . validateRepository ( repositoryPath , true , false ) ;
let primaryManifest = yield this . validateRepository ( repositoryPath , true , false ) ;
const usingBetaManifest = primaryManifest ? true : false ;
if ( usingBetaManifest === false )
primaryManifest = await this . validateRepository ( repositoryPath , false , true ) ;
primaryManifest = yield this . validateRepository ( repositoryPath , false , true ) ;
if ( primaryManifest === null ) {
new import _obsidian4 . Notice ( ` BRAT
$ { repositoryPath }
@ -265,8 +303,8 @@ ${repositoryPath}
The manifest$ { usingBetaManifest ? "-beta" : "" } . json file in the root directory of the repository does not have a version number in the file . This plugin cannot be installed . ` , noticeTimeout);
return false ;
}
const getRelease = async ( ) => {
const rFiles = await this . getAllReleaseFiles ( repositoryPath , primaryManifest , usingBetaManifest ) ;
const getRelease = ( ) => _ _async ( this , null , function * ( ) {
const rFiles = yield this . getAllReleaseFiles ( repositoryPath , primaryManifest , usingBetaManifest ) ;
if ( usingBetaManifest || rFiles . manifest === null )
rFiles . manifest = JSON . stringify ( primaryManifest ) ;
if ( rFiles . mainJs === null ) {
@ -276,14 +314,14 @@ The release is not complete and cannot be download. main.js is missing from the
return null ;
}
return rFiles ;
} ;
} ) ;
if ( updatePluginFiles === false ) {
const releaseFiles = await getRelease ( ) ;
const releaseFiles = yield getRelease ( ) ;
if ( releaseFiles === null )
return ;
await this . writeReleaseFilesToPluginFolder ( primaryManifest . id , releaseFiles ) ;
await addBetaPluginToList ( this . plugin , repositoryPath ) ;
await this . plugin . app . plugins . loadManifests ( ) ;
yield this . writeReleaseFilesToPluginFolder ( primaryManifest . id , releaseFiles ) ;
yield addBetaPluginToList ( this . plugin , repositoryPath ) ;
yield this . plugin . app . plugins . loadManifests ( ) ;
new import _obsidian4 . Notice ( ` BRAT
$ { repositoryPath }
The plugin has been registered with BRAT . You may still need to enable it the Community Plugin List . ` , noticeTimeout);
@ -291,68 +329,84 @@ The plugin has been registered with BRAT. You may still need to enable it the Co
const pluginTargetFolderPath = this . plugin . app . vault . configDir + "/plugins/" + primaryManifest . id + "/" ;
let localManifestContents = null ;
try {
localManifestContents = await this . plugin . app . vault . adapter . read ( pluginTargetFolderPath + "manifest.json" ) ;
localManifestContents = yield this . plugin . app . vault . adapter . read ( pluginTargetFolderPath + "manifest.json" ) ;
} catch ( e ) {
if ( e . errno === - 4058 ) {
await this . addPlugin ( repositoryPath , false , usingBetaManifest ) ;
yield this . addPlugin ( repositoryPath , false , usingBetaManifest ) ;
return true ;
} else
console . log ( "BRAT - Local Manifest Load" , primaryManifest . id , JSON . stringify ( e , null , 2 ) ) ;
}
const localManifestJSON = await JSON . parse ( localManifestContents ) ;
const localManifestJSON = yield JSON . parse ( localManifestContents ) ;
if ( localManifestJSON . version !== primaryManifest . version ) {
const releaseFiles = await getRelease ( ) ;
const releaseFiles = yield getRelease ( ) ;
if ( releaseFiles === null )
return ;
if ( seeIfUpdatedOnly ) {
new import _obsidian4 . Notice ( ` BRAT
There is an update available for $ { primaryManifest . id } ` );
There is an update available for $ { primaryManifest . id } from version $ { localManifestJSON . version } to $ { primaryManifest . version } ` , 3e4 );
} else {
await this . writeReleaseFilesToPluginFolder ( primaryManifest . id , releaseFiles ) ;
await this . plugin . app . plugins . loadManifests ( ) ;
if ( this . plugin . app . plugins . plugins [ primaryManifest . id ] ? . manifest )
await this . reloadPlugin ( primaryManifest . id ) ;
yield this . writeReleaseFilesToPluginFolder ( primaryManifest . id , releaseFiles ) ;
yield this . plugin . app . plugins . loadManifests ( ) ;
if ( ( _a = this . plugin . app . plugins . plugins [ primaryManifest . id ] ) == null ? void 0 : _a . manifest )
yield this . reloadPlugin ( primaryManifest . id ) ;
new import _obsidian4 . Notice ( ` BRAT
$ { primaryManifest . id }
Plugin has been updated . ` , noticeTimeout );
Plugin has been updated from version $ { localManifestJSON . version } to $ { primaryManifest . version } . ` , 3e4 );
}
} else if ( reportIfNotUpdted )
new import _obsidian4 . Notice ( ` BRAT
No update available for $ { repositoryPath } ` , 3e3);
}
return true ;
} ) ;
}
async reloadPlugin ( pluginName ) {
reloadPlugin ( pluginName ) {
return _ _async ( this , null , function * ( ) {
const plugins = this . plugin . app . plugins ;
try {
await plugins . disablePlugin ( pluginName ) ;
await plugins . enablePlugin ( pluginName ) ;
yield plugins . disablePlugin ( pluginName ) ;
yield plugins . enablePlugin ( pluginName ) ;
} catch ( e ) {
console . log ( "reload plugin" , e ) ;
}
} ) ;
}
async updatePlugin ( repositoryPath , onlyCheckDontUpdate = false , reportIfNotUpdted = false ) {
const result = await this . addPlugin ( repositoryPath , true , onlyCheckDontUpdate , reportIfNotUpdted ) ;
updatePlugin ( repositoryPath , onlyCheckDontUpdate = false , reportIfNotUpdted = false ) {
return _ _async ( this , null , function * ( ) {
const result = yield this . addPlugin ( repositoryPath , true , onlyCheckDontUpdate , reportIfNotUpdted ) ;
if ( result === false && onlyCheckDontUpdate === false )
new import _obsidian4 . Notice ( ` BRAT
$ { repositoryPath }
Update of plugin failed . ` );
return result ;
} ) ;
}
async checkForUpdatesAndInstallUpdates ( showInfo = false , onlyCheckDontUpdate = false ) {
checkForUpdatesAndInstallUpdates ( showInfo = false , onlyCheckDontUpdate = false ) {
return _ _async ( this , null , function * ( ) {
if ( showInfo )
new import _obsidian4 . Notice ( ` BRAT
Checking for plugin updates STARTED ` , 1e4);
for ( const bp of this . plugin . settings . pluginList ) {
await this . updatePlugin ( bp , onlyCheckDontUpdate ) ;
yield this . updatePlugin ( bp , onlyCheckDontUpdate ) ;
}
if ( showInfo )
new import _obsidian4 . Notice ( ` BRAT
Checking for plugin updates COMPLETED ` , 1e4);
} ) ;
}
async deletePlugin ( repositoryPath ) {
deletePlugin ( repositoryPath ) {
return _ _async ( this , null , function * ( ) {
this . plugin . settings . pluginList = this . plugin . settings . pluginList . filter ( ( b ) => b != repositoryPath ) ;
this . plugin . saveSettings ( ) ;
} ) ;
}
getEnabledDisabledPlugins ( enabled ) {
const pl = this . plugin . app . plugins ;
const manifests = Object . values ( pl . manifests ) ;
const enabledPlugins = Object . values ( pl . plugins ) . map ( ( p ) => p . manifest ) ;
console . log ( enabledPlugins ) ;
return enabled ? manifests . filter ( ( manifest ) => enabledPlugins . find ( ( pluginName ) => manifest . id === pluginName . id ) ) : manifests . filter ( ( manifest ) => ! enabledPlugins . find ( ( pluginName ) => manifest . id === pluginName . id ) ) ;
}
} ;
@ -367,9 +421,11 @@ var GenericFuzzySuggester = class extends import_obsidian5.FuzzySuggestModal {
setSuggesterData ( suggesterData ) {
this . data = suggesterData ;
}
async display ( callBack ) {
display ( callBack ) {
return _ _async ( this , null , function * ( ) {
this . callbackFunction = callBack ;
this . open ( ) ;
} ) ;
}
getItems ( ) {
return this . data ;
@ -406,69 +462,70 @@ var ThePlugin = class extends import_obsidian6.Plugin {
this . appName = "Obsidian42 - Beta Reviewer's Auto-update Tool (BRAT)" ;
this . appID = "obsidian42-brat" ;
}
async onload ( ) {
onload ( ) {
return _ _async ( this , null , function * ( ) {
console . log ( "loading Obsidian42 - BRAT" ) ;
await this . loadSettings ( ) ;
yield this . loadSettings ( ) ;
this . addSettingTab ( new SettingsTab ( this . app , this ) ) ;
this . betaPlugins = new BetaPlugins ( this ) ;
this . addCommand ( {
id : "BRAT-AddBetaPlugin" ,
name : "Add a beta plugin for testing" ,
callback : async ( ) => {
await this . betaPlugins . displayAddNewPluginModal ( ) ;
}
callback : ( ) => _ _async ( this , null , function * ( ) {
yield this . betaPlugins . displayAddNewPluginModal ( ) ;
} )
} ) ;
this . addCommand ( {
id : "BRAT-checkForUpdatesAndUpdate" ,
name : "Check for updates to all beta plugins and UPDATE" ,
callback : async ( ) => {
await this . betaPlugins . checkForUpdatesAndInstallUpdates ( true , false ) ;
}
callback : ( ) => _ _async ( this , null , function * ( ) {
yield this . betaPlugins . checkForUpdatesAndInstallUpdates ( true , false ) ;
} )
} ) ;
this . addCommand ( {
id : "BRAT-checkForUpdatesAndDontUpdate" ,
name : "Only check for updates to beta plugins, but don't Update" ,
callback : async ( ) => {
await this . betaPlugins . checkForUpdatesAndInstallUpdates ( true , true ) ;
}
callback : ( ) => _ _async ( this , null , function * ( ) {
yield this . betaPlugins . checkForUpdatesAndInstallUpdates ( true , true ) ;
} )
} ) ;
this . addCommand ( {
id : "BRAT-updateOnePlugin" ,
name : "Choose a single plugin to update" ,
callback : async ( ) => {
callback : ( ) => _ _async ( this , null , function * ( ) {
const pluginList = Object . values ( this . settings . pluginList ) . map ( ( m ) => {
return { display : m , info : m } ;
} ) ;
const gfs = new GenericFuzzySuggester ( this ) ;
gfs . setSuggesterData ( pluginList ) ;
await gfs . display ( async ( results ) => {
yield gfs . display ( ( results ) => _ _async ( this , null , function * ( ) {
new import _obsidian6 . Notice ( ` BRAT
Checking for updates for $ { results . info } ` , 3e3);
await this . betaPlugins . updatePlugin ( results . info , false , true ) ;
} ) ;
}
yield this . betaPlugins . updatePlugin ( results . info , false , true ) ;
} ) ) ;
} )
} ) ;
this . addCommand ( {
id : "BRAT-restartPlugin" ,
name : "Restart a plugin that is already installed" ,
callback : async ( ) => {
callback : ( ) => _ _async ( this , null , function * ( ) {
const pluginList = Object . values ( this . app . plugins . manifests ) . map ( ( m ) => {
return { display : m . id , info : m . id } ;
} ) ;
const gfs = new GenericFuzzySuggester ( this ) ;
gfs . setSuggesterData ( pluginList ) ;
await gfs . display ( async ( results ) => {
yield gfs . display ( ( results ) => _ _async ( this , null , function * ( ) {
new import _obsidian6 . Notice ( ` ${ results . info }
Plugin reloading ... . . ` , 5e3);
await this . betaPlugins . reloadPlugin ( results . info ) ;
} ) ;
}
yield this . betaPlugins . reloadPlugin ( results . info ) ;
} ) ) ;
} )
} ) ;
this . addCommand ( {
id : "BRAT-openGitHubRepository" ,
name : "Open the GitHub repository for a plugin" ,
callback : async ( ) => {
const communityPlugins = await grabCommmunityPluginList ( ) ;
callback : ( ) => _ _async ( this , null , function * ( ) {
const communityPlugins = yield grabCommmunityPluginList ( ) ;
const communityPluginList = Object . values ( communityPlugins ) . map ( ( p ) => {
return { display : ` Community: ${ p . name } ( ${ p . repo } ) ` , info : p . repo } ;
} ) ;
@ -478,26 +535,59 @@ Plugin reloading .....`, 5e3);
communityPluginList . forEach ( ( si ) => bratList . push ( si ) ) ;
const gfs = new GenericFuzzySuggester ( this ) ;
gfs . setSuggesterData ( bratList ) ;
await gfs . display ( async ( results ) => {
yield gfs . display ( ( results ) => _ _async ( this , null , function * ( ) {
if ( results . info )
window . open ( ` https://github.com/ ${ results . info } ` ) ;
} ) ) ;
} )
} ) ;
}
this . addCommand ( {
id : "BRAT-disablePlugin" ,
name : "Disable a plugin - toggle it off" ,
callback : ( ) => _ _async ( this , null , function * ( ) {
const pluginList = this . betaPlugins . getEnabledDisabledPlugins ( true ) . map ( ( manifest ) => {
return { display : ` ${ manifest . name } ( ${ manifest . id } ) ` , info : manifest . id } ;
} ) ;
const gfs = new GenericFuzzySuggester ( this ) ;
gfs . setSuggesterData ( pluginList ) ;
yield gfs . display ( ( results ) => _ _async ( this , null , function * ( ) {
yield this . app . plugins . disablePlugin ( results . info ) ;
} ) ) ;
} )
} ) ;
this . addCommand ( {
id : "BRAT-enablePlugin" ,
name : "Enable a plugin - toggle it on" ,
callback : ( ) => _ _async ( this , null , function * ( ) {
const pluginList = this . betaPlugins . getEnabledDisabledPlugins ( false ) . map ( ( manifest ) => {
return { display : ` ${ manifest . name } ( ${ manifest . id } ) ` , info : manifest . id } ;
} ) ;
const gfs = new GenericFuzzySuggester ( this ) ;
gfs . setSuggesterData ( pluginList ) ;
yield gfs . display ( ( results ) => _ _async ( this , null , function * ( ) {
yield this . app . plugins . enablePlugin ( results . info ) ;
} ) ) ;
} )
} ) ;
this . app . workspace . onLayoutReady ( ( ) => {
if ( this . settings . updateAtStartup )
setTimeout ( async ( ) => {
await this . betaPlugins . checkForUpdatesAndInstallUpdates ( false ) ;
} , 6e4 ) ;
setTimeout ( ( ) => _ _async ( this , null , function * ( ) {
yield this . betaPlugins . checkForUpdatesAndInstallUpdates ( false ) ;
} ) , 6e4 ) ;
} ) ;
} ) ;
}
onunload ( ) {
console . log ( "unloading " + this . appName ) ;
}
async loadSettings ( ) {
this . settings = Object . assign ( { } , DEFAULT _SETTINGS , await this . loadData ( ) ) ;
loadSettings ( ) {
return _ _async ( this , null , function * ( ) {
this . settings = Object . assign ( { } , DEFAULT _SETTINGS , yield this . loadData ( ) ) ;
} ) ;
}
async saveSettings ( ) {
await this . saveData ( this . settings ) ;
saveSettings ( ) {
return _ _async ( this , null , function * ( ) {
yield this . saveData ( this . settings ) ;
} ) ;
}
} ;