vault66-crt-effect
Version:
A customizable CRT visual effect component for React
23 lines (22 loc) • 7.74 kB
JavaScript
(function(p,i){typeof exports=="object"&&typeof module<"u"?module.exports=i(require("react")):typeof define=="function"&&define.amd?define(["react"],i):(p=typeof globalThis<"u"?globalThis:p||self,p.CRTEffect=i(p.React))})(this,function(p){"use strict";var i={exports:{}},T={};/**
* @license React
* react-jsx-runtime.production.js
*
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/var z;function Q(){if(z)return T;z=1;var l=Symbol.for("react.transitional.element"),R=Symbol.for("react.fragment");function f(d,a,s){var m=null;if(s!==void 0&&(m=""+s),a.key!==void 0&&(m=""+a.key),"key"in a){s={};for(var E in a)E!=="key"&&(s[E]=a[E])}else s=a;return a=s.ref,{$$typeof:l,type:d,key:m,ref:a!==void 0?a:null,props:s}}return T.Fragment=R,T.jsx=f,T.jsxs=f,T}var _={};/**
* @license React
* react-jsx-runtime.development.js
*
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/var U;function K(){return U||(U=1,process.env.NODE_ENV!=="production"&&function(){function l(e){if(e==null)return null;if(typeof e=="function")return e.$$typeof===te?null:e.displayName||e.name||null;if(typeof e=="string")return e;switch(e){case g:return"Fragment";case C:return"Profiler";case j:return"StrictMode";case F:return"Suspense";case A:return"SuspenseList";case re:return"Activity"}if(typeof e=="object")switch(typeof e.tag=="number"&&console.error("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."),e.$$typeof){case N:return"Portal";case Y:return(e.displayName||"Context")+".Provider";case S:return(e._context.displayName||"Context")+".Consumer";case $:var r=e.render;return e=e.displayName,e||(e=r.displayName||r.name||"",e=e!==""?"ForwardRef("+e+")":"ForwardRef"),e;case q:return r=e.displayName||null,r!==null?r:l(e.type)||"Memo";case P:r=e._payload,e=e._init;try{return l(e(r))}catch{}}return null}function R(e){return""+e}function f(e){try{R(e);var r=!1}catch{r=!0}if(r){r=console;var t=r.error,n=typeof Symbol=="function"&&Symbol.toStringTag&&e[Symbol.toStringTag]||e.constructor.name||"Object";return t.call(r,"The provided key is an unsupported type %s. This value must be coerced to a string before using it here.",n),R(e)}}function d(e){if(e===g)return"<>";if(typeof e=="object"&&e!==null&&e.$$typeof===P)return"<...>";try{var r=l(e);return r?"<"+r+">":"<...>"}catch{return"<...>"}}function a(){var e=I.A;return e===null?null:e.getOwner()}function s(){return Error("react-stack-top-frame")}function m(e){if(J.call(e,"key")){var r=Object.getOwnPropertyDescriptor(e,"key").get;if(r&&r.isReactWarning)return!1}return e.key!==void 0}function E(e,r){function t(){V||(V=!0,console.error("%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://react.dev/link/special-props)",r))}t.isReactWarning=!0,Object.defineProperty(e,"key",{get:t,configurable:!0})}function k(){var e=l(this.type);return B[e]||(B[e]=!0,console.error("Accessing element.ref was removed in React 19. ref is now a regular prop. It will be removed from the JSX Element type in a future release.")),e=this.props.ref,e!==void 0?e:null}function y(e,r,t,n,u,c,M,L){return t=c.ref,e={$$typeof:h,type:e,key:r,props:c,_owner:u},(t!==void 0?t:null)!==null?Object.defineProperty(e,"ref",{enumerable:!1,get:k}):Object.defineProperty(e,"ref",{enumerable:!1,value:null}),e._store={},Object.defineProperty(e._store,"validated",{configurable:!1,enumerable:!1,writable:!0,value:0}),Object.defineProperty(e,"_debugInfo",{configurable:!1,enumerable:!1,writable:!0,value:null}),Object.defineProperty(e,"_debugStack",{configurable:!1,enumerable:!1,writable:!0,value:M}),Object.defineProperty(e,"_debugTask",{configurable:!1,enumerable:!1,writable:!0,value:L}),Object.freeze&&(Object.freeze(e.props),Object.freeze(e)),e}function x(e,r,t,n,u,c,M,L){var o=r.children;if(o!==void 0)if(n)if(ne(o)){for(n=0;n<o.length;n++)O(o[n]);Object.freeze&&Object.freeze(o)}else console.error("React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead.");else O(o);if(J.call(r,"key")){o=l(e);var v=Object.keys(r).filter(function(oe){return oe!=="key"});n=0<v.length?"{key: someKey, "+v.join(": ..., ")+": ...}":"{key: someKey}",Z[o+n]||(v=0<v.length?"{"+v.join(": ..., ")+": ...}":"{}",console.error(`A props object containing a "key" prop is being spread into JSX:
let props = %s;
<%s {...props} />
React keys must be passed directly to JSX without using spread:
let props = %s;
<%s key={someKey} {...props} />`,n,o,v,o),Z[o+n]=!0)}if(o=null,t!==void 0&&(f(t),o=""+t),m(r)&&(f(r.key),o=""+r.key),"key"in r){t={};for(var W in r)W!=="key"&&(t[W]=r[W])}else t=r;return o&&E(t,typeof e=="function"?e.displayName||e.name||"Unknown":e),y(e,o,c,u,a(),t,M,L)}function O(e){typeof e=="object"&&e!==null&&e.$$typeof===h&&e._store&&(e._store.validated=1)}var b=p,h=Symbol.for("react.transitional.element"),N=Symbol.for("react.portal"),g=Symbol.for("react.fragment"),j=Symbol.for("react.strict_mode"),C=Symbol.for("react.profiler"),S=Symbol.for("react.consumer"),Y=Symbol.for("react.context"),$=Symbol.for("react.forward_ref"),F=Symbol.for("react.suspense"),A=Symbol.for("react.suspense_list"),q=Symbol.for("react.memo"),P=Symbol.for("react.lazy"),re=Symbol.for("react.activity"),te=Symbol.for("react.client.reference"),I=b.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,J=Object.prototype.hasOwnProperty,ne=Array.isArray,D=console.createTask?console.createTask:function(){return null};b={"react-stack-bottom-frame":function(e){return e()}};var V,B={},X=b["react-stack-bottom-frame"].bind(b,s)(),H=D(d(s)),Z={};_.Fragment=g,_.jsx=function(e,r,t,n,u){var c=1e4>I.recentlyCreatedOwnerStacks++;return x(e,r,t,!1,n,u,c?Error("react-stack-top-frame"):X,c?D(d(e)):H)},_.jsxs=function(e,r,t,n,u){var c=1e4>I.recentlyCreatedOwnerStacks++;return x(e,r,t,!0,n,u,c?Error("react-stack-top-frame"):X,c?D(d(e)):H)}}()),_}var G;function ee(){return G||(G=1,process.env.NODE_ENV==="production"?i.exports=Q():i.exports=K()),i.exports}var w=ee();return({enabled:l=!0,sweepDuration:R=10,sweepThickness:f=10,sweepStyle:d="classic",scanlineOpacity:a=.2,scanlineColor:s="rgba(91, 179, 135, 0.2)",enableScanlines:m=!0,enableSweep:E=!0,theme:k="green",enableGlow:y=!1,glowColor:x="rgba(0, 255, 128, 0.3)",enableEdgeGlow:O=!1,edgeGlowColor:b="rgba(0, 255, 128, 0.2)",edgeGlowSize:h=30,enableFlicker:N=!1,scanlineOrientation:g="horizontal",children:j})=>{if(!l)return w.jsx(w.Fragment,{children:j});const C=F=>{const A=F.match(/rgba?\(\s*([\d\s.,]+)\)/);return A?A[1].split(",").map(P=>P.trim()).slice(0,3).join(", "):"91, 179, 135"},S={green:"91, 179, 135",amber:"255, 200, 100",blue:"100, 200, 255"},Y=k!=="custom"?S[k]??S.green:C(s),$=["crt-effect-wrapper",m&&"scanlines-on",E&&(d==="classic"?"sweep-on":"sweep-soft"),O&&"edge-glow-on",N&&"flicker-on"].filter(Boolean).join(" ");return w.jsx("div",{className:$,style:{position:"relative","--sweep-duration":`${R}s`,"--sweep-thickness":`${f}px`,"--scanline-opacity":a,"--scanline-color-rgb":Y,"--glow-color":x,"--edge-glow-color":b,"--edge-glow-size":`${h}px`,"--scanline-gradient-direction":g==="horizontal"?"to bottom":"to right"},children:w.jsx("div",{className:"crt-inner",style:{boxShadow:y?"0 0 6px var(--glow-color), 0 0 12px var(--glow-color), 0 0 20px var(--glow-color)":void 0},children:j})})}});