Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

nextjs-themes

Package Overview
Dependencies
Maintainers
0
Versions
39
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

nextjs-themes - npm Package Compare versions

Comparing version 4.0.0-alpha.3 to 4.0.0-alpha.4

chunk-HRERMBVW.mjs

2

client/index.d.ts

@@ -6,3 +6,5 @@ /**

*/
export * from "./force-theme";
export * from "./force-color-scheme";
export * from "./theme-switcher";
export * from "./color-switch";

2

client/index.js
"use client";
"use strict";var E=Object.defineProperty;var K=Object.getOwnPropertyDescriptor;var _=Object.getOwnPropertyNames;var q=Object.prototype.hasOwnProperty;var Q=(t,e)=>{for(var s in e)E(t,s,{get:e[s],enumerable:!0})},B=(t,e,s,p)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of _(e))!q.call(t,n)&&n!==s&&E(t,n,{get:()=>e[n],enumerable:!(p=K(e,n))||p.enumerable});return t};var W=t=>B(E({},"__esModule",{value:!0}),t);var re={};Q(re,{ColorSwitch:()=>oe,ThemeSwitcher:()=>te});module.exports=W(re);var k=require("react");var O=(t,e,s,p,n)=>{window.m=matchMedia(`(prefers-color-scheme:${e.d})`);let c=["color-scheme","csp","theme","th"];window.u=l=>{var b;let a=(b=document.querySelector(t))!=null?b:document.documentElement,T=[];c.forEach((w,C)=>{T.push(`${w}-${l[C]}`),a.setAttribute(`data-${w}`,l[C])}),T[0]=l[0],s&&(T=T.map(w=>{var C;return(C=s[w])!=null?C:w})),a.className=T.join(" ")};let d=localStorage.getItem(t),i={...d?JSON.parse(d):e,s:m.matches?e.d:e.l},o,h,P,R;window.f=(l,a)=>{h=R=l,o=P=a},window.g=(l,a)=>{h=R!=null?R:l,o=P!=null?P:a},f(p,n),window.r=l=>{let a=o!=null?o:l.c,T=a===e.c?l.s:a,b=T===""?l.t:T===e.d?l.d:l.l,w=h!=null?h:b;return[T||l.s,a,w,h!=null?h:l.t]},u(r(i))};var $=require("r18gs");var x="nth",S="light",v="dark",F="system";var U={t:"",d:v,l:S,c:F,s:S},D=t=>{let e=t!=null?t:`#${x}`;return(0,$.useRGS)(e,()=>{let s=typeof m!="undefined"&&localStorage.getItem(e);return s?{...JSON.parse(s),s:m.matches?v:S}:U})},L=t=>{let e=`${t!=null?t:`#${x}`}-`;return(0,$.useRGS)(e,{})};var y=require("react/jsx-runtime"),I,j,M,H,J,X=({targetSelector:t,nonce:e,styles:s,forcedTheme:p,forcedColorScheme:n})=>{let c=t||`#${x}`;return typeof window!="undefined"&&!window.m&&O(c,U,s,p,n),typeof m!="undefined"&&([I,j,M,H,J]=[m,u,r,f,g]),(0,y.jsx)("script",{dangerouslySetInnerHTML:{__html:`(${O})(${JSON.stringify([c,U,s,p,n]).slice(1,-1)})`},nonce:e})},Z=(t="none")=>{let e=document.createElement("style");return e.textContent=`transition: ${t.split(";")[0]} !important;`,document.head.appendChild(e),()=>{getComputedStyle(document.body),setTimeout(()=>document.head.removeChild(e),1)}},ee=({forcedTheme:t,forcedColorScheme:e,targetSelector:s,themeTransition:p})=>{let n=s||`#${x}`,[c,d]=D(s),[i]=L(s);return(0,k.useEffect)(()=>{I.addEventListener("change",()=>d(o=>({...o,s:I.matches?v:S}))),addEventListener("storage",o=>{o.key===n&&d(h=>({...h,...JSON.parse(o.newValue||"{}")}))})},[]),(0,k.useEffect)(()=>{let o=Z(p);j(M(c)),o(),localStorage.setItem(n,JSON.stringify(c))},[c]),(0,k.useEffect)(()=>{H(t,e),j(M(c))},[e,t]),(0,k.useEffect)(()=>{J(i.f,i.fc),j(M(c))},[i]),null},te=t=>(0,y.jsxs)(y.Fragment,{children:[(0,y.jsx)(X,{...t}),(0,y.jsx)(ee,{...t})]});var N={"color-switch":"nextjs-themes--color-switch",swing:"nextjs-themes--swing"};var z=[F,v,S],A,Y=t=>{let[e,s]=D(t),[p,n]=L(t);(0,k.useEffect)(()=>{A=window.r},[]);let c=i=>o=>s(h=>({...h,[i]:o})),d={theme:e.t,darkTheme:e.d,lightTheme:e.l,colorSchemePref:e.c,systemColorScheme:e.s,resolvedColorScheme:e.c===F||e.c===""?e.s:e.c,resolvedTheme:e.t,setTheme:c("t"),setDarkTheme:c("d"),setLightTheme:c("l"),setThemeSet:({darkTheme:i,lightTheme:o})=>s(h=>({...h,d:i,l:o})),setColorSchemePref:c("c"),toggleColorScheme(i){let o=z.indexOf(e.c),h=z.length;(o===-1||i&&o===h-1)&&(o=0),c("c")(z[(o+1)%h])},setForcedColorScheme:i=>n(o=>({...o,fc:i})),setForcedTheme:i=>n(o=>({...o,f:i}))};if(A){let i=A(e);d.resolvedColorScheme=i[0],d.resolvedTheme=i[1]}return d};var oe=({size:t=25,skipSystem:e,targetSelector:s,className:p,...n})=>{let{toggleColorScheme:c}=Y(s),d=[N["color-switch"],p].join(" ");return(0,y.jsx)("button",{className:d,onClick:()=>c(e),style:{"--size":`${t}px`},...n})};0&&(module.exports={ColorSwitch,ThemeSwitcher});
"use strict";var M=Object.defineProperty;var q=Object.getOwnPropertyDescriptor;var Q=Object.getOwnPropertyNames;var B=Object.prototype.hasOwnProperty;var W=(t,e)=>{for(var o in e)M(t,o,{get:e[o],enumerable:!0})},X=(t,e,o,c)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of Q(e))!B.call(t,n)&&n!==o&&M(t,n,{get:()=>e[n],enumerable:!(c=q(e,n))||c.enumerable});return t};var Z=t=>X(M({},"__esModule",{value:!0}),t);var me={};W(me,{ColorSwitch:()=>ne,ForceColorScheme:()=>te,ForceTheme:()=>ee,ThemeSwitcher:()=>ce});module.exports=Z(me);var H=require("react");var O=require("r18gs");var v="nth",S="light",C="dark",k="system";var D={t:"",d:C,l:S,c:k,s:S},L=t=>{let e=t!=null?t:`#${v}`;return(0,O.useRGS)(e,()=>{let o=typeof m!="undefined"&&localStorage.getItem(e);return o?{...JSON.parse(o),s:m.matches?C:S}:D})},y=t=>{let e=`${t!=null?t:`#${v}`}-`;return(0,O.useRGS)(e,{})};var ee=t=>{let[e,o]=y();return(0,H.useEffect)(()=>(o(c=>({...c,f:t.theme})),()=>{o(c=>({...c,f:void 0}))}),[t.theme]),null};var te=t=>{let[e,o]=y();return(0,H.useEffect)(()=>(o(c=>({...c,fc:t.colorScheme})),()=>{o(c=>({...c,fc:void 0}))}),[t.colorScheme]),null};var $=(t,e,o,c,n)=>{window.m=matchMedia("(prefers-color-scheme: dark)");let i=["color-scheme","csp","theme","th"];window.u=p=>{var U;let a=(U=document.querySelector(t))!=null?U:document.documentElement,T=[];i.forEach((x,F)=>{T.push(`${x}-${p[F]}`),a.setAttribute(`data-${x}`,p[F])}),T[0]=p[0],o&&(T=T.map(x=>{var F;return(F=o[x])!=null?F:x})),a.className=T.join(" ")};let d=localStorage.getItem(t),h={...d?JSON.parse(d):e,s:m.matches?e.d:e.l},s,l,R,b;window.f=(p,a)=>{l=b=p,s=R=a},window.g=(p,a)=>{l=b!=null?b:p,s=R!=null?R:a},f(c,n),window.r=p=>{let a=s!=null?s:p.c,T=a===e.c?p.s:a,U=T===""?p.t:T===e.d?p.d:p.l,x=l!=null?l:U;return[T||p.s,a,x,l!=null?l:p.t]},u(r(h))};var w=require("react/jsx-runtime"),I,E,j,N,V,oe=({targetSelector:t,nonce:e,styles:o,forcedTheme:c,forcedColorScheme:n})=>{let i=t||`#${v}`;return typeof window!="undefined"&&!window.m&&$(i,D,o,c,n),typeof m!="undefined"&&([I,E,j,N,V]=[m,u,r,f,g]),(0,w.jsx)("script",{dangerouslySetInnerHTML:{__html:`(${$})(${JSON.stringify([i,D,o,c,n]).slice(1,-1)})`},nonce:e})},re=(t="none")=>{let e=document.createElement("style");return e.textContent=`transition: ${t.split(";")[0]} !important;`,document.head.appendChild(e),()=>{getComputedStyle(document.body),setTimeout(()=>document.head.removeChild(e),1)}},se=({forcedTheme:t,forcedColorScheme:e,targetSelector:o,themeTransition:c})=>{let n=o||`#${v}`,[i,d]=L(o),[h]=y(o);return(0,H.useEffect)(()=>{I.addEventListener("change",()=>d(s=>({...s,s:I.matches?C:S}))),addEventListener("storage",s=>{s.key===n&&d(l=>({...l,...JSON.parse(s.newValue||"{}")}))})},[]),(0,H.useEffect)(()=>{let s=re(c);E(j(i)),s(),localStorage.setItem(n,JSON.stringify(i))},[i]),(0,H.useEffect)(()=>{N(t,e),E(j(i))},[e,t]),(0,H.useEffect)(()=>{V(h.f,h.fc),E(j(i))},[h]),null},ce=t=>(0,w.jsxs)(w.Fragment,{children:[(0,w.jsx)(oe,{...t}),(0,w.jsx)(se,{...t})]});var Y={"color-switch":"nextjs-themes--color-switch",swing:"nextjs-themes--swing"};var z=[k,C,S],A,G=t=>{let[e,o]=L(t),[c,n]=y(t);(0,H.useEffect)(()=>{A=window.r},[]);let i=h=>s=>o(l=>({...l,[h]:s})),d={theme:e.t,darkTheme:e.d,lightTheme:e.l,colorSchemePref:e.c,systemColorScheme:e.s,resolvedColorScheme:e.c===k||e.c===""?e.s:e.c,resolvedTheme:e.t,setTheme:i("t"),setDarkTheme:i("d"),setLightTheme:i("l"),setThemeSet:({darkTheme:h,lightTheme:s})=>o(l=>({...l,d:h,l:s})),setColorSchemePref:i("c"),toggleColorScheme(h){let s=z.indexOf(e.c),l=z.length;(s===-1||h&&s===l-1)&&(s=0),i("c")(z[(s+1)%l])},setForcedColorScheme:h=>n(s=>({...s,fc:h})),setForcedTheme:h=>n(s=>({...s,f:h}))};if(A){let h=A(e);d.resolvedColorScheme=h[0],d.resolvedTheme=h[1]}return d};var ne=({size:t=25,skipSystem:e,targetSelector:o,className:c,...n})=>{let{toggleColorScheme:i}=G(o),d=[Y["color-switch"],c].join(" ");return(0,w.jsx)("button",{className:d,onClick:()=>i(e),style:{"--size":`${t}px`},...n})};0&&(module.exports={ColorSwitch,ForceColorScheme,ForceTheme,ThemeSwitcher});
"use client";
"use strict";var E=Object.defineProperty;var G=Object.getOwnPropertyDescriptor;var H=Object.getOwnPropertyNames;var b=Object.prototype.hasOwnProperty;var K=(t,e)=>{for(var o in e)E(t,o,{get:e[o],enumerable:!0})},_=(t,e,o,h)=>{if(e&&typeof e=="object"||typeof e=="function")for(let s of H(e))!b.call(t,s)&&s!==o&&E(t,s,{get:()=>e[s],enumerable:!(h=G(e,s))||h.enumerable});return t};var q=t=>_(E({},"__esModule",{value:!0}),t);var B={};K(B,{ThemeSwitcher:()=>z});module.exports=q(B);var x=require("react");var L=(t,e,o,h,s)=>{window.m=matchMedia(`(prefers-color-scheme:${e.d})`);let p=["color-scheme","csp","theme","th"];window.u=n=>{var R;let d=(R=document.querySelector(t))!=null?R:document.documentElement,l=[];p.forEach((a,v)=>{l.push(`${a}-${n[v]}`),d.setAttribute(`data-${a}`,n[v])}),l[0]=n[0],o&&(l=l.map(a=>{var v;return(v=o[a])!=null?v:a})),d.className=l.join(" ")};let F=localStorage.getItem(t),w={...F?JSON.parse(F):e,s:m.matches?e.d:e.l},c,i,U,D;window.f=(n,d)=>{i=D=n,c=U=d},window.g=(n,d)=>{i=D!=null?D:n,c=U!=null?U:d},f(h,s),window.r=n=>{let d=c!=null?c:n.c,l=d===e.c?n.s:d,R=l===""?n.t:l===e.d?n.d:n.l,a=i!=null?i:R;return[l||n.s,d,a,i!=null?i:n.t]},u(r(w))};var M=require("r18gs");var y="nth",S="light",C="dark",A="system";var O={t:"",d:C,l:S,c:A,s:S},k=t=>{let e=t!=null?t:`#${y}`;return(0,M.useRGS)(e,()=>{let o=typeof m!="undefined"&&localStorage.getItem(e);return o?{...JSON.parse(o),s:m.matches?C:S}:O})},J=t=>{let e=`${t!=null?t:`#${y}`}-`;return(0,M.useRGS)(e,{})};var T=require("react/jsx-runtime"),I,P,$,N,V,Q=({targetSelector:t,nonce:e,styles:o,forcedTheme:h,forcedColorScheme:s})=>{let p=t||`#${y}`;return typeof window!="undefined"&&!window.m&&L(p,O,o,h,s),typeof m!="undefined"&&([I,P,$,N,V]=[m,u,r,f,g]),(0,T.jsx)("script",{dangerouslySetInnerHTML:{__html:`(${L})(${JSON.stringify([p,O,o,h,s]).slice(1,-1)})`},nonce:e})},Y=(t="none")=>{let e=document.createElement("style");return e.textContent=`transition: ${t.split(";")[0]} !important;`,document.head.appendChild(e),()=>{getComputedStyle(document.body),setTimeout(()=>document.head.removeChild(e),1)}},j=({forcedTheme:t,forcedColorScheme:e,targetSelector:o,themeTransition:h})=>{let s=o||`#${y}`,[p,F]=k(o),[w]=J(o);return(0,x.useEffect)(()=>{I.addEventListener("change",()=>F(c=>({...c,s:I.matches?C:S}))),addEventListener("storage",c=>{c.key===s&&F(i=>({...i,...JSON.parse(c.newValue||"{}")}))})},[]),(0,x.useEffect)(()=>{let c=Y(h);P($(p)),c(),localStorage.setItem(s,JSON.stringify(p))},[p]),(0,x.useEffect)(()=>{N(t,e),P($(p))},[e,t]),(0,x.useEffect)(()=>{V(w.f,w.fc),P($(p))},[w]),null},z=t=>(0,T.jsxs)(T.Fragment,{children:[(0,T.jsx)(Q,{...t}),(0,T.jsx)(j,{...t})]});0&&(module.exports={ThemeSwitcher});
"use strict";var L=Object.defineProperty;var G=Object.getOwnPropertyDescriptor;var H=Object.getOwnPropertyNames;var b=Object.prototype.hasOwnProperty;var K=(t,e)=>{for(var o in e)L(t,o,{get:e[o],enumerable:!0})},_=(t,e,o,a)=>{if(e&&typeof e=="object"||typeof e=="function")for(let s of H(e))!b.call(t,s)&&s!==o&&L(t,s,{get:()=>e[s],enumerable:!(a=G(e,s))||a.enumerable});return t};var q=t=>_(L({},"__esModule",{value:!0}),t);var B={};K(B,{ThemeSwitcher:()=>z});module.exports=q(B);var x=require("react");var M=(t,e,o,a,s)=>{window.m=matchMedia("(prefers-color-scheme: dark)");let p=["color-scheme","csp","theme","th"];window.u=n=>{var R;let d=(R=document.querySelector(t))!=null?R:document.documentElement,l=[];p.forEach((T,v)=>{l.push(`${T}-${n[v]}`),d.setAttribute(`data-${T}`,n[v])}),l[0]=n[0],o&&(l=l.map(T=>{var v;return(v=o[T])!=null?v:T})),d.className=l.join(" ")};let F=localStorage.getItem(t),w={...F?JSON.parse(F):e,s:m.matches?e.d:e.l},c,i,U,D;window.f=(n,d)=>{i=D=n,c=U=d},window.g=(n,d)=>{i=D!=null?D:n,c=U!=null?U:d},f(a,s),window.r=n=>{let d=c!=null?c:n.c,l=d===e.c?n.s:d,R=l===""?n.t:l===e.d?n.d:n.l,T=i!=null?i:R;return[l||n.s,d,T,i!=null?i:n.t]},u(r(w))};var $=require("r18gs");var y="nth",S="light",C="dark",k="system";var O={t:"",d:C,l:S,c:k,s:S},A=t=>{let e=t!=null?t:`#${y}`;return(0,$.useRGS)(e,()=>{let o=typeof m!="undefined"&&localStorage.getItem(e);return o?{...JSON.parse(o),s:m.matches?C:S}:O})},J=t=>{let e=`${t!=null?t:`#${y}`}-`;return(0,$.useRGS)(e,{})};var h=require("react/jsx-runtime"),I,P,E,N,V,Q=({targetSelector:t,nonce:e,styles:o,forcedTheme:a,forcedColorScheme:s})=>{let p=t||`#${y}`;return typeof window!="undefined"&&!window.m&&M(p,O,o,a,s),typeof m!="undefined"&&([I,P,E,N,V]=[m,u,r,f,g]),(0,h.jsx)("script",{dangerouslySetInnerHTML:{__html:`(${M})(${JSON.stringify([p,O,o,a,s]).slice(1,-1)})`},nonce:e})},Y=(t="none")=>{let e=document.createElement("style");return e.textContent=`transition: ${t.split(";")[0]} !important;`,document.head.appendChild(e),()=>{getComputedStyle(document.body),setTimeout(()=>document.head.removeChild(e),1)}},j=({forcedTheme:t,forcedColorScheme:e,targetSelector:o,themeTransition:a})=>{let s=o||`#${y}`,[p,F]=A(o),[w]=J(o);return(0,x.useEffect)(()=>{I.addEventListener("change",()=>F(c=>({...c,s:I.matches?C:S}))),addEventListener("storage",c=>{c.key===s&&F(i=>({...i,...JSON.parse(c.newValue||"{}")}))})},[]),(0,x.useEffect)(()=>{let c=Y(a);P(E(p)),c(),localStorage.setItem(s,JSON.stringify(p))},[p]),(0,x.useEffect)(()=>{N(t,e),P(E(p))},[e,t]),(0,x.useEffect)(()=>{V(w.f,w.fc),P(E(p))},[w]),null},z=t=>(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(Q,{...t}),(0,h.jsx)(j,{...t})]});0&&(module.exports={ThemeSwitcher});

@@ -1,1 +0,1 @@

"use strict";var S=Object.defineProperty;var C=Object.getOwnPropertyDescriptor;var U=Object.getOwnPropertyNames;var R=Object.prototype.hasOwnProperty;var M=(t,e)=>{for(var n in e)S(t,n,{get:e[n],enumerable:!0})},O=(t,e,n,a)=>{if(e&&typeof e=="object"||typeof e=="function")for(let d of U(e))!R.call(t,d)&&d!==n&&S(t,d,{get:()=>e[d],enumerable:!(a=C(e,d))||a.enumerable});return t};var P=t=>O(S({},"__esModule",{value:!0}),t);var $={};M($,{noFOUCScript:()=>V});module.exports=P($);var V=(t,e,n,a,d)=>{window.m=matchMedia(`(prefers-color-scheme:${e.d})`);let F=["color-scheme","csp","theme","th"];window.u=o=>{var i;let c=(i=document.querySelector(t))!=null?i:document.documentElement,p=[];F.forEach((l,h)=>{p.push(`${l}-${o[h]}`),c.setAttribute(`data-${l}`,o[h])}),p[0]=o[0],n&&(p=p.map(l=>{var h;return(h=n[l])!=null?h:l})),c.className=p.join(" ")};let v=localStorage.getItem(t),w={...v?JSON.parse(v):e,s:m.matches?e.d:e.l},y,s,T,g;window.f=(o,c)=>{s=g=o,y=T=c},window.g=(o,c)=>{s=g!=null?g:o,y=T!=null?T:c},f(a,d),window.r=o=>{let c=y!=null?y:o.c,p=c===e.c?o.s:c,i=p===""?o.t:p===e.d?o.d:o.l,l=s!=null?s:i;return[p||o.s,c,l,s!=null?s:o.t]},u(r(w))};0&&(module.exports={noFOUCScript});
"use strict";var S=Object.defineProperty;var C=Object.getOwnPropertyDescriptor;var U=Object.getOwnPropertyNames;var R=Object.prototype.hasOwnProperty;var M=(t,e)=>{for(var n in e)S(t,n,{get:e[n],enumerable:!0})},O=(t,e,n,h)=>{if(e&&typeof e=="object"||typeof e=="function")for(let d of U(e))!R.call(t,d)&&d!==n&&S(t,d,{get:()=>e[d],enumerable:!(h=C(e,d))||h.enumerable});return t};var P=t=>O(S({},"__esModule",{value:!0}),t);var x={};M(x,{noFOUCScript:()=>V});module.exports=P(x);var V=(t,e,n,h,d)=>{window.m=matchMedia("(prefers-color-scheme: dark)");let F=["color-scheme","csp","theme","th"];window.u=o=>{var g;let c=(g=document.querySelector(t))!=null?g:document.documentElement,p=[];F.forEach((l,a)=>{p.push(`${l}-${o[a]}`),c.setAttribute(`data-${l}`,o[a])}),p[0]=o[0],n&&(p=p.map(l=>{var a;return(a=n[l])!=null?a:l})),c.className=p.join(" ")};let v=localStorage.getItem(t),w={...v?JSON.parse(v):e,s:m.matches?e.d:e.l},y,s,T,i;window.f=(o,c)=>{s=i=o,y=T=c},window.g=(o,c)=>{s=i!=null?i:o,y=T!=null?T:c},f(h,d),window.r=o=>{let c=y!=null?y:o.c,p=c===e.c?o.s:c,g=p===""?o.t:p===e.d?o.d:o.l,l=s!=null?s:g;return[p||o.s,c,l,s!=null?s:o.t]},u(r(w))};0&&(module.exports={noFOUCScript});

@@ -1,1 +0,1 @@

"use strict";var E=Object.defineProperty;var G=Object.getOwnPropertyDescriptor;var H=Object.getOwnPropertyNames;var b=Object.prototype.hasOwnProperty;var K=(t,e)=>{for(var o in e)E(t,o,{get:e[o],enumerable:!0})},_=(t,e,o,h)=>{if(e&&typeof e=="object"||typeof e=="function")for(let s of H(e))!b.call(t,s)&&s!==o&&E(t,s,{get:()=>e[s],enumerable:!(h=G(e,s))||h.enumerable});return t};var q=t=>_(E({},"__esModule",{value:!0}),t);var B={};K(B,{ThemeSwitcher:()=>z});module.exports=q(B);var U=require("react");var L=(t,e,o,h,s)=>{window.m=matchMedia(`(prefers-color-scheme:${e.d})`);let p=["color-scheme","csp","theme","th"];window.u=n=>{var R;let d=(R=document.querySelector(t))!=null?R:document.documentElement,T=[];p.forEach((l,v)=>{T.push(`${l}-${n[v]}`),d.setAttribute(`data-${l}`,n[v])}),T[0]=n[0],o&&(T=T.map(l=>{var v;return(v=o[l])!=null?v:l})),d.className=T.join(" ")};let F=localStorage.getItem(t),w={...F?JSON.parse(F):e,s:m.matches?e.d:e.l},c,i,x,D;window.f=(n,d)=>{i=D=n,c=x=d},window.g=(n,d)=>{i=D!=null?D:n,c=x!=null?x:d},f(h,s),window.r=n=>{let d=c!=null?c:n.c,T=d===e.c?n.s:d,R=T===""?n.t:T===e.d?n.d:n.l,l=i!=null?i:R;return[T||n.s,d,l,i!=null?i:n.t]},u(r(w))};var M=require("r18gs");var y="nth",S="light",C="dark",A="system";var O={t:"",d:C,l:S,c:A,s:S},k=t=>{let e=t!=null?t:`#${y}`;return(0,M.useRGS)(e,()=>{let o=typeof m!="undefined"&&localStorage.getItem(e);return o?{...JSON.parse(o),s:m.matches?C:S}:O})},J=t=>{let e=`${t!=null?t:`#${y}`}-`;return(0,M.useRGS)(e,{})};var a=require("react/jsx-runtime"),I,P,$,N,V,Q=({targetSelector:t,nonce:e,styles:o,forcedTheme:h,forcedColorScheme:s})=>{let p=t||`#${y}`;return typeof window!="undefined"&&!window.m&&L(p,O,o,h,s),typeof m!="undefined"&&([I,P,$,N,V]=[m,u,r,f,g]),(0,a.jsx)("script",{dangerouslySetInnerHTML:{__html:`(${L})(${JSON.stringify([p,O,o,h,s]).slice(1,-1)})`},nonce:e})},Y=(t="none")=>{let e=document.createElement("style");return e.textContent=`transition: ${t.split(";")[0]} !important;`,document.head.appendChild(e),()=>{getComputedStyle(document.body),setTimeout(()=>document.head.removeChild(e),1)}},j=({forcedTheme:t,forcedColorScheme:e,targetSelector:o,themeTransition:h})=>{let s=o||`#${y}`,[p,F]=k(o),[w]=J(o);return(0,U.useEffect)(()=>{I.addEventListener("change",()=>F(c=>({...c,s:I.matches?C:S}))),addEventListener("storage",c=>{c.key===s&&F(i=>({...i,...JSON.parse(c.newValue||"{}")}))})},[]),(0,U.useEffect)(()=>{let c=Y(h);P($(p)),c(),localStorage.setItem(s,JSON.stringify(p))},[p]),(0,U.useEffect)(()=>{N(t,e),P($(p))},[e,t]),(0,U.useEffect)(()=>{V(w.f,w.fc),P($(p))},[w]),null},z=t=>(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(Q,{...t}),(0,a.jsx)(j,{...t})]});0&&(module.exports={ThemeSwitcher});
"use strict";var L=Object.defineProperty;var G=Object.getOwnPropertyDescriptor;var H=Object.getOwnPropertyNames;var b=Object.prototype.hasOwnProperty;var K=(t,e)=>{for(var o in e)L(t,o,{get:e[o],enumerable:!0})},_=(t,e,o,a)=>{if(e&&typeof e=="object"||typeof e=="function")for(let s of H(e))!b.call(t,s)&&s!==o&&L(t,s,{get:()=>e[s],enumerable:!(a=G(e,s))||a.enumerable});return t};var q=t=>_(L({},"__esModule",{value:!0}),t);var B={};K(B,{ThemeSwitcher:()=>z});module.exports=q(B);var U=require("react");var M=(t,e,o,a,s)=>{window.m=matchMedia("(prefers-color-scheme: dark)");let p=["color-scheme","csp","theme","th"];window.u=n=>{var R;let d=(R=document.querySelector(t))!=null?R:document.documentElement,h=[];p.forEach((T,v)=>{h.push(`${T}-${n[v]}`),d.setAttribute(`data-${T}`,n[v])}),h[0]=n[0],o&&(h=h.map(T=>{var v;return(v=o[T])!=null?v:T})),d.className=h.join(" ")};let F=localStorage.getItem(t),w={...F?JSON.parse(F):e,s:m.matches?e.d:e.l},c,i,x,D;window.f=(n,d)=>{i=D=n,c=x=d},window.g=(n,d)=>{i=D!=null?D:n,c=x!=null?x:d},f(a,s),window.r=n=>{let d=c!=null?c:n.c,h=d===e.c?n.s:d,R=h===""?n.t:h===e.d?n.d:n.l,T=i!=null?i:R;return[h||n.s,d,T,i!=null?i:n.t]},u(r(w))};var $=require("r18gs");var y="nth",S="light",C="dark",k="system";var O={t:"",d:C,l:S,c:k,s:S},A=t=>{let e=t!=null?t:`#${y}`;return(0,$.useRGS)(e,()=>{let o=typeof m!="undefined"&&localStorage.getItem(e);return o?{...JSON.parse(o),s:m.matches?C:S}:O})},J=t=>{let e=`${t!=null?t:`#${y}`}-`;return(0,$.useRGS)(e,{})};var l=require("react/jsx-runtime"),I,P,E,N,V,Q=({targetSelector:t,nonce:e,styles:o,forcedTheme:a,forcedColorScheme:s})=>{let p=t||`#${y}`;return typeof window!="undefined"&&!window.m&&M(p,O,o,a,s),typeof m!="undefined"&&([I,P,E,N,V]=[m,u,r,f,g]),(0,l.jsx)("script",{dangerouslySetInnerHTML:{__html:`(${M})(${JSON.stringify([p,O,o,a,s]).slice(1,-1)})`},nonce:e})},Y=(t="none")=>{let e=document.createElement("style");return e.textContent=`transition: ${t.split(";")[0]} !important;`,document.head.appendChild(e),()=>{getComputedStyle(document.body),setTimeout(()=>document.head.removeChild(e),1)}},j=({forcedTheme:t,forcedColorScheme:e,targetSelector:o,themeTransition:a})=>{let s=o||`#${y}`,[p,F]=A(o),[w]=J(o);return(0,U.useEffect)(()=>{I.addEventListener("change",()=>F(c=>({...c,s:I.matches?C:S}))),addEventListener("storage",c=>{c.key===s&&F(i=>({...i,...JSON.parse(c.newValue||"{}")}))})},[]),(0,U.useEffect)(()=>{let c=Y(a);P(E(p)),c(),localStorage.setItem(s,JSON.stringify(p))},[p]),(0,U.useEffect)(()=>{N(t,e),P(E(p))},[e,t]),(0,U.useEffect)(()=>{V(w.f,w.fc),P(E(p))},[w]),null},z=t=>(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)(Q,{...t}),(0,l.jsx)(j,{...t})]});0&&(module.exports={ThemeSwitcher});
"use client";
"use strict";var E=Object.defineProperty;var K=Object.getOwnPropertyDescriptor;var _=Object.getOwnPropertyNames;var q=Object.prototype.hasOwnProperty;var Q=(t,e)=>{for(var s in e)E(t,s,{get:e[s],enumerable:!0})},B=(t,e,s,p)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of _(e))!q.call(t,n)&&n!==s&&E(t,n,{get:()=>e[n],enumerable:!(p=K(e,n))||p.enumerable});return t};var W=t=>B(E({},"__esModule",{value:!0}),t);var re={};Q(re,{ColorSwitch:()=>oe,ThemeSwitcher:()=>te,useTheme:()=>H});module.exports=W(re);var k=require("react");var O=(t,e,s,p,n)=>{window.m=matchMedia(`(prefers-color-scheme:${e.d})`);let c=["color-scheme","csp","theme","th"];window.u=l=>{var b;let a=(b=document.querySelector(t))!=null?b:document.documentElement,T=[];c.forEach((w,C)=>{T.push(`${w}-${l[C]}`),a.setAttribute(`data-${w}`,l[C])}),T[0]=l[0],s&&(T=T.map(w=>{var C;return(C=s[w])!=null?C:w})),a.className=T.join(" ")};let d=localStorage.getItem(t),i={...d?JSON.parse(d):e,s:m.matches?e.d:e.l},o,h,P,R;window.f=(l,a)=>{h=R=l,o=P=a},window.g=(l,a)=>{h=R!=null?R:l,o=P!=null?P:a},f(p,n),window.r=l=>{let a=o!=null?o:l.c,T=a===e.c?l.s:a,b=T===""?l.t:T===e.d?l.d:l.l,w=h!=null?h:b;return[T||l.s,a,w,h!=null?h:l.t]},u(r(i))};var $=require("r18gs");var v="nth",S="light",x="dark",F="system";var U={t:"",d:x,l:S,c:F,s:S},D=t=>{let e=t!=null?t:`#${v}`;return(0,$.useRGS)(e,()=>{let s=typeof m!="undefined"&&localStorage.getItem(e);return s?{...JSON.parse(s),s:m.matches?x:S}:U})},L=t=>{let e=`${t!=null?t:`#${v}`}-`;return(0,$.useRGS)(e,{})};var y=require("react/jsx-runtime"),I,j,M,J,N,X=({targetSelector:t,nonce:e,styles:s,forcedTheme:p,forcedColorScheme:n})=>{let c=t||`#${v}`;return typeof window!="undefined"&&!window.m&&O(c,U,s,p,n),typeof m!="undefined"&&([I,j,M,J,N]=[m,u,r,f,g]),(0,y.jsx)("script",{dangerouslySetInnerHTML:{__html:`(${O})(${JSON.stringify([c,U,s,p,n]).slice(1,-1)})`},nonce:e})},Z=(t="none")=>{let e=document.createElement("style");return e.textContent=`transition: ${t.split(";")[0]} !important;`,document.head.appendChild(e),()=>{getComputedStyle(document.body),setTimeout(()=>document.head.removeChild(e),1)}},ee=({forcedTheme:t,forcedColorScheme:e,targetSelector:s,themeTransition:p})=>{let n=s||`#${v}`,[c,d]=D(s),[i]=L(s);return(0,k.useEffect)(()=>{I.addEventListener("change",()=>d(o=>({...o,s:I.matches?x:S}))),addEventListener("storage",o=>{o.key===n&&d(h=>({...h,...JSON.parse(o.newValue||"{}")}))})},[]),(0,k.useEffect)(()=>{let o=Z(p);j(M(c)),o(),localStorage.setItem(n,JSON.stringify(c))},[c]),(0,k.useEffect)(()=>{J(t,e),j(M(c))},[e,t]),(0,k.useEffect)(()=>{N(i.f,i.fc),j(M(c))},[i]),null},te=t=>(0,y.jsxs)(y.Fragment,{children:[(0,y.jsx)(X,{...t}),(0,y.jsx)(ee,{...t})]});var V={"color-switch":"nextjs-themes--color-switch",swing:"nextjs-themes--swing"};var z=[F,x,S],A,H=t=>{let[e,s]=D(t),[p,n]=L(t);(0,k.useEffect)(()=>{A=window.r},[]);let c=i=>o=>s(h=>({...h,[i]:o})),d={theme:e.t,darkTheme:e.d,lightTheme:e.l,colorSchemePref:e.c,systemColorScheme:e.s,resolvedColorScheme:e.c===F||e.c===""?e.s:e.c,resolvedTheme:e.t,setTheme:c("t"),setDarkTheme:c("d"),setLightTheme:c("l"),setThemeSet:({darkTheme:i,lightTheme:o})=>s(h=>({...h,d:i,l:o})),setColorSchemePref:c("c"),toggleColorScheme(i){let o=z.indexOf(e.c),h=z.length;(o===-1||i&&o===h-1)&&(o=0),c("c")(z[(o+1)%h])},setForcedColorScheme:i=>n(o=>({...o,fc:i})),setForcedTheme:i=>n(o=>({...o,f:i}))};if(A){let i=A(e);d.resolvedColorScheme=i[0],d.resolvedTheme=i[1]}return d};var oe=({size:t=25,skipSystem:e,targetSelector:s,className:p,...n})=>{let{toggleColorScheme:c}=H(s),d=[V["color-switch"],p].join(" ");return(0,y.jsx)("button",{className:d,onClick:()=>c(e),style:{"--size":`${t}px`},...n})};0&&(module.exports={ColorSwitch,ThemeSwitcher,useTheme});
"use strict";var M=Object.defineProperty;var q=Object.getOwnPropertyDescriptor;var Q=Object.getOwnPropertyNames;var B=Object.prototype.hasOwnProperty;var W=(t,e)=>{for(var o in e)M(t,o,{get:e[o],enumerable:!0})},X=(t,e,o,c)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of Q(e))!B.call(t,n)&&n!==o&&M(t,n,{get:()=>e[n],enumerable:!(c=q(e,n))||c.enumerable});return t};var Z=t=>X(M({},"__esModule",{value:!0}),t);var me={};W(me,{ColorSwitch:()=>ne,ForceColorScheme:()=>te,ForceTheme:()=>ee,ThemeSwitcher:()=>ce,useTheme:()=>H});module.exports=Z(me);var J=require("react");var O=require("r18gs");var v="nth",S="light",C="dark",k="system";var D={t:"",d:C,l:S,c:k,s:S},L=t=>{let e=t!=null?t:`#${v}`;return(0,O.useRGS)(e,()=>{let o=typeof m!="undefined"&&localStorage.getItem(e);return o?{...JSON.parse(o),s:m.matches?C:S}:D})},y=t=>{let e=`${t!=null?t:`#${v}`}-`;return(0,O.useRGS)(e,{})};var ee=t=>{let[e,o]=y();return(0,J.useEffect)(()=>(o(c=>({...c,f:t.theme})),()=>{o(c=>({...c,f:void 0}))}),[t.theme]),null};var te=t=>{let[e,o]=y();return(0,J.useEffect)(()=>(o(c=>({...c,fc:t.colorScheme})),()=>{o(c=>({...c,fc:void 0}))}),[t.colorScheme]),null};var $=(t,e,o,c,n)=>{window.m=matchMedia("(prefers-color-scheme: dark)");let i=["color-scheme","csp","theme","th"];window.u=p=>{var U;let a=(U=document.querySelector(t))!=null?U:document.documentElement,T=[];i.forEach((x,F)=>{T.push(`${x}-${p[F]}`),a.setAttribute(`data-${x}`,p[F])}),T[0]=p[0],o&&(T=T.map(x=>{var F;return(F=o[x])!=null?F:x})),a.className=T.join(" ")};let d=localStorage.getItem(t),h={...d?JSON.parse(d):e,s:m.matches?e.d:e.l},s,l,R,b;window.f=(p,a)=>{l=b=p,s=R=a},window.g=(p,a)=>{l=b!=null?b:p,s=R!=null?R:a},f(c,n),window.r=p=>{let a=s!=null?s:p.c,T=a===e.c?p.s:a,U=T===""?p.t:T===e.d?p.d:p.l,x=l!=null?l:U;return[T||p.s,a,x,l!=null?l:p.t]},u(r(h))};var w=require("react/jsx-runtime"),I,E,j,V,Y,oe=({targetSelector:t,nonce:e,styles:o,forcedTheme:c,forcedColorScheme:n})=>{let i=t||`#${v}`;return typeof window!="undefined"&&!window.m&&$(i,D,o,c,n),typeof m!="undefined"&&([I,E,j,V,Y]=[m,u,r,f,g]),(0,w.jsx)("script",{dangerouslySetInnerHTML:{__html:`(${$})(${JSON.stringify([i,D,o,c,n]).slice(1,-1)})`},nonce:e})},re=(t="none")=>{let e=document.createElement("style");return e.textContent=`transition: ${t.split(";")[0]} !important;`,document.head.appendChild(e),()=>{getComputedStyle(document.body),setTimeout(()=>document.head.removeChild(e),1)}},se=({forcedTheme:t,forcedColorScheme:e,targetSelector:o,themeTransition:c})=>{let n=o||`#${v}`,[i,d]=L(o),[h]=y(o);return(0,J.useEffect)(()=>{I.addEventListener("change",()=>d(s=>({...s,s:I.matches?C:S}))),addEventListener("storage",s=>{s.key===n&&d(l=>({...l,...JSON.parse(s.newValue||"{}")}))})},[]),(0,J.useEffect)(()=>{let s=re(c);E(j(i)),s(),localStorage.setItem(n,JSON.stringify(i))},[i]),(0,J.useEffect)(()=>{V(t,e),E(j(i))},[e,t]),(0,J.useEffect)(()=>{Y(h.f,h.fc),E(j(i))},[h]),null},ce=t=>(0,w.jsxs)(w.Fragment,{children:[(0,w.jsx)(oe,{...t}),(0,w.jsx)(se,{...t})]});var _={"color-switch":"nextjs-themes--color-switch",swing:"nextjs-themes--swing"};var z=[k,C,S],A,H=t=>{let[e,o]=L(t),[c,n]=y(t);(0,J.useEffect)(()=>{A=window.r},[]);let i=h=>s=>o(l=>({...l,[h]:s})),d={theme:e.t,darkTheme:e.d,lightTheme:e.l,colorSchemePref:e.c,systemColorScheme:e.s,resolvedColorScheme:e.c===k||e.c===""?e.s:e.c,resolvedTheme:e.t,setTheme:i("t"),setDarkTheme:i("d"),setLightTheme:i("l"),setThemeSet:({darkTheme:h,lightTheme:s})=>o(l=>({...l,d:h,l:s})),setColorSchemePref:i("c"),toggleColorScheme(h){let s=z.indexOf(e.c),l=z.length;(s===-1||h&&s===l-1)&&(s=0),i("c")(z[(s+1)%l])},setForcedColorScheme:h=>n(s=>({...s,fc:h})),setForcedTheme:h=>n(s=>({...s,f:h}))};if(A){let h=A(e);d.resolvedColorScheme=h[0],d.resolvedTheme=h[1]}return d};var ne=({size:t=25,skipSystem:e,targetSelector:o,className:c,...n})=>{let{toggleColorScheme:i}=H(o),d=[_["color-switch"],c].join(" ");return(0,w.jsx)("button",{className:d,onClick:()=>i(e),style:{"--size":`${t}px`},...n})};0&&(module.exports={ColorSwitch,ForceColorScheme,ForceTheme,ThemeSwitcher,useTheme});

@@ -5,3 +5,3 @@ {

"private": false,
"version": "4.0.0-alpha.3",
"version": "4.0.0-alpha.4",
"description": "Unleash the Power of React Server Components! Use multiple themes on your site with confidence, without losing any advantages of React Server Components.",

@@ -8,0 +8,0 @@ "license": "MPL-2.0",

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc