Skip to content

Vault

Defined in: storage/vault.svelte.ts:38

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.

new Vault(adapter): Vault

Defined in: storage/vault.svelte.ts:50

DataAdapter

Vault

EventDispatcher.constructor

readonly adapter: DataAdapter

Defined in: storage/vault.svelte.ts:50


readonly cache: FileCache

Defined in: storage/vault.svelte.ts:48


configDir: string = ".obsidian"

Defined in: storage/vault.svelte.ts:47

append(file, data, options?): Promise<void>

Defined in: storage/vault.svelte.ts:494

TFile

string

Partial<FileProperties>

Promise<void>


appendBinary(file, data, options?): Promise<void>

Defined in: storage/vault.svelte.ts:511

TFile

ArrayBuffer

Partial<FileProperties>

Promise<void>


cachedRead(file): Promise<string>

Defined in: storage/vault.svelte.ts:348

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

TFile

Promise<string>


copy<T>(file, newPath): Promise<T>

Defined in: storage/vault.svelte.ts:532

T extends TAbstractFile

T

string

Promise<T>


create(path, data, options?): Promise<TFile>

Defined in: storage/vault.svelte.ts:151

Create a new plaintext file inside the vault.

string

Vault absolute path for the new file, with extension.

string

Text content for the new file.

Partial<FileProperties>

(Optional)

Promise<TFile>


createBinary(path, data, options?): Promise<TFile>

Defined in: storage/vault.svelte.ts:188

Create a new binary file inside the vault.

string

Vault absolute path for the new file, with extension.

ArrayBuffer

Content for the new file.

Partial<FileProperties>

(Optional)

Promise<TFile>

Error if file already exists


createFolder(path): Promise<TFolder>

Defined in: storage/vault.svelte.ts:218

Create a new folder inside the vault.

string

Vault absolute path for the new folder.

Promise<TFolder>

Error if folder already exists


delete(file, force?): Promise<void>

Defined in: storage/vault.svelte.ts:285

Deletes the file completely.

TAbstractFile

The file or folder to be deleted

boolean

Should attempt to delete folder even if it has hidden children

Promise<void>


dispatch<T>(eventName, …args): boolean

Defined in: events.ts:105

T extends "load" | "create" | "modify" | "delete" | "rename" | "all"

T

ArgumentMap<{ all: [string, TAbstractFile, Record<string, unknown>]; create: [TAbstractFile]; delete: [TAbstractFile]; load: []; modify: [TAbstractFile]; rename: [TAbstractFile, string]; }>[Extract<T, "load" | "create" | "modify" | "delete" | "rename" | "all">]

boolean

EventDispatcher.dispatch


emit<T>(eventName, …args): boolean

Defined in: events.ts:98

T extends "load" | "create" | "modify" | "delete" | "rename" | "all"

T

ArgumentMap<{ all: [string, TAbstractFile, Record<string, unknown>]; create: [TAbstractFile]; delete: [TAbstractFile]; load: []; modify: [TAbstractFile]; rename: [TAbstractFile, string]; }>[Extract<T, "load" | "create" | "modify" | "delete" | "rename" | "all">]

boolean

EventDispatcher.emit


exists(path, sensitive?): Promise<boolean>

Defined in: storage/vault.svelte.ts:66

string

boolean

Promise<boolean>


getAbstractFileByPath(path): TAbstractFile | null

Defined in: storage/vault.svelte.ts:587

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.

string

Vault absolute path to the folder or file, with extension, case sensitive.

TAbstractFile | null

The abstract file, if it’s found.


getAllFolders(includeRoot?): TFolder[]

Defined in: storage/vault.svelte.ts:628

Get all folders in the vault.

boolean

Should the root folder (/) be returned

TFolder[]


getAllLoadedFiles(): TAbstractFile[]

Defined in: storage/vault.svelte.ts:618

TAbstractFile[]


getFileByPath(path): TFile | null

Defined in: storage/vault.svelte.ts:552

Get a file inside the vault at the given path. Returns null if the file does not exist.

string

TFile | null


getFiles(): TFile[]

Defined in: storage/vault.svelte.ts:639

Get all files in the vault.

TFile[]


getFolderByPath(path): TFolder | null

Defined in: storage/vault.svelte.ts:568

Get a folder inside the vault at the given path. Returns null if the folder does not exist.

string

TFolder | null


getMarkdownFiles(): TFile[]

Defined in: storage/vault.svelte.ts:643

TFile[]


getName(): string

Defined in: storage/vault.svelte.ts:62

string


getResourcePath(file): string

Defined in: storage/vault.svelte.ts:601

TFile

string


getResourceUrl(file): Promise<string>

Defined in: storage/vault.svelte.ts:605

TFile

Promise<string>


getRoot(): TFolder

Defined in: storage/vault.svelte.ts:597

Get the root folder of the current vault.

TFolder


list(path?): Promise<ListedFiles>

Defined in: storage/vault.svelte.ts:74

string = "/"

