UNPKG

@ribajs/router

Version:

Routing extension for Riba.js inspired by Barba.js

60 lines (59 loc) 3.04 kB
export * from "./Dom.js"; export * from "./Prefetch.js"; import { EventDispatcher } from "@ribajs/events"; import { BaseCache } from "@ribajs/cache"; import { Transition, Response, PjaxOptions } from "../../types/index.js"; import { HistoryManager } from "@ribajs/history"; export interface PjaxInstances { [key: string]: Pjax; } declare class Pjax { static cache: BaseCache<Promise<Response>>; static getInstance(id?: string): Pjax | undefined; protected static preventCheckUrl(href: string): boolean; static preventCheck(url: string, element?: HTMLAnchorElement | HTMLLinkElement | HTMLUnknownElement, evt?: Event): boolean; static getHref(el: HTMLAnchorElement | SVGAElement | HTMLLinkElement | HTMLUnknownElement): string | undefined; private static instances; history: HistoryManager; cacheEnabled: boolean; transitionProgress: boolean; protected listenAllLinks: boolean; protected listenPopstate: boolean; protected parseTitle: boolean; protected changeBrowserUrl: boolean; protected dispatcher: EventDispatcher; protected transition?: Transition; protected wrapper?: HTMLElement; protected viewId: string; protected containerSelector: string; protected prefetchLinks: boolean; protected scrollToAnchorOffset: number; constructor({ id, action, wrapper, containerSelector, listenAllLinks, listenPopstate, parseTitle, changeBrowserUrl, prefetchLinks, scrollToTop, scrollToAnchorOffset, }: PjaxOptions); setActiveWrapper(wrapper: HTMLElement): void; start(): void; getCurrentUrl(): string; goTo(url: string, newTab?: boolean): false | void | Promise<false | undefined>; getTransition(): Transition; prefetchLink(href: string): Promise<{ fromCache: boolean; responsePromise: Promise<Response>; }> | undefined; protected prefetchLinkElement(linkElement: HTMLLinkElement, head: HTMLHeadElement): void; protected removePrefetchLinks(head: HTMLHeadElement): void; protected replacePrefetchLinkElements(prefetchLinks: NodeListOf<HTMLLinkElement> | HTMLLinkElement[]): void; loadCached(url: string): Promise<HTMLElement>; loadResponseCached(url: string, forceCache?: boolean, fallback?: boolean): Promise<{ fromCache: boolean; responsePromise: Promise<Response>; }>; loadResponse(url: string, forceCache?: boolean): Promise<Response>; protected bindEvents(listenAllLinks: boolean, listenPopstate: boolean): void; forceGoTo(url: Location | string): void; protected onLinkClickIntern(evt: Event): false | Promise<void> | undefined; onLinkClick(evt: Event, el: HTMLAnchorElement, href: string, newTab?: boolean): Promise<void> | undefined; protected onStateChange(event?: Event, newUrl?: string): Promise<false | undefined>; protected onNewContainerLoaded(container: HTMLElement): void; protected onTransitionEnd(): void; protected init(wrapper: HTMLElement, listenAllLinks: boolean, listenPopstate: boolean): void; } export { Pjax };