UNPKG

3.19 kBTypeScriptView Raw
1/**
2 * Triggered by the ModelRouter when the route has changed.
3 *
4 * @event cq-pagemodel-route-changed
5 * @type {Object}
6 * @property {Object} detail
7 * @property {Object} detail.model - The page model object corresponding to the new route
8 */
9/**
10 * <p>The ModelRouter listens for HTML5 History API <i>popstate</i> events and calls {@link PageModelManager#getData()} with the model path it extracted from the URL.</p>
11 *
12 * <h2>Configuration</h2>
13 *
14 * <p>The Model Router can be configured using meta properties located in the head section of the document.</p>
15 *
16 * <h3>Meta properties</h3>
17 * <ul>
18 * <li>cq:page_model_router - default=undefined, options=disable</li>
19 * <li>cq:page_model_route_filters - default=undefined, options=RegExp<></li>
20 * </ul>
21 *
22 * <h3>Defaults</h3>
23 * <ul>
24 * <li>The ModelRouter is enabled and uses the <i>History</i> API to extract the model path from the current content path</li>
25 * </ul>
26 *
27 * <h3>Examples and Usages</h3>
28 *
29 * <h4>Disables the page model router</h4>
30 * <pre>
31 * <code>e.g. &lt;meta property="cq:page_model_router" content="disable"\&gt;</code>
32 * </pre>
33 *
34 * <h4>Filters paths from the model routing with the given patterns</h4>
35 * <pre>
36 * <code>e.g. &lt;meta property="cq:page_model_route_filters" content="route/not/found,^(.*)(?:exclude/path)(.*)"\&gt;</code>
37 * </pre>
38 *
39 * @module ModelRouter
40 */
41/**
42 * Modes in which the Model Router operates
43 *
44 * @type {{DISABLED: string, CONTENT_PATH: string}}
45 */
46export declare class RouterModes {
47 /**
48 * Flag that indicates that the model router should be disabled.
49 */
50 static readonly DISABLED = "disabled";
51 /**
52 * Flag that indicates that the model router should extract the model path from the content path section of the URL.
53 */
54 static readonly CONTENT_PATH = "path";
55 private constructor();
56}
57/**
58 * Returns the model path. If no URL is provided the current window URL is used
59 *
60 * @param {string} [url] - url from which to extract the model path
61 *
62 * @return {string}
63 */
64export declare function getModelPath(url?: string | null): string;
65/**
66 * Returns the list of provided route filters
67 *
68 * @returns {string[]}
69 *
70 * @private
71 */
72export declare function getRouteFilters(): string[];
73/**
74 * Should the route be excluded
75 *
76 * @param route
77 * @returns {boolean}
78 *
79 * @private
80 */
81export declare function isRouteExcluded(route: string): boolean;
82/**
83 * Is the model router enabled. Enabled by default
84 * @returns {boolean}
85 *
86 * @private
87 */
88export declare function isModelRouterEnabled(): boolean;
89/**
90 * Fetches the model from the PageModelManager and then dispatches it
91 *
92 * @fires cq-pagemodel-route-changed
93 *
94 * @param {string} [path] - path of the model to be dispatched
95 *
96 * @private
97 */
98export declare function dispatchRouteChanged(path: string): void;
99/**
100 * Triggers the PageModelManager to fetch data based on the current route
101 *
102 * @fires cq-pagemodel-route-changed - with the root page model object
103 *
104 * @param {string} [url] - url from which to extract the model path
105 *
106 * @private
107 */
108export declare function routeModel(url?: string | null): void;
109//# sourceMappingURL=ModelRouter.d.ts.map
\No newline at end of file