UNPKG

@bespunky/angular-zen

Version:

The Angular tools you always wished were there.

78 lines (73 loc) 3.57 kB
import * as i0 from '@angular/core'; import { Component, NgModule } from '@angular/core'; /** A multi-level route string for. */ const DeepRoutePath = '/deeply/nested/route/for/testing'; /** * The segments of `DeepRoutePath`. First element will always be '' (empty string) as the route begins with a forward slash. * Use `DeepRouteSegmentsNoRoot` for an array of segments without the root ''. */ const DeepRouteSegments = ['', 'deeply', 'nested', 'route', 'for', 'testing']; // For some reasone `DeepRoutePath.split('/')` causes a stack overflow when building with --prod. /** * The segments of `DeepRoutePath` without the root route (the '' route). * Use `DeepRouteSegments` for an array of segments with the root ''. */ const DeepRouteSegmentsNoRoot = DeepRouteSegments.slice(1); /** * Recoursively creates nested routes for the specified segments. * Each specified segment will be a child route of its previous segment. * * #### Example * Running the function on `['some', 'route']` will result in the following supported routes: * / * * /some * /some/route * * @export * @param {string[]} segments The route segments from which routes are to be created. * @returns {Route} An Angular router module compatible route tree containing all segments as child routes. */ function createDeeplyNestedRoutes(segments) { const parent = { path: segments[0], component: NoopComponent, children: [] }; if (segments.length > 1) { const nestedChildren = createDeeplyNestedRoutes(segments.slice(1)); // Add the route tree to the node parent.children.push(nestedChildren); } return parent; } /** * A functionless component. * Can be used for setting routes in which the component is not important, but required by the route object. * * @export * @class NoopComponent */ class NoopComponent { } NoopComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.2.12", ngImport: i0, type: NoopComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); NoopComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "14.2.12", type: NoopComponent, selector: "zen-router-x-noop", ngImport: i0, template: '<div>noop</div>', isInline: true }); i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.2.12", ngImport: i0, type: NoopComponent, decorators: [{ type: Component, args: [{ selector: 'zen-router-x-noop', template: '<div>noop</div>' }] }] }); /** * A functionless module exporting the functionless `NoopComponent`. * * @export * @class NoopModule */ class NoopModule { } NoopModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.2.12", ngImport: i0, type: NoopModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule }); NoopModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "14.2.12", ngImport: i0, type: NoopModule, declarations: [NoopComponent], exports: [NoopComponent] }); NoopModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "14.2.12", ngImport: i0, type: NoopModule }); i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.2.12", ngImport: i0, type: NoopModule, decorators: [{ type: NgModule, args: [{ declarations: [NoopComponent], exports: [NoopComponent] }] }] }); /** * Generated bundle index. Do not edit. */ export { DeepRoutePath, DeepRouteSegments, DeepRouteSegmentsNoRoot, NoopComponent, NoopModule, createDeeplyNestedRoutes }; //# sourceMappingURL=bespunky-angular-zen-router-x-testing.mjs.map