@use-cookie-consent/core
Advanced tools
Comparing version 0.3.4 to 0.3.5
@@ -1,2 +0,16 @@ | ||
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e,t=require("react"),n={exports:{}};e=function(){function e(){for(var e=0,t={};e<arguments.length;e++){var n=arguments[e];for(var r in n)t[r]=n[r]}return t}function t(e){return e.replace(/(%[0-9A-Z]{2})+/g,decodeURIComponent)}return function n(r){function o(){}function i(t,n,i){if("undefined"!=typeof document){"number"==typeof(i=e({path:"/"},o.defaults,i)).expires&&(i.expires=new Date(1*new Date+864e5*i.expires)),i.expires=i.expires?i.expires.toUTCString():"";try{var c=JSON.stringify(n);/^[\{\[]/.test(c)&&(n=c)}catch(e){}n=r.write?r.write(n,t):encodeURIComponent(String(n)).replace(/%(23|24|26|2B|3A|3C|3E|3D|2F|3F|40|5B|5D|5E|60|7B|7D|7C)/g,decodeURIComponent),t=encodeURIComponent(String(t)).replace(/%(23|24|26|2B|5E|60|7C)/g,decodeURIComponent).replace(/[\(\)]/g,escape);var s="";for(var u in i)i[u]&&(s+="; "+u,!0!==i[u]&&(s+="="+i[u].split(";")[0]));return document.cookie=t+"="+n+s}}function c(e,n){if("undefined"!=typeof document){for(var o={},i=document.cookie?document.cookie.split("; "):[],c=0;c<i.length;c++){var s=i[c].split("="),u=s.slice(1).join("=");n||'"'!==u.charAt(0)||(u=u.slice(1,-1));try{var a=t(s[0]);if(u=(r.read||r)(u,a)||t(u),n)try{u=JSON.parse(u)}catch(e){}if(o[a]=u,e===a)break}catch(e){}}return e?o[e]:o}}return o.set=i,o.get=function(e){return c(e,!1)},o.getJSON=function(e){return c(e,!0)},o.remove=function(t,n){i(t,"",e(n,{expires:-1}))},o.defaults={},o.withConverter=n,o}((function(){}))},n.exports=e();var r={},o=function(e){return{session:e,persistent:e,necessary:!0,preferences:e,statistics:e,marketing:e,firstParty:e,thirdParty:e}};exports.useCookieConsent=function(e){var i=n.exports.getJSON("USE_COOKIE_CONSENT_STATE")||(null==e?void 0:e.defaultConsent)||r,c=t.useState(i),s=c[0],u=c[1];t.useEffect((function(){(null==s?void 0:s.necessary)&&n.exports.set("USE_COOKIE_CONSENT_STATE",s,null==e?void 0:e.consentCookieAttributes)}),[s]);var a={set:function(e,t,r,o){if(function(e,t){return!!(t&&t[e.duration]&&t[e.provenance]&&t[e.purpose])}(r,s))return n.exports.set(e,t,o)},get:n.exports.get,getAll:n.exports.get,getJSON:n.exports.getJSON,getAllJSON:n.exports.getJSON,remove:n.exports.remove};return{consent:s,acceptCookies:function(e){u(e)},declineAllCookies:function(){u(o(!1))},acceptAllCookies:function(){u(o(!0))},didAcceptAll:function(){return Object.keys(s||{}).reduce((function(e,t){return e&&s&&s[t]||!1}),!0)},didDeclineAll:function(e){return Object.keys(s||{}).reduce((function(t,n){return(null==e?void 0:e.includingNecessary)||"necessary"!==n?t&&s&&!s[n]||!1:t}),!0)},cookies:a}}; | ||
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e,t=require("react"),n=function(){return n=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var o in t=arguments[n])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},n.apply(this,arguments)},r={exports:{}}; | ||
/*! ***************************************************************************** | ||
Copyright (c) Microsoft Corporation. | ||
Permission to use, copy, modify, and/or distribute this software for any | ||
purpose with or without fee is hereby granted. | ||
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH | ||
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY | ||
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, | ||
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM | ||
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR | ||
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR | ||
PERFORMANCE OF THIS SOFTWARE. | ||
***************************************************************************** */e=function(){function e(){for(var e=0,t={};e<arguments.length;e++){var n=arguments[e];for(var r in n)t[r]=n[r]}return t}function t(e){return e.replace(/(%[0-9A-Z]{2})+/g,decodeURIComponent)}return function n(r){function o(){}function i(t,n,i){if("undefined"!=typeof document){"number"==typeof(i=e({path:"/"},o.defaults,i)).expires&&(i.expires=new Date(1*new Date+864e5*i.expires)),i.expires=i.expires?i.expires.toUTCString():"";try{var c=JSON.stringify(n);/^[\{\[]/.test(c)&&(n=c)}catch(e){}n=r.write?r.write(n,t):encodeURIComponent(String(n)).replace(/%(23|24|26|2B|3A|3C|3E|3D|2F|3F|40|5B|5D|5E|60|7B|7D|7C)/g,decodeURIComponent),t=encodeURIComponent(String(t)).replace(/%(23|24|26|2B|5E|60|7C)/g,decodeURIComponent).replace(/[\(\)]/g,escape);var s="";for(var u in i)i[u]&&(s+="; "+u,!0!==i[u]&&(s+="="+i[u].split(";")[0]));return document.cookie=t+"="+n+s}}function c(e,n){if("undefined"!=typeof document){for(var o={},i=document.cookie?document.cookie.split("; "):[],c=0;c<i.length;c++){var s=i[c].split("="),u=s.slice(1).join("=");n||'"'!==u.charAt(0)||(u=u.slice(1,-1));try{var a=t(s[0]);if(u=(r.read||r)(u,a)||t(u),n)try{u=JSON.parse(u)}catch(e){}if(o[a]=u,e===a)break}catch(e){}}return e?o[e]:o}}return o.set=i,o.get=function(e){return c(e,!1)},o.getJSON=function(e){return c(e,!0)},o.remove=function(t,n){i(t,"",e(n,{expires:-1}))},o.defaults={},o.withConverter=n,o}((function(){}))},r.exports=e();var o={necessary:!0},i=function(e){return{session:e,persistent:e,necessary:!0,preferences:e,statistics:e,marketing:e,firstParty:e,thirdParty:e}};exports.useCookieConsent=function(e){var c=r.exports.getJSON("USE_COOKIE_CONSENT_STATE")||(null==e?void 0:e.defaultConsent)||o,s=t.useState(c),u=s[0],a=s[1];t.useEffect((function(){(null==u?void 0:u.necessary)&&r.exports.set("USE_COOKIE_CONSENT_STATE",u,null==e?void 0:e.consentCookieAttributes)}),[u]);var p={set:function(e,t,n,o){if(function(e,t){return!!(t&&t[e.duration]&&t[e.provenance]&&t[e.purpose])}(n,u))return r.exports.set(e,t,o)},get:r.exports.get,getAll:r.exports.get,getJSON:r.exports.getJSON,getAllJSON:r.exports.getJSON,remove:r.exports.remove};return{consent:u,acceptCookies:function(e,t){(null==t?void 0:t.allowChangingNecessary)?a(e):a(n(n({},e),{necessary:!0}))},declineAllCookies:function(){a(i(!1))},acceptAllCookies:function(){a(i(!0))},didAcceptAll:function(){return Object.keys(u||{}).reduce((function(e,t){return e&&u&&u[t]||!1}),!0)},didDeclineAll:function(e){return Object.keys(u||{}).reduce((function(t,n){return(null==e?void 0:e.includingNecessary)||"necessary"!==n?t&&u&&!u[n]||!1:t}),!0)},cookies:p}}; | ||
//# sourceMappingURL=index.js.map |
import { CookieConsent } from './types'; | ||
export declare const COOKIE_CONSENT_KEY = "USE_COOKIE_CONSENT_STATE"; | ||
export declare const EMPTY_CONSENT: CookieConsent; | ||
export declare const DEFAULT_CONSENT: CookieConsent; |
@@ -1,9 +0,16 @@ | ||
import{useState as e,useEffect as t}from"react";var n,r={exports:{}}; | ||
/*! | ||
* JavaScript Cookie v2.2.1 | ||
* https://github.com/js-cookie/js-cookie | ||
* | ||
* Copyright 2006, 2015 Klaus Hartl & Fagner Brack | ||
* Released under the MIT license | ||
*/n=function(){function e(){for(var e=0,t={};e<arguments.length;e++){var n=arguments[e];for(var r in n)t[r]=n[r]}return t}function t(e){return e.replace(/(%[0-9A-Z]{2})+/g,decodeURIComponent)}return function n(r){function o(){}function i(t,n,i){if("undefined"!=typeof document){"number"==typeof(i=e({path:"/"},o.defaults,i)).expires&&(i.expires=new Date(1*new Date+864e5*i.expires)),i.expires=i.expires?i.expires.toUTCString():"";try{var c=JSON.stringify(n);/^[\{\[]/.test(c)&&(n=c)}catch(e){}n=r.write?r.write(n,t):encodeURIComponent(String(n)).replace(/%(23|24|26|2B|3A|3C|3E|3D|2F|3F|40|5B|5D|5E|60|7B|7D|7C)/g,decodeURIComponent),t=encodeURIComponent(String(t)).replace(/%(23|24|26|2B|5E|60|7C)/g,decodeURIComponent).replace(/[\(\)]/g,escape);var s="";for(var u in i)i[u]&&(s+="; "+u,!0!==i[u]&&(s+="="+i[u].split(";")[0]));return document.cookie=t+"="+n+s}}function c(e,n){if("undefined"!=typeof document){for(var o={},i=document.cookie?document.cookie.split("; "):[],c=0;c<i.length;c++){var s=i[c].split("="),u=s.slice(1).join("=");n||'"'!==u.charAt(0)||(u=u.slice(1,-1));try{var p=t(s[0]);if(u=(r.read||r)(u,p)||t(u),n)try{u=JSON.parse(u)}catch(e){}if(o[p]=u,e===p)break}catch(e){}}return e?o[e]:o}}return o.set=i,o.get=function(e){return c(e,!1)},o.getJSON=function(e){return c(e,!0)},o.remove=function(t,n){i(t,"",e(n,{expires:-1}))},o.defaults={},o.withConverter=n,o}((function(){}))},r.exports=n();var o={},i=function(e){return{session:e,persistent:e,necessary:!0,preferences:e,statistics:e,marketing:e,firstParty:e,thirdParty:e}},c=function(n){var c=r.exports.getJSON("USE_COOKIE_CONSENT_STATE")||(null==n?void 0:n.defaultConsent)||o,s=e(c),u=s[0],p=s[1];t((function(){(null==u?void 0:u.necessary)&&r.exports.set("USE_COOKIE_CONSENT_STATE",u,null==n?void 0:n.consentCookieAttributes)}),[u]);var a={set:function(e,t,n,o){if(function(e,t){return!!(t&&t[e.duration]&&t[e.provenance]&&t[e.purpose])}(n,u))return r.exports.set(e,t,o)},get:r.exports.get,getAll:r.exports.get,getJSON:r.exports.getJSON,getAllJSON:r.exports.getJSON,remove:r.exports.remove};return{consent:u,acceptCookies:function(e){p(e)},declineAllCookies:function(){p(i(!1))},acceptAllCookies:function(){p(i(!0))},didAcceptAll:function(){return Object.keys(u||{}).reduce((function(e,t){return e&&u&&u[t]||!1}),!0)},didDeclineAll:function(e){return Object.keys(u||{}).reduce((function(t,n){return(null==e?void 0:e.includingNecessary)||"necessary"!==n?t&&u&&!u[n]||!1:t}),!0)},cookies:a}};export{c as useCookieConsent}; | ||
import{useState as e,useEffect as t}from"react"; | ||
/*! ***************************************************************************** | ||
Copyright (c) Microsoft Corporation. | ||
Permission to use, copy, modify, and/or distribute this software for any | ||
purpose with or without fee is hereby granted. | ||
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH | ||
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY | ||
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, | ||
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM | ||
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR | ||
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR | ||
PERFORMANCE OF THIS SOFTWARE. | ||
***************************************************************************** */var n,r=function(){return r=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var o in t=arguments[n])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},r.apply(this,arguments)},o={exports:{}};n=function(){function e(){for(var e=0,t={};e<arguments.length;e++){var n=arguments[e];for(var r in n)t[r]=n[r]}return t}function t(e){return e.replace(/(%[0-9A-Z]{2})+/g,decodeURIComponent)}return function n(r){function o(){}function i(t,n,i){if("undefined"!=typeof document){"number"==typeof(i=e({path:"/"},o.defaults,i)).expires&&(i.expires=new Date(1*new Date+864e5*i.expires)),i.expires=i.expires?i.expires.toUTCString():"";try{var c=JSON.stringify(n);/^[\{\[]/.test(c)&&(n=c)}catch(e){}n=r.write?r.write(n,t):encodeURIComponent(String(n)).replace(/%(23|24|26|2B|3A|3C|3E|3D|2F|3F|40|5B|5D|5E|60|7B|7D|7C)/g,decodeURIComponent),t=encodeURIComponent(String(t)).replace(/%(23|24|26|2B|5E|60|7C)/g,decodeURIComponent).replace(/[\(\)]/g,escape);var s="";for(var u in i)i[u]&&(s+="; "+u,!0!==i[u]&&(s+="="+i[u].split(";")[0]));return document.cookie=t+"="+n+s}}function c(e,n){if("undefined"!=typeof document){for(var o={},i=document.cookie?document.cookie.split("; "):[],c=0;c<i.length;c++){var s=i[c].split("="),u=s.slice(1).join("=");n||'"'!==u.charAt(0)||(u=u.slice(1,-1));try{var a=t(s[0]);if(u=(r.read||r)(u,a)||t(u),n)try{u=JSON.parse(u)}catch(e){}if(o[a]=u,e===a)break}catch(e){}}return e?o[e]:o}}return o.set=i,o.get=function(e){return c(e,!1)},o.getJSON=function(e){return c(e,!0)},o.remove=function(t,n){i(t,"",e(n,{expires:-1}))},o.defaults={},o.withConverter=n,o}((function(){}))},o.exports=n();var i={necessary:!0},c=function(e){return{session:e,persistent:e,necessary:!0,preferences:e,statistics:e,marketing:e,firstParty:e,thirdParty:e}},s=function(n){var s=o.exports.getJSON("USE_COOKIE_CONSENT_STATE")||(null==n?void 0:n.defaultConsent)||i,u=e(s),a=u[0],p=u[1];t((function(){(null==a?void 0:a.necessary)&&o.exports.set("USE_COOKIE_CONSENT_STATE",a,null==n?void 0:n.consentCookieAttributes)}),[a]);var f={set:function(e,t,n,r){if(function(e,t){return!!(t&&t[e.duration]&&t[e.provenance]&&t[e.purpose])}(n,a))return o.exports.set(e,t,r)},get:o.exports.get,getAll:o.exports.get,getJSON:o.exports.getJSON,getAllJSON:o.exports.getJSON,remove:o.exports.remove};return{consent:a,acceptCookies:function(e,t){(null==t?void 0:t.allowChangingNecessary)?p(e):p(r(r({},e),{necessary:!0}))},declineAllCookies:function(){p(c(!1))},acceptAllCookies:function(){p(c(!0))},didAcceptAll:function(){return Object.keys(a||{}).reduce((function(e,t){return e&&a&&a[t]||!1}),!0)},didDeclineAll:function(e){return Object.keys(a||{}).reduce((function(t,n){return(null==e?void 0:e.includingNecessary)||"necessary"!==n?t&&a&&!a[n]||!1:t}),!0)},cookies:f}};export{s as useCookieConsent}; | ||
//# sourceMappingURL=index.js.map |
@@ -53,2 +53,5 @@ import { CookieAttributes } from 'js-cookie'; | ||
} | ||
export interface AcceptCookiesOptions { | ||
allowChangingNecessary?: boolean; | ||
} | ||
export {}; |
{ | ||
"name": "@use-cookie-consent/core", | ||
"version": "0.3.4", | ||
"version": "0.3.5", | ||
"description": "React hook for managing GDPR cookie consent state.", | ||
@@ -5,0 +5,0 @@ "main": "./build/cjs/index.js", |
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
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
72786
116