bippy 0.2.0 → 0.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,24 +0,0 @@
1
- import { F as Fiber$1 } from '../types-BqcvCznx.cjs';
2
- import 'react-reconciler';
3
-
4
- type Fiber = Fiber$1<Element>;
5
- declare global {
6
- var __REACT_SCAN_STOP__: boolean;
7
- var ReactScan: {
8
- hasStopped: () => boolean;
9
- stop: () => void;
10
- cleanup: () => void;
11
- init: () => void;
12
- flushOutlines: () => void;
13
- };
14
- }
15
-
16
- declare const outlineFiber: (fiber: Fiber) => void;
17
- declare const getRectMap: (elements: Element[]) => Promise<Map<Element, DOMRect>>;
18
- declare const flushOutlines: () => Promise<void>;
19
- declare const getCanvasEl: () => HTMLDivElement | null;
20
- declare const hasStopped: () => boolean;
21
- declare const stop: () => void;
22
- declare const cleanup: () => void;
23
-
24
- export { cleanup, flushOutlines, getCanvasEl, getRectMap, hasStopped, outlineFiber, stop };
@@ -1,24 +0,0 @@
1
- import { F as Fiber$1 } from '../types-BqcvCznx.js';
2
- import 'react-reconciler';
3
-
4
- type Fiber = Fiber$1<Element>;
5
- declare global {
6
- var __REACT_SCAN_STOP__: boolean;
7
- var ReactScan: {
8
- hasStopped: () => boolean;
9
- stop: () => void;
10
- cleanup: () => void;
11
- init: () => void;
12
- flushOutlines: () => void;
13
- };
14
- }
15
-
16
- declare const outlineFiber: (fiber: Fiber) => void;
17
- declare const getRectMap: (elements: Element[]) => Promise<Map<Element, DOMRect>>;
18
- declare const flushOutlines: () => Promise<void>;
19
- declare const getCanvasEl: () => HTMLDivElement | null;
20
- declare const hasStopped: () => boolean;
21
- declare const stop: () => void;
22
- declare const cleanup: () => void;
23
-
24
- export { cleanup, flushOutlines, getCanvasEl, getRectMap, hasStopped, outlineFiber, stop };
@@ -1,9 +0,0 @@
1
- var ReactScan=function(t){"use strict";
2
- /**
3
- * @license bippy
4
- *
5
- * Copyright (c) Aiden Bai, Million Software, Inc.
6
- *
7
- * This source code is licensed under the MIT license found in the
8
- * LICENSE file in the root directory of this source tree.
9
- */var e="bippy-0.2.0",n=()=>{},o=t=>{try{Function.prototype.toString.call(t).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{}},i=t=>{const i=new Map;let r=0;const l={checkDCE:o,supportsFiber:!0,supportsFlight:!0,hasUnsupportedRendererAttached:!1,renderers:i,onCommitFiberRoot:n,onCommitFiberUnmount:n,onPostCommitFiberRoot:n,inject(e){const n=++r;return i.set(n,e),l._instrumentationIsActive||(l._instrumentationIsActive=!0,t?.()),n},_instrumentationSource:e,_instrumentationIsActive:!1};try{Object.defineProperty(globalThis,"__REACT_DEVTOOLS_GLOBAL_HOOK__",{value:l})}catch{}return l},r=()=>Object.prototype.hasOwnProperty.call(globalThis,"__REACT_DEVTOOLS_GLOBAL_HOOK__"),l=t=>{let e=globalThis.__REACT_DEVTOOLS_GLOBAL_HOOK__;return e&&t?.(),r()||(e=i(t)),e};try{"undefined"==typeof window||!window.document?.createElement&&"ReactNative"!==window.navigator?.product||"undefined"==typeof process||null==process.versions||null==process.versions.node||i()}catch{}var a=t=>{switch(t.tag){case 5:case 26:case 27:return!0;default:return"string"==typeof t.type}},s=t=>{const e=t.memoizedProps,n=t.alternate?.memoizedProps||{},o=t.flags??t.effectTag??0;switch(t.tag){case 1:case 0:case 9:case 11:case 14:case 15:return!(1&~o);default:return!t.alternate||(n!==e||t.alternate.memoizedState!==t.memoizedState||t.alternate.ref!==t.ref)}},c=t=>{switch(t.tag){case 18:case 6:case 7:case 23:case 22:return!0;case 3:return!1;default:{const e="object"==typeof t.type&&null!==t.type?t.type.$$typeof:t.type;switch("symbol"==typeof e?e.toString():e){case 60111:case"Symbol(react.concurrent_mode)":case"Symbol(react.async_mode)":return!0;default:return!1}}}},h=t=>{const e=t;return"function"==typeof e?e:"object"==typeof e&&e?h(e.type||e.render):null},u=t=>{try{if("string"==typeof t.version&&t.bundleType>0)return"development"}catch{}return"production"},d=0,f=new WeakMap,m=t=>{let e=f.get(t);return!e&&t.alternate&&(e=f.get(t.alternate)),e||(e=d++,((t,e=d++)=>{f.set(t,e)})(t,e)),e},g=(t,e,n)=>{let o=e;for(;null!=o;){f.has(o)||m(o);if(!c(o)&&s(o)&&t(o,"mount"),13===o.tag){if(null!==o.memoizedState){const e=o.child,n=e?e.sibling:null;if(n){const e=n.child;null!==e&&g(t,e,!1)}}else{let e=null;null!==o.child&&(e=o.child.child),null!==e&&g(t,e,!1)}}else null!=o.child&&g(t,o.child,!0);o=n?o.sibling:null}},p=(t,e,n,o)=>{if(f.has(e)||m(e),!n)return;f.has(n)||m(n);const i=13===e.tag;!c(e)&&s(e)&&t(e,"update");const r=i&&null!==n.memoizedState,l=i&&null!==e.memoizedState;if(r&&l){const o=e.child?.sibling??null,i=n.child?.sibling??null;null!==o&&null!==i&&p(t,o,i)}else if(r&&!l){const n=e.child;null!==n&&g(t,n,!0)}else if(!r&&l){y(t,n);const o=e.child?.sibling??null;null!==o&&g(t,o,!0)}else if(e.child!==n.child){let n=e.child;for(;n;){if(n.alternate){const e=n.alternate;p(t,n,e)}else g(t,n,!1);n=n.sibling}}},w=(t,e)=>{!(3===e.tag)&&c(e)||t(e,"unmount")},y=(t,e)=>{const n=13===e.tag&&null!==e.memoizedState;let o=e.child;if(n){const t=e.child,n=t?.sibling??null;o=n?.child??null}for(;null!==o;)null!==o.return&&(w(t,o),y(t,o)),o=o.sibling},b=0,v=new WeakMap,x=({onRender:t})=>(e,n,o)=>{((t,e)=>{const n="current"in t?t.current:t;let o=v.get(t);o||(o={prevFiber:null,id:b++},v.set(t,o));const{prevFiber:i}=o;if(n)if(null!==i){const t=i&&null!=i.memoizedState&&null!=i.memoizedState.element&&!0!==i.memoizedState.isDehydrated,o=null!=n.memoizedState&&null!=n.memoizedState.element&&!0!==n.memoizedState.isDehydrated;!t&&o?g(e,n,!1):t&&o?p(e,n,n.alternate):t&&!o&&w(e,n)}else g(e,n,!0);else w(e,n);o.prevFiber=n})(n,t)},C=(t,e={})=>{const n=t.onActive,o=r(),i="reactDevtoolsAgent"in l();let a,s=!1;return t.onActive=()=>{clearTimeout(a);let o=!0;try{n?.();const t=l();for(const n of t.renderers.values()){const[t]=n.version.split(".");Number(t)<(e.minReactMajorVersion??17)&&(o=!1);"development"!==u(n)&&(s=!0,e.dangerouslyRunInProduction||(o=!1))}}catch(t){e.onError?.(t)}if(!o)return t.onCommitFiberRoot=void 0,t.onCommitFiberUnmount=void 0,t.onPostCommitFiberRoot=void 0,void(t.onActive=void 0);try{const n=t.onCommitFiberRoot;n&&(t.onCommitFiberRoot=(t,o,i)=>{try{n(t,o,i)}catch(t){e.onError?.(t)}});const o=t.onCommitFiberUnmount;o&&(t.onCommitFiberUnmount=(t,n)=>{try{o(t,n)}catch(t){e.onError?.(t)}});const i=t.onPostCommitFiberRoot;i&&(t.onPostCommitFiberRoot=(t,n)=>{try{i(t,n)}catch(t){e.onError?.(t)}})}catch(t){e.onError?.(t)}},o||i||(a=setTimeout((()=>{s||e.onError?.(),stop()}),e.installCheckTimeout??100)),t};function R(){return function(t){let e=new Blob([t],{type:"text/javascript"}),n=URL.createObjectURL(e),o=new Worker(n);return URL.revokeObjectURL(n),o}('var Y="Menlo,Consolas,Monaco,Liberation Mono,Lucida Console,monospace";var C=(t,l)=>Math.floor(t+(l-t)*.2);var _="115,97,230";var $=t=>{let l=new Map;for(let i of t){let{name:h,count:e}=i;l.set(h,(l.get(h)||0)+e)}let u=new Map;for(let[i,h]of l.entries()){let e=u.get(h);e?e.push(i):u.set(h,[i])}let p=Array.from(u.entries()).sort(([i],[h])=>h-i),a=p.length,r="";for(let i=0;i<a;i++){let[h,e]=p[i],n=`${e.slice(0,4).join(", ")} \\xD7${h}`;n.length>40&&(n=`${n.slice(0,40)}\\u2026`),i!==a-1&&(n+=", "),r+=n}return r.length>40?`${r.slice(0,40)}\\u2026`:r},S=t=>{let l=0;for(let u of t)l+=u.width*u.height;return l};var N=(t,l)=>{let u=t.getContext("2d",{alpha:!0});return u&&u.scale(l,l),u},X=(t,l,u,p)=>{t.clearRect(0,0,l.width/u,l.height/u);let a=new Map,r=new Map;for(let e of p.values()){let{x:n,y:c,width:s,height:f,targetX:o,targetY:d,targetWidth:g,targetHeight:m,frame:x}=e;o!==n&&(e.x=C(n,o)),d!==c&&(e.y=C(c,d)),g!==s&&(e.width=C(s,g)),m!==f&&(e.height=C(f,m));let O=`${o!=null?o:n},${d!=null?d:c}`,y=`${O},${g!=null?g:s},${m!=null?m:f}`,R=a.get(O);R?R.push(e):a.set(O,[e]);let M=1-x/45;e.frame++;let E=r.get(y)||{x:n,y:c,width:s,height:f,alpha:M};M>E.alpha&&(E.alpha=M),r.set(y,E)}for(let e of r.values()){let{x:n,y:c,width:s,height:f,alpha:o}=e;t.strokeStyle=`rgba(${_},${o})`,t.lineWidth=1,t.beginPath(),t.rect(n,c,s,f),t.stroke(),t.fillStyle=`rgba(${_},${o*.1})`,t.fill()}t.font=`11px ${Y}`;let i=new Map;t.textRendering="optimizeSpeed";for(let e of a.values()){let n=e[0],{x:c,y:s,frame:f}=n,o=1-f/45,d=$(e),{width:g}=t.measureText(d),m=11;i.set(`${c},${s},${g},${d}`,{text:d,width:g,height:m,alpha:o,x:c,y:s,outlines:e});let x=s-m-4;if(x<0&&(x=0),f>45)for(let O of e)p.delete(String(O.id))}let h=Array.from(i.entries()).sort(([e,n],[c,s])=>S(s.outlines)-S(n.outlines));for(let[e,n]of h)if(i.has(e))for(let[c,s]of i.entries()){if(e===c)continue;let{x:f,y:o,width:d,height:g}=n,{x:m,y:x,width:O,height:y}=s;f+d>m&&m+O>f&&o+g>x&&x+y>o&&(n.text=$([...n.outlines,...s.outlines]),n.width=t.measureText(n.text).width,i.delete(c))}for(let e of i.values()){let{x:n,y:c,alpha:s,width:f,height:o,text:d}=e,g=c-o-4;g<0&&(g=0),t.fillStyle=`rgba(${_},${s})`,t.fillRect(n,g,f+4,o+4),t.fillStyle=`rgba(255,255,255,${s})`,t.fillText(d,n+2,g+o)}return p.size>0};var A=null,w=null,b=1,L=new Map,T=null,v=()=>{if(!w||!A)return;X(w,A,b,L)?T=requestAnimationFrame(v):T=null};self.onmessage=t=>{let{type:l}=t.data;if(l==="init"&&(A=t.data.canvas,b=t.data.dpr,A&&(A.width=t.data.width,A.height=t.data.height,w=N(A,b))),!(!A||!w)){if(l==="resize"){b=t.data.dpr,A.width=t.data.width*b,A.height=t.data.height*b,w.resetTransform(),w.scale(b,b),v();return}if(l==="draw-outlines"){let{data:u,names:p}=t.data,a=new Float32Array(u);for(let r=0;r<a.length;r+=7){let i=a[r+2],h=a[r+3],e=a[r+4],n=a[r+5],c=a[r+6],s={id:a[r],name:p[r/7],count:a[r+1],x:i,y:h,width:e,height:n,frame:0,targetX:i,targetY:h,targetWidth:e,targetHeight:n,didCommit:c},f=String(s.id),o=L.get(f);o?(o.count++,o.frame=0,o.targetX=i,o.targetY=h,o.targetWidth=e,o.targetHeight=n,o.didCommit=c):L.set(f,s)}T||(T=requestAnimationFrame(v));return}if(l==="scroll"){let{deltaX:u,deltaY:p}=t.data;for(let a of L.values()){let r=a.x-u,i=a.y-p;a.targetX=r,a.targetY=i}}}};\n')}var S=(t,e)=>Math.floor(t+.2*(e-t)),$="115,97,230",A=t=>{const e=new Map;for(const n of t){const{name:t,count:o}=n;e.set(t,(e.get(t)||0)+o)}const n=new Map;for(const[t,o]of e.entries()){const e=n.get(o);e?e.push(t):n.set(o,[t])}const o=Array.from(n.entries()).sort((([t],[e])=>e-t)),i=o.length;let r="";for(let t=0;t<i;t++){const[e,n]=o[t];let l=`${n.slice(0,4).join(", ")} ×${e}`;l.length>40&&(l=`${l.slice(0,40)}…`),t!==i-1&&(l+=", "),r+=l}return r.length>40?`${r.slice(0,40)}…`:r},_=t=>{let e=0;for(const n of t)e+=n.width*n.height;return e},M=null,F=null,T=null,O=1,E=null,L=new Map,z=new WeakMap,P=new Set,k=t=>{if(!(t=>{switch(t.tag){case 0:case 1:case 15:case 14:case 11:return!0;default:return!1}})(t))return;const e="string"==typeof t.type?t.type:(t=>{const e=t;if("function"!=typeof e&&("object"!=typeof e||!e))return null;const n=e.displayName||e.name||null;if(n)return n;const o=h(e);return o&&(o.displayName||o.name)||null})(t);if(!e)return;const n=z.get(t),o=(t=>{const e=[],n=[];for(a(t)?e.push(t):t.child&&n.push(t.child);n.length;){const t=n.pop();if(!t)break;a(t)?e.push(t):t.child&&n.push(t.child),t.sibling&&n.push(t.sibling)}return e})(t),i=(t=>Boolean(!!(13374&t.flags)||!!(13374&t.subtreeFlags)))(t);n?n.count++:(z.set(t,{name:e,count:1,elements:o.map((t=>t.stateNode)),didCommit:i?1:0}),P.add(t))},W=t=>{const e=t[0];if(1===t.length)return e;let n,o,i,r;for(let e=0,l=t.length;e<l;e++){const l=t[e];n=null==n?l.x:Math.min(n,l.x),o=null==o?l.y:Math.min(o,l.y),i=null==i?l.x+l.width:Math.max(i,l.x+l.width),r=null==r?l.y+l.height:Math.max(r,l.y+l.height)}return null==n||null==o||null==i||null==r?t[0]:new DOMRect(n,o,i-n,r-o)},X=t=>new Promise((e=>{const n=new Map,o=new IntersectionObserver((t=>{for(let e=0,o=t.length;e<o;e++){const o=t[e],i=o.target,r=o.boundingClientRect;o.isIntersecting&&r.width&&r.height&&n.set(i,r)}o.disconnect(),e(n)}));for(let e=0,n=t.length;e<n;e++){const n=t[e];o.observe(n)}})),Y="undefined"!=typeof SharedArrayBuffer?SharedArrayBuffer:ArrayBuffer,j=async()=>{const t=[];for(const e of P){const n=z.get(e);if(n)for(let e=0;e<n.elements.length;e++)t.push(n.elements[e])}const e=await X(t),n=[],o=[],i=[];for(const t of P){const r=z.get(t);if(!r)continue;const l=[];for(let t=0;t<r.elements.length;t++){const n=r.elements[t],o=e.get(n);o&&l.push(o)}z.delete(t),P.delete(t),l.length&&(n.push(r),o.push(W(l)),i.push(m(t)))}const r=new Y(7*n.length*4),l=new Float32Array(r),a=new Array(n.length);let s;for(let t=0,e=n.length;t<e;t++){const e=n[t],r=i[t],{x:c,y:h,width:u,height:d}=o[t],{count:f,name:m,didCommit:g}=e;if(M){const e=7*t;l[e]=r,l[e+1]=f,l[e+2]=c,l[e+3]=h,l[e+4]=u,l[e+5]=d,l[e+6]=g,a[t]=m}else s||=new Array(n.length),s[t]={id:r,name:m,count:f,x:c,y:h,width:u,height:d,didCommit:g}}M?M.postMessage({type:"draw-outlines",data:r,names:a}):F&&T&&s&&(((t,e)=>{for(const{id:n,name:o,count:i,x:r,y:l,width:a,height:s,didCommit:c}of e){const e={id:n,name:o,count:i,x:r,y:l,width:a,height:s,frame:0,targetX:r,targetY:l,targetWidth:a,targetHeight:s,didCommit:c},h=String(e.id),u=t.get(h);u?(u.count++,u.frame=0,u.targetX=r,u.targetY=l,u.targetWidth=a,u.targetHeight=s,u.didCommit=c):t.set(h,e)}})(L,s),E||(E=requestAnimationFrame(U)))},U=()=>{if(!T||!F)return;const t=((t,e,n,o)=>{t.clearRect(0,0,e.width/n,e.height/n);const i=new Map,r=new Map;for(const t of o.values()){const{x:e,y:n,width:o,height:l,targetX:a,targetY:s,targetWidth:c,targetHeight:h,frame:u}=t;a!==e&&(t.x=S(e,a)),s!==n&&(t.y=S(n,s)),c!==o&&(t.width=S(o,c)),h!==l&&(t.height=S(l,h));const d=`${a??e},${s??n}`,f=`${d},${c??o},${h??l}`,m=i.get(d);m?m.push(t):i.set(d,[t]);const g=1-u/45;t.frame++;const p=r.get(f)||{x:e,y:n,width:o,height:l,alpha:g};g>p.alpha&&(p.alpha=g),r.set(f,p)}for(const e of r.values()){const{x:n,y:o,width:i,height:r,alpha:l}=e;t.strokeStyle=`rgba(${$},${l})`,t.lineWidth=1,t.beginPath(),t.rect(n,o,i,r),t.stroke(),t.fillStyle=`rgba(${$},${.1*l})`,t.fill()}t.font="11px Menlo,Consolas,Monaco,Liberation Mono,Lucida Console,monospace";const l=new Map;t.textRendering="optimizeSpeed";for(const e of i.values()){const n=e[0],{x:i,y:r,frame:a}=n,s=1-a/45,c=A(e),{width:h}=t.measureText(c),u=11;if(l.set(`${i},${r},${h},${c}`,{text:c,width:h,height:u,alpha:s,x:i,y:r,outlines:e}),a>45)for(const t of e)o.delete(String(t.id))}const a=Array.from(l.entries()).sort((([t,e],[n,o])=>_(o.outlines)-_(e.outlines)));for(const[e,n]of a)if(l.has(e))for(const[o,i]of l.entries()){if(e===o)continue;const{x:r,y:a,width:s,height:c}=n,{x:h,y:u,width:d,height:f}=i;r+s>h&&h+d>r&&a+c>u&&u+f>a&&(n.text=A([...n.outlines,...i.outlines]),n.width=t.measureText(n.text).width,l.delete(o))}for(const e of l.values()){const{x:n,y:o,alpha:i,width:r,height:l,text:a}=e;let s=o-l-4;s<0&&(s=0),t.fillStyle=`rgba(${$},${i})`,t.fillRect(n,s,r+4,l+4),t.fillStyle=`rgba(255,255,255,${i})`,t.fillText(a,n+2,s+l)}return o.size>0})(T,F,O,L);E=t?requestAnimationFrame(U):null},H="undefined"!=typeof OffscreenCanvas&&void 0!==R,D=()=>Math.min(window.devicePixelRatio||1,2),N=()=>{const t=document.createElement("div");t.setAttribute("data-react-scan","true");const e=t.attachShadow({mode:"open"});e.innerHTML='<canvas style="position:fixed;top:0;left:0;pointer-events:none;z-index:2147483646" aria-hidden="true"></canvas>';const n=e.firstChild;if(!n)return null;O=D(),F=n;const{innerWidth:o,innerHeight:i}=window;n.style.width=`${o}px`,n.style.height=`${i}px`;const r=o*O,l=i*O;if(n.width=r,n.height=l,H)try{M=R();const t=n.transferControlToOffscreen();M.postMessage({type:"init",canvas:t,width:n.width,height:n.height,dpr:O},[t])}catch{}M||(T=((t,e)=>{const n=t.getContext("2d",{alpha:!0});return n&&n.scale(e,e),n})(n,O));let a=!1;window.addEventListener("resize",(()=>{a||(a=!0,setTimeout((()=>{const t=window.innerWidth,e=window.innerHeight;O=D(),n.style.width=`${t}px`,n.style.height=`${e}px`,M?M.postMessage({type:"resize",width:t,height:e,dpr:O}):(n.width=t*O,n.height=e*O,T&&(T.resetTransform(),T.scale(O,O)),U()),a=!1})))}));let s=window.scrollX,c=window.scrollY,h=!1;return window.addEventListener("scroll",(()=>{h||(h=!0,setTimeout((()=>{const{scrollX:t,scrollY:e}=window,n=t-s,o=e-c;s=t,c=e,M?M.postMessage({type:"scroll",deltaX:n,deltaY:o}):requestAnimationFrame((()=>{((t,e,n)=>{for(const o of t.values()){const t=o.x-e,i=o.y-n;o.targetX=t,o.targetY=i}})(L,n,o)})),h=!1}),32))})),setInterval((()=>{P.size&&j()}),32),e.appendChild(n),t},B=()=>globalThis.__REACT_SCAN_STOP__,I=!1,q=()=>{if(I)return;I=!0;const t=document.querySelector("[data-react-scan]");t&&t.remove()};return"undefined"!=typeof window&&(()=>{if(q(),B())return;const t=x({onRender(t){document.hidden||k(t)},onError(){}});var n;n=C({onActive(){if(B())return;const t=N();t&&document.documentElement.appendChild(t)},onCommitFiberRoot(e,n){if(B())return q();t(e,n)}},{dangerouslyRunInProduction:!0,onError(t){console.warn("React Scan did not install correctly.\n\n{link to install doc}",t)}}),l((()=>{const t=l();n.onActive?.(),t._instrumentationSource=n.name??e;const o=t.onCommitFiberRoot;n.onCommitFiberRoot&&(t.onCommitFiberRoot=(t,e,i)=>{o&&o(t,e,i),n.onCommitFiberRoot?.(t,e,i)});const i=t.onCommitFiberUnmount;n.onCommitFiberUnmount&&(t.onCommitFiberUnmount=(t,e)=>{i&&i(t,e),n.onCommitFiberUnmount?.(t,e)});const r=t.onPostCommitFiberRoot;n.onPostCommitFiberRoot&&(t.onPostCommitFiberRoot=(t,e)=>{r&&r(t,e),n.onPostCommitFiberRoot?.(t,e)})}))})(),t.cleanup=q,t.flushOutlines=j,t.getCanvasEl=N,t.getRectMap=X,t.hasStopped=B,t.outlineFiber=k,t.stop=()=>{globalThis.__REACT_SCAN_STOP__=!0,q()},t}({});