react-perfscope 0.7.0 → 0.7.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.
package/dist/auto.cjs CHANGED
@@ -35,7 +35,12 @@ function bootstrap() {
35
35
  if (typeof globalThis === "undefined") return;
36
36
  const g = globalThis;
37
37
  if (g.__REACT_PERFSCOPE_AUTO_MOUNTED__) return;
38
- const env = globalThis.process?.env?.NODE_ENV;
38
+ let env;
39
+ try {
40
+ env = process.env.NODE_ENV;
41
+ } catch {
42
+ env = void 0;
43
+ }
39
44
  if (env === "production") return;
40
45
  if (typeof document === "undefined") return;
41
46
  try {
package/dist/auto.cjs.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/auto.ts","../src/bootstrap.ts"],"sourcesContent":["import { createSourceMapResolver } from '@react-perfscope/core'\nimport { installDevToolsHook } from '@react-perfscope/react'\nimport { mount } from '@react-perfscope/ui'\nimport { createConfiguredRecorder } from './bootstrap'\n\n/**\n * Side-effect entry. Importing `react-perfscope/auto` bootstraps a Recorder\n * with the render collector and mounts the UI. Idempotent — importing twice\n * is a no-op (the first import wins).\n *\n * Bails when `process.env.NODE_ENV === 'production'` (build plugins also\n * guard against prod, but this is defense-in-depth).\n */\nfunction bootstrap(): void {\n if (typeof globalThis === 'undefined') return\n const g = globalThis as { __REACT_PERFSCOPE_AUTO_MOUNTED__?: boolean }\n if (g.__REACT_PERFSCOPE_AUTO_MOUNTED__) return\n\n const env = (globalThis as { process?: { env?: { NODE_ENV?: string } } }).process?.env?.NODE_ENV\n if (env === 'production') return\n\n if (typeof document === 'undefined') return\n\n try {\n // Install the React DevTools hook SYNCHRONOUSLY before react-dom is\n // evaluated. react-dom captures `__REACT_DEVTOOLS_GLOBAL_HOOK__` exactly\n // once at module-load time, so the hook must exist by the time the user\n // bundle imports react-dom. A no-op listener is enough to register the\n // hook — when the render collector later activates, it adds the real\n // commit handler to the same global hook.\n installDevToolsHook(() => {})\n\n const { recorder, finalize } = createConfiguredRecorder()\n const resolver = createSourceMapResolver()\n mount({\n recorder,\n resolveFrame: (f) => resolver.resolve(f),\n finalize,\n })\n g.__REACT_PERFSCOPE_AUTO_MOUNTED__ = true\n } catch (err) {\n console.warn('[react-perfscope] auto bootstrap failed:', err)\n }\n}\n\nbootstrap()\n","import {\n createRecorder,\n createForcedReflowCollector,\n createLongTasksCollector,\n createLayoutShiftCollector,\n createNetworkCollector,\n createWebVitalsCollector,\n createSelfProfilingCollector,\n createHeapCollector,\n createInteractionCollector,\n createFrameCollector,\n} from '@react-perfscope/core'\nimport type { Recorder, RecordingResult } from '@react-perfscope/core'\nimport { createRenderCollector, createLeakCollector } from '@react-perfscope/react'\n\nexport interface ConfiguredRecorder {\n recorder: Recorder\n /** Runs the post-recording finalize chain (interaction → self-profiling →\n * heap → frame) in the order each collector depends on the previous one. */\n finalize: (result: RecordingResult) => Promise<RecordingResult>\n}\n\n/**\n * Assembles the recorder + full collector set that react-perfscope ships,\n * minus the UI. The single source of truth for what gets recorded: both the\n * `/auto` bootstrap and the E2E verification harness call this, so the harness\n * can never validate a collector set that differs from what users get.\n *\n * The caller is responsible for installing the React DevTools hook BEFORE\n * react-dom evaluates (it is timing-sensitive) and for mounting any UI.\n */\nexport function createConfiguredRecorder(): ConfiguredRecorder {\n const recorder = createRecorder()\n recorder.use(createForcedReflowCollector())\n recorder.use(createLongTasksCollector())\n recorder.use(createLayoutShiftCollector())\n recorder.use(createNetworkCollector())\n recorder.use(createWebVitalsCollector())\n recorder.use(createRenderCollector())\n const selfProfiler = createSelfProfilingCollector()\n recorder.use(selfProfiler)\n const heap = createHeapCollector()\n recorder.use(heap)\n const interaction = createInteractionCollector()\n recorder.use(interaction)\n const frame = createFrameCollector()\n recorder.use(frame)\n const leak = createLeakCollector()\n recorder.use(leak)\n\n // Assemble interactions first so self-profiling can attribute their\n // processing windows, then attach the heap series, frame timestamps, and\n // leak suspects.\n const finalize = (result: RecordingResult): Promise<RecordingResult> =>\n Promise.resolve(interaction.finalize(result))\n .then((r) => selfProfiler.finalize(r))\n .then((r) => heap.finalize(r))\n .then((r) => frame.finalize(r))\n .then((r) => leak.finalize(r))\n\n return { recorder, finalize }\n}\n"],"mappings":";;;AAAA,IAAAA,eAAwC;AACxC,IAAAC,gBAAoC;AACpC,gBAAsB;;;ACFtB,kBAWO;AAEP,mBAA2D;AAkBpD,SAAS,2BAA+C;AAC7D,QAAM,eAAW,4BAAe;AAChC,WAAS,QAAI,yCAA4B,CAAC;AAC1C,WAAS,QAAI,sCAAyB,CAAC;AACvC,WAAS,QAAI,wCAA2B,CAAC;AACzC,WAAS,QAAI,oCAAuB,CAAC;AACrC,WAAS,QAAI,sCAAyB,CAAC;AACvC,WAAS,QAAI,oCAAsB,CAAC;AACpC,QAAM,mBAAe,0CAA6B;AAClD,WAAS,IAAI,YAAY;AACzB,QAAM,WAAO,iCAAoB;AACjC,WAAS,IAAI,IAAI;AACjB,QAAM,kBAAc,wCAA2B;AAC/C,WAAS,IAAI,WAAW;AACxB,QAAM,YAAQ,kCAAqB;AACnC,WAAS,IAAI,KAAK;AAClB,QAAM,WAAO,kCAAoB;AACjC,WAAS,IAAI,IAAI;AAKjB,QAAM,WAAW,CAAC,WAChB,QAAQ,QAAQ,YAAY,SAAS,MAAM,CAAC,EACzC,KAAK,CAAC,MAAM,aAAa,SAAS,CAAC,CAAC,EACpC,KAAK,CAAC,MAAM,KAAK,SAAS,CAAC,CAAC,EAC5B,KAAK,CAAC,MAAM,MAAM,SAAS,CAAC,CAAC,EAC7B,KAAK,CAAC,MAAM,KAAK,SAAS,CAAC,CAAC;AAEjC,SAAO,EAAE,UAAU,SAAS;AAC9B;;;ADhDA,SAAS,YAAkB;AACzB,MAAI,OAAO,eAAe,YAAa;AACvC,QAAM,IAAI;AACV,MAAI,EAAE,iCAAkC;AAExC,QAAM,MAAO,WAA6D,SAAS,KAAK;AACxF,MAAI,QAAQ,aAAc;AAE1B,MAAI,OAAO,aAAa,YAAa;AAErC,MAAI;AAOF,2CAAoB,MAAM;AAAA,IAAC,CAAC;AAE5B,UAAM,EAAE,UAAU,SAAS,IAAI,yBAAyB;AACxD,UAAM,eAAW,sCAAwB;AACzC,yBAAM;AAAA,MACJ;AAAA,MACA,cAAc,CAAC,MAAM,SAAS,QAAQ,CAAC;AAAA,MACvC;AAAA,IACF,CAAC;AACD,MAAE,mCAAmC;AAAA,EACvC,SAAS,KAAK;AACZ,YAAQ,KAAK,4CAA4C,GAAG;AAAA,EAC9D;AACF;AAEA,UAAU;","names":["import_core","import_react"]}
1
+ {"version":3,"sources":["../src/auto.ts","../src/bootstrap.ts"],"sourcesContent":["import { createSourceMapResolver } from '@react-perfscope/core'\nimport { installDevToolsHook } from '@react-perfscope/react'\nimport { mount } from '@react-perfscope/ui'\nimport { createConfiguredRecorder } from './bootstrap'\n\n// Type-only declaration so the guard below can use the bare member expression\n// `process.env.NODE_ENV` — the exact token bundlers (Vite define, webpack\n// DefinePlugin, esbuild) statically replace. Optional-chained access through\n// globalThis is not replaced and browsers have no `process` global, which\n// would make the guard a silent no-op in production bundles. The try/catch\n// absorbs the ReferenceError when no bundler and no `process` exist.\ndeclare const process: { env: { NODE_ENV?: string } }\n\n/**\n * Side-effect entry. Importing `react-perfscope/auto` bootstraps a Recorder\n * with the render collector and mounts the UI. Idempotent — importing twice\n * is a no-op (the first import wins).\n *\n * Bails when `process.env.NODE_ENV === 'production'` (build plugins also\n * guard against prod, but this is defense-in-depth).\n */\nfunction bootstrap(): void {\n if (typeof globalThis === 'undefined') return\n const g = globalThis as { __REACT_PERFSCOPE_AUTO_MOUNTED__?: boolean }\n if (g.__REACT_PERFSCOPE_AUTO_MOUNTED__) return\n\n let env: string | undefined\n try {\n env = process.env.NODE_ENV\n } catch {\n env = undefined\n }\n if (env === 'production') return\n\n if (typeof document === 'undefined') return\n\n try {\n // Install the React DevTools hook SYNCHRONOUSLY before react-dom is\n // evaluated. react-dom captures `__REACT_DEVTOOLS_GLOBAL_HOOK__` exactly\n // once at module-load time, so the hook must exist by the time the user\n // bundle imports react-dom. A no-op listener is enough to register the\n // hook — when the render collector later activates, it adds the real\n // commit handler to the same global hook.\n installDevToolsHook(() => {})\n\n const { recorder, finalize } = createConfiguredRecorder()\n const resolver = createSourceMapResolver()\n mount({\n recorder,\n resolveFrame: (f) => resolver.resolve(f),\n finalize,\n })\n g.__REACT_PERFSCOPE_AUTO_MOUNTED__ = true\n } catch (err) {\n console.warn('[react-perfscope] auto bootstrap failed:', err)\n }\n}\n\nbootstrap()\n","import {\n createRecorder,\n createForcedReflowCollector,\n createLongTasksCollector,\n createLayoutShiftCollector,\n createNetworkCollector,\n createWebVitalsCollector,\n createSelfProfilingCollector,\n createHeapCollector,\n createInteractionCollector,\n createFrameCollector,\n} from '@react-perfscope/core'\nimport type { Recorder, RecordingResult } from '@react-perfscope/core'\nimport { createRenderCollector, createLeakCollector } from '@react-perfscope/react'\n\nexport interface ConfiguredRecorder {\n recorder: Recorder\n /** Runs the post-recording finalize chain (interaction → self-profiling →\n * heap → frame) in the order each collector depends on the previous one. */\n finalize: (result: RecordingResult) => Promise<RecordingResult>\n}\n\n/**\n * Assembles the recorder + full collector set that react-perfscope ships,\n * minus the UI. The single source of truth for what gets recorded: both the\n * `/auto` bootstrap and the E2E verification harness call this, so the harness\n * can never validate a collector set that differs from what users get.\n *\n * The caller is responsible for installing the React DevTools hook BEFORE\n * react-dom evaluates (it is timing-sensitive) and for mounting any UI.\n */\nexport function createConfiguredRecorder(): ConfiguredRecorder {\n const recorder = createRecorder()\n recorder.use(createForcedReflowCollector())\n recorder.use(createLongTasksCollector())\n recorder.use(createLayoutShiftCollector())\n recorder.use(createNetworkCollector())\n recorder.use(createWebVitalsCollector())\n recorder.use(createRenderCollector())\n const selfProfiler = createSelfProfilingCollector()\n recorder.use(selfProfiler)\n const heap = createHeapCollector()\n recorder.use(heap)\n const interaction = createInteractionCollector()\n recorder.use(interaction)\n const frame = createFrameCollector()\n recorder.use(frame)\n const leak = createLeakCollector()\n recorder.use(leak)\n\n // Assemble interactions first so self-profiling can attribute their\n // processing windows, then attach the heap series, frame timestamps, and\n // leak suspects.\n const finalize = (result: RecordingResult): Promise<RecordingResult> =>\n Promise.resolve(interaction.finalize(result))\n .then((r) => selfProfiler.finalize(r))\n .then((r) => heap.finalize(r))\n .then((r) => frame.finalize(r))\n .then((r) => leak.finalize(r))\n\n return { recorder, finalize }\n}\n"],"mappings":";;;AAAA,IAAAA,eAAwC;AACxC,IAAAC,gBAAoC;AACpC,gBAAsB;;;ACFtB,kBAWO;AAEP,mBAA2D;AAkBpD,SAAS,2BAA+C;AAC7D,QAAM,eAAW,4BAAe;AAChC,WAAS,QAAI,yCAA4B,CAAC;AAC1C,WAAS,QAAI,sCAAyB,CAAC;AACvC,WAAS,QAAI,wCAA2B,CAAC;AACzC,WAAS,QAAI,oCAAuB,CAAC;AACrC,WAAS,QAAI,sCAAyB,CAAC;AACvC,WAAS,QAAI,oCAAsB,CAAC;AACpC,QAAM,mBAAe,0CAA6B;AAClD,WAAS,IAAI,YAAY;AACzB,QAAM,WAAO,iCAAoB;AACjC,WAAS,IAAI,IAAI;AACjB,QAAM,kBAAc,wCAA2B;AAC/C,WAAS,IAAI,WAAW;AACxB,QAAM,YAAQ,kCAAqB;AACnC,WAAS,IAAI,KAAK;AAClB,QAAM,WAAO,kCAAoB;AACjC,WAAS,IAAI,IAAI;AAKjB,QAAM,WAAW,CAAC,WAChB,QAAQ,QAAQ,YAAY,SAAS,MAAM,CAAC,EACzC,KAAK,CAAC,MAAM,aAAa,SAAS,CAAC,CAAC,EACpC,KAAK,CAAC,MAAM,KAAK,SAAS,CAAC,CAAC,EAC5B,KAAK,CAAC,MAAM,MAAM,SAAS,CAAC,CAAC,EAC7B,KAAK,CAAC,MAAM,KAAK,SAAS,CAAC,CAAC;AAEjC,SAAO,EAAE,UAAU,SAAS;AAC9B;;;ADxCA,SAAS,YAAkB;AACzB,MAAI,OAAO,eAAe,YAAa;AACvC,QAAM,IAAI;AACV,MAAI,EAAE,iCAAkC;AAExC,MAAI;AACJ,MAAI;AACF,UAAM,QAAQ,IAAI;AAAA,EACpB,QAAQ;AACN,UAAM;AAAA,EACR;AACA,MAAI,QAAQ,aAAc;AAE1B,MAAI,OAAO,aAAa,YAAa;AAErC,MAAI;AAOF,2CAAoB,MAAM;AAAA,IAAC,CAAC;AAE5B,UAAM,EAAE,UAAU,SAAS,IAAI,yBAAyB;AACxD,UAAM,eAAW,sCAAwB;AACzC,yBAAM;AAAA,MACJ;AAAA,MACA,cAAc,CAAC,MAAM,SAAS,QAAQ,CAAC;AAAA,MACvC;AAAA,IACF,CAAC;AACD,MAAE,mCAAmC;AAAA,EACvC,SAAS,KAAK;AACZ,YAAQ,KAAK,4CAA4C,GAAG;AAAA,EAC9D;AACF;AAEA,UAAU;","names":["import_core","import_react"]}
package/dist/auto.js CHANGED
@@ -10,7 +10,12 @@ function bootstrap() {
10
10
  if (typeof globalThis === "undefined") return;
11
11
  const g = globalThis;
12
12
  if (g.__REACT_PERFSCOPE_AUTO_MOUNTED__) return;
13
- const env = globalThis.process?.env?.NODE_ENV;
13
+ let env;
14
+ try {
15
+ env = process.env.NODE_ENV;
16
+ } catch {
17
+ env = void 0;
18
+ }
14
19
  if (env === "production") return;
15
20
  if (typeof document === "undefined") return;
16
21
  try {
package/dist/auto.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/auto.ts"],"sourcesContent":["import { createSourceMapResolver } from '@react-perfscope/core'\nimport { installDevToolsHook } from '@react-perfscope/react'\nimport { mount } from '@react-perfscope/ui'\nimport { createConfiguredRecorder } from './bootstrap'\n\n/**\n * Side-effect entry. Importing `react-perfscope/auto` bootstraps a Recorder\n * with the render collector and mounts the UI. Idempotent — importing twice\n * is a no-op (the first import wins).\n *\n * Bails when `process.env.NODE_ENV === 'production'` (build plugins also\n * guard against prod, but this is defense-in-depth).\n */\nfunction bootstrap(): void {\n if (typeof globalThis === 'undefined') return\n const g = globalThis as { __REACT_PERFSCOPE_AUTO_MOUNTED__?: boolean }\n if (g.__REACT_PERFSCOPE_AUTO_MOUNTED__) return\n\n const env = (globalThis as { process?: { env?: { NODE_ENV?: string } } }).process?.env?.NODE_ENV\n if (env === 'production') return\n\n if (typeof document === 'undefined') return\n\n try {\n // Install the React DevTools hook SYNCHRONOUSLY before react-dom is\n // evaluated. react-dom captures `__REACT_DEVTOOLS_GLOBAL_HOOK__` exactly\n // once at module-load time, so the hook must exist by the time the user\n // bundle imports react-dom. A no-op listener is enough to register the\n // hook — when the render collector later activates, it adds the real\n // commit handler to the same global hook.\n installDevToolsHook(() => {})\n\n const { recorder, finalize } = createConfiguredRecorder()\n const resolver = createSourceMapResolver()\n mount({\n recorder,\n resolveFrame: (f) => resolver.resolve(f),\n finalize,\n })\n g.__REACT_PERFSCOPE_AUTO_MOUNTED__ = true\n } catch (err) {\n console.warn('[react-perfscope] auto bootstrap failed:', err)\n }\n}\n\nbootstrap()\n"],"mappings":";;;;;AAAA,SAAS,+BAA+B;AACxC,SAAS,2BAA2B;AACpC,SAAS,aAAa;AAWtB,SAAS,YAAkB;AACzB,MAAI,OAAO,eAAe,YAAa;AACvC,QAAM,IAAI;AACV,MAAI,EAAE,iCAAkC;AAExC,QAAM,MAAO,WAA6D,SAAS,KAAK;AACxF,MAAI,QAAQ,aAAc;AAE1B,MAAI,OAAO,aAAa,YAAa;AAErC,MAAI;AAOF,wBAAoB,MAAM;AAAA,IAAC,CAAC;AAE5B,UAAM,EAAE,UAAU,SAAS,IAAI,yBAAyB;AACxD,UAAM,WAAW,wBAAwB;AACzC,UAAM;AAAA,MACJ;AAAA,MACA,cAAc,CAAC,MAAM,SAAS,QAAQ,CAAC;AAAA,MACvC;AAAA,IACF,CAAC;AACD,MAAE,mCAAmC;AAAA,EACvC,SAAS,KAAK;AACZ,YAAQ,KAAK,4CAA4C,GAAG;AAAA,EAC9D;AACF;AAEA,UAAU;","names":[]}
1
+ {"version":3,"sources":["../src/auto.ts"],"sourcesContent":["import { createSourceMapResolver } from '@react-perfscope/core'\nimport { installDevToolsHook } from '@react-perfscope/react'\nimport { mount } from '@react-perfscope/ui'\nimport { createConfiguredRecorder } from './bootstrap'\n\n// Type-only declaration so the guard below can use the bare member expression\n// `process.env.NODE_ENV` — the exact token bundlers (Vite define, webpack\n// DefinePlugin, esbuild) statically replace. Optional-chained access through\n// globalThis is not replaced and browsers have no `process` global, which\n// would make the guard a silent no-op in production bundles. The try/catch\n// absorbs the ReferenceError when no bundler and no `process` exist.\ndeclare const process: { env: { NODE_ENV?: string } }\n\n/**\n * Side-effect entry. Importing `react-perfscope/auto` bootstraps a Recorder\n * with the render collector and mounts the UI. Idempotent — importing twice\n * is a no-op (the first import wins).\n *\n * Bails when `process.env.NODE_ENV === 'production'` (build plugins also\n * guard against prod, but this is defense-in-depth).\n */\nfunction bootstrap(): void {\n if (typeof globalThis === 'undefined') return\n const g = globalThis as { __REACT_PERFSCOPE_AUTO_MOUNTED__?: boolean }\n if (g.__REACT_PERFSCOPE_AUTO_MOUNTED__) return\n\n let env: string | undefined\n try {\n env = process.env.NODE_ENV\n } catch {\n env = undefined\n }\n if (env === 'production') return\n\n if (typeof document === 'undefined') return\n\n try {\n // Install the React DevTools hook SYNCHRONOUSLY before react-dom is\n // evaluated. react-dom captures `__REACT_DEVTOOLS_GLOBAL_HOOK__` exactly\n // once at module-load time, so the hook must exist by the time the user\n // bundle imports react-dom. A no-op listener is enough to register the\n // hook — when the render collector later activates, it adds the real\n // commit handler to the same global hook.\n installDevToolsHook(() => {})\n\n const { recorder, finalize } = createConfiguredRecorder()\n const resolver = createSourceMapResolver()\n mount({\n recorder,\n resolveFrame: (f) => resolver.resolve(f),\n finalize,\n })\n g.__REACT_PERFSCOPE_AUTO_MOUNTED__ = true\n } catch (err) {\n console.warn('[react-perfscope] auto bootstrap failed:', err)\n }\n}\n\nbootstrap()\n"],"mappings":";;;;;AAAA,SAAS,+BAA+B;AACxC,SAAS,2BAA2B;AACpC,SAAS,aAAa;AAmBtB,SAAS,YAAkB;AACzB,MAAI,OAAO,eAAe,YAAa;AACvC,QAAM,IAAI;AACV,MAAI,EAAE,iCAAkC;AAExC,MAAI;AACJ,MAAI;AACF,UAAM,QAAQ,IAAI;AAAA,EACpB,QAAQ;AACN,UAAM;AAAA,EACR;AACA,MAAI,QAAQ,aAAc;AAE1B,MAAI,OAAO,aAAa,YAAa;AAErC,MAAI;AAOF,wBAAoB,MAAM;AAAA,IAAC,CAAC;AAE5B,UAAM,EAAE,UAAU,SAAS,IAAI,yBAAyB;AACxD,UAAM,WAAW,wBAAwB;AACzC,UAAM;AAAA,MACJ;AAAA,MACA,cAAc,CAAC,MAAM,SAAS,QAAQ,CAAC;AAAA,MACvC;AAAA,IACF,CAAC;AACD,MAAE,mCAAmC;AAAA,EACvC,SAAS,KAAK;AACZ,YAAQ,KAAK,4CAA4C,GAAG;AAAA,EAC9D;AACF;AAEA,UAAU;","names":[]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-perfscope",
3
- "version": "0.7.0",
3
+ "version": "0.7.1",
4
4
  "description": "Zero-config React performance profiler with an in-app panel.",
5
5
  "keywords": [
6
6
  "react",
@@ -39,9 +39,9 @@
39
39
  "./dist/auto.cjs"
40
40
  ],
41
41
  "dependencies": {
42
- "@react-perfscope/core": "0.7.0",
43
- "@react-perfscope/ui": "0.7.0",
44
- "@react-perfscope/react": "0.7.0"
42
+ "@react-perfscope/core": "0.7.1",
43
+ "@react-perfscope/react": "0.7.1",
44
+ "@react-perfscope/ui": "0.7.1"
45
45
  },
46
46
  "license": "MIT",
47
47
  "author": "rayforvideos",