react-grab 0.0.2 → 0.0.3

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/index.cjs CHANGED
@@ -94,7 +94,7 @@ var init = () => {
94
94
  hideOverlay();
95
95
  if (elementToInspect) {
96
96
  void getReactData(elementToInspect).then((data) => {
97
- const serializedStack = data?.stack.map((item) => `${item.componentName} (${item.fileName})`).join("\n");
97
+ const serializedStack = data?.stack.map((item) => `${item.componentName}${item.fileName ? ` (${item.fileName})` : ""}`).join("\n");
98
98
  if (serializedStack) {
99
99
  void navigator.clipboard.writeText(serializedStack);
100
100
  }
@@ -16,7 +16,7 @@ var me="0.3.28",W=`bippy-${me}`,fe=Object.defineProperty,De=Object.prototype.has
16
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
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
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(`
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?` (${R.fileName})`:""}`).join(`
20
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
21
 
22
22
  bippy/dist/src-CqIv1vpl.js:
package/dist/index.js CHANGED
@@ -92,7 +92,7 @@ var init = () => {
92
92
  hideOverlay();
93
93
  if (elementToInspect) {
94
94
  void getReactData(elementToInspect).then((data) => {
95
- const serializedStack = data?.stack.map((item) => `${item.componentName} (${item.fileName})`).join("\n");
95
+ const serializedStack = data?.stack.map((item) => `${item.componentName}${item.fileName ? ` (${item.fileName})` : ""}`).join("\n");
96
96
  if (serializedStack) {
97
97
  void navigator.clipboard.writeText(serializedStack);
98
98
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-grab",
3
- "version": "0.0.2",
3
+ "version": "0.0.3",
4
4
  "description": "",
5
5
  "keywords": [],
6
6
  "homepage": "https://github.com/aidenybai/react-grab#readme",
package/README.md DELETED
@@ -1,64 +0,0 @@
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
- ```