react-grab 0.0.0 → 0.0.2
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/LICENSE +21 -0
- package/README.md +64 -0
- package/dist/index.cjs +180 -0
- package/dist/index.d.cts +13 -0
- package/dist/index.d.ts +13 -0
- package/dist/index.global.js +61 -0
- package/dist/index.js +177 -0
- package/package.json +72 -1
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 Aiden Bai
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
# <img src="https://github.com/aidenybai/yaps/blob/main/.github/assets/yaps.png?raw=true" width="60" align="center" /> yaps – yet another project starter
|
|
2
|
+
|
|
3
|
+
i got super tired of manually setting up projects every time i start a new one, so i made this boilerplate.
|
|
4
|
+
|
|
5
|
+
yaps should help you quickly get set up with a typescript web library in less than 2min of setup.
|
|
6
|
+
|
|
7
|
+
a similar underlying structure is used in [react-scan](https://github.com/aidenybai/react-scan) and [bippy](https://github.com/aidenybai/bippy). it makes me feel super productive and it's not super boilerplate-y so i can can just focus on building stuff, and when it comes time to scale features it's easy to delete/add code.
|
|
8
|
+
|
|
9
|
+
this is mainly maintained for me and by me, feel free to remix/use it as you see fit.
|
|
10
|
+
|
|
11
|
+
## setup
|
|
12
|
+
|
|
13
|
+
```sh
|
|
14
|
+
git clone https://github.com/aidenybai/yaps.git
|
|
15
|
+
cd yaps
|
|
16
|
+
pnpm install
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
next, i recommend you global search `REPLACE_ME_PLEASE` and replace it with whatever you want. here are some files you should enter your project name in:
|
|
20
|
+
|
|
21
|
+
- `kitchen-sink/vite.config.mjs`
|
|
22
|
+
- `kitchen-sink/index.html`
|
|
23
|
+
- `kitchen-sink/LICENSE`
|
|
24
|
+
- `kitchen-sink/package.json`
|
|
25
|
+
- `kitchen-sink/tsup.config.ts`
|
|
26
|
+
|
|
27
|
+
## development
|
|
28
|
+
|
|
29
|
+
here are some neat commands you can run:
|
|
30
|
+
|
|
31
|
+
```sh
|
|
32
|
+
# dev
|
|
33
|
+
pnpm run dev
|
|
34
|
+
|
|
35
|
+
# build
|
|
36
|
+
pnpm run build
|
|
37
|
+
|
|
38
|
+
# lint
|
|
39
|
+
pnpm run lint
|
|
40
|
+
|
|
41
|
+
# format
|
|
42
|
+
pnpm run format
|
|
43
|
+
|
|
44
|
+
# lint publish config
|
|
45
|
+
pnpm run publint
|
|
46
|
+
|
|
47
|
+
# test
|
|
48
|
+
pnpm run test
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
## testing
|
|
52
|
+
|
|
53
|
+
for ad-hoc testing use the `kitchen-sink` directory:
|
|
54
|
+
|
|
55
|
+
```sh
|
|
56
|
+
cd kitchen-sink
|
|
57
|
+
pnpm run dev
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
for unit testing, edit `src/index.test.ts` and run:
|
|
61
|
+
|
|
62
|
+
```sh
|
|
63
|
+
pnpm run test
|
|
64
|
+
```
|
package/dist/index.cjs
ADDED
|
@@ -0,0 +1,180 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var bippy = require('bippy');
|
|
4
|
+
var source = require('bippy/dist/source');
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* @license MIT
|
|
8
|
+
*
|
|
9
|
+
* Copyright (c) 2025 Aiden Bai
|
|
10
|
+
*
|
|
11
|
+
* This source code is licensed under the MIT license found in the
|
|
12
|
+
* LICENSE file in the root directory of this source tree.
|
|
13
|
+
*/
|
|
14
|
+
|
|
15
|
+
var getReactData = async (element) => {
|
|
16
|
+
const fiber = bippy.getFiberFromHostInstance(element);
|
|
17
|
+
if (!fiber) return null;
|
|
18
|
+
const stackTrace = source.getFiberStackTrace(fiber);
|
|
19
|
+
const rawOwnerStack = await source.getOwnerStack(stackTrace);
|
|
20
|
+
const stack = rawOwnerStack.filter((item) => !item.source?.fileName.includes("node_modules")).map((item) => ({
|
|
21
|
+
componentName: item.name,
|
|
22
|
+
fileName: item.source?.fileName
|
|
23
|
+
}));
|
|
24
|
+
return {
|
|
25
|
+
fiber,
|
|
26
|
+
stack
|
|
27
|
+
};
|
|
28
|
+
};
|
|
29
|
+
var init = () => {
|
|
30
|
+
let metaKeyTimer = null;
|
|
31
|
+
let overlay = null;
|
|
32
|
+
let isActive = false;
|
|
33
|
+
let currentElement = null;
|
|
34
|
+
let animationFrame = null;
|
|
35
|
+
let currentX = 0;
|
|
36
|
+
let currentY = 0;
|
|
37
|
+
let currentWidth = 0;
|
|
38
|
+
let currentHeight = 0;
|
|
39
|
+
let targetX = 0;
|
|
40
|
+
let targetY = 0;
|
|
41
|
+
let targetWidth = 0;
|
|
42
|
+
let targetHeight = 0;
|
|
43
|
+
let targetBorderRadius = "";
|
|
44
|
+
const isInsideInputOrTextarea = () => {
|
|
45
|
+
const activeElement = document.activeElement;
|
|
46
|
+
return activeElement instanceof HTMLInputElement || activeElement instanceof HTMLTextAreaElement || activeElement?.tagName === "INPUT" || activeElement?.tagName === "TEXTAREA";
|
|
47
|
+
};
|
|
48
|
+
const createOverlay = () => {
|
|
49
|
+
const div = document.createElement("div");
|
|
50
|
+
div.style.position = "fixed";
|
|
51
|
+
div.style.border = "2px solid #3b82f6";
|
|
52
|
+
div.style.backgroundColor = "rgba(59, 130, 246, 0.1)";
|
|
53
|
+
div.style.pointerEvents = "none";
|
|
54
|
+
div.style.zIndex = "999999";
|
|
55
|
+
div.style.transition = "none";
|
|
56
|
+
document.body.appendChild(div);
|
|
57
|
+
return div;
|
|
58
|
+
};
|
|
59
|
+
const lerp = (start, end, factor) => {
|
|
60
|
+
return start + (end - start) * factor;
|
|
61
|
+
};
|
|
62
|
+
const updateOverlayPosition = () => {
|
|
63
|
+
if (!overlay || !isActive) return;
|
|
64
|
+
const factor = 0.2;
|
|
65
|
+
currentX = lerp(currentX, targetX, factor);
|
|
66
|
+
currentY = lerp(currentY, targetY, factor);
|
|
67
|
+
currentWidth = lerp(currentWidth, targetWidth, factor);
|
|
68
|
+
currentHeight = lerp(currentHeight, targetHeight, factor);
|
|
69
|
+
overlay.style.left = `${currentX}px`;
|
|
70
|
+
overlay.style.top = `${currentY}px`;
|
|
71
|
+
overlay.style.width = `${currentWidth}px`;
|
|
72
|
+
overlay.style.height = `${currentHeight}px`;
|
|
73
|
+
overlay.style.borderRadius = targetBorderRadius;
|
|
74
|
+
animationFrame = requestAnimationFrame(updateOverlayPosition);
|
|
75
|
+
};
|
|
76
|
+
const handleMouseMove = (e) => {
|
|
77
|
+
const element = document.elementFromPoint(e.clientX, e.clientY);
|
|
78
|
+
if (!element || element === overlay) return;
|
|
79
|
+
currentElement = element;
|
|
80
|
+
const rect = element.getBoundingClientRect();
|
|
81
|
+
const computedStyle = window.getComputedStyle(element);
|
|
82
|
+
targetX = rect.left;
|
|
83
|
+
targetY = rect.top;
|
|
84
|
+
targetWidth = rect.width;
|
|
85
|
+
targetHeight = rect.height;
|
|
86
|
+
targetBorderRadius = computedStyle.borderRadius;
|
|
87
|
+
};
|
|
88
|
+
const handleClick = (e) => {
|
|
89
|
+
if (!isActive) return;
|
|
90
|
+
e.preventDefault();
|
|
91
|
+
e.stopPropagation();
|
|
92
|
+
e.stopImmediatePropagation();
|
|
93
|
+
const elementToInspect = currentElement;
|
|
94
|
+
hideOverlay();
|
|
95
|
+
if (elementToInspect) {
|
|
96
|
+
void getReactData(elementToInspect).then((data) => {
|
|
97
|
+
const serializedStack = data?.stack.map((item) => `${item.componentName} (${item.fileName})`).join("\n");
|
|
98
|
+
if (serializedStack) {
|
|
99
|
+
void navigator.clipboard.writeText(serializedStack);
|
|
100
|
+
}
|
|
101
|
+
});
|
|
102
|
+
}
|
|
103
|
+
};
|
|
104
|
+
const handleMouseDown = (e) => {
|
|
105
|
+
if (!isActive) return;
|
|
106
|
+
e.preventDefault();
|
|
107
|
+
e.stopPropagation();
|
|
108
|
+
e.stopImmediatePropagation();
|
|
109
|
+
};
|
|
110
|
+
const showOverlay = () => {
|
|
111
|
+
if (!overlay) {
|
|
112
|
+
overlay = createOverlay();
|
|
113
|
+
}
|
|
114
|
+
isActive = true;
|
|
115
|
+
overlay.style.display = "block";
|
|
116
|
+
currentX = targetX;
|
|
117
|
+
currentY = targetY;
|
|
118
|
+
currentWidth = targetWidth;
|
|
119
|
+
currentHeight = targetHeight;
|
|
120
|
+
updateOverlayPosition();
|
|
121
|
+
};
|
|
122
|
+
const hideOverlay = () => {
|
|
123
|
+
isActive = false;
|
|
124
|
+
if (overlay) {
|
|
125
|
+
overlay.style.display = "none";
|
|
126
|
+
}
|
|
127
|
+
if (animationFrame) {
|
|
128
|
+
cancelAnimationFrame(animationFrame);
|
|
129
|
+
animationFrame = null;
|
|
130
|
+
}
|
|
131
|
+
currentElement = null;
|
|
132
|
+
};
|
|
133
|
+
const handleKeyDown = (e) => {
|
|
134
|
+
if (e.metaKey && !metaKeyTimer && !isActive) {
|
|
135
|
+
metaKeyTimer = setTimeout(() => {
|
|
136
|
+
console.log("Meta key held for 750ms");
|
|
137
|
+
if (!isInsideInputOrTextarea()) {
|
|
138
|
+
showOverlay();
|
|
139
|
+
}
|
|
140
|
+
metaKeyTimer = null;
|
|
141
|
+
}, 750);
|
|
142
|
+
}
|
|
143
|
+
};
|
|
144
|
+
const handleKeyUp = (e) => {
|
|
145
|
+
if (!e.metaKey) {
|
|
146
|
+
if (metaKeyTimer) {
|
|
147
|
+
clearTimeout(metaKeyTimer);
|
|
148
|
+
metaKeyTimer = null;
|
|
149
|
+
}
|
|
150
|
+
if (isActive) {
|
|
151
|
+
hideOverlay();
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
};
|
|
155
|
+
document.addEventListener("keydown", handleKeyDown);
|
|
156
|
+
document.addEventListener("keyup", handleKeyUp);
|
|
157
|
+
document.addEventListener("mousemove", handleMouseMove);
|
|
158
|
+
document.addEventListener("mousedown", handleMouseDown, true);
|
|
159
|
+
document.addEventListener("click", handleClick, true);
|
|
160
|
+
return () => {
|
|
161
|
+
if (metaKeyTimer) {
|
|
162
|
+
clearTimeout(metaKeyTimer);
|
|
163
|
+
}
|
|
164
|
+
if (animationFrame) {
|
|
165
|
+
cancelAnimationFrame(animationFrame);
|
|
166
|
+
}
|
|
167
|
+
if (overlay && overlay.parentNode) {
|
|
168
|
+
overlay.parentNode.removeChild(overlay);
|
|
169
|
+
}
|
|
170
|
+
document.removeEventListener("keydown", handleKeyDown);
|
|
171
|
+
document.removeEventListener("keyup", handleKeyUp);
|
|
172
|
+
document.removeEventListener("mousemove", handleMouseMove);
|
|
173
|
+
document.removeEventListener("mousedown", handleMouseDown, true);
|
|
174
|
+
document.removeEventListener("click", handleClick, true);
|
|
175
|
+
};
|
|
176
|
+
};
|
|
177
|
+
init();
|
|
178
|
+
|
|
179
|
+
exports.getReactData = getReactData;
|
|
180
|
+
exports.init = init;
|
package/dist/index.d.cts
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import * as bippy from 'bippy';
|
|
2
|
+
|
|
3
|
+
interface StackItem {
|
|
4
|
+
componentName: string;
|
|
5
|
+
fileName: string | undefined;
|
|
6
|
+
}
|
|
7
|
+
declare const getReactData: (element: Element) => Promise<{
|
|
8
|
+
fiber: bippy.Fiber;
|
|
9
|
+
stack: StackItem[];
|
|
10
|
+
} | null>;
|
|
11
|
+
declare const init: () => () => void;
|
|
12
|
+
|
|
13
|
+
export { type StackItem, getReactData, init };
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import * as bippy from 'bippy';
|
|
2
|
+
|
|
3
|
+
interface StackItem {
|
|
4
|
+
componentName: string;
|
|
5
|
+
fileName: string | undefined;
|
|
6
|
+
}
|
|
7
|
+
declare const getReactData: (element: Element) => Promise<{
|
|
8
|
+
fiber: bippy.Fiber;
|
|
9
|
+
stack: StackItem[];
|
|
10
|
+
} | null>;
|
|
11
|
+
declare const init: () => () => void;
|
|
12
|
+
|
|
13
|
+
export { type StackItem, getReactData, init };
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
var ReactGrab=(function(exports){'use strict';/**
|
|
2
|
+
* @license MIT
|
|
3
|
+
*
|
|
4
|
+
* Copyright (c) 2025 Aiden Bai
|
|
5
|
+
*
|
|
6
|
+
* This source code is licensed under the MIT license found in the
|
|
7
|
+
* LICENSE file in the root directory of this source tree.
|
|
8
|
+
*/
|
|
9
|
+
var me="0.3.28",W=`bippy-${me}`,fe=Object.defineProperty,De=Object.prototype.hasOwnProperty,G=()=>{},pe=n=>{try{Function.prototype.toString.call(n).indexOf("^_^")>-1&&setTimeout(()=>{throw new Error("React is running in production mode, but dead code elimination has not been applied. Read how to correctly configure React for production: https://reactjs.org/link/perf-use-production-build")});}catch{}},he=(n=j())=>"getFiberRoots"in n,ge=false,de,q=(n=j())=>ge?true:(typeof n.inject=="function"&&(de=n.inject.toString()),!!de?.includes("(injected)")),U=new Set,P=new Set,ve=n=>{let e=new Map,a=0,p={checkDCE:pe,supportsFiber:true,supportsFlight:true,hasUnsupportedRendererAttached:false,renderers:e,onCommitFiberRoot:G,onCommitFiberUnmount:G,onPostCommitFiberRoot:G,on:G,inject(C){let d=++a;return e.set(d,C),P.add(C),p._instrumentationIsActive||(p._instrumentationIsActive=true,U.forEach(s=>s())),d},_instrumentationSource:W,_instrumentationIsActive:false};try{fe(globalThis,"__REACT_DEVTOOLS_GLOBAL_HOOK__",{get(){return p},set(s){if(s&&typeof s=="object"){let o=p.renderers;p=s,o.size>0&&(o.forEach((i,u)=>{P.add(i),s.renderers.set(u,i);}),z(n));}},configurable:!0,enumerable:!0});let C=window.hasOwnProperty,d=!1;fe(window,"hasOwnProperty",{value:function(){try{if(!d&&arguments[0]==="__REACT_DEVTOOLS_GLOBAL_HOOK__")return globalThis.__REACT_DEVTOOLS_GLOBAL_HOOK__=void 0,d=!0,-0}catch{}return C.apply(this,arguments)},configurable:!0,writable:!0});}catch{z(n);}return p},z=n=>{try{let e=globalThis.__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!e)return;if(!e._instrumentationSource){if(e.checkDCE=pe,e.supportsFiber=!0,e.supportsFlight=!0,e.hasUnsupportedRendererAttached=!1,e._instrumentationSource=W,e._instrumentationIsActive=!1,e.on=G,e.renderers.size){e._instrumentationIsActive=!0,U.forEach(p=>p());return}let a=e.inject;q(e)&&!he()&&(ge=!0,e.inject({scheduleRefresh(){}})&&(e._instrumentationIsActive=!0)),e.inject=p=>{let C=a(p);return P.add(p),e._instrumentationIsActive=!0,U.forEach(d=>d()),C};}(e.renderers.size||e._instrumentationIsActive||q())&&n?.();}catch{}},_e=()=>De.call(globalThis,"__REACT_DEVTOOLS_GLOBAL_HOOK__"),j=n=>_e()?(z(n),globalThis.__REACT_DEVTOOLS_GLOBAL_HOOK__):ve(n),ye=()=>!!(typeof window<"u"&&(window.document?.createElement||window.navigator?.product==="ReactNative")),Ce=()=>{try{ye()&&j();}catch{}},Y=0,K=1;var Q=5;var X=11,J=13;var Z=15,ee=16;var te=19;var ne=26,re=27,oe=28,ie=30;var $=n=>{let e=n;return typeof e=="function"?e:typeof e=="object"&&e?$(e.type||e.render):null},B=n=>{let e=n;if(typeof e=="string")return e;if(typeof e!="function"&&!(typeof e=="object"&&e))return null;let a=e.displayName||e.name||null;if(a)return a;let p=$(e);return p&&(p.displayName||p.name)||null};var se=n=>{let e=j();for(let a of e.renderers.values())try{let p=a.findFiberByHostInstance?.(n);if(p)return p}catch{}if(typeof n=="object"&&n!=null){if("_reactRootContainer"in n)return n._reactRootContainer?._internalRoot?.current?.child;for(let a in n)if(a.startsWith("__reactContainer$")||a.startsWith("__reactInternalInstance$")||a.startsWith("__reactFiber"))return n[a]||null}return null};Ce();var We=Object.create,Se=Object.defineProperty,Ye=Object.getOwnPropertyDescriptor,be=Object.getOwnPropertyNames,Ke=Object.getPrototypeOf,Qe=Object.prototype.hasOwnProperty,N=(n,e)=>function(){return e||(0, n[be(n)[0]])((e={exports:{}}).exports,e),e.exports},Xe=(n,e,a,p)=>{if(e&&typeof e=="object"||typeof e=="function")for(var C=be(e),d=0,s=C.length,o;d<s;d++)o=C[d],!Qe.call(n,o)&&o!==a&&Se(n,o,{get:(i=>e[i]).bind(null,o),enumerable:!(p=Ye(e,o))||p.enumerable});return n},Je=(n,e,a)=>(a=n!=null?We(Ke(n)):{},Xe(Se(a,"default",{value:n,enumerable:true}),n)),Ee=/^\s*at .*(\S+:\d+|\(native\))/m,Ze=/^(eval@)?(\[native code\])?$/;function et(n,e){return n.match(Ee)?tt(n,e):nt(n,e)}function we(n){if(!n.includes(":"))return [n,undefined,undefined];let a=/(.+?)(?::(\d+))?(?::(\d+))?$/.exec(n.replace(/[()]/g,""));return [a[1],a[2]||undefined,a[3]||undefined]}function Te(n,e){return e&&e.slice!=null?Array.isArray(e.slice)?n.slice(e.slice[0],e.slice[1]):n.slice(0,e.slice):n}function tt(n,e){return Te(n.split(`
|
|
10
|
+
`).filter(p=>!!p.match(Ee)),e).map(p=>{p.includes("(eval ")&&(p=p.replace(/eval code/g,"eval").replace(/(\(eval at [^()]*)|(,.*$)/g,""));let C=p.replace(/^\s+/,"").replace(/\(eval code/g,"(").replace(/^.*?\s+/,""),d=C.match(/ (\(.+\)$)/);C=d?C.replace(d[0],""):C;let s=we(d?d[1]:C),o=d&&C||undefined,i=["eval","<anonymous>"].includes(s[0])?undefined:s[0];return {function:o,file:i,line:s[1]?+s[1]:undefined,col:s[2]?+s[2]:undefined,raw:p}})}function nt(n,e){return Te(n.split(`
|
|
11
|
+
`).filter(p=>!p.match(Ze)),e).map(p=>{if(p.includes(" > eval")&&(p=p.replace(/ line (\d+)(?: > eval line \d+)* > eval:\d+:\d+/g,":$1")),!p.includes("@")&&!p.includes(":"))return {function:p};{let C=/(([^\n\r"\u2028\u2029]*".[^\n\r"\u2028\u2029]*"[^\n\r@\u2028\u2029]*(?:@[^\n\r"\u2028\u2029]*"[^\n\r@\u2028\u2029]*)*(?:[\n\r\u2028\u2029][^@]*)?)?[^@]*)@/,d=p.match(C),s=d&&d[1]?d[1]:undefined,o=we(p.replace(C,""));return {function:s,file:o[0],line:o[1]?+o[1]:undefined,col:o[2]?+o[2]:undefined,raw:p}}})}var rt=N({"../../node_modules/.pnpm/source-map-js@1.2.1/node_modules/source-map-js/lib/base64.js"(n){var e="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".split("");n.encode=function(a){if(0<=a&&a<e.length)return e[a];throw new TypeError("Must be between 0 and 63: "+a)},n.decode=function(a){var p=65,C=90,d=97,s=122,o=48,i=57,u=43,y=47,g=26,h=52;return p<=a&&a<=C?a-p:d<=a&&a<=s?a-d+g:o<=a&&a<=i?a-o+h:a==u?62:a==y?63:-1};}}),Oe=N({"../../node_modules/.pnpm/source-map-js@1.2.1/node_modules/source-map-js/lib/base64-vlq.js"(n){var e=rt(),a=5,p=1<<a,C=p-1,d=p;function s(i){return i<0?(-i<<1)+1:(i<<1)+0}function o(i){var u=(i&1)===1,y=i>>1;return u?-y:y}n.encode=function(u){var y="",g,h=s(u);do g=h&C,h>>>=a,h>0&&(g|=d),y+=e.encode(g);while(h>0);return y},n.decode=function(u,y,g){var h=u.length,r=0,l=0,c,v;do{if(y>=h)throw new Error("Expected more digits in base 64 VLQ value.");if(v=e.decode(u.charCodeAt(y++)),v===-1)throw new Error("Invalid base64 digit: "+u.charAt(y-1));c=!!(v&d),v&=C,r=r+(v<<l),l+=a;}while(c);g.value=o(r),g.rest=y;};}}),H=N({"../../node_modules/.pnpm/source-map-js@1.2.1/node_modules/source-map-js/lib/util.js"(n){function e(f,t,S){if(t in f)return f[t];if(arguments.length===3)return S;throw new Error('"'+t+'" is a required argument.')}n.getArg=e;var a=/^(?:([\w+\-.]+):)?\/\/(?:(\w+:\w+)@)?([\w.-]*)(?::(\d+))?(.*)$/,p=/^data:.+\,.+$/;function C(f){var t=f.match(a);return t?{scheme:t[1],auth:t[2],host:t[3],port:t[4],path:t[5]}:null}n.urlParse=C;function d(f){var t="";return f.scheme&&(t+=f.scheme+":"),t+="//",f.auth&&(t+=f.auth+"@"),f.host&&(t+=f.host),f.port&&(t+=":"+f.port),f.path&&(t+=f.path),t}n.urlGenerate=d;var s=32;function o(f){var t=[];return function(S){for(var m=0;m<t.length;m++)if(t[m].input===S){var F=t[0];return t[0]=t[m],t[m]=F,t[0].result}var R=f(S);return t.unshift({input:S,result:R}),t.length>s&&t.pop(),R}}var i=o(function(t){var S=t,m=C(t);if(m){if(!m.path)return t;S=m.path;}for(var F=n.isAbsolute(S),R=[],A=0,L=0;;)if(A=L,L=S.indexOf("/",A),L===-1){R.push(S.slice(A));break}else for(R.push(S.slice(A,L));L<S.length&&S[L]==="/";)L++;for(var D,I=0,L=R.length-1;L>=0;L--)D=R[L],D==="."?R.splice(L,1):D===".."?I++:I>0&&(D===""?(R.splice(L+1,I),I=0):(R.splice(L,2),I--));return S=R.join("/"),S===""&&(S=F?"/":"."),m?(m.path=S,d(m)):S});n.normalize=i;function u(f,t){f===""&&(f="."),t===""&&(t=".");var S=C(t),m=C(f);if(m&&(f=m.path||"/"),S&&!S.scheme)return m&&(S.scheme=m.scheme),d(S);if(S||t.match(p))return t;if(m&&!m.host&&!m.path)return m.host=t,d(m);var F=t.charAt(0)==="/"?t:i(f.replace(/\/+$/,"")+"/"+t);return m?(m.path=F,d(m)):F}n.join=u,n.isAbsolute=function(f){return f.charAt(0)==="/"||a.test(f)};function y(f,t){f===""&&(f="."),f=f.replace(/\/$/,"");for(var S=0;t.indexOf(f+"/")!==0;){var m=f.lastIndexOf("/");if(m<0||(f=f.slice(0,m),f.match(/^([^\/]+:\/)?\/*$/)))return t;++S;}return Array(S+1).join("../")+t.substr(f.length+1)}n.relative=y;var g=function(){var f=Object.create(null);return !("__proto__"in f)}();function h(f){return f}function r(f){return c(f)?"$"+f:f}n.toSetString=g?h:r;function l(f){return c(f)?f.slice(1):f}n.fromSetString=g?h:l;function c(f){if(!f)return false;var t=f.length;if(t<9||f.charCodeAt(t-1)!==95||f.charCodeAt(t-2)!==95||f.charCodeAt(t-3)!==111||f.charCodeAt(t-4)!==116||f.charCodeAt(t-5)!==111||f.charCodeAt(t-6)!==114||f.charCodeAt(t-7)!==112||f.charCodeAt(t-8)!==95||f.charCodeAt(t-9)!==95)return false;for(var S=t-10;S>=0;S--)if(f.charCodeAt(S)!==36)return false;return true}function v(f,t,S){var m=w(f.source,t.source);return m!==0||(m=f.originalLine-t.originalLine,m!==0)||(m=f.originalColumn-t.originalColumn,m!==0||S)||(m=f.generatedColumn-t.generatedColumn,m!==0)||(m=f.generatedLine-t.generatedLine,m!==0)?m:w(f.name,t.name)}n.compareByOriginalPositions=v;function _(f,t,S){var m;return m=f.originalLine-t.originalLine,m!==0||(m=f.originalColumn-t.originalColumn,m!==0||S)||(m=f.generatedColumn-t.generatedColumn,m!==0)||(m=f.generatedLine-t.generatedLine,m!==0)?m:w(f.name,t.name)}n.compareByOriginalPositionsNoSource=_;function b(f,t,S){var m=f.generatedLine-t.generatedLine;return m!==0||(m=f.generatedColumn-t.generatedColumn,m!==0||S)||(m=w(f.source,t.source),m!==0)||(m=f.originalLine-t.originalLine,m!==0)||(m=f.originalColumn-t.originalColumn,m!==0)?m:w(f.name,t.name)}n.compareByGeneratedPositionsDeflated=b;function E(f,t,S){var m=f.generatedColumn-t.generatedColumn;return m!==0||S||(m=w(f.source,t.source),m!==0)||(m=f.originalLine-t.originalLine,m!==0)||(m=f.originalColumn-t.originalColumn,m!==0)?m:w(f.name,t.name)}n.compareByGeneratedPositionsDeflatedNoLine=E;function w(f,t){return f===t?0:f===null?1:t===null?-1:f>t?1:-1}function T(f,t){var S=f.generatedLine-t.generatedLine;return S!==0||(S=f.generatedColumn-t.generatedColumn,S!==0)||(S=w(f.source,t.source),S!==0)||(S=f.originalLine-t.originalLine,S!==0)||(S=f.originalColumn-t.originalColumn,S!==0)?S:w(f.name,t.name)}n.compareByGeneratedPositionsInflated=T;function O(f){return JSON.parse(f.replace(/^\)]}'[^\n]*\n/,""))}n.parseSourceMapInput=O;function M(f,t,S){if(t=t||"",f&&(f[f.length-1]!=="/"&&t[0]!=="/"&&(f+="/"),t=f+t),S){var m=C(S);if(!m)throw new Error("sourceMapURL could not be parsed");if(m.path){var F=m.path.lastIndexOf("/");F>=0&&(m.path=m.path.substring(0,F+1));}t=u(d(m),t);}return i(t)}n.computeSourceURL=M;}}),Re=N({"../../node_modules/.pnpm/source-map-js@1.2.1/node_modules/source-map-js/lib/array-set.js"(n){var e=H(),a=Object.prototype.hasOwnProperty,p=typeof Map<"u";function C(){this._array=[],this._set=p?new Map:Object.create(null);}C.fromArray=function(s,o){for(var i=new C,u=0,y=s.length;u<y;u++)i.add(s[u],o);return i},C.prototype.size=function(){return p?this._set.size:Object.getOwnPropertyNames(this._set).length},C.prototype.add=function(s,o){var i=p?s:e.toSetString(s),u=p?this.has(s):a.call(this._set,i),y=this._array.length;(!u||o)&&this._array.push(s),u||(p?this._set.set(s,y):this._set[i]=y);},C.prototype.has=function(s){if(p)return this._set.has(s);var o=e.toSetString(s);return a.call(this._set,o)},C.prototype.indexOf=function(s){if(p){var o=this._set.get(s);if(o>=0)return o}else {var i=e.toSetString(s);if(a.call(this._set,i))return this._set[i]}throw new Error('"'+s+'" is not in the set.')},C.prototype.at=function(s){if(s>=0&&s<this._array.length)return this._array[s];throw new Error("No element indexed by "+s)},C.prototype.toArray=function(){return this._array.slice()},n.ArraySet=C;}}),ot=N({"../../node_modules/.pnpm/source-map-js@1.2.1/node_modules/source-map-js/lib/mapping-list.js"(n){var e=H();function a(C,d){var s=C.generatedLine,o=d.generatedLine,i=C.generatedColumn,u=d.generatedColumn;return o>s||o==s&&u>=i||e.compareByGeneratedPositionsInflated(C,d)<=0}function p(){this._array=[],this._sorted=true,this._last={generatedLine:-1,generatedColumn:0};}p.prototype.unsortedForEach=function(d,s){this._array.forEach(d,s);},p.prototype.add=function(d){a(this._last,d)?(this._last=d,this._array.push(d)):(this._sorted=false,this._array.push(d));},p.prototype.toArray=function(){return this._sorted||(this._array.sort(e.compareByGeneratedPositionsInflated),this._sorted=true),this._array},n.MappingList=p;}}),Le=N({"../../node_modules/.pnpm/source-map-js@1.2.1/node_modules/source-map-js/lib/source-map-generator.js"(n){var e=Oe(),a=H(),p=Re().ArraySet,C=ot().MappingList;function d(s){s||(s={}),this._file=a.getArg(s,"file",null),this._sourceRoot=a.getArg(s,"sourceRoot",null),this._skipValidation=a.getArg(s,"skipValidation",false),this._ignoreInvalidMapping=a.getArg(s,"ignoreInvalidMapping",false),this._sources=new p,this._names=new p,this._mappings=new C,this._sourcesContents=null;}d.prototype._version=3,d.fromSourceMap=function(o,i){var u=o.sourceRoot,y=new d(Object.assign(i||{},{file:o.file,sourceRoot:u}));return o.eachMapping(function(g){var h={generated:{line:g.generatedLine,column:g.generatedColumn}};g.source!=null&&(h.source=g.source,u!=null&&(h.source=a.relative(u,h.source)),h.original={line:g.originalLine,column:g.originalColumn},g.name!=null&&(h.name=g.name)),y.addMapping(h);}),o.sources.forEach(function(g){var h=g;u!==null&&(h=a.relative(u,g)),y._sources.has(h)||y._sources.add(h);var r=o.sourceContentFor(g);r!=null&&y.setSourceContent(g,r);}),y},d.prototype.addMapping=function(o){var i=a.getArg(o,"generated"),u=a.getArg(o,"original",null),y=a.getArg(o,"source",null),g=a.getArg(o,"name",null);!this._skipValidation&&this._validateMapping(i,u,y,g)===false||(y!=null&&(y=String(y),this._sources.has(y)||this._sources.add(y)),g!=null&&(g=String(g),this._names.has(g)||this._names.add(g)),this._mappings.add({generatedLine:i.line,generatedColumn:i.column,originalLine:u!=null&&u.line,originalColumn:u!=null&&u.column,source:y,name:g}));},d.prototype.setSourceContent=function(o,i){var u=o;this._sourceRoot!=null&&(u=a.relative(this._sourceRoot,u)),i!=null?(this._sourcesContents||(this._sourcesContents=Object.create(null)),this._sourcesContents[a.toSetString(u)]=i):this._sourcesContents&&(delete this._sourcesContents[a.toSetString(u)],Object.keys(this._sourcesContents).length===0&&(this._sourcesContents=null));},d.prototype.applySourceMap=function(o,i,u){var y=i;if(i==null){if(o.file==null)throw new Error(`SourceMapGenerator.prototype.applySourceMap requires either an explicit source file, or the source map's "file" property. Both were omitted.`);y=o.file;}var g=this._sourceRoot;g!=null&&(y=a.relative(g,y));var h=new p,r=new p;this._mappings.unsortedForEach(function(l){if(l.source===y&&l.originalLine!=null){var c=o.originalPositionFor({line:l.originalLine,column:l.originalColumn});c.source!=null&&(l.source=c.source,u!=null&&(l.source=a.join(u,l.source)),g!=null&&(l.source=a.relative(g,l.source)),l.originalLine=c.line,l.originalColumn=c.column,c.name!=null&&(l.name=c.name));}var v=l.source;v!=null&&!h.has(v)&&h.add(v);var _=l.name;_!=null&&!r.has(_)&&r.add(_);},this),this._sources=h,this._names=r,o.sources.forEach(function(l){var c=o.sourceContentFor(l);c!=null&&(u!=null&&(l=a.join(u,l)),g!=null&&(l=a.relative(g,l)),this.setSourceContent(l,c));},this);},d.prototype._validateMapping=function(o,i,u,y){if(i&&typeof i.line!="number"&&typeof i.column!="number"){var g="original.line and original.column are not numbers -- you probably meant to omit the original mapping entirely and only map the generated position. If so, pass null for the original mapping instead of an object with empty or null values.";if(this._ignoreInvalidMapping)return typeof console<"u"&&console.warn&&console.warn(g),false;throw new Error(g)}if(!(o&&"line"in o&&"column"in o&&o.line>0&&o.column>=0&&!i&&!u&&!y)){if(o&&"line"in o&&"column"in o&&i&&"line"in i&&"column"in i&&o.line>0&&o.column>=0&&i.line>0&&i.column>=0&&u)return;var g="Invalid mapping: "+JSON.stringify({generated:o,source:u,original:i,name:y});if(this._ignoreInvalidMapping)return typeof console<"u"&&console.warn&&console.warn(g),false;throw new Error(g)}},d.prototype._serializeMappings=function(){for(var o=0,i=1,u=0,y=0,g=0,h=0,r="",l,c,v,_,b=this._mappings.toArray(),E=0,w=b.length;E<w;E++){if(c=b[E],l="",c.generatedLine!==i)for(o=0;c.generatedLine!==i;)l+=";",i++;else if(E>0){if(!a.compareByGeneratedPositionsInflated(c,b[E-1]))continue;l+=",";}l+=e.encode(c.generatedColumn-o),o=c.generatedColumn,c.source!=null&&(_=this._sources.indexOf(c.source),l+=e.encode(_-h),h=_,l+=e.encode(c.originalLine-1-y),y=c.originalLine-1,l+=e.encode(c.originalColumn-u),u=c.originalColumn,c.name!=null&&(v=this._names.indexOf(c.name),l+=e.encode(v-g),g=v)),r+=l;}return r},d.prototype._generateSourcesContent=function(o,i){return o.map(function(u){if(!this._sourcesContents)return null;i!=null&&(u=a.relative(i,u));var y=a.toSetString(u);return Object.prototype.hasOwnProperty.call(this._sourcesContents,y)?this._sourcesContents[y]:null},this)},d.prototype.toJSON=function(){var o={version:this._version,sources:this._sources.toArray(),names:this._names.toArray(),mappings:this._serializeMappings()};return this._file!=null&&(o.file=this._file),this._sourceRoot!=null&&(o.sourceRoot=this._sourceRoot),this._sourcesContents&&(o.sourcesContent=this._generateSourcesContent(o.sources,o.sourceRoot)),o},d.prototype.toString=function(){return JSON.stringify(this.toJSON())},n.SourceMapGenerator=d;}}),it=N({"../../node_modules/.pnpm/source-map-js@1.2.1/node_modules/source-map-js/lib/binary-search.js"(n){n.GREATEST_LOWER_BOUND=1,n.LEAST_UPPER_BOUND=2;function e(a,p,C,d,s,o){var i=Math.floor((p-a)/2)+a,u=s(C,d[i],true);return u===0?i:u>0?p-i>1?e(i,p,C,d,s,o):o==n.LEAST_UPPER_BOUND?p<d.length?p:-1:i:i-a>1?e(a,i,C,d,s,o):o==n.LEAST_UPPER_BOUND?i:a<0?-1:a}n.search=function(p,C,d,s){if(C.length===0)return -1;var o=e(-1,C.length,p,C,d,s||n.GREATEST_LOWER_BOUND);if(o<0)return -1;for(;o-1>=0&&d(C[o],C[o-1],true)===0;)--o;return o};}}),st=N({"../../node_modules/.pnpm/source-map-js@1.2.1/node_modules/source-map-js/lib/quick-sort.js"(n){function e(C){function d(i,u,y){var g=i[u];i[u]=i[y],i[y]=g;}function s(i,u){return Math.round(i+Math.random()*(u-i))}function o(i,u,y,g){if(y<g){var h=s(y,g),r=y-1;d(i,h,g);for(var l=i[g],c=y;c<g;c++)u(i[c],l,false)<=0&&(r+=1,d(i,r,c));d(i,r+1,c);var v=r+1;o(i,u,y,v-1),o(i,u,v+1,g);}}return o}function a(C){let d=e.toString();return new Function(`return ${d}`)()(C)}let p=new WeakMap;n.quickSort=function(C,d,s=0){let o=p.get(d);o===undefined&&(o=a(d),p.set(d,o)),o(C,d,s,C.length-1);};}}),at=N({"../../node_modules/.pnpm/source-map-js@1.2.1/node_modules/source-map-js/lib/source-map-consumer.js"(n){var e=H(),a=it(),p=Re().ArraySet,C=Oe(),d=st().quickSort;function s(h,r){var l=h;return typeof h=="string"&&(l=e.parseSourceMapInput(h)),l.sections!=null?new g(l,r):new o(l,r)}s.fromSourceMap=function(h,r){return o.fromSourceMap(h,r)},s.prototype._version=3,s.prototype.__generatedMappings=null,Object.defineProperty(s.prototype,"_generatedMappings",{configurable:true,enumerable:true,get:function(){return this.__generatedMappings||this._parseMappings(this._mappings,this.sourceRoot),this.__generatedMappings}}),s.prototype.__originalMappings=null,Object.defineProperty(s.prototype,"_originalMappings",{configurable:true,enumerable:true,get:function(){return this.__originalMappings||this._parseMappings(this._mappings,this.sourceRoot),this.__originalMappings}}),s.prototype._charIsMappingSeparator=function(r,l){var c=r.charAt(l);return c===";"||c===","},s.prototype._parseMappings=function(r,l){throw new Error("Subclasses must implement _parseMappings")},s.GENERATED_ORDER=1,s.ORIGINAL_ORDER=2,s.GREATEST_LOWER_BOUND=1,s.LEAST_UPPER_BOUND=2,s.prototype.eachMapping=function(r,l,c){var v=l||null,_=c||s.GENERATED_ORDER,b;switch(_){case s.GENERATED_ORDER:b=this._generatedMappings;break;case s.ORIGINAL_ORDER:b=this._originalMappings;break;default:throw new Error("Unknown order of iteration.")}for(var E=this.sourceRoot,w=r.bind(v),T=this._names,O=this._sources,M=this._sourceMapURL,f=0,t=b.length;f<t;f++){var S=b[f],m=S.source===null?null:O.at(S.source);m!==null&&(m=e.computeSourceURL(E,m,M)),w({source:m,generatedLine:S.generatedLine,generatedColumn:S.generatedColumn,originalLine:S.originalLine,originalColumn:S.originalColumn,name:S.name===null?null:T.at(S.name)});}},s.prototype.allGeneratedPositionsFor=function(r){var l=e.getArg(r,"line"),c={source:e.getArg(r,"source"),originalLine:l,originalColumn:e.getArg(r,"column",0)};if(c.source=this._findSourceIndex(c.source),c.source<0)return [];var v=[],_=this._findMapping(c,this._originalMappings,"originalLine","originalColumn",e.compareByOriginalPositions,a.LEAST_UPPER_BOUND);if(_>=0){var b=this._originalMappings[_];if(r.column===undefined)for(var E=b.originalLine;b&&b.originalLine===E;)v.push({line:e.getArg(b,"generatedLine",null),column:e.getArg(b,"generatedColumn",null),lastColumn:e.getArg(b,"lastGeneratedColumn",null)}),b=this._originalMappings[++_];else for(var w=b.originalColumn;b&&b.originalLine===l&&b.originalColumn==w;)v.push({line:e.getArg(b,"generatedLine",null),column:e.getArg(b,"generatedColumn",null),lastColumn:e.getArg(b,"lastGeneratedColumn",null)}),b=this._originalMappings[++_];}return v},n.SourceMapConsumer=s;function o(h,r){var l=h;typeof h=="string"&&(l=e.parseSourceMapInput(h));var c=e.getArg(l,"version"),v=e.getArg(l,"sources"),_=e.getArg(l,"names",[]),b=e.getArg(l,"sourceRoot",null),E=e.getArg(l,"sourcesContent",null),w=e.getArg(l,"mappings"),T=e.getArg(l,"file",null);if(c!=this._version)throw new Error("Unsupported version: "+c);b&&(b=e.normalize(b)),v=v.map(String).map(e.normalize).map(function(O){return b&&e.isAbsolute(b)&&e.isAbsolute(O)?e.relative(b,O):O}),this._names=p.fromArray(_.map(String),true),this._sources=p.fromArray(v,true),this._absoluteSources=this._sources.toArray().map(function(O){return e.computeSourceURL(b,O,r)}),this.sourceRoot=b,this.sourcesContent=E,this._mappings=w,this._sourceMapURL=r,this.file=T;}o.prototype=Object.create(s.prototype),o.prototype.consumer=s,o.prototype._findSourceIndex=function(h){var r=h;if(this.sourceRoot!=null&&(r=e.relative(this.sourceRoot,r)),this._sources.has(r))return this._sources.indexOf(r);var l;for(l=0;l<this._absoluteSources.length;++l)if(this._absoluteSources[l]==h)return l;return -1},o.fromSourceMap=function(r,l){var c=Object.create(o.prototype),v=c._names=p.fromArray(r._names.toArray(),true),_=c._sources=p.fromArray(r._sources.toArray(),true);c.sourceRoot=r._sourceRoot,c.sourcesContent=r._generateSourcesContent(c._sources.toArray(),c.sourceRoot),c.file=r._file,c._sourceMapURL=l,c._absoluteSources=c._sources.toArray().map(function(t){return e.computeSourceURL(c.sourceRoot,t,l)});for(var b=r._mappings.toArray().slice(),E=c.__generatedMappings=[],w=c.__originalMappings=[],T=0,O=b.length;T<O;T++){var M=b[T],f=new i;f.generatedLine=M.generatedLine,f.generatedColumn=M.generatedColumn,M.source&&(f.source=_.indexOf(M.source),f.originalLine=M.originalLine,f.originalColumn=M.originalColumn,M.name&&(f.name=v.indexOf(M.name)),w.push(f)),E.push(f);}return d(c.__originalMappings,e.compareByOriginalPositions),c},o.prototype._version=3,Object.defineProperty(o.prototype,"sources",{get:function(){return this._absoluteSources.slice()}});function i(){this.generatedLine=0,this.generatedColumn=0,this.source=null,this.originalLine=null,this.originalColumn=null,this.name=null;}let u=e.compareByGeneratedPositionsDeflatedNoLine;function y(h,r){let l=h.length,c=h.length-r;if(!(c<=1))if(c==2){let v=h[r],_=h[r+1];u(v,_)>0&&(h[r]=_,h[r+1]=v);}else if(c<20)for(let v=r;v<l;v++)for(let _=v;_>r;_--){let b=h[_-1],E=h[_];if(u(b,E)<=0)break;h[_-1]=E,h[_]=b;}else d(h,u,r);}o.prototype._parseMappings=function(r,l){var c=1,v=0,_=0,b=0,E=0,w=0,T=r.length,O=0,f={},t=[],S=[],m,R,A,L;let D=0;for(;O<T;)if(r.charAt(O)===";")c++,O++,v=0,y(S,D),D=S.length;else if(r.charAt(O)===",")O++;else {for(m=new i,m.generatedLine=c,A=O;A<T&&!this._charIsMappingSeparator(r,A);A++);for(r.slice(O,A),R=[];O<A;)C.decode(r,O,f),L=f.value,O=f.rest,R.push(L);if(R.length===2)throw new Error("Found a source, but no line and column");if(R.length===3)throw new Error("Found a source and line, but no column");if(m.generatedColumn=v+R[0],v=m.generatedColumn,R.length>1&&(m.source=E+R[1],E+=R[1],m.originalLine=_+R[2],_=m.originalLine,m.originalLine+=1,m.originalColumn=b+R[3],b=m.originalColumn,R.length>4&&(m.name=w+R[4],w+=R[4])),S.push(m),typeof m.originalLine=="number"){let x=m.source;for(;t.length<=x;)t.push(null);t[x]===null&&(t[x]=[]),t[x].push(m);}}y(S,D),this.__generatedMappings=S;for(var I=0;I<t.length;I++)t[I]!=null&&d(t[I],e.compareByOriginalPositionsNoSource);this.__originalMappings=[].concat(...t);},o.prototype._findMapping=function(r,l,c,v,_,b){if(r[c]<=0)throw new TypeError("Line must be greater than or equal to 1, got "+r[c]);if(r[v]<0)throw new TypeError("Column must be greater than or equal to 0, got "+r[v]);return a.search(r,l,_,b)},o.prototype.computeColumnSpans=function(){for(var r=0;r<this._generatedMappings.length;++r){var l=this._generatedMappings[r];if(r+1<this._generatedMappings.length){var c=this._generatedMappings[r+1];if(l.generatedLine===c.generatedLine){l.lastGeneratedColumn=c.generatedColumn-1;continue}}l.lastGeneratedColumn=1/0;}},o.prototype.originalPositionFor=function(r){var l={generatedLine:e.getArg(r,"line"),generatedColumn:e.getArg(r,"column")},c=this._findMapping(l,this._generatedMappings,"generatedLine","generatedColumn",e.compareByGeneratedPositionsDeflated,e.getArg(r,"bias",s.GREATEST_LOWER_BOUND));if(c>=0){var v=this._generatedMappings[c];if(v.generatedLine===l.generatedLine){var _=e.getArg(v,"source",null);_!==null&&(_=this._sources.at(_),_=e.computeSourceURL(this.sourceRoot,_,this._sourceMapURL));var b=e.getArg(v,"name",null);return b!==null&&(b=this._names.at(b)),{source:_,line:e.getArg(v,"originalLine",null),column:e.getArg(v,"originalColumn",null),name:b}}}return {source:null,line:null,column:null,name:null}},o.prototype.hasContentsOfAllSources=function(){return this.sourcesContent?this.sourcesContent.length>=this._sources.size()&&!this.sourcesContent.some(function(r){return r==null}):false},o.prototype.sourceContentFor=function(r,l){if(!this.sourcesContent)return null;var c=this._findSourceIndex(r);if(c>=0)return this.sourcesContent[c];var v=r;this.sourceRoot!=null&&(v=e.relative(this.sourceRoot,v));var _;if(this.sourceRoot!=null&&(_=e.urlParse(this.sourceRoot))){var b=v.replace(/^file:\/\//,"");if(_.scheme=="file"&&this._sources.has(b))return this.sourcesContent[this._sources.indexOf(b)];if((!_.path||_.path=="/")&&this._sources.has("/"+v))return this.sourcesContent[this._sources.indexOf("/"+v)]}if(l)return null;throw new Error('"'+v+'" is not in the SourceMap.')},o.prototype.generatedPositionFor=function(r){var l=e.getArg(r,"source");if(l=this._findSourceIndex(l),l<0)return {line:null,column:null,lastColumn:null};var c={source:l,originalLine:e.getArg(r,"line"),originalColumn:e.getArg(r,"column")},v=this._findMapping(c,this._originalMappings,"originalLine","originalColumn",e.compareByOriginalPositions,e.getArg(r,"bias",s.GREATEST_LOWER_BOUND));if(v>=0){var _=this._originalMappings[v];if(_.source===c.source)return {line:e.getArg(_,"generatedLine",null),column:e.getArg(_,"generatedColumn",null),lastColumn:e.getArg(_,"lastGeneratedColumn",null)}}return {line:null,column:null,lastColumn:null}},n.BasicSourceMapConsumer=o;function g(h,r){var l=h;typeof h=="string"&&(l=e.parseSourceMapInput(h));var c=e.getArg(l,"version"),v=e.getArg(l,"sections");if(c!=this._version)throw new Error("Unsupported version: "+c);this._sources=new p,this._names=new p;var _={line:-1,column:0};this._sections=v.map(function(b){if(b.url)throw new Error("Support for url field in sections not implemented.");var E=e.getArg(b,"offset"),w=e.getArg(E,"line"),T=e.getArg(E,"column");if(w<_.line||w===_.line&&T<_.column)throw new Error("Section offsets must be ordered and non-overlapping.");return _=E,{generatedOffset:{generatedLine:w+1,generatedColumn:T+1},consumer:new s(e.getArg(b,"map"),r)}});}g.prototype=Object.create(s.prototype),g.prototype.constructor=s,g.prototype._version=3,Object.defineProperty(g.prototype,"sources",{get:function(){for(var h=[],r=0;r<this._sections.length;r++)for(var l=0;l<this._sections[r].consumer.sources.length;l++)h.push(this._sections[r].consumer.sources[l]);return h}}),g.prototype.originalPositionFor=function(r){var l={generatedLine:e.getArg(r,"line"),generatedColumn:e.getArg(r,"column")},c=a.search(l,this._sections,function(_,b){var E=_.generatedLine-b.generatedOffset.generatedLine;return E||_.generatedColumn-b.generatedOffset.generatedColumn}),v=this._sections[c];return v?v.consumer.originalPositionFor({line:l.generatedLine-(v.generatedOffset.generatedLine-1),column:l.generatedColumn-(v.generatedOffset.generatedLine===l.generatedLine?v.generatedOffset.generatedColumn-1:0),bias:r.bias}):{source:null,line:null,column:null,name:null}},g.prototype.hasContentsOfAllSources=function(){return this._sections.every(function(r){return r.consumer.hasContentsOfAllSources()})},g.prototype.sourceContentFor=function(r,l){for(var c=0;c<this._sections.length;c++){var v=this._sections[c],_=v.consumer.sourceContentFor(r,true);if(_||_==="")return _}if(l)return null;throw new Error('"'+r+'" is not in the SourceMap.')},g.prototype.generatedPositionFor=function(r){for(var l=0;l<this._sections.length;l++){var c=this._sections[l];if(c.consumer._findSourceIndex(e.getArg(r,"source"))!==-1){var v=c.consumer.generatedPositionFor(r);if(v){var _={line:v.line+(c.generatedOffset.generatedLine-1),column:v.column+(c.generatedOffset.generatedLine===v.line?c.generatedOffset.generatedColumn-1:0)};return _}}}return {line:null,column:null}},g.prototype._parseMappings=function(r,l){this.__generatedMappings=[],this.__originalMappings=[];for(var c=0;c<this._sections.length;c++)for(var v=this._sections[c],_=v.consumer._generatedMappings,b=0;b<_.length;b++){var E=_[b],w=v.consumer._sources.at(E.source);w!==null&&(w=e.computeSourceURL(v.consumer.sourceRoot,w,this._sourceMapURL)),this._sources.add(w),w=this._sources.indexOf(w);var T=null;E.name&&(T=v.consumer._names.at(E.name),this._names.add(T),T=this._names.indexOf(T));var O={source:w,generatedLine:E.generatedLine+(v.generatedOffset.generatedLine-1),generatedColumn:E.generatedColumn+(v.generatedOffset.generatedLine===E.generatedLine?v.generatedOffset.generatedColumn-1:0),originalLine:E.originalLine,originalColumn:E.originalColumn,name:T};this.__generatedMappings.push(O),typeof O.originalLine=="number"&&this.__originalMappings.push(O);}d(this.__generatedMappings,e.compareByGeneratedPositionsDeflated),d(this.__originalMappings,e.compareByOriginalPositions);},n.IndexedSourceMapConsumer=g;}}),lt=N({"../../node_modules/.pnpm/source-map-js@1.2.1/node_modules/source-map-js/lib/source-node.js"(n){var e=Le().SourceMapGenerator,a=H(),p=/(\r?\n)/,C=10,d="$$$isSourceNode$$$";function s(o,i,u,y,g){this.children=[],this.sourceContents={},this.line=o??null,this.column=i??null,this.source=u??null,this.name=g??null,this[d]=true,y!=null&&this.add(y);}s.fromStringWithSourceMap=function(i,u,y){var g=new s,h=i.split(p),r=0,l=function(){var E=T(),w=T()||"";return E+w;function T(){return r<h.length?h[r++]:undefined}},c=1,v=0,_=null;return u.eachMapping(function(E){if(_!==null)if(c<E.generatedLine)b(_,l()),c++,v=0;else {var w=h[r]||"",T=w.substr(0,E.generatedColumn-v);h[r]=w.substr(E.generatedColumn-v),v=E.generatedColumn,b(_,T),_=E;return}for(;c<E.generatedLine;)g.add(l()),c++;if(v<E.generatedColumn){var w=h[r]||"";g.add(w.substr(0,E.generatedColumn)),h[r]=w.substr(E.generatedColumn),v=E.generatedColumn;}_=E;},this),r<h.length&&(_&&b(_,l()),g.add(h.splice(r).join(""))),u.sources.forEach(function(E){var w=u.sourceContentFor(E);w!=null&&(y!=null&&(E=a.join(y,E)),g.setSourceContent(E,w));}),g;function b(E,w){if(E===null||E.source===undefined)g.add(w);else {var T=y?a.join(y,E.source):E.source;g.add(new s(E.originalLine,E.originalColumn,T,w,E.name));}}},s.prototype.add=function(i){if(Array.isArray(i))i.forEach(function(u){this.add(u);},this);else if(i[d]||typeof i=="string")i&&this.children.push(i);else throw new TypeError("Expected a SourceNode, string, or an array of SourceNodes and strings. Got "+i);return this},s.prototype.prepend=function(i){if(Array.isArray(i))for(var u=i.length-1;u>=0;u--)this.prepend(i[u]);else if(i[d]||typeof i=="string")this.children.unshift(i);else throw new TypeError("Expected a SourceNode, string, or an array of SourceNodes and strings. Got "+i);return this},s.prototype.walk=function(i){for(var u,y=0,g=this.children.length;y<g;y++)u=this.children[y],u[d]?u.walk(i):u!==""&&i(u,{source:this.source,line:this.line,column:this.column,name:this.name});},s.prototype.join=function(i){var u,y,g=this.children.length;if(g>0){for(u=[],y=0;y<g-1;y++)u.push(this.children[y]),u.push(i);u.push(this.children[y]),this.children=u;}return this},s.prototype.replaceRight=function(i,u){var y=this.children[this.children.length-1];return y[d]?y.replaceRight(i,u):typeof y=="string"?this.children[this.children.length-1]=y.replace(i,u):this.children.push("".replace(i,u)),this},s.prototype.setSourceContent=function(i,u){this.sourceContents[a.toSetString(i)]=u;},s.prototype.walkSourceContents=function(i){for(var u=0,y=this.children.length;u<y;u++)this.children[u][d]&&this.children[u].walkSourceContents(i);for(var g=Object.keys(this.sourceContents),u=0,y=g.length;u<y;u++)i(a.fromSetString(g[u]),this.sourceContents[g[u]]);},s.prototype.toString=function(){var i="";return this.walk(function(u){i+=u;}),i},s.prototype.toStringWithSourceMap=function(i){var u={code:"",line:1,column:0},y=new e(i),g=false,h=null,r=null,l=null,c=null;return this.walk(function(v,_){u.code+=v,_.source!==null&&_.line!==null&&_.column!==null?((h!==_.source||r!==_.line||l!==_.column||c!==_.name)&&y.addMapping({source:_.source,original:{line:_.line,column:_.column},generated:{line:u.line,column:u.column},name:_.name}),h=_.source,r=_.line,l=_.column,c=_.name,g=true):g&&(y.addMapping({generated:{line:u.line,column:u.column}}),h=null,g=false);for(var b=0,E=v.length;b<E;b++)v.charCodeAt(b)===C?(u.line++,u.column=0,b+1===E?(h=null,g=false):g&&y.addMapping({source:_.source,original:{line:_.line,column:_.column},generated:{line:u.line,column:u.column},name:_.name})):u.column++;}),this.walkSourceContents(function(v,_){y.setSourceContent(v,_);}),{code:u.code,map:y}},n.SourceNode=s;}}),ut=N({"../../node_modules/.pnpm/source-map-js@1.2.1/node_modules/source-map-js/source-map.js"(n){n.SourceMapGenerator=Le().SourceMapGenerator,n.SourceMapConsumer=at().SourceMapConsumer,n.SourceNode=lt().SourceNode;}}),ct=Je(ut()),ae=false,k=n=>`
|
|
12
|
+
in ${n}`,ft=/^data:application\/json[^,]+base64,/,dt=/(?:\/\/[@#][ \t]+sourceMappingURL=([^\s'"]+?)[ \t]*$)|(?:\/\*[@#][ \t]+sourceMappingURL=([^*]+?)[ \t]*(?:\*\/)[ \t]*$)/,Me=async(n,e)=>{let a=e.split(`
|
|
13
|
+
`),p;for(let s=a.length-1;s>=0&&!p;s--){let o=a[s].match(dt);o&&(p=o[1]);}if(!p)return null;if(!(ft.test(p)||p.startsWith("/"))){let s=n.split("/");s[s.length-1]=p,p=s.join("/");}let d=await(await fetch(p)).json();return new ct.SourceMapConsumer(d)},Fe=async(n,e)=>{let a=et(n);if(!a.length)return [];let p=a.slice(0,e);return (await Promise.all(p.map(async({file:d,line:s,col:o=0})=>{if(!d||!s)return null;try{let i=await fetch(d);if(i.ok){let u=await i.text(),y=await Me(d,u);if(y){let g=y.originalPositionFor({line:s,column:o});return {fileName:(y.file||g.source).replace(/^file:\/\//,""),lineNumber:g.line,columnNumber:g.column}}}return {fileName:d.replace(/^file:\/\//,""),lineNumber:s,columnNumber:o}}catch{return {fileName:d.replace(/^file:\/\//,""),lineNumber:s,columnNumber:o}}}))).filter(d=>d!==null)},V=(n,e)=>{if(!n||ae)return "";let a=Error.prepareStackTrace;Error.prepareStackTrace=undefined,ae=true;let p=Ae();le(null);let C=console.error,d=console.warn;console.error=()=>{},console.warn=()=>{};try{let i={DetermineComponentFrameRoot(){let h;try{if(e){let r=function(){throw Error()};if(Object.defineProperty(r.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(r,[]);}catch(l){h=l;}Reflect.construct(n,[],r);}else {try{r.call();}catch(l){h=l;}n.call(r.prototype);}}else {try{throw Error()}catch(l){h=l;}let r=n();r&&typeof r.catch=="function"&&r.catch(()=>{});}}catch(r){if(r&&h&&typeof r.stack=="string")return [r.stack,h.stack]}return [null,null]}};i.DetermineComponentFrameRoot.displayName="DetermineComponentFrameRoot",Object.getOwnPropertyDescriptor(i.DetermineComponentFrameRoot,"name")?.configurable&&Object.defineProperty(i.DetermineComponentFrameRoot,"name",{value:"DetermineComponentFrameRoot"});let[y,g]=i.DetermineComponentFrameRoot();if(y&&g){let h=y.split(`
|
|
14
|
+
`),r=g.split(`
|
|
15
|
+
`),l=0,c=0;for(;l<h.length&&!h[l].includes("DetermineComponentFrameRoot");)l++;for(;c<r.length&&!r[c].includes("DetermineComponentFrameRoot");)c++;if(l===h.length||c===r.length)for(l=h.length-1,c=r.length-1;l>=1&&c>=0&&h[l]!==r[c];)c--;for(;l>=1&&c>=0;l--,c--)if(h[l]!==r[c]){if(l!==1||c!==1)do if(l--,c--,c<0||h[l]!==r[c]){let v=`
|
|
16
|
+
${h[l].replace(" at new "," at ")}`,_=B(n);return _&&v.includes("<anonymous>")&&(v=v.replace("<anonymous>",_)),v}while(l>=1&&c>=0);break}}}finally{ae=false,Error.prepareStackTrace=a,le(p),console.error=C,console.warn=d;}let s=n?B(n):"";return s?k(s):""},Ae=()=>{let n=j();for(let e of [...Array.from(P),...Array.from(n.renderers.values())]){let a=e.currentDispatcherRef;if(a&&typeof a=="object")return "H"in a?a.H:a.current}return null},le=n=>{for(let e of P){let a=e.currentDispatcherRef;a&&typeof a=="object"&&("H"in a?a.H=n:a.current=n);}};var Ne=(n,e)=>{switch(n.tag){case ne:case re:case Q:return k(n.type);case ee:return k("Lazy");case J:return n.child!==e&&e!==null?k("Suspense Fallback"):k("Suspense");case te:return k("SuspenseList");case Y:case Z:return V(n.type,false);case X:return V(n.type.render,false);case K:return V(n.type,true);case oe:return k("Activity");case ie:return k("ViewTransition");default:return ""}},Ie=(n,e,a)=>{let p=`
|
|
17
|
+
in ${n}`;return e&&(p+=` (at ${e})`),p},ue=n=>{try{let e="",a=n,p=null;do{e+=Ne(a,p);let C=a._debugInfo;if(C&&Array.isArray(C))for(let d=C.length-1;d>=0;d--){let s=C[d];typeof s.name=="string"&&(e+=Ie(s.name,s.env,s.debugLocation));}p=a,a=a.return;}while(a);return e}catch(e){return e instanceof Error?`
|
|
18
|
+
Error generating stack: ${e.message}
|
|
19
|
+
${e.stack}`:""}},ke=n=>n.length?n[0]===n[0].toUpperCase():false,ce=async n=>{let e=/\n\s+(?:in|at)\s+([^\s(]+)(?:\s+\((?:at\s+)?([^)]+)\))?/g,a=[],p;for(p=e.exec(n);p!==null;){let C=p[1],d=p[2];if(!ke(C)){p=e.exec(n),a.push({name:C,source:undefined});continue}let s;if(d&&d!=="Server")try{let o=` at ${C} (${d})`,i=await Fe(o,1);i.length>0&&(s=i[0]);}catch{}a.push({name:C,source:s||undefined}),p=e.exec(n);}return a};var mt=async n=>{let e=se(n);if(!e)return null;let a=ue(e),C=(await ce(a)).filter(d=>!d.source?.fileName.includes("node_modules")).map(d=>({componentName:d.name,fileName:d.source?.fileName}));return {fiber:e,stack:C}},pt=()=>{let n=null,e=null,a=false,p=null,C=null,d=0,s=0,o=0,i=0,u=0,y=0,g=0,h=0,r="",l=()=>{let t=document.activeElement;return t instanceof HTMLInputElement||t instanceof HTMLTextAreaElement||t?.tagName==="INPUT"||t?.tagName==="TEXTAREA"},c=()=>{let t=document.createElement("div");return t.style.position="fixed",t.style.border="2px solid #3b82f6",t.style.backgroundColor="rgba(59, 130, 246, 0.1)",t.style.pointerEvents="none",t.style.zIndex="999999",t.style.transition="none",document.body.appendChild(t),t},v=(t,S,m)=>t+(S-t)*m,_=()=>{if(!e||!a)return;let t=.2;d=v(d,u,t),s=v(s,y,t),o=v(o,g,t),i=v(i,h,t),e.style.left=`${d}px`,e.style.top=`${s}px`,e.style.width=`${o}px`,e.style.height=`${i}px`,e.style.borderRadius=r,C=requestAnimationFrame(_);},b=t=>{let S=document.elementFromPoint(t.clientX,t.clientY);if(!S||S===e)return;p=S;let m=S.getBoundingClientRect(),F=window.getComputedStyle(S);u=m.left,y=m.top,g=m.width,h=m.height,r=F.borderRadius;},E=t=>{if(!a)return;t.preventDefault(),t.stopPropagation(),t.stopImmediatePropagation();let S=p;O(),S&&mt(S).then(m=>{let F=m?.stack.map(R=>`${R.componentName} (${R.fileName})`).join(`
|
|
20
|
+
`);F&&navigator.clipboard.writeText(F);});},w=t=>{a&&(t.preventDefault(),t.stopPropagation(),t.stopImmediatePropagation());},T=()=>{e||(e=c()),a=true,e.style.display="block",d=u,s=y,o=g,i=h,_();},O=()=>{a=false,e&&(e.style.display="none"),C&&(cancelAnimationFrame(C),C=null),p=null;},M=t=>{t.metaKey&&!n&&!a&&(n=setTimeout(()=>{console.log("Meta key held for 750ms"),l()||T(),n=null;},750));},f=t=>{t.metaKey||(n&&(clearTimeout(n),n=null),a&&O());};return document.addEventListener("keydown",M),document.addEventListener("keyup",f),document.addEventListener("mousemove",b),document.addEventListener("mousedown",w,true),document.addEventListener("click",E,true),()=>{n&&clearTimeout(n),C&&cancelAnimationFrame(C),e&&e.parentNode&&e.parentNode.removeChild(e),document.removeEventListener("keydown",M),document.removeEventListener("keyup",f),document.removeEventListener("mousemove",b),document.removeEventListener("mousedown",w,true),document.removeEventListener("click",E,true);}};pt();/*! Bundled license information:
|
|
21
|
+
|
|
22
|
+
bippy/dist/src-CqIv1vpl.js:
|
|
23
|
+
(**
|
|
24
|
+
* @license bippy
|
|
25
|
+
*
|
|
26
|
+
* Copyright (c) Aiden Bai
|
|
27
|
+
*
|
|
28
|
+
* This source code is licensed under the MIT license found in the
|
|
29
|
+
* LICENSE file in the root directory of this source tree.
|
|
30
|
+
*)
|
|
31
|
+
|
|
32
|
+
bippy/dist/index.js:
|
|
33
|
+
(**
|
|
34
|
+
* @license bippy
|
|
35
|
+
*
|
|
36
|
+
* Copyright (c) Aiden Bai
|
|
37
|
+
*
|
|
38
|
+
* This source code is licensed under the MIT license found in the
|
|
39
|
+
* LICENSE file in the root directory of this source tree.
|
|
40
|
+
*)
|
|
41
|
+
|
|
42
|
+
bippy/dist/source-BfkxIx1q.js:
|
|
43
|
+
(**
|
|
44
|
+
* @license bippy
|
|
45
|
+
*
|
|
46
|
+
* Copyright (c) Aiden Bai
|
|
47
|
+
*
|
|
48
|
+
* This source code is licensed under the MIT license found in the
|
|
49
|
+
* LICENSE file in the root directory of this source tree.
|
|
50
|
+
*)
|
|
51
|
+
|
|
52
|
+
bippy/dist/source.js:
|
|
53
|
+
(**
|
|
54
|
+
* @license bippy
|
|
55
|
+
*
|
|
56
|
+
* Copyright (c) Aiden Bai
|
|
57
|
+
*
|
|
58
|
+
* This source code is licensed under the MIT license found in the
|
|
59
|
+
* LICENSE file in the root directory of this source tree.
|
|
60
|
+
*)
|
|
61
|
+
*/exports.getReactData=mt;exports.init=pt;return exports;})({});
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,177 @@
|
|
|
1
|
+
import { getFiberFromHostInstance } from 'bippy';
|
|
2
|
+
import { getFiberStackTrace, getOwnerStack } from 'bippy/dist/source';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* @license MIT
|
|
6
|
+
*
|
|
7
|
+
* Copyright (c) 2025 Aiden Bai
|
|
8
|
+
*
|
|
9
|
+
* This source code is licensed under the MIT license found in the
|
|
10
|
+
* LICENSE file in the root directory of this source tree.
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
var getReactData = async (element) => {
|
|
14
|
+
const fiber = getFiberFromHostInstance(element);
|
|
15
|
+
if (!fiber) return null;
|
|
16
|
+
const stackTrace = getFiberStackTrace(fiber);
|
|
17
|
+
const rawOwnerStack = await getOwnerStack(stackTrace);
|
|
18
|
+
const stack = rawOwnerStack.filter((item) => !item.source?.fileName.includes("node_modules")).map((item) => ({
|
|
19
|
+
componentName: item.name,
|
|
20
|
+
fileName: item.source?.fileName
|
|
21
|
+
}));
|
|
22
|
+
return {
|
|
23
|
+
fiber,
|
|
24
|
+
stack
|
|
25
|
+
};
|
|
26
|
+
};
|
|
27
|
+
var init = () => {
|
|
28
|
+
let metaKeyTimer = null;
|
|
29
|
+
let overlay = null;
|
|
30
|
+
let isActive = false;
|
|
31
|
+
let currentElement = null;
|
|
32
|
+
let animationFrame = null;
|
|
33
|
+
let currentX = 0;
|
|
34
|
+
let currentY = 0;
|
|
35
|
+
let currentWidth = 0;
|
|
36
|
+
let currentHeight = 0;
|
|
37
|
+
let targetX = 0;
|
|
38
|
+
let targetY = 0;
|
|
39
|
+
let targetWidth = 0;
|
|
40
|
+
let targetHeight = 0;
|
|
41
|
+
let targetBorderRadius = "";
|
|
42
|
+
const isInsideInputOrTextarea = () => {
|
|
43
|
+
const activeElement = document.activeElement;
|
|
44
|
+
return activeElement instanceof HTMLInputElement || activeElement instanceof HTMLTextAreaElement || activeElement?.tagName === "INPUT" || activeElement?.tagName === "TEXTAREA";
|
|
45
|
+
};
|
|
46
|
+
const createOverlay = () => {
|
|
47
|
+
const div = document.createElement("div");
|
|
48
|
+
div.style.position = "fixed";
|
|
49
|
+
div.style.border = "2px solid #3b82f6";
|
|
50
|
+
div.style.backgroundColor = "rgba(59, 130, 246, 0.1)";
|
|
51
|
+
div.style.pointerEvents = "none";
|
|
52
|
+
div.style.zIndex = "999999";
|
|
53
|
+
div.style.transition = "none";
|
|
54
|
+
document.body.appendChild(div);
|
|
55
|
+
return div;
|
|
56
|
+
};
|
|
57
|
+
const lerp = (start, end, factor) => {
|
|
58
|
+
return start + (end - start) * factor;
|
|
59
|
+
};
|
|
60
|
+
const updateOverlayPosition = () => {
|
|
61
|
+
if (!overlay || !isActive) return;
|
|
62
|
+
const factor = 0.2;
|
|
63
|
+
currentX = lerp(currentX, targetX, factor);
|
|
64
|
+
currentY = lerp(currentY, targetY, factor);
|
|
65
|
+
currentWidth = lerp(currentWidth, targetWidth, factor);
|
|
66
|
+
currentHeight = lerp(currentHeight, targetHeight, factor);
|
|
67
|
+
overlay.style.left = `${currentX}px`;
|
|
68
|
+
overlay.style.top = `${currentY}px`;
|
|
69
|
+
overlay.style.width = `${currentWidth}px`;
|
|
70
|
+
overlay.style.height = `${currentHeight}px`;
|
|
71
|
+
overlay.style.borderRadius = targetBorderRadius;
|
|
72
|
+
animationFrame = requestAnimationFrame(updateOverlayPosition);
|
|
73
|
+
};
|
|
74
|
+
const handleMouseMove = (e) => {
|
|
75
|
+
const element = document.elementFromPoint(e.clientX, e.clientY);
|
|
76
|
+
if (!element || element === overlay) return;
|
|
77
|
+
currentElement = element;
|
|
78
|
+
const rect = element.getBoundingClientRect();
|
|
79
|
+
const computedStyle = window.getComputedStyle(element);
|
|
80
|
+
targetX = rect.left;
|
|
81
|
+
targetY = rect.top;
|
|
82
|
+
targetWidth = rect.width;
|
|
83
|
+
targetHeight = rect.height;
|
|
84
|
+
targetBorderRadius = computedStyle.borderRadius;
|
|
85
|
+
};
|
|
86
|
+
const handleClick = (e) => {
|
|
87
|
+
if (!isActive) return;
|
|
88
|
+
e.preventDefault();
|
|
89
|
+
e.stopPropagation();
|
|
90
|
+
e.stopImmediatePropagation();
|
|
91
|
+
const elementToInspect = currentElement;
|
|
92
|
+
hideOverlay();
|
|
93
|
+
if (elementToInspect) {
|
|
94
|
+
void getReactData(elementToInspect).then((data) => {
|
|
95
|
+
const serializedStack = data?.stack.map((item) => `${item.componentName} (${item.fileName})`).join("\n");
|
|
96
|
+
if (serializedStack) {
|
|
97
|
+
void navigator.clipboard.writeText(serializedStack);
|
|
98
|
+
}
|
|
99
|
+
});
|
|
100
|
+
}
|
|
101
|
+
};
|
|
102
|
+
const handleMouseDown = (e) => {
|
|
103
|
+
if (!isActive) return;
|
|
104
|
+
e.preventDefault();
|
|
105
|
+
e.stopPropagation();
|
|
106
|
+
e.stopImmediatePropagation();
|
|
107
|
+
};
|
|
108
|
+
const showOverlay = () => {
|
|
109
|
+
if (!overlay) {
|
|
110
|
+
overlay = createOverlay();
|
|
111
|
+
}
|
|
112
|
+
isActive = true;
|
|
113
|
+
overlay.style.display = "block";
|
|
114
|
+
currentX = targetX;
|
|
115
|
+
currentY = targetY;
|
|
116
|
+
currentWidth = targetWidth;
|
|
117
|
+
currentHeight = targetHeight;
|
|
118
|
+
updateOverlayPosition();
|
|
119
|
+
};
|
|
120
|
+
const hideOverlay = () => {
|
|
121
|
+
isActive = false;
|
|
122
|
+
if (overlay) {
|
|
123
|
+
overlay.style.display = "none";
|
|
124
|
+
}
|
|
125
|
+
if (animationFrame) {
|
|
126
|
+
cancelAnimationFrame(animationFrame);
|
|
127
|
+
animationFrame = null;
|
|
128
|
+
}
|
|
129
|
+
currentElement = null;
|
|
130
|
+
};
|
|
131
|
+
const handleKeyDown = (e) => {
|
|
132
|
+
if (e.metaKey && !metaKeyTimer && !isActive) {
|
|
133
|
+
metaKeyTimer = setTimeout(() => {
|
|
134
|
+
console.log("Meta key held for 750ms");
|
|
135
|
+
if (!isInsideInputOrTextarea()) {
|
|
136
|
+
showOverlay();
|
|
137
|
+
}
|
|
138
|
+
metaKeyTimer = null;
|
|
139
|
+
}, 750);
|
|
140
|
+
}
|
|
141
|
+
};
|
|
142
|
+
const handleKeyUp = (e) => {
|
|
143
|
+
if (!e.metaKey) {
|
|
144
|
+
if (metaKeyTimer) {
|
|
145
|
+
clearTimeout(metaKeyTimer);
|
|
146
|
+
metaKeyTimer = null;
|
|
147
|
+
}
|
|
148
|
+
if (isActive) {
|
|
149
|
+
hideOverlay();
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
};
|
|
153
|
+
document.addEventListener("keydown", handleKeyDown);
|
|
154
|
+
document.addEventListener("keyup", handleKeyUp);
|
|
155
|
+
document.addEventListener("mousemove", handleMouseMove);
|
|
156
|
+
document.addEventListener("mousedown", handleMouseDown, true);
|
|
157
|
+
document.addEventListener("click", handleClick, true);
|
|
158
|
+
return () => {
|
|
159
|
+
if (metaKeyTimer) {
|
|
160
|
+
clearTimeout(metaKeyTimer);
|
|
161
|
+
}
|
|
162
|
+
if (animationFrame) {
|
|
163
|
+
cancelAnimationFrame(animationFrame);
|
|
164
|
+
}
|
|
165
|
+
if (overlay && overlay.parentNode) {
|
|
166
|
+
overlay.parentNode.removeChild(overlay);
|
|
167
|
+
}
|
|
168
|
+
document.removeEventListener("keydown", handleKeyDown);
|
|
169
|
+
document.removeEventListener("keyup", handleKeyUp);
|
|
170
|
+
document.removeEventListener("mousemove", handleMouseMove);
|
|
171
|
+
document.removeEventListener("mousedown", handleMouseDown, true);
|
|
172
|
+
document.removeEventListener("click", handleClick, true);
|
|
173
|
+
};
|
|
174
|
+
};
|
|
175
|
+
init();
|
|
176
|
+
|
|
177
|
+
export { getReactData, init };
|
package/package.json
CHANGED
|
@@ -1,4 +1,75 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "react-grab",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.2",
|
|
4
|
+
"description": "",
|
|
5
|
+
"keywords": [],
|
|
6
|
+
"homepage": "https://github.com/aidenybai/react-grab#readme",
|
|
7
|
+
"bugs": {
|
|
8
|
+
"url": "https://github.com/aidenybai/react-grab/issues"
|
|
9
|
+
},
|
|
10
|
+
"repository": {
|
|
11
|
+
"type": "git",
|
|
12
|
+
"url": "git+https://github.com/aidenybai/react-grab.git"
|
|
13
|
+
},
|
|
14
|
+
"license": "MIT",
|
|
15
|
+
"author": {
|
|
16
|
+
"name": "Aiden Bai",
|
|
17
|
+
"email": "aiden@million.dev"
|
|
18
|
+
},
|
|
19
|
+
"type": "module",
|
|
20
|
+
"exports": {
|
|
21
|
+
"./package.json": "./package.json",
|
|
22
|
+
".": {
|
|
23
|
+
"import": {
|
|
24
|
+
"types": "./dist/index.d.ts",
|
|
25
|
+
"default": "./dist/index.js"
|
|
26
|
+
},
|
|
27
|
+
"require": {
|
|
28
|
+
"types": "./dist/index.d.cts",
|
|
29
|
+
"default": "./dist/index.cjs"
|
|
30
|
+
}
|
|
31
|
+
},
|
|
32
|
+
"./dist/*": "./dist/*.js",
|
|
33
|
+
"./dist/*.js": "./dist/*.js",
|
|
34
|
+
"./dist/*.cjs": "./dist/*.cjs",
|
|
35
|
+
"./dist/*.mjs": "./dist/*.mjs"
|
|
36
|
+
},
|
|
37
|
+
"main": "dist/index.js",
|
|
38
|
+
"module": "dist/index.js",
|
|
39
|
+
"browser": "dist/index.global.js",
|
|
40
|
+
"types": "dist/index.d.ts",
|
|
41
|
+
"files": [
|
|
42
|
+
"dist",
|
|
43
|
+
"bin",
|
|
44
|
+
"package.json",
|
|
45
|
+
"README.md",
|
|
46
|
+
"LICENSE"
|
|
47
|
+
],
|
|
48
|
+
"scripts": {
|
|
49
|
+
"build": "NODE_ENV=production tsup",
|
|
50
|
+
"dev": "NODE_ENV=development tsup --watch",
|
|
51
|
+
"lint": "eslint src/**/*.ts",
|
|
52
|
+
"lint:fix": "eslint src/**/*.ts --fix",
|
|
53
|
+
"format": "prettier --write .",
|
|
54
|
+
"check": "eslint src/**/*.ts && prettier --check .",
|
|
55
|
+
"publint": "publint",
|
|
56
|
+
"test": "vitest --dom",
|
|
57
|
+
"coverage": "vitest run --coverage --dom",
|
|
58
|
+
"prepublishOnly": "pnpm build"
|
|
59
|
+
},
|
|
60
|
+
"devDependencies": {
|
|
61
|
+
"@vitest/coverage-istanbul": "2.1.8",
|
|
62
|
+
"eslint": "^9.37.0",
|
|
63
|
+
"eslint-plugin-perfectionist": "^4.15.1",
|
|
64
|
+
"publint": "^0.2.12",
|
|
65
|
+
"terser": "^5.36.0",
|
|
66
|
+
"tsup": "^8.2.4",
|
|
67
|
+
"typescript-eslint": "^8.46.1"
|
|
68
|
+
},
|
|
69
|
+
"publishConfig": {
|
|
70
|
+
"access": "public"
|
|
71
|
+
},
|
|
72
|
+
"dependencies": {
|
|
73
|
+
"bippy": "^0.3.28"
|
|
74
|
+
}
|
|
4
75
|
}
|