@guardian/consent-management-platform
Advanced tools
Comparing version 13.10.0 to 13.11.1
@@ -175,2 +175,3 @@ import { log, removeCookie, storage } from '@guardian/libs'; | ||
const callBackQueue = []; | ||
const finalCallbackQueue = []; | ||
const awaitingUserInteractionInTCFv2 = (state) => state.tcfv2?.eventStatus === 'cmpuishown'; | ||
@@ -234,3 +235,4 @@ const invokeCallback = (callback, state) => { | ||
const invokeCallbacks = () => { | ||
if (callBackQueue.length === 0) | ||
const callbacksToInvoke = callBackQueue.concat(finalCallbackQueue); | ||
if (callbacksToInvoke.length === 0) | ||
return; | ||
@@ -240,8 +242,13 @@ void getConsentState().then((state) => { | ||
return; | ||
callBackQueue.forEach((callback) => invokeCallback(callback, state)); | ||
callbacksToInvoke.forEach((callback) => invokeCallback(callback, state)); | ||
}); | ||
}; | ||
const onConsentChange$1 = (callBack) => { | ||
const onConsentChange$1 = (callBack, final = false) => { | ||
const newCallback = { fn: callBack }; | ||
callBackQueue.push(newCallback); | ||
if (final) { | ||
finalCallbackQueue.push(newCallback); | ||
} | ||
else { | ||
callBackQueue.push(newCallback); | ||
} | ||
void getConsentState() | ||
@@ -1003,5 +1010,5 @@ .then((consentState) => { | ||
if (window.guCmpHotFix.initialised) { | ||
if (window.guCmpHotFix.cmp?.version !== "13.10.0") | ||
if (window.guCmpHotFix.cmp?.version !== "13.11.1") | ||
console.warn('Two different versions of the CMP are running:', [ | ||
"13.10.0", | ||
"13.11.1", | ||
window.guCmpHotFix.cmp?.version, | ||
@@ -1044,3 +1051,3 @@ ]); | ||
showPrivacyManager, | ||
version: "13.10.0", | ||
version: "13.11.1", | ||
__isDisabled: isDisabled, | ||
@@ -1047,0 +1054,0 @@ __enable: enable, |
@@ -179,2 +179,3 @@ 'use strict'; | ||
const callBackQueue = []; | ||
const finalCallbackQueue = []; | ||
const awaitingUserInteractionInTCFv2 = (state) => state.tcfv2?.eventStatus === 'cmpuishown'; | ||
@@ -238,3 +239,4 @@ const invokeCallback = (callback, state) => { | ||
const invokeCallbacks = () => { | ||
if (callBackQueue.length === 0) | ||
const callbacksToInvoke = callBackQueue.concat(finalCallbackQueue); | ||
if (callbacksToInvoke.length === 0) | ||
return; | ||
@@ -244,8 +246,13 @@ void getConsentState().then((state) => { | ||
return; | ||
callBackQueue.forEach((callback) => invokeCallback(callback, state)); | ||
callbacksToInvoke.forEach((callback) => invokeCallback(callback, state)); | ||
}); | ||
}; | ||
const onConsentChange$1 = (callBack) => { | ||
const onConsentChange$1 = (callBack, final = false) => { | ||
const newCallback = { fn: callBack }; | ||
callBackQueue.push(newCallback); | ||
if (final) { | ||
finalCallbackQueue.push(newCallback); | ||
} | ||
else { | ||
callBackQueue.push(newCallback); | ||
} | ||
void getConsentState() | ||
@@ -1007,5 +1014,5 @@ .then((consentState) => { | ||
if (window.guCmpHotFix.initialised) { | ||
if (window.guCmpHotFix.cmp?.version !== "13.10.0") | ||
if (window.guCmpHotFix.cmp?.version !== "13.11.1") | ||
console.warn('Two different versions of the CMP are running:', [ | ||
"13.10.0", | ||
"13.11.1", | ||
window.guCmpHotFix.cmp?.version, | ||
@@ -1048,3 +1055,3 @@ ]); | ||
showPrivacyManager, | ||
version: "13.10.0", | ||
version: "13.11.1", | ||
__isDisabled: isDisabled, | ||
@@ -1051,0 +1058,0 @@ __enable: enable, |
@@ -22,3 +22,3 @@ import type { VendorName } from '../vendors'; | ||
}) => void; | ||
export type OnConsentChange = (fn: Callback) => void; | ||
export type OnConsentChange = (fn: Callback, final?: boolean) => void; | ||
export type GetConsentFor = (vendor: VendorName, consent: ConsentState) => boolean; | ||
@@ -25,0 +25,0 @@ export interface ConsentState { |
{ | ||
"name": "@guardian/consent-management-platform", | ||
"version": "13.10.0", | ||
"version": "13.11.1", | ||
"description": "Consent management for *.theguardian.com.", | ||
@@ -50,3 +50,3 @@ "homepage": "https://github.com/guardian/consent-management-platform.git", | ||
"@guardian/eslint-config-typescript": "^9.0.2", | ||
"@guardian/libs": "16.0.1", | ||
"@guardian/libs": "16.0.2", | ||
"@guardian/prettier": "^8.0.0", | ||
@@ -82,10 +82,10 @@ "@guardian/tsconfig": "^0.2.0", | ||
"prettier-plugin-svelte": "^3.1.2", | ||
"rollup": "^2.70.1", | ||
"rollup": "^2.79.1", | ||
"rollup-plugin-css-only": "^4.5.2", | ||
"rollup-plugin-livereload": "^2", | ||
"rollup-plugin-serve": "^2.0.2", | ||
"rollup-plugin-serve": "^2.0.3", | ||
"rollup-plugin-svelte": "^7.1.6", | ||
"serve": "^14.2.1", | ||
"start-server-and-test": "~2.0.3", | ||
"svelte": "~3.59.1", | ||
"svelte": "3.59.1", | ||
"tslib": "^2.6.2", | ||
@@ -92,0 +92,0 @@ "typescript": "~5.3.3", |
@@ -26,3 +26,3 @@ # Consent Management Platform | ||
- [Using Consent](#using-consent) | ||
* [`onConsentChange(callback)`](#onconsentchangecallback) | ||
* [`onConsentChange(callback, final?)`](#onconsentchangecallback-final) | ||
* [`onConsent()`](#onconsent) | ||
@@ -176,3 +176,3 @@ * [`getConsentFor(vendor, consentState)`](#getconsentforvendor-consentstate) | ||
### `onConsentChange(callback)` | ||
### `onConsentChange(callback, final?)` | ||
@@ -189,2 +189,7 @@ returns: `void` | ||
Passing `true` for the optional `final` parameter guarantees that the callback | ||
will be executed after all other callbacks that haven't been registered with the flag when consent state changes. | ||
If more than one callback registered with `final = true`, they will be executed in the order in which they were registered | ||
when consent changes. | ||
#### `callback(consentState)` | ||
@@ -191,0 +196,0 @@ |
102553
2578
444