use-prefers-color-scheme
Advanced tools
Comparing version 0.1.2-rc.4 to 1.0.0
@@ -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
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
12954
2
2
16
+ Addedeslint@^8.24.0
+ Added@eslint-community/eslint-utils@4.4.1(transitive)
+ Added@eslint-community/regexpp@4.12.1(transitive)
+ Added@eslint/eslintrc@2.1.4(transitive)
+ Added@eslint/js@8.57.1(transitive)
+ Added@humanwhocodes/config-array@0.13.0(transitive)
+ Added@humanwhocodes/module-importer@1.0.1(transitive)
+ Added@humanwhocodes/object-schema@2.0.3(transitive)
+ Added@nodelib/fs.scandir@2.1.5(transitive)
+ Added@nodelib/fs.stat@2.0.5(transitive)
+ Added@nodelib/fs.walk@1.2.8(transitive)
+ Added@ungap/structured-clone@1.2.1(transitive)
+ Addedacorn@8.14.0(transitive)
+ Addedacorn-jsx@5.3.2(transitive)
+ Addedajv@6.12.6(transitive)
+ Addedansi-regex@5.0.1(transitive)
+ Addedansi-styles@4.3.0(transitive)
+ Addedargparse@2.0.1(transitive)
+ Addedbalanced-match@1.0.2(transitive)
+ Addedbrace-expansion@1.1.11(transitive)
+ Addedcallsites@3.1.0(transitive)
+ Addedchalk@4.1.2(transitive)
+ Addedcolor-convert@2.0.1(transitive)
+ Addedcolor-name@1.1.4(transitive)
+ Addedconcat-map@0.0.1(transitive)
+ Addedcross-spawn@7.0.6(transitive)
+ Addeddebug@4.4.0(transitive)
+ Addeddeep-is@0.1.4(transitive)
+ Addeddoctrine@3.0.0(transitive)
+ Addedescape-string-regexp@4.0.0(transitive)
+ Addedeslint@8.57.1(transitive)
+ Addedeslint-scope@7.2.2(transitive)
+ Addedeslint-visitor-keys@3.4.3(transitive)
+ Addedespree@9.6.1(transitive)
+ Addedesquery@1.6.0(transitive)
+ Addedesrecurse@4.3.0(transitive)
+ Addedestraverse@5.3.0(transitive)
+ Addedesutils@2.0.3(transitive)
+ Addedfast-deep-equal@3.1.3(transitive)
+ Addedfast-json-stable-stringify@2.1.0(transitive)
+ Addedfast-levenshtein@2.0.6(transitive)
+ Addedfastq@1.17.1(transitive)
+ Addedfile-entry-cache@6.0.1(transitive)
+ Addedfind-up@5.0.0(transitive)
+ Addedflat-cache@3.2.0(transitive)
+ Addedflatted@3.3.2(transitive)
+ Addedfs.realpath@1.0.0(transitive)
+ Addedglob@7.2.3(transitive)
+ Addedglob-parent@6.0.2(transitive)
+ Addedglobals@13.24.0(transitive)
+ Addedgraphemer@1.4.0(transitive)
+ Addedhas-flag@4.0.0(transitive)
+ Addedignore@5.3.2(transitive)
+ Addedimport-fresh@3.3.0(transitive)
+ Addedimurmurhash@0.1.4(transitive)
+ Addedinflight@1.0.6(transitive)
+ Addedinherits@2.0.4(transitive)
+ Addedis-extglob@2.1.1(transitive)
+ Addedis-glob@4.0.3(transitive)
+ Addedis-path-inside@3.0.3(transitive)
+ Addedisexe@2.0.0(transitive)
+ Addedjs-yaml@4.1.0(transitive)
+ Addedjson-buffer@3.0.1(transitive)
+ Addedjson-schema-traverse@0.4.1(transitive)
+ Addedjson-stable-stringify-without-jsonify@1.0.1(transitive)
+ Addedkeyv@4.5.4(transitive)
+ Addedlevn@0.4.1(transitive)
+ Addedlocate-path@6.0.0(transitive)
+ Addedlodash.merge@4.6.2(transitive)
+ Addedminimatch@3.1.2(transitive)
+ Addedms@2.1.3(transitive)
+ Addednatural-compare@1.4.0(transitive)
+ Addedonce@1.4.0(transitive)
+ Addedoptionator@0.9.4(transitive)
+ Addedp-limit@3.1.0(transitive)
+ Addedp-locate@5.0.0(transitive)
+ Addedparent-module@1.0.1(transitive)
+ Addedpath-exists@4.0.0(transitive)
+ Addedpath-is-absolute@1.0.1(transitive)
+ Addedpath-key@3.1.1(transitive)
+ Addedprelude-ls@1.2.1(transitive)
+ Addedpunycode@2.3.1(transitive)
+ Addedqueue-microtask@1.2.3(transitive)
+ Addedresolve-from@4.0.0(transitive)
+ Addedreusify@1.0.4(transitive)
+ Addedrimraf@3.0.2(transitive)
+ Addedrun-parallel@1.2.0(transitive)
+ Addedshebang-command@2.0.0(transitive)
+ Addedshebang-regex@3.0.0(transitive)
+ Addedstrip-ansi@6.0.1(transitive)
+ Addedstrip-json-comments@3.1.1(transitive)
+ Addedsupports-color@7.2.0(transitive)
+ Addedtext-table@0.2.0(transitive)
+ Addedtype-check@0.4.0(transitive)
+ Addedtype-fest@0.20.2(transitive)
+ Addeduri-js@4.4.1(transitive)
+ Addedwhich@2.0.2(transitive)
+ Addedword-wrap@1.2.5(transitive)
+ Addedwrappy@1.0.2(transitive)
+ Addedyocto-queue@0.1.0(transitive)