@adstage/web-sdk 2.3.6 → 2.4.0
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/README.md +1 -1
- package/dist/index.cjs.js +2239 -2339
- package/dist/index.d.ts +12 -71
- package/dist/index.esm.js +2240 -2337
- package/dist/index.standalone.js +2214 -2383
- package/package.json +1 -1
- package/src/core/AdStage.ts +0 -9
- package/src/index.ts +0 -3
- package/src/managers/ads/advertisement-event-tracker.ts +8 -15
- package/src/managers/ads/carousel-slider-manager.ts +4 -35
- package/src/managers/ads/text-transition-manager.ts +1 -2
- package/src/managers/ads/viewable-event-tracker.ts +1 -5
- package/src/modules/ads/AdRenderer.ts +730 -0
- package/src/modules/ads/AdsModule.ts +27 -718
- package/src/react/AdStageProvider.tsx +0 -117
- package/src/react/index.ts +0 -11
- package/src/renderers/base-renderer.ts +5 -11
- package/src/types/advertisement.ts +17 -4
- package/src/types/api.ts +5 -1
|
@@ -1,117 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* AdStage SDK - React Provider
|
|
3
|
-
* React 애플리케이션에서 AdStage SDK를 쉽게 사용할 수 있도록 하는 Provider 컴포넌트
|
|
4
|
-
*/
|
|
5
|
-
|
|
6
|
-
import React, { createContext, useContext, useEffect, useState, ReactNode } from 'react';
|
|
7
|
-
import AdStage from '../core/AdStage';
|
|
8
|
-
import { AdStageConfig } from '../types/config';
|
|
9
|
-
|
|
10
|
-
interface AdStageContextType {
|
|
11
|
-
isInitialized: boolean;
|
|
12
|
-
config: AdStageConfig | null;
|
|
13
|
-
initialize: (config: AdStageConfig) => void;
|
|
14
|
-
reset: () => void;
|
|
15
|
-
error: string | null;
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
const AdStageContext = createContext<AdStageContextType | null>(null);
|
|
19
|
-
|
|
20
|
-
interface AdStageProviderProps {
|
|
21
|
-
children: ReactNode;
|
|
22
|
-
/**
|
|
23
|
-
* 자동 초기화를 위한 설정 (선택사항)
|
|
24
|
-
* 제공되면 Provider 마운트 시 자동으로 초기화됩니다.
|
|
25
|
-
*/
|
|
26
|
-
config?: AdStageConfig;
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
export function AdStageProvider({ children, config }: AdStageProviderProps) {
|
|
30
|
-
const [isInitialized, setIsInitialized] = useState(false);
|
|
31
|
-
const [currentConfig, setCurrentConfig] = useState<AdStageConfig | null>(null);
|
|
32
|
-
const [error, setError] = useState<string | null>(null);
|
|
33
|
-
|
|
34
|
-
const initialize = (newConfig: AdStageConfig) => {
|
|
35
|
-
try {
|
|
36
|
-
setError(null);
|
|
37
|
-
|
|
38
|
-
// 기존 인스턴스가 있으면 리셋
|
|
39
|
-
if (isInitialized) {
|
|
40
|
-
AdStage.reset();
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
AdStage.init(newConfig);
|
|
44
|
-
|
|
45
|
-
setCurrentConfig(newConfig);
|
|
46
|
-
setIsInitialized(true);
|
|
47
|
-
|
|
48
|
-
if (newConfig.debug) {
|
|
49
|
-
console.log('✅ AdStage SDK initialized successfully via React Provider');
|
|
50
|
-
}
|
|
51
|
-
} catch (err) {
|
|
52
|
-
const errorMessage = err instanceof Error ? err.message : 'Unknown error';
|
|
53
|
-
setError(errorMessage);
|
|
54
|
-
console.error('❌ AdStage SDK initialization failed:', err);
|
|
55
|
-
setIsInitialized(false);
|
|
56
|
-
setCurrentConfig(null);
|
|
57
|
-
}
|
|
58
|
-
};
|
|
59
|
-
|
|
60
|
-
const reset = () => {
|
|
61
|
-
try {
|
|
62
|
-
AdStage.reset();
|
|
63
|
-
setIsInitialized(false);
|
|
64
|
-
setCurrentConfig(null);
|
|
65
|
-
setError(null);
|
|
66
|
-
} catch (err) {
|
|
67
|
-
console.error('❌ AdStage SDK reset failed:', err);
|
|
68
|
-
}
|
|
69
|
-
};
|
|
70
|
-
|
|
71
|
-
// 자동 초기화
|
|
72
|
-
useEffect(() => {
|
|
73
|
-
if (config && !isInitialized) {
|
|
74
|
-
initialize(config);
|
|
75
|
-
}
|
|
76
|
-
}, [config, isInitialized]);
|
|
77
|
-
|
|
78
|
-
const contextValue: AdStageContextType = {
|
|
79
|
-
isInitialized,
|
|
80
|
-
config: currentConfig,
|
|
81
|
-
initialize,
|
|
82
|
-
reset,
|
|
83
|
-
error
|
|
84
|
-
};
|
|
85
|
-
|
|
86
|
-
return (
|
|
87
|
-
<AdStageContext.Provider value={contextValue}>
|
|
88
|
-
{children}
|
|
89
|
-
</AdStageContext.Provider>
|
|
90
|
-
);
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
/**
|
|
94
|
-
* AdStage Context Hook
|
|
95
|
-
* AdStageProvider 내에서 SDK 상태에 접근할 수 있습니다.
|
|
96
|
-
*/
|
|
97
|
-
export function useAdStage(): AdStageContextType {
|
|
98
|
-
const context = useContext(AdStageContext);
|
|
99
|
-
if (!context) {
|
|
100
|
-
throw new Error('useAdStage must be used within an AdStageProvider');
|
|
101
|
-
}
|
|
102
|
-
return context;
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
/**
|
|
106
|
-
* AdStage SDK Hook
|
|
107
|
-
* 초기화된 AdStage 인스턴스에 직접 접근할 수 있습니다.
|
|
108
|
-
*/
|
|
109
|
-
export function useAdStageSDK() {
|
|
110
|
-
const { isInitialized } = useAdStage();
|
|
111
|
-
|
|
112
|
-
if (!isInitialized) {
|
|
113
|
-
throw new Error('AdStage SDK is not initialized. Please call initialize() first or provide config to AdStageProvider.');
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
return AdStage;
|
|
117
|
-
}
|
package/src/react/index.ts
CHANGED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* AdStage Web SDK - React Integration
|
|
3
|
-
* React 애플리케이션을 위한 컴포넌트와 훅들
|
|
4
|
-
*/
|
|
5
|
-
|
|
6
|
-
export { AdStageProvider, useAdStage, useAdStageSDK } from './AdStageProvider';
|
|
7
|
-
|
|
8
|
-
// 타입들도 재export
|
|
9
|
-
export type { AdStageConfig, ModuleName, BaseModule } from '../types/config';
|
|
10
|
-
export type { AdOptions } from '../modules/ads/AdsModule';
|
|
11
|
-
export type { AdType, AdEventType, Advertisement, AdSlot } from '../types/advertisement';
|
|
@@ -108,24 +108,18 @@ export abstract class BaseAdRenderer implements AdRenderer {
|
|
|
108
108
|
protected getImageStyles(slot?: AdSlot): Record<string, string> {
|
|
109
109
|
const styles: Record<string, string> = {
|
|
110
110
|
display: 'block',
|
|
111
|
-
'
|
|
111
|
+
'max-width': '100%',
|
|
112
|
+
height: 'auto',
|
|
112
113
|
};
|
|
113
114
|
|
|
114
|
-
// 사용자가 컨테이너 크기를
|
|
115
|
+
// 사용자가 컨테이너 크기를 지정한 경우에만 크기 제한
|
|
115
116
|
const parsedWidth = this.parseSizeValue(slot?.width);
|
|
116
117
|
const parsedHeight = this.parseSizeValue(slot?.height);
|
|
117
|
-
const hasUserDefinedSize = parsedWidth || parsedHeight;
|
|
118
118
|
|
|
119
|
-
if (
|
|
120
|
-
// 🎯 사용자가 크기를 지정한 경우: 컨테이너에 꽉 차도록 설정
|
|
119
|
+
if (parsedWidth && parsedHeight) {
|
|
121
120
|
styles.width = '100%';
|
|
122
121
|
styles.height = '100%';
|
|
123
|
-
styles['object-fit'] = 'cover';
|
|
124
|
-
styles['object-position'] = 'center';
|
|
125
|
-
} else {
|
|
126
|
-
// 사용자가 크기를 지정하지 않은 경우: 원본 이미지 크기 유지
|
|
127
|
-
styles['max-width'] = '100%';
|
|
128
|
-
styles.height = 'auto';
|
|
122
|
+
styles['object-fit'] = 'cover';
|
|
129
123
|
}
|
|
130
124
|
|
|
131
125
|
return styles;
|
|
@@ -16,8 +16,15 @@ export enum Platform {
|
|
|
16
16
|
|
|
17
17
|
// 광고 이벤트 타입
|
|
18
18
|
export enum AdEventType {
|
|
19
|
-
|
|
19
|
+
IMPRESSION = 'IMPRESSION',
|
|
20
20
|
CLICK = 'CLICK',
|
|
21
|
+
HOVER = 'HOVER',
|
|
22
|
+
VIEWABLE = 'VIEWABLE',
|
|
23
|
+
VIEWABLE_IMPRESSION = 'VIEWABLE_IMPRESSION',
|
|
24
|
+
COMPLETED = 'COMPLETED',
|
|
25
|
+
VIDEO_START = 'VIDEO_START',
|
|
26
|
+
VIDEO_COMPLETE = 'VIDEO_COMPLETE',
|
|
27
|
+
ERROR = 'ERROR',
|
|
21
28
|
}
|
|
22
29
|
|
|
23
30
|
// 디바이스 타입
|
|
@@ -72,7 +79,7 @@ export interface ViewabilityMetrics {
|
|
|
72
79
|
isViewable: boolean;
|
|
73
80
|
visibilityRatio: number;
|
|
74
81
|
duration: number;
|
|
75
|
-
|
|
82
|
+
impressions: number;
|
|
76
83
|
attentionTime: number;
|
|
77
84
|
scrollDepth: number;
|
|
78
85
|
completionRate: number;
|
|
@@ -164,7 +171,7 @@ export interface AdSlot {
|
|
|
164
171
|
config?: AdSlotConfig;
|
|
165
172
|
advertisement?: Advertisement;
|
|
166
173
|
isViewable?: boolean;
|
|
167
|
-
|
|
174
|
+
impressionSent?: boolean;
|
|
168
175
|
loadTime?: number;
|
|
169
176
|
renderTime?: number;
|
|
170
177
|
events?: AdEvent[];
|
|
@@ -178,7 +185,13 @@ export interface AdSlot {
|
|
|
178
185
|
|
|
179
186
|
// 광고 성과 지표
|
|
180
187
|
export interface AdAnalytics {
|
|
181
|
-
|
|
188
|
+
impressions: number;
|
|
182
189
|
clicks: number;
|
|
190
|
+
hovers: number;
|
|
191
|
+
viewableImpressions: number;
|
|
192
|
+
errors: number;
|
|
183
193
|
ctr: number; // Click Through Rate
|
|
194
|
+
viewabilityRate: number;
|
|
195
|
+
averageViewTime: number;
|
|
196
|
+
totalViewTime: number;
|
|
184
197
|
}
|
package/src/types/api.ts
CHANGED
|
@@ -76,9 +76,13 @@ export interface AnalyticsRequest {
|
|
|
76
76
|
|
|
77
77
|
// 광고 분석 응답
|
|
78
78
|
export interface AnalyticsResponse {
|
|
79
|
-
|
|
79
|
+
impressions: number;
|
|
80
80
|
clicks: number;
|
|
81
|
+
hovers: number;
|
|
82
|
+
viewableImpressions: number;
|
|
83
|
+
errors: number;
|
|
81
84
|
ctr: number;
|
|
85
|
+
viewabilityRate: number;
|
|
82
86
|
breakdown?: Record<string, AdAnalytics>;
|
|
83
87
|
}
|
|
84
88
|
|