Vault
API reference uses a reviewed source snapshot. Source links open the published source; unverified line locations are omitted.
Defined in: storage/vault.svelte.ts:65
High-level file-system facade for the active vault.
Vault wraps a DataAdapter, maintains the in-memory file tree used by
the workspace, and emits Obsidian-style file lifecycle events.
Extends
Section titled “Extends”EventDispatcher<{all: [event:string,file:TAbstractFile,context:Record<string,unknown>];create: [file:TAbstractFile];delete: [file:TAbstractFile];load: [];modify: [file:TAbstractFile];rename: [file:TAbstractFile,oldPath:string]; }>
Constructors
Section titled “Constructors”Constructor
Section titled “Constructor”new Vault(
adapter,operations?,options?):Vault
Defined in: storage/vault.svelte.ts:109
Parameters
Section titled “Parameters”adapter
Section titled “adapter”operations?
Section titled “operations?”Pick<FileEditingSessionRegistry, "track">
options?
Section titled “options?”VaultListingOptions = {}
Returns
Section titled “Returns”Vault
Overrides
Section titled “Overrides”Properties
Section titled “Properties”adapter
Section titled “adapter”
readonlyadapter:DataAdapter
Defined in: storage/vault.svelte.ts:110
readonlycache:FileCache
Defined in: storage/vault.svelte.ts:105
configDir
Section titled “configDir”configDir:
string=DEFAULT_APP_STATE_DIRECTORY
Defined in: storage/vault.svelte.ts:104
Accessors
Section titled “Accessors”supportsConditionalTextWrites
Section titled “supportsConditionalTextWrites”Get Signature
Section titled “Get Signature”get supportsConditionalTextWrites():
boolean
Defined in: storage/vault.svelte.ts:736
Returns
Section titled “Returns”boolean
supportsExclusiveCreate
Section titled “supportsExclusiveCreate”Get Signature
Section titled “Get Signature”get supportsExclusiveCreate():
boolean
Defined in: storage/vault.svelte.ts:328
Returns
Section titled “Returns”boolean
Methods
Section titled “Methods”append()
Section titled “append()”append(
file,data,options?):Promise<void>
Defined in: storage/vault.svelte.ts:869
Parameters
Section titled “Parameters”string
options?
Section titled “options?”Partial<FileProperties>
Returns
Section titled “Returns”Promise<void>
appendBinary()
Section titled “appendBinary()”appendBinary(
file,data,options?):Promise<void>
Defined in: storage/vault.svelte.ts:892
Parameters
Section titled “Parameters”ArrayBuffer
options?
Section titled “options?”Partial<FileProperties>
Returns
Section titled “Returns”Promise<void>
atomicWrite()
Section titled “atomicWrite()”atomicWrite(
path,source,options?):Promise<TFile>
Defined in: storage/vault.svelte.ts:621
Stream a file into the adapter’s atomic or strongest safe replacement path.
Parameters
Section titled “Parameters”string
source
Section titled “source”ReadableStream<Uint8Array<ArrayBufferLike>>
options?
Section titled “options?”AtomicDataWriteOptions = {}
Returns
Section titled “Returns”Promise<TFile>
cachedRead()
Section titled “cachedRead()”cachedRead(
file):Promise<string>
Defined in: storage/vault.svelte.ts:569
Read the content of a plaintext file stored inside the vault Use this if you only want to display the content to the user. If you want to modify the file content afterward use Vault.read
Parameters
Section titled “Parameters”Returns
Section titled “Returns”Promise<string>
copy()
Section titled “copy()”copy<
T>(file,newPath):Promise<T>
Defined in: storage/vault.svelte.ts:921
Type Parameters
Section titled “Type Parameters”T extends TAbstractFile
Parameters
Section titled “Parameters”T
newPath
Section titled “newPath”string
Returns
Section titled “Returns”Promise<T>
create()
Section titled “create()”create(
path,data,options?):Promise<TFile>
Defined in: storage/vault.svelte.ts:294
Create a new plaintext file inside the vault.
Parameters
Section titled “Parameters”string
Vault absolute path for the new file, with extension.
string
Text content for the new file.
options?
Section titled “options?”Partial<FileProperties>
(Optional)
Returns
Section titled “Returns”Promise<TFile>
createBinary()
Section titled “createBinary()”createBinary(
path,data,options?):Promise<TFile>
Defined in: storage/vault.svelte.ts:383
Create a new binary file inside the vault.
Parameters
Section titled “Parameters”string
Vault absolute path for the new file, with extension.
ArrayBuffer
Content for the new file.
options?
Section titled “options?”Partial<FileProperties>
(Optional)
Returns
Section titled “Returns”Promise<TFile>
Throws
Section titled “Throws”Error if file already exists
createExclusive()
Section titled “createExclusive()”createExclusive(
path,data,options?):Promise<TFile>
Defined in: storage/vault.svelte.ts:337
Create new bytes without replacing a cached or newly arriving file.
Parameters
Section titled “Parameters”string
string | ArrayBuffer
options?
Section titled “options?”Partial<FileProperties>
Returns
Section titled “Returns”Promise<TFile>
createFolder()
Section titled “createFolder()”createFolder(
path):Promise<TFolder>
Defined in: storage/vault.svelte.ts:420
Create a new folder inside the vault.
Parameters
Section titled “Parameters”string
Vault absolute path for the new folder.
Returns
Section titled “Returns”Promise<TFolder>
Throws
Section titled “Throws”Error if folder already exists
delete()
Section titled “delete()”delete(
file,force?,context?):Promise<void>
Defined in: storage/vault.svelte.ts:492
Deletes the file completely.
Parameters
Section titled “Parameters”The file or folder to be deleted
force?
Section titled “force?”boolean
Should attempt to delete folder even if it has hidden children
context?
Section titled “context?”operationOrigin?
Section titled “operationOrigin?”string
Returns
Section titled “Returns”Promise<void>
dispatch()
Section titled “dispatch()”dispatch<
T>(eventName, …args):boolean
Defined in: events.ts:105
Type Parameters
Section titled “Type Parameters”T extends "all" | "rename" | "create" | "modify" | "delete" | "load"
Parameters
Section titled “Parameters”eventName
Section titled “eventName”T
…ArgumentMap<{ all: [event: string, file: TAbstractFile, context: Record<string, unknown>]; create: [file: TAbstractFile]; delete: [file: TAbstractFile]; load: []; modify: [file: TAbstractFile]; rename: [file: TAbstractFile, oldPath: string]; }>[Extract<T, "all" | "rename" | "create" | "modify" | "delete" | "load">]
Returns
Section titled “Returns”boolean
Inherited from
Section titled “Inherited from”emit()
Section titled “emit()”emit<
T>(eventName, …args):boolean
Defined in: events.ts:98
Type Parameters
Section titled “Type Parameters”T extends "all" | "rename" | "create" | "modify" | "delete" | "load"
Parameters
Section titled “Parameters”eventName
Section titled “eventName”T
…ArgumentMap<{ all: [event: string, file: TAbstractFile, context: Record<string, unknown>]; create: [file: TAbstractFile]; delete: [file: TAbstractFile]; load: []; modify: [file: TAbstractFile]; rename: [file: TAbstractFile, oldPath: string]; }>[Extract<T, "all" | "rename" | "create" | "modify" | "delete" | "load">]
Returns
Section titled “Returns”boolean
Inherited from
Section titled “Inherited from”exists()
Section titled “exists()”exists(
path,sensitive?):Promise<boolean>
Defined in: storage/vault.svelte.ts:132
Parameters
Section titled “Parameters”string
sensitive?
Section titled “sensitive?”boolean
Returns
Section titled “Returns”Promise<boolean>
getAbstractFileByPath()
Section titled “getAbstractFileByPath()”getAbstractFileByPath(
path):TAbstractFile|null
Defined in: storage/vault.svelte.ts:981
Get a file or folder inside the vault at the given path. To check if the
return type is a file, use instanceof TFile. To check if it is a folder,
use instanceof TFolder.
Parameters
Section titled “Parameters”string
Vault absolute path to the folder or file, with extension, case sensitive.
Returns
Section titled “Returns”TAbstractFile | null
The abstract file, if it’s found.
getAllFolders()
Section titled “getAllFolders()”getAllFolders(
includeRoot?):TFolder[]
Defined in: storage/vault.svelte.ts:1023
Get all folders in the vault.
Parameters
Section titled “Parameters”includeRoot?
Section titled “includeRoot?”boolean
Should the root folder (/) be returned
Returns
Section titled “Returns”TFolder[]
getAllLoadedFiles()
Section titled “getAllLoadedFiles()”getAllLoadedFiles():
TAbstractFile[]
Defined in: storage/vault.svelte.ts:1012
Returns
Section titled “Returns”getFileByPath()
Section titled “getFileByPath()”getFileByPath(
path):TFile|null
Defined in: storage/vault.svelte.ts:946
Get a file inside the vault at the given path. Returns null if the file
does not exist.
Parameters
Section titled “Parameters”string
Returns
Section titled “Returns”TFile | null
getFiles()
Section titled “getFiles()”getFiles():
TFile[]
Defined in: storage/vault.svelte.ts:1038
Get all files in the vault.
Returns
Section titled “Returns”TFile[]
getFilesByGlob()
Section titled “getFilesByGlob()”getFilesByGlob(
pattern,options?):TFile[]
Defined in: storage/vault.svelte.ts:1077
Get all files matching a shared editor-association glob.
Filename-only patterns match files in every folder. Patterns containing a slash match normalized vault-relative paths. Invalid patterns return no files.
Parameters
Section titled “Parameters”pattern
Section titled “pattern”string
options?
Section titled “options?”VaultGlobOptions = {}
Returns
Section titled “Returns”TFile[]
getFolderByPath()
Section titled “getFolderByPath()”getFolderByPath(
path):TFolder|null
Defined in: storage/vault.svelte.ts:962
Get a folder inside the vault at the given path. Returns null if the
folder does not exist.
Parameters
Section titled “Parameters”string
Returns
Section titled “Returns”TFolder | null
getMarkdownFiles()
Section titled “getMarkdownFiles()”getMarkdownFiles():
TFile[]
Defined in: storage/vault.svelte.ts:1118
Returns
Section titled “Returns”TFile[]
getName()
Section titled “getName()”getName():
string
Defined in: storage/vault.svelte.ts:128
Returns
Section titled “Returns”string
getResourcePath()
Section titled “getResourcePath()”getResourcePath(
file):string
Defined in: storage/vault.svelte.ts:995
Parameters
Section titled “Parameters”Returns
Section titled “Returns”string
getResourceUrl()
Section titled “getResourceUrl()”getResourceUrl(
file):Promise<string>
Defined in: storage/vault.svelte.ts:999
Parameters
Section titled “Parameters”Returns
Section titled “Returns”Promise<string>
getRoot()
Section titled “getRoot()”getRoot():
TFolder
Defined in: storage/vault.svelte.ts:991
Get the root folder of the current vault.
Returns
Section titled “Returns”iterateFiles()
Section titled “iterateFiles()”iterateFiles():
IterableIterator<TFile>
Defined in: storage/vault.svelte.ts:1052
Iterate loaded files without allocating a second vault-sized collection. The traversal follows the existing folder tree and only retains iterator state proportional to folder depth.
Returns
Section titled “Returns”IterableIterator<TFile>
list()
Section titled “list()”list(
path?):Promise<{files:string[];folders:string[]; }>
Defined in: storage/vault.svelte.ts:140
Parameters
Section titled “Parameters”string = "/"
Returns
Section titled “Returns”Promise<{ files: string[]; folders: string[]; }>
load()
Section titled “load()”load(
options?):Promise<void>
Defined in: storage/vault.svelte.ts
Retry only failed discovery; concurrent and completed loads remain shared.
Parameters
Section titled “Parameters”options?
Section titled “options?”retry?
Section titled “retry?”boolean
Returns
Section titled “Returns”Promise<void>
loadPath()
Section titled “loadPath()”loadPath(
basePath?,sourceFiles?):Promise<Record<string,TAbstractFile>>
Defined in: storage/vault.svelte.ts:239
Parameters
Section titled “Parameters”basePath?
Section titled “basePath?”string = "/"
sourceFiles?
Section titled “sourceFiles?”Record<string, TAbstractFile> = ...
Returns
Section titled “Returns”Promise<Record<string, TAbstractFile>>
mkpath()
Section titled “mkpath()”mkpath(
path):Promise<TFolder>
Defined in: storage/vault.svelte.ts:456
Parameters
Section titled “Parameters”string
Returns
Section titled “Returns”Promise<TFolder>
modify()
Section titled “modify()”modify(
file,data,options?):Promise<void>
Defined in: storage/vault.svelte.ts:718
Modify the contents of a plaintext file.
Parameters
Section titled “Parameters”The file
string
The new file content
options?
Section titled “options?”Partial<FileProperties>
(Optional)
Returns
Section titled “Returns”Promise<void>
modifyBinary()
Section titled “modifyBinary()”modifyBinary(
file,data,options?):Promise<void>
Defined in: storage/vault.svelte.ts:800
Modify the contents of a binary file.
Parameters
Section titled “Parameters”The file
ArrayBuffer
The new file content
options?
Section titled “options?”Partial<FileProperties>
(Optional)
Returns
Section titled “Returns”Promise<void>
modifyIfUnchanged()
Section titled “modifyIfUnchanged()”modifyIfUnchanged(
file,data,expected,options?):Promise<void>
Defined in: storage/vault.svelte.ts:745
Persist only the caller’s captured text version; never fall back to write.
Parameters
Section titled “Parameters”string
expected
Section titled “expected”string | null
options?
Section titled “options?”Partial<FileProperties>
Returns
Section titled “Returns”Promise<void>
off<
T>(eventName,listener,context?,once?):void
Defined in: events.ts:78
Type Parameters
Section titled “Type Parameters”T extends "all" | "rename" | "create" | "modify" | "delete" | "load"
Parameters
Section titled “Parameters”eventName
Section titled “eventName”T
listener
Section titled “listener”(…args) => void
context?
Section titled “context?”any
boolean
Returns
Section titled “Returns”void
Inherited from
Section titled “Inherited from”offref()
Section titled “offref()”offref<
T>(ref):void
Defined in: events.ts:87
Type Parameters
Section titled “Type Parameters”T extends "all" | "rename" | "create" | "modify" | "delete" | "load"
Parameters
Section titled “Parameters”EventRef<{ all: [event: string, file: TAbstractFile, context: Record<string, unknown>]; create: [file: TAbstractFile]; delete: [file: TAbstractFile]; load: []; modify: [file: TAbstractFile]; rename: [file: TAbstractFile, oldPath: string]; }, T>
Returns
Section titled “Returns”void
Inherited from
Section titled “Inherited from”on<
T>(eventName,listener,context?):EventRef<{all: [event:string,file:TAbstractFile,context:Record<string,unknown>];create: [file:TAbstractFile];delete: [file:TAbstractFile];load: [];modify: [file:TAbstractFile];rename: [file:TAbstractFile,oldPath:string]; },T,any>
Defined in: events.ts:48
Type Parameters
Section titled “Type Parameters”T extends "all" | "rename" | "create" | "modify" | "delete" | "load"
Parameters
Section titled “Parameters”eventName
Section titled “eventName”T
listener
Section titled “listener”(…args) => void
context?
Section titled “context?”any
Returns
Section titled “Returns”EventRef<{ all: [event: string, file: TAbstractFile, context: Record<string, unknown>]; create: [file: TAbstractFile]; delete: [file: TAbstractFile]; load: []; modify: [file: TAbstractFile]; rename: [file: TAbstractFile, oldPath: string]; }, T, any>
Inherited from
Section titled “Inherited from”once()
Section titled “once()”once<
T>(eventName,listener,context?):EventRef<{all: [event:string,file:TAbstractFile,context:Record<string,unknown>];create: [file:TAbstractFile];delete: [file:TAbstractFile];load: [];modify: [file:TAbstractFile];rename: [file:TAbstractFile,oldPath:string]; },T,any>
Defined in: events.ts:63
Type Parameters
Section titled “Type Parameters”T extends "all" | "rename" | "create" | "modify" | "delete" | "load"
Parameters
Section titled “Parameters”eventName
Section titled “eventName”T
listener
Section titled “listener”(…args) => void
context?
Section titled “context?”any
Returns
Section titled “Returns”EventRef<{ all: [event: string, file: TAbstractFile, context: Record<string, unknown>]; create: [file: TAbstractFile]; delete: [file: TAbstractFile]; load: []; modify: [file: TAbstractFile]; rename: [file: TAbstractFile, oldPath: string]; }, T, any>
Inherited from
Section titled “Inherited from”openRead()
Section titled “openRead()”openRead(
file):Promise<VaultReadHandle>
Defined in: storage/vault.svelte.ts:586
Open a stable streamed snapshot of a file when the adapter supports it.
Parameters
Section titled “Parameters”Returns
Section titled “Returns”Promise<VaultReadHandle>
process()
Section titled “process()”process(
file,fn,options?):Promise<string>
Defined in: storage/vault.svelte.ts:850
Atomically read, modify, and save the contents of a note.
Parameters
Section titled “Parameters”The file to be read and modified.
(data) => string
A callback function which returns the new content of the note synchronously.
options?
Section titled “options?”Partial<FileProperties>
Write options.
Returns
Section titled “Returns”Promise<string>
String - the text value of the note that was written.
Remarks
Section titled “Remarks”Example:
app.vault.process(file, (data) => { return data.replace("Hello", "World");});read()
Section titled “read()”read(
file):Promise<string>
Defined in: storage/vault.svelte.ts:555
Read a plaintext file that is stored inside the vault, directly from disk. Use this if you intend to modify the file content afterwards. Use Vault.cachedRead otherwise for better performance.
Parameters
Section titled “Parameters”Returns
Section titled “Returns”Promise<string>
readBinary()
Section titled “readBinary()”readBinary(
file):Promise<ArrayBuffer>
Defined in: storage/vault.svelte.ts:581
Read the content of a binary file stored inside the vault.
Parameters
Section titled “Parameters”Returns
Section titled “Returns”Promise<ArrayBuffer>
reconcile()
Section titled “reconcile()”reconcile(
hints?,current?,context?):Promise<void>
Defined in: storage/vault.svelte.ts:171
Reconcile a complete disk snapshot without replacing live resources.
Parameters
Section titled “Parameters”hints?
Section titled “hints?”readonly ChangeEvent[] = []
current?
Section titled “current?”() => boolean
context?
Section titled “context?”Record<string, unknown> = {}
Returns
Section titled “Returns”Promise<void>
reload()
Section titled “reload()”reload():
Promise<TFolder>
Defined in: storage/vault.svelte.ts:162
Returns
Section titled “Returns”Promise<TFolder>
rename()
Section titled “rename()”rename(
file,newPath):Promise<void>
Defined in: storage/vault.svelte.ts:690
Rename or move a file. To ensure links are automatically renamed, use FileManager.renameFile instead.
Parameters
Section titled “Parameters”The file to rename/move
newPath
Section titled “newPath”string
Vault absolute path to move file to.
Returns
Section titled “Returns”Promise<void>
revokeResourceUrl()
Section titled “revokeResourceUrl()”revokeResourceUrl(
url):void
Defined in: storage/vault.svelte.ts:1007
Parameters
Section titled “Parameters”string
Returns
Section titled “Returns”void
stat()
Section titled “stat()”stat(
path):Promise<Stat|null>
Defined in: storage/vault.svelte.ts:136
Parameters
Section titled “Parameters”string
Returns
Section titled “Returns”Promise<Stat | null>
trash()
Section titled “trash()”trash(
file,system?):Promise<void>
Defined in: storage/vault.svelte.ts:534
Parameters
Section titled “Parameters”system?
Section titled “system?”boolean = true
Returns
Section titled “Returns”Promise<void>
trigger()
Section titled “trigger()”trigger<
T>(eventName, …args):boolean
Defined in: events.ts:91
Type Parameters
Section titled “Type Parameters”T extends "all" | "rename" | "create" | "modify" | "delete" | "load"
Parameters
Section titled “Parameters”eventName
Section titled “eventName”T
…ArgumentMap<{ all: [event: string, file: TAbstractFile, context: Record<string, unknown>]; create: [file: TAbstractFile]; delete: [file: TAbstractFile]; load: []; modify: [file: TAbstractFile]; rename: [file: TAbstractFile, oldPath: string]; }>[Extract<T, "all" | "rename" | "create" | "modify" | "delete" | "load">]
Returns
Section titled “Returns”boolean
Inherited from
Section titled “Inherited from”tryTrigger()
Section titled “tryTrigger()”tryTrigger<
T>(evt, …args):void
Defined in: events.ts:112
Type Parameters
Section titled “Type Parameters”T extends "all" | "rename" | "create" | "modify" | "delete" | "load"
Parameters
Section titled “Parameters”EventRef<{ all: [event: string, file: TAbstractFile, context: Record<string, unknown>]; create: [file: TAbstractFile]; delete: [file: TAbstractFile]; load: []; modify: [file: TAbstractFile]; rename: [file: TAbstractFile, oldPath: string]; }, T>
…ArgumentMap<{ all: [event: string, file: TAbstractFile, context: Record<string, unknown>]; create: [file: TAbstractFile]; delete: [file: TAbstractFile]; load: []; modify: [file: TAbstractFile]; rename: [file: TAbstractFile, oldPath: string]; }>[Extract<T, "all" | "rename" | "create" | "modify" | "delete" | "load">]
Returns
Section titled “Returns”void
Inherited from
Section titled “Inherited from”recurseChildren()
Section titled “recurseChildren()”
staticrecurseChildren(root,cb):void
Defined in: storage/vault.svelte.ts:1124
Parameters
Section titled “Parameters”(file) => any
Returns
Section titled “Returns”void