Promise<ListedFiles>


load(): Promise<void>

Defined in: storage/vault.svelte.ts:79

Promise<void>


loadPath(basePath?, sourceFiles?): Promise<Record<string, TAbstractFile>>

Defined in: storage/vault.svelte.ts:96

string = "/"

Record<string, TAbstractFile> = ...

Promise<Record<string, TAbstractFile>>


mkpath(path): Promise<TFolder>

Defined in: storage/vault.svelte.ts:249

string

Promise<TFolder>


modify(file, data, options?): Promise<void>

Defined in: storage/vault.svelte.ts:409

Modify the contents of a plaintext file.

TFile

The file

string

The new file content

Partial<FileProperties>

(Optional)

Promise<void>


modifyBinary(file, data, options?): Promise<void>

Defined in: storage/vault.svelte.ts:440

Modify the contents of a binary file.

TFile

The file

ArrayBuffer

The new file content

Partial<FileProperties>

(Optional)

Promise<void>


off<T>(eventName, listener, context?, once?): void

Defined in: events.ts:78

T extends "load" | "create" | "modify" | "delete" | "rename" | "all"

T

(…args) => void

any

boolean

void

EventDispatcher.off


offref<T>(ref): void

Defined in: events.ts:87

T extends "load" | "create" | "modify" | "delete" | "rename" | "all"

EventRef<{ all: [string, TAbstractFile, Record<string, unknown>]; create: [TAbstractFile]; delete: [TAbstractFile]; load: []; modify: [TAbstractFile]; rename: [TAbstractFile, string]; }, T>

void

EventDispatcher.offref


on<T>(eventName, listener, context?): EventRef<{ all: [string, TAbstractFile, Record<string, unknown>]; create: [TAbstractFile]; delete: [TAbstractFile]; load: []; modify: [TAbstractFile]; rename: [TAbstractFile, string]; }, T, any>

Defined in: events.ts:48

T extends "load" | "create" | "modify" | "delete" | "rename" | "all"

T

(…args) => void

any

EventRef<{ all: [string, TAbstractFile, Record<string, unknown>]; create: [TAbstractFile]; delete: [TAbstractFile]; load: []; modify: [TAbstractFile]; rename: [TAbstractFile, string]; }, T, any>

EventDispatcher.on


once<T>(eventName, listener, context?): EventRef<{ all: [string, TAbstractFile, Record<string, unknown>]; create: [TAbstractFile]; delete: [TAbstractFile]; load: []; modify: [TAbstractFile]; rename: [TAbstractFile, string]; }, T, any>

Defined in: events.ts:63

T extends "load" | "create" | "modify" | "delete" | "rename" | "all"

T

(…args) => void

any

EventRef<{ all: [string, TAbstractFile, Record<string, unknown>]; create: [TAbstractFile]; delete: [TAbstractFile]; load: []; modify: [TAbstractFile]; rename: [TAbstractFile, string]; }, T, any>

EventDispatcher.once


process(file, fn, options?): Promise<string>

Defined in: storage/vault.svelte.ts:481

Atomically read, modify, and save the contents of a note.

TFile

The file to be read and modified.

(data) => string

A callback function which returns the new content of the note synchronously.

Partial<FileProperties>

Write options.

Promise<string>

String - the text value of the note that was written.

