@safaricom-mxl/web-sdk 0.0.7 → 0.0.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (29) hide show
  1. package/dist/instrumentations/navigation/NavigationInstrumentation/react/reactRouterV6Data/listenToRouterChanges.cjs +12 -11
  2. package/dist/instrumentations/navigation/NavigationInstrumentation/react/reactRouterV6Data/listenToRouterChanges.cjs.map +1 -1
  3. package/dist/instrumentations/navigation/NavigationInstrumentation/react/reactRouterV6Data/listenToRouterChanges.d.cts.map +1 -1
  4. package/dist/instrumentations/navigation/NavigationInstrumentation/react/reactRouterV6Data/listenToRouterChanges.d.ts.map +1 -1
  5. package/dist/instrumentations/navigation/NavigationInstrumentation/react/reactRouterV6Data/listenToRouterChanges.js +12 -11
  6. package/dist/instrumentations/navigation/NavigationInstrumentation/react/reactRouterV6Data/listenToRouterChanges.js.map +1 -1
  7. package/dist/instrumentations/navigation/NavigationInstrumentation/react/reactRouterV6Declarative/withMXLRouting.cjs +2 -1
  8. package/dist/instrumentations/navigation/NavigationInstrumentation/react/reactRouterV6Declarative/withMXLRouting.cjs.map +1 -1
  9. package/dist/instrumentations/navigation/NavigationInstrumentation/react/reactRouterV6Declarative/withMXLRouting.d.cts.map +1 -1
  10. package/dist/instrumentations/navigation/NavigationInstrumentation/react/reactRouterV6Declarative/withMXLRouting.d.ts.map +1 -1
  11. package/dist/instrumentations/navigation/NavigationInstrumentation/react/reactRouterV6Declarative/withMXLRouting.js +2 -1
  12. package/dist/instrumentations/navigation/NavigationInstrumentation/react/reactRouterV6Declarative/withMXLRouting.js.map +1 -1
  13. package/dist/mxl-web-sdk.js +1 -1
  14. package/dist/mxl-web-sdk.js.map +1 -1
  15. package/dist/resources/constants/index.cjs +1 -1
  16. package/dist/resources/constants/index.cjs.map +1 -1
  17. package/dist/resources/constants/index.d.cts +1 -1
  18. package/dist/resources/constants/index.d.ts +1 -1
  19. package/dist/resources/constants/index.js +1 -1
  20. package/dist/resources/constants/index.js.map +1 -1
  21. package/dist/transport/FetchTransport/FetchTransport.cjs +60 -10
  22. package/dist/transport/FetchTransport/FetchTransport.cjs.map +1 -1
  23. package/dist/transport/FetchTransport/FetchTransport.d.cts +3 -1
  24. package/dist/transport/FetchTransport/FetchTransport.d.cts.map +1 -1
  25. package/dist/transport/FetchTransport/FetchTransport.d.ts +3 -1
  26. package/dist/transport/FetchTransport/FetchTransport.d.ts.map +1 -1
  27. package/dist/transport/FetchTransport/FetchTransport.js +60 -11
  28. package/dist/transport/FetchTransport/FetchTransport.js.map +1 -1
  29. package/package.json +1 -1
@@ -10,17 +10,18 @@ const require_instrumentations_navigation_NavigationInstrumentation_instance = r
10
10
  *
11
11
  * Filtering by currentPathname ensures that we only consider routes that are relevant to the current URL.
12
12
  */
