@adobe/aem-spa-page-model-manager
Version:
An interpreter between AEM Editor and the AEM SPA Editor.
100 lines • 2.97 kB
TypeScript
/**
* <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>
*
* <h2>Configuration</h2>
*
* <p>The Model Router can be configured using meta properties located in the head section of the document.</p>
*
* <h3>Meta properties</h3>
* <ul>
* <li>cq:page_model_router - default=undefined, options=disable</li>
* <li>cq:page_model_route_filters - default=undefined, options=RegExp<></li>
* </ul>
*
* <h3>Defaults</h3>
* <ul>
* <li>The ModelRouter is enabled and uses the <i>History</i> API to extract the model path from the current content path</li>
* </ul>
*
* <h3>Examples and Usages</h3>
*
* <h4>Disables the page model router</h4>
* <pre>
* <code>e.g. <meta property="cq:page_model_router" content="disable"\></code>
* </pre>
*
* <h4>Filters paths from the model routing with the given patterns</h4>
* <pre>
* <code>e.g. <meta property="cq:page_model_route_filters" content="route/not/found,^(.*)(?:exclude/path)(.*)"\></code>
* </pre>
*
* @module ModelRouter
*/
/**
* Modes in which the Model Router operates.
* @private
*/
export declare class RouterModes {
/**
* Flag that indicates that the model router should be disabled.
*/
static readonly DISABLED = "disabled";
/**
* Flag that indicates that the model router should extract the model path from the content path section of the URL.
*/
static readonly CONTENT_PATH = "path";
private constructor();
}
/**
* Returns the model path. If no URL is provided the current window URL is used
* @param [url] url from which to extract the model path
* @private
* @return
*/
export declare function getModelPath(url?: string | null | URL): string | null;
/**
* Returns the list of provided route filters
*
* @returns {string[]}
*
* @private
*/
export declare function getRouteFilters(): string[];
/**
* Should the route be excluded
*
* @param route
* @returns {boolean}
*
* @private
*/
export declare function isRouteExcluded(route: string): boolean;
/**
* Is the model router enabled. Enabled by default
* @returns {boolean}
* @private
*/
export declare function isModelRouterEnabled(): boolean;
/**
* Fetches the model from the PageModelManager and then dispatches it
*
* @fires cq-pagemodel-route-changed
*
* @param {string} [path] - path of the model to be dispatched
*
* @private
*/
export declare function dispatchRouteChanged(path: string): void;
/**
* Triggers the PageModelManager to fetch data based on the current route
*
* @fires cq-pagemodel-route-changed - with the root page model object
*
* @param {string} [url] - url from which to extract the model path
*
* @private
*/
export declare function routeModel(url?: string | undefined | null | URL): void;
export declare function initModelRouter(): void;
//# sourceMappingURL=ModelRouter.d.ts.map