UNPKG

4.28 kBTypeScriptView Raw
1import { History } from 'aurelia-history';
2
3/**
4 * An implementation of the basic history API.
5 */
6export declare class BrowserHistory extends History {
7 /**
8 * Creates an instance of BrowserHistory
9 * @param linkHandler An instance of LinkHandler.
10 */
11 constructor(linkHandler: LinkHandler);
12 /**
13 * Activates the history object.
14 * @param options The set of options to activate history with.
15 * @returns Whether or not activation occurred.
16 */
17 activate(options?: Object): boolean;
18 /**
19 * Deactivates the history object.
20 */
21 deactivate(): void;
22 /**
23 * Returns the fully-qualified root of the current history object.
24 * @returns The absolute root of the application.
25 */
26 getAbsoluteRoot(): string;
27 /**
28 * Causes a history navigation to occur.
29 *
30 * @param fragment The history fragment to navigate to.
31 * @param options The set of options that specify how the navigation should occur.
32 * @return Promise if triggering navigation, otherwise true/false indicating if navigation occurred.
33 */
34 navigate(fragment?: string, { trigger, replace }?: {
35 trigger?: boolean;
36 replace?: boolean;
37 }): boolean;
38 /**
39 * Causes the history state to navigate back.
40 */
41 navigateBack(): void;
42 /**
43 * Sets the document title.
44 */
45 setTitle(title: string): void;
46 /**
47 * Sets a key in the history page state.
48 * @param key The key for the value.
49 * @param value The value to set.
50 */
51 setState(key: string, value: any): void;
52 /**
53 * Gets a key in the history page state.
54 * @param key The key for the value.
55 * @return The value for the key.
56 */
57 getState(key: string): any;
58 /**
59 * Returns the current index in the navigation history.
60 * @returns The current index.
61 */
62 getHistoryIndex(): number;
63 /**
64 * Move to a specific position in the navigation history.
65 * @param movement The amount of steps, positive or negative, to move.
66 */
67 go(movement: number): void;
68}
69/**
70 * Provides information about how to handle an anchor event.
71 */
72export interface AnchorEventInfo {
73 /**
74 * Indicates whether the event should be handled or not.
75 */
76 shouldHandleEvent: boolean;
77 /**
78 * The href of the link or null if not-applicable.
79 */
80 href: string;
81 /**
82 * The anchor element or null if not-applicable.
83 */
84 anchor: Element;
85}
86/**
87 * Class responsible for handling interactions that should trigger browser history navigations.
88 */
89export declare class LinkHandler {
90 /**
91 * Activate the instance.
92 *
93 * @param history The BrowserHistory instance that navigations should be dispatched to.
94 */
95 activate(history: BrowserHistory): void;
96 /**
97 * Deactivate the instance. Event handlers and other resources should be cleaned up here.
98 */
99 deactivate(): void;
100}
101/**
102 * The default LinkHandler implementation. Navigations are triggered by click events on
103 * anchor elements with relative hrefs when the history instance is using pushstate.
104 */
105export declare class DefaultLinkHandler extends LinkHandler {
106 /**
107 * Creates an instance of DefaultLinkHandler.
108 */
109 constructor();
110 /**
111 * Activate the instance.
112 *
113 * @param history The BrowserHistory instance that navigations should be dispatched to.
114 */
115 activate(history: BrowserHistory): void;
116 /**
117 * Deactivate the instance. Event handlers and other resources should be cleaned up here.
118 */
119 deactivate(): void;
120 /**
121 * Gets the href and a "should handle" recommendation, given an Event.
122 *
123 * @param event The Event to inspect for target anchor and href.
124 */
125 static getEventInfo(event: Event): AnchorEventInfo;
126 /**
127 * Finds the closest ancestor that's an anchor element.
128 *
129 * @param el The element to search upward from.
130 * @returns The link element that is the closest ancestor.
131 */
132 static findClosestAnchor(el: Element): Element;
133 /**
134 * Gets a value indicating whether or not an anchor targets the current window.
135 *
136 * @param target The anchor element whose target should be inspected.
137 * @returns True if the target of the link element is this window; false otherwise.
138 */
139 static targetIsThisWindow(target: Element): boolean;
140}
141/**
142 * Configures the plugin by registering BrowserHistory as the implementation of History in the DI container.
143 * @param config The FrameworkConfiguration object provided by Aurelia.
144 */
145export declare function configure(config: Object): void;
\No newline at end of file