Merged features tied to Carolina Reaper funding goal

This commit is contained in:
squidfunk
2022-12-07 11:11:02 +01:00
parent e0dce6cc1d
commit b550b1a532
118 changed files with 2544 additions and 1042 deletions

20
typings/_/index.d.ts vendored
View File

@@ -24,33 +24,13 @@ import { Observable, Subject } from "rxjs"
import { Keyboard, Viewport } from "~/browser"
import { Component } from "~/components"
import {
SearchIndex,
SearchTransformFn
} from "~/integrations"
/* ----------------------------------------------------------------------------
* Global types
* ------------------------------------------------------------------------- */
/**
* Global search configuration
*/
export interface GlobalSearchConfig {
transform?: SearchTransformFn /* Transformation function */
index?: Promise<SearchIndex> /* Alternate index */
worker?: string /* Alternate worker URL */
}
/* ------------------------------------------------------------------------- */
declare global {
/**
* Global search configuration
*/
const __search: GlobalSearchConfig | undefined
/**
* Compute hash from the given string
*

View File

@@ -27,5 +27,117 @@ import lunr from "lunr"
* ------------------------------------------------------------------------- */
declare global {
const lunr: typeof lunr /* Global Lunr.js namespace */
namespace lunr {
/**
* Index - expose inverted index
*/
interface Index {
invertedIndex: Record<string, unknown>
fields: string[] // @todo: make typing generic?
}
interface Builder {
field(
fieldName: string,
attributes?: {
boost?: number | undefined,
extractor?: Function
}): void;
}
/**
* Query parser
*/
class QueryParser {
constructor(value: string, query: Query)
public parse(): void
}
/**
* Query clause - add missing field definitions
*/
namespace Query {
interface Clause {
presence: Query.presence
}
}
/**
* Tokenizer
*/
namespace tokenizer {
let table: number[][]
}
/**
* Lexeme type
*/
const enum LexemeType {
FIELD = "FIELD",
TERM = "TERM",
PRESENCE = "PRESENCE"
}
/**
* Lexeme
*/
interface Lexeme {
type: LexemeType
str: string
start: number
end: number
}
/**
* Query lexer - add missing class definitions
*/
class QueryLexer {
/**
* Create query lexer
*
* @param query - Query
*/
constructor(query: string)
/**
* Query lexemes
*/
public lexemes: Lexeme[]
/**
* Lex query
*/
public run(): void
}
/**
* Enable multi-language support
*
* @param lang - Languages
*
* @returns Plugin
*/
function multiLanguage(...lang: string[]): Builder.Plugin
/**
* Stopword filter
*
* @template T - Token type
*
* @param token - Token or string
*
* @returns Token or nothing
*/
function stopWordFilter<T>(token: T): T | undefined;
/**
* Segmenter for Japanese
*/
class TinySegmenter {
public ctype_(value: string): string
public segment(value: string): string[]
}
}
}