c15t
Version:
<div align="center"> <img src="https://c15t.com/logo-icon.png" alt="c15t Logo" width="64" height="64" /> <h1>c15t</h1> <p>Transform privacy consent from a compliance checkbox into a fully observable system</p>
121 lines • 3.76 kB
TypeScript
/**
* @packageDocumentation
* Implements the core consent management store using Zustand.
* This module provides the main store creation and management functionality.
*/
import type { TranslationConfig } from '@c15t/translations';
import type { ConsentManagerInterface } from './client/client-factory';
import type { TrackingBlockerConfig } from './libs/tracking-blocker';
import type { PrivacyConsentState } from './store.type';
import type { ComplianceSettings } from './types/compliance';
import { type AllConsentNames } from './types/gdpr';
import type { ContractsOutputs } from '@c15t/backend/contracts';
import { type GTMConfiguration } from './libs/gtm';
/**
* Configuration options for the consent manager store.
*
* @remarks
* These options control the behavior of the store,
* including initialization, tracking blocker, and persistence.
*
* @public
*/
export interface StoreOptions {
/**
* Custom namespace for the store instance.
* @default 'c15tStore'
*/
namespace?: string;
/** Information about the consent manager */
config?: {
pkg: string;
version: string;
mode: string;
meta?: Record<string, unknown>;
};
/**
* Initial GDPR consent types to activate.
*/
initialGdprTypes?: AllConsentNames[];
/**
* Initial compliance settings for different regions.
*/
initialComplianceSettings?: Record<string, Partial<ComplianceSettings>>;
/**
* Configuration for the tracking blocker.
*/
trackingBlockerConfig?: TrackingBlockerConfig;
/**
* Flag indicating if the consent manager is using the c15t.dev domain.
* @default false
*/
isConsentDomain?: boolean;
/**
* Google Tag Manager configuration.
*/
unstable_googleTagManager?: GTMConfiguration;
/**
* Whether to ignore geo location. Will always show the consent banner.
* @default false
*/
ignoreGeoLocation?: boolean;
/**
* Initial Translation Config
*/
initialTranslationConfig?: Partial<TranslationConfig>;
/**
* Translation configuration for the consent manager.
*/
translationConfig?: TranslationConfig;
/**
* Initial showConsentBanner value. This will set a cookie for the consent banner.
* @internal
*/
_initialData?: Promise<ContractsOutputs['consent']['showBanner'] | undefined>;
}
export interface StoreConfig extends Pick<StoreOptions, 'trackingBlockerConfig'> {
}
/**
* Creates a new consent manager store instance.
*
* @remarks
* This function initializes a new consent management store with:
* - Persistence through localStorage
* - Initial state handling
* - Consent management methods
* - Privacy settings
* - Compliance configuration
*
* The store is typically used through React hooks but can also be
* accessed directly for non-React applications.
*
* @param namespace - Optional namespace for the store instance
* @returns A Zustand store instance with consent management functionality
*
* @example
* Basic usage:
* ```typescript
* const store = createConsentManagerStore();
*
* // Subscribe to state changes
* const unsubscribe = store.subscribe(
* state => console.log('Consent updated:', state.consents)
* );
*
* // Update consent
* store.getState().setConsent('analytics', true);
* ```
*
* @example
* Custom namespace:
* ```typescript
* const store = createConsentManagerStore(client, 'MyApp');
*
* // Access from window
* const state = window.MyApp.getState();
* ```
*
* @public
*/
export declare const createConsentManagerStore: (manager: ConsentManagerInterface, options?: StoreOptions) => import("zustand/vanilla").StoreApi<PrivacyConsentState>;
//# sourceMappingURL=store.d.ts.map