react-perfscope 0.7.1 → 1.0.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/auto-payload.cjs +68 -0
- package/dist/auto-payload.cjs.map +1 -0
- package/dist/auto-payload.d.cts +9 -0
- package/dist/auto-payload.d.ts +9 -0
- package/dist/auto-payload.js +20 -0
- package/dist/auto-payload.js.map +1 -0
- package/dist/auto.cjs +30 -42
- package/dist/auto.cjs.map +1 -1
- package/dist/auto.js +7 -18
- package/dist/auto.js.map +1 -1
- package/package.json +7 -4
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// src/auto-payload.ts
|
|
21
|
+
var auto_payload_exports = {};
|
|
22
|
+
__export(auto_payload_exports, {
|
|
23
|
+
mountAuto: () => mountAuto
|
|
24
|
+
});
|
|
25
|
+
module.exports = __toCommonJS(auto_payload_exports);
|
|
26
|
+
var import_core2 = require("@react-perfscope/core");
|
|
27
|
+
var import_ui = require("@react-perfscope/ui");
|
|
28
|
+
|
|
29
|
+
// src/bootstrap.ts
|
|
30
|
+
var import_core = require("@react-perfscope/core");
|
|
31
|
+
var import_react = require("@react-perfscope/react");
|
|
32
|
+
function createConfiguredRecorder() {
|
|
33
|
+
const recorder = (0, import_core.createRecorder)();
|
|
34
|
+
recorder.use((0, import_core.createForcedReflowCollector)());
|
|
35
|
+
recorder.use((0, import_core.createLongTasksCollector)());
|
|
36
|
+
recorder.use((0, import_core.createLayoutShiftCollector)());
|
|
37
|
+
recorder.use((0, import_core.createNetworkCollector)());
|
|
38
|
+
recorder.use((0, import_core.createWebVitalsCollector)());
|
|
39
|
+
recorder.use((0, import_react.createRenderCollector)());
|
|
40
|
+
const selfProfiler = (0, import_core.createSelfProfilingCollector)();
|
|
41
|
+
recorder.use(selfProfiler);
|
|
42
|
+
const heap = (0, import_core.createHeapCollector)();
|
|
43
|
+
recorder.use(heap);
|
|
44
|
+
const interaction = (0, import_core.createInteractionCollector)();
|
|
45
|
+
recorder.use(interaction);
|
|
46
|
+
const frame = (0, import_core.createFrameCollector)();
|
|
47
|
+
recorder.use(frame);
|
|
48
|
+
const leak = (0, import_react.createLeakCollector)();
|
|
49
|
+
recorder.use(leak);
|
|
50
|
+
const finalize = (result) => Promise.resolve(interaction.finalize(result)).then((r) => selfProfiler.finalize(r)).then((r) => heap.finalize(r)).then((r) => frame.finalize(r)).then((r) => leak.finalize(r));
|
|
51
|
+
return { recorder, finalize };
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
// src/auto-payload.ts
|
|
55
|
+
function mountAuto() {
|
|
56
|
+
const { recorder, finalize } = createConfiguredRecorder();
|
|
57
|
+
const resolver = (0, import_core2.createSourceMapResolver)();
|
|
58
|
+
(0, import_ui.mount)({
|
|
59
|
+
recorder,
|
|
60
|
+
resolveFrame: (f) => resolver.resolve(f),
|
|
61
|
+
finalize
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
65
|
+
0 && (module.exports = {
|
|
66
|
+
mountAuto
|
|
67
|
+
});
|
|
68
|
+
//# sourceMappingURL=auto-payload.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/auto-payload.ts","../src/bootstrap.ts"],"sourcesContent":["import { createSourceMapResolver } from '@react-perfscope/core'\nimport { mount } from '@react-perfscope/ui'\nimport { createConfiguredRecorder } from './bootstrap'\n\n/**\n * The heavy half of the `/auto` entry: recorder wiring + panel mount. Loaded\n * exclusively via dynamic import from `auto.ts` so that production bundles\n * (where the stub's NODE_ENV guard makes this unreachable) never carry the\n * recorder, collectors, panel, or preact.\n */\nexport function mountAuto(): void {\n const { recorder, finalize } = createConfiguredRecorder()\n const resolver = createSourceMapResolver()\n mount({\n recorder,\n resolveFrame: (f) => resolver.resolve(f),\n finalize,\n })\n}\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;AAAA;AAAA;AAAA;AAAA;AAAA,IAAAA,eAAwC;AACxC,gBAAsB;;;ACDtB,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;;;ADnDO,SAAS,YAAkB;AAChC,QAAM,EAAE,UAAU,SAAS,IAAI,yBAAyB;AACxD,QAAM,eAAW,sCAAwB;AACzC,uBAAM;AAAA,IACJ;AAAA,IACA,cAAc,CAAC,MAAM,SAAS,QAAQ,CAAC;AAAA,IACvC;AAAA,EACF,CAAC;AACH;","names":["import_core"]}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The heavy half of the `/auto` entry: recorder wiring + panel mount. Loaded
|
|
3
|
+
* exclusively via dynamic import from `auto.ts` so that production bundles
|
|
4
|
+
* (where the stub's NODE_ENV guard makes this unreachable) never carry the
|
|
5
|
+
* recorder, collectors, panel, or preact.
|
|
6
|
+
*/
|
|
7
|
+
declare function mountAuto(): void;
|
|
8
|
+
|
|
9
|
+
export { mountAuto };
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The heavy half of the `/auto` entry: recorder wiring + panel mount. Loaded
|
|
3
|
+
* exclusively via dynamic import from `auto.ts` so that production bundles
|
|
4
|
+
* (where the stub's NODE_ENV guard makes this unreachable) never carry the
|
|
5
|
+
* recorder, collectors, panel, or preact.
|
|
6
|
+
*/
|
|
7
|
+
declare function mountAuto(): void;
|
|
8
|
+
|
|
9
|
+
export { mountAuto };
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import {
|
|
2
|
+
createConfiguredRecorder
|
|
3
|
+
} from "./chunk-AZMABLM7.js";
|
|
4
|
+
|
|
5
|
+
// src/auto-payload.ts
|
|
6
|
+
import { createSourceMapResolver } from "@react-perfscope/core";
|
|
7
|
+
import { mount } from "@react-perfscope/ui";
|
|
8
|
+
function mountAuto() {
|
|
9
|
+
const { recorder, finalize } = createConfiguredRecorder();
|
|
10
|
+
const resolver = createSourceMapResolver();
|
|
11
|
+
mount({
|
|
12
|
+
recorder,
|
|
13
|
+
resolveFrame: (f) => resolver.resolve(f),
|
|
14
|
+
finalize
|
|
15
|
+
});
|
|
16
|
+
}
|
|
17
|
+
export {
|
|
18
|
+
mountAuto
|
|
19
|
+
};
|
|
20
|
+
//# sourceMappingURL=auto-payload.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/auto-payload.ts"],"sourcesContent":["import { createSourceMapResolver } from '@react-perfscope/core'\nimport { mount } from '@react-perfscope/ui'\nimport { createConfiguredRecorder } from './bootstrap'\n\n/**\n * The heavy half of the `/auto` entry: recorder wiring + panel mount. Loaded\n * exclusively via dynamic import from `auto.ts` so that production bundles\n * (where the stub's NODE_ENV guard makes this unreachable) never carry the\n * recorder, collectors, panel, or preact.\n */\nexport function mountAuto(): void {\n const { recorder, finalize } = createConfiguredRecorder()\n const resolver = createSourceMapResolver()\n mount({\n recorder,\n resolveFrame: (f) => resolver.resolve(f),\n finalize,\n })\n}\n"],"mappings":";;;;;AAAA,SAAS,+BAA+B;AACxC,SAAS,aAAa;AASf,SAAS,YAAkB;AAChC,QAAM,EAAE,UAAU,SAAS,IAAI,yBAAyB;AACxD,QAAM,WAAW,wBAAwB;AACzC,QAAM;AAAA,IACJ;AAAA,IACA,cAAc,CAAC,MAAM,SAAS,QAAQ,CAAC;AAAA,IACvC;AAAA,EACF,CAAC;AACH;","names":[]}
|
package/dist/auto.cjs
CHANGED
|
@@ -1,62 +1,50 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __copyProps = (to, from, except, desc) => {
|
|
9
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
10
|
+
for (let key of __getOwnPropNames(from))
|
|
11
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
12
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
13
|
+
}
|
|
14
|
+
return to;
|
|
15
|
+
};
|
|
16
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
17
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
18
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
19
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
20
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
21
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
22
|
+
mod
|
|
23
|
+
));
|
|
2
24
|
|
|
3
25
|
// src/auto.ts
|
|
4
|
-
var import_core2 = require("@react-perfscope/core");
|
|
5
|
-
var import_react2 = require("@react-perfscope/react");
|
|
6
|
-
var import_ui = require("@react-perfscope/ui");
|
|
7
|
-
|
|
8
|
-
// src/bootstrap.ts
|
|
9
|
-
var import_core = require("@react-perfscope/core");
|
|
10
26
|
var import_react = require("@react-perfscope/react");
|
|
11
|
-
function createConfiguredRecorder() {
|
|
12
|
-
const recorder = (0, import_core.createRecorder)();
|
|
13
|
-
recorder.use((0, import_core.createForcedReflowCollector)());
|
|
14
|
-
recorder.use((0, import_core.createLongTasksCollector)());
|
|
15
|
-
recorder.use((0, import_core.createLayoutShiftCollector)());
|
|
16
|
-
recorder.use((0, import_core.createNetworkCollector)());
|
|
17
|
-
recorder.use((0, import_core.createWebVitalsCollector)());
|
|
18
|
-
recorder.use((0, import_react.createRenderCollector)());
|
|
19
|
-
const selfProfiler = (0, import_core.createSelfProfilingCollector)();
|
|
20
|
-
recorder.use(selfProfiler);
|
|
21
|
-
const heap = (0, import_core.createHeapCollector)();
|
|
22
|
-
recorder.use(heap);
|
|
23
|
-
const interaction = (0, import_core.createInteractionCollector)();
|
|
24
|
-
recorder.use(interaction);
|
|
25
|
-
const frame = (0, import_core.createFrameCollector)();
|
|
26
|
-
recorder.use(frame);
|
|
27
|
-
const leak = (0, import_react.createLeakCollector)();
|
|
28
|
-
recorder.use(leak);
|
|
29
|
-
const finalize = (result) => Promise.resolve(interaction.finalize(result)).then((r) => selfProfiler.finalize(r)).then((r) => heap.finalize(r)).then((r) => frame.finalize(r)).then((r) => leak.finalize(r));
|
|
30
|
-
return { recorder, finalize };
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
// src/auto.ts
|
|
34
27
|
function bootstrap() {
|
|
35
28
|
if (typeof globalThis === "undefined") return;
|
|
36
29
|
const g = globalThis;
|
|
37
30
|
if (g.__REACT_PERFSCOPE_AUTO_MOUNTED__) return;
|
|
38
|
-
let env;
|
|
39
31
|
try {
|
|
40
|
-
|
|
32
|
+
if (process.env.NODE_ENV === "production") return;
|
|
41
33
|
} catch {
|
|
42
|
-
env = void 0;
|
|
43
34
|
}
|
|
44
|
-
if (env === "production") return;
|
|
45
35
|
if (typeof document === "undefined") return;
|
|
46
36
|
try {
|
|
47
|
-
(0,
|
|
48
|
-
});
|
|
49
|
-
const { recorder, finalize } = createConfiguredRecorder();
|
|
50
|
-
const resolver = (0, import_core2.createSourceMapResolver)();
|
|
51
|
-
(0, import_ui.mount)({
|
|
52
|
-
recorder,
|
|
53
|
-
resolveFrame: (f) => resolver.resolve(f),
|
|
54
|
-
finalize
|
|
37
|
+
(0, import_react.installDevToolsHook)(() => {
|
|
55
38
|
});
|
|
56
|
-
g.__REACT_PERFSCOPE_AUTO_MOUNTED__ = true;
|
|
57
39
|
} catch (err) {
|
|
58
40
|
console.warn("[react-perfscope] auto bootstrap failed:", err);
|
|
41
|
+
return;
|
|
59
42
|
}
|
|
43
|
+
g.__REACT_PERFSCOPE_AUTO_MOUNTED__ = true;
|
|
44
|
+
void import("./auto-payload.js").then((m) => m.mountAuto()).catch((err) => {
|
|
45
|
+
g.__REACT_PERFSCOPE_AUTO_MOUNTED__ = false;
|
|
46
|
+
console.warn("[react-perfscope] auto bootstrap failed:", err);
|
|
47
|
+
});
|
|
60
48
|
}
|
|
61
49
|
bootstrap();
|
|
62
50
|
//# sourceMappingURL=auto.cjs.map
|
package/dist/auto.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/auto.ts"
|
|
1
|
+
{"version":3,"sources":["../src/auto.ts"],"sourcesContent":["import { installDevToolsHook } from '@react-perfscope/react'\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). Only this stub and the\n * DevTools-hook shim are imported statically; the recorder + panel load via\n * dynamic import so production bundles never carry them — bundlers that fold\n * the NODE_ENV comparison drop the payload chunk entirely, and even without\n * folding the chunk is emitted but never fetched.\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 try {\n // Shaped as a direct early return (not a flag variable) so that after\n // bundlers replace the token, minifiers fold `if ('production' ===\n // 'production') return` and drop everything below — including the\n // dynamic payload import and the hook-shim import — from prod bundles.\n if (process.env.NODE_ENV === 'production') return\n } catch {\n // No bundler and no `process` global: treat as development.\n }\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 — this is the one thing that cannot wait for\n // the dynamic payload. A no-op listener is enough to register the hook;\n // when the render collector later activates, it adds the real commit\n // handler to the same global hook.\n installDevToolsHook(() => {})\n } catch (err) {\n console.warn('[react-perfscope] auto bootstrap failed:', err)\n return\n }\n\n // Claim the flag before the async load so a second import racing the first\n // stays a no-op; release it on failure so a later import can retry.\n g.__REACT_PERFSCOPE_AUTO_MOUNTED__ = true\n void import('./auto-payload.js')\n .then((m) => m.mountAuto())\n .catch((err) => {\n g.__REACT_PERFSCOPE_AUTO_MOUNTED__ = false\n console.warn('[react-perfscope] auto bootstrap failed:', err)\n })\n}\n\nbootstrap()\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAAA,mBAAoC;AAsBpC,SAAS,YAAkB;AACzB,MAAI,OAAO,eAAe,YAAa;AACvC,QAAM,IAAI;AACV,MAAI,EAAE,iCAAkC;AAExC,MAAI;AAKF,QAAI,QAAQ,IAAI,aAAa,aAAc;AAAA,EAC7C,QAAQ;AAAA,EAER;AAEA,MAAI,OAAO,aAAa,YAAa;AAErC,MAAI;AAQF,0CAAoB,MAAM;AAAA,IAAC,CAAC;AAAA,EAC9B,SAAS,KAAK;AACZ,YAAQ,KAAK,4CAA4C,GAAG;AAC5D;AAAA,EACF;AAIA,IAAE,mCAAmC;AACrC,OAAK,OAAO,mBAAmB,EAC5B,KAAK,CAAC,MAAM,EAAE,UAAU,CAAC,EACzB,MAAM,CAAC,QAAQ;AACd,MAAE,mCAAmC;AACrC,YAAQ,KAAK,4CAA4C,GAAG;AAAA,EAC9D,CAAC;AACL;AAEA,UAAU;","names":[]}
|
package/dist/auto.js
CHANGED
|
@@ -1,37 +1,26 @@
|
|
|
1
|
-
import {
|
|
2
|
-
createConfiguredRecorder
|
|
3
|
-
} from "./chunk-AZMABLM7.js";
|
|
4
|
-
|
|
5
1
|
// src/auto.ts
|
|
6
|
-
import { createSourceMapResolver } from "@react-perfscope/core";
|
|
7
2
|
import { installDevToolsHook } from "@react-perfscope/react";
|
|
8
|
-
import { mount } from "@react-perfscope/ui";
|
|
9
3
|
function bootstrap() {
|
|
10
4
|
if (typeof globalThis === "undefined") return;
|
|
11
5
|
const g = globalThis;
|
|
12
6
|
if (g.__REACT_PERFSCOPE_AUTO_MOUNTED__) return;
|
|
13
|
-
let env;
|
|
14
7
|
try {
|
|
15
|
-
|
|
8
|
+
if (process.env.NODE_ENV === "production") return;
|
|
16
9
|
} catch {
|
|
17
|
-
env = void 0;
|
|
18
10
|
}
|
|
19
|
-
if (env === "production") return;
|
|
20
11
|
if (typeof document === "undefined") return;
|
|
21
12
|
try {
|
|
22
13
|
installDevToolsHook(() => {
|
|
23
14
|
});
|
|
24
|
-
const { recorder, finalize } = createConfiguredRecorder();
|
|
25
|
-
const resolver = createSourceMapResolver();
|
|
26
|
-
mount({
|
|
27
|
-
recorder,
|
|
28
|
-
resolveFrame: (f) => resolver.resolve(f),
|
|
29
|
-
finalize
|
|
30
|
-
});
|
|
31
|
-
g.__REACT_PERFSCOPE_AUTO_MOUNTED__ = true;
|
|
32
15
|
} catch (err) {
|
|
33
16
|
console.warn("[react-perfscope] auto bootstrap failed:", err);
|
|
17
|
+
return;
|
|
34
18
|
}
|
|
19
|
+
g.__REACT_PERFSCOPE_AUTO_MOUNTED__ = true;
|
|
20
|
+
void import("./auto-payload.js").then((m) => m.mountAuto()).catch((err) => {
|
|
21
|
+
g.__REACT_PERFSCOPE_AUTO_MOUNTED__ = false;
|
|
22
|
+
console.warn("[react-perfscope] auto bootstrap failed:", err);
|
|
23
|
+
});
|
|
35
24
|
}
|
|
36
25
|
bootstrap();
|
|
37
26
|
//# sourceMappingURL=auto.js.map
|
package/dist/auto.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/auto.ts"],"sourcesContent":["import {
|
|
1
|
+
{"version":3,"sources":["../src/auto.ts"],"sourcesContent":["import { installDevToolsHook } from '@react-perfscope/react'\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). Only this stub and the\n * DevTools-hook shim are imported statically; the recorder + panel load via\n * dynamic import so production bundles never carry them — bundlers that fold\n * the NODE_ENV comparison drop the payload chunk entirely, and even without\n * folding the chunk is emitted but never fetched.\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 try {\n // Shaped as a direct early return (not a flag variable) so that after\n // bundlers replace the token, minifiers fold `if ('production' ===\n // 'production') return` and drop everything below — including the\n // dynamic payload import and the hook-shim import — from prod bundles.\n if (process.env.NODE_ENV === 'production') return\n } catch {\n // No bundler and no `process` global: treat as development.\n }\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 — this is the one thing that cannot wait for\n // the dynamic payload. A no-op listener is enough to register the hook;\n // when the render collector later activates, it adds the real commit\n // handler to the same global hook.\n installDevToolsHook(() => {})\n } catch (err) {\n console.warn('[react-perfscope] auto bootstrap failed:', err)\n return\n }\n\n // Claim the flag before the async load so a second import racing the first\n // stays a no-op; release it on failure so a later import can retry.\n g.__REACT_PERFSCOPE_AUTO_MOUNTED__ = true\n void import('./auto-payload.js')\n .then((m) => m.mountAuto())\n .catch((err) => {\n g.__REACT_PERFSCOPE_AUTO_MOUNTED__ = false\n console.warn('[react-perfscope] auto bootstrap failed:', err)\n })\n}\n\nbootstrap()\n"],"mappings":";AAAA,SAAS,2BAA2B;AAsBpC,SAAS,YAAkB;AACzB,MAAI,OAAO,eAAe,YAAa;AACvC,QAAM,IAAI;AACV,MAAI,EAAE,iCAAkC;AAExC,MAAI;AAKF,QAAI,QAAQ,IAAI,aAAa,aAAc;AAAA,EAC7C,QAAQ;AAAA,EAER;AAEA,MAAI,OAAO,aAAa,YAAa;AAErC,MAAI;AAQF,wBAAoB,MAAM;AAAA,IAAC,CAAC;AAAA,EAC9B,SAAS,KAAK;AACZ,YAAQ,KAAK,4CAA4C,GAAG;AAC5D;AAAA,EACF;AAIA,IAAE,mCAAmC;AACrC,OAAK,OAAO,mBAAmB,EAC5B,KAAK,CAAC,MAAM,EAAE,UAAU,CAAC,EACzB,MAAM,CAAC,QAAQ;AACd,MAAE,mCAAmC;AACrC,YAAQ,KAAK,4CAA4C,GAAG;AAAA,EAC9D,CAAC;AACL;AAEA,UAAU;","names":[]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "react-perfscope",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "1.0.0",
|
|
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.
|
|
43
|
-
"@react-perfscope/react": "0.
|
|
44
|
-
"@react-perfscope/ui": "0.
|
|
42
|
+
"@react-perfscope/core": "1.0.0",
|
|
43
|
+
"@react-perfscope/react": "1.0.0",
|
|
44
|
+
"@react-perfscope/ui": "1.0.0"
|
|
45
45
|
},
|
|
46
46
|
"license": "MIT",
|
|
47
47
|
"author": "rayforvideos",
|
|
@@ -55,6 +55,9 @@
|
|
|
55
55
|
"publishConfig": {
|
|
56
56
|
"access": "public"
|
|
57
57
|
},
|
|
58
|
+
"engines": {
|
|
59
|
+
"node": ">=18"
|
|
60
|
+
},
|
|
58
61
|
"scripts": {
|
|
59
62
|
"build": "tsup && node scripts/prepend-dts-refs.mjs",
|
|
60
63
|
"typecheck": "tsc --noEmit"
|