Skip to content

Tankōbon / preload / LibraryApi

Interface: LibraryApi ​

Defined in: preload.ts:88

The library and its per-entry fields, as window.tankobon.library.

Methods ​

addFile() ​

addFile(): Promise<AddFileResult>

Defined in: preload.ts:92

Opens a native file picker, then adds the chosen comic to the library without opening it; an unreadable file resolves to an error result rather than rejecting. The library organization then moves it, or offers to (organization).

Returns ​

Promise<AddFileResult>


addFolder() ​

addFolder(): Promise<ScanResult>

Defined in: preload.ts:94

Opens a native directory picker, then adds every comic found under it, recursively. The library organization then moves them, or offers to (organization).

Returns ​

Promise<ScanResult>


analyzeCleanup() ​

analyzeCleanup(ids): Promise<CleanupAnalysisResult>

Defined in: preload.ts:104

First step of cleaning the books: lists the files that are not images in the CBZ of ids (the whole library when empty), grouped by extension, without touching anything. Progress goes over onScanProgress. The result's token is what applyCleanup() takes.

Parameters ​

ids ​

string[]

Returns ​

Promise<CleanupAnalysisResult>


applyCleanup() ​

applyCleanup(token, keptExtensions): Promise<CleanupResult>

Defined in: preload.ts:106

Second step: rewrites the archives of the analysis token without those files, except the kinds whose extension (.xml, empty for none) is in keptExtensions. The original is replaced only once the new archive has been checked. The token works once.

Parameters ​

token ​

string

keptExtensions ​

string[]

Returns ​

Promise<CleanupResult>


cleanFolders() ​

cleanFolders(): Promise<CleanFoldersResult>

Defined in: preload.ts:116

Moves those orphan folders to the .deletedByTankobon folder of the organized folder; progress arrives through onScanProgress. The folders books are added from are never touched.

Returns ​

Promise<CleanFoldersResult>


convertCbr() ​

convertCbr(): Promise<ConvertCbrResult>

Defined in: preload.ts:110

Writes each CBR of the organized folder as a CBZ beside it, points the book at it (progress, rating, tags and lists are kept) and moves the CBR to .deletedByTankobon at the root of the organized folder. Progress goes over onScanProgress.

Returns ​

Promise<ConvertCbrResult>


countConvertible() ​

countConvertible(): Promise<ConvertCountResult>

Defined in: preload.ts:108

How many CBR of the organized folder convertCbr() would convert, and what its .deletedByTankobon folder holds; an error when the organization is off or its folder unreachable.

Returns ​

Promise<ConvertCountResult>


countOrphanFolders() ​

countOrphanFolders(): Promise<OrphanFoldersCountResult>

Defined in: preload.ts:114

How many folders of the organized folder cleanFolders() would move: those holding no book, only .nfo files and cover images; an error when the organization is off or its folder unreachable.

Returns ​

Promise<OrphanFoldersCountResult>


countUnorganized() ​

countUnorganized(): Promise<UnorganizedCountResult>

Defined in: preload.ts:100

How many library comics aren't in their place in the organized folder yet; an error result when the organization is off or its folder unreachable.

Returns ​

Promise<UnorganizedCountResult>


emptyDeleted() ​

emptyDeleted(): Promise<EmptyDeletedResult>

Defined in: preload.ts:112

Deletes for good everything in the .deletedByTankobon folder of the organized folder.

Returns ​

Promise<EmptyDeletedResult>


imageScanStatus() ​

imageScanStatus(): Promise<ImageScanProgress>

Defined in: preload.ts:130

Where the background measure of the books' page sizes is now (it runs after an import, a resync or the first opening of a book); resolves with the state a window that loads late missed.

Returns ​

Promise<ImageScanProgress>


list() ​

list(): Promise<LibraryEntry[]>

Defined in: preload.ts:90

Every library entry, most recently opened first.

Returns ​

Promise<LibraryEntry[]>


listFolders() ​

listFolders(): Promise<string[]>

Defined in: preload.ts:118

The folders added with addFolder, which resync walks again, in the order they were added.

Returns ​

Promise<string[]>


listUnlinkedFolders() ​

listUnlinkedFolders(): Promise<UnlinkedFolder[]>

Defined in: preload.ts:122

The library folders that have no path on this machine yet (the library was made on another one): their comics are listed but their files can't be found until relinkFolder.

Returns ​

Promise<UnlinkedFolder[]>


onImageScanProgress() ​

onImageScanProgress(listener): () => void

Defined in: preload.ts:132

Subscribes to the progress of that background measure; returns the unsubscribe function.

Parameters ​

listener ​

(progress) => void

Returns ​

() => void


onScanProgress() ​

onScanProgress(listener): () => void

Defined in: preload.ts:128

Subscribes to the progress of addFolder, resync, organizeAll, convertCbr and cleanFolders; returns the unsubscribe function.

Parameters ​

listener ​

(progress) => void

Returns ​

() => void


organize() ​

organize(token): Promise<OrganizeResult>

Defined in: preload.ts:98

Moves into the organized folder the comics an addition offered to move (organization.pending.token of its result), each into its own subfolder; a token works once.

Parameters ​

token ​

string

Returns ​

