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 0.1.2-rc.4 to 1.0.0

2

dist/index.cjs.js

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

"use strict";(()=>{var m=(t=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(t,{get:(c,a)=>(typeof require<"u"?require:c)[a]}):t)(function(t){if(typeof require<"u")return require.apply(this,arguments);throw new Error('Dynamic require of "'+t+'" is not supported')});var o=m("react"),d,e=(d=window.matchMedia)==null?void 0:d.call(window,"(prefers-color-scheme: dark)"),f,n=(f=window.matchMedia)==null?void 0:f.call(window,"(prefers-color-scheme: light)"),l=()=>{let t=e==null?void 0:e.matches,c=n==null?void 0:n.matches,[a,s]=(0,o.useState)(t?"dark":c?"light":"no-preference");return typeof window.matchMedia!="function"||((0,o.useEffect)(()=>{s(t?"dark":c?"light":"no-preference")},[t,c]),(0,o.useEffect)(()=>{if(typeof e.addEventListener=="function"){let r=({matches:i})=>i&&s("dark"),h=({matches:i})=>i&&s("light");return e.addEventListener("change",r),n.addEventListener("change",h),()=>{e.removeEventListener("change",r),n.removeEventListener("change",h)}}else{let r=()=>s(e.matches?"dark":n.matches?"light":"no-preference");return e.addEventListener("change",r),n.addEventListener("change",r),()=>{e.removeEventListener("change",r),n.removeEventListener("change",r)}}},[])),a},v=l;})();
"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;})();
//# sourceMappingURL=index.cjs.js.map

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

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

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

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

@@ -19,3 +19,3 @@ "author": "rfoel",

"deploy": "gh-pages -d example/build",
"lint": "eslint src/ --fix",
"lint": "eslint . --fix",
"postbuild": "npm run types",

@@ -25,4 +25,4 @@ "prebuild": "rimraf dist",

"start": "rollup -c -w",
"test:watch": "react-scripts test --env=jsdom",
"test": "react-scripts test --env=jsdom",
"test:watch": "react-scripts test",
"test": "react-scripts test",
"types": "tsc --project tsconfig.build.json"

@@ -34,8 +34,15 @@ },

"devDependencies": {
"@testing-library/react-hooks": "^8.0.1",
"@semantic-release/changelog": "^6.0.1",
"@semantic-release/commit-analyzer": "^9.0.2",
"@semantic-release/git": "^10.0.1",
"@semantic-release/github": "^8.0.6",
"@semantic-release/npm": "^9.0.1",
"@semantic-release/release-notes-generator": "^10.0.3",
"@testing-library/react": "^13.4.0",
"@types/jest": "^29.1.1",
"@types/react": "^18.0.21",
"esbuild": "^0.15.10",
"gh-pages": "^4.0.0",
"prettier": "^2.7.1",
"react": "^16.9.0",
"react": "^18.2.0",
"react-scripts": "^5.0.1",

@@ -48,3 +55,6 @@ "rimraf": "^3.0.2",

"npm": ">=5"
},
"dependencies": {
"eslint": "^8.24.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

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