@grafana/faro-react 2.8.2 → 2.10.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/dist/bundle/faro-react.iife.js +11 -8
- package/dist/bundle/faro-react.iife.js.map +1 -0
- package/dist/cjs/_virtual/_@oxc-project_runtime@0.143.0/helpers/esm/defineProperty.js +13 -0
- package/dist/cjs/_virtual/_@oxc-project_runtime@0.143.0/helpers/esm/objectSpread2.js +26 -0
- package/dist/cjs/_virtual/_@oxc-project_runtime@0.143.0/helpers/esm/toPrimitive.js +15 -0
- package/dist/cjs/_virtual/_@oxc-project_runtime@0.143.0/helpers/esm/toPropertyKey.js +10 -0
- package/dist/cjs/_virtual/_@oxc-project_runtime@0.143.0/helpers/esm/typeof.js +17 -0
- package/dist/cjs/_virtual/_rolldown/runtime.js +24 -0
- package/dist/cjs/dependencies.js +20 -4
- package/dist/cjs/dependencies.js.map +1 -1
- package/dist/cjs/errorBoundary/FaroErrorBoundary.js +62 -67
- package/dist/cjs/errorBoundary/FaroErrorBoundary.js.map +1 -1
- package/dist/cjs/errorBoundary/const.js +7 -4
- package/dist/cjs/errorBoundary/const.js.map +1 -1
- package/dist/cjs/errorBoundary/index.js +6 -8
- package/dist/cjs/errorBoundary/types.js +0 -1
- package/dist/cjs/errorBoundary/withFaroErrorBoundary.js +17 -15
- package/dist/cjs/errorBoundary/withFaroErrorBoundary.js.map +1 -1
- package/dist/cjs/index.js +480 -108
- package/dist/cjs/instrumentation.js +19 -16
- package/dist/cjs/instrumentation.js.map +1 -1
- package/dist/cjs/profiler/FaroProfiler.js +75 -97
- package/dist/cjs/profiler/FaroProfiler.js.map +1 -1
- package/dist/cjs/profiler/index.js +4 -6
- package/dist/cjs/profiler/withFaroProfiler.js +20 -15
- package/dist/cjs/profiler/withFaroProfiler.js.map +1 -1
- package/dist/cjs/router/index.js +26 -21
- package/dist/cjs/router/initialize.js +30 -26
- package/dist/cjs/router/initialize.js.map +1 -1
- package/dist/cjs/router/types.js +20 -16
- package/dist/cjs/router/types.js.map +1 -1
- package/dist/cjs/router/v4v5/FaroRoute.js +12 -12
- package/dist/cjs/router/v4v5/FaroRoute.js.map +1 -1
- package/dist/cjs/router/v4v5/activeEvent.js +23 -17
- package/dist/cjs/router/v4v5/activeEvent.js.map +1 -1
- package/dist/cjs/router/v4v5/index.js +8 -10
- package/dist/cjs/router/v4v5/initialize.js +36 -34
- package/dist/cjs/router/v4v5/initialize.js.map +1 -1
- package/dist/cjs/router/v4v5/routerDependencies.js +30 -8
- package/dist/cjs/router/v4v5/routerDependencies.js.map +1 -1
- package/dist/cjs/router/v4v5/types.js +0 -1
- package/dist/cjs/router/v6v7/FaroRoutes.js +42 -59
- package/dist/cjs/router/v6v7/FaroRoutes.js.map +1 -1
- package/dist/cjs/router/v6v7/index.js +14 -16
- package/dist/cjs/router/v6v7/initialize.js +34 -32
- package/dist/cjs/router/v6v7/initialize.js.map +1 -1
- package/dist/cjs/router/v6v7/routerDependencies.js +59 -16
- package/dist/cjs/router/v6v7/routerDependencies.js.map +1 -1
- package/dist/cjs/router/v6v7/types.js +0 -1
- package/dist/cjs/router/v6v7/utils.js +27 -32
- package/dist/cjs/router/v6v7/utils.js.map +1 -1
- package/dist/cjs/router/v6v7/withFaroRouterInstrumentation.js +32 -25
- package/dist/cjs/router/v6v7/withFaroRouterInstrumentation.js.map +1 -1
- package/dist/cjs/types.js +0 -1
- package/dist/cjs/utils/index.js +9 -11
- package/dist/cjs/utils/reactVersion.js +24 -18
- package/dist/cjs/utils/reactVersion.js.map +1 -1
- package/dist/esm/_virtual/_@oxc-project_runtime@0.143.0/helpers/esm/defineProperty.js +12 -0
- package/dist/esm/_virtual/_@oxc-project_runtime@0.143.0/helpers/esm/objectSpread2.js +25 -0
- package/dist/esm/_virtual/_@oxc-project_runtime@0.143.0/helpers/esm/toPrimitive.js +14 -0
- package/dist/esm/_virtual/_@oxc-project_runtime@0.143.0/helpers/esm/toPropertyKey.js +9 -0
- package/dist/esm/_virtual/_@oxc-project_runtime@0.143.0/helpers/esm/typeof.js +11 -0
- package/dist/esm/dependencies.js +9 -5
- package/dist/esm/dependencies.js.map +1 -1
- package/dist/esm/errorBoundary/FaroErrorBoundary.js +61 -66
- package/dist/esm/errorBoundary/FaroErrorBoundary.js.map +1 -1
- package/dist/esm/errorBoundary/const.js +7 -3
- package/dist/esm/errorBoundary/const.js.map +1 -1
- package/dist/esm/errorBoundary/index.js +4 -4
- package/dist/esm/errorBoundary/types.js +0 -2
- package/dist/esm/errorBoundary/withFaroErrorBoundary.js +15 -12
- package/dist/esm/errorBoundary/withFaroErrorBoundary.js.map +1 -1
- package/dist/esm/index.js +21 -7
- package/dist/esm/instrumentation.js +20 -15
- package/dist/esm/instrumentation.js.map +1 -1
- package/dist/esm/profiler/FaroProfiler.js +74 -96
- package/dist/esm/profiler/FaroProfiler.js.map +1 -1
- package/dist/esm/profiler/index.js +3 -3
- package/dist/esm/profiler/withFaroProfiler.js +18 -12
- package/dist/esm/profiler/withFaroProfiler.js.map +1 -1
- package/dist/esm/router/index.js +12 -5
- package/dist/esm/router/initialize.js +31 -26
- package/dist/esm/router/initialize.js.map +1 -1
- package/dist/esm/router/types.js +19 -15
- package/dist/esm/router/types.js.map +1 -1
- package/dist/esm/router/v4v5/FaroRoute.js +11 -9
- package/dist/esm/router/v4v5/FaroRoute.js.map +1 -1
- package/dist/esm/router/v4v5/activeEvent.js +18 -16
- package/dist/esm/router/v4v5/activeEvent.js.map +1 -1
- package/dist/esm/router/v4v5/index.js +4 -4
- package/dist/esm/router/v4v5/initialize.js +35 -31
- package/dist/esm/router/v4v5/initialize.js.map +1 -1
- package/dist/esm/router/v4v5/routerDependencies.js +13 -9
- package/dist/esm/router/v4v5/routerDependencies.js.map +1 -1
- package/dist/esm/router/v4v5/types.js +0 -2
- package/dist/esm/router/v6v7/FaroRoutes.js +41 -26
- package/dist/esm/router/v6v7/FaroRoutes.js.map +1 -1
- package/dist/esm/router/v6v7/index.js +5 -5
- package/dist/esm/router/v6v7/initialize.js +33 -29
- package/dist/esm/router/v6v7/initialize.js.map +1 -1
- package/dist/esm/router/v6v7/routerDependencies.js +24 -20
- package/dist/esm/router/v6v7/routerDependencies.js.map +1 -1
- package/dist/esm/router/v6v7/types.js +0 -2
- package/dist/esm/router/v6v7/utils.js +28 -32
- package/dist/esm/router/v6v7/utils.js.map +1 -1
- package/dist/esm/router/v6v7/withFaroRouterInstrumentation.js +33 -25
- package/dist/esm/router/v6v7/withFaroRouterInstrumentation.js.map +1 -1
- package/dist/esm/types.js +0 -2
- package/dist/esm/utils/index.js +2 -2
- package/dist/esm/utils/reactVersion.js +20 -17
- package/dist/esm/utils/reactVersion.js.map +1 -1
- package/dist/types/dependencies.d.ts +7 -4
- package/dist/types/errorBoundary/FaroErrorBoundary.d.ts +15 -13
- package/dist/types/errorBoundary/const.d.ts +5 -2
- package/dist/types/errorBoundary/index.d.ts +5 -4
- package/dist/types/errorBoundary/types.d.ts +20 -17
- package/dist/types/errorBoundary/withFaroErrorBoundary.d.ts +6 -3
- package/dist/types/index.d.ts +24 -11
- package/dist/types/instrumentation.d.ts +11 -8
- package/dist/types/profiler/FaroProfiler.d.ts +24 -22
- package/dist/types/profiler/index.d.ts +3 -3
- package/dist/types/profiler/withFaroProfiler.d.ts +6 -3
- package/dist/types/router/index.d.ts +14 -7
- package/dist/types/router/initialize.d.ts +5 -2
- package/dist/types/router/types.d.ts +23 -20
- package/dist/types/router/v4v5/FaroRoute.d.ts +6 -3
- package/dist/types/router/v4v5/activeEvent.d.ts +8 -5
- package/dist/types/router/v4v5/index.d.ts +5 -4
- package/dist/types/router/v4v5/initialize.d.ts +8 -5
- package/dist/types/router/v4v5/routerDependencies.d.ts +10 -7
- package/dist/types/router/v4v5/types.d.ts +16 -13
- package/dist/types/router/v6v7/FaroRoutes.d.ts +6 -3
- package/dist/types/router/v6v7/index.d.ts +6 -5
- package/dist/types/router/v6v7/initialize.d.ts +11 -8
- package/dist/types/router/v6v7/routerDependencies.d.ts +14 -11
- package/dist/types/router/v6v7/types.d.ts +57 -58
- package/dist/types/router/v6v7/utils.d.ts +7 -4
- package/dist/types/router/v6v7/withFaroRouterInstrumentation.d.ts +11 -10
- package/dist/types/types.d.ts +24 -18
- package/dist/types/utils/index.d.ts +2 -1
- package/dist/types/utils/reactVersion.d.ts +11 -8
- package/package.json +17 -21
- package/dist/bundle/types/dependencies.d.ts +0 -4
- package/dist/bundle/types/errorBoundary/FaroErrorBoundary.d.ts +0 -14
- package/dist/bundle/types/errorBoundary/const.d.ts +0 -2
- package/dist/bundle/types/errorBoundary/index.d.ts +0 -4
- package/dist/bundle/types/errorBoundary/types.d.ts +0 -19
- package/dist/bundle/types/errorBoundary/withFaroErrorBoundary.d.ts +0 -3
- package/dist/bundle/types/index.d.ts +0 -11
- package/dist/bundle/types/instrumentation.d.ts +0 -9
- package/dist/bundle/types/profiler/FaroProfiler.d.ts +0 -24
- package/dist/bundle/types/profiler/FaroProfiler.test.d.ts +0 -1
- package/dist/bundle/types/profiler/index.d.ts +0 -3
- package/dist/bundle/types/profiler/withFaroProfiler.d.ts +0 -3
- package/dist/bundle/types/router/index.d.ts +0 -7
- package/dist/bundle/types/router/initialize.d.ts +0 -2
- package/dist/bundle/types/router/types.d.ts +0 -24
- package/dist/bundle/types/router/v4v5/FaroRoute.d.ts +0 -3
- package/dist/bundle/types/router/v4v5/activeEvent.d.ts +0 -5
- package/dist/bundle/types/router/v4v5/index.d.ts +0 -4
- package/dist/bundle/types/router/v4v5/initialize.d.ts +0 -5
- package/dist/bundle/types/router/v4v5/routerDependencies.d.ts +0 -7
- package/dist/bundle/types/router/v4v5/types.d.ts +0 -16
- package/dist/bundle/types/router/v6v7/FaroRoutes.d.ts +0 -3
- package/dist/bundle/types/router/v6v7/index.d.ts +0 -5
- package/dist/bundle/types/router/v6v7/initialize.d.ts +0 -8
- package/dist/bundle/types/router/v6v7/routerDependencies.d.ts +0 -11
- package/dist/bundle/types/router/v6v7/types.d.ts +0 -69
- package/dist/bundle/types/router/v6v7/utils.d.ts +0 -4
- package/dist/bundle/types/router/v6v7/withFaroRouterInstrumentation.d.ts +0 -17
- package/dist/bundle/types/types.d.ts +0 -24
- package/dist/bundle/types/utils/index.d.ts +0 -1
- package/dist/bundle/types/utils/reactVersion.d.ts +0 -8
- package/dist/cjs/errorBoundary/index.js.map +0 -1
- package/dist/cjs/errorBoundary/types.js.map +0 -1
- package/dist/cjs/index.js.map +0 -1
- package/dist/cjs/profiler/FaroProfiler.test.js +0 -75
- package/dist/cjs/profiler/FaroProfiler.test.js.map +0 -1
- package/dist/cjs/profiler/index.js.map +0 -1
- package/dist/cjs/router/index.js.map +0 -1
- package/dist/cjs/router/v4v5/index.js.map +0 -1
- package/dist/cjs/router/v4v5/types.js.map +0 -1
- package/dist/cjs/router/v6v7/index.js.map +0 -1
- package/dist/cjs/router/v6v7/types.js.map +0 -1
- package/dist/cjs/types.js.map +0 -1
- package/dist/cjs/utils/index.js.map +0 -1
- package/dist/esm/errorBoundary/index.js.map +0 -1
- package/dist/esm/errorBoundary/types.js.map +0 -1
- package/dist/esm/index.js.map +0 -1
- package/dist/esm/profiler/FaroProfiler.test.js +0 -73
- package/dist/esm/profiler/FaroProfiler.test.js.map +0 -1
- package/dist/esm/profiler/index.js.map +0 -1
- package/dist/esm/router/index.js.map +0 -1
- package/dist/esm/router/v4v5/index.js.map +0 -1
- package/dist/esm/router/v4v5/types.js.map +0 -1
- package/dist/esm/router/v6v7/index.js.map +0 -1
- package/dist/esm/router/v6v7/types.js.map +0 -1
- package/dist/esm/types.js.map +0 -1
- package/dist/esm/utils/index.js.map +0 -1
- package/dist/types/profiler/FaroProfiler.test.d.ts +0 -1
|
@@ -1,39 +1,34 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
const routerDependencies_1 = require("./routerDependencies");
|
|
3
|
+
const require_router_v6v7_routerDependencies = require("./routerDependencies.js");
|
|
4
|
+
//#region src/router/v6v7/utils.ts
|
|
6
5
|
function getNumberOfUrlSegments(url) {
|
|
7
|
-
|
|
6
|
+
return url.split(/\\?\//).filter((currentSegment) => currentSegment.length > 0 && currentSegment !== ",").length;
|
|
8
7
|
}
|
|
9
8
|
function getRouteFromLocation(routes, location) {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
}
|
|
31
|
-
return pathBuilder;
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
return location.pathname;
|
|
9
|
+
if (!routes || routes.length === 0) return location.pathname;
|
|
10
|
+
const matchedRoutes = require_router_v6v7_routerDependencies.matchRoutes(routes, location);
|
|
11
|
+
let pathBuilder = "";
|
|
12
|
+
if (matchedRoutes) for (let x = 0; x < matchedRoutes.length; x++) {
|
|
13
|
+
const branch = matchedRoutes[x];
|
|
14
|
+
const route = branch.route;
|
|
15
|
+
if (route) {
|
|
16
|
+
if (route.index) return branch.pathname;
|
|
17
|
+
let path = route.path;
|
|
18
|
+
if (path) {
|
|
19
|
+
path = path.startsWith("/") ? path : `/${path}`;
|
|
20
|
+
pathBuilder += path;
|
|
21
|
+
if (branch.pathname === location.pathname) {
|
|
22
|
+
if (getNumberOfUrlSegments(pathBuilder) !== getNumberOfUrlSegments(branch.pathname)) return path;
|
|
23
|
+
return pathBuilder;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
return location.pathname;
|
|
38
29
|
}
|
|
30
|
+
//#endregion
|
|
31
|
+
exports.getNumberOfUrlSegments = getNumberOfUrlSegments;
|
|
32
|
+
exports.getRouteFromLocation = getRouteFromLocation;
|
|
33
|
+
|
|
39
34
|
//# sourceMappingURL=utils.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.js","
|
|
1
|
+
{"version":3,"file":"utils.js","names":["matchRoutes"],"sources":["../../../../src/router/v6v7/utils.ts"],"sourcesContent":["import type { ReactRouterLocation } from '../types';\n\nimport { matchRoutes } from './routerDependencies';\nimport type { ReactRouterV6RouteObject } from './types';\n\nexport function getNumberOfUrlSegments(url: string): number {\n return url.split(/\\\\?\\//).filter((currentSegment) => currentSegment.length > 0 && currentSegment !== ',').length;\n}\n\nexport function getRouteFromLocation(routes: ReactRouterV6RouteObject[], location: ReactRouterLocation): string {\n if (!routes || routes.length === 0) {\n return location.pathname;\n }\n\n const matchedRoutes = matchRoutes(routes, location);\n\n let pathBuilder = '';\n\n if (matchedRoutes) {\n for (let x = 0; x < matchedRoutes.length; x++) {\n const branch = matchedRoutes[x]!;\n const route = branch.route;\n\n if (route) {\n if (route.index) {\n return branch.pathname;\n }\n\n let path = route.path;\n\n if (path) {\n path = path.startsWith('/') ? path : `/${path}`;\n\n pathBuilder += path;\n\n if (branch.pathname === location.pathname) {\n if (getNumberOfUrlSegments(pathBuilder) !== getNumberOfUrlSegments(branch.pathname)) {\n return path;\n }\n\n return pathBuilder;\n }\n }\n }\n }\n }\n\n return location.pathname;\n}\n"],"mappings":";;;;AAKA,SAAgB,uBAAuB,KAAqB;CAC1D,OAAO,IAAI,MAAM,OAAO,CAAC,CAAC,QAAQ,mBAAmB,eAAe,SAAS,KAAK,mBAAmB,GAAG,CAAC,CAAC;AAC5G;AAEA,SAAgB,qBAAqB,QAAoC,UAAuC;CAC9G,IAAI,CAAC,UAAU,OAAO,WAAW,GAC/B,OAAO,SAAS;CAGlB,MAAM,gBAAgBA,uCAAAA,YAAY,QAAQ,QAAQ;CAElD,IAAI,cAAc;CAElB,IAAI,eACF,KAAK,IAAI,IAAI,GAAG,IAAI,cAAc,QAAQ,KAAK;EAC7C,MAAM,SAAS,cAAc;EAC7B,MAAM,QAAQ,OAAO;EAErB,IAAI,OAAO;GACT,IAAI,MAAM,OACR,OAAO,OAAO;GAGhB,IAAI,OAAO,MAAM;GAEjB,IAAI,MAAM;IACR,OAAO,KAAK,WAAW,GAAG,IAAI,OAAO,IAAI;IAEzC,eAAe;IAEf,IAAI,OAAO,aAAa,SAAS,UAAU;KACzC,IAAI,uBAAuB,WAAW,MAAM,uBAAuB,OAAO,QAAQ,GAChF,OAAO;KAGT,OAAO;IACT;GACF;EACF;CACF;CAGF,OAAO,SAAS;AAClB"}
|
|
@@ -1,31 +1,38 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
const
|
|
6
|
-
const
|
|
7
|
-
const
|
|
8
|
-
|
|
3
|
+
const require_dependencies = require("../../dependencies.js");
|
|
4
|
+
require("../types.js");
|
|
5
|
+
const require_router_v6v7_routerDependencies = require("./routerDependencies.js");
|
|
6
|
+
const require_router_v6v7_utils = require("./utils.js");
|
|
7
|
+
const require_objectSpread2 = require("../../_virtual/_@oxc-project_runtime@0.143.0/helpers/esm/objectSpread2.js");
|
|
8
|
+
let _grafana_faro_web_sdk = require("@grafana/faro-web-sdk");
|
|
9
|
+
//#region src/router/v6v7/withFaroRouterInstrumentation.ts
|
|
9
10
|
/**
|
|
10
|
-
|
|
11
|
-
|
|
11
|
+
* To use with React Router 6.4 data APIs.
|
|
12
|
+
*/
|
|
12
13
|
function withFaroRouterInstrumentation(router) {
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
14
|
+
let lastRoute = {};
|
|
15
|
+
router.subscribe((state) => {
|
|
16
|
+
const navigationType = state.historyAction;
|
|
17
|
+
const location = state.location;
|
|
18
|
+
const routes = router.routes;
|
|
19
|
+
if (require_router_v6v7_routerDependencies.isInitialized && (navigationType === "PUSH" || navigationType === "POP")) {
|
|
20
|
+
var _globalObject$locatio, _globalObject$locatio2;
|
|
21
|
+
const route = require_router_v6v7_utils.getRouteFromLocation(routes, location);
|
|
22
|
+
const url = (_globalObject$locatio = _grafana_faro_web_sdk.globalObject.location) === null || _globalObject$locatio === void 0 ? void 0 : _globalObject$locatio.href;
|
|
23
|
+
require_dependencies.api.pushEvent(_grafana_faro_web_sdk.EVENT_ROUTE_CHANGE, require_objectSpread2.default({
|
|
24
|
+
toRoute: route,
|
|
25
|
+
toUrl: (_globalObject$locatio2 = _grafana_faro_web_sdk.globalObject.location) === null || _globalObject$locatio2 === void 0 ? void 0 : _globalObject$locatio2.href
|
|
26
|
+
}, lastRoute));
|
|
27
|
+
lastRoute = {
|
|
28
|
+
fromRoute: route,
|
|
29
|
+
fromUrl: url
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
});
|
|
33
|
+
return router;
|
|
30
34
|
}
|
|
35
|
+
//#endregion
|
|
36
|
+
exports.withFaroRouterInstrumentation = withFaroRouterInstrumentation;
|
|
37
|
+
|
|
31
38
|
//# sourceMappingURL=withFaroRouterInstrumentation.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"withFaroRouterInstrumentation.js","
|
|
1
|
+
{"version":3,"file":"withFaroRouterInstrumentation.js","names":["isInitialized","getRouteFromLocation","globalObject","EVENT_ROUTE_CHANGE"],"sources":["../../../../src/router/v6v7/withFaroRouterInstrumentation.ts"],"sourcesContent":["import { EVENT_ROUTE_CHANGE, globalObject } from '@grafana/faro-web-sdk';\n\nimport { api } from '../../dependencies';\nimport { NavigationType } from '../types';\nimport type { ReactRouterLocation } from '../types';\n\nimport { isInitialized } from './routerDependencies';\nimport type { EventRouteTransitionAttributes, RouteObjectV6DataRouter } from './types';\nimport { getRouteFromLocation } from './utils';\n\ninterface RouterState {\n historyAction: NavigationType | any;\n location: ReactRouterLocation;\n}\n\ninterface Router {\n state: RouterState;\n routes: RouteObjectV6DataRouter[];\n subscribe(fn: (state: RouterState) => void): () => void;\n}\n\n/**\n * To use with React Router 6.4 data APIs.\n */\nexport function withFaroRouterInstrumentation<R extends Router = Router>(router: R): R {\n let lastRoute: EventRouteTransitionAttributes = {};\n\n router.subscribe((state) => {\n const navigationType: NavigationType = state.historyAction;\n const location = state.location;\n const routes = router.routes;\n\n if (isInitialized && (navigationType === NavigationType.Push || navigationType === NavigationType.Pop)) {\n const route = getRouteFromLocation(routes, location);\n const url = globalObject.location?.href;\n\n api.pushEvent(EVENT_ROUTE_CHANGE, {\n toRoute: route,\n toUrl: globalObject.location?.href,\n ...lastRoute,\n });\n\n lastRoute = {\n fromRoute: route,\n fromUrl: url,\n };\n }\n });\n\n return router;\n}\n"],"mappings":";;;;;;;;;;;;AAwBA,SAAgB,8BAAyD,QAAc;CACrF,IAAI,YAA4C,CAAC;CAEjD,OAAO,WAAW,UAAU;EAC1B,MAAM,iBAAiC,MAAM;EAC7C,MAAM,WAAW,MAAM;EACvB,MAAM,SAAS,OAAO;EAEtB,IAAIA,uCAAAA,kBAAkB,mBAAA,UAA0C,mBAAA,QAAwC;;GACtG,MAAM,QAAQC,0BAAAA,qBAAqB,QAAQ,QAAQ;GACnD,MAAM,OAAA,wBAAMC,sBAAAA,aAAa,cAAA,QAAA,0BAAA,KAAA,IAAA,KAAA,IAAA,sBAAU;GAEnC,qBAAA,IAAI,UAAUC,sBAAAA,oBAAAA,sBAAAA,QAAAA;IACZ,SAAS;IACT,QAAA,yBAAOD,sBAAAA,aAAa,cAAA,QAAA,2BAAA,KAAA,IAAA,KAAA,IAAA,uBAAU;GAC3B,GAAA,SACL,CAAC;GAED,YAAY;IACV,WAAW;IACX,SAAS;GACX;EACF;CACF,CAAC;CAED,OAAO;AACT"}
|
package/dist/cjs/types.js
CHANGED
package/dist/cjs/utils/index.js
CHANGED
|
@@ -1,13 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
Object.defineProperty(exports, "reactVersionMajor", { enumerable: true, get: function () { return reactVersion_1.reactVersionMajor; } });
|
|
13
|
-
//# sourceMappingURL=index.js.map
|
|
3
|
+
const require_utils_reactVersion = require("./reactVersion.js");
|
|
4
|
+
exports.getMajorReactVersion = require_utils_reactVersion.getMajorReactVersion;
|
|
5
|
+
exports.isReactVersionAtLeast = require_utils_reactVersion.isReactVersionAtLeast;
|
|
6
|
+
exports.isReactVersionAtLeast16 = require_utils_reactVersion.isReactVersionAtLeast16;
|
|
7
|
+
exports.isReactVersionAtLeast17 = require_utils_reactVersion.isReactVersionAtLeast17;
|
|
8
|
+
exports.isReactVersionAtLeast18 = require_utils_reactVersion.isReactVersionAtLeast18;
|
|
9
|
+
exports.isReactVersionAtLeast19 = require_utils_reactVersion.isReactVersionAtLeast19;
|
|
10
|
+
exports.reactVersion = require_utils_reactVersion.reactVersion;
|
|
11
|
+
exports.reactVersionMajor = require_utils_reactVersion.reactVersionMajor;
|
|
@@ -1,25 +1,31 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
const
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
exports.isReactVersionAtLeast18 = isReactVersionAtLeast(18);
|
|
11
|
-
exports.isReactVersionAtLeast17 = isReactVersionAtLeast(17);
|
|
12
|
-
exports.isReactVersionAtLeast16 = isReactVersionAtLeast(16);
|
|
3
|
+
//#region src/utils/reactVersion.ts
|
|
4
|
+
const reactVersion = require("react").version;
|
|
5
|
+
const reactVersionMajor = getMajorReactVersion();
|
|
6
|
+
const isReactVersionAtLeast19 = isReactVersionAtLeast(19);
|
|
7
|
+
const isReactVersionAtLeast18 = isReactVersionAtLeast(18);
|
|
8
|
+
const isReactVersionAtLeast17 = isReactVersionAtLeast(17);
|
|
9
|
+
const isReactVersionAtLeast16 = isReactVersionAtLeast(16);
|
|
13
10
|
function getMajorReactVersion() {
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
}
|
|
11
|
+
const major = reactVersion.split(".");
|
|
12
|
+
try {
|
|
13
|
+
return major[0] ? parseInt(major[0], 10) : null;
|
|
14
|
+
} catch (_err) {
|
|
15
|
+
return null;
|
|
16
|
+
}
|
|
21
17
|
}
|
|
22
18
|
function isReactVersionAtLeast(version) {
|
|
23
|
-
|
|
19
|
+
return reactVersionMajor === null ? false : reactVersionMajor >= version;
|
|
24
20
|
}
|
|
21
|
+
//#endregion
|
|
22
|
+
exports.getMajorReactVersion = getMajorReactVersion;
|
|
23
|
+
exports.isReactVersionAtLeast = isReactVersionAtLeast;
|
|
24
|
+
exports.isReactVersionAtLeast16 = isReactVersionAtLeast16;
|
|
25
|
+
exports.isReactVersionAtLeast17 = isReactVersionAtLeast17;
|
|
26
|
+
exports.isReactVersionAtLeast18 = isReactVersionAtLeast18;
|
|
27
|
+
exports.isReactVersionAtLeast19 = isReactVersionAtLeast19;
|
|
28
|
+
exports.reactVersion = reactVersion;
|
|
29
|
+
exports.reactVersionMajor = reactVersionMajor;
|
|
30
|
+
|
|
25
31
|
//# sourceMappingURL=reactVersion.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"reactVersion.js","
|
|
1
|
+
{"version":3,"file":"reactVersion.js","names":["version"],"sources":["../../../src/utils/reactVersion.ts"],"sourcesContent":["import { version } from 'react';\n\nexport const reactVersion: string = version;\nexport const reactVersionMajor: number | null = getMajorReactVersion();\nexport const isReactVersionAtLeast19: boolean = isReactVersionAtLeast(19);\nexport const isReactVersionAtLeast18: boolean = isReactVersionAtLeast(18);\nexport const isReactVersionAtLeast17: boolean = isReactVersionAtLeast(17);\nexport const isReactVersionAtLeast16: boolean = isReactVersionAtLeast(16);\n\nexport function getMajorReactVersion(): number | null {\n const major = reactVersion.split('.');\n\n try {\n return major[0] ? parseInt(major[0], 10) : null;\n } catch (_err) {\n return null;\n }\n}\n\nexport function isReactVersionAtLeast(version: number): boolean {\n return reactVersionMajor === null ? false : reactVersionMajor >= version;\n}\n"],"mappings":";;;AAEA,MAAa,8BAAuBA,CAAAA,CAAAA;AACpC,MAAa,oBAAmC,qBAAqB;AACrE,MAAa,0BAAmC,sBAAsB,EAAE;AACxE,MAAa,0BAAmC,sBAAsB,EAAE;AACxE,MAAa,0BAAmC,sBAAsB,EAAE;AACxE,MAAa,0BAAmC,sBAAsB,EAAE;AAExE,SAAgB,uBAAsC;CACpD,MAAM,QAAQ,aAAa,MAAM,GAAG;CAEpC,IAAI;EACF,OAAO,MAAM,KAAK,SAAS,MAAM,IAAI,EAAE,IAAI;CAC7C,SAAS,MAAM;EACb,OAAO;CACT;AACF;AAEA,SAAgB,sBAAsB,SAA0B;CAC9D,OAAO,sBAAsB,OAAO,QAAQ,qBAAqB;AACnE"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import toPropertyKey from "./toPropertyKey.js";
|
|
2
|
+
//#region \0@oxc-project+runtime@0.143.0/helpers/esm/defineProperty.js
|
|
3
|
+
function _defineProperty(e, r, t) {
|
|
4
|
+
return (r = toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
|
|
5
|
+
value: t,
|
|
6
|
+
enumerable: !0,
|
|
7
|
+
configurable: !0,
|
|
8
|
+
writable: !0
|
|
9
|
+
}) : e[r] = t, e;
|
|
10
|
+
}
|
|
11
|
+
//#endregion
|
|
12
|
+
export { _defineProperty as default };
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import _defineProperty from "./defineProperty.js";
|
|
2
|
+
//#region \0@oxc-project+runtime@0.143.0/helpers/esm/objectSpread2.js
|
|
3
|
+
function ownKeys(e, r) {
|
|
4
|
+
var t = Object.keys(e);
|
|
5
|
+
if (Object.getOwnPropertySymbols) {
|
|
6
|
+
var o = Object.getOwnPropertySymbols(e);
|
|
7
|
+
r && (o = o.filter(function(r) {
|
|
8
|
+
return Object.getOwnPropertyDescriptor(e, r).enumerable;
|
|
9
|
+
})), t.push.apply(t, o);
|
|
10
|
+
}
|
|
11
|
+
return t;
|
|
12
|
+
}
|
|
13
|
+
function _objectSpread2(e) {
|
|
14
|
+
for (var r = 1; r < arguments.length; r++) {
|
|
15
|
+
var t = null != arguments[r] ? arguments[r] : {};
|
|
16
|
+
r % 2 ? ownKeys(Object(t), !0).forEach(function(r) {
|
|
17
|
+
_defineProperty(e, r, t[r]);
|
|
18
|
+
}) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function(r) {
|
|
19
|
+
Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r));
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
return e;
|
|
23
|
+
}
|
|
24
|
+
//#endregion
|
|
25
|
+
export { _objectSpread2 as default };
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import _typeof from "./typeof.js";
|
|
2
|
+
//#region \0@oxc-project+runtime@0.143.0/helpers/esm/toPrimitive.js
|
|
3
|
+
function toPrimitive(t, r) {
|
|
4
|
+
if ("object" != _typeof(t) || !t) return t;
|
|
5
|
+
var e = t[Symbol.toPrimitive];
|
|
6
|
+
if (void 0 !== e) {
|
|
7
|
+
var i = e.call(t, r || "default");
|
|
8
|
+
if ("object" != _typeof(i)) return i;
|
|
9
|
+
throw new TypeError("@@toPrimitive must return a primitive value.");
|
|
10
|
+
}
|
|
11
|
+
return ("string" === r ? String : Number)(t);
|
|
12
|
+
}
|
|
13
|
+
//#endregion
|
|
14
|
+
export { toPrimitive as default };
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import _typeof from "./typeof.js";
|
|
2
|
+
import toPrimitive from "./toPrimitive.js";
|
|
3
|
+
//#region \0@oxc-project+runtime@0.143.0/helpers/esm/toPropertyKey.js
|
|
4
|
+
function toPropertyKey(t) {
|
|
5
|
+
var i = toPrimitive(t, "string");
|
|
6
|
+
return "symbol" == _typeof(i) ? i : i + "";
|
|
7
|
+
}
|
|
8
|
+
//#endregion
|
|
9
|
+
export { toPropertyKey as default };
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
//#region \0@oxc-project+runtime@0.143.0/helpers/esm/typeof.js
|
|
2
|
+
function _typeof(o) {
|
|
3
|
+
"@babel/helpers - typeof";
|
|
4
|
+
return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(o) {
|
|
5
|
+
return typeof o;
|
|
6
|
+
} : function(o) {
|
|
7
|
+
return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o;
|
|
8
|
+
}, _typeof(o);
|
|
9
|
+
}
|
|
10
|
+
//#endregion
|
|
11
|
+
export { _typeof as default };
|
package/dist/esm/dependencies.js
CHANGED
|
@@ -1,7 +1,11 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
//#region src/dependencies.ts
|
|
2
|
+
let internalLogger;
|
|
3
|
+
let api;
|
|
4
|
+
function setDependencies(newInternalLogger, newApi) {
|
|
5
|
+
internalLogger = newInternalLogger;
|
|
6
|
+
api = newApi;
|
|
6
7
|
}
|
|
8
|
+
//#endregion
|
|
9
|
+
export { api, internalLogger, setDependencies };
|
|
10
|
+
|
|
7
11
|
//# sourceMappingURL=dependencies.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dependencies.js","
|
|
1
|
+
{"version":3,"file":"dependencies.js","names":[],"sources":["../../src/dependencies.ts"],"sourcesContent":["import type { API, InternalLogger } from '@grafana/faro-web-sdk';\n\nexport let internalLogger: InternalLogger;\nexport let api: API;\n\nexport function setDependencies(newInternalLogger: InternalLogger, newApi: API): void {\n internalLogger = newInternalLogger;\n api = newApi;\n}\n"],"mappings":";AAEA,IAAW;AACX,IAAW;AAEX,SAAgB,gBAAgB,mBAAmC,QAAmB;CACpF,iBAAiB;CACjB,MAAM;AACR"}
|
|
@@ -1,67 +1,62 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
import
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
internalLogger === null || internalLogger === void 0 ? void 0 : internalLogger.warn('ErrorBoundary\n', 'Cannot get a valid ReactElement from "fallback"');
|
|
63
|
-
}
|
|
64
|
-
return null;
|
|
65
|
-
}
|
|
66
|
-
}
|
|
1
|
+
import { api, internalLogger } from "../dependencies.js";
|
|
2
|
+
import { faroErrorBoundaryInitialState } from "./const.js";
|
|
3
|
+
import { isReactVersionAtLeast17 } from "../utils/reactVersion.js";
|
|
4
|
+
import "../utils/index.js";
|
|
5
|
+
import { Component, isValidElement } from "react";
|
|
6
|
+
import { isFunction } from "@grafana/faro-web-sdk";
|
|
7
|
+
//#region src/errorBoundary/FaroErrorBoundary.tsx
|
|
8
|
+
var FaroErrorBoundary = class extends Component {
|
|
9
|
+
constructor(props) {
|
|
10
|
+
super(props);
|
|
11
|
+
this.state = faroErrorBoundaryInitialState;
|
|
12
|
+
this.resetErrorBoundary = this.resetErrorBoundary.bind(this);
|
|
13
|
+
}
|
|
14
|
+
getErrorWithComponentStack(error, errorInfo) {
|
|
15
|
+
if (!isReactVersionAtLeast17 || !errorInfo.componentStack) return error;
|
|
16
|
+
const newError = new Error(error.message);
|
|
17
|
+
newError.name = `React ErrorBoundary ${error.name}`;
|
|
18
|
+
newError.stack = errorInfo.componentStack;
|
|
19
|
+
return newError;
|
|
20
|
+
}
|
|
21
|
+
static getDerivedStateFromError(error) {
|
|
22
|
+
return {
|
|
23
|
+
hasError: true,
|
|
24
|
+
error
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
componentDidCatch(error, errorInfo) {
|
|
28
|
+
var _this$props$beforeCap, _this$props, _this$props$onError, _this$props2;
|
|
29
|
+
const errorWithComponentStack = this.getErrorWithComponentStack(error, errorInfo);
|
|
30
|
+
(_this$props$beforeCap = (_this$props = this.props).beforeCapture) === null || _this$props$beforeCap === void 0 || _this$props$beforeCap.call(_this$props, errorWithComponentStack);
|
|
31
|
+
api.pushError(errorWithComponentStack, this.props.pushErrorOptions);
|
|
32
|
+
(_this$props$onError = (_this$props2 = this.props).onError) === null || _this$props$onError === void 0 || _this$props$onError.call(_this$props2, errorWithComponentStack);
|
|
33
|
+
this.setState({
|
|
34
|
+
hasError: true,
|
|
35
|
+
error
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
componentDidMount() {
|
|
39
|
+
var _this$props$onMount, _this$props3;
|
|
40
|
+
(_this$props$onMount = (_this$props3 = this.props).onMount) === null || _this$props$onMount === void 0 || _this$props$onMount.call(_this$props3);
|
|
41
|
+
}
|
|
42
|
+
componentWillUnmount() {
|
|
43
|
+
var _this$props$onUnmount, _this$props4;
|
|
44
|
+
(_this$props$onUnmount = (_this$props4 = this.props).onUnmount) === null || _this$props$onUnmount === void 0 || _this$props$onUnmount.call(_this$props4, this.state.error);
|
|
45
|
+
}
|
|
46
|
+
resetErrorBoundary() {
|
|
47
|
+
var _this$props$onReset, _this$props5;
|
|
48
|
+
(_this$props$onReset = (_this$props5 = this.props).onReset) === null || _this$props$onReset === void 0 || _this$props$onReset.call(_this$props5, this.state.error);
|
|
49
|
+
this.setState(faroErrorBoundaryInitialState);
|
|
50
|
+
}
|
|
51
|
+
render() {
|
|
52
|
+
if (!this.state.hasError) return isFunction(this.props.children) ? this.props.children() : this.props.children;
|
|
53
|
+
const element = !isFunction(this.props.fallback) ? this.props.fallback : this.props.fallback(this.state.error, this.resetErrorBoundary);
|
|
54
|
+
if (isValidElement(element)) return element;
|
|
55
|
+
if (this.props.fallback) internalLogger === null || internalLogger === void 0 || internalLogger.warn("ErrorBoundary\n", "Cannot get a valid ReactElement from \"fallback\"");
|
|
56
|
+
return null;
|
|
57
|
+
}
|
|
58
|
+
};
|
|
59
|
+
//#endregion
|
|
60
|
+
export { FaroErrorBoundary };
|
|
61
|
+
|
|
67
62
|
//# sourceMappingURL=FaroErrorBoundary.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FaroErrorBoundary.js","
|
|
1
|
+
{"version":3,"file":"FaroErrorBoundary.js","names":[],"sources":["../../../src/errorBoundary/FaroErrorBoundary.tsx"],"sourcesContent":["// React is required in scope for JSX transformation with the classic transform\n// @ts-expect-error - TS6133: React appears unused but is required for JSX\n// eslint-disable-next-line @typescript-eslint/no-unused-vars\nimport React, { Component, isValidElement } from 'react';\nimport type { ErrorInfo, ReactNode } from 'react';\n\nimport { isFunction } from '@grafana/faro-web-sdk';\n\nimport { api, internalLogger } from '../dependencies';\nimport { isReactVersionAtLeast17 } from '../utils';\n\nimport { faroErrorBoundaryInitialState } from './const';\nimport type { FaroErrorBoundaryProps, FaroErrorBoundaryState } from './types';\n\nexport class FaroErrorBoundary extends Component<FaroErrorBoundaryProps, FaroErrorBoundaryState> {\n override state: FaroErrorBoundaryState = faroErrorBoundaryInitialState;\n\n constructor(props: FaroErrorBoundaryProps) {\n super(props);\n\n this.resetErrorBoundary = this.resetErrorBoundary.bind(this);\n }\n\n getErrorWithComponentStack(error: Error, errorInfo: ErrorInfo): Error {\n if (!isReactVersionAtLeast17 || !errorInfo.componentStack) {\n return error;\n }\n\n const newError = new Error(error.message);\n\n newError.name = `React ErrorBoundary ${error.name}`;\n newError.stack = errorInfo.componentStack;\n\n return newError;\n }\n\n static getDerivedStateFromError(error: Error): FaroErrorBoundaryState {\n return {\n hasError: true,\n error,\n };\n }\n\n override componentDidCatch(error: Error, errorInfo: ErrorInfo): void {\n const errorWithComponentStack = this.getErrorWithComponentStack(error, errorInfo);\n\n this.props.beforeCapture?.(errorWithComponentStack);\n\n api.pushError(errorWithComponentStack, this.props.pushErrorOptions);\n\n this.props.onError?.(errorWithComponentStack);\n\n this.setState({ hasError: true, error });\n }\n\n override componentDidMount(): void {\n this.props.onMount?.();\n }\n\n override componentWillUnmount(): void {\n this.props.onUnmount?.(this.state.error);\n }\n\n resetErrorBoundary(): void {\n this.props.onReset?.(this.state.error);\n\n this.setState(faroErrorBoundaryInitialState);\n }\n\n override render(): ReactNode {\n if (!this.state.hasError) {\n return isFunction(this.props.children) ? this.props.children() : this.props.children;\n }\n\n const element = !isFunction(this.props.fallback)\n ? this.props.fallback\n : this.props.fallback(this.state.error!, this.resetErrorBoundary);\n\n if (isValidElement(element)) {\n return element;\n }\n\n if (this.props.fallback) {\n internalLogger?.warn('ErrorBoundary\\n', 'Cannot get a valid ReactElement from \"fallback\"');\n }\n\n return null;\n }\n}\n"],"mappings":";;;;;;;AAcA,IAAa,oBAAb,cAAuC,UAA0D;CAG/F,YAAY,OAA+B;EACzC,MAAM,KAAK;EAHb,KAAS,QAAgC;EAKvC,KAAK,qBAAqB,KAAK,mBAAmB,KAAK,IAAI;CAC7D;CAEA,2BAA2B,OAAc,WAA6B;EACpE,IAAI,CAAC,2BAA2B,CAAC,UAAU,gBACzC,OAAO;EAGT,MAAM,WAAW,IAAI,MAAM,MAAM,OAAO;EAExC,SAAS,OAAO,uBAAuB,MAAM;EAC7C,SAAS,QAAQ,UAAU;EAE3B,OAAO;CACT;CAEA,OAAO,yBAAyB,OAAsC;EACpE,OAAO;GACL,UAAU;GACV;EACF;CACF;CAEA,kBAA2B,OAAc,WAA4B;;EACnE,MAAM,0BAA0B,KAAK,2BAA2B,OAAO,SAAS;EAEhF,CAAA,yBAAA,cAAA,KAAK,MAAA,CAAM,mBAAA,QAAA,0BAAA,KAAA,KAAA,sBAAA,KAAA,aAAgB,uBAAuB;EAElD,IAAI,UAAU,yBAAyB,KAAK,MAAM,gBAAgB;EAElE,CAAA,uBAAA,eAAA,KAAK,MAAA,CAAM,aAAA,QAAA,wBAAA,KAAA,KAAA,oBAAA,KAAA,cAAU,uBAAuB;EAE5C,KAAK,SAAS;GAAE,UAAU;GAAM;EAAM,CAAC;CACzC;CAEA,oBAAmC;;EACjC,CAAA,uBAAA,eAAA,KAAK,MAAA,CAAM,aAAA,QAAA,wBAAA,KAAA,KAAA,oBAAA,KAAA,YAAU;CACvB;CAEA,uBAAsC;;EACpC,CAAA,yBAAA,eAAA,KAAK,MAAA,CAAM,eAAA,QAAA,0BAAA,KAAA,KAAA,sBAAA,KAAA,cAAY,KAAK,MAAM,KAAK;CACzC;CAEA,qBAA2B;;EACzB,CAAA,uBAAA,eAAA,KAAK,MAAA,CAAM,aAAA,QAAA,wBAAA,KAAA,KAAA,oBAAA,KAAA,cAAU,KAAK,MAAM,KAAK;EAErC,KAAK,SAAS,6BAA6B;CAC7C;CAEA,SAA6B;EAC3B,IAAI,CAAC,KAAK,MAAM,UACd,OAAO,WAAW,KAAK,MAAM,QAAQ,IAAI,KAAK,MAAM,SAAS,IAAI,KAAK,MAAM;EAG9E,MAAM,UAAU,CAAC,WAAW,KAAK,MAAM,QAAQ,IAC3C,KAAK,MAAM,WACX,KAAK,MAAM,SAAS,KAAK,MAAM,OAAQ,KAAK,kBAAkB;EAElE,IAAI,eAAe,OAAO,GACxB,OAAO;EAGT,IAAI,KAAK,MAAM,UACb,mBAAA,QAAA,mBAAA,KAAA,KAAA,eAAgB,KAAK,mBAAmB,mDAAiD;EAG3F,OAAO;CACT;AACF"}
|
|
@@ -1,5 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
//#region src/errorBoundary/const.ts
|
|
2
|
+
const faroErrorBoundaryInitialState = {
|
|
3
|
+
hasError: false,
|
|
4
|
+
error: null
|
|
4
5
|
};
|
|
6
|
+
//#endregion
|
|
7
|
+
export { faroErrorBoundaryInitialState };
|
|
8
|
+
|
|
5
9
|
//# sourceMappingURL=const.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"const.js","
|
|
1
|
+
{"version":3,"file":"const.js","names":[],"sources":["../../../src/errorBoundary/const.ts"],"sourcesContent":["import type { FaroErrorBoundaryState } from './types';\n\nexport const faroErrorBoundaryInitialState: FaroErrorBoundaryState = {\n hasError: false,\n error: null,\n} as const;\n"],"mappings":";AAEA,MAAa,gCAAwD;CACnE,UAAU;CACV,OAAO;AACT"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
import { faroErrorBoundaryInitialState } from "./const.js";
|
|
2
|
+
import { FaroErrorBoundary } from "./FaroErrorBoundary.js";
|
|
3
|
+
import { withFaroErrorBoundary } from "./withFaroErrorBoundary.js";
|
|
4
|
+
export { FaroErrorBoundary, faroErrorBoundaryInitialState, withFaroErrorBoundary };
|
|
@@ -1,14 +1,17 @@
|
|
|
1
|
-
import
|
|
2
|
-
import React from
|
|
3
|
-
import { unknownString } from
|
|
4
|
-
import
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
1
|
+
import { FaroErrorBoundary } from "./FaroErrorBoundary.js";
|
|
2
|
+
import React from "react";
|
|
3
|
+
import { unknownString } from "@grafana/faro-web-sdk";
|
|
4
|
+
import hoistNonReactStatics from "hoist-non-react-statics";
|
|
5
|
+
//#region src/errorBoundary/withFaroErrorBoundary.tsx
|
|
6
|
+
function withFaroErrorBoundary(WrappedComponent, errorBoundaryProps) {
|
|
7
|
+
var _ref, _WrappedComponent$dis;
|
|
8
|
+
const componentDisplayName = (_ref = (_WrappedComponent$dis = WrappedComponent.displayName) !== null && _WrappedComponent$dis !== void 0 ? _WrappedComponent$dis : WrappedComponent.name) !== null && _ref !== void 0 ? _ref : unknownString;
|
|
9
|
+
const Component = (wrappedComponentProps) => /* @__PURE__ */ React.createElement(FaroErrorBoundary, errorBoundaryProps, /* @__PURE__ */ React.createElement(WrappedComponent, wrappedComponentProps));
|
|
10
|
+
Component.displayName = `faroErrorBoundary(${componentDisplayName})`;
|
|
11
|
+
hoistNonReactStatics(Component, WrappedComponent);
|
|
12
|
+
return Component;
|
|
13
13
|
}
|
|
14
|
+
//#endregion
|
|
15
|
+
export { withFaroErrorBoundary };
|
|
16
|
+
|
|
14
17
|
//# sourceMappingURL=withFaroErrorBoundary.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"withFaroErrorBoundary.js","
|
|
1
|
+
{"version":3,"file":"withFaroErrorBoundary.js","names":[],"sources":["../../../src/errorBoundary/withFaroErrorBoundary.tsx"],"sourcesContent":["import hoistNonReactStatics from 'hoist-non-react-statics';\nimport React from 'react';\nimport type { ComponentType, FC } from 'react';\n\nimport { unknownString } from '@grafana/faro-web-sdk';\n\nimport { FaroErrorBoundary } from './FaroErrorBoundary';\nimport type { FaroErrorBoundaryProps, ReactProps } from './types';\n\nexport function withFaroErrorBoundary<P extends ReactProps = {}>(\n WrappedComponent: ComponentType<P>,\n errorBoundaryProps: FaroErrorBoundaryProps\n): FC<P> {\n const componentDisplayName = WrappedComponent.displayName ?? WrappedComponent.name ?? unknownString;\n\n const Component: FC<P> = (wrappedComponentProps: P) => (\n <FaroErrorBoundary {...errorBoundaryProps}>\n <WrappedComponent {...wrappedComponentProps} />\n </FaroErrorBoundary>\n );\n\n Component.displayName = `faroErrorBoundary(${componentDisplayName})`;\n\n hoistNonReactStatics(Component, WrappedComponent);\n\n return Component;\n}\n"],"mappings":";;;;;AASA,SAAgB,sBACd,kBACA,oBACO;;CACP,MAAM,wBAAA,QAAA,wBAAuB,iBAAiB,iBAAA,QAAA,0BAAA,KAAA,IAAA,wBAAe,iBAAiB,UAAA,QAAA,SAAA,KAAA,IAAA,OAAQ;CAEtF,MAAM,aAAoB,0BACxB,sBAAA,cAAC,mBAAsB,oBACrB,sBAAA,cAAC,kBAAqB,qBAAwB,CAC7B;CAGrB,UAAU,cAAc,qBAAqB,qBAAqB;CAElE,qBAAqB,WAAW,gBAAgB;CAEhD,OAAO;AACT"}
|