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

use-prefers-color-scheme

Package Overview
Dependencies
Maintainers
1
Versions
18
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

use-prefers-color-scheme - npm Package Compare versions

Comparing version 1.0.0 to 1.1.0

2

dist/index.cjs.js

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

"use strict";(()=>{var d=(t=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(t,{get:(o,i)=>(typeof require<"u"?require:o)[i]}):t)(function(t){if(typeof require<"u")return require.apply(this,arguments);throw new Error('Dynamic require of "'+t+'" is not supported')});var r=d("react"),h,e=(h=window.matchMedia)==null?void 0:h.call(window,"(prefers-color-scheme: dark)"),m,n=(m=window.matchMedia)==null?void 0:m.call(window,"(prefers-color-scheme: light)"),v=()=>{let t=e==null?void 0:e.matches,o=n==null?void 0:n.matches,[i,c]=(0,r.useState)(t?"dark":o?"light":"no-preference");return(0,r.useEffect)(()=>{c(t?"dark":o?"light":"no-preference")},[t,o]),(0,r.useEffect)(()=>{if(typeof(e==null?void 0:e.addEventListener)=="function"){let s=({matches:a})=>a&&c("dark"),f=({matches:a})=>a&&c("light");return e==null||e.addEventListener("change",s),n==null||n.addEventListener("change",f),()=>{e==null||e.removeEventListener("change",s),n==null||n.removeEventListener("change",f)}}else{let s=()=>c(e.matches?"dark":n.matches?"light":"no-preference");return e==null||e.addEventListener("change",s),n==null||n.addEventListener("change",s),()=>{e==null||e.removeEventListener("change",s),n==null||n.removeEventListener("change",s)}}},[]),typeof window.matchMedia!="function",i},p=v;})();
"use strict";(()=>{var d=Object.create;var c=Object.defineProperty;var h=Object.getOwnPropertyDescriptor;var f=Object.getOwnPropertyNames;var m=Object.getPrototypeOf,L=Object.prototype.hasOwnProperty;var u=(e=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(e,{get:(r,t)=>(typeof require<"u"?require:r)[t]}):e)(function(e){if(typeof require<"u")return require.apply(this,arguments);throw new Error('Dynamic require of "'+e+'" is not supported')});var l=(e,r,t,i)=>{if(r&&typeof r=="object"||typeof r=="function")for(let n of f(r))!L.call(e,n)&&n!==t&&c(e,n,{get:()=>r[n],enumerable:!(i=h(r,n))||i.enumerable});return e};var p=(e,r,t)=>(t=e!=null?d(m(e)):{},l(r||!e||!e.__esModule?c(t,"default",{value:e,enumerable:!0}):t,e));var o=p(u("react")),g=()=>{let[e,r]=o.useState("no-preference");return o.useEffect(()=>{if(typeof window.matchMedia!="function")return;let t=window.matchMedia("(prefers-color-scheme: dark)"),i=window.matchMedia("(prefers-color-scheme: light)");if(r(t.matches?"dark":i.matches?"light":"no-preference"),typeof i.addEventListener=="function"){let n=({matches:s})=>{s&&r("dark")},a=({matches:s})=>{s&&r("light")};return t.addEventListener("change",n),i.addEventListener("change",a),()=>{t.removeEventListener("change",n),i.removeEventListener("change",a)}}if(typeof i.addListener=="function"){let n=()=>r(t.matches?"dark":i.matches?"light":"no-preference");return t.addListener(n),i.addListener(n),()=>{t.removeListener(n),i.removeListener(n)}}},[]),e},E=g;})();
//# sourceMappingURL=index.cjs.js.map

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

declare const usePrefersColorScheme: () => "dark" | "light" | "no-preference";
export declare const usePrefersColorScheme: () => "dark" | "light" | "no-preference";
export default usePrefersColorScheme;
//# sourceMappingURL=index.d.ts.map

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

import{useEffect as f,useState as d}from"react";var h,e=(h=window.matchMedia)==null?void 0:h.call(window,"(prefers-color-scheme: dark)"),m,n=(m=window.matchMedia)==null?void 0:m.call(window,"(prefers-color-scheme: light)"),v=()=>{let c=e==null?void 0:e.matches,o=n==null?void 0:n.matches,[i,s]=d(c?"dark":o?"light":"no-preference");return f(()=>{s(c?"dark":o?"light":"no-preference")},[c,o]),f(()=>{if(typeof(e==null?void 0:e.addEventListener)=="function"){let t=({matches:r})=>r&&s("dark"),a=({matches:r})=>r&&s("light");return e==null||e.addEventListener("change",t),n==null||n.addEventListener("change",a),()=>{e==null||e.removeEventListener("change",t),n==null||n.removeEventListener("change",a)}}else{let t=()=>s(e.matches?"dark":n.matches?"light":"no-preference");return e==null||e.addEventListener("change",t),n==null||n.addEventListener("change",t),()=>{e==null||e.removeEventListener("change",t),n==null||n.removeEventListener("change",t)}}},[]),typeof window.matchMedia!="function",i},p=v;export{p as default};
import*as i from"react";var c=()=>{let[a,n]=i.useState("no-preference");return i.useEffect(()=>{if(typeof window.matchMedia!="function")return;let t=window.matchMedia("(prefers-color-scheme: dark)"),e=window.matchMedia("(prefers-color-scheme: light)");if(n(t.matches?"dark":e.matches?"light":"no-preference"),typeof e.addEventListener=="function"){let r=({matches:o})=>{o&&n("dark")},s=({matches:o})=>{o&&n("light")};return t.addEventListener("change",r),e.addEventListener("change",s),()=>{t.removeEventListener("change",r),e.removeEventListener("change",s)}}if(typeof e.addListener=="function"){let r=()=>n(t.matches?"dark":e.matches?"light":"no-preference");return t.addListener(r),e.addListener(r),()=>{t.removeListener(r),e.removeListener(r)}}},[]),a},d=c;export{d as default,c as usePrefersColorScheme};
//# sourceMappingURL=index.esm.js.map
{
"name": "use-prefers-color-scheme",
"version": "1.0.0",
"version": "1.1.0",
"description": "React hook for determining the preferred color scheme",

@@ -5,0 +5,0 @@ "author": "rfoel",

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