From 10e35c6afc14c60e741e83f040773aa3cd6e57dd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89mile=20R=C3=A9?= Date: Mon, 18 May 2026 18:41:52 +0400 Subject: [PATCH] Share consent MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Émile Ré --- packages/cookie-banner/src/consent.ts | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/packages/cookie-banner/src/consent.ts b/packages/cookie-banner/src/consent.ts index 2b9e4bcbd..9e7b75849 100644 --- a/packages/cookie-banner/src/consent.ts +++ b/packages/cookie-banner/src/consent.ts @@ -87,11 +87,15 @@ export class ConsentManager { } } -let instance: ConsentManager | null = null; +const GLOBAL_KEY = "__proboConsentManager"; export function getConsent(): ConsentManager { - if (!instance) { - instance = new ConsentManager(); + const g = typeof globalThis !== "undefined" + ? (globalThis as unknown as Record) + : (window as unknown as Record); + + if (!g[GLOBAL_KEY]) { + g[GLOBAL_KEY] = new ConsentManager(); } - return instance; + return g[GLOBAL_KEY] as ConsentManager; }