UNPKG

@ima/core

Version:

IMA.js framework for isomorphic javascript application

136 lines 4.65 kB
import { RouteParams } from './AbstractRoute'; import { AbstractRouter } from './AbstractRouter'; import { RouteFactory } from './RouteFactory'; import { RouteAction, RouteLocals, RouteOptions } from './Router'; import { Settings } from '../boot'; import { Dispatcher } from '../event/Dispatcher'; import { Dependencies } from '../oc/ObjectContainer'; import { PageManager } from '../page/manager/PageManager'; import { StringParameters, UnknownParameters } from '../types'; import { Window } from '../window/Window'; /** * The client-side implementation of the {@link Router} interface. */ export declare class ClientRouter extends AbstractRouter { #private; protected _window: Window; protected _boundHandleClick: (event: Event) => void; protected _boundHandlePopState: (event: Event) => void; /** * Mounted promise to prevent routing until app is fully mounted. */ protected _mountedPromise: { promise: Promise<void>; resolve: () => void; reject: () => void; } | null; static get $dependencies(): Dependencies; /** * Initializes the client-side router. * * @param pageManager The page manager handling UI rendering, * and transitions between pages if at the client side. * @param factory Factory for routes. * @param dispatcher Dispatcher fires events to app. * @param window The current global client-side APIs provider. * @param settings $Router settings. */ constructor(pageManager: PageManager, factory: RouteFactory, dispatcher: Dispatcher, window: Window, settings: Settings['$Router'] | number); /** * @inheritDoc */ init(config: { $Protocol: string; $Root: string; $LanguagePartPath: string; $Host: string; }): this; /** * @inheritDoc */ getUrl(): string; /** * @inheritDoc */ getPath(): string; /** * @inheritDoc */ listen(): this; /** * @inheritDoc */ unlisten(): this; /** * @inheritDoc */ redirect(url: string, options?: Partial<RouteOptions>, action?: RouteAction, locals?: RouteLocals): void; /** * @inheritDoc */ route(path: string, options?: Partial<RouteOptions>, action?: RouteAction, locals?: RouteLocals): Promise<void | UnknownParameters>; /** * @inheritDoc */ handleError(params: RouteParams, options?: Partial<RouteOptions>, locals?: RouteLocals): Promise<void | UnknownParameters>; /** * @inheritDoc */ handleNotFound(params: StringParameters, options?: {}, locals?: {}): Promise<void | UnknownParameters>; /** * Handle a fatal error application state. IMA handle fatal error when IMA * handle error. * * @param error */ _handleFatalError(error: Error): void; /** * Handles a popstate event. The method is performed when the active history * entry changes. * * The navigation will be handled by the router if the event state is defined * and event is not `defaultPrevented`. * * @param event The popstate event. */ _handlePopState(event: PopStateEvent): void; /** * Handles a click event. The method performs navigation to the target * location of the anchor (if it has one). * * The navigation will be handled by the router if the protocol and domain * of the anchor's target location (href) is the same as the current, * otherwise the method results in a hard redirect. * * @param event The click event. */ _handleClick(event: MouseEvent): void; /** * The method determines whether an anchor element or a child of an anchor * element has been clicked, and if it was, the method returns anchor * element else null. * * @param {Node} target * @return {?Node} */ _getAnchorElement(target: Node): Node; /** * Tests whether the provided target URL contains only an update of the * hash fragment of the current URL. * * @param targetUrl The target URL. * @return `true` if the navigation to target URL would * result only in updating the hash fragment of the current URL. */ _isHashLink(targetUrl: string): boolean; /** * Tests whether the the protocol and domain of the provided URL are the * same as the current. * * @param [url=''] The URL. * @return `true` if the protocol and domain of the * provided URL are the same as the current. */ _isSameDomain(url?: string): boolean; } //# sourceMappingURL=ClientRouter.d.ts.map