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:
79
consent-sdk/src/angular/module.ts
Normal file
79
consent-sdk/src/angular/module.ts
Normal file
@@ -0,0 +1,79 @@
|
||||
/**
|
||||
* Angular Module configuration — DI tokens, factory, module definition.
|
||||
*
|
||||
* Phase 4: extracted from angular/index.ts.
|
||||
*/
|
||||
|
||||
import type { ConsentConfig } from '../types';
|
||||
import { ConsentServiceBase } from './service';
|
||||
|
||||
/**
|
||||
* Konfiguration fuer ConsentModule.forRoot()
|
||||
*/
|
||||
export interface ConsentModuleConfig extends ConsentConfig {}
|
||||
|
||||
/**
|
||||
* Token fuer Dependency Injection
|
||||
* Verwendung mit Angular @Inject():
|
||||
*
|
||||
* @example
|
||||
* ```typescript
|
||||
* constructor(@Inject(CONSENT_CONFIG) private config: ConsentConfig) {}
|
||||
* ```
|
||||
*/
|
||||
export const CONSENT_CONFIG = 'CONSENT_CONFIG';
|
||||
export const CONSENT_SERVICE = 'CONSENT_SERVICE';
|
||||
|
||||
/**
|
||||
* Factory fuer ConsentService
|
||||
*
|
||||
* @example
|
||||
* ```typescript
|
||||
* // app.module.ts
|
||||
* providers: [
|
||||
* { provide: CONSENT_CONFIG, useValue: { apiEndpoint: '...', siteId: '...' } },
|
||||
* { provide: CONSENT_SERVICE, useFactory: consentServiceFactory, deps: [CONSENT_CONFIG] },
|
||||
* ]
|
||||
* ```
|
||||
*/
|
||||
export function consentServiceFactory(
|
||||
config: ConsentConfig
|
||||
): ConsentServiceBase {
|
||||
return new ConsentServiceBase(config);
|
||||
}
|
||||
|
||||
/**
|
||||
* ConsentModule - Angular Module
|
||||
*
|
||||
* Dies ist eine Template-Definition. Fuer echte Angular-Nutzung
|
||||
* muss ein separates Angular Library Package erstellt werden.
|
||||
*
|
||||
* @example
|
||||
* ```typescript
|
||||
* // In einem Angular Library Package:
|
||||
* @NgModule({
|
||||
* declarations: [ConsentBannerComponent, ConsentGateDirective],
|
||||
* exports: [ConsentBannerComponent, ConsentGateDirective],
|
||||
* })
|
||||
* export class ConsentModule {
|
||||
* static forRoot(config: ConsentModuleConfig): ModuleWithProviders<ConsentModule> {
|
||||
* return {
|
||||
* ngModule: ConsentModule,
|
||||
* providers: [
|
||||
* { provide: CONSENT_CONFIG, useValue: config },
|
||||
* { provide: CONSENT_SERVICE, useFactory: consentServiceFactory, deps: [CONSENT_CONFIG] },
|
||||
* ],
|
||||
* };
|
||||
* }
|
||||
* }
|
||||
* ```
|
||||
*/
|
||||
export const ConsentModuleDefinition = {
|
||||
/**
|
||||
* Providers fuer Root-Module
|
||||
*/
|
||||
forRoot: (config: ConsentModuleConfig) => ({
|
||||
provide: CONSENT_CONFIG,
|
||||
useValue: config,
|
||||
}),
|
||||
};
|
||||
Reference in New Issue
Block a user