{"version":3,"file":"wrapCreateRouter.mjs","names":[],"sources":["../../../src/domain/tanstackRouter/wrapCreateRouter.ts"],"sourcesContent":["import { startTanStackRouterView } from './startTanStackRouterView'\nimport type { AnyTanStackCreateRouter } from './types'\n\n/**\n * Wraps TanStack Router's `createRouter` to automatically track route changes as RUM views.\n *\n * Subscribes to the `onLoad` event which fires after loaders complete but before rendering.\n * This is the earliest event where route matches are up to date, ensuring rendering-related\n * events (resources, errors) are attributed to the correct view. Only creates a new view\n * when the pathname changes (query param and hash changes are ignored).\n */\nexport function wrapCreateRouter<CreateRouter extends AnyTanStackCreateRouter>(\n  originalCreateRouter: CreateRouter\n): CreateRouter {\n  return ((options: any) => {\n    const router = originalCreateRouter(options)\n\n    // onLoad fires for the initial navigation too, so no explicit initial view call is needed\n    router.subscribe('onLoad', (event) => {\n      if (!event.pathChanged) {\n        return\n      }\n      startTanStackRouterView(router.state.matches)\n    })\n\n    return router\n  }) as CreateRouter\n}\n"],"mappings":";;;;;;;;;;AAWA,SAAgB,iBACd,sBACc;CACd,SAAS,YAAiB;EACxB,MAAM,SAAS,qBAAqB,OAAO;EAG3C,OAAO,UAAU,WAAW,UAAU;GACpC,IAAI,CAAC,MAAM,aACT;GAEF,wBAAwB,OAAO,MAAM,OAAO;EAC9C,CAAC;EAED,OAAO;CACT;AACF"}