react-render-profiler 0.1.1 → 0.2.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 CHANGED
@@ -1,6 +1,6 @@
1
1
  # React Render Profiler
2
2
 
3
- A tiny profiler helper to measure initial render + rerender timings for React components.
3
+ Profiler helpers built on React's `<Profiler>` callback with debounced aggregation output.
4
4
 
5
5
  ## Install
6
6
 
@@ -8,127 +8,101 @@ A tiny profiler helper to measure initial render + rerender timings for React co
8
8
  npm i react-render-profiler
9
9
  ```
10
10
 
11
- ## Why
11
+ ## What It Gives You
12
12
 
13
- Use it when you want:
13
+ - Render samples from React `actualDuration` and `baseDuration`
14
+ - Aggregated reporting with debounce (`reportAfterMs`)
15
+ - Three integration styles:
16
+ - `withRenderProfiler(Component, options?)`
17
+ - `<RenderProfiler id="...">...</RenderProfiler>`
18
+ - `useRenderProfiler(componentName, options?)`
14
19
 
15
- - render count and rerender count per component instance
16
- - approximate commit timing (`render start` -> `useEffect`)
17
- - delayed aggregated reporting to keep console noise low
20
+ By default profiling is **disabled in production** (`NODE_ENV === "production"`).
18
21
 
19
- ## Usage (HOC)
22
+ ## Usage
20
23
 
21
- ```tsx
22
- import { withRenderProfiler } from 'react-render-profiler';
23
- import { ProductCard } from './ProductCard';
24
-
25
- export default withRenderProfiler(ProductCard, {
26
- reportAfterMs: 5000,
27
- logEachRender: false
28
- });
29
- ```
30
-
31
- ## Actual usage patterns
32
-
33
- ### 1) Wrap component on export (global for all usages)
24
+ ### HOC
34
25
 
35
26
  ```tsx
36
- function MenuItem(props) {
37
- ...
38
- }
27
+ import { withRenderProfiler } from 'react-render-profiler';
39
28
 