13
- const getRouteFromMatches = (matches, currentPathname) => matches.filter((m) => currentPathname.includes(m.pathname)).reduce((route, match) => {
14
- if (!match.route.path) return route;
15
- if (route) return {
16
- url: match.pathname,
17
- path: `${route.path}/${match.route.path}`
18
- };
19
- return {
20
- url: match.pathname,
21
- path: match.route.path
22
- };
23
- }, null);
13
+ const getRouteFromMatches = (matches, currentPathname) => {
14
+ const currentMatchIndex = matches.findIndex((match) => match.pathname === currentPathname);
15
+ if (currentMatchIndex === -1 || !matches[currentMatchIndex].route.path) return null;
16
+ return matches.slice(0, currentMatchIndex + 1).reduce((acc, match) => {
17
+ const routePath = match.route.path;
18
+ if (!routePath) return acc;
19
+ return {
20
+ path: routePath.startsWith("/") ? routePath : `${acc?.path ?? ""}/${routePath}`,
21
+ url: matches[currentMatchIndex].pathname
22
+ };
23
+ }, null);
24
+ };
24
25
  const listenToRouterChanges = ({ router, routesMatcher, config: { pathnameDocument = window.location } = {} }) => {
25
26
  const navigationInstrumentation = require_instrumentations_navigation_NavigationInstrumentation_instance.getNavigationInstrumentation();
26
27
  navigationInstrumentation.setInstrumentationType(require_constants_attributes.MXL_NAVIGATION_INSTRUMENTATIONS.Data);
@@ -1 +1 @@
1
- {"version":3,"file":"listenToRouterChanges.cjs","names":["getNavigationInstrumentation","MXL_NAVIGATION_INSTRUMENTATIONS"],"sources":["../../../../../../src/instrumentations/navigation/NavigationInstrumentation/react/reactRouterV6Data/listenToRouterChanges.ts"],"sourcesContent":["import type { Route } from '../../../../../api-page/index.ts';\nimport { MXL_NAVIGATION_INSTRUMENTATIONS } from '../../../../../constants/index.ts';\nimport { getNavigationInstrumentation } from '../../index.ts';\nimport type { ListenToRouterChangesArgs, Match } from './types.ts';\n\n/**\n * getRouteFromMatches goes through all the matches routes to build the full path\n * nested routes contain only the partial match, so we need to go through all of them\n * in order to build the full path.\n *\n * Filtering by currentPathname ensures that we only consider routes that are relevant to the current URL.\n */\nconst getRouteFromMatches = (\n matches: Match[],\n currentPathname: string,\n): Route | null =>\n matches\n .filter((m) => currentPathname.includes(m.pathname))\n .reduce<null | Route>((route, match) => {\n if (!match.route.path) {\n return route;\n }\n\n if (route) {\n return {\n url: match.pathname,\n path: `${route.path}/${match.route.path}`,\n } as Route;\n }\n\n return {\n url: match.pathname,\n path: match.route.path,\n } as Route;\n }, null);\n\nexport const listenToRouterChanges = ({\n router,\n routesMatcher,\n config: { pathnameDocument = window.location } = {},\n}: ListenToRouterChangesArgs) => {\n const navigationInstrumentation = getNavigationInstrumentation();\n navigationInstrumentation.setInstrumentationType(\n MXL_NAVIGATION_INSTRUMENTATIONS.Data,\n );\n\n const initialMatches = routesMatcher(router.routes, {\n pathname: pathnameDocument.pathname,\n });\n\n const initialRoute = initialMatches\n ? getRouteFromMatches(initialMatches, pathnameDocument.pathname)\n : null;\n\n if (initialRoute) {\n navigationInstrumentation.setCurrentRoute(initialRoute);\n }\n\n return router.subscribe((state) => {\n // State has a list of already matched routes\n // https://github.com/remix-run/react-router/blob/main/packages/react-router/lib/router/router.ts#L954\n const currentRoute = getRouteFromMatches(\n state.matches,\n state.location.pathname,\n );\n\n if (currentRoute) {\n navigationInstrumentation.setCurrentRoute(currentRoute);\n }\n });\n};\n"],"mappings":";;;;;;;;;;;;AAYA,MAAM,uBACJ,SACA,oBAEA,QACG,QAAQ,MAAM,gBAAgB,SAAS,EAAE,SAAS,CAAC,CACnD,QAAsB,OAAO,UAAU;AACtC,KAAI,CAAC,MAAM,MAAM,KACf,QAAO;AAGT,KAAI,MACF,QAAO;EACL,KAAK,MAAM;EACX,MAAM,GAAG,MAAM,KAAK,GAAG,MAAM,MAAM;EACpC;AAGH,QAAO;EACL,KAAK,MAAM;EACX,MAAM,MAAM,MAAM;EACnB;GACA,KAAK;AAEZ,MAAa,yBAAyB,EACpC,QACA,eACA,QAAQ,EAAE,mBAAmB,OAAO,aAAa,EAAE,OACpB;CAC/B,MAAM,4BAA4BA,qGAA8B;AAChE,2BAA0B,uBACxBC,6DAAgC,KACjC;CAED,MAAM,iBAAiB,cAAc,OAAO,QAAQ,EAClD,UAAU,iBAAiB,UAC5B,CAAC;CAEF,MAAM,eAAe,iBACjB,oBAAoB,gBAAgB,iBAAiB,SAAS,GAC9D;AAEJ,KAAI,aACF,2BAA0B,gBAAgB,aAAa;AAGzD,QAAO,OAAO,WAAW,UAAU;EAGjC,MAAM,eAAe,oBACnB,MAAM,SACN,MAAM,SAAS,SAChB;AAED,MAAI,aACF,2BAA0B,gBAAgB,aAAa;GAEzD"}
1
+ {"version":3,"file":"listenToRouterChanges.cjs","names":["getNavigationInstrumentation","MXL_NAVIGATION_INSTRUMENTATIONS"],"sources":["../../../../../../src/instrumentations/navigation/NavigationInstrumentation/react/reactRouterV6Data/listenToRouterChanges.ts"],"sourcesContent":["import type { Route } from '../../../../../api-page/index.ts';\nimport { MXL_NAVIGATION_INSTRUMENTATIONS } from '../../../../../constants/index.ts';\nimport { getNavigationInstrumentation } from '../../index.ts';\nimport type { ListenToRouterChangesArgs, Match } from './types.ts';\n\n/**\n * getRouteFromMatches goes through all the matches routes to build the full path\n * nested routes contain only the partial match, so we need to go through all of them\n * in order to build the full path.\n *\n * Filtering by currentPathname ensures that we only consider routes that are relevant to the current URL.\n */\nconst getRouteFromMatches = (\n matches: Match[],\n currentPathname: string,\n): Route | null => {\n const currentMatchIndex = matches.findIndex(\n (match) => match.pathname === currentPathname,\n );\n\n if (currentMatchIndex === -1 || !matches[currentMatchIndex].route.path) {\n return null;\n }\n\n // Build full absolute path by reducing all matches up to the current one.\n // Absolute child paths reset the accumulation; relative paths are appended.\n return matches\n .slice(0, currentMatchIndex + 1)\n .reduce<Route | null>((acc, match) => {\n const routePath = match.route.path;\n\n if (!routePath) {\n return acc;\n }\n\n // If the route path starts with '/', it's an absolute path and should reset the accumulated path.\n // Otherwise, it's a relative path and should be appended to the accumulated path.\n const path = routePath.startsWith('/')\n ? routePath\n : `${acc?.path ?? ''}/${routePath}`;\n\n return { path, url: matches[currentMatchIndex].pathname };\n }, null);\n};\n\nexport const listenToRouterChanges = ({\n router,\n routesMatcher,\n config: { pathnameDocument = window.location } = {},\n}: ListenToRouterChangesArgs) => {\n const navigationInstrumentation = getNavigationInstrumentation();\n navigationInstrumentation.setInstrumentationType(\n MXL_NAVIGATION_INSTRUMENTATIONS.Data,\n );\n\n const initialMatches = routesMatcher(router.routes, {\n pathname: pathnameDocument.pathname,\n });\n\n const initialRoute = initialMatches\n ? getRouteFromMatches(initialMatches, pathnameDocument.pathname)\n : null;\n\n if (initialRoute) {\n navigationInstrumentation.setCurrentRoute(initialRoute);\n }\n\n return router.subscribe((state) => {\n // State has a list of already matched routes\n // https://github.com/remix-run/react-router/blob/main/packages/react-router/lib/router/router.ts#L954\n const currentRoute = getRouteFromMatches(\n state.matches,\n state.location.pathname,\n );\n\n if (currentRoute) {\n navigationInstrumentation.setCurrentRoute(currentRoute);\n }\n });\n};\n"],"mappings":";;;;;;;;;;;;AAYA,MAAM,uBACJ,SACA,oBACiB;CACjB,MAAM,oBAAoB,QAAQ,WAC/B,UAAU,MAAM,aAAa,gBAC/B;AAED,KAAI,sBAAsB,MAAM,CAAC,QAAQ,mBAAmB,MAAM,KAChE,QAAO;AAKT,QAAO,QACJ,MAAM,GAAG,oBAAoB,EAAE,CAC/B,QAAsB,KAAK,UAAU;EACpC,MAAM,YAAY,MAAM,MAAM;AAE9B,MAAI,CAAC,UACH,QAAO;AAST,SAAO;GAAE,MAJI,UAAU,WAAW,IAAI,GAClC,YACA,GAAG,KAAK,QAAQ,GAAG,GAAG;GAEX,KAAK,QAAQ,mBAAmB;GAAU;IACxD,KAAK;;AAGZ,MAAa,yBAAyB,EACpC,QACA,eACA,QAAQ,EAAE,mBAAmB,OAAO,aAAa,EAAE,OACpB;CAC/B,MAAM,4BAA4BA,qGAA8B;AAChE,2BAA0B,uBACxBC,6DAAgC,KACjC;CAED,MAAM,iBAAiB,cAAc,OAAO,QAAQ,EAClD,UAAU,iBAAiB,UAC5B,CAAC;CAEF,MAAM,eAAe,iBACjB,oBAAoB,gBAAgB,iBAAiB,SAAS,GAC9D;AAEJ,KAAI,aACF,2BAA0B,gBAAgB,aAAa;AAGzD,QAAO,OAAO,WAAW,UAAU;EAGjC,MAAM,eAAe,oBACnB,MAAM,SACN,MAAM,SAAS,SAChB;AAED,MAAI,aACF,2BAA0B,gBAAgB,aAAa;GAEzD"}
@@ -1 +1 @@
1
- {"version":3,"file":"listenToRouterChanges.d.cts","names":[],"sources":["../../../../../../src/instrumentations/navigation/NavigationInstrumentation/react/reactRouterV6Data/listenToRouterChanges.ts"],"mappings":";;;cAoCa,qBAAA;EAAyB,MAAA;EAAA,aAAA;EAAA,MAAA;IAAA;EAAA;AAAA,GAInC,yBAAA"}
1
+ {"version":3,"file":"listenToRouterChanges.d.cts","names":[],"sources":["../../../../../../src/instrumentations/navigation/NavigationInstrumentation/react/reactRouterV6Data/listenToRouterChanges.ts"],"mappings":";;;cA6Ca,qBAAA;EAAyB,MAAA;EAAA,aAAA;EAAA,MAAA;IAAA;EAAA;AAAA,GAInC,yBAAA"}
@@ -1 +1 @@
1
- {"version":3,"file":"listenToRouterChanges.d.ts","names":[],"sources":["../../../../../../src/instrumentations/navigation/NavigationInstrumentation/react/reactRouterV6Data/listenToRouterChanges.ts"],"mappings":";;;cAoCa,qBAAA;EAAyB,MAAA;EAAA,aAAA;EAAA,MAAA;IAAA;EAAA;AAAA,GAInC,yBAAA"}
1
+ {"version":3,"file":"listenToRouterChanges.d.ts","names":[],"sources":["../../../../../../src/instrumentations/navigation/NavigationInstrumentation/react/reactRouterV6Data/listenToRouterChanges.ts"],"mappings":";;;cA6Ca,qBAAA;EAAyB,MAAA;EAAA,aAAA;EAAA,MAAA;IAAA;EAAA;AAAA,GAInC,yBAAA"}
@@ -9,17 +9,18 @@ import { getNavigationInstrumentation } from "../../instance.js";
9
9
  *
10
10
  * Filtering by currentPathname ensures that we only consider routes that are relevant to the current URL.
11
11
  */
12
- const getRouteFromMatches = (matches, currentPathname) => matches.filter((m) => currentPathname.includes(m.pathname)).reduce((route, match) => {
13
- if (!match.route.path) return route;
14
- if (route) return {
15
- url: match.pathname,
16
- path: `${route.path}/${match.route.path}`
17
- };
18
- return {
19
- url: match.pathname,
20
- path: match.route.path
21
- };
22
- }, null);
12
+ const getRouteFromMatches = (matches, currentPathname) => {
13
+ const currentMatchIndex = matches.findIndex((match) => match.pathname === currentPathname);
14
+ if (currentMatchIndex === -1 || !matches[currentMatchIndex].route.path) return null;
15
+ return matches.slice(0, currentMatchIndex + 1).reduce((acc, match) => {
16
+ const routePath = match.route.path;
17
+ if (!routePath) return acc;
18
+ return {
19
+ path: routePath.startsWith("/") ? routePath : `${acc?.path ?? ""}/${routePath}`,
20
+ url: matches[currentMatchIndex].pathname
21
+ };
22
+ }, null);
23
+ };
23
24
  const listenToRouterChanges = ({ router, routesMatcher, config: { pathnameDocument = window.location } = {} }) => {
24
25
  const navigationInstrumentation = getNavigationInstrumentation();
25
26
  navigationInstrumentation.setInstrumentationType(MXL_NAVIGATION_INSTRUMENTATIONS.Data);
@@ -1 +1 @@
1
- {"version":3,"file":"listenToRouterChanges.js","names":[],"sources":["../../../../../../src/instrumentations/navigation/NavigationInstrumentation/react/reactRouterV6Data/listenToRouterChanges.ts"],"sourcesContent":["import type { Route } from '../../../../../api-page/index.ts';\nimport { MXL_NAVIGATION_INSTRUMENTATIONS } from '../../../../../constants/index.ts';\nimport { getNavigationInstrumentation } from '../../index.ts';\nimport type { ListenToRouterChangesArgs, Match } from './types.ts';\n\n/**\n * getRouteFromMatches goes through all the matches routes to build the full path\n * nested routes contain only the partial match, so we need to go through all of them\n * in order to build the full path.\n *\n * Filtering by currentPathname ensures that we only consider routes that are relevant to the current URL.\n */\nconst getRouteFromMatches = (\n matches: Match[],\n currentPathname: string,\n): Route | null =>\n matches\n .filter((m) => currentPathname.includes(m.pathname))\n .reduce<null | Route>((route, match) => {\n if (!match.route.path) {\n return route;\n }\n\n if (route) {\n return {\n url: match.pathname,\n path: `${route.path}/${match.route.path}`,\n } as Route;\n }\n\n return {\n url: match.pathname,\n path: match.route.path,\n } as Route;\n }, null);\n\nexport const listenToRouterChanges = ({\n router,\n routesMatcher,\n config: { pathnameDocument = window.location } = {},\n}: ListenToRouterChangesArgs) => {\n const navigationInstrumentation = getNavigationInstrumentation();\n navigationInstrumentation.setInstrumentationType(\n MXL_NAVIGATION_INSTRUMENTATIONS.Data,\n );\n\n const initialMatches = routesMatcher(router.routes, {\n pathname: pathnameDocument.pathname,\n });\n\n const initialRoute = initialMatches\n ? getRouteFromMatches(initialMatches, pathnameDocument.pathname)\n : null;\n\n if (initialRoute) {\n navigationInstrumentation.setCurrentRoute(initialRoute);\n }\n\n return router.subscribe((state) => {\n // State has a list of already matched routes\n // https://github.com/remix-run/react-router/blob/main/packages/react-router/lib/router/router.ts#L954\n const currentRoute = getRouteFromMatches(\n state.matches,\n state.location.pathname,\n );\n\n if (currentRoute) {\n navigationInstrumentation.setCurrentRoute(currentRoute);\n }\n });\n};\n"],"mappings":";;;;;;;;;;;AAYA,MAAM,uBACJ,SACA,oBAEA,QACG,QAAQ,MAAM,gBAAgB,SAAS,EAAE,SAAS,CAAC,CACnD,QAAsB,OAAO,UAAU;AACtC,KAAI,CAAC,MAAM,MAAM,KACf,QAAO;AAGT,KAAI,MACF,QAAO;EACL,KAAK,MAAM;EACX,MAAM,GAAG,MAAM,KAAK,GAAG,MAAM,MAAM;EACpC;AAGH,QAAO;EACL,KAAK,MAAM;EACX,MAAM,MAAM,MAAM;EACnB;GACA,KAAK;AAEZ,MAAa,yBAAyB,EACpC,QACA,eACA,QAAQ,EAAE,mBAAmB,OAAO,aAAa,EAAE,OACpB;CAC/B,MAAM,4BAA4B,8BAA8B;AAChE,2BAA0B,uBACxB,gCAAgC,KACjC;CAED,MAAM,iBAAiB,cAAc,OAAO,QAAQ,EAClD,UAAU,iBAAiB,UAC5B,CAAC;CAEF,MAAM,eAAe,iBACjB,oBAAoB,gBAAgB,iBAAiB,SAAS,GAC9D;AAEJ,KAAI,aACF,2BAA0B,gBAAgB,aAAa;AAGzD,QAAO,OAAO,WAAW,UAAU;EAGjC,MAAM,eAAe,oBACnB,MAAM,SACN,MAAM,SAAS,SAChB;AAED,MAAI,aACF,2BAA0B,gBAAgB,aAAa;GAEzD"}
1
+ {"version":3,"file":"listenToRouterChanges.js","names":[],"sources":["../../../../../../src/instrumentations/navigation/NavigationInstrumentation/react/reactRouterV6Data/listenToRouterChanges.ts"],"sourcesContent":["import type { Route } from '../../../../../api-page/index.ts';\nimport { MXL_NAVIGATION_INSTRUMENTATIONS } from '../../../../../constants/index.ts';\nimport { getNavigationInstrumentation } from '../../index.ts';\nimport type { ListenToRouterChangesArgs, Match } from './types.ts';\n\n/**\n * getRouteFromMatches goes through all the matches routes to build the full path\n * nested routes contain only the partial match, so we need to go through all of them\n * in order to build the full path.\n *\n * Filtering by currentPathname ensures that we only consider routes that are relevant to the current URL.\n */\nconst getRouteFromMatches = (\n matches: Match[],\n currentPathname: string,\n): Route | null => {\n const currentMatchIndex = matches.findIndex(\n (match) => match.pathname === currentPathname,\n );\n\n if (currentMatchIndex === -1 || !matches[currentMatchIndex].route.path) {\n return null;\n }\n\n // Build full absolute path by reducing all matches up to the current one.\n // Absolute child paths reset the accumulation; relative paths are appended.\n return matches\n .slice(0, currentMatchIndex + 1)\n .reduce<Route | null>((acc, match) => {\n const routePath = match.route.path;\n\n if (!routePath) {\n return acc;\n }\n\n // If the route path starts with '/', it's an absolute path and should reset the accumulated path.\n // Otherwise, it's a relative path and should be appended to the accumulated path.\n const path = routePath.startsWith('/')\n ? routePath\n : `${acc?.path ?? ''}/${routePath}`;\n\n return { path, url: matches[currentMatchIndex].pathname };\n }, null);\n};\n\nexport const listenToRouterChanges = ({\n router,\n routesMatcher,\n config: { pathnameDocument = window.location } = {},\n}: ListenToRouterChangesArgs) => {\n const navigationInstrumentation = getNavigationInstrumentation();\n navigationInstrumentation.setInstrumentationType(\n MXL_NAVIGATION_INSTRUMENTATIONS.Data,\n );\n\n const initialMatches = routesMatcher(router.routes, {\n pathname: pathnameDocument.pathname,\n });\n\n const initialRoute = initialMatches\n ? getRouteFromMatches(initialMatches, pathnameDocument.pathname)\n : null;\n\n if (initialRoute) {\n navigationInstrumentation.setCurrentRoute(initialRoute);\n }\n\n return router.subscribe((state) => {\n // State has a list of already matched routes\n // https://github.com/remix-run/react-router/blob/main/packages/react-router/lib/router/router.ts#L954\n const currentRoute = getRouteFromMatches(\n state.matches,\n state.location.pathname,\n );\n\n if (currentRoute) {\n navigationInstrumentation.setCurrentRoute(currentRoute);\n }\n });\n};\n"],"mappings":";;;;;;;;;;;AAYA,MAAM,uBACJ,SACA,oBACiB;CACjB,MAAM,oBAAoB,QAAQ,WAC/B,UAAU,MAAM,aAAa,gBAC/B;AAED,KAAI,sBAAsB,MAAM,CAAC,QAAQ,mBAAmB,MAAM,KAChE,QAAO;AAKT,QAAO,QACJ,MAAM,GAAG,oBAAoB,EAAE,CAC/B,QAAsB,KAAK,UAAU;EACpC,MAAM,YAAY,MAAM,MAAM;AAE9B,MAAI,CAAC,UACH,QAAO;AAST,SAAO;GAAE,MAJI,UAAU,WAAW,IAAI,GAClC,YACA,GAAG,KAAK,QAAQ,GAAG,GAAG;GAEX,KAAK,QAAQ,mBAAmB;GAAU;IACxD,KAAK;;AAGZ,MAAa,yBAAyB,EACpC,QACA,eACA,QAAQ,EAAE,mBAAmB,OAAO,aAAa,EAAE,OACpB;CAC/B,MAAM,4BAA4B,8BAA8B;AAChE,2BAA0B,uBACxB,gCAAgC,KACjC;CAED,MAAM,iBAAiB,cAAc,OAAO,QAAQ,EAClD,UAAU,iBAAiB,UAC5B,CAAC;CAEF,MAAM,eAAe,iBACjB,oBAAoB,gBAAgB,iBAAiB,SAAS,GAC9D;AAEJ,KAAI,aACF,2BAA0B,gBAAgB,aAAa;AAGzD,QAAO,OAAO,WAAW,UAAU;EAGjC,MAAM,eAAe,oBACnB,MAAM,SACN,MAAM,SAAS,SAChB;AAED,MAAI,aACF,2BAA0B,gBAAgB,aAAa;GAEzD"}
@@ -9,7 +9,8 @@ hoist_non_react_statics = require_runtime.__toESM(hoist_non_react_statics);
9
9
  //#region src/instrumentations/navigation/NavigationInstrumentation/react/reactRouterV6Declarative/withMXLRouting.ts
10
10
  const getLastRoute = (matchedComponent, lastRoute) => {
11
11
  if (!matchedComponent.props.match || !matchedComponent.props.match.route) return null;
12
- const path = lastRoute ? `${lastRoute.path}/${matchedComponent.props.match.route.path}` : matchedComponent.props.match.route.path;
12
+ const childPath = matchedComponent.props.match.route.path;
13
+ const path = lastRoute && !childPath.startsWith("/") ? `${lastRoute.path}/${childPath}` : childPath;
13
14
  if (matchedComponent.props.routeContext?.outlet) return getLastRoute(matchedComponent.props.routeContext.outlet, {
14
15
  path,
15
16
  url: matchedComponent.props.match.pathname
@@ -1 +1 @@
1
- {"version":3,"file":"withMXLRouting.cjs","names":["getNavigationInstrumentation","MXL_NAVIGATION_INSTRUMENTATIONS"],"sources":["../../../../../../src/instrumentations/navigation/NavigationInstrumentation/react/reactRouterV6Declarative/withMXLRouting.ts"],"sourcesContent":["import hoistNonReactStatics from 'hoist-non-react-statics';\nimport type React from 'react';\nimport { createElement } from 'react';\nimport type { Route } from '../../../../../api-page/index.ts';\nimport { MXL_NAVIGATION_INSTRUMENTATIONS } from '../../../../../constants/index.ts';\nimport { getNavigationInstrumentation } from '../../index.ts';\nimport type { RoutesFunctionalComponentReturn } from './types.ts';\n\n// Routes can be nested, we need to traverse the routeContext to find the last route\nconst getLastRoute = (\n matchedComponent: RoutesFunctionalComponentReturn,\n lastRoute: Route | null,\n): Route | null => {\n if (!matchedComponent.props.match || !matchedComponent.props.match.route) {\n return null;\n }\n\n const path = lastRoute\n ? `${lastRoute.path}/${matchedComponent.props.match.route.path}`\n : matchedComponent.props.match.route.path;\n\n if (matchedComponent.props.routeContext?.outlet) {\n return getLastRoute(matchedComponent.props.routeContext.outlet, {\n path,\n url: matchedComponent.props.match.pathname,\n });\n }\n\n return {\n path,\n url: matchedComponent.props.match.pathname,\n };\n};\n\nexport const withMXLRouting = <P extends object>(\n WrappedComponent: React.FunctionComponent<P>,\n) => {\n const navigationInstrumentation = getNavigationInstrumentation();\n navigationInstrumentation.setInstrumentationType(\n MXL_NAVIGATION_INSTRUMENTATIONS.Declarative,\n );\n\n const RoutesWithMXLRouting: React.FC<P> = (props: P) => {\n /**\n * React-router v6+ implementation is very different from v5\n * It doesn't have a <Switch> component that injects props into <Route>\n * Instead, it has <Routes> which internally calculates the matched route\n * and returns it as a children, <Route> cannot be wrapped since it requires all children to be a <Route> component\n * here we rely on that matching to get the current route.\n * It's not ideal to rely on internal implementation details, but it's the easier way of getting the current route\n * without having to manually match it or using hooks on each children component\n *\n * See: https://github.com/remix-run/react-router/blob/main/packages/react-router/lib/hooks.tsx#L553\n */\n const matchedComponent = WrappedComponent(\n props,\n ) as unknown as RoutesFunctionalComponentReturn;\n\n if (matchedComponent.props.match?.route) {\n const lastRoute = getLastRoute(matchedComponent, null);\n if (lastRoute) {\n navigationInstrumentation.setCurrentRoute(lastRoute);\n }\n }\n\n return createElement<P>(WrappedComponent, props);\n };\n\n // Keep wrapped component metadata\n RoutesWithMXLRouting.displayName = `withMXLRouting(${WrappedComponent.displayName || WrappedComponent.name || 'Component'})`;\n hoistNonReactStatics(RoutesWithMXLRouting, WrappedComponent);\n\n return RoutesWithMXLRouting;\n};\n"],"mappings":";;;;;;;;;AASA,MAAM,gBACJ,kBACA,cACiB;AACjB,KAAI,CAAC,iBAAiB,MAAM,SAAS,CAAC,iBAAiB,MAAM,MAAM,MACjE,QAAO;CAGT,MAAM,OAAO,YACT,GAAG,UAAU,KAAK,GAAG,iBAAiB,MAAM,MAAM,MAAM,SACxD,iBAAiB,MAAM,MAAM,MAAM;AAEvC,KAAI,iBAAiB,MAAM,cAAc,OACvC,QAAO,aAAa,iBAAiB,MAAM,aAAa,QAAQ;EAC9D;EACA,KAAK,iBAAiB,MAAM,MAAM;EACnC,CAAC;AAGJ,QAAO;EACL;EACA,KAAK,iBAAiB,MAAM,MAAM;EACnC;;AAGH,MAAa,kBACX,qBACG;CACH,MAAM,4BAA4BA,qGAA8B;AAChE,2BAA0B,uBACxBC,6DAAgC,YACjC;CAED,MAAM,wBAAqC,UAAa;;;;;;;;;;;;EAYtD,MAAM,mBAAmB,iBACvB,MACD;AAED,MAAI,iBAAiB,MAAM,OAAO,OAAO;GACvC,MAAM,YAAY,aAAa,kBAAkB,KAAK;AACtD,OAAI,UACF,2BAA0B,gBAAgB,UAAU;;AAIxD,kCAAwB,kBAAkB,MAAM;;AAIlD,sBAAqB,cAAc,kBAAkB,iBAAiB,eAAe,iBAAiB,QAAQ,YAAY;AAC1H,sCAAqB,sBAAsB,iBAAiB;AAE5D,QAAO"}
1
+ {"version":3,"file":"withMXLRouting.cjs","names":["getNavigationInstrumentation","MXL_NAVIGATION_INSTRUMENTATIONS"],"sources":["../../../../../../src/instrumentations/navigation/NavigationInstrumentation/react/reactRouterV6Declarative/withMXLRouting.ts"],"sourcesContent":["import hoistNonReactStatics from 'hoist-non-react-statics';\nimport type React from 'react';\nimport { createElement } from 'react';\nimport type { Route } from '../../../../../api-page/index.ts';\nimport { MXL_NAVIGATION_INSTRUMENTATIONS } from '../../../../../constants/index.ts';\nimport { getNavigationInstrumentation } from '../../index.ts';\nimport type { RoutesFunctionalComponentReturn } from './types.ts';\n\n// Routes can be nested, we need to traverse the routeContext to find the last route\nconst getLastRoute = (\n matchedComponent: RoutesFunctionalComponentReturn,\n lastRoute: Route | null,\n): Route | null => {\n if (!matchedComponent.props.match || !matchedComponent.props.match.route) {\n return null;\n }\n\n const childPath = matchedComponent.props.match.route.path;\n const path =\n lastRoute && !childPath.startsWith('/')\n ? `${lastRoute.path}/${childPath}`\n : childPath;\n\n if (matchedComponent.props.routeContext?.outlet) {\n return getLastRoute(matchedComponent.props.routeContext.outlet, {\n path,\n url: matchedComponent.props.match.pathname,\n });\n }\n\n return {\n path,\n url: matchedComponent.props.match.pathname,\n };\n};\n\nexport const withMXLRouting = <P extends object>(\n WrappedComponent: React.FunctionComponent<P>,\n) => {\n const navigationInstrumentation = getNavigationInstrumentation();\n navigationInstrumentation.setInstrumentationType(\n MXL_NAVIGATION_INSTRUMENTATIONS.Declarative,\n );\n\n const RoutesWithMXLRouting: React.FC<P> = (props: P) => {\n /**\n * React-router v6+ implementation is very different from v5\n * It doesn't have a <Switch> component that injects props into <Route>\n * Instead, it has <Routes> which internally calculates the matched route\n * and returns it as a children, <Route> cannot be wrapped since it requires all children to be a <Route> component\n * here we rely on that matching to get the current route.\n * It's not ideal to rely on internal implementation details, but it's the easier way of getting the current route\n * without having to manually match it or using hooks on each children component\n *\n * See: https://github.com/remix-run/react-router/blob/main/packages/react-router/lib/hooks.tsx#L553\n */\n const matchedComponent = WrappedComponent(\n props,\n ) as unknown as RoutesFunctionalComponentReturn;\n\n if (matchedComponent.props.match?.route) {\n const lastRoute = getLastRoute(matchedComponent, null);\n if (lastRoute) {\n navigationInstrumentation.setCurrentRoute(lastRoute);\n }\n }\n\n return createElement<P>(WrappedComponent, props);\n };\n\n // Keep wrapped component metadata\n RoutesWithMXLRouting.displayName = `withMXLRouting(${WrappedComponent.displayName || WrappedComponent.name || 'Component'})`;\n hoistNonReactStatics(RoutesWithMXLRouting, WrappedComponent);\n\n return RoutesWithMXLRouting;\n};\n"],"mappings":";;;;;;;;;AASA,MAAM,gBACJ,kBACA,cACiB;AACjB,KAAI,CAAC,iBAAiB,MAAM,SAAS,CAAC,iBAAiB,MAAM,MAAM,MACjE,QAAO;CAGT,MAAM,YAAY,iBAAiB,MAAM,MAAM,MAAM;CACrD,MAAM,OACJ,aAAa,CAAC,UAAU,WAAW,IAAI,GACnC,GAAG,UAAU,KAAK,GAAG,cACrB;AAEN,KAAI,iBAAiB,MAAM,cAAc,OACvC,QAAO,aAAa,iBAAiB,MAAM,aAAa,QAAQ;EAC9D;EACA,KAAK,iBAAiB,MAAM,MAAM;EACnC,CAAC;AAGJ,QAAO;EACL;EACA,KAAK,iBAAiB,MAAM,MAAM;EACnC;;AAGH,MAAa,kBACX,qBACG;CACH,MAAM,4BAA4BA,qGAA8B;AAChE,2BAA0B,uBACxBC,6DAAgC,YACjC;CAED,MAAM,wBAAqC,UAAa;;;;;;;;;;;;EAYtD,MAAM,mBAAmB,iBACvB,MACD;AAED,MAAI,iBAAiB,MAAM,OAAO,OAAO;GACvC,MAAM,YAAY,aAAa,kBAAkB,KAAK;AACtD,OAAI,UACF,2BAA0B,gBAAgB,UAAU;;AAIxD,kCAAwB,kBAAkB,MAAM;;AAIlD,sBAAqB,cAAc,kBAAkB,iBAAiB,eAAe,iBAAiB,QAAQ,YAAY;AAC1H,sCAAqB,sBAAsB,iBAAiB;AAE5D,QAAO"}
@@ -1 +1 @@
1
- {"version":3,"file":"withMXLRouting.d.cts","names":[],"sources":["../../../../../../src/instrumentations/navigation/NavigationInstrumentation/react/reactRouterV6Declarative/withMXLRouting.ts"],"mappings":";;;cAkCa,cAAA,qBACX,gBAAA,EAAkB,KAAA,CAAM,iBAAA,CAAkB,CAAA,MAAE,KAAA,CAAA,EAAA,CAAA,CAAA"}
1
+ {"version":3,"file":"withMXLRouting.d.cts","names":[],"sources":["../../../../../../src/instrumentations/navigation/NavigationInstrumentation/react/reactRouterV6Declarative/withMXLRouting.ts"],"mappings":";;;cAoCa,cAAA,qBACX,gBAAA,EAAkB,KAAA,CAAM,iBAAA,CAAkB,CAAA,MAAE,KAAA,CAAA,EAAA,CAAA,CAAA"}
@@ -1 +1 @@
1
- {"version":3,"file":"withMXLRouting.d.ts","names":[],"sources":["../../../../../../src/instrumentations/navigation/NavigationInstrumentation/react/reactRouterV6Declarative/withMXLRouting.ts"],"mappings":";;;cAkCa,cAAA,qBACX,gBAAA,EAAkB,KAAA,CAAM,iBAAA,CAAkB,CAAA,MAAE,KAAA,CAAA,EAAA,CAAA,CAAA"}
1
+ {"version":3,"file":"withMXLRouting.d.ts","names":[],"sources":["../../../../../../src/instrumentations/navigation/NavigationInstrumentation/react/reactRouterV6Declarative/withMXLRouting.ts"],"mappings":";;;cAoCa,cAAA,qBACX,gBAAA,EAAkB,KAAA,CAAM,iBAAA,CAAkB,CAAA,MAAE,KAAA,CAAA,EAAA,CAAA,CAAA"}
@@ -6,7 +6,8 @@ import hoistNonReactStatics from "hoist-non-react-statics";
6
6
  //#region src/instrumentations/navigation/NavigationInstrumentation/react/reactRouterV6Declarative/withMXLRouting.ts
7
7
  const getLastRoute = (matchedComponent, lastRoute) => {
8
8
  if (!matchedComponent.props.match || !matchedComponent.props.match.route) return null;
9
- const path = lastRoute ? `${lastRoute.path}/${matchedComponent.props.match.route.path}` : matchedComponent.props.match.route.path;
9
+ const childPath = matchedComponent.props.match.route.path;
10
+ const path = lastRoute && !childPath.startsWith("/") ? `${lastRoute.path}/${childPath}` : childPath;
10
11
  if (matchedComponent.props.routeContext?.outlet) return getLastRoute(matchedComponent.props.routeContext.outlet, {
11
12
  path,
12
13
  url: matchedComponent.props.match.pathname
@@ -1 +1 @@
1
- {"version":3,"file":"withMXLRouting.js","names":[],"sources":["../../../../../../src/instrumentations/navigation/NavigationInstrumentation/react/reactRouterV6Declarative/withMXLRouting.ts"],"sourcesContent":["import hoistNonReactStatics from 'hoist-non-react-statics';\nimport type React from 'react';\nimport { createElement } from 'react';\nimport type { Route } from '../../../../../api-page/index.ts';\nimport { MXL_NAVIGATION_INSTRUMENTATIONS } from '../../../../../constants/index.ts';\nimport { getNavigationInstrumentation } from '../../index.ts';\nimport type { RoutesFunctionalComponentReturn } from './types.ts';\n\n// Routes can be nested, we need to traverse the routeContext to find the last route\nconst getLastRoute = (\n matchedComponent: RoutesFunctionalComponentReturn,\n lastRoute: Route | null,\n): Route | null => {\n if (!matchedComponent.props.match || !matchedComponent.props.match.route) {\n return null;\n }\n\n const path = lastRoute\n ? `${lastRoute.path}/${matchedComponent.props.match.route.path}`\n : matchedComponent.props.match.route.path;\n\n if (matchedComponent.props.routeContext?.outlet) {\n return getLastRoute(matchedComponent.props.routeContext.outlet, {\n path,\n url: matchedComponent.props.match.pathname,\n });\n }\n\n return {\n path,\n url: matchedComponent.props.match.pathname,\n };\n};\n\nexport const withMXLRouting = <P extends object>(\n WrappedComponent: React.FunctionComponent<P>,\n) => {\n const navigationInstrumentation = getNavigationInstrumentation();\n navigationInstrumentation.setInstrumentationType(\n MXL_NAVIGATION_INSTRUMENTATIONS.Declarative,\n );\n\n const RoutesWithMXLRouting: React.FC<P> = (props: P) => {\n /**\n * React-router v6+ implementation is very different from v5\n * It doesn't have a <Switch> component that injects props into <Route>\n * Instead, it has <Routes> which internally calculates the matched route\n * and returns it as a children, <Route> cannot be wrapped since it requires all children to be a <Route> component\n * here we rely on that matching to get the current route.\n * It's not ideal to rely on internal implementation details, but it's the easier way of getting the current route\n * without having to manually match it or using hooks on each children component\n *\n * See: https://github.com/remix-run/react-router/blob/main/packages/react-router/lib/hooks.tsx#L553\n */\n const matchedComponent = WrappedComponent(\n props,\n ) as unknown as RoutesFunctionalComponentReturn;\n\n if (matchedComponent.props.match?.route) {\n const lastRoute = getLastRoute(matchedComponent, null);\n if (lastRoute) {\n navigationInstrumentation.setCurrentRoute(lastRoute);\n }\n }\n\n return createElement<P>(WrappedComponent, props);\n };\n\n // Keep wrapped component metadata\n RoutesWithMXLRouting.displayName = `withMXLRouting(${WrappedComponent.displayName || WrappedComponent.name || 'Component'})`;\n hoistNonReactStatics(RoutesWithMXLRouting, WrappedComponent);\n\n return RoutesWithMXLRouting;\n};\n"],"mappings":";;;;;;AASA,MAAM,gBACJ,kBACA,cACiB;AACjB,KAAI,CAAC,iBAAiB,MAAM,SAAS,CAAC,iBAAiB,MAAM,MAAM,MACjE,QAAO;CAGT,MAAM,OAAO,YACT,GAAG,UAAU,KAAK,GAAG,iBAAiB,MAAM,MAAM,MAAM,SACxD,iBAAiB,MAAM,MAAM,MAAM;AAEvC,KAAI,iBAAiB,MAAM,cAAc,OACvC,QAAO,aAAa,iBAAiB,MAAM,aAAa,QAAQ;EAC9D;EACA,KAAK,iBAAiB,MAAM,MAAM;EACnC,CAAC;AAGJ,QAAO;EACL;EACA,KAAK,iBAAiB,MAAM,MAAM;EACnC;;AAGH,MAAa,kBACX,qBACG;CACH,MAAM,4BAA4B,8BAA8B;AAChE,2BAA0B,uBACxB,gCAAgC,YACjC;CAED,MAAM,wBAAqC,UAAa;;;;;;;;;;;;EAYtD,MAAM,mBAAmB,iBACvB,MACD;AAED,MAAI,iBAAiB,MAAM,OAAO,OAAO;GACvC,MAAM,YAAY,aAAa,kBAAkB,KAAK;AACtD,OAAI,UACF,2BAA0B,gBAAgB,UAAU;;AAIxD,SAAO,cAAiB,kBAAkB,MAAM;;AAIlD,sBAAqB,cAAc,kBAAkB,iBAAiB,eAAe,iBAAiB,QAAQ,YAAY;AAC1H,sBAAqB,sBAAsB,iBAAiB;AAE5D,QAAO"}
1
+ {"version":3,"file":"withMXLRouting.js","names":[],"sources":["../../../../../../src/instrumentations/navigation/NavigationInstrumentation/react/reactRouterV6Declarative/withMXLRouting.ts"],"sourcesContent":["import hoistNonReactStatics from 'hoist-non-react-statics';\nimport type React from 'react';\nimport { createElement } from 'react';\nimport type { Route } from '../../../../../api-page/index.ts';\nimport { MXL_NAVIGATION_INSTRUMENTATIONS } from '../../../../../constants/index.ts';\nimport { getNavigationInstrumentation } from '../../index.ts';\nimport type { RoutesFunctionalComponentReturn } from './types.ts';\n\n// Routes can be nested, we need to traverse the routeContext to find the last route\nconst getLastRoute = (\n matchedComponent: RoutesFunctionalComponentReturn,\n lastRoute: Route | null,\n): Route | null => {\n if (!matchedComponent.props.match || !matchedComponent.props.match.route) {\n return null;\n }\n\n const childPath = matchedComponent.props.match.route.path;\n const path =\n lastRoute && !childPath.startsWith('/')\n ? `${lastRoute.path}/${childPath}`\n : childPath;\n\n if (matchedComponent.props.routeContext?.outlet) {\n return getLastRoute(matchedComponent.props.routeContext.outlet, {\n path,\n url: matchedComponent.props.match.pathname,\n });\n }\n\n return {\n path,\n url: matchedComponent.props.match.pathname,\n };\n};\n\nexport const withMXLRouting = <P extends object>(\n WrappedComponent: React.FunctionComponent<P>,\n) => {\n const navigationInstrumentation = getNavigationInstrumentation();\n navigationInstrumentation.setInstrumentationType(\n MXL_NAVIGATION_INSTRUMENTATIONS.Declarative,\n );\n\n const RoutesWithMXLRouting: React.FC<P> = (props: P) => {\n /**\n * React-router v6+ implementation is very different from v5\n * It doesn't have a <Switch> component that injects props into <Route>\n * Instead, it has <Routes> which internally calculates the matched route\n * and returns it as a children, <Route> cannot be wrapped since it requires all children to be a <Route> component\n * here we rely on that matching to get the current route.\n * It's not ideal to rely on internal implementation details, but it's the easier way of getting the current route\n * without having to manually match it or using hooks on each children component\n *\n * See: https://github.com/remix-run/react-router/blob/main/packages/react-router/lib/hooks.tsx#L553\n */\n const matchedComponent = WrappedComponent(\n props,\n ) as unknown as RoutesFunctionalComponentReturn;\n\n if (matchedComponent.props.match?.route) {\n const lastRoute = getLastRoute(matchedComponent, null);\n if (lastRoute) {\n navigationInstrumentation.setCurrentRoute(lastRoute);\n }\n }\n\n return createElement<P>(WrappedComponent, props);\n };\n\n // Keep wrapped component metadata\n RoutesWithMXLRouting.displayName = `withMXLRouting(${WrappedComponent.displayName || WrappedComponent.name || 'Component'})`;\n hoistNonReactStatics(RoutesWithMXLRouting, WrappedComponent);\n\n return RoutesWithMXLRouting;\n};\n"],"mappings":";;;;;;AASA,MAAM,gBACJ,kBACA,cACiB;AACjB,KAAI,CAAC,iBAAiB,MAAM,SAAS,CAAC,iBAAiB,MAAM,MAAM,MACjE,QAAO;CAGT,MAAM,YAAY,iBAAiB,MAAM,MAAM,MAAM;CACrD,MAAM,OACJ,aAAa,CAAC,UAAU,WAAW,IAAI,GACnC,GAAG,UAAU,KAAK,GAAG,cACrB;AAEN,KAAI,iBAAiB,MAAM,cAAc,OACvC,QAAO,aAAa,iBAAiB,MAAM,aAAa,QAAQ;EAC9D;EACA,KAAK,iBAAiB,MAAM,MAAM;EACnC,CAAC;AAGJ,QAAO;EACL;EACA,KAAK,iBAAiB,MAAM,MAAM;EACnC;;AAGH,MAAa,kBACX,qBACG;CACH,MAAM,4BAA4B,8BAA8B;AAChE,2BAA0B,uBACxB,gCAAgC,YACjC;CAED,MAAM,wBAAqC,UAAa;;;;;;;;;;;;EAYtD,MAAM,mBAAmB,iBACvB,MACD;AAED,MAAI,iBAAiB,MAAM,OAAO,OAAO;GACvC,MAAM,YAAY,aAAa,kBAAkB,KAAK;AACtD,OAAI,UACF,2BAA0B,gBAAgB,UAAU;;AAIxD,SAAO,cAAiB,kBAAkB,MAAM;;AAIlD,sBAAqB,cAAc,kBAAkB,iBAAiB,eAAe,iBAAiB,QAAQ,YAAY;AAC1H,sBAAqB,sBAAsB,iBAAiB;AAE5D,QAAO"}