app.vault.process(file, (data) => {
return data.replace('Hello', 'World');
});
```;
***
### read()
> **read**(`file`): `Promise`\<`string`\>
Defined in: [storage/vault.svelte.ts:334](https://code.ju.ma/lapis-notes/lapis/src/branch/main/packages/api/src/lib/storage/vault.svelte.ts#L334)
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](#cachedread) otherwise for better performance.
#### Parameters
##### file
[`TFile`](TFile.md)
#### Returns
`Promise`\<`string`\>
***
### readBinary()
> **readBinary**(`file`): `Promise`\<`ArrayBuffer`\>
Defined in: [storage/vault.svelte.ts:360](https://code.ju.ma/lapis-notes/lapis/src/branch/main/packages/api/src/lib/storage/vault.svelte.ts#L360)
Read the content of a binary file stored inside the vault.
#### Parameters
##### file
[`TFile`](TFile.md)
#### Returns
`Promise`\<`ArrayBuffer`\>
***
### reload()
> **reload**(): `Promise`\<[`TFolder`](TFolder.md)\>
Defined in: [storage/vault.svelte.ts:87](https://code.ju.ma/lapis-notes/lapis/src/branch/main/packages/api/src/lib/storage/vault.svelte.ts#L87)
#### Returns
`Promise`\<[`TFolder`](TFolder.md)\>
***
### rename()
> **rename**(`file`, `newPath`): `Promise`\<`void`\>
Defined in: [storage/vault.svelte.ts:372](https://code.ju.ma/lapis-notes/lapis/src/branch/main/packages/api/src/lib/storage/vault.svelte.ts#L372)
Rename or move a file. To ensure links are automatically renamed, use
[FileManager.renameFile](FileManager.md#renamefile) instead.
#### Parameters
##### file
[`TAbstractFile`](TAbstractFile.md)
The file to rename/move
##### newPath
`string`
Vault absolute path to move file to.
#### Returns
`Promise`\<`void`\>
***
### revokeResourceUrl()
> **revokeResourceUrl**(`url`): `void`
Defined in: [storage/vault.svelte.ts:613](https://code.ju.ma/lapis-notes/lapis/src/branch/main/packages/api/src/lib/storage/vault.svelte.ts#L613)
#### Parameters
##### url
`string`
#### Returns
`void`
***
### stat()
> **stat**(`path`): `Promise`\<`Stat` \| `null`\>
Defined in: [storage/vault.svelte.ts:70](https://code.ju.ma/lapis-notes/lapis/src/branch/main/packages/api/src/lib/storage/vault.svelte.ts#L70)
#### Parameters
##### path
`string`
#### Returns
`Promise`\<`Stat` \| `null`\>
***
### trash()
> **trash**(`file`, `system?`): `Promise`\<`void`\>
Defined in: [storage/vault.svelte.ts:311](https://code.ju.ma/lapis-notes/lapis/src/branch/main/packages/api/src/lib/storage/vault.svelte.ts#L311)
#### Parameters
##### file
[`TAbstractFile`](TAbstractFile.md)
##### system?
`boolean` = `true`
#### Returns
`Promise`\<`void`\>
***
### trigger()
> **trigger**\<`T`\>(`eventName`, ...`args`): `boolean`
Defined in: [events.ts:91](https://code.ju.ma/lapis-notes/lapis/src/branch/main/packages/api/src/lib/events.ts#L91)
#### Type Parameters
##### T
`T` *extends* `"load"` \| `"create"` \| `"modify"` \| `"delete"` \| `"rename"` \| `"all"`
#### Parameters
##### eventName
`T`
##### args
...`ArgumentMap`\<\{ `all`: \[`string`, [`TAbstractFile`](TAbstractFile.md), `Record`\<`string`, `unknown`\>\]; `create`: \[[`TAbstractFile`](TAbstractFile.md)\]; `delete`: \[[`TAbstractFile`](TAbstractFile.md)\]; `load`: \[\]; `modify`: \[[`TAbstractFile`](TAbstractFile.md)\]; `rename`: \[[`TAbstractFile`](TAbstractFile.md), `string`\]; \}\>\[`Extract`\<`T`, `"load"` \| `"create"` \| `"modify"` \| `"delete"` \| `"rename"` \| `"all"`\>\]
#### Returns
`boolean`
#### Inherited from
[`EventDispatcher`](EventDispatcher.md).[`trigger`](EventDispatcher.md#trigger)
***
### tryTrigger()
> **tryTrigger**\<`T`\>(`evt`, ...`args`): `void`
Defined in: [events.ts:112](https://code.ju.ma/lapis-notes/lapis/src/branch/main/packages/api/src/lib/events.ts#L112)
#### Type Parameters
##### T
`T` *extends* `"load"` \| `"create"` \| `"modify"` \| `"delete"` \| `"rename"` \| `"all"`
#### Parameters
##### evt
`EventRef`\<\{ `all`: \[`string`, [`TAbstractFile`](TAbstractFile.md), `Record`\<`string`, `unknown`\>\]; `create`: \[[`TAbstractFile`](TAbstractFile.md)\]; `delete`: \[[`TAbstractFile`](TAbstractFile.md)\]; `load`: \[\]; `modify`: \[[`TAbstractFile`](TAbstractFile.md)\]; `rename`: \[[`TAbstractFile`](TAbstractFile.md), `string`\]; \}, `T`\>
##### args
...`ArgumentMap`\<\{ `all`: \[`string`, [`TAbstractFile`](TAbstractFile.md), `Record`\<`string`, `unknown`\>\]; `create`: \[[`TAbstractFile`](TAbstractFile.md)\]; `delete`: \[[`TAbstractFile`](TAbstractFile.md)\]; `load`: \[\]; `modify`: \[[`TAbstractFile`](TAbstractFile.md)\]; `rename`: \[[`TAbstractFile`](TAbstractFile.md), `string`\]; \}\>\[`Extract`\<`T`, `"load"` \| `"create"` \| `"modify"` \| `"delete"` \| `"rename"` \| `"all"`\>\]
#### Returns
`void`
#### Inherited from
[`EventDispatcher`](EventDispatcher.md).[`tryTrigger`](EventDispatcher.md#trytrigger)
***
### recurseChildren()
> `static` **recurseChildren**(`root`, `cb`): `void`
Defined in: [storage/vault.svelte.ts:649](https://code.ju.ma/lapis-notes/lapis/src/branch/main/packages/api/src/lib/storage/vault.svelte.ts#L649)
#### Parameters
##### root
[`TFolder`](TFolder.md)
##### cb
(`file`) => `any`
#### Returns
`void`