valtech-components 2.0.500 → 2.0.502
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/esm2022/lib/components/atoms/button/button.component.mjs +87 -48
- package/esm2022/lib/components/molecules/action-header/action-header.component.mjs +1 -1
- package/esm2022/lib/components/molecules/ad-slot/ad-slot.component.mjs +249 -0
- package/esm2022/lib/components/molecules/button-group/button-group.component.mjs +1 -1
- package/esm2022/lib/components/molecules/card/card.component.mjs +2 -2
- package/esm2022/lib/components/molecules/file-input/file-input.component.mjs +1 -1
- package/esm2022/lib/components/molecules/raffle-status-card/raffle-status-card.component.mjs +2 -2
- package/esm2022/lib/components/organisms/article/article.component.mjs +2 -2
- package/esm2022/lib/components/organisms/menu/menu.component.mjs +1 -1
- package/esm2022/lib/components/templates/page-template/page-template.component.mjs +1 -1
- package/esm2022/lib/services/ads/ads-consent.service.mjs +152 -0
- package/esm2022/lib/services/ads/ads-loader.service.mjs +160 -0
- package/esm2022/lib/services/ads/ads.service.mjs +449 -0
- package/esm2022/lib/services/ads/config.mjs +118 -0
- package/esm2022/lib/services/ads/index.mjs +14 -0
- package/esm2022/lib/services/ads/types.mjs +23 -0
- package/esm2022/public-api.mjs +6 -1
- package/fesm2022/valtech-components.mjs +1330 -154
- package/fesm2022/valtech-components.mjs.map +1 -1
- package/lib/components/atoms/button/button.component.d.ts +30 -6
- package/lib/components/molecules/ad-slot/ad-slot.component.d.ts +78 -0
- package/lib/services/ads/ads-consent.service.d.ts +59 -0
- package/lib/services/ads/ads-loader.service.d.ts +46 -0
- package/lib/services/ads/ads.service.d.ts +123 -0
- package/lib/services/ads/config.d.ts +69 -0
- package/lib/services/ads/index.d.ts +10 -0
- package/lib/services/ads/types.d.ts +163 -0
- package/package.json +1 -1
- package/public-api.d.ts +2 -0
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { EventEmitter, OnInit } from '@angular/core';
|
|
1
|
+
import { EventEmitter, OnChanges, OnInit, SimpleChanges } from '@angular/core';
|
|
2
2
|
import { DownloadService } from '../../../services/download.service';
|
|
3
3
|
import { IconService } from '../../../services/icons.service';
|
|
4
4
|
import { NavigationService } from '../../../services/navigation.service';
|
|
5
5
|
import { ButtonMetadata } from '../../types';
|
|
6
6
|
import * as i0 from "@angular/core";
|
|
7
|
-
export declare class ButtonComponent implements OnInit {
|
|
7
|
+
export declare class ButtonComponent implements OnInit, OnChanges {
|
|
8
8
|
private download;
|
|
9
9
|
private navigation;
|
|
10
10
|
states: {
|
|
@@ -13,19 +13,43 @@ export declare class ButtonComponent implements OnInit {
|
|
|
13
13
|
WORKING: "WORKING";
|
|
14
14
|
ERROR: "ERROR";
|
|
15
15
|
};
|
|
16
|
+
private presets;
|
|
16
17
|
/**
|
|
17
18
|
* The text to display on the button.
|
|
18
19
|
*/
|
|
19
20
|
displayText: string;
|
|
20
|
-
|
|
21
|
+
/**
|
|
22
|
+
* Preset name to apply. Presets define reusable button configurations
|
|
23
|
+
* (size, color, fill, etc.) that can be registered at app level.
|
|
24
|
+
*
|
|
25
|
+
* @example
|
|
26
|
+
* <val-button preset="primary-action" [props]="{ text: 'Save' }"></val-button>
|
|
27
|
+
*/
|
|
28
|
+
preset?: string;
|
|
29
|
+
/**
|
|
30
|
+
* Button configuration. Values here override preset values.
|
|
31
|
+
* When using presets, only partial props are needed (preset provides defaults).
|
|
32
|
+
*/
|
|
33
|
+
props: Partial<ButtonMetadata>;
|
|
34
|
+
/**
|
|
35
|
+
* Resolved props after merging preset + explicit props.
|
|
36
|
+
* Preset values are overridden by explicit props.
|
|
37
|
+
*/
|
|
38
|
+
resolvedProps: ButtonMetadata;
|
|
21
39
|
/**
|
|
22
40
|
* Event emitted when the button is clicked.
|
|
23
41
|
*/
|
|
24
42
|
onClick: EventEmitter<string>;
|
|
25
|
-
constructor(download: DownloadService,
|
|
43
|
+
constructor(download: DownloadService, _icon: IconService, navigation: NavigationService);
|
|
26
44
|
ngOnInit(): void;
|
|
45
|
+
ngOnChanges(changes: SimpleChanges): void;
|
|
46
|
+
/**
|
|
47
|
+
* Merge preset configuration with explicit props.
|
|
48
|
+
* Explicit props take precedence over preset values.
|
|
49
|
+
*/
|
|
50
|
+
private resolveProps;
|
|
27
51
|
/**
|
|
28
|
-
* Set up the text content based on the props configuration.
|
|
52
|
+
* Set up the text content based on the resolved props configuration.
|
|
29
53
|
*/
|
|
30
54
|
private setupDisplayText;
|
|
31
55
|
/**
|
|
@@ -35,5 +59,5 @@ export declare class ButtonComponent implements OnInit {
|
|
|
35
59
|
private interpolateContent;
|
|
36
60
|
clickHandler(): void;
|
|
37
61
|
static ɵfac: i0.ɵɵFactoryDeclaration<ButtonComponent, never>;
|
|
38
|
-
static ɵcmp: i0.ɵɵComponentDeclaration<ButtonComponent, "val-button", never, { "props": { "alias": "props"; "required": false; }; }, { "onClick": "onClick"; }, never, never, true, never>;
|
|
62
|
+
static ɵcmp: i0.ɵɵComponentDeclaration<ButtonComponent, "val-button", never, { "preset": { "alias": "preset"; "required": false; }; "props": { "alias": "props"; "required": false; }; }, { "onClick": "onClick"; }, never, never, true, never>;
|
|
39
63
|
}
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Ad Slot Component
|
|
3
|
+
*
|
|
4
|
+
* Componente standalone para mostrar ads de Google Ad Manager.
|
|
5
|
+
* Se integra automaticamente con el servicio de Ads y respeta consent + premium.
|
|
6
|
+
*
|
|
7
|
+
* @example
|
|
8
|
+
* ```html
|
|
9
|
+
* <!-- Banner basico -->
|
|
10
|
+
* <val-ad-slot
|
|
11
|
+
* slotId="homepage-top"
|
|
12
|
+
* adUnitPath="/homepage/top"
|
|
13
|
+
* size="leaderboard"
|
|
14
|
+
* />
|
|
15
|
+
*
|
|
16
|
+
* <!-- Con responsivo -->
|
|
17
|
+
* <val-ad-slot
|
|
18
|
+
* slotId="sidebar-ad"
|
|
19
|
+
* adUnitPath="/sidebar"
|
|
20
|
+
* [size]="['medium-rectangle', 'half-page']"
|
|
21
|
+
* [sizeMapping]="[
|
|
22
|
+
* { viewportWidth: 1024, sizes: [[300, 600]] },
|
|
23
|
+
* { viewportWidth: 768, sizes: [[300, 250]] },
|
|
24
|
+
* { viewportWidth: 0, sizes: [[320, 50]] }
|
|
25
|
+
* ]"
|
|
26
|
+
* />
|
|
27
|
+
*
|
|
28
|
+
* <!-- Native ad -->
|
|
29
|
+
* <val-ad-slot
|
|
30
|
+
* slotId="article-native"
|
|
31
|
+
* adUnitPath="/article/native"
|
|
32
|
+
* size="native"
|
|
33
|
+
* [isNative]="true"
|
|
34
|
+
* />
|
|
35
|
+
* ```
|
|
36
|
+
*/
|
|
37
|
+
import { OnInit, OnDestroy } from '@angular/core';
|
|
38
|
+
import { AdsService } from '../../../services/ads/ads.service';
|
|
39
|
+
import { AdSlotSize, AdSlotState, SizeMapping } from '../../../services/ads/types';
|
|
40
|
+
import * as i0 from "@angular/core";
|
|
41
|
+
export declare class AdSlotComponent implements OnInit, OnDestroy {
|
|
42
|
+
readonly adsService: AdsService;
|
|
43
|
+
private readonly platformId;
|
|
44
|
+
/** ID unico del slot */
|
|
45
|
+
slotId: string;
|
|
46
|
+
/** Ad unit path (sin el network ID) */
|
|
47
|
+
adUnitPath: string;
|
|
48
|
+
/** Tamano del ad */
|
|
49
|
+
size: AdSlotSize | AdSlotSize[] | [number, number] | [number, number][];
|
|
50
|
+
/** Mapping responsivo */
|
|
51
|
+
sizeMapping?: SizeMapping[];
|
|
52
|
+
/** Targeting especifico */
|
|
53
|
+
targeting?: Record<string, string | string[]>;
|
|
54
|
+
/** Colapsar si vacio */
|
|
55
|
+
collapseEmpty: boolean;
|
|
56
|
+
/** Es native ad */
|
|
57
|
+
isNative: boolean;
|
|
58
|
+
/** CSS class adicional */
|
|
59
|
+
cssClass: string;
|
|
60
|
+
/** Altura minima */
|
|
61
|
+
minHeight: string;
|
|
62
|
+
/** Mostrar skeleton */
|
|
63
|
+
showSkeleton: boolean;
|
|
64
|
+
private readonly _state;
|
|
65
|
+
readonly state: import("@angular/core").Signal<AdSlotState>;
|
|
66
|
+
/** Indica si el componente debe renderizarse */
|
|
67
|
+
readonly shouldRender: import("@angular/core").Signal<boolean>;
|
|
68
|
+
/** Ancho del skeleton */
|
|
69
|
+
readonly skeletonWidth: import("@angular/core").Signal<string>;
|
|
70
|
+
/** Altura del skeleton */
|
|
71
|
+
readonly skeletonHeight: import("@angular/core").Signal<string>;
|
|
72
|
+
ngOnInit(): Promise<void>;
|
|
73
|
+
ngOnDestroy(): void;
|
|
74
|
+
private initializeSlot;
|
|
75
|
+
private getFirstSize;
|
|
76
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<AdSlotComponent, never>;
|
|
77
|
+
static ɵcmp: i0.ɵɵComponentDeclaration<AdSlotComponent, "val-ad-slot", never, { "slotId": { "alias": "slotId"; "required": true; }; "adUnitPath": { "alias": "adUnitPath"; "required": true; }; "size": { "alias": "size"; "required": false; }; "sizeMapping": { "alias": "sizeMapping"; "required": false; }; "targeting": { "alias": "targeting"; "required": false; }; "collapseEmpty": { "alias": "collapseEmpty"; "required": false; }; "isNative": { "alias": "isNative"; "required": false; }; "cssClass": { "alias": "cssClass"; "required": false; }; "minHeight": { "alias": "minHeight"; "required": false; }; "showSkeleton": { "alias": "showSkeleton"; "required": false; }; }, {}, never, never, true, never>;
|
|
78
|
+
}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { AdsConsentState } from './types';
|
|
2
|
+
import * as i0 from "@angular/core";
|
|
3
|
+
/**
|
|
4
|
+
* Servicio que maneja el consent para ads.
|
|
5
|
+
*
|
|
6
|
+
* Se integra con AnalyticsService para reutilizar el estado de consent GDPR.
|
|
7
|
+
* Si AnalyticsService no esta disponible, usa valores por defecto conservadores.
|
|
8
|
+
*/
|
|
9
|
+
export declare class AdsConsentService {
|
|
10
|
+
private readonly platformId;
|
|
11
|
+
private readonly injector;
|
|
12
|
+
private readonly _consentState;
|
|
13
|
+
/** Estado de consent para ads (readonly) */
|
|
14
|
+
readonly adsConsentState: import("@angular/core").Signal<AdsConsentState>;
|
|
15
|
+
/** Indica si se pueden mostrar ads (al menos consent basico) */
|
|
16
|
+
readonly canShowAds: import("@angular/core").Signal<boolean>;
|
|
17
|
+
/** Indica si se pueden mostrar ads personalizados */
|
|
18
|
+
readonly canPersonalize: import("@angular/core").Signal<boolean>;
|
|
19
|
+
private analyticsService;
|
|
20
|
+
private consentSyncInterval;
|
|
21
|
+
constructor();
|
|
22
|
+
/**
|
|
23
|
+
* Inicializa la sincronizacion con AnalyticsService.
|
|
24
|
+
*/
|
|
25
|
+
private initializeConsentSync;
|
|
26
|
+
/**
|
|
27
|
+
* Sincroniza el estado de consent desde AnalyticsService.
|
|
28
|
+
*/
|
|
29
|
+
private syncWithAnalyticsConsent;
|
|
30
|
+
/**
|
|
31
|
+
* Actualiza el estado de consent desde AnalyticsService.
|
|
32
|
+
*/
|
|
33
|
+
private updateFromAnalyticsConsent;
|
|
34
|
+
/**
|
|
35
|
+
* Establece consent por defecto (sin datos personales).
|
|
36
|
+
*/
|
|
37
|
+
private setDefaultConsent;
|
|
38
|
+
/**
|
|
39
|
+
* Actualiza manualmente el consent para ads.
|
|
40
|
+
* Usar cuando el usuario actualiza sus preferencias directamente.
|
|
41
|
+
*
|
|
42
|
+
* @param consent - Nuevo estado de consent parcial
|
|
43
|
+
*/
|
|
44
|
+
updateConsent(consent: Partial<AdsConsentState>): void;
|
|
45
|
+
/**
|
|
46
|
+
* Aplica el estado de consent actual a GPT.
|
|
47
|
+
*/
|
|
48
|
+
applyConsentToGPT(): void;
|
|
49
|
+
/**
|
|
50
|
+
* Obtiene el estado actual de consent.
|
|
51
|
+
*/
|
|
52
|
+
getConsentState(): AdsConsentState;
|
|
53
|
+
/**
|
|
54
|
+
* Destruye el servicio y limpia recursos.
|
|
55
|
+
*/
|
|
56
|
+
destroy(): void;
|
|
57
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<AdsConsentService, never>;
|
|
58
|
+
static ɵprov: i0.ɵɵInjectableDeclaration<AdsConsentService>;
|
|
59
|
+
}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { ValtechAdsConfig, GPTNamespace } from './types';
|
|
2
|
+
import { AdsConsentService } from './ads-consent.service';
|
|
3
|
+
import * as i0 from "@angular/core";
|
|
4
|
+
/**
|
|
5
|
+
* Servicio para cargar el script de Google Publisher Tags.
|
|
6
|
+
*
|
|
7
|
+
* Implementa lazy loading: el script solo se carga cuando
|
|
8
|
+
* se solicita renderizar el primer ad slot.
|
|
9
|
+
*/
|
|
10
|
+
export declare class AdsLoaderService {
|
|
11
|
+
private config;
|
|
12
|
+
private platformId;
|
|
13
|
+
private consentService;
|
|
14
|
+
private readonly _isLoading;
|
|
15
|
+
private readonly _isLoaded;
|
|
16
|
+
private readonly _error;
|
|
17
|
+
/** Indica si el script esta cargando */
|
|
18
|
+
readonly isLoading: import("@angular/core").Signal<boolean>;
|
|
19
|
+
/** Indica si el script esta cargado */
|
|
20
|
+
readonly isLoaded: import("@angular/core").Signal<boolean>;
|
|
21
|
+
/** Error de carga (si existe) */
|
|
22
|
+
readonly error: import("@angular/core").Signal<Error>;
|
|
23
|
+
private loadPromise;
|
|
24
|
+
constructor(config: ValtechAdsConfig, platformId: Object, consentService: AdsConsentService);
|
|
25
|
+
/**
|
|
26
|
+
* Carga el script GPT de forma lazy.
|
|
27
|
+
* Retorna la instancia de googletag o null si falla.
|
|
28
|
+
*
|
|
29
|
+
* @returns Promise con googletag o null
|
|
30
|
+
*/
|
|
31
|
+
loadGPT(): Promise<GPTNamespace | null>;
|
|
32
|
+
/**
|
|
33
|
+
* Configura GPT con las opciones de la aplicacion.
|
|
34
|
+
*/
|
|
35
|
+
private configureGPT;
|
|
36
|
+
/**
|
|
37
|
+
* Verifica si el script GPT esta disponible.
|
|
38
|
+
*/
|
|
39
|
+
isGPTAvailable(): boolean;
|
|
40
|
+
/**
|
|
41
|
+
* Obtiene la instancia de googletag si esta cargada.
|
|
42
|
+
*/
|
|
43
|
+
getGPT(): GPTNamespace | null;
|
|
44
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<AdsLoaderService, never>;
|
|
45
|
+
static ɵprov: i0.ɵɵInjectableDeclaration<AdsLoaderService>;
|
|
46
|
+
}
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Ads Service
|
|
3
|
+
*
|
|
4
|
+
* Servicio principal para Google Ad Manager (GPT).
|
|
5
|
+
* Integra con el sistema de consent existente y respeta usuarios premium.
|
|
6
|
+
*/
|
|
7
|
+
import { Injector, OnDestroy } from '@angular/core';
|
|
8
|
+
import { Router } from '@angular/router';
|
|
9
|
+
import { AdsLoaderService } from './ads-loader.service';
|
|
10
|
+
import { AdsConsentService } from './ads-consent.service';
|
|
11
|
+
import { ValtechAdsConfig, AdSlotConfig, AdSlotState, AdEvent, GPTNamespace } from './types';
|
|
12
|
+
import * as i0 from "@angular/core";
|
|
13
|
+
/**
|
|
14
|
+
* Servicio principal de Google Ad Manager.
|
|
15
|
+
*
|
|
16
|
+
* Maneja la creacion, destruccion y refresh de ad slots.
|
|
17
|
+
* Integra automaticamente con consent mode y detecta usuarios premium.
|
|
18
|
+
*
|
|
19
|
+
* @example
|
|
20
|
+
* ```typescript
|
|
21
|
+
* @Component({...})
|
|
22
|
+
* export class MyComponent {
|
|
23
|
+
* private ads = inject(AdsService);
|
|
24
|
+
*
|
|
25
|
+
* // Verificar si mostrar ads
|
|
26
|
+
* showAds = this.ads.isEnabled;
|
|
27
|
+
*
|
|
28
|
+
* // Verificar si usuario es premium
|
|
29
|
+
* isPremium = this.ads.isPremiumUser;
|
|
30
|
+
* }
|
|
31
|
+
* ```
|
|
32
|
+
*/
|
|
33
|
+
export declare class AdsService implements OnDestroy {
|
|
34
|
+
private injector;
|
|
35
|
+
private config;
|
|
36
|
+
private platformId;
|
|
37
|
+
private router;
|
|
38
|
+
private loaderService;
|
|
39
|
+
private consentService;
|
|
40
|
+
private readonly _isInitialized;
|
|
41
|
+
private readonly _isEnabled;
|
|
42
|
+
private readonly _isPremiumUser;
|
|
43
|
+
private readonly _isDebugMode;
|
|
44
|
+
private readonly _slots;
|
|
45
|
+
private readonly _slotStates;
|
|
46
|
+
private readonly _events;
|
|
47
|
+
/** Indica si el servicio esta inicializado */
|
|
48
|
+
readonly isInitialized: import("@angular/core").Signal<boolean>;
|
|
49
|
+
/** Indica si los ads estan habilitados (consent + no premium) */
|
|
50
|
+
readonly isEnabled: import("@angular/core").Signal<boolean>;
|
|
51
|
+
/** Indica si el usuario es premium (no ve ads) */
|
|
52
|
+
readonly isPremiumUser: import("@angular/core").Signal<boolean>;
|
|
53
|
+
/** Indica si esta en modo debug */
|
|
54
|
+
readonly isDebugMode: import("@angular/core").Signal<boolean>;
|
|
55
|
+
/** Estado de consent para ads */
|
|
56
|
+
readonly consentState: import("@angular/core").Signal<import("./types").AdsConsentState>;
|
|
57
|
+
/** Eventos de ads (historial) */
|
|
58
|
+
readonly events: import("@angular/core").Signal<AdEvent[]>;
|
|
59
|
+
private activeSlots;
|
|
60
|
+
private routerSubscription;
|
|
61
|
+
private refreshTimerId;
|
|
62
|
+
constructor(injector: Injector, config: ValtechAdsConfig, platformId: Object, router: Router, loaderService: AdsLoaderService, consentService: AdsConsentService);
|
|
63
|
+
/**
|
|
64
|
+
* Inicializa el servicio de ads.
|
|
65
|
+
* Llamado automaticamente por APP_INITIALIZER.
|
|
66
|
+
* NO carga el script GPT hasta que se necesite el primer ad.
|
|
67
|
+
*/
|
|
68
|
+
initialize(): Promise<void>;
|
|
69
|
+
/**
|
|
70
|
+
* Carga el script GPT de forma lazy.
|
|
71
|
+
* Llamado automaticamente cuando se renderiza el primer ad slot.
|
|
72
|
+
*/
|
|
73
|
+
ensureGPTLoaded(): Promise<GPTNamespace | null>;
|
|
74
|
+
/**
|
|
75
|
+
* Define y muestra un ad slot.
|
|
76
|
+
* Llamado internamente por el componente AdSlot.
|
|
77
|
+
*
|
|
78
|
+
* @param config - Configuracion del slot
|
|
79
|
+
* @returns ID del slot o null si no se puede mostrar
|
|
80
|
+
*/
|
|
81
|
+
defineSlot(config: AdSlotConfig): Promise<string | null>;
|
|
82
|
+
/**
|
|
83
|
+
* Destruye un slot y libera recursos.
|
|
84
|
+
*
|
|
85
|
+
* @param slotId - ID del slot a destruir
|
|
86
|
+
*/
|
|
87
|
+
destroySlot(slotId: string): void;
|
|
88
|
+
/**
|
|
89
|
+
* Refresca un slot especifico o todos los slots activos.
|
|
90
|
+
*
|
|
91
|
+
* @param slotIds - IDs de slots a refrescar (undefined = todos)
|
|
92
|
+
*/
|
|
93
|
+
refreshSlots(slotIds?: string[]): void;
|
|
94
|
+
/**
|
|
95
|
+
* Obtiene el estado de un slot.
|
|
96
|
+
*
|
|
97
|
+
* @param slotId - ID del slot
|
|
98
|
+
* @returns Estado actual del slot
|
|
99
|
+
*/
|
|
100
|
+
getSlotState(slotId: string): AdSlotState;
|
|
101
|
+
/**
|
|
102
|
+
* Actualiza el estado premium del usuario.
|
|
103
|
+
* Llamar cuando cambie el estado de suscripcion.
|
|
104
|
+
*
|
|
105
|
+
* @param isPremium - Nuevo estado premium
|
|
106
|
+
*/
|
|
107
|
+
updatePremiumStatus(isPremium: boolean): void;
|
|
108
|
+
/**
|
|
109
|
+
* Destruye todos los slots activos.
|
|
110
|
+
*/
|
|
111
|
+
destroyAllSlots(): void;
|
|
112
|
+
private resolveSizes;
|
|
113
|
+
private buildSizeMapping;
|
|
114
|
+
private applyTargeting;
|
|
115
|
+
private updateSlotState;
|
|
116
|
+
private emitEvent;
|
|
117
|
+
private setupRouteListener;
|
|
118
|
+
private setupAutoRefresh;
|
|
119
|
+
private isRouteExcluded;
|
|
120
|
+
ngOnDestroy(): void;
|
|
121
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<AdsService, never>;
|
|
122
|
+
static ɵprov: i0.ɵɵInjectableDeclaration<AdsService>;
|
|
123
|
+
}
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Ads Configuration
|
|
3
|
+
*
|
|
4
|
+
* Configuracion e inicializacion de Google Ad Manager para Angular.
|
|
5
|
+
* Usa provideValtechAds() en el bootstrap de tu aplicacion.
|
|
6
|
+
*/
|
|
7
|
+
import { EnvironmentProviders, InjectionToken } from '@angular/core';
|
|
8
|
+
import { ValtechAdsConfig, LazyLoadConfig } from './types';
|
|
9
|
+
/**
|
|
10
|
+
* Token de inyeccion para la configuracion de Ads.
|
|
11
|
+
* Usado internamente por los servicios de ads.
|
|
12
|
+
*/
|
|
13
|
+
export declare const VALTECH_ADS_CONFIG: InjectionToken<ValtechAdsConfig>;
|
|
14
|
+
/**
|
|
15
|
+
* Configuracion por defecto de lazy loading.
|
|
16
|
+
*/
|
|
17
|
+
export declare const DEFAULT_LAZY_LOAD_CONFIG: LazyLoadConfig;
|
|
18
|
+
/**
|
|
19
|
+
* Configuracion por defecto del servicio de ads.
|
|
20
|
+
*/
|
|
21
|
+
export declare const DEFAULT_ADS_CONFIG: Partial<ValtechAdsConfig>;
|
|
22
|
+
/**
|
|
23
|
+
* Provee el servicio de Ads a la aplicacion Angular.
|
|
24
|
+
*
|
|
25
|
+
* @param config - Configuracion de Google Ad Manager
|
|
26
|
+
* @returns EnvironmentProviders para usar en bootstrapApplication
|
|
27
|
+
*
|
|
28
|
+
* @example
|
|
29
|
+
* ```typescript
|
|
30
|
+
* // main.ts
|
|
31
|
+
* import { bootstrapApplication } from '@angular/platform-browser';
|
|
32
|
+
* import { provideValtechAds, provideValtechFirebase } from 'valtech-components';
|
|
33
|
+
* import { environment } from './environments/environment';
|
|
34
|
+
*
|
|
35
|
+
* bootstrapApplication(AppComponent, {
|
|
36
|
+
* providers: [
|
|
37
|
+
* // Firebase primero (para consent mode)
|
|
38
|
+
* provideValtechFirebase({
|
|
39
|
+
* firebase: environment.firebase,
|
|
40
|
+
* enableAnalytics: true,
|
|
41
|
+
* }),
|
|
42
|
+
*
|
|
43
|
+
* // Luego Ads
|
|
44
|
+
* provideValtechAds({
|
|
45
|
+
* networkId: '/12345678',
|
|
46
|
+
* debugMode: !environment.production,
|
|
47
|
+
* isPremiumUser: () => inject(AuthService).hasRole('premium'),
|
|
48
|
+
* }),
|
|
49
|
+
* ],
|
|
50
|
+
* });
|
|
51
|
+
* ```
|
|
52
|
+
*
|
|
53
|
+
* @example Con targeting global y rutas excluidas
|
|
54
|
+
* ```typescript
|
|
55
|
+
* provideValtechAds({
|
|
56
|
+
* networkId: '/12345678',
|
|
57
|
+
* globalTargeting: {
|
|
58
|
+
* site: 'myvaltech',
|
|
59
|
+
* section: 'app',
|
|
60
|
+
* },
|
|
61
|
+
* excludeRoutes: [
|
|
62
|
+
* '^/checkout',
|
|
63
|
+
* '^/payment',
|
|
64
|
+
* '^/premium',
|
|
65
|
+
* ],
|
|
66
|
+
* })
|
|
67
|
+
* ```
|
|
68
|
+
*/
|
|
69
|
+
export declare function provideValtechAds(config: ValtechAdsConfig): EnvironmentProviders;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Ads Module
|
|
3
|
+
*
|
|
4
|
+
* Exports publicos para el servicio de Google Ad Manager.
|
|
5
|
+
*/
|
|
6
|
+
export { provideValtechAds, VALTECH_ADS_CONFIG, DEFAULT_ADS_CONFIG, DEFAULT_LAZY_LOAD_CONFIG } from './config';
|
|
7
|
+
export { AdsService } from './ads.service';
|
|
8
|
+
export { AdsConsentService } from './ads-consent.service';
|
|
9
|
+
export { AdsLoaderService } from './ads-loader.service';
|
|
10
|
+
export { ValtechAdsConfig, LazyLoadConfig, AdSlotConfig, AdSlotSize, AD_SIZE_MAP, SizeMapping, AdSlotState, AdEvent, AdsConsentState, GPTSlot, GPTNamespace, GPTPubadsService, GPTSizeMappingBuilder, GPTEvent, } from './types';
|
|
@@ -0,0 +1,163 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Ads Types
|
|
3
|
+
*
|
|
4
|
+
* Tipos e interfaces para el servicio de Google Ad Manager.
|
|
5
|
+
* Usa Google Publisher Tags (GPT) para renderizar ads.
|
|
6
|
+
*/
|
|
7
|
+
/**
|
|
8
|
+
* Configuracion del servicio de Ads.
|
|
9
|
+
* Pasada a provideValtechAds() en el bootstrap de la aplicacion.
|
|
10
|
+
*/
|
|
11
|
+
export interface ValtechAdsConfig {
|
|
12
|
+
/** Network ID de Google Ad Manager (ej: '/12345678') */
|
|
13
|
+
networkId: string;
|
|
14
|
+
/** Habilitar modo debug (muestra info de ads en consola) */
|
|
15
|
+
debugMode?: boolean;
|
|
16
|
+
/** Activar lazy loading de ads (viewport intersection) */
|
|
17
|
+
lazyLoad?: boolean;
|
|
18
|
+
/** Configuracion de lazy loading */
|
|
19
|
+
lazyLoadConfig?: LazyLoadConfig;
|
|
20
|
+
/** Funcion para determinar si el usuario es premium (sin ads) */
|
|
21
|
+
isPremiumUser?: () => boolean;
|
|
22
|
+
/** Configuracion por defecto para ad slots */
|
|
23
|
+
defaultSlotConfig?: Partial<AdSlotConfig>;
|
|
24
|
+
/** Targeting global (aplica a todos los slots) */
|
|
25
|
+
globalTargeting?: Record<string, string | string[]>;
|
|
26
|
+
/** Habilitar personalizacion de ads (requiere consent) */
|
|
27
|
+
enablePersonalization?: boolean;
|
|
28
|
+
/** Mostrar ads de fallback si no hay consent */
|
|
29
|
+
showNonPersonalizedAds?: boolean;
|
|
30
|
+
/** Callback cuando se carga un ad */
|
|
31
|
+
onAdLoaded?: (slotId: string, isEmpty: boolean) => void;
|
|
32
|
+
/** Callback cuando falla un ad */
|
|
33
|
+
onAdError?: (slotId: string, error: Error) => void;
|
|
34
|
+
/** Refresh automatico de ads (en segundos, 0 = deshabilitado) */
|
|
35
|
+
autoRefreshInterval?: number;
|
|
36
|
+
/** Rutas donde NO mostrar ads (regex patterns) */
|
|
37
|
+
excludeRoutes?: string[];
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Configuracion de lazy loading para GPT.
|
|
41
|
+
*/
|
|
42
|
+
export interface LazyLoadConfig {
|
|
43
|
+
/** Margen del viewport para cargar (ej: '200px') */
|
|
44
|
+
rootMargin?: string;
|
|
45
|
+
/** Threshold de interseccion (0-1) */
|
|
46
|
+
threshold?: number;
|
|
47
|
+
/** Fetch margin para GPT (pixels antes del viewport) */
|
|
48
|
+
fetchMarginPercent?: number;
|
|
49
|
+
/** Render margin para GPT */
|
|
50
|
+
renderMarginPercent?: number;
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Tamanos de ad predefinidos (IAB standard).
|
|
54
|
+
*/
|
|
55
|
+
export type AdSlotSize = 'leaderboard' | 'billboard' | 'medium-rectangle' | 'large-rectangle' | 'half-page' | 'skyscraper' | 'mobile-banner' | 'mobile-leaderboard' | 'fluid' | 'native' | 'custom';
|
|
56
|
+
/**
|
|
57
|
+
* Mapeo de tamanos predefinidos a dimensiones.
|
|
58
|
+
*/
|
|
59
|
+
export declare const AD_SIZE_MAP: Record<AdSlotSize, [number, number] | 'fluid'>;
|
|
60
|
+
/**
|
|
61
|
+
* Configuracion de un ad slot individual.
|
|
62
|
+
*/
|
|
63
|
+
export interface AdSlotConfig {
|
|
64
|
+
/** ID unico del slot (usado para el div container) */
|
|
65
|
+
slotId: string;
|
|
66
|
+
/** Ad unit path (ej: '/homepage/top') - se concatena con networkId */
|
|
67
|
+
adUnitPath: string;
|
|
68
|
+
/** Tamano del ad o tamanos responsivos */
|
|
69
|
+
size: AdSlotSize | AdSlotSize[] | [number, number] | [number, number][];
|
|
70
|
+
/** Mapping responsivo: [viewport-width, sizes] */
|
|
71
|
+
sizeMapping?: SizeMapping[];
|
|
72
|
+
/** Targeting especifico para este slot */
|
|
73
|
+
targeting?: Record<string, string | string[]>;
|
|
74
|
+
/** Colapsar slot si esta vacio */
|
|
75
|
+
collapseEmpty?: boolean;
|
|
76
|
+
/** Es un native ad */
|
|
77
|
+
isNative?: boolean;
|
|
78
|
+
/** CSS class adicional */
|
|
79
|
+
cssClass?: string;
|
|
80
|
+
/** Altura minima mientras carga */
|
|
81
|
+
minHeight?: string;
|
|
82
|
+
/** Mostrar skeleton mientras carga */
|
|
83
|
+
showSkeleton?: boolean;
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* Mapping de tamanos responsivos.
|
|
87
|
+
* Define que tamanos de ad mostrar segun el viewport.
|
|
88
|
+
*/
|
|
89
|
+
export interface SizeMapping {
|
|
90
|
+
/** Ancho minimo del viewport */
|
|
91
|
+
viewportWidth: number;
|
|
92
|
+
/** Tamanos de ad para este viewport */
|
|
93
|
+
sizes: ([number, number] | 'fluid')[];
|
|
94
|
+
}
|
|
95
|
+
/**
|
|
96
|
+
* Estado de un ad slot.
|
|
97
|
+
*/
|
|
98
|
+
export type AdSlotState = 'idle' | 'loading' | 'rendered' | 'empty' | 'hidden' | 'error';
|
|
99
|
+
/**
|
|
100
|
+
* Evento emitido por el servicio de ads.
|
|
101
|
+
*/
|
|
102
|
+
export interface AdEvent {
|
|
103
|
+
type: 'loaded' | 'empty' | 'error' | 'viewable' | 'clicked';
|
|
104
|
+
slotId: string;
|
|
105
|
+
timestamp: Date;
|
|
106
|
+
isEmpty?: boolean;
|
|
107
|
+
error?: Error;
|
|
108
|
+
}
|
|
109
|
+
/**
|
|
110
|
+
* Estado de consent para ads (mapeado desde AnalyticsService).
|
|
111
|
+
*/
|
|
112
|
+
export interface AdsConsentState {
|
|
113
|
+
/** Permite almacenamiento de ads */
|
|
114
|
+
adStorage: boolean;
|
|
115
|
+
/** Permite personalizacion de ads */
|
|
116
|
+
adPersonalization: boolean;
|
|
117
|
+
/** Permite datos de usuario para ads */
|
|
118
|
+
adUserData: boolean;
|
|
119
|
+
}
|
|
120
|
+
/** GPT Slot reference */
|
|
121
|
+
export interface GPTSlot {
|
|
122
|
+
getSlotElementId(): string;
|
|
123
|
+
getAdUnitPath(): string;
|
|
124
|
+
addService(service: unknown): GPTSlot;
|
|
125
|
+
defineSizeMapping(mapping: unknown): GPTSlot;
|
|
126
|
+
setTargeting(key: string, value: string | string[]): GPTSlot;
|
|
127
|
+
setCollapseEmptyDiv(collapse: boolean, collapseBeforeAdFetch?: boolean): GPTSlot;
|
|
128
|
+
}
|
|
129
|
+
/** GPT global namespace (window.googletag) */
|
|
130
|
+
export interface GPTNamespace {
|
|
131
|
+
cmd: Array<() => void>;
|
|
132
|
+
defineSlot(adUnitPath: string, size: unknown, divId: string): GPTSlot | null;
|
|
133
|
+
pubads(): GPTPubadsService;
|
|
134
|
+
enableServices(): void;
|
|
135
|
+
display(divId: string): void;
|
|
136
|
+
destroySlots(slots?: GPTSlot[]): boolean;
|
|
137
|
+
sizeMapping(): GPTSizeMappingBuilder;
|
|
138
|
+
}
|
|
139
|
+
/** GPT Pubads Service */
|
|
140
|
+
export interface GPTPubadsService {
|
|
141
|
+
enableSingleRequest(): void;
|
|
142
|
+
enableLazyLoad(config?: object): void;
|
|
143
|
+
setTargeting(key: string, value: string | string[]): void;
|
|
144
|
+
setRequestNonPersonalizedAds(value: 0 | 1): void;
|
|
145
|
+
addEventListener(event: string, callback: (event: GPTEvent) => void): void;
|
|
146
|
+
refresh(slots?: GPTSlot[]): void;
|
|
147
|
+
collapseEmptyDivs(collapseBeforeAdFetch?: boolean): void;
|
|
148
|
+
}
|
|
149
|
+
/** GPT Size Mapping Builder */
|
|
150
|
+
export interface GPTSizeMappingBuilder {
|
|
151
|
+
addSize(viewport: [number, number], sizes: unknown): GPTSizeMappingBuilder;
|
|
152
|
+
build(): unknown;
|
|
153
|
+
}
|
|
154
|
+
/** GPT Event */
|
|
155
|
+
export interface GPTEvent {
|
|
156
|
+
slot: GPTSlot;
|
|
157
|
+
isEmpty?: boolean;
|
|
158
|
+
}
|
|
159
|
+
declare global {
|
|
160
|
+
interface Window {
|
|
161
|
+
googletag?: GPTNamespace;
|
|
162
|
+
}
|
|
163
|
+
}
|
package/package.json
CHANGED
package/public-api.d.ts
CHANGED
|
@@ -221,6 +221,8 @@ export * from './lib/services/firebase';
|
|
|
221
221
|
export * from './lib/services/auth';
|
|
222
222
|
export * from './lib/services/i18n';
|
|
223
223
|
export * from './lib/services/presets';
|
|
224
|
+
export * from './lib/services/ads';
|
|
225
|
+
export * from './lib/components/molecules/ad-slot/ad-slot.component';
|
|
224
226
|
export * from './lib/components/types';
|
|
225
227
|
export * from './lib/shared/pipes/process-links.pipe';
|
|
226
228
|
export * from './lib/shared/utils/dom';
|