unvendor: Replace Fuse
This commit is contained in:
parent
4725b869eb
commit
e6d8f0a33e
|
@ -52,7 +52,6 @@ module.exports = {
|
|||
globals: {
|
||||
DOMPurify: 'readonly',
|
||||
droll: 'readonly',
|
||||
Fuse: 'readonly',
|
||||
Handlebars: 'readonly',
|
||||
hljs: 'readonly',
|
||||
localforage: 'readonly',
|
||||
|
|
|
@ -117,160 +117,6 @@ interface JQuery {
|
|||
//#endregion
|
||||
}
|
||||
|
||||
//#region Fuse
|
||||
|
||||
/**
|
||||
* Fuse.js provides fast and flexible fuzzy searching
|
||||
* @constructor
|
||||
* @param list - The list of items to search through
|
||||
* @param options - Configuration options for the search algorithm
|
||||
*/
|
||||
declare var Fuse: {
|
||||
new(list: any[], options?: FuseOptions): FuseInstance;
|
||||
};
|
||||
|
||||
/** Instead of providing a (nested) key as a string, an object can be defined that can specify weight and a custom get function */
|
||||
interface FuseKey {
|
||||
/**
|
||||
* The name of they key. Supports nested paths.
|
||||
*/
|
||||
name: string;
|
||||
/**
|
||||
* You can allocate a weight to keys to give them higher (or lower) values in search results. The weight value has to be greater than 0. When a weight isn't provided, it will default to 1.
|
||||
* @default 1
|
||||
*/
|
||||
weight?: number;
|
||||
/**
|
||||
* Function to retrieve an object's value at the specified path. The default searches nested paths.
|
||||
* @default (obj: T, path: string | string[]) => string | string[]
|
||||
*/
|
||||
getFn?: (any) => string;
|
||||
}
|
||||
|
||||
/** Configuration options for the Fuse search algorithm */
|
||||
interface FuseOptions {
|
||||
/**
|
||||
* List of keys that will be searched. Supports nested paths, weighted search, and searching in arrays of strings and objects.
|
||||
* @default []
|
||||
*/
|
||||
keys?: string[] | FuseKey[];
|
||||
|
||||
/**
|
||||
* How much distance one character can be from another to be considered a match.
|
||||
* @default 100
|
||||
*/
|
||||
distance?: number;
|
||||
|
||||
/**
|
||||
* At what point the match algorithm gives up. A threshold of 0.0 requires a perfect match, while 1.0 matches everything.
|
||||
* @default 0.6
|
||||
*/
|
||||
threshold?: number;
|
||||
|
||||
/**
|
||||
* Whether the score should be included in the result set. A score of 0 indicates a perfect match, while a score of 1 indicates a complete mismatch.
|
||||
* @default false
|
||||
*/
|
||||
includeScore?: boolean;
|
||||
|
||||
/**
|
||||
* Indicates whether comparisons should be case-sensitive.
|
||||
* @default false
|
||||
*/
|
||||
isCaseSensitive?: boolean;
|
||||
|
||||
/**
|
||||
* Whether the matches should be included in the result set. When true, each record in the result set will include the indices of matched characters.
|
||||
* @default false
|
||||
*/
|
||||
includeMatches?: boolean;
|
||||
|
||||
/**
|
||||
* Only matches whose length exceeds this value will be returned.
|
||||
* @default 1
|
||||
*/
|
||||
minMatchCharLength?: number;
|
||||
|
||||
/**
|
||||
* Whether to sort the result list by score.
|
||||
* @default true
|
||||
*/
|
||||
shouldSort?: boolean;
|
||||
|
||||
/**
|
||||
* When true, the matching function will continue to the end of a search pattern even if a perfect match has already been found.
|
||||
* @default false
|
||||
*/
|
||||
findAllMatches?: boolean;
|
||||
|
||||
/**
|
||||
* Determines approximately where in the text the pattern is expected to be found.
|
||||
* @default 0
|
||||
*/
|
||||
location?: number;
|
||||
|
||||
/**
|
||||
* When true, search will ignore location and distance, so it won't matter where in the string the pattern appears.
|
||||
* @default false
|
||||
*/
|
||||
ignoreLocation?: boolean;
|
||||
|
||||
/**
|
||||
* When true, it enables the use of Unix-like search commands.
|
||||
* @default false
|
||||
*/
|
||||
useExtendedSearch?: boolean;
|
||||
|
||||
/**
|
||||
* Function to retrieve an object's value at the specified path. The default searches nested paths.
|
||||
* @default (obj: T, path: string | string[]) => string | string[]
|
||||
*/
|
||||
getFn?: (obj: any, path: string | string[]) => string | string[];
|
||||
|
||||
/**
|
||||
* Function to sort the results. The default sorts by ascending relevance score.
|
||||
* @default (a, b) => number
|
||||
*/
|
||||
sortFn?: (a: any, b: any) => number;
|
||||
|
||||
/**
|
||||
* When true, the calculation for the relevance score will ignore the field-length norm.
|
||||
* @default false
|
||||
*/
|
||||
ignoreFieldNorm?: boolean;
|
||||
|
||||
/**
|
||||
* Determines how much the field-length norm affects scoring. 0 is equivalent to ignoring the field-length norm, while higher values increase the effect.
|
||||
* @default 1
|
||||
*/
|
||||
fieldNormWeight?: number;
|
||||
}
|
||||
|
||||
|
||||
/** Represents an individual Fuse search result */
|
||||
interface FuseResult {
|
||||
/** The original item that was matched */
|
||||
item: any;
|
||||
/** The index of the item from the original input collection that was searched */
|
||||
refIndex: number;
|
||||
/** The search score, where 0 is a perfect match and 1 is the worst */
|
||||
score?: number;
|
||||
/** Optional list of matched search keys */
|
||||
matches?: Array<{ key: string; indices: [number, number][] }>;
|
||||
}
|
||||
|
||||
/** Represents a Fuse instance, used for performing searches */
|
||||
interface FuseInstance {
|
||||
/**
|
||||
* Searches through the list using the specified query.
|
||||
* @param query - The search term or phrase to use
|
||||
* @returns An array of search results matching the query
|
||||
*/
|
||||
search(query: string): FuseResult[];
|
||||
}
|
||||
|
||||
//#endregion
|
||||
|
||||
//#region select2
|
||||
|
||||
/** Options for configuring a select2 instance */
|
||||
|
|
|
@ -6756,7 +6756,6 @@
|
|||
<script src="lib/cropper.min.js"></script>
|
||||
<script src="lib/jquery-cropper.min.js"></script>
|
||||
<script src="lib/toastr.min.js"></script>
|
||||
<script src="lib/fuse.js"></script>
|
||||
<script src="lib/select2.min.js"></script>
|
||||
<script src="lib/select2-search-placeholder.js"></script>
|
||||
<script src="lib/seedrandom.min.js"></script>
|
||||
|
|
2240
public/lib/fuse.js
2240
public/lib/fuse.js
File diff suppressed because it is too large
Load Diff
|
@ -1,3 +1,5 @@
|
|||
import { Fuse } from './lib.js';
|
||||
|
||||
import { humanizedDateTime, favsToHotswap, getMessageTimeStamp, dragElement, isMobile, initRossMods, shouldSendOnEnter, addSafariPatch } from './scripts/RossAscends-mods.js';
|
||||
import { userStatsHandler, statMesProcess, initStats } from './scripts/stats.js';
|
||||
import {
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
import { Fuse } from '../lib.js';
|
||||
|
||||
import { callPopup, chat_metadata, eventSource, event_types, generateQuietPrompt, getCurrentChatId, getRequestHeaders, getThumbnailUrl, saveSettingsDebounced } from '../script.js';
|
||||
import { saveMetadataDebounced } from './extensions.js';
|
||||
import { SlashCommand } from './slash-commands/SlashCommand.js';
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
import { Fuse } from '../../../lib.js';
|
||||
|
||||
import { event_types, eventSource, main_api, saveSettingsDebounced } from '../../../script.js';
|
||||
import { extension_settings, renderExtensionTemplateAsync } from '../../extensions.js';
|
||||
import { callGenericPopup, Popup, POPUP_RESULT, POPUP_TYPE } from '../../popup.js';
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
import { Fuse } from '../../../lib.js';
|
||||
|
||||
import { callPopup, eventSource, event_types, generateRaw, getRequestHeaders, main_api, online_status, saveSettingsDebounced, substituteParams, substituteParamsExtended, system_message_types } from '../../../script.js';
|
||||
import { dragElement, isMobile } from '../../RossAscends-mods.js';
|
||||
import { getContext, getApiUrl, modules, extension_settings, ModuleWorkerWrapper, doExtrasFetch, renderExtensionTemplateAsync } from '../../extensions.js';
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
import { Fuse } from '../lib.js';
|
||||
|
||||
import {
|
||||
shuffle,
|
||||
onlyUnique,
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
* By CncAnon (@CncAnon1)
|
||||
* https://github.com/CncAnon1/TavernAITurbo
|
||||
*/
|
||||
import { Fuse } from '../lib.js';
|
||||
|
||||
import {
|
||||
abortStatusCheck,
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
import { Fuse } from '../lib.js';
|
||||
|
||||
import {
|
||||
saveSettingsDebounced,
|
||||
scrollChatToBottom,
|
||||
|
@ -1823,7 +1825,7 @@ async function loadContextSettings() {
|
|||
/**
|
||||
* Fuzzy search characters by a search term
|
||||
* @param {string} searchValue - The search term
|
||||
* @returns {FuseResult[]} Results as items with their score
|
||||
* @returns {import('fuse.js').FuseResult<any>[]} Results as items with their score
|
||||
*/
|
||||
export function fuzzySearchCharacters(searchValue) {
|
||||
// @ts-ignore
|
||||
|
@ -1856,7 +1858,7 @@ export function fuzzySearchCharacters(searchValue) {
|
|||
* Fuzzy search world info entries by a search term
|
||||
* @param {*[]} data - WI items data array
|
||||
* @param {string} searchValue - The search term
|
||||
* @returns {FuseResult[]} Results as items with their score
|
||||
* @returns {import('fuse.js').FuseResult<any>[]} Results as items with their score
|
||||
*/
|
||||
export function fuzzySearchWorldInfo(data, searchValue) {
|
||||
// @ts-ignore
|
||||
|
@ -1885,7 +1887,7 @@ export function fuzzySearchWorldInfo(data, searchValue) {
|
|||
* Fuzzy search persona entries by a search term
|
||||
* @param {*[]} data - persona data array
|
||||
* @param {string} searchValue - The search term
|
||||
* @returns {FuseResult[]} Results as items with their score
|
||||
* @returns {import('fuse.js').FuseResult<any>[]} Results as items with their score
|
||||
*/
|
||||
export function fuzzySearchPersonas(data, searchValue) {
|
||||
data = data.map(x => ({ key: x, name: power_user.personas[x] ?? '', description: power_user.persona_descriptions[x]?.description ?? '' }));
|
||||
|
@ -1909,7 +1911,7 @@ export function fuzzySearchPersonas(data, searchValue) {
|
|||
/**
|
||||
* Fuzzy search tags by a search term
|
||||
* @param {string} searchValue - The search term
|
||||
* @returns {FuseResult[]} Results as items with their score
|
||||
* @returns {import('fuse.js').FuseResult<any>[]} Results as items with their score
|
||||
*/
|
||||
export function fuzzySearchTags(searchValue) {
|
||||
// @ts-ignore
|
||||
|
@ -1931,7 +1933,7 @@ export function fuzzySearchTags(searchValue) {
|
|||
/**
|
||||
* Fuzzy search groups by a search term
|
||||
* @param {string} searchValue - The search term
|
||||
* @returns {FuseResult[]} Results as items with their score
|
||||
* @returns {import('fuse.js').FuseResult<any>[]} Results as items with their score
|
||||
*/
|
||||
export function fuzzySearchGroups(searchValue) {
|
||||
// @ts-ignore
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
import { Fuse } from '../lib.js';
|
||||
|
||||
import {
|
||||
amount_gen,
|
||||
characters,
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
import { Fuse } from '../lib.js';
|
||||
|
||||
import {
|
||||
Generate,
|
||||
UNIQUE_APIS,
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
import { Fuse } from '../lib.js';
|
||||
|
||||
import { saveSettingsDebounced } from '../script.js';
|
||||
import { callGenericPopup, POPUP_TYPE } from './popup.js';
|
||||
import { power_user } from './power-user.js';
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
import { Fuse } from '../lib.js';
|
||||
|
||||
import { saveSettings, callPopup, substituteParams, getRequestHeaders, chat_metadata, this_chid, characters, saveCharacterDebounced, menu_type, eventSource, event_types, getExtensionPromptByName, saveMetadata, getCurrentChatId, extension_prompt_roles } from '../script.js';
|
||||
import { download, debounce, initScrollHeight, resetScrollHeight, parseJsonFile, extractDataFromPng, getFileBuffer, getCharaFilename, getSortableDelay, escapeRegex, PAGINATION_TEMPLATE, navigation_option, waitUntilCondition, isTrueBoolean, setValueByPath, flashHighlight, select2ModifyOptions, getSelect2OptionId, dynamicSelect2DataViaAjax, highlightRegex, select2ChoiceClickSubscribe, isFalseBoolean, getSanitizedFilename, checkOverwriteExistingData, getStringHash, parseStringArray, cancelDebounce } from './utils.js';
|
||||
import { extension_settings, getContext } from './extensions.js';
|
||||
|
|
Loading…
Reference in New Issue