|
|
|
|
|
type StringOrRegExp = string | RegExp; |
|
|
type PluginModuleType = "js" | "jsx" | "ts" | "tsx" | "json" | "text" | "base64" | "dataurl" | "binary" | "empty" | (string & {}); |
|
|
type FilterExpressionKind = FilterExpression["kind"]; |
|
|
type FilterExpression = And | Or | Not | Id | ModuleType | Code | Query; |
|
|
type TopLevelFilterExpression = Include | Exclude; |
|
|
declare class And { |
|
|
kind: "and"; |
|
|
args: FilterExpression[]; |
|
|
constructor(...args: FilterExpression[]); |
|
|
} |
|
|
declare class Or { |
|
|
kind: "or"; |
|
|
args: FilterExpression[]; |
|
|
constructor(...args: FilterExpression[]); |
|
|
} |
|
|
declare class Not { |
|
|
kind: "not"; |
|
|
expr: FilterExpression; |
|
|
constructor(expr: FilterExpression); |
|
|
} |
|
|
interface QueryFilterObject { |
|
|
[key: string]: StringOrRegExp | boolean; |
|
|
} |
|
|
interface IdParams { |
|
|
cleanUrl?: boolean; |
|
|
} |
|
|
declare class Id { |
|
|
kind: "id"; |
|
|
pattern: StringOrRegExp; |
|
|
params: IdParams; |
|
|
constructor(pattern: StringOrRegExp, params?: IdParams); |
|
|
} |
|
|
declare class ModuleType { |
|
|
kind: "moduleType"; |
|
|
pattern: PluginModuleType; |
|
|
constructor(pattern: PluginModuleType); |
|
|
} |
|
|
declare class Code { |
|
|
kind: "code"; |
|
|
pattern: StringOrRegExp; |
|
|
constructor(expr: StringOrRegExp); |
|
|
} |
|
|
declare class Query { |
|
|
kind: "query"; |
|
|
key: string; |
|
|
pattern: StringOrRegExp | boolean; |
|
|
constructor(key: string, pattern: StringOrRegExp | boolean); |
|
|
} |
|
|
declare class Include { |
|
|
kind: "include"; |
|
|
expr: FilterExpression; |
|
|
constructor(expr: FilterExpression); |
|
|
} |
|
|
declare class Exclude { |
|
|
kind: "exclude"; |
|
|
expr: FilterExpression; |
|
|
constructor(expr: FilterExpression); |
|
|
} |
|
|
declare function and(...args: FilterExpression[]): And; |
|
|
declare function or(...args: FilterExpression[]): Or; |
|
|
declare function not(expr: FilterExpression): Not; |
|
|
declare function id(pattern: StringOrRegExp, params?: IdParams): Id; |
|
|
declare function moduleType(pattern: PluginModuleType): ModuleType; |
|
|
declare function code(pattern: StringOrRegExp): Code; |
|
|
declare function query(key: string, pattern: StringOrRegExp | boolean): Query; |
|
|
declare function include(expr: FilterExpression): Include; |
|
|
declare function exclude(expr: FilterExpression): Exclude; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
declare function queries(queryFilter: QueryFilterObject): And; |
|
|
declare function interpreter(exprs: TopLevelFilterExpression | TopLevelFilterExpression[], code?: string, id?: string, moduleType?: PluginModuleType): boolean; |
|
|
interface InterpreterCtx { |
|
|
urlSearchParamsCache?: URLSearchParams; |
|
|
} |
|
|
declare function interpreterImpl(expr: TopLevelFilterExpression[], code?: string, id?: string, moduleType?: PluginModuleType, ctx?: InterpreterCtx): boolean; |
|
|
declare function exprInterpreter(expr: FilterExpression, code?: string, id?: string, moduleType?: PluginModuleType, ctx?: InterpreterCtx): boolean; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
declare function exactRegex(str: string, flags?: string): RegExp; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
declare function prefixRegex(str: string, flags?: string): RegExp; |
|
|
type WidenString<T> = T extends string ? string : T; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
declare function makeIdFiltersToMatchWithQuery<T extends string | RegExp>(input: T): WidenString<T>; |
|
|
declare function makeIdFiltersToMatchWithQuery<T extends string | RegExp>(input: readonly T[]): WidenString<T>[]; |
|
|
declare function makeIdFiltersToMatchWithQuery(input: string | RegExp | readonly (string | RegExp)[]): string | RegExp | (string | RegExp)[]; |
|
|
|
|
|
export { FilterExpression, FilterExpressionKind, QueryFilterObject, TopLevelFilterExpression, and, code, exactRegex, exclude, exprInterpreter, id, include, interpreter, interpreterImpl, makeIdFiltersToMatchWithQuery, moduleType, not, or, prefixRegex, queries, query }; |