40
- export default withRenderProfiler(MenuItem, {
41
- componentName: 'MenuItem',
29
+ const ProfiledCard = withRenderProfiler(ProductCard, {
30
+ componentName: 'ProductCard',
42
31
  groupByComponent: true,
43
- enabled: process.env.NODE_ENV !== 'production',
44
- reportAfterMs: 5000,
32
+ reportAfterMs: 1000,
45
33
  });
46
34
  ```
47
35
 
48
- ### 2) Wrap only in one place (recommended for focused profiling)
36
+ ### Wrapper Component
49
37
 
50
38
  ```tsx
51
- const FooterProfiled = withRenderProfiler(FooterWidget, {
52
- componentName: 'HomePage:FooterWidget',
53
- groupByComponent: true,
54
- enabled: process.env.NODE_ENV !== 'production',
55
- reportAfterMs: 5000,
56
- });
57
-
58
- // Inside ProductPage:
59
- <RecommendationsWidgetProfiled productAlias={product.alias} />
60
- ```
61
-
62
- ## Measure only specific usage
63
-
64
- For HOC usage, `enabled` can be a function of component props.
65
- This lets you measure only specific places/instances and keep others unprofiled.
66
-
67
- ```tsx
68
- type CardProps = { alias: string; profileRender?: boolean };
69
-
70
- const ProductCardProfiled = withRenderProfiler<CardProps>(ProductCard, {
71
- componentName: 'ProductCard',
72
- groupByComponent: true,
73
- enabled: (props) => props.profileRender === true,
74
- });
75
-
76
- // Only this usage is measured:
77
- <ProductCardProfiled alias="a" profileRender />
78
-
79
- // This usage is ignored by profiler:
80
- <ProductCardProfiled alias="b" />
39
+ import { RenderProfiler } from 'react-render-profiler';
40
+
41
+ export function ProductSection() {
42
+ return (
43
+ <RenderProfiler id="ProductSection" groupByComponent reportAfterMs={1000}>
44
+ <ProductList />
45
+ </RenderProfiler>
46
+ );
47
+ }
81
48
  ```
82
49
 
83
- ## Usage (Hook)
50
+ ### Hook (manual `<Profiler>` placement)
84
51
 
85
52
  ```tsx
53
+ import { Profiler } from 'react';
86
54
  import { useRenderProfiler } from 'react-render-profiler';
87
55
 
88
56
  export function CheckoutSidebar() {
89
- useRenderProfiler('CheckoutSidebar', { reportAfterMs: 3000 });
90
- return <aside>...</aside>;
57
+ const { profilerId, onRender, enabled } = useRenderProfiler('CheckoutSidebar', {
58
+ reportAfterMs: 1000,
59
+ });
60
+
61
+ if (!enabled) {
62
+ return <aside>...</aside>;
63
+ }
64
+
65
+ return (
66
+ <Profiler id={profilerId} onRender={onRender}>
67
+ <aside>...</aside>
68
+ </Profiler>
69
+ );
91
70
  }
92
71
  ```
93
72
 
94
73
  ## API
95
74
 
96
- ### `withRenderProfiler(Component, options?)`
97
-
98
- Wraps a component and reports stats to console after inactivity timeout.
99
-
100
- ### `useRenderProfiler(componentName, options?)`
75
+ ### `RenderProfilerOptions<P>`
101
76
 
102
- Hook variant when you do not want to wrap export.
77
+ - `componentName?: string`
78
+ - `reportAfterMs?: number` (default `500`)
79
+ - `groupByComponent?: boolean` (default `false`)
80
+ - `log?: (rows: LogPayload[]) => void` (default `console.table` sink)
81
+ - `enabled?: boolean | ((props: P) => boolean)`
103
82
 
104
- ### `options`
83
+ ### `LogPayload`
105
84
 
106
- - `reportAfterMs` (default `3000`) - report debounce timeout
107
- - `groupByComponent` (default `false`) - aggregate all instances under one component report
108
- - `logEachRender` (default `false`) - emit log on every commit
109
- - `enabled` (default `true`) - disable profiler globally (`boolean`) or for HOC by props (`(props) => boolean`)
110
- - `logger` - custom logger function for integrating with your telemetry
85
+ - `componentName`
86
+ - `renders`
87
+ - `mountPhases`
88
+ - `updatePhases`
89
+ - `totalActualMs`
90
+ - `minActualMs`
91
+ - `maxActualMs`
92
+ - `totalBaseMs`
111
93
 
112
- ### Typical presets
94
+ ### `withRenderProfiler(Component, options?)`
113
95
 
114
- - **Page/widget profiling**: `{ componentName, groupByComponent: true, enabled: dev, reportAfterMs: 5000 }`
115
- - **Instance-level profiling**: `{ componentName, enabled: (props) => ..., reportAfterMs: 2000-5000 }`
96
+ Wraps a component in `<Profiler>`, supporting `enabled` as boolean or predicate function.
116
97
 
117
- ## Notes
98
+ ### `RenderProfiler`
118
99
 
119
- - In React StrictMode (development), render/effect invocations can be doubled.
120
- - This helper measures render-to-effect timing, not full browser paint time.
100
+ Component form:
121
101
 
122
- ## Report Fields
102
+ ```tsx
103
+ <RenderProfiler id="MySection">{children}</RenderProfiler>
104
+ ```
123
105
 
124
- Each console row includes these fields:
106
+ ### `useRenderProfiler(componentName, options?)`
125
107
 
126
- - `label` - logger label, usually `[RenderProfiler] <ComponentName>`
127
- - `component` - component name used for profiling/grouping
128
- - `renders` - total committed renders counted in this profile bucket
129
- - `initialRenders` - number of first renders for mounted instances in this bucket
130
- - `rerenders` - number of subsequent renders (`renders - initialRenders`)
131
- - `totalMs` - sum of measured render durations in milliseconds
132
- - `avgMs` - average render duration (`totalMs / renders`)
133
- - `minMs` - fastest measured render duration in milliseconds
134
- - `maxMs` - slowest measured render duration in milliseconds
108
+ Returns `{ profilerId, onRender, enabled }` for manual `<Profiler>` usage.
package/dist/index.d.ts CHANGED
@@ -1,26 +1,34 @@
1
- import React from 'react';
2
- type LogPayload = {
3
- component: string;
4
- renders: number;
5
- initialRenders: number;
6
- rerenders: number;
7
- totalMs: number;
8
- avgMs: number;
9
- minMs: number;
10
- maxMs: number;
11
- };
12
- export type RenderProfilerOptions = {
1
+ import React, { type ProfilerOnRenderCallback } from 'react';
2
+ export type RenderProfilerOptions<P = unknown> = {
13
3
  componentName?: string;
14
- groupByComponent?: boolean;
15
4
  reportAfterMs?: number;
16
- logEachRender?: boolean;
5
+ groupByComponent?: boolean;
6
+ log?: (rows: LogPayload[]) => void;
7
+ enabled?: boolean | ((props: P) => boolean);
8
+ };
9
+ export type LogPayload = {
10
+ componentName: string;
11
+ renders: number;
12
+ mountPhases: number;
13
+ updatePhases: number;
14
+ totalActualMs: number;
15
+ minActualMs: number;
16
+ maxActualMs: number;
17
+ totalBaseMs: number;
18
+ };
19
+ export type RenderProfilerProps = {
20
+ id: string;
21
+ children: React.ReactNode;
22
+ } & Omit<RenderProfilerOptions<never>, 'enabled'> & {
17
23
  enabled?: boolean;
18
- logger?: (label: string, payload: LogPayload) => void;
19
24
  };
20
- export type RenderProfilerHOCOptions<P> = Omit<RenderProfilerOptions, 'enabled'> & {
21
- enabled?: boolean | ((props: P) => boolean);
25
+ export declare function RenderProfiler({ id, children, reportAfterMs, groupByComponent, log, enabled, }: RenderProfilerProps): React.ReactElement;
26
+ export declare function useRenderProfiler(componentName: string, options?: Omit<RenderProfilerOptions<never>, 'enabled'> & {
27
+ enabled?: boolean;
28
+ }): {
29
+ profilerId: string;
30
+ onRender: ProfilerOnRenderCallback;
31
+ enabled: boolean;
22
32
  };
23
- export declare const useRenderProfiler: (componentName: string, options?: RenderProfilerOptions) => void;
24
- export declare const withRenderProfiler: <P extends object>(WrappedComponent: React.ComponentType<P>, options?: RenderProfilerHOCOptions<P>) => React.FC<P>;
25
- export {};
33
+ export declare function withRenderProfiler<P extends object>(WrappedComponent: React.ComponentType<P>, options?: RenderProfilerOptions<P>): React.FC<P>;
26
34
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.tsx"],"names":[],"mappings":"AAAA,OAAO,KAA4B,MAAM,OAAO,CAAC;AAEjD,KAAK,UAAU,GAAG;IAChB,SAAS,EAAE,MAAM,CAAC;IAClB,OAAO,EAAE,MAAM,CAAC;IAChB,cAAc,EAAE,MAAM,CAAC;IACvB,SAAS,EAAE,MAAM,CAAC;IAClB,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,MAAM,CAAC;CACf,CAAC;AAEF,MAAM,MAAM,qBAAqB,GAAG;IAClC,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAC3B,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,MAAM,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,UAAU,KAAK,IAAI,CAAC;CACvD,CAAC;AAEF,MAAM,MAAM,wBAAwB,CAAC,CAAC,IAAI,IAAI,CAAC,qBAAqB,EAAE,SAAS,CAAC,GAAG;IACjF,OAAO,CAAC,EAAE,OAAO,GAAG,CAAC,CAAC,KAAK,EAAE,CAAC,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B,GAAmB,EACnB,OAAO,GACR,EAAE,mBAAmB,GAAG,KAAK,CAAC,YAAY,CA8B1C;AAED,wBAAgB,iBAAiB,CAC/B,aAAa,EAAE,MAAM,EACrB,OAAO,GAAE,IAAI,CAAC,qBAAqB,CAAC,KAAK,CAAC,EAAE,SAAS,CAAC,GAAG;IAAE,OAAO,CAAC,EAAE,OAAO,CAAA;CAAO,GAClF;IACD,UAAU,EAAE,MAAM,CAAC;IACnB,QAAQ,EAAE,wBAAwB,CAAC;IACnC,OAAO,EAAE,OAAO,CAAC;CAClB,CAmCA;AAED,wBAAgB,kBAAkB,CAAC,CAAC,SAAS,MAAM,EACjD,gBAAgB,EAAE,KAAK,CAAC,aAAa,CAAC,CAAC,CAAC,EACxC,OAAO,GAAE,qBAAqB,CAAC,CAAC,CAAM,GACrC,KAAK,CAAC,EAAE,CAAC,CAAC,CAAC,CAuCb"}
package/dist/index.js CHANGED
@@ -1,122 +1,144 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.withRenderProfiler = exports.useRenderProfiler = void 0;
3
+ exports.withRenderProfiler = exports.useRenderProfiler = exports.RenderProfiler = void 0;
4
4
  const jsx_runtime_1 = require("react/jsx-runtime");
5
5
  const react_1 = require("react");
6
- const defaultLogger = (label, payload) => {
7
- // Console table keeps output readable when multiple profiled components run.
8
- // eslint-disable-next-line no-console
9
- console.table([{ label, ...payload }]);
10
- };
11
- const groupedStatsStore = new Map();
12
- const createEmptyStats = () => ({
13
- renders: 0,
14
- initialRenders: 0,
15
- rerenders: 0,
16
- totalMs: 0,
17
- minMs: Number.POSITIVE_INFINITY,
18
- maxMs: 0,
19
- timerId: null
20
- });
21
- const scheduleReport = (componentName, stats, reportAfterMs, logger) => {
22
- if (stats.timerId) {
23
- clearTimeout(stats.timerId);
6
+ const buckets = new Map();
7
+ let debounceTimer = null;
8
+ function defaultEnabledByEnv() {
9
+ if (typeof process !== 'undefined' && process.env && process.env.NODE_ENV === 'production') {
10
+ return false;
24
11
  }
25
- stats.timerId = setTimeout(() => {
26
- const avg = stats.renders > 0 ? stats.totalMs / stats.renders : 0;
27
- const payload = {
28
- component: componentName,
29
- renders: stats.renders,
30
- initialRenders: stats.initialRenders,
31
- rerenders: stats.rerenders,
32
- totalMs: Number(stats.totalMs.toFixed(2)),
33
- avgMs: Number(avg.toFixed(2)),
34
- minMs: Number((Number.isFinite(stats.minMs) ? stats.minMs : 0).toFixed(2)),
35
- maxMs: Number(stats.maxMs.toFixed(2))
12
+ return true;
13
+ }
14
+ function round3(n) {
15
+ return Math.round(n * 1000) / 1000;
16
+ }
17
+ function touchBucket(key, displayName) {
18
+ let bucket = buckets.get(key);
19
+ if (!bucket) {
20
+ bucket = {
21
+ componentName: displayName,
22
+ renders: 0,
23
+ mountPhases: 0,
24
+ updatePhases: 0,
25
+ totalActualMs: 0,
26
+ minActualMs: Number.POSITIVE_INFINITY,
27
+ maxActualMs: 0,
28
+ totalBaseMs: 0,
36
29
  };
37
- logger(`[RenderProfiler] ${componentName}`, payload);
38
- }, reportAfterMs);
39
- };
40
- const useRenderProfiler = (componentName, options = {}) => {
41
- const { groupByComponent = false, reportAfterMs = 3000, logEachRender = false, enabled = true, logger = defaultLogger } = options;
42
- const renderStartRef = (0, react_1.useRef)(0);
43
- const instanceRenderCountRef = (0, react_1.useRef)(0);
44
- const renderGenerationRef = (0, react_1.useRef)(0);
45
- const statsRef = (0, react_1.useRef)(createEmptyStats());
46
- if (groupByComponent && !groupedStatsStore.has(componentName)) {
47
- groupedStatsStore.set(componentName, createEmptyStats());
30
+ buckets.set(key, bucket);
48
31
  }
49
- const activeStats = groupByComponent ? groupedStatsStore.get(componentName) : statsRef.current;
50
- // Record render start during render; count and measure in useEffect so totals match per-render
51
- // durations. A render-generation token in the effect deps forces the effect to run after every
52
- // profiled render. Without it, rerenders with the same logger/options leave deps unchanged, so React
53
- // skips the effect while render-only counting would still advance — producing avg/total/min/max that
54
- // disagree. Dev Strict Mode can also widen that gap by extra render passes before commit.
55
- if (enabled) {
56
- const now = performance.now();
57
- renderStartRef.current = now;
58
- renderGenerationRef.current += 1;
32
+ return bucket;
33
+ }
34
+ function defaultLogger(rows) {
35
+ const tableRows = rows.map((row) => ({
36
+ component: row.componentName,
37
+ renders: row.renders,
38
+ mounts: row.mountPhases,
39
+ updates: row.updatePhases,
40
+ totalMs: round3(row.totalActualMs),
41
+ minMs: row.renders ? round3(row.minActualMs) : 0,
42
+ maxMs: round3(row.maxActualMs),
43
+ avgMs: row.renders ? round3(row.totalActualMs / row.renders) : 0,
44
+ baseMs: round3(row.totalBaseMs),
45
+ }));
46
+ // eslint-disable-next-line no-console
47
+ console.table(tableRows);
48
+ }
49
+ function scheduleFlush(reportAfterMs, log) {
50
+ if (debounceTimer) {
51
+ clearTimeout(debounceTimer);
59
52
  }
60
- const renderGeneration = renderGenerationRef.current;
61
- (0, react_1.useEffect)(() => {
62
- if (!enabled) {
63
- return;
64
- }
65
- const end = performance.now();
66
- const renderDuration = end - renderStartRef.current;
67
- const stats = activeStats;
68
- instanceRenderCountRef.current += 1;
69
- stats.renders += 1;
70
- if (instanceRenderCountRef.current === 1) {
71
- stats.initialRenders += 1;
53
+ debounceTimer = setTimeout(() => {
54
+ debounceTimer = null;
55
+ const rows = [...buckets.values()].map((bucket) => ({ ...bucket }));
56
+ buckets.clear();
57
+ if (rows.length) {
58
+ log(rows);
72
59
  }
73
- else {
74
- stats.rerenders += 1;
75
- }
76
- stats.totalMs += renderDuration;
77
- stats.minMs = Math.min(stats.minMs, renderDuration);
78
- stats.maxMs = Math.max(stats.maxMs, renderDuration);
79
- if (logEachRender) {
80
- logger(`[RenderProfiler] ${componentName}#${stats.renders}`, {
81
- component: componentName,
82
- renders: stats.renders,
83
- initialRenders: stats.initialRenders,
84
- rerenders: stats.rerenders,
85
- totalMs: Number(stats.totalMs.toFixed(2)),
86
- avgMs: Number((stats.totalMs / stats.renders).toFixed(2)),
87
- minMs: Number(stats.minMs.toFixed(2)),
88
- maxMs: Number(stats.maxMs.toFixed(2))
89
- });
60
+ }, reportAfterMs);
61
+ }
62
+ function normalizePhase(phase) {
63
+ return phase === 'mount' ? 'mount' : 'update';
64
+ }
65
+ function recordProfilerSample(aggregateKey, displayName, phase, actualDuration, baseDuration, reportAfterMs, log) {
66
+ const bucket = touchBucket(aggregateKey, displayName);
67
+ const normalizedPhase = normalizePhase(phase);
68
+ bucket.renders += 1;
69
+ if (normalizedPhase === 'mount') {
70
+ bucket.mountPhases += 1;
71
+ }
72
+ else {
73
+ bucket.updatePhases += 1;
74
+ }
75
+ bucket.totalActualMs += actualDuration;
76
+ bucket.minActualMs = Math.min(bucket.minActualMs, actualDuration);
77
+ bucket.maxActualMs = Math.max(bucket.maxActualMs, actualDuration);
78
+ bucket.totalBaseMs += baseDuration;
79
+ scheduleFlush(reportAfterMs, log);
80
+ }
81
+ function resolveEnabled(options, props) {
82
+ const { enabled } = options;
83
+ if (enabled === undefined) {
84
+ return defaultEnabledByEnv();
85
+ }
86
+ if (typeof enabled === 'function') {
87
+ return Boolean(enabled(props));
88
+ }
89
+ return enabled;
90
+ }
91
+ function RenderProfiler({ id, children, reportAfterMs = 500, groupByComponent = false, log = defaultLogger, enabled, }) {
92
+ const instanceId = (0, react_1.useId)();
93
+ const aggregateKey = groupByComponent ? id : `${id} (${instanceId})`;
94
+ const onRender = (0, react_1.useCallback)((_profilerId, phase, actualDuration, baseDuration) => {
95
+ recordProfilerSample(aggregateKey, id, phase, actualDuration, baseDuration, reportAfterMs, log);
96
+ }, [aggregateKey, id, log, reportAfterMs]);
97
+ const isEnabled = enabled === undefined ? defaultEnabledByEnv() : Boolean(enabled);
98
+ if (!isEnabled) {
99
+ return (0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, { children: children });
100
+ }
101
+ return ((0, jsx_runtime_1.jsx)(react_1.Profiler, { id: aggregateKey, onRender: onRender, children: children }));
102
+ }
103
+ exports.RenderProfiler = RenderProfiler;
104
+ function useRenderProfiler(componentName, options = {}) {
105
+ const { reportAfterMs = 500, groupByComponent = false, log = defaultLogger } = options;
106
+ const instanceId = (0, react_1.useId)();
107
+ const aggregateKey = (0, react_1.useMemo)(() => (groupByComponent ? componentName : `${componentName} (${instanceId})`), [componentName, groupByComponent, instanceId]);
108
+ const onRender = (0, react_1.useCallback)((_id, phase, actualDuration, baseDuration) => {
109
+ recordProfilerSample(aggregateKey, componentName, phase, actualDuration, baseDuration, reportAfterMs, log);
110
+ }, [aggregateKey, componentName, log, reportAfterMs]);
111
+ const enabledByOption = (0, react_1.useMemo)(() => {
112
+ if (options.enabled === undefined) {
113
+ return defaultEnabledByEnv();
90
114
  }
91
- scheduleReport(componentName, stats, reportAfterMs, logger);
92
- return () => {
93
- if (!groupByComponent && stats.timerId) {
94
- clearTimeout(stats.timerId);
95
- stats.timerId = null;
96
- }
97
- };
98
- }, [
99
- activeStats,
100
- componentName,
101
- enabled,
102
- groupByComponent,
103
- logEachRender,
104
- logger,
105
- reportAfterMs,
106
- renderGeneration
107
- ]);
108
- };
115
+ return Boolean(options.enabled);
116
+ }, [options.enabled]);
117
+ return {
118
+ profilerId: aggregateKey,
119
+ onRender,
120
+ enabled: enabledByOption,
121
+ };
122
+ }
109
123
  exports.useRenderProfiler = useRenderProfiler;
