{"version":3,"file":"spinque-angular-ui-router-outlet.mjs","sources":["../../../projects/spinque-angular-ui/router-outlet/src/router-outlet.directive.ts","../../../projects/spinque-angular-ui/router-outlet/src/route-reuse-strategy.service.ts","../../../projects/spinque-angular-ui/router-outlet/spinque-angular-ui-router-outlet.ts"],"sourcesContent":["import { Directive, ComponentRef } from '@angular/core';\nimport { ActivatedRoute, RouterOutlet } from '@angular/router';\n\nexport interface OnAttach {\n  /**\n   * A callback method that is invoked when the RouteReuseStrategy instructs\n   * to re-attach a previously detached component / subtree\n   */\n  onAttach(activatedRoute: ActivatedRoute): void;\n}\nexport interface OnDetach {\n  /**\n   * A callback method that is invoked when the RouteReuseStrategy instructs\n   * to detach component / subtree\n   */\n  onDetach(): void;\n}\n\n/**\n * SpinqueRouterOutlet provides a custom router outlet that reuses routes if 'reuseRoute' is set\n * to true in a Route's data object. Use this to make search results quicker and improve the\n * user experience when navigating between results and a detail page.\n */\n@Directive({\n  selector: 'spinque-router-outlet',\n  standalone: true\n})\nexport class SpinqueRouterOutlet extends RouterOutlet {\n  override detach(): ComponentRef<any> {\n    const instance: any = this.component;\n    if (instance && typeof instance.onDetach === 'function') {\n      instance.onDetach();\n    }\n    return super.detach();\n  }\n\n  override attach(ref: ComponentRef<any>, activatedRoute: ActivatedRoute): void {\n    super.attach(ref, activatedRoute);\n    if (ref.instance && typeof ref.instance.onAttach === 'function') {\n      ref.instance.onAttach(activatedRoute);\n    }\n  }\n}","import { Injectable } from '@angular/core';\nimport { RouteReuseStrategy, ActivatedRouteSnapshot, DetachedRouteHandle } from '@angular/router';\n\n/**\n * Implementation of the route reuse strategy based on data property 'reuseRoute'.\n * Also see: https://angular.io/api/router/RouteReuseStrategy\n */\n@Injectable({\n  providedIn: 'root'\n})\nexport class SpinqueRouteReuseStategy implements RouteReuseStrategy {\n  private storedRouteHandles = new Map<string, DetachedRouteHandle>();\n  private allowRetriveCache: { [key: string]: any } = {};\n\n  shouldDetach(route: ActivatedRouteSnapshot): boolean {\n    const path = this.getPath(route);\n    if (path && this.allowRetriveCache.hasOwnProperty(path)) {\n      return true;\n    }\n    return false;\n  }\n\n  store(route: ActivatedRouteSnapshot, detachedTree: DetachedRouteHandle): void {\n    const path = this.getPath(route);\n    if (path) {\n      this.storedRouteHandles.set(path, detachedTree);\n    }\n  }\n\n  shouldAttach(route: ActivatedRouteSnapshot): boolean {\n    const path = this.getPath(route);\n    if (path && this.allowRetriveCache[path]) {\n      return this.storedRouteHandles.has(path);\n    }\n    return false;\n  }\n\n  retrieve(route: ActivatedRouteSnapshot): DetachedRouteHandle | null {\n    const path = this.getPath(route);\n    if (path) {\n      return this.storedRouteHandles.get(path) as DetachedRouteHandle;\n    } else {\n      return null;\n    }\n  }\n\n  shouldReuseRoute(before: ActivatedRouteSnapshot, current: ActivatedRouteSnapshot): boolean {\n    // store if we can use the cache\n    const path = this.getPath(before);\n\n    if (\n      before.routeConfig &&\n      before.routeConfig.data &&\n      (typeof before.routeConfig.data['reuseRoute'] === 'boolean' || before.routeConfig.data['reuseRouteFrom']) &&\n      path !== undefined\n    ) {\n      // check if we come from the right place\n      const reuseFrom =\n        before.routeConfig.data['reuseRouteFrom'] && (before.routeConfig.data['reuseRouteFrom'] === current.routeConfig?.path || before.routeConfig.data['reuseRouteFrom'].includes(current.routeConfig?.path));\n\n      this.allowRetriveCache[path] = before.routeConfig.data['reuseRoute'] || reuseFrom;\n    }\n    return before.routeConfig === current.routeConfig;\n  }\n\n  private getPath(route: ActivatedRouteSnapshot): string | undefined {\n    if (route.routeConfig) {\n      const url = route.routeConfig.path;\n      return url;\n    }\n    return;\n  }\n}","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public_api';\n"],"names":[],"mappings":";;;;AAkBA;;;;AAIG;AAKG,MAAO,mBAAoB,SAAQ,YAAY,CAAA;IAC1C,MAAM,GAAA;AACb,QAAA,MAAM,QAAQ,GAAQ,IAAI,CAAC,SAAS;QACpC,IAAI,QAAQ,IAAI,OAAO,QAAQ,CAAC,QA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