@shware/analytics 11.15.0 → 11.15.1
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.
|
@@ -3,13 +3,14 @@ let react = require("react");
|
|
|
3
3
|
let web_vitals = require("web-vitals");
|
|
4
4
|
//#region src/hooks/use-report-web-vitals.ts
|
|
5
5
|
function useReportWebVitals(reportWebVitalsFn) {
|
|
6
|
+
const report = (0, react.useEffectEvent)((metric) => reportWebVitalsFn(metric));
|
|
6
7
|
(0, react.useEffect)(() => {
|
|
7
|
-
(0, web_vitals.onCLS)(
|
|
8
|
-
(0, web_vitals.onLCP)(
|
|
9
|
-
(0, web_vitals.onINP)(
|
|
10
|
-
(0, web_vitals.onFCP)(
|
|
11
|
-
(0, web_vitals.onTTFB)(
|
|
12
|
-
}, [
|
|
8
|
+
(0, web_vitals.onCLS)(report);
|
|
9
|
+
(0, web_vitals.onLCP)(report);
|
|
10
|
+
(0, web_vitals.onINP)(report);
|
|
11
|
+
(0, web_vitals.onFCP)(report);
|
|
12
|
+
(0, web_vitals.onTTFB)(report);
|
|
13
|
+
}, []);
|
|
13
14
|
}
|
|
14
15
|
//#endregion
|
|
15
16
|
exports.useReportWebVitals = useReportWebVitals;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-report-web-vitals.cjs","names":[],"sources":["../../src/hooks/use-report-web-vitals.ts"],"sourcesContent":["import { useEffect } from 'react';\nimport { type Metric, onCLS, onFCP, onINP, onLCP, onTTFB } from 'web-vitals';\n\nexport function useReportWebVitals(reportWebVitalsFn: (metric: Metric) => void) {\n useEffect(() => {\n onCLS(
|
|
1
|
+
{"version":3,"file":"use-report-web-vitals.cjs","names":["useEffectEvent"],"sources":["../../src/hooks/use-report-web-vitals.ts"],"sourcesContent":["import { useEffect, useEffectEvent } from 'react';\nimport { type Metric, onCLS, onFCP, onINP, onLCP, onTTFB } from 'web-vitals';\n\nexport function useReportWebVitals(reportWebVitalsFn: (metric: Metric) => void) {\n // Callers (e.g. `Analytics`) pass an inline callback and re-render on every\n // navigation, and the published build is not React Compiler output, so the\n // reference changes each render. web-vitals offers no way to unsubscribe, so\n // subscribe once per mount and always forward to the latest callback.\n const report = useEffectEvent((metric: Metric) => reportWebVitalsFn(metric));\n\n useEffect(() => {\n onCLS(report);\n onLCP(report);\n onINP(report);\n onFCP(report);\n onTTFB(report);\n }, []);\n}\n"],"mappings":";;;;AAGA,SAAgB,mBAAmB,mBAA6C;CAK9E,MAAM,UAAA,GAASA,MAAAA,eAAAA,EAAgB,WAAmB,kBAAkB,MAAM,CAAC;CAE3E,CAAA,GAAA,MAAA,UAAA,OAAgB;EACd,CAAA,GAAA,WAAA,MAAA,CAAM,MAAM;EACZ,CAAA,GAAA,WAAA,MAAA,CAAM,MAAM;EACZ,CAAA,GAAA,WAAA,MAAA,CAAM,MAAM;EACZ,CAAA,GAAA,WAAA,MAAA,CAAM,MAAM;EACZ,CAAA,GAAA,WAAA,OAAA,CAAO,MAAM;CACf,GAAG,CAAC,CAAC;AACP"}
|
|
@@ -1,14 +1,15 @@
|
|
|
1
|
-
import { useEffect } from "react";
|
|
1
|
+
import { useEffect, useEffectEvent } from "react";
|
|
2
2
|
import { onCLS, onFCP, onINP, onLCP, onTTFB } from "web-vitals";
|
|
3
3
|
//#region src/hooks/use-report-web-vitals.ts
|
|
4
4
|
function useReportWebVitals(reportWebVitalsFn) {
|
|
5
|
+
const report = useEffectEvent((metric) => reportWebVitalsFn(metric));
|
|
5
6
|
useEffect(() => {
|
|
6
|
-
onCLS(
|
|
7
|
-
onLCP(
|
|
8
|
-
onINP(
|
|
9
|
-
onFCP(
|
|
10
|
-
onTTFB(
|
|
11
|
-
}, [
|
|
7
|
+
onCLS(report);
|
|
8
|
+
onLCP(report);
|
|
9
|
+
onINP(report);
|
|
10
|
+
onFCP(report);
|
|
11
|
+
onTTFB(report);
|
|
12
|
+
}, []);
|
|
12
13
|
}
|
|
13
14
|
//#endregion
|
|
14
15
|
export { useReportWebVitals };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-report-web-vitals.mjs","names":[],"sources":["../../src/hooks/use-report-web-vitals.ts"],"sourcesContent":["import { useEffect } from 'react';\nimport { type Metric, onCLS, onFCP, onINP, onLCP, onTTFB } from 'web-vitals';\n\nexport function useReportWebVitals(reportWebVitalsFn: (metric: Metric) => void) {\n useEffect(() => {\n onCLS(
|
|
1
|
+
{"version":3,"file":"use-report-web-vitals.mjs","names":[],"sources":["../../src/hooks/use-report-web-vitals.ts"],"sourcesContent":["import { useEffect, useEffectEvent } from 'react';\nimport { type Metric, onCLS, onFCP, onINP, onLCP, onTTFB } from 'web-vitals';\n\nexport function useReportWebVitals(reportWebVitalsFn: (metric: Metric) => void) {\n // Callers (e.g. `Analytics`) pass an inline callback and re-render on every\n // navigation, and the published build is not React Compiler output, so the\n // reference changes each render. web-vitals offers no way to unsubscribe, so\n // subscribe once per mount and always forward to the latest callback.\n const report = useEffectEvent((metric: Metric) => reportWebVitalsFn(metric));\n\n useEffect(() => {\n onCLS(report);\n onLCP(report);\n onINP(report);\n onFCP(report);\n onTTFB(report);\n }, []);\n}\n"],"mappings":";;;AAGA,SAAgB,mBAAmB,mBAA6C;CAK9E,MAAM,SAAS,gBAAgB,WAAmB,kBAAkB,MAAM,CAAC;CAE3E,gBAAgB;EACd,MAAM,MAAM;EACZ,MAAM,MAAM;EACZ,MAAM,MAAM;EACZ,MAAM,MAAM;EACZ,OAAO,MAAM;CACf,GAAG,CAAC,CAAC;AACP"}
|