110
- const withRenderProfiler = (WrappedComponent, options = {}) => {
111
- const wrappedName = options.componentName || WrappedComponent.displayName || WrappedComponent.name || 'AnonymousComponent';
112
- const ProfiledComponent = (props) => {
113
- const { enabled = true, ...restOptions } = options;
114
- const resolvedEnabled = typeof enabled === 'function' ? enabled(props) : enabled;
115
- (0, exports.useRenderProfiler)(wrappedName, { ...restOptions, enabled: resolvedEnabled });
116
- return (0, jsx_runtime_1.jsx)(WrappedComponent, { ...props });
124
+ function withRenderProfiler(WrappedComponent, options = {}) {
125
+ const fallbackName = WrappedComponent.displayName || WrappedComponent.name || 'Component';
126
+ const wrappedName = options.componentName || fallbackName;
127
+ const Profiled = (props) => {
128
+ const { reportAfterMs = 500, groupByComponent = false, log = defaultLogger } = options;
129
+ const instanceId = (0, react_1.useId)();
130
+ const aggregateKey = groupByComponent ? wrappedName : `${wrappedName} (${instanceId})`;
131
+ const onRender = (0, react_1.useCallback)((_profilerId, phase, actualDuration, baseDuration) => {
132
+ recordProfilerSample(aggregateKey, wrappedName, phase, actualDuration, baseDuration, reportAfterMs, log);
133
+ }, [aggregateKey, log, reportAfterMs, wrappedName]);
134
+ const isEnabled = resolveEnabled(options, props);
135
+ if (!isEnabled) {
136
+ return (0, jsx_runtime_1.jsx)(WrappedComponent, { ...props });
137
+ }
138
+ return ((0, jsx_runtime_1.jsx)(react_1.Profiler, { id: aggregateKey, onRender: onRender, children: (0, jsx_runtime_1.jsx)(WrappedComponent, { ...props }) }));
117
139
  };
118
- ProfiledComponent.displayName = `withRenderProfiler(${wrappedName})`;
119
- return ProfiledComponent;
120
- };
140
+ Profiled.displayName = `withRenderProfiler(${wrappedName})`;
141
+ return Profiled;
142
+ }
121
143
  exports.withRenderProfiler = withRenderProfiler;
122
144
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.tsx"],"names":[],"mappings":";;;;AAAA,iCAAiD;AAoCjD,MAAM,aAAa,GAAG,CAAC,KAAa,EAAE,OAAmB,EAAQ,EAAE;IACjE,6EAA6E;IAC7E,sCAAsC;IACtC,OAAO,CAAC,KAAK,CAAC,CAAC,EAAE,KAAK,EAAE,GAAG,OAAO,EAAE,CAAC,CAAC,CAAC;AACzC,CAAC,CAAC;AAEF,MAAM,iBAAiB,GAAG,IAAI,GAAG,EAAwB,CAAC;AAE1D,MAAM,gBAAgB,GAAG,GAAiB,EAAE,CAAC,CAAC;IAC5C,OAAO,EAAE,CAAC;IACV,cAAc,EAAE,CAAC;IACjB,SAAS,EAAE,CAAC;IACZ,OAAO,EAAE,CAAC;IACV,KAAK,EAAE,MAAM,CAAC,iBAAiB;IAC/B,KAAK,EAAE,CAAC;IACR,O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,CAAC;QACjD,IAAI,CAAC,SAAS,EAAE;YACd,OAAO,uBAAC,gBAAgB,OAAK,KAAK,GAAI,CAAC;SACxC;QAED,OAAO,CACL,uBAAC,gBAAQ,IAAC,EAAE,EAAE,YAAY,EAAE,QAAQ,EAAE,QAAQ,YAC5C,uBAAC,gBAAgB,OAAK,KAAK,GAAI,GACtB,CACZ,CAAC;IACJ,CAAC,CAAC;IAEF,QAAQ,CAAC,WAAW,GAAG,sBAAsB,WAAW,GAAG,CAAC;IAC5D,OAAO,QAAQ,CAAC;AAClB,CAAC;AA1CD,gDA0CC"}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "react-render-profiler",
3
- "version": "0.1.1",
4
- "description": "Lightweight React render and rerender profiler",
3
+ "version": "0.2.0",
4
+ "description": "React render profiling via Profiler API with debounced aggregated reporting",
5
5
  "main": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",
7
7
  "scripts": {
@@ -30,11 +30,14 @@
30
30
  "react",
31
31
  "performance",
32
32
  "profiler",
33
+ "react-profiler",
33
34
  "render",
34
- "rerender"
35
+ "rerender",
36
+ "actualduration",
37
+ "baseduration"
35
38
  ],
36
39
  "peerDependencies": {
37
- "react": ">=16.8.0"
40
+ "react": ">=18.0.0"
38
41
  },
39
42
  "devDependencies": {
40
43
  "@testing-library/jest-dom": "^6.9.1",