Promise<OrganizeResult>


organizeAll() ​

organizeAll(): Promise<OrganizeResult>

Defined in: preload.ts:102

Moves every library comic not in its place yet into the organized folder (its own subfolder each), whenever it was added. Reports through onScanProgress; an error result when the organization is off, its folder unreachable, or a resynchronization or another organization is running.

Returns ​

Promise<OrganizeResult>


pickOrganizationFolder() ​

pickOrganizationFolder(): Promise<PickOrganizationFolderResult>

Defined in: preload.ts:96

Opens a native directory picker and makes the chosen folder the library organization's folder (the libraryOrganizationFolder setting, which settings.set refuses), also remembered among the folders resync walks.

Returns ​

Promise<PickOrganizationFolderResult>


relinkFolder() ​

relinkFolder(id): Promise<RelinkFolderResult>

Defined in: preload.ts:124

Opens a native directory picker to say where an unlinked folder (an id returned by listUnlinkedFolders) is on this machine; the comics stored relative to it are found again.

Parameters ​

id ​

string

Returns ​

Promise<RelinkFolderResult>


remove() ​

remove(id, deleteFile?): Promise<RemoveEntryResult>

Defined in: preload.ts:134

Removes an entry from the library. The file on disk is left untouched, unless deleteFile is true: it (and its cover and .nfo sidecars) then goes to the trash. An error result means the entry is gone from the library but the file could not be trashed.

Parameters ​

id ​

string

deleteFile? ​

boolean

Returns ​

Promise<RemoveEntryResult>


removeFolder() ​

removeFolder(folder): Promise<void>

Defined in: preload.ts:120

Forgets one of those folders (a path returned by listFolders); its comics stay in the library.

Parameters ​

folder ​

string

Returns ​

Promise<void>


removeMany() ​

removeMany(ids, deleteFiles): Promise<RemoveEntriesResult>

Defined in: preload.ts:136

Removes several entries from the library; with deleteFiles, their files (and the covers beside them) are also moved to the system trash. A file that can't be trashed is counted as failed, its entry is removed anyway.

Parameters ​

ids ​

string[]

deleteFiles ​

boolean

Returns ​

Promise<RemoveEntriesResult>


resync() ​

resync(): Promise<ResyncResult>

Defined in: preload.ts:126

Walks the remembered folders (and the organized folder, when the organization is on) again: new comics are added (then moved or offered by the organization, a comic dropped in the organized folder being moved into place), and comics whose file no longer exists are removed from the library (with their progress, rating, tags and reading-list places; the files on disk are never touched). A folder that can't be read is skipped and counted as unreachable. Comics of those folders without a .nfo get one written from their library information (an existing one is never overwritten), counted as nfoWritten, and the missing cover thumbnails of those comics are extracted, counted as coversExtracted. Stores the date as the lastResyncAt setting. Reports through onScanProgress; an error result when one is already running.

Returns ​

Promise<ResyncResult>


setCover() ​

setCover(id, image): Promise<SetCoverResult>

Defined in: preload.ts:150

Replaces the cover thumbnail of a library entry with image (PNG, JPEG or WebP, at most 8 MiB, already cropped to the cover's 2:3 proportions by the caller); the main process shrinks it to the thumbnail size and writes it beside the comic (or in the local cache). A picture that can't be decoded comes back as an error result and leaves the current cover as it was.

Parameters ​

id ​

string

image ​

Uint8Array

Returns ​

Promise<SetCoverResult>


thumbnail() ​

thumbnail(id): Promise<Uint8Array<ArrayBuffer> | null>

Defined in: preload.ts:148

Cover thumbnail (first page, shrunk) of a library entry as WebP bytes, generated and cached first when missing; null if the entry is unknown or unreadable.

Parameters ​

id ​

string

Returns ​

Promise<Uint8Array<ArrayBuffer> | null>


updateMetadata() ​

updateMetadata(id, update): Promise<LibraryEntry | null>

Defined in: preload.ts:144

Writes the given metadata fields (title, series, credits…) of a library entry; resolves with the updated entry, or null if it is gone.

Parameters ​

id ​

string

update ​

MetadataUpdate

Returns ​

Promise<LibraryEntry | null>


updateMetadataMany() ​

updateMetadataMany(ids, update): Promise<number>

Defined in: preload.ts:146

Writes the same metadata fields on several library entries at once (all or none); resolves with the number of entries updated (unknown ids are skipped).

Parameters ​

ids ​

string[]

update ​

MetadataUpdate

Returns ​

Promise<number>


updateProgress() ​

updateProgress(id, currentPage): Promise<void>

Defined in: preload.ts:138

Saves the last page read (0-based) of a library entry.

Parameters ​

id ​

string

currentPage ​

number

Returns ​

Promise<void>


updateRating() ​

updateRating(id, rating): Promise<void>

Defined in: preload.ts:140

Sets the rating of a library entry: 0 (unrated) to 5.

Parameters ​

id ​

string

rating ​

number

Returns ​

Promise<void>


updateTags() ​

updateTags(id, tags): Promise<void>

Defined in: preload.ts:142

Replaces the tags of a library entry.

Parameters ​

id ​

string

tags ​

string[]

Returns ​

Promise<void>