refactor(consent-sdk): split ConsentManager + framework adapters under 500 LOC
Phase 4: extract config defaults, Google Consent Mode helper, and framework adapter internals into sibling files so every source file is under the hard cap. Public API surface preserved; all 135 tests green, tsup build + tsc typecheck clean. - core/ConsentManager 525 -> 467 LOC (extract config + google helpers) - react/index 511 LOC -> 199 LOC barrel + components/hooks/context - vue/index 511 LOC -> 32 LOC barrel + components/composables/context/plugin - angular/index 509 LOC -> 45 LOC barrel + interface/service/module/templates Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
44
consent-sdk/src/react/context.ts
Normal file
44
consent-sdk/src/react/context.ts
Normal file
@@ -0,0 +1,44 @@
|
||||
/**
|
||||
* Consent context definition — shared by the provider and hooks.
|
||||
*
|
||||
* Phase 4: extracted from index.tsx.
|
||||
*/
|
||||
|
||||
import { createContext } from 'react';
|
||||
import type { ConsentManager } from '../core/ConsentManager';
|
||||
import type {
|
||||
ConsentCategories,
|
||||
ConsentCategory,
|
||||
ConsentState,
|
||||
} from '../types';
|
||||
|
||||
export interface ConsentContextValue {
|
||||
/** ConsentManager Instanz */
|
||||
manager: ConsentManager | null;
|
||||
/** Aktueller Consent-State */
|
||||
consent: ConsentState | null;
|
||||
/** Ist SDK initialisiert? */
|
||||
isInitialized: boolean;
|
||||
/** Wird geladen? */
|
||||
isLoading: boolean;
|
||||
/** Ist Banner sichtbar? */
|
||||
isBannerVisible: boolean;
|
||||
/** Wird Consent benoetigt? */
|
||||
needsConsent: boolean;
|
||||
/** Consent fuer Kategorie pruefen */
|
||||
hasConsent: (category: ConsentCategory) => boolean;
|
||||
/** Alle akzeptieren */
|
||||
acceptAll: () => Promise<void>;
|
||||
/** Alle ablehnen */
|
||||
rejectAll: () => Promise<void>;
|
||||
/** Auswahl speichern */
|
||||
saveSelection: (categories: Partial<ConsentCategories>) => Promise<void>;
|
||||
/** Banner anzeigen */
|
||||
showBanner: () => void;
|
||||
/** Banner verstecken */
|
||||
hideBanner: () => void;
|
||||
/** Einstellungen oeffnen */
|
||||
showSettings: () => void;
|
||||
}
|
||||
|
||||
export const ConsentContext = createContext<ConsentContextValue | null>(null);
|
||||
Reference in New Issue
Block a user