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

next-themes

Package Overview
Dependencies
Maintainers
2
Versions
53
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

next-themes - npm Package Compare versions

Comparing version 0.4.3 to 0.4.4

2

dist/index.js

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

"use client";var _=Object.create;var R=Object.defineProperty;var H=Object.getOwnPropertyDescriptor;var V=Object.getOwnPropertyNames;var W=Object.getPrototypeOf,$=Object.prototype.hasOwnProperty;var j=(e,s)=>{for(var n in s)R(e,n,{get:s[n],enumerable:!0})},M=(e,s,n,m)=>{if(s&&typeof s=="object"||typeof s=="function")for(let o of V(s))!$.call(e,o)&&o!==n&&R(e,o,{get:()=>s[o],enumerable:!(m=H(s,o))||m.enumerable});return e};var z=(e,s,n)=>(n=e!=null?_(W(e)):{},M(s||!e||!e.__esModule?R(n,"default",{value:e,enumerable:!0}):n,e)),J=e=>M(R({},"__esModule",{value:!0}),e);var ee={};j(ee,{ThemeProvider:()=>G,useTheme:()=>F});module.exports=J(ee);var t=z(require("react"));var b=(e,s,n,m,o,l,u,h)=>{let c=document.documentElement,T=["light","dark"];function p(d){(Array.isArray(e)?e:[e]).forEach(g=>{let k=g==="class",S=k&&l?o.map(f=>l[f]||f):o;k?(c.classList.remove(...S),c.classList.add(d)):c.setAttribute(g,d)}),C(d)}function C(d){h&&T.includes(d)&&(c.style.colorScheme=d)}function a(){return window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"}if(m)p(m);else try{let d=localStorage.getItem(s)||n,g=u&&d==="system"?a():d;p(g)}catch(d){}};var I=["light","dark"],O="(prefers-color-scheme: dark)",q=typeof window=="undefined",x=t.createContext(void 0),B={setTheme:e=>{},themes:[]},F=()=>{var e;return(e=t.useContext(x))!=null?e:B},G=e=>t.useContext(x)?t.createElement(t.Fragment,null,e.children):t.createElement(Y,{...e}),X=["light","dark"],Y=({forcedTheme:e,disableTransitionOnChange:s=!1,enableSystem:n=!0,enableColorScheme:m=!0,storageKey:o="theme",themes:l=X,defaultTheme:u=n?"system":"light",attribute:h="data-theme",value:c,children:T,nonce:p,scriptProps:C})=>{let[a,d]=t.useState(()=>Q(o,u)),[w,g]=t.useState(()=>Q(o)),k=c?Object.values(c):l,S=t.useCallback(r=>{let i=r;if(!i)return;r==="system"&&n&&(i=D());let y=c?c[i]:i,E=s?K(p):null,P=document.documentElement,L=v=>{v==="class"?(P.classList.remove(...k),y&&P.classList.add(y)):v.startsWith("data-")&&(y?P.setAttribute(v,y):P.removeAttribute(v))};if(Array.isArray(h)?h.forEach(L):L(h),m){let v=I.includes(u)?u:null,N=I.includes(i)?i:v;P.style.colorScheme=N}E==null||E()},[p]),f=t.useCallback(r=>{let i=typeof r=="function"?r(a):r;d(i);try{localStorage.setItem(o,i)}catch(y){}},[a]),A=t.useCallback(r=>{let i=D(r);g(i),a==="system"&&n&&!e&&S("system")},[a,e]);t.useEffect(()=>{let r=window.matchMedia(O);return r.addListener(A),A(r),()=>r.removeListener(A)},[A]),t.useEffect(()=>{let r=i=>{if(i.key!==o)return;let y=i.newValue||u;f(y)};return window.addEventListener("storage",r),()=>window.removeEventListener("storage",r)},[f]),t.useEffect(()=>{S(e!=null?e:a)},[e,a]);let U=t.useMemo(()=>({theme:a,setTheme:f,forcedTheme:e,resolvedTheme:a==="system"?w:a,themes:n?[...l,"system"]:l,systemTheme:n?w:void 0}),[a,f,e,w,n,l]);return t.createElement(x.Provider,{value:U},t.createElement(Z,{forcedTheme:e,storageKey:o,attribute:h,enableSystem:n,enableColorScheme:m,defaultTheme:u,value:c,themes:l,nonce:p,scriptProps:C}),T)},Z=t.memo(({forcedTheme:e,storageKey:s,attribute:n,enableSystem:m,enableColorScheme:o,defaultTheme:l,value:u,themes:h,nonce:c,scriptProps:T})=>{let p=JSON.stringify([n,s,l,e,h,u,m,o]).slice(1,-1);return t.createElement("script",{...T,suppressHydrationWarning:!0,nonce:typeof window=="undefined"?c:"",dangerouslySetInnerHTML:{__html:`(${b.toString()})(${p})`}})}),Q=(e,s)=>{if(q)return;let n;try{n=localStorage.getItem(e)||void 0}catch(m){}return n||s},K=e=>{let s=document.createElement("style");return e&&s.setAttribute("nonce",e),s.appendChild(document.createTextNode("*,*::before,*::after{-webkit-transition:none!important;-moz-transition:none!important;-o-transition:none!important;-ms-transition:none!important;transition:none!important}")),document.head.appendChild(s),()=>{window.getComputedStyle(document.body),setTimeout(()=>{document.head.removeChild(s)},1)}},D=e=>(e||(e=window.matchMedia(O)),e.matches?"dark":"light");0&&(module.exports={ThemeProvider,useTheme});
"use client";var V=Object.create;var R=Object.defineProperty;var _=Object.getOwnPropertyDescriptor;var H=Object.getOwnPropertyNames;var W=Object.getPrototypeOf,$=Object.prototype.hasOwnProperty;var j=(e,s)=>{for(var n in s)R(e,n,{get:s[n],enumerable:!0})},M=(e,s,n,m)=>{if(s&&typeof s=="object"||typeof s=="function")for(let o of H(s))!$.call(e,o)&&o!==n&&R(e,o,{get:()=>s[o],enumerable:!(m=_(s,o))||m.enumerable});return e};var z=(e,s,n)=>(n=e!=null?V(W(e)):{},M(s||!e||!e.__esModule?R(n,"default",{value:e,enumerable:!0}):n,e)),J=e=>M(R({},"__esModule",{value:!0}),e);var ee={};j(ee,{ThemeProvider:()=>G,useTheme:()=>F});module.exports=J(ee);var t=z(require("react"));var b=(e,s,n,m,o,l,u,h)=>{let a=document.documentElement,v=["light","dark"];function p(c){(Array.isArray(e)?e:[e]).forEach(y=>{let k=y==="class",S=k&&l?o.map(f=>l[f]||f):o;k?(a.classList.remove(...S),a.classList.add(c)):a.setAttribute(y,c)}),C(c)}function C(c){h&&v.includes(c)&&(a.style.colorScheme=c)}function d(){return window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"}if(m)p(m);else try{let c=localStorage.getItem(s)||n,y=u&&c==="system"?d():c;p(y)}catch(c){}};var I=["light","dark"],O="(prefers-color-scheme: dark)",q=typeof window=="undefined",x=t.createContext(void 0),B={setTheme:e=>{},themes:[]},F=()=>{var e;return(e=t.useContext(x))!=null?e:B},G=e=>t.useContext(x)?t.createElement(t.Fragment,null,e.children):t.createElement(Y,{...e}),X=["light","dark"],Y=({forcedTheme:e,disableTransitionOnChange:s=!1,enableSystem:n=!0,enableColorScheme:m=!0,storageKey:o="theme",themes:l=X,defaultTheme:u=n?"system":"light",attribute:h="data-theme",value:a,children:v,nonce:p,scriptProps:C})=>{let[d,c]=t.useState(()=>Q(o,u)),[w,y]=t.useState(()=>Q(o)),k=a?Object.values(a):l,S=t.useCallback(r=>{let i=r;if(!i)return;r==="system"&&n&&(i=D());let T=a?a[i]:i,E=s?K(p):null,P=document.documentElement,L=g=>{g==="class"?(P.classList.remove(...k),T&&P.classList.add(T)):g.startsWith("data-")&&(T?P.setAttribute(g,T):P.removeAttribute(g))};if(Array.isArray(h)?h.forEach(L):L(h),m){let g=I.includes(u)?u:null,N=I.includes(i)?i:g;P.style.colorScheme=N}E==null||E()},[p]),f=t.useCallback(r=>{let i=typeof r=="function"?r(d):r;c(i);try{localStorage.setItem(o,i)}catch(T){}},[d]),A=t.useCallback(r=>{let i=D(r);y(i),d==="system"&&n&&!e&&S("system")},[d,e]);t.useEffect(()=>{let r=window.matchMedia(O);return r.addListener(A),A(r),()=>r.removeListener(A)},[A]),t.useEffect(()=>{let r=i=>{i.key===o&&(i.newValue?c(i.newValue):f(u))};return window.addEventListener("storage",r),()=>window.removeEventListener("storage",r)},[f]),t.useEffect(()=>{S(e!=null?e:d)},[e,d]);let U=t.useMemo(()=>({theme:d,setTheme:f,forcedTheme:e,resolvedTheme:d==="system"?w:d,themes:n?[...l,"system"]:l,systemTheme:n?w:void 0}),[d,f,e,w,n,l]);return t.createElement(x.Provider,{value:U},t.createElement(Z,{forcedTheme:e,storageKey:o,attribute:h,enableSystem:n,enableColorScheme:m,defaultTheme:u,value:a,themes:l,nonce:p,scriptProps:C}),v)},Z=t.memo(({forcedTheme:e,storageKey:s,attribute:n,enableSystem:m,enableColorScheme:o,defaultTheme:l,value:u,themes:h,nonce:a,scriptProps:v})=>{let p=JSON.stringify([n,s,l,e,h,u,m,o]).slice(1,-1);return t.createElement("script",{...v,suppressHydrationWarning:!0,nonce:typeof window=="undefined"?a:"",dangerouslySetInnerHTML:{__html:`(${b.toString()})(${p})`}})}),Q=(e,s)=>{if(q)return;let n;try{n=localStorage.getItem(e)||void 0}catch(m){}return n||s},K=e=>{let s=document.createElement("style");return e&&s.setAttribute("nonce",e),s.appendChild(document.createTextNode("*,*::before,*::after{-webkit-transition:none!important;-moz-transition:none!important;-o-transition:none!important;-ms-transition:none!important;transition:none!important}")),document.head.appendChild(s),()=>{window.getComputedStyle(document.body),setTimeout(()=>{document.head.removeChild(s)},1)}},D=e=>(e||(e=window.matchMedia(O)),e.matches?"dark":"light");0&&(module.exports={ThemeProvider,useTheme});
{
"name": "next-themes",
"version": "0.4.3",
"version": "0.4.4",
"license": "MIT",

@@ -5,0 +5,0 @@ "main": "./dist/index.js",

@@ -114,3 +114,3 @@ # next-themes ![next-themes minzip package size](https://img.shields.io/bundlephobia/minzip/next-themes) [![Version](https://img.shields.io/npm/v/next-themes.svg?colorB=green)](https://www.npmjs.com/package/next-themes)

> **Note!** If you set the attribute of your Theme Provider to class for Tailwind next-themes will modify the `class` attribute on the `html` element. See [With Tailwind](#with-tailwind).
> **Note!** If you set the attribute of your Theme Provider to class for Tailwind next-themes will modify the `class` attribute on the `html` element. See [With TailwindCSS](#with-tailwindcss).

@@ -117,0 +117,0 @@ ### useTheme

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