/ *
THIS IS A GENERATED / BUNDLED FILE BY ESBUILD
if you want to view the source , please visit the github repository of this plugin
* /
var _ _defProp = Object . defineProperty ;
var _ _getOwnPropDesc = Object . getOwnPropertyDescriptor ;
var _ _getOwnPropNames = Object . getOwnPropertyNames ;
var _ _hasOwnProp = Object . prototype . hasOwnProperty ;
var _ _export = ( target , all ) => {
for ( var name in all )
_ _defProp ( target , name , { get : all [ name ] , enumerable : true } ) ;
} ;
var _ _copyProps = ( to , from , except , desc ) => {
if ( from && typeof from === "object" || typeof from === "function" ) {
for ( let key of _ _getOwnPropNames ( from ) )
if ( ! _ _hasOwnProp . call ( to , key ) && key !== except )
_ _defProp ( to , key , { get : ( ) => from [ key ] , enumerable : ! ( desc = _ _getOwnPropDesc ( from , key ) ) || desc . enumerable } ) ;
}
return to ;
} ;
var _ _toCommonJS = ( mod ) => _ _copyProps ( _ _defProp ( { } , "__esModule" , { value : true } ) , mod ) ;
// main.ts
var main _exports = { } ;
_ _export ( main _exports , {
DEFAULT _SETTINGS : ( ) => DEFAULT _SETTINGS ,
default : ( ) => PackratPlugin
} ) ;
module . exports = _ _toCommonJS ( main _exports ) ;
var import _obsidian = require ( "obsidian" ) ;
var DEFAULT _SETTINGS = {
deletion _trigger : "%%done_del%%" ,
bottom _trigger : "%%done_end%%" ,
archive _trigger : "%%done_log%%" ,
archive _filepath : "archive.md"
} ;
var PackratPlugin = class extends import _obsidian . Plugin {
async onload ( ) {
console . log ( "Packrat: Loading..." ) ;
await this . loadSettings ( ) ;
this . addSettingTab ( new PackratSettingTab ( this . app , this ) ) ;
this . addCommand ( {
// (to the Command Palette)
id : "run" ,
name : "Process completed recurring Tasks within the active note" ,
checkCallback : ( checking ) => {
const { workspace } = this . app ;
const activeFile = workspace . getActiveFile ( ) ;
if ( activeFile && activeFile . extension == "md" ) {
if ( checking ) {
return true ;
}
this . ProcessCompletedRecurringTasks ( activeFile ) ;
} else {
return false ;
}
}
} ) ;
}
onunload ( ) {
console . log ( "Packrat: Unloading..." ) ;
}
async loadSettings ( ) {
this . settings = Object . assign ( { } , DEFAULT _SETTINGS , await this . loadData ( ) ) ;
}
async saveSettings ( ) {
await this . saveData ( this . settings ) ;
}
async ProcessCompletedRecurringTasks ( activeFile ) {
try {
const { vault } = this . app ;
const rruleSignifier = "\u{1F501}" . normalize ( ) ;
const dv _rruleSignifier = "[repeat::" ;
const deleteTrigger = this . settings . deletion _trigger ;
const archiveTrigger = this . settings . archive _trigger ;
const bottomTrigger = this . settings . bottom _trigger ;
const archiveFilename = this . settings . archive _filepath ;
const archiveFile = vault . getAbstractFileByPath ( archiveFilename ) || await vault . create ( archiveFilename , "" ) ;
let deletedTaskCount = 0 ;
let movedTaskCount = 0 ;
let archivedTaskCount = 0 ;
let thisLine = "" ;
let writebackLines = [ ] ;
let appendLines = [ ] ;
let archiveLines = [ ] ;
let results = [ ] ;
let fileContents = await vault . read ( activeFile ) ;
fileContents = fileContents . split ( "\n" ) ;
for ( let i = 0 ; i < fileContents . length ; i ++ ) {
thisLine = fileContents [ i ] ;
let firstFive = thisLine . trim ( ) . substring ( 0 , 5 ) . toUpperCase ( ) ;
if ( firstFive === "- [X]" && ( thisLine . indexOf ( rruleSignifier ) != - 1 || thisLine . indexOf ( dv _rruleSignifier ) != - 1 ) ) {
if ( 0 < thisLine . indexOf ( deleteTrigger ) ) {
deletedTaskCount += 1 ;
continue ;
}
if ( 0 < thisLine . indexOf ( archiveTrigger ) ) {
archiveLines . push ( thisLine ) ;
archivedTaskCount += 1 ;
continue ;
}
if ( 0 < thisLine . indexOf ( bottomTrigger ) ) {
appendLines . push ( thisLine ) ;
movedTaskCount += 1 ;
continue ;
}
writebackLines . push ( thisLine ) ;
} else {
writebackLines . push ( thisLine ) ;
}
}
if ( archivedTaskCount > 0 ) {
let archiveFileContents = await vault . read ( archiveFile ) ;
archiveFileContents = archiveFileContents . split ( "\n" ) ;
archiveFileContents = archiveFileContents . concat ( archiveLines ) ;
vault . modify ( archiveFile , archiveFileContents . join ( "\n" ) ) ;
}
results = writebackLines . concat ( appendLines ) ;
vault . modify ( activeFile , results . join ( "\n" ) ) ;
var tdMsg = ` ${ deletedTaskCount } tasks deleted
` ;
var tmMsg = ` ${ movedTaskCount } tasks moved to end of note
` ;
var taMsg = ` ${ archivedTaskCount } tasks archived
` ;
const noticeText = tdMsg + tmMsg + taMsg ;
new import _obsidian . Notice ( noticeText ) ;
} catch ( err ) {
new import _obsidian . Notice ( err ) ;
console . log ( err ) ;
return ;
}
}
} ;
var PackratSettingTab = class extends import _obsidian . PluginSettingTab {
constructor ( app , plugin ) {
super ( app , plugin ) ;
this . defaultDeletionTrigger = "%%done_del%%" ;
this . defaultBottomTrigger = "%%done_move%%" ;
this . defaultArchiveTrigger = "%%done_log%%" ;
this . defaultArchiveFilepath = "logfile.md" ;
this . plugin = plugin ;
}
display ( ) {
const { containerEl } = this ;
containerEl . empty ( ) ;
containerEl . createEl ( "h2" , { text : "Packrat plugin settings" } ) ;
new import _obsidian . Setting ( containerEl ) . setName ( "Deletion trigger" ) . setDesc ( "Text to trigger deletion of completed recurring Task instance" ) . addText ( ( text ) => text . setPlaceholder ( this . defaultDeletionTrigger ) . setValue ( this . plugin . settings . deletion _trigger ) . onChange ( async ( value ) => {
console . log ( "deletion_trigger: " + value ) ;
this . plugin . settings . deletion _trigger = value ;
await this . plugin . saveSettings ( ) ;
} ) ) ;
new import _obsidian . Setting ( containerEl ) . setName ( '"Move to end of file" trigger' ) . setDesc ( "Text to trigger moving completed recurring Task instance to bottom of Active note" ) . addText ( ( text ) => text . setPlaceholder ( this . defaultbottomTrigger ) . setValue ( this . plugin . settings . bottom _trigger ) . onChange ( async ( value ) => {
console . log ( "bottom_trigger: " + value ) ;
this . plugin . settings . bottom _trigger = value ;
await this . plugin . saveSettings ( ) ;
} ) ) ;
new import _obsidian . Setting ( containerEl ) . setName ( "Archive trigger" ) . setDesc ( "Text to trigger moving completed recurring Task instance to archive note" ) . addText ( ( text ) => text . setPlaceholder ( this . defaultarchiveTrigger ) . setValue ( this . plugin . settings . archive _trigger ) . onChange ( async ( value ) => {
console . log ( "archive_trigger: " + value ) ;
this . plugin . settings . archive _trigger = value ;
await this . plugin . saveSettings ( ) ;
} ) ) ;
new import _obsidian . Setting ( containerEl ) . setName ( "Archive file" ) . setDesc ( 'Relative filepath to archive file (include ".md" extension)' ) . addText ( ( text ) => text . setPlaceholder ( this . defaultArchiveFilepath ) . setValue ( this . plugin . settings . archive _filepath ) . onChange ( async ( value ) => {
console . log ( "archive_filepath: " + value ) ;
this . plugin . settings . archive _filepath = value ;
await this . plugin . saveSettings ( ) ;
} ) ) ;
}
} ;
//# sourceMappingURL=data:application/json;base64,ewogICJ2ZXJzaW9uIjogMywKICAic291cmNlcyI6IFsibWFpbi50cyJdLAogICJzb3VyY2VzQ29udGVudCI6IFsiaW1wb3J0IHsgQXBwLCBOb3RpY2UsIFBsdWdpbiwgUGx1Z2luU2V0dGluZ1RhYiwgU2V0dGluZywgVEZpbGUgfSBmcm9tICdvYnNpZGlhbic7XHJcblxyXG5leHBvcnQgaW50ZXJmYWNlIFBhY2tyYXRTZXR0aW5ncyB7XHJcblx0ZGVsZXRpb25fdHJpZ2dlcjogc3RyaW5nO1xyXG5cdGJvdHRvbV90cmlnZ2VyOiBzdHJpbmc7XHJcblx0YXJjaGl2ZV90cmlnZ2VyOiBzdHJpbmc7XHJcblx0YXJjaGl2ZV9maWxlcGF0aDogc3RyaW5nO1xyXG59XHJcblxyXG5leHBvcnQgY29uc3QgREVGQVVMVF9TRVRUSU5HUzogUGFja3JhdFNldHRpbmdzID0ge1xyXG5cdGRlbGV0aW9uX3RyaWdnZXI6ICclJWRvbmVfZGVsJSUnLFxyXG5cdGJvdHRvbV90cmlnZ2VyOiAnJSVkb25lX2VuZCUlJyxcclxuXHRhcmNoaXZlX3RyaWdnZXI6ICclJWRvbmVfbG9nJSUnLFxyXG5cdGFyY2hpdmVfZmlsZXBhdGg6ICdhcmNoaXZlLm1kJyxcclxufVxyXG5cclxuZX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