/* eslint-disable spaced-comment, max-classes-per-file */ /// declare module 'minim' { export type Meta = Record; export type Attributes = Record; export type Predicate = (element: Element) => boolean; type Callback = (element: Element) => void; export function refract(value: any): Element; export class Element { static refract(value: any, options?: Record): Element; public element: string; public meta: ObjectElement; public attributes: ObjectElement; public classes: ArrayElement; public children: ArraySlice; public parent: Element; public content: Array; constructor(content?: Array, meta?: Meta, attributes?: Attributes); set id(element: Element); get id(): Element; equals(value: any): boolean; toValue(): any; getMetaProperty(name: string, value?: any): any; setMetaProperty(name: string, value: any): void; freeze(): void; clone(): Element; primitive(): string | undefined; [key: string]: unknown; } interface Type extends Element { new (...args: any[]): T; } type ExtendingElement = Record; export class Namespace { get elements(): Record; toRefract(element: Element): JSON; toElement(value: any): Element; fromRefract(doc: Record | Array): Element; register(name: string, elementClass: any): Namespace; detect(test: any, elementClass: any, givenPrepend: boolean): Namespace; use(plugin: NamespacePlugin): Namespace; getElementClass(element: string): typeof Element; } export interface NamespacePluginOptions { base: Namespace; } export interface NamespacePlugin { namespace(options: NamespacePluginOptions): Namespace; } export class StringElement extends Element { constructor(content?: string, meta?: Meta, attributes?: Attributes); } export class NumberElement extends Element { constructor(content?: number, meta?: Meta, attributes?: Attributes); } export class NullElement extends Element {} export class BooleanElement extends Element { constructor(content?: boolean, meta?: Meta, attributes?: Attributes); } export class ArrayElement extends Element { constructor(content?: unknown[], meta?: Meta, attributes?: Attributes); first: Element | undefined; second: Element | undefined; get(index: string | number): any; set(index: string | number, element: Element): void; find(predicate: Predicate): ArraySlice; findElements(condition: Predicate, givenOptions: any): Array; filter(predicate: Predicate): ArraySlice; contains(value: any): boolean; includes(value: any): boolean; push(value: any): ArrayElement; concat(value: ArrayElement): ArrayElement; ['fantasy-land/map'](transform: any): ArrayElement; forEach(callback: (item: Element, index: number) => void, thisArg?: unknown): void; [Symbol.iterator](): IterableIterator; get length(): number; map(callback: (element: Element) => Element, thisArg?: unknown): Array; } export class ObjectElement extends ArrayElement { constructor(content?: Record, meta?: Meta, attributes?: Attributes); remove(name: string): Element; set(key: string | StringElement | number, value: any): ObjectElement; hasKey(value: string): boolean; getKey(value: string): StringElement; getMember(key: string): MemberElement; // @ts-ignore forEach( callback: (value: Element, key: Element, item: Element) => void, thisArg?: unknown, ): void; map( callback: (value: Element, key: Element, member: MemberElement) => MemberElement, thisArg?: unknown, ): Array; keys(): unknown[]; } export class MemberElement extends Element { constructor(key?: unknown, value?: unknown, meta?: Meta, attributes?: Attributes); get key(): unknown; set key(key: unknown); get value(): unknown; set value(value: unknown); } export class LinkElement extends Element { constructor(content?: unknown, meta?: Meta, attributes?: Attributes); get relation(): string; set relation(relation: string); get href(): string; set href(key: string); } export class RefElement extends Element { constructor(content?: unknown, meta?: Meta, attributes?: Attributes); get path(): string; set path(path: string); } export class ArraySlice { constructor(elements?: Array); get length(): number; get first(): Element; get isEmpty(): boolean; filter(predicate: Predicate, thisArg?: unknown): ArraySlice; reject(predicate: Predicate, thisArg?: unknown): ArraySlice; forEach(callback: Callback): void; reduce(callback: (acc: T, cur: Element) => T, initialValue: T): ArraySlice; map(callback: (currentValue: any, index: number) => any, thisArg?: unknown): ArraySlice; hasKey(value: string): boolean; get(index: number): T; [Symbol.iterator](): IterableIterator; toValue(): any; clone(): ArraySlice; } export class ObjectSlice extends ArraySlice { clone(): ObjectSlice; } export class KeyValuePair { public key: Element | undefined; public value: Element | undefined; constructor(key?: Element, value?: Element); clone(): KeyValuePair; } }