inpspy 1.0.0-test → 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/react.cjs ADDED
@@ -0,0 +1,56 @@
1
+ "use client";
2
+ "use strict";
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
7
+ var __export = (target, all) => {
8
+ for (var name in all)
9
+ __defProp(target, name, { get: all[name], enumerable: true });
10
+ };
11
+ var __copyProps = (to, from, except, desc) => {
12
+ if (from && typeof from === "object" || typeof from === "function") {
13
+ for (let key of __getOwnPropNames(from))
14
+ if (!__hasOwnProp.call(to, key) && key !== except)
15
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
16
+ }
17
+ return to;
18
+ };
19
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
20
+
21
+ // src/react.ts
22
+ var react_exports = {};
23
+ __export(react_exports, {
24
+ InpSpy: () => InpSpy,
25
+ useInpSpy: () => useInpSpy
26
+ });
27
+ module.exports = __toCommonJS(react_exports);
28
+ var import_react = require("react");
29
+ var import_inpspy = require("inpspy");
30
+ function useInpSpy(options = {}) {
31
+ const callback = (0, import_react.useRef)(options.onInteraction);
32
+ callback.current = options.onInteraction;
33
+ const { threshold, durationThreshold, overlay, console: log, maxEntries, position, toastDuration } = options;
34
+ (0, import_react.useEffect)(
35
+ () => (0, import_inpspy.start)({
36
+ threshold,
37
+ durationThreshold,
38
+ overlay,
39
+ console: log,
40
+ maxEntries,
41
+ position,
42
+ toastDuration,
43
+ onInteraction: (interaction) => callback.current?.(interaction)
44
+ }),
45
+ [threshold, durationThreshold, overlay, log, maxEntries, position, toastDuration]
46
+ );
47
+ }
48
+ function InpSpy(props) {
49
+ useInpSpy(props);
50
+ return null;
51
+ }
52
+ // Annotate the CommonJS export names for ESM import in node:
53
+ 0 && (module.exports = {
54
+ InpSpy,
55
+ useInpSpy
56
+ });
@@ -0,0 +1,14 @@
1
+ import { InpSpyOptions } from 'inpspy';
2
+ export { InpInteraction, InpSpyOptions } from 'inpspy';
3
+
4
+ /**
5
+ * Starts inpspy when the component mounts and stops it on unmount. Strict Mode safe: the double
6
+ * mount/unmount of development leaves exactly one running session. Restarts when an option changes
7
+ * (`onInteraction` may change freely).
8
+ */
9
+ declare function useInpSpy(options?: InpSpyOptions): void;
10
+ type InpSpyProps = InpSpyOptions;
11
+ /** Renders nothing; runs inpspy while mounted. `<InpSpy threshold={150} position="bottom-left" />` */
12
+ declare function InpSpy(props: InpSpyProps): null;
13
+
14
+ export { InpSpy, type InpSpyProps, useInpSpy };
@@ -0,0 +1,14 @@
1
+ import { InpSpyOptions } from 'inpspy';
2
+ export { InpInteraction, InpSpyOptions } from 'inpspy';
3
+
4
+ /**
5
+ * Starts inpspy when the component mounts and stops it on unmount. Strict Mode safe: the double
6
+ * mount/unmount of development leaves exactly one running session. Restarts when an option changes
7
+ * (`onInteraction` may change freely).
8
+ */
9
+ declare function useInpSpy(options?: InpSpyOptions): void;
10
+ type InpSpyProps = InpSpyOptions;
11
+ /** Renders nothing; runs inpspy while mounted. `<InpSpy threshold={150} position="bottom-left" />` */
12
+ declare function InpSpy(props: InpSpyProps): null;
13
+
14
+ export { InpSpy, type InpSpyProps, useInpSpy };
package/dist/react.js ADDED
@@ -0,0 +1,31 @@
1
+ "use client";
2
+
3
+ // src/react.ts
4
+ import { useEffect, useRef } from "react";
5
+ import { start } from "inpspy";
6
+ function useInpSpy(options = {}) {
7
+ const callback = useRef(options.onInteraction);
8
+ callback.current = options.onInteraction;
9
+ const { threshold, durationThreshold, overlay, console: log, maxEntries, position, toastDuration } = options;
10
+ useEffect(
11
+ () => start({
12
+ threshold,
13
+ durationThreshold,
14
+ overlay,
15
+ console: log,
16
+ maxEntries,
17
+ position,
18
+ toastDuration,
19
+ onInteraction: (interaction) => callback.current?.(interaction)
20
+ }),
21
+ [threshold, durationThreshold, overlay, log, maxEntries, position, toastDuration]
22
+ );
23
+ }
24
+ function InpSpy(props) {
25
+ useInpSpy(props);
26
+ return null;
27
+ }
28
+ export {
29
+ InpSpy,
30
+ useInpSpy
31
+ };
package/package.json CHANGED
@@ -1,9 +1,101 @@
1
1
  {
2
2
  "name": "inpspy",
3
- "version": "1.0.0-test",
4
- "description": "Find what makes clicks slow: a dev overlay that shows which script, handler and element caused each slow INP interaction (placeholder - in development)",
5
- "main": "index.js",
6
- "files": ["index.js", "README.md"],
3
+ "version": "1.0.0",
4
+ "description": "Find what makes clicks slow. A development overlay for INP (Interaction to Next Paint) that shows, for every slow click, tap or key press, the element, the input delay / processing / presentation split and the scripts that ran (Long Animation Frames). Plain JS, React and Next.js. Zero dependencies.",
5
+ "keywords": [
6
+ "inp",
7
+ "interaction-to-next-paint",
8
+ "core-web-vitals",
9
+ "web-vitals",
10
+ "performance",
11
+ "web-performance",
12
+ "responsiveness",
13
+ "event-timing",
14
+ "long-animation-frames",
15
+ "loaf",
16
+ "long-tasks",
17
+ "slow-interactions",
18
+ "third-party-scripts",
19
+ "devtools",
20
+ "overlay",
21
+ "debugging",
22
+ "profiling",
23
+ "react",
24
+ "nextjs",
25
+ "vite",
26
+ "lighthouse"
27
+ ],
28
+ "license": "MIT",
7
29
  "author": "CK Giri <ckgdev@gmail.com>",
8
- "license": "MIT"
30
+ "funding": "https://github.com/ckgiri/inpspy?sponsor=1",
31
+ "homepage": "https://github.com/ckgiri/inpspy",
32
+ "repository": {
33
+ "type": "git",
34
+ "url": "git+https://github.com/ckgiri/inpspy.git"
35
+ },
36
+ "bugs": {
37
+ "url": "https://github.com/ckgiri/inpspy/issues"
38
+ },
39
+ "type": "module",
40
+ "sideEffects": false,
41
+ "main": "./dist/index.cjs",
42
+ "module": "./dist/index.js",
43
+ "types": "./dist/index.d.ts",
44
+ "exports": {
45
+ ".": {
46
+ "import": {
47
+ "types": "./dist/index.d.ts",
48
+ "default": "./dist/index.js"
49
+ },
50
+ "require": {
51
+ "types": "./dist/index.d.cts",
52
+ "default": "./dist/index.cjs"
53
+ }
54
+ },
55
+ "./react": {
56
+ "import": {
57
+ "types": "./dist/react.d.ts",
58
+ "default": "./dist/react.js"
59
+ },
60
+ "require": {
61
+ "types": "./dist/react.d.cts",
62
+ "default": "./dist/react.cjs"
63
+ }
64
+ },
65
+ "./package.json": "./package.json"
66
+ },
67
+ "files": [
68
+ "dist",
69
+ "CHANGELOG.md"
70
+ ],
71
+ "engines": {
72
+ "node": ">=20"
73
+ },
74
+ "scripts": {
75
+ "build": "tsup",
76
+ "test": "vitest run",
77
+ "typecheck": "tsc -p .",
78
+ "prepublishOnly": "npm run typecheck && npm test && npm run build"
79
+ },
80
+ "peerDependencies": {
81
+ "react": ">=18"
82
+ },
83
+ "peerDependenciesMeta": {
84
+ "react": {
85
+ "optional": true
86
+ }
87
+ },
88
+ "devDependencies": {
89
+ "@types/node": "^20.19.43",
90
+ "@types/react": "^19.3.3",
91
+ "@types/react-dom": "^19.3.0",
92
+ "esbuild": "^0.28.2",
93
+ "puppeteer-core": "^25.19.0",
94
+ "react": "^19.3.1",
95
+ "react-dom": "^19.3.1",
96
+ "sharp": "^0.35.6",
97
+ "tsup": "^8.5.1",
98
+ "typescript": "^5.9.3",
99
+ "vitest": "^2.1.9"
100
+ }
9
101
  }
package/index.js DELETED
@@ -1 +0,0 @@
1
- module.exports = {};