@depup/sentry__react 10.48.0-depup.0 → 10.68.0-depup.0
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.
- package/README.md +9 -3
- package/build/cjs/constants.js +3 -5
- package/build/cjs/constants.js.map +1 -1
- package/build/cjs/debug-build.js +0 -5
- package/build/cjs/debug-build.js.map +1 -1
- package/build/cjs/error.js +14 -77
- package/build/cjs/error.js.map +1 -1
- package/build/cjs/errorboundary.js +22 -77
- package/build/cjs/errorboundary.js.map +1 -1
- package/build/cjs/hoist-non-react-statics.js +16 -84
- package/build/cjs/hoist-non-react-statics.js.map +1 -1
- package/build/cjs/index.js +6 -0
- package/build/cjs/index.js.map +1 -1
- package/build/cjs/isSyntheticEvent.js +10 -0
- package/build/cjs/isSyntheticEvent.js.map +1 -0
- package/build/cjs/profiler.js +35 -110
- package/build/cjs/profiler.js.map +1 -1
- package/build/cjs/reactrouter-compat-utils/instrumentation.js +236 -692
- package/build/cjs/reactrouter-compat-utils/instrumentation.js.map +1 -1
- package/build/cjs/reactrouter-compat-utils/lazy-routes.js +24 -85
- package/build/cjs/reactrouter-compat-utils/lazy-routes.js.map +1 -1
- package/build/cjs/reactrouter-compat-utils/route-manifest.js +18 -96
- package/build/cjs/reactrouter-compat-utils/route-manifest.js.map +1 -1
- package/build/cjs/reactrouter-compat-utils/utils.js +82 -193
- package/build/cjs/reactrouter-compat-utils/utils.js.map +1 -1
- package/build/cjs/reactrouter.compat.js +29 -0
- package/build/cjs/reactrouter.compat.js.map +1 -0
- package/build/cjs/reactrouter.js +34 -111
- package/build/cjs/reactrouter.js.map +1 -1
- package/build/cjs/reactrouterv3.js +31 -60
- package/build/cjs/reactrouterv3.js.map +1 -1
- package/build/cjs/reactrouterv6.js +10 -42
- package/build/cjs/reactrouterv6.js.map +1 -1
- package/build/cjs/reactrouterv7.js +10 -42
- package/build/cjs/reactrouterv7.js.map +1 -1
- package/build/cjs/redux.js +61 -90
- package/build/cjs/redux.js.map +1 -1
- package/build/cjs/sdk.js +15 -10
- package/build/cjs/sdk.js.map +1 -1
- package/build/cjs/tanstackrouter.js +90 -92
- package/build/cjs/tanstackrouter.js.map +1 -1
- package/build/esm/constants.js +3 -5
- package/build/esm/constants.js.map +1 -1
- package/build/esm/debug-build.js +0 -5
- package/build/esm/debug-build.js.map +1 -1
- package/build/esm/error.js +13 -76
- package/build/esm/error.js.map +1 -1
- package/build/esm/errorboundary.js +22 -77
- package/build/esm/errorboundary.js.map +1 -1
- package/build/esm/hoist-non-react-statics.js +16 -84
- package/build/esm/hoist-non-react-statics.js.map +1 -1
- package/build/esm/index.js +1 -0
- package/build/esm/index.js.map +1 -1
- package/build/esm/isSyntheticEvent.js +8 -0
- package/build/esm/isSyntheticEvent.js.map +1 -0
- package/build/esm/package.json +1 -1
- package/build/esm/profiler.js +35 -110
- package/build/esm/profiler.js.map +1 -1
- package/build/esm/reactrouter-compat-utils/instrumentation.js +237 -693
- package/build/esm/reactrouter-compat-utils/instrumentation.js.map +1 -1
- package/build/esm/reactrouter-compat-utils/lazy-routes.js +24 -85
- package/build/esm/reactrouter-compat-utils/lazy-routes.js.map +1 -1
- package/build/esm/reactrouter-compat-utils/route-manifest.js +18 -96
- package/build/esm/reactrouter-compat-utils/route-manifest.js.map +1 -1
- package/build/esm/reactrouter-compat-utils/utils.js +80 -191
- package/build/esm/reactrouter-compat-utils/utils.js.map +1 -1
- package/build/esm/reactrouter.compat.js +23 -0
- package/build/esm/reactrouter.compat.js.map +1 -0
- package/build/esm/reactrouter.js +34 -111
- package/build/esm/reactrouter.js.map +1 -1
- package/build/esm/reactrouterv3.js +29 -58
- package/build/esm/reactrouterv3.js.map +1 -1
- package/build/esm/reactrouterv6.js +10 -42
- package/build/esm/reactrouterv6.js.map +1 -1
- package/build/esm/reactrouterv7.js +10 -42
- package/build/esm/reactrouterv7.js.map +1 -1
- package/build/esm/redux.js +61 -90
- package/build/esm/redux.js.map +1 -1
- package/build/esm/sdk.js +15 -10
- package/build/esm/sdk.js.map +1 -1
- package/build/esm/tanstackrouter.js +91 -93
- package/build/esm/tanstackrouter.js.map +1 -1
- package/build/types/error.d.ts.map +1 -1
- package/build/types/index.d.ts +1 -0
- package/build/types/index.d.ts.map +1 -1
- package/build/types/isSyntheticEvent.d.ts +10 -0
- package/build/types/isSyntheticEvent.d.ts.map +1 -0
- package/build/types/reactrouter-compat-utils/instrumentation.d.ts +1 -1
- package/build/types/reactrouter-compat-utils/instrumentation.d.ts.map +1 -1
- package/build/types/reactrouter-compat-utils/utils.d.ts +1 -1
- package/build/types/reactrouter-compat-utils/utils.d.ts.map +1 -1
- package/build/types/reactrouter.compat.d.ts +42 -0
- package/build/types/reactrouter.compat.d.ts.map +1 -0
- package/build/types/reactrouter.d.ts.map +1 -1
- package/build/types/reactrouterv3.d.ts +1 -1
- package/build/types/reactrouterv3.d.ts.map +1 -1
- package/build/types/reactrouterv6.d.ts +10 -0
- package/build/types/reactrouterv6.d.ts.map +1 -1
- package/build/types/reactrouterv7.d.ts +10 -0
- package/build/types/reactrouterv7.d.ts.map +1 -1
- package/build/types/redux.d.ts +1 -1
- package/build/types/redux.d.ts.map +1 -1
- package/build/types/sdk.d.ts +1 -1
- package/build/types/sdk.d.ts.map +1 -1
- package/build/types/tanstackrouter.d.ts +1 -1
- package/build/types/tanstackrouter.d.ts.map +1 -1
- package/build/types/vendor/tanstackrouter-types.d.ts +2 -1
- package/build/types/vendor/tanstackrouter-types.d.ts.map +1 -1
- package/build/types-ts3.8/index.d.ts +1 -0
- package/build/types-ts3.8/isSyntheticEvent.d.ts +10 -0
- package/build/types-ts3.8/reactrouter-compat-utils/instrumentation.d.ts +1 -1
- package/build/types-ts3.8/reactrouter-compat-utils/utils.d.ts +1 -1
- package/build/types-ts3.8/reactrouter.compat.d.ts +42 -0
- package/build/types-ts3.8/reactrouterv3.d.ts +1 -1
- package/build/types-ts3.8/reactrouterv6.d.ts +10 -0
- package/build/types-ts3.8/reactrouterv7.d.ts +10 -0
- package/build/types-ts3.8/redux.d.ts +1 -1
- package/build/types-ts3.8/sdk.d.ts +1 -1
- package/build/types-ts3.8/tanstackrouter.d.ts +1 -1
- package/build/types-ts3.8/vendor/tanstackrouter-types.d.ts +2 -1
- package/changes.json +8 -3
- package/package.json +18 -8
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"lazy-routes.js","sources":["../../../src/reactrouter-compat-utils/lazy-routes.tsx"],"sourcesContent":["import { WINDOW } from '@sentry/browser';\nimport type { Span } from '@sentry/core';\nimport { addNonEnumerableProperty, debug, isThenable } from '@sentry/core';\nimport { DEBUG_BUILD } from '../debug-build';\nimport type { Location, RouteObject } from '../types';\nimport { getActiveRootSpan, getNavigationContext } from './utils';\n\n/**\n * Captures location at invocation time. Prefers navigation context over window.location\n * since window.location hasn't updated yet when async handlers are invoked.\n *\n * When inside a patchRoutesOnNavigation call, uses the captured targetPath. If targetPath\n * is undefined (patchRoutesOnNavigation can be invoked without a path argument), returns\n * null rather than falling back to WINDOW.location which could be stale/wrong after the\n * user navigated away during async loading. Returning null causes the span name update\n * to be skipped, which is safer than using incorrect location data.\n */\nfunction captureCurrentLocation(): Location | null {\n const navContext = getNavigationContext();\n\n if (navContext) {\n if (navContext.targetPath) {\n return {\n pathname: navContext.targetPath,\n search: '',\n hash: '',\n state: null,\n key: 'default',\n };\n }\n // Don't fall back to potentially stale WINDOW.location\n return null;\n }\n\n if (typeof WINDOW !== 'undefined') {\n try {\n const windowLocation = WINDOW.location;\n if (windowLocation) {\n return {\n pathname: windowLocation.pathname,\n search: windowLocation.search || '',\n hash: windowLocation.hash || '',\n state: null,\n key: 'default',\n };\n }\n } catch {\n DEBUG_BUILD && debug.warn('[React Router] Could not access window.location');\n }\n }\n return null;\n}\n\n/**\n * Captures the active span at invocation time. Prefers navigation context span\n * to ensure we update the correct span even if another navigation starts.\n */\nfunction captureActiveSpan(): Span | undefined {\n const navContext = getNavigationContext();\n if (navContext) {\n return navContext.span;\n }\n return getActiveRootSpan();\n}\n\n/**\n * Creates a proxy wrapper for an async handler function.\n * Captures both the location and the active span at invocation time to ensure\n * the correct span is updated when the handler resolves.\n */\nexport function createAsyncHandlerProxy(\n originalFunction: (...args: unknown[]) => unknown,\n route: RouteObject,\n handlerKey: string,\n processResolvedRoutes: (\n resolvedRoutes: RouteObject[],\n parentRoute?: RouteObject,\n currentLocation?: Location,\n capturedSpan?: Span,\n ) => void,\n): (...args: unknown[]) => unknown {\n const proxy = new Proxy(originalFunction, {\n apply(target: (...args: unknown[]) => unknown, thisArg, argArray) {\n const locationAtInvocation = captureCurrentLocation();\n const spanAtInvocation = captureActiveSpan();\n const result = target.apply(thisArg, argArray);\n handleAsyncHandlerResult(\n result,\n route,\n handlerKey,\n processResolvedRoutes,\n locationAtInvocation,\n spanAtInvocation,\n );\n return result;\n },\n });\n\n addNonEnumerableProperty(proxy, '__sentry_proxied__', true);\n\n return proxy;\n}\n\n/**\n * Handles the result of an async handler function call.\n * Passes the captured span through to ensure the correct span is updated.\n */\nexport function handleAsyncHandlerResult(\n result: unknown,\n route: RouteObject,\n handlerKey: string,\n processResolvedRoutes: (\n resolvedRoutes: RouteObject[],\n parentRoute?: RouteObject,\n currentLocation?: Location,\n capturedSpan?: Span,\n ) => void,\n currentLocation: Location | null,\n capturedSpan: Span | undefined,\n): void {\n if (isThenable(result)) {\n (result as Promise<unknown>)\n .then((resolvedRoutes: unknown) => {\n if (Array.isArray(resolvedRoutes)) {\n processResolvedRoutes(resolvedRoutes, route, currentLocation ?? undefined, capturedSpan);\n }\n })\n .catch((e: unknown) => {\n DEBUG_BUILD && debug.warn(`Error resolving async handler '${handlerKey}' for route`, route, e);\n });\n } else if (Array.isArray(result)) {\n processResolvedRoutes(result, route, currentLocation ?? undefined, capturedSpan);\n }\n}\n\n/**\n * Recursively checks a route for async handlers and sets up Proxies to add discovered child routes to allRoutes when called.\n */\nexport function checkRouteForAsyncHandler(\n route: RouteObject,\n processResolvedRoutes: (\n resolvedRoutes: RouteObject[],\n parentRoute?: RouteObject,\n currentLocation?: Location,\n capturedSpan?: Span,\n ) => void,\n): void {\n // Set up proxies for any functions in the route's handle\n if (route.handle && typeof route.handle === 'object') {\n for (const key of Object.keys(route.handle)) {\n const maybeFn = route.handle[key];\n if (typeof maybeFn === 'function' && !(maybeFn as { __sentry_proxied__?: boolean }).__sentry_proxied__) {\n route.handle[key] = createAsyncHandlerProxy(maybeFn, route, key, processResolvedRoutes);\n }\n }\n }\n\n // Recursively check child routes\n if (Array.isArray(route.children)) {\n for (const child of route.children) {\n checkRouteForAsyncHandler(child, processResolvedRoutes);\n }\n }\n}\n"],"names":["getNavigationContext","WINDOW","DEBUG_BUILD","debug","getActiveRootSpan","addNonEnumerableProperty","isThenable"],"mappings":";;;;;;;
|
|
1
|
+
{"version":3,"file":"lazy-routes.js","sources":["../../../src/reactrouter-compat-utils/lazy-routes.tsx"],"sourcesContent":["import { WINDOW } from '@sentry/browser';\nimport type { Span } from '@sentry/core';\nimport { addNonEnumerableProperty, debug, isThenable } from '@sentry/core';\nimport { DEBUG_BUILD } from '../debug-build';\nimport type { Location, RouteObject } from '../types';\nimport { getActiveRootSpan, getNavigationContext } from './utils';\n\n/**\n * Captures location at invocation time. Prefers navigation context over window.location\n * since window.location hasn't updated yet when async handlers are invoked.\n *\n * When inside a patchRoutesOnNavigation call, uses the captured targetPath. If targetPath\n * is undefined (patchRoutesOnNavigation can be invoked without a path argument), returns\n * null rather than falling back to WINDOW.location which could be stale/wrong after the\n * user navigated away during async loading. Returning null causes the span name update\n * to be skipped, which is safer than using incorrect location data.\n */\nfunction captureCurrentLocation(): Location | null {\n const navContext = getNavigationContext();\n\n if (navContext) {\n if (navContext.targetPath) {\n return {\n pathname: navContext.targetPath,\n search: '',\n hash: '',\n state: null,\n key: 'default',\n };\n }\n // Don't fall back to potentially stale WINDOW.location\n return null;\n }\n\n if (typeof WINDOW !== 'undefined') {\n try {\n const windowLocation = WINDOW.location;\n if (windowLocation) {\n return {\n pathname: windowLocation.pathname,\n search: windowLocation.search || '',\n hash: windowLocation.hash || '',\n state: null,\n key: 'default',\n };\n }\n } catch {\n DEBUG_BUILD && debug.warn('[React Router] Could not access window.location');\n }\n }\n return null;\n}\n\n/**\n * Captures the active span at invocation time. Prefers navigation context span\n * to ensure we update the correct span even if another navigation starts.\n */\nfunction captureActiveSpan(): Span | undefined {\n const navContext = getNavigationContext();\n if (navContext) {\n return navContext.span;\n }\n return getActiveRootSpan();\n}\n\n/**\n * Creates a proxy wrapper for an async handler function.\n * Captures both the location and the active span at invocation time to ensure\n * the correct span is updated when the handler resolves.\n */\nexport function createAsyncHandlerProxy(\n originalFunction: (...args: unknown[]) => unknown,\n route: RouteObject,\n handlerKey: string,\n processResolvedRoutes: (\n resolvedRoutes: RouteObject[],\n parentRoute?: RouteObject,\n currentLocation?: Location,\n capturedSpan?: Span,\n ) => void,\n): (...args: unknown[]) => unknown {\n const proxy = new Proxy(originalFunction, {\n apply(target: (...args: unknown[]) => unknown, thisArg, argArray) {\n const locationAtInvocation = captureCurrentLocation();\n const spanAtInvocation = captureActiveSpan();\n const result = target.apply(thisArg, argArray);\n handleAsyncHandlerResult(\n result,\n route,\n handlerKey,\n processResolvedRoutes,\n locationAtInvocation,\n spanAtInvocation,\n );\n return result;\n },\n });\n\n addNonEnumerableProperty(proxy, '__sentry_proxied__', true);\n\n return proxy;\n}\n\n/**\n * Handles the result of an async handler function call.\n * Passes the captured span through to ensure the correct span is updated.\n */\nexport function handleAsyncHandlerResult(\n result: unknown,\n route: RouteObject,\n handlerKey: string,\n processResolvedRoutes: (\n resolvedRoutes: RouteObject[],\n parentRoute?: RouteObject,\n currentLocation?: Location,\n capturedSpan?: Span,\n ) => void,\n currentLocation: Location | null,\n capturedSpan: Span | undefined,\n): void {\n if (isThenable(result)) {\n (result as Promise<unknown>)\n .then((resolvedRoutes: unknown) => {\n if (Array.isArray(resolvedRoutes)) {\n processResolvedRoutes(resolvedRoutes, route, currentLocation ?? undefined, capturedSpan);\n }\n })\n .catch((e: unknown) => {\n DEBUG_BUILD && debug.warn(`Error resolving async handler '${handlerKey}' for route`, route, e);\n });\n } else if (Array.isArray(result)) {\n processResolvedRoutes(result, route, currentLocation ?? undefined, capturedSpan);\n }\n}\n\n/**\n * Recursively checks a route for async handlers and sets up Proxies to add discovered child routes to allRoutes when called.\n */\nexport function checkRouteForAsyncHandler(\n route: RouteObject,\n processResolvedRoutes: (\n resolvedRoutes: RouteObject[],\n parentRoute?: RouteObject,\n currentLocation?: Location,\n capturedSpan?: Span,\n ) => void,\n): void {\n // Set up proxies for any functions in the route's handle\n if (route.handle && typeof route.handle === 'object') {\n for (const key of Object.keys(route.handle)) {\n const maybeFn = route.handle[key];\n if (typeof maybeFn === 'function' && !(maybeFn as { __sentry_proxied__?: boolean }).__sentry_proxied__) {\n route.handle[key] = createAsyncHandlerProxy(maybeFn, route, key, processResolvedRoutes);\n }\n }\n }\n\n // Recursively check child routes\n if (Array.isArray(route.children)) {\n for (const child of route.children) {\n checkRouteForAsyncHandler(child, processResolvedRoutes);\n }\n }\n}\n"],"names":["getNavigationContext","WINDOW","DEBUG_BUILD","debug","getActiveRootSpan","addNonEnumerableProperty","isThenable"],"mappings":";;;;;;;AAiBA,SAAS,sBAAA,GAA0C;AACjD,EAAA,MAAM,aAAaA,0BAAA,EAAqB;AAExC,EAAA,IAAI,UAAA,EAAY;AACd,IAAA,IAAI,WAAW,UAAA,EAAY;AACzB,MAAA,OAAO;AAAA,QACL,UAAU,UAAA,CAAW,UAAA;AAAA,QACrB,MAAA,EAAQ,EAAA;AAAA,QACR,IAAA,EAAM,EAAA;AAAA,QACN,KAAA,EAAO,IAAA;AAAA,QACP,GAAA,EAAK;AAAA,OACP;AAAA,IACF;AAEA,IAAA,OAAO,IAAA;AAAA,EACT;AAEA,EAAA,IAAI,OAAOC,mBAAW,WAAA,EAAa;AACjC,IAAA,IAAI;AACF,MAAA,MAAM,iBAAiBA,cAAA,CAAO,QAAA;AAC9B,MAAA,IAAI,cAAA,E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,EAAG;AACjC,IAAA,KAAA,MAAW,KAAA,IAAS,MAAM,QAAA,EAAU;AAClC,MAAA,yBAAA,CAA0B,OAAO,qBAAqB,CAAA;AAAA,IACxD;AAAA,EACF;AACF;;;;;;"}
|
|
@@ -1,84 +1,51 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
2
|
|
|
3
|
-
const
|
|
3
|
+
const browser = require('@sentry/core/browser');
|
|
4
4
|
const debugBuild = require('../debug-build.js');
|
|
5
5
|
|
|
6
|
-
/**
|
|
7
|
-
* Strip the basename from a pathname if exists.
|
|
8
|
-
*
|
|
9
|
-
* Vendored and modified from `react-router`
|
|
10
|
-
* https://github.com/remix-run/react-router/blob/462bb712156a3f739d6139a0f14810b76b002df6/packages/router/utils.ts#L1038
|
|
11
|
-
*/
|
|
12
6
|
function stripBasenameFromPathname(pathname, basename) {
|
|
13
|
-
if (!basename || basename ===
|
|
7
|
+
if (!basename || basename === "/") {
|
|
14
8
|
return pathname;
|
|
15
9
|
}
|
|
16
|
-
|
|
17
10
|
if (!pathname.toLowerCase().startsWith(basename.toLowerCase())) {
|
|
18
11
|
return pathname;
|
|
19
12
|
}
|
|
20
|
-
|
|
21
|
-
// We want to leave trailing slash behavior in the user's control, so if they
|
|
22
|
-
// specify a basename with a trailing slash, we should support it
|
|
23
|
-
const startIndex = basename.endsWith('/') ? basename.length - 1 : basename.length;
|
|
13
|
+
const startIndex = basename.endsWith("/") ? basename.length - 1 : basename.length;
|
|
24
14
|
const nextChar = pathname.charAt(startIndex);
|
|
25
|
-
if (nextChar && nextChar !==
|
|
26
|
-
// pathname does not start with basename/
|
|
15
|
+
if (nextChar && nextChar !== "/") {
|
|
27
16
|
return pathname;
|
|
28
17
|
}
|
|
29
|
-
|
|
30
|
-
return pathname.slice(startIndex) || '/';
|
|
18
|
+
return pathname.slice(startIndex) || "/";
|
|
31
19
|
}
|
|
32
|
-
|
|
33
|
-
// Cache for sorted manifests - keyed by manifest array reference
|
|
34
|
-
const SORTED_MANIFEST_CACHE = new WeakMap();
|
|
35
|
-
|
|
36
|
-
/**
|
|
37
|
-
* Matches a pathname against a route manifest and returns the matching pattern.
|
|
38
|
-
* Optionally strips a basename prefix before matching.
|
|
39
|
-
*/
|
|
20
|
+
const SORTED_MANIFEST_CACHE = /* @__PURE__ */ new WeakMap();
|
|
40
21
|
function matchRouteManifest(pathname, manifest, basename) {
|
|
41
22
|
if (!pathname || !manifest?.length) {
|
|
42
23
|
return null;
|
|
43
24
|
}
|
|
44
|
-
|
|
45
25
|
const normalizedPathname = basename ? stripBasenameFromPathname(pathname, basename) : pathname;
|
|
46
|
-
|
|
47
26
|
let sorted = SORTED_MANIFEST_CACHE.get(manifest);
|
|
48
27
|
if (!sorted) {
|
|
49
28
|
sorted = sortBySpecificity(manifest);
|
|
50
29
|
SORTED_MANIFEST_CACHE.set(manifest, sorted);
|
|
51
|
-
debugBuild.DEBUG_BUILD &&
|
|
30
|
+
debugBuild.DEBUG_BUILD && browser.debug.log("[React Router] Sorted route manifest by specificity:", sorted.length, "patterns");
|
|
52
31
|
}
|
|
53
|
-
|
|
54
32
|
for (const pattern of sorted) {
|
|
55
33
|
if (matchesPattern(normalizedPathname, pattern)) {
|
|
56
|
-
debugBuild.DEBUG_BUILD &&
|
|
34
|
+
debugBuild.DEBUG_BUILD && browser.debug.log("[React Router] Matched pathname", normalizedPathname, "to pattern", pattern);
|
|
57
35
|
return pattern;
|
|
58
36
|
}
|
|
59
37
|
}
|
|
60
|
-
|
|
61
|
-
debugBuild.DEBUG_BUILD && core.debug.log('[React Router] No manifest match found for pathname:', normalizedPathname);
|
|
38
|
+
debugBuild.DEBUG_BUILD && browser.debug.log("[React Router] No manifest match found for pathname:", normalizedPathname);
|
|
62
39
|
return null;
|
|
63
40
|
}
|
|
64
|
-
|
|
65
|
-
/**
|
|
66
|
-
* Checks if a pathname matches a route pattern.
|
|
67
|
-
*/
|
|
68
41
|
function matchesPattern(pathname, pattern) {
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
return pathname === '/' || pathname === '';
|
|
42
|
+
if (pattern === "/") {
|
|
43
|
+
return pathname === "/" || pathname === "";
|
|
72
44
|
}
|
|
73
|
-
|
|
74
45
|
const pathSegments = splitPath(pathname);
|
|
75
46
|
const patternSegments = splitPath(pattern);
|
|
76
|
-
|
|
77
|
-
// Handle wildcard at end
|
|
78
|
-
const hasWildcard = patternSegments.length > 0 && patternSegments[patternSegments.length - 1] === '*';
|
|
79
|
-
|
|
47
|
+
const hasWildcard = patternSegments.length > 0 && patternSegments[patternSegments.length - 1] === "*";
|
|
80
48
|
if (hasWildcard) {
|
|
81
|
-
// Pattern with wildcard: path must have at least as many segments as pattern (minus wildcard)
|
|
82
49
|
const patternSegmentsWithoutWildcard = patternSegments.slice(0, -1);
|
|
83
50
|
if (pathSegments.length < patternSegmentsWithoutWildcard.length) {
|
|
84
51
|
return false;
|
|
@@ -90,101 +57,56 @@ function matchesPattern(pathname, pattern) {
|
|
|
90
57
|
}
|
|
91
58
|
return true;
|
|
92
59
|
}
|
|
93
|
-
|
|
94
|
-
// Exact segment count match required
|
|
95
60
|
if (pathSegments.length !== patternSegments.length) {
|
|
96
61
|
return false;
|
|
97
62
|
}
|
|
98
|
-
|
|
99
63
|
for (const [i, patternSegment] of patternSegments.entries()) {
|
|
100
64
|
if (!segmentMatches(pathSegments[i], patternSegment)) {
|
|
101
65
|
return false;
|
|
102
66
|
}
|
|
103
67
|
}
|
|
104
|
-
|
|
105
68
|
return true;
|
|
106
69
|
}
|
|
107
|
-
|
|
108
|
-
/**
|
|
109
|
-
* Checks if a path segment matches a pattern segment.
|
|
110
|
-
*/
|
|
111
70
|
function segmentMatches(pathSegment, patternSegment) {
|
|
112
|
-
if (pathSegment ===
|
|
71
|
+
if (pathSegment === void 0 || patternSegment === void 0) {
|
|
113
72
|
return false;
|
|
114
73
|
}
|
|
115
|
-
// Parameter matches anything
|
|
116
74
|
if (PARAM_RE.test(patternSegment)) {
|
|
117
75
|
return true;
|
|
118
76
|
}
|
|
119
|
-
// Literal must match exactly
|
|
120
77
|
return pathSegment === patternSegment;
|
|
121
78
|
}
|
|
122
|
-
|
|
123
|
-
/**
|
|
124
|
-
* Splits a path into segments, filtering out empty strings.
|
|
125
|
-
*/
|
|
126
79
|
function splitPath(path) {
|
|
127
|
-
return path.split(
|
|
80
|
+
return path.split("/").filter(Boolean);
|
|
128
81
|
}
|
|
129
|
-
|
|
130
|
-
/**
|
|
131
|
-
* React Router scoring weights and param detection.
|
|
132
|
-
* https://github.com/remix-run/react-router/blob/main/packages/react-router/lib/router/utils.ts
|
|
133
|
-
*/
|
|
134
82
|
const PARAM_RE = /^:[\w-]+$/;
|
|
135
83
|
const STATIC_SEGMENT_SCORE = 10;
|
|
136
84
|
const DYNAMIC_SEGMENT_SCORE = 3;
|
|
137
85
|
const EMPTY_SEGMENT_SCORE = 1;
|
|
138
86
|
const SPLAT_PENALTY = -2;
|
|
139
|
-
|
|
140
|
-
/**
|
|
141
|
-
* Computes a specificity score for a route pattern.
|
|
142
|
-
* Matches React Router's computeScore() algorithm exactly.
|
|
143
|
-
*/
|
|
144
87
|
function computeScore(pattern) {
|
|
145
|
-
const segments = pattern.split(
|
|
146
|
-
|
|
147
|
-
// Base score is segment count (including empty segment from leading slash)
|
|
88
|
+
const segments = pattern.split("/");
|
|
148
89
|
let score = segments.length;
|
|
149
|
-
|
|
150
|
-
// Apply splat penalty once if pattern contains wildcard
|
|
151
|
-
if (segments.includes('*')) {
|
|
90
|
+
if (segments.includes("*")) {
|
|
152
91
|
score += SPLAT_PENALTY;
|
|
153
92
|
}
|
|
154
|
-
|
|
155
93
|
for (const segment of segments) {
|
|
156
|
-
if (segment ===
|
|
157
|
-
// Splat penalty already applied globally above
|
|
94
|
+
if (segment === "*") {
|
|
158
95
|
continue;
|
|
159
96
|
} else if (PARAM_RE.test(segment)) {
|
|
160
97
|
score += DYNAMIC_SEGMENT_SCORE;
|
|
161
|
-
} else if (segment ===
|
|
98
|
+
} else if (segment === "") {
|
|
162
99
|
score += EMPTY_SEGMENT_SCORE;
|
|
163
100
|
} else {
|
|
164
101
|
score += STATIC_SEGMENT_SCORE;
|
|
165
102
|
}
|
|
166
103
|
}
|
|
167
|
-
|
|
168
104
|
return score;
|
|
169
105
|
}
|
|
170
|
-
|
|
171
|
-
/**
|
|
172
|
-
* Sorts route patterns by specificity (most specific first).
|
|
173
|
-
* Implements React Router's ranking algorithm from computeScore():
|
|
174
|
-
* https://github.com/remix-run/react-router/blob/main/packages/react-router/lib/router/utils.ts
|
|
175
|
-
*
|
|
176
|
-
* React Router scoring: base=segments.length, static=+10, dynamic=+3, empty=+1, splat=-2 (once)
|
|
177
|
-
* Higher score = more specific pattern.
|
|
178
|
-
* Equal scores preserve manifest order (same as React Router).
|
|
179
|
-
*
|
|
180
|
-
* Note: Users should order their manifest from most specific to least specific
|
|
181
|
-
* when patterns have equal specificity (e.g., `/users/:id/settings` and `/:type/123/settings`).
|
|
182
|
-
*/
|
|
183
106
|
function sortBySpecificity(manifest) {
|
|
184
107
|
return [...manifest].sort((a, b) => {
|
|
185
108
|
const aScore = computeScore(a);
|
|
186
109
|
const bScore = computeScore(b);
|
|
187
|
-
|
|
188
110
|
return bScore - aScore;
|
|
189
111
|
});
|
|
190
112
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"route-manifest.js","sources":["../../../src/reactrouter-compat-utils/route-manifest.ts"],"sourcesContent":["import { debug } from '@sentry/core';\nimport { DEBUG_BUILD } from '../debug-build';\n\n/**\n * Strip the basename from a pathname if exists.\n *\n * Vendored and modified from `react-router`\n * https://github.com/remix-run/react-router/blob/462bb712156a3f739d6139a0f14810b76b002df6/packages/router/utils.ts#L1038\n */\nexport function stripBasenameFromPathname(pathname: string, basename: string): string {\n if (!basename || basename === '/') {\n return pathname;\n }\n\n if (!pathname.toLowerCase().startsWith(basename.toLowerCase())) {\n return pathname;\n }\n\n // We want to leave trailing slash behavior in the user's control, so if they\n // specify a basename with a trailing slash, we should support it\n const startIndex = basename.endsWith('/') ? basename.length - 1 : basename.length;\n const nextChar = pathname.charAt(startIndex);\n if (nextChar && nextChar !== '/') {\n // pathname does not start with basename/\n return pathname;\n }\n\n return pathname.slice(startIndex) || '/';\n}\n\n// Cache for sorted manifests - keyed by manifest array reference\nconst SORTED_MANIFEST_CACHE = new WeakMap<string[], string[]>();\n\n/**\n * Matches a pathname against a route manifest and returns the matching pattern.\n * Optionally strips a basename prefix before matching.\n */\nexport function matchRouteManifest(pathname: string, manifest: string[], basename?: string): string | null {\n if (!pathname || !manifest?.length) {\n return null;\n }\n\n const normalizedPathname = basename ? stripBasenameFromPathname(pathname, basename) : pathname;\n\n let sorted = SORTED_MANIFEST_CACHE.get(manifest);\n if (!sorted) {\n sorted = sortBySpecificity(manifest);\n SORTED_MANIFEST_CACHE.set(manifest, sorted);\n DEBUG_BUILD && debug.log('[React Router] Sorted route manifest by specificity:', sorted.length, 'patterns');\n }\n\n for (const pattern of sorted) {\n if (matchesPattern(normalizedPathname, pattern)) {\n DEBUG_BUILD && debug.log('[React Router] Matched pathname', normalizedPathname, 'to pattern', pattern);\n return pattern;\n }\n }\n\n DEBUG_BUILD && debug.log('[React Router] No manifest match found for pathname:', normalizedPathname);\n return null;\n}\n\n/**\n * Checks if a pathname matches a route pattern.\n */\nfunction matchesPattern(pathname: string, pattern: string): boolean {\n // Handle root path special case\n if (pattern === '/') {\n return pathname === '/' || pathname === '';\n }\n\n const pathSegments = splitPath(pathname);\n const patternSegments = splitPath(pattern);\n\n // Handle wildcard at end\n const hasWildcard = patternSegments.length > 0 && patternSegments[patternSegments.length - 1] === '*';\n\n if (hasWildcard) {\n // Pattern with wildcard: path must have at least as many segments as pattern (minus wildcard)\n const patternSegmentsWithoutWildcard = patternSegments.slice(0, -1);\n if (pathSegments.length < patternSegmentsWithoutWildcard.length) {\n return false;\n }\n for (const [i, patternSegment] of patternSegmentsWithoutWildcard.entries()) {\n if (!segmentMatches(pathSegments[i], patternSegment)) {\n return false;\n }\n }\n return true;\n }\n\n // Exact segment count match required\n if (pathSegments.length !== patternSegments.length) {\n return false;\n }\n\n for (const [i, patternSegment] of patternSegments.entries()) {\n if (!segmentMatches(pathSegments[i], patternSegment)) {\n return false;\n }\n }\n\n return true;\n}\n\n/**\n * Checks if a path segment matches a pattern segment.\n */\nfunction segmentMatches(pathSegment: string | undefined, patternSegment: string | undefined): boolean {\n if (pathSegment === undefined || patternSegment === undefined) {\n return false;\n }\n // Parameter matches anything\n if (PARAM_RE.test(patternSegment)) {\n return true;\n }\n // Literal must match exactly\n return pathSegment === patternSegment;\n}\n\n/**\n * Splits a path into segments, filtering out empty strings.\n */\nfunction splitPath(path: string): string[] {\n return path.split('/').filter(Boolean);\n}\n\n/**\n * React Router scoring weights and param detection.\n * https://github.com/remix-run/react-router/blob/main/packages/react-router/lib/router/utils.ts\n */\nconst PARAM_RE = /^:[\\w-]+$/;\nconst STATIC_SEGMENT_SCORE = 10;\nconst DYNAMIC_SEGMENT_SCORE = 3;\nconst EMPTY_SEGMENT_SCORE = 1;\nconst SPLAT_PENALTY = -2;\n\n/**\n * Computes a specificity score for a route pattern.\n * Matches React Router's computeScore() algorithm exactly.\n */\nfunction computeScore(pattern: string): number {\n const segments = pattern.split('/');\n\n // Base score is segment count (including empty segment from leading slash)\n let score = segments.length;\n\n // Apply splat penalty once if pattern contains wildcard\n if (segments.includes('*')) {\n score += SPLAT_PENALTY;\n }\n\n for (const segment of segments) {\n if (segment === '*') {\n // Splat penalty already applied globally above\n continue;\n } else if (PARAM_RE.test(segment)) {\n score += DYNAMIC_SEGMENT_SCORE;\n } else if (segment === '') {\n score += EMPTY_SEGMENT_SCORE;\n } else {\n score += STATIC_SEGMENT_SCORE;\n }\n }\n\n return score;\n}\n\n/**\n * Sorts route patterns by specificity (most specific first).\n * Implements React Router's ranking algorithm from computeScore():\n * https://github.com/remix-run/react-router/blob/main/packages/react-router/lib/router/utils.ts\n *\n * React Router scoring: base=segments.length, static=+10, dynamic=+3, empty=+1, splat=-2 (once)\n * Higher score = more specific pattern.\n * Equal scores preserve manifest order (same as React Router).\n *\n * Note: Users should order their manifest from most specific to least specific\n * when patterns have equal specificity (e.g., `/users/:id/settings` and `/:type/123/settings`).\n */\nfunction sortBySpecificity(manifest: string[]): string[] {\n return [...manifest].sort((a, b) => {\n const aScore = computeScore(a);\n const bScore = computeScore(b);\n\n return bScore - aScore;\n });\n}\n"],"names":["DEBUG_BUILD","debug"],"mappings":";;;;;AAGA;AACA;AACA;AACA;AACA;AACA;AACO,SAAS,yBAAyB,CAAC,QAAQ,EAAU,QAAQ,EAAkB;AACtF,EAAE,IAAI,CAAC,QAAA,IAAY,QAAA,KAAa,GAAG,EAAE;AACrC,IAAI,OAAO,QAAQ;AACnB,EAAE;;AAEF,EAAE,IAAI,CAAC,QAAQ,CAAC,WAAW,EAAE,CAAC,UAAU,CAAC,QAAQ,CAAC,WAAW,EAAE,CAAC,EAAE;AAClE,IAAI,OAAO,QAAQ;AACnB,EAAE;;AAEF;AACA;AACA,EAAE,MAAM,UAAA,GAAa,QAAQ,CAAC,QAAQ,CAAC,GAAG,CAAA,GAAI,QAAQ,CAAC,MAAA,GAAS,IAAI,QAAQ,CAAC,MAAM;AACnF,EAAE,MAAM,WAAW,QAAQ,CAAC,MAAM,CAAC,UAAU,CAAC;AAC9C,EAAE,IAAI,QAAA,IAAY,QAAA,KAAa,GAAG,EAAE;AACpC;AACA,IAAI,OAAO,QAAQ;AACnB,EAAE;;AAEF,EAAE,OAAO,QAAQ,CAAC,KAAK,CAAC,UAAU,CAAA,IAAK,GAAG;AAC1C;;AAEA;AACA,MAAM,qBAAA,GAAwB,IAAI,OAAO,EAAsB;;AAE/D;AACA;AACA;AACA;AACO,SAAS,kBAAkB,CAAC,QAAQ,EAAU,QAAQ,EAAY,QAAQ,EAA0B;AAC3G,EAAE,IAAI,CAAC,QAAA,IAAY,CAAC,QAAQ,EAAE,MAAM,EAAE;AACtC,IAAI,OAAO,I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Y,CAAC,CAAC,CAAC;;AAElC,IAAI,OAAO,MAAA,GAAS,MAAM;AAC1B,EAAE,CAAC,CAAC;AACJ;;;;;"}
|
|
1
|
+
{"version":3,"file":"route-manifest.js","sources":["../../../src/reactrouter-compat-utils/route-manifest.ts"],"sourcesContent":["import { debug } from '@sentry/core/browser';\nimport { DEBUG_BUILD } from '../debug-build';\n\n/**\n * Strip the basename from a pathname if exists.\n *\n * Vendored and modified from `react-router`\n * https://github.com/remix-run/react-router/blob/462bb712156a3f739d6139a0f14810b76b002df6/packages/router/utils.ts#L1038\n */\nexport function stripBasenameFromPathname(pathname: string, basename: string): string {\n if (!basename || basename === '/') {\n return pathname;\n }\n\n if (!pathname.toLowerCase().startsWith(basename.toLowerCase())) {\n return pathname;\n }\n\n // We want to leave trailing slash behavior in the user's control, so if they\n // specify a basename with a trailing slash, we should support it\n const startIndex = basename.endsWith('/') ? basename.length - 1 : basename.length;\n const nextChar = pathname.charAt(startIndex);\n if (nextChar && nextChar !== '/') {\n // pathname does not start with basename/\n return pathname;\n }\n\n return pathname.slice(startIndex) || '/';\n}\n\n// Cache for sorted manifests - keyed by manifest array reference\nconst SORTED_MANIFEST_CACHE = new WeakMap<string[], string[]>();\n\n/**\n * Matches a pathname against a route manifest and returns the matching pattern.\n * Optionally strips a basename prefix before matching.\n */\nexport function matchRouteManifest(pathname: string, manifest: string[], basename?: string): string | null {\n if (!pathname || !manifest?.length) {\n return null;\n }\n\n const normalizedPathname = basename ? stripBasenameFromPathname(pathname, basename) : pathname;\n\n let sorted = SORTED_MANIFEST_CACHE.get(manifest);\n if (!sorted) {\n sorted = sortBySpecificity(manifest);\n SORTED_MANIFEST_CACHE.set(manifest, sorted);\n DEBUG_BUILD && debug.log('[React Router] Sorted route manifest by specificity:', sorted.length, 'patterns');\n }\n\n for (const pattern of sorted) {\n if (matchesPattern(normalizedPathname, pattern)) {\n DEBUG_BUILD && debug.log('[React Router] Matched pathname', normalizedPathname, 'to pattern', pattern);\n return pattern;\n }\n }\n\n DEBUG_BUILD && debug.log('[React Router] No manifest match found for pathname:', normalizedPathname);\n return null;\n}\n\n/**\n * Checks if a pathname matches a route pattern.\n */\nfunction matchesPattern(pathname: string, pattern: string): boolean {\n // Handle root path special case\n if (pattern === '/') {\n return pathname === '/' || pathname === '';\n }\n\n const pathSegments = splitPath(pathname);\n const patternSegments = splitPath(pattern);\n\n // Handle wildcard at end\n const hasWildcard = patternSegments.length > 0 && patternSegments[patternSegments.length - 1] === '*';\n\n if (hasWildcard) {\n // Pattern with wildcard: path must have at least as many segments as pattern (minus wildcard)\n const patternSegmentsWithoutWildcard = patternSegments.slice(0, -1);\n if (pathSegments.length < patternSegmentsWithoutWildcard.length) {\n return false;\n }\n for (const [i, patternSegment] of patternSegmentsWithoutWildcard.entries()) {\n if (!segmentMatches(pathSegments[i], patternSegment)) {\n return false;\n }\n }\n return true;\n }\n\n // Exact segment count match required\n if (pathSegments.length !== patternSegments.length) {\n return false;\n }\n\n for (const [i, patternSegment] of patternSegments.entries()) {\n if (!segmentMatches(pathSegments[i], patternSegment)) {\n return false;\n }\n }\n\n return true;\n}\n\n/**\n * Checks if a path segment matches a pattern segment.\n */\nfunction segmentMatches(pathSegment: string | undefined, patternSegment: string | undefined): boolean {\n if (pathSegment === undefined || patternSegment === undefined) {\n return false;\n }\n // Parameter matches anything\n if (PARAM_RE.test(patternSegment)) {\n return true;\n }\n // Literal must match exactly\n return pathSegment === patternSegment;\n}\n\n/**\n * Splits a path into segments, filtering out empty strings.\n */\nfunction splitPath(path: string): string[] {\n return path.split('/').filter(Boolean);\n}\n\n/**\n * React Router scoring weights and param detection.\n * https://github.com/remix-run/react-router/blob/main/packages/react-router/lib/router/utils.ts\n */\nconst PARAM_RE = /^:[\\w-]+$/;\nconst STATIC_SEGMENT_SCORE = 10;\nconst DYNAMIC_SEGMENT_SCORE = 3;\nconst EMPTY_SEGMENT_SCORE = 1;\nconst SPLAT_PENALTY = -2;\n\n/**\n * Computes a specificity score for a route pattern.\n * Matches React Router's computeScore() algorithm exactly.\n */\nfunction computeScore(pattern: string): number {\n const segments = pattern.split('/');\n\n // Base score is segment count (including empty segment from leading slash)\n let score = segments.length;\n\n // Apply splat penalty once if pattern contains wildcard\n if (segments.includes('*')) {\n score += SPLAT_PENALTY;\n }\n\n for (const segment of segments) {\n if (segment === '*') {\n // Splat penalty already applied globally above\n continue;\n } else if (PARAM_RE.test(segment)) {\n score += DYNAMIC_SEGMENT_SCORE;\n } else if (segment === '') {\n score += EMPTY_SEGMENT_SCORE;\n } else {\n score += STATIC_SEGMENT_SCORE;\n }\n }\n\n return score;\n}\n\n/**\n * Sorts route patterns by specificity (most specific first).\n * Implements React Router's ranking algorithm from computeScore():\n * https://github.com/remix-run/react-router/blob/main/packages/react-router/lib/router/utils.ts\n *\n * React Router scoring: base=segments.length, static=+10, dynamic=+3, empty=+1, splat=-2 (once)\n * Higher score = more specific pattern.\n * Equal scores preserve manifest order (same as React Router).\n *\n * Note: Users should order their manifest from most specific to least specific\n * when patterns have equal specificity (e.g., `/users/:id/settings` and `/:type/123/settings`).\n */\nfunction sortBySpecificity(manifest: string[]): string[] {\n return [...manifest].sort((a, b) => {\n const aScore = computeScore(a);\n const bScore = computeScore(b);\n\n return bScore - aScore;\n });\n}\n"],"names":["DEBUG_BUILD","debug"],"mappings":";;;;;AASO,SAAS,yBAAA,CAA0B,UAAkB,QAAA,EAA0B;AACpF,EAAA,IAAI,CAAC,QAAA,IAAY,QAAA,KAAa,GAAA,EAAK;AACjC,IAAA,OAAO,QAAA;AAAA,EACT;AAEA,EAAA,IAAI,CAAC,SAAS,WAAA,EAAY,CAAE,WAAW,QAAA,CAAS,WAAA,EAAa,CAAA,EAAG;AAC9D,IAAA,OAAO,QAAA;AAAA,EACT;AAIA,EAAA,MAAM,UAAA,GAAa,SAAS,QAAA,CAAS,GAAG,IAAI,QAAA,CAAS,MAAA,GAAS,IAAI,QAAA,CAAS,MAAA;AAC3E,EAAA,MAAM,QAAA,GAAW,QAAA,C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