Skip to content

Commit

Permalink
feat: Indexer
Browse files Browse the repository at this point in the history
  • Loading branch information
linonetwo committed Apr 2, 2024
1 parent a4dcbad commit 12019b7
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 1 deletion.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "tw5-typed",
"version": "0.5.7",
"version": "0.5.8",
"scripts": {
"check": "tsc --noEmit && eslint src/**/*.ts",
"docs": "docs-ts",
Expand Down
1 change: 1 addition & 0 deletions src/modules/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
/// <reference path="server/index.d.ts" />
/// <reference path="parsers/index.d.ts" />
/// <reference path="widgets/index.d.ts" />
/// <reference path="indexers/index.d.ts" />
/// <reference path="parsers/index.d.ts" />
/// <reference path="syncer/syncAdaptor.d.ts" />
/// <reference path="syncer/syncer.d.ts" />
Expand Down
46 changes: 46 additions & 0 deletions src/modules/indexers/index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
declare module 'tiddlywiki' {
/**
* Abstract class representing an indexer in TiddlyWiki. Indexers maintain indexes of tiddlers organized efficiently for different types of access, improving the speed of certain filter operations.
* @url https://tiddlywiki.com/dev/#indexer%20modules
*/
abstract class Indexer {
protected wiki: Wiki;
protected index: Record<string, Record<string, string[]>> | null;
protected maxIndexedValueLength: number;

/**
* Constructs an Indexer instance.
* @param {Wiki} wiki - The wiki object associated with this indexer.
*/
constructor(wiki: Wiki) {
this.wiki = wiki;
}

/**
* Initializes the indexer, performing any necessary setup.
*/
abstract init(): void;

/**
* Rebuilds the indexer's index from scratch. Typically used after a significant number of changes in the wiki.
*/
abstract rebuild(): void;

/**
* Updates the index based on changes to a tiddler.
* @param {Object} updateDescriptor - Describes the changes to the tiddler.
* @param {Object} updateDescriptor.old - The state of the tiddler before the update.
* @param {boolean} updateDescriptor.old.exists - Indicates if the tiddler existed before the update.
* @param {boolean} updateDescriptor.old.shadow - Indicates if the tiddler was a shadow tiddler before the update.
* @param {Tiddler} updateDescriptor.old.tiddler - The tiddler before the update.
* @param {Object} updateDescriptor.new - The state of the tiddler after the update.
* @param {boolean} updateDescriptor.new.exists - Indicates if the tiddler exists after the update.
* @param {boolean} updateDescriptor.new.shadow - Indicates if the tiddler is a shadow tiddler after the update.
* @param {Tiddler} updateDescriptor.new.tiddler - The tiddler after the update.
*/
abstract update(updateDescriptor: {
new: { exists: boolean; shadow: boolean; tiddler: Tiddler };
old: { exists: boolean; shadow: boolean; tiddler: Tiddler };
}): void;
}
}

0 comments on commit 12019b7

Please sign in to comment.