@adstage/web-sdk 1.3.4 → 2.0.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.
Files changed (60) hide show
  1. package/README.md +539 -34
  2. package/dist/index.cjs.js +753 -509
  3. package/dist/index.d.ts +286 -97
  4. package/dist/index.esm.js +737 -485
  5. package/dist/index.standalone.js +737 -485
  6. package/package.json +12 -13
  7. package/src/constants/endpoints.ts +93 -0
  8. package/src/core/AdStage.ts +128 -0
  9. package/src/index.ts +14 -432
  10. package/src/managers/{slider-manager.ts → carousel-slider-manager.ts} +9 -8
  11. package/src/managers/event-tracker.ts +2 -4
  12. package/src/managers/{fade-slider-manager.ts → text-transition-manager.ts} +7 -7
  13. package/src/modules/ads/AdsModule.ts +525 -0
  14. package/src/modules/config/ConfigModule.ts +124 -0
  15. package/src/modules/events/EventsModule.ts +106 -0
  16. package/src/types/config.ts +74 -3
  17. package/src/types/index.ts +2 -1
  18. package/src/utils/api-headers.ts +52 -0
  19. package/src/utils/dom-utils.ts +1 -1
  20. package/examples/README.md +0 -33
  21. package/examples/banner-ads.html +0 -512
  22. package/examples/index.html +0 -338
  23. package/examples/native-ads.html +0 -634
  24. package/examples/react-app/README.md +0 -70
  25. package/examples/react-app/index.html +0 -13
  26. package/examples/react-app/package-lock.json +0 -3042
  27. package/examples/react-app/package.json +0 -26
  28. package/examples/react-app/pnpm-lock.yaml +0 -1857
  29. package/examples/react-app/public/index.standalone.js +0 -2331
  30. package/examples/react-app/src/App.tsx +0 -226
  31. package/examples/react-app/src/index.css +0 -37
  32. package/examples/react-app/src/main.tsx +0 -10
  33. package/examples/react-app/tsconfig.json +0 -25
  34. package/examples/react-app/tsconfig.node.json +0 -10
  35. package/examples/react-app/vite.config.ts +0 -15
  36. package/examples/react-nextjs/app/globals.css +0 -200
  37. package/examples/react-nextjs/app/layout.tsx +0 -27
  38. package/examples/react-nextjs/app/page.tsx +0 -258
  39. package/examples/react-nextjs/next.config.js +0 -9
  40. package/examples/react-nextjs/package.json +0 -22
  41. package/examples/react-nextjs/pnpm-lock.yaml +0 -343
  42. package/examples/react-nextjs/tsconfig.json +0 -34
  43. package/examples/text-ads.html +0 -597
  44. package/examples/video-ads.html +0 -739
  45. package/src/react/components/AdErrorBoundary.tsx +0 -75
  46. package/src/react/components/AdSlot.tsx +0 -144
  47. package/src/react/components/BannerAd.tsx +0 -24
  48. package/src/react/components/InterstitialAd.tsx +0 -24
  49. package/src/react/components/NativeAd.tsx +0 -24
  50. package/src/react/components/TextAd.tsx +0 -24
  51. package/src/react/components/VideoAd.tsx +0 -24
  52. package/src/react/components/index.ts +0 -8
  53. package/src/react/hooks/index.ts +0 -4
  54. package/src/react/hooks/useAdSlot.ts +0 -83
  55. package/src/react/hooks/useAdStage.ts +0 -14
  56. package/src/react/hooks/useAdTracking.ts +0 -61
  57. package/src/react/index.ts +0 -4
  58. package/src/react/providers/AdStageProvider.tsx +0 -86
  59. package/src/react/providers/index.ts +0 -2
  60. package/src/utils/sdk-standalone.ts +0 -155
@@ -1,155 +0,0 @@
1
- /**
2
- * AdStage SDK Standalone API
3
- * 간단하고 직관적인 사용을 위한 통합 API
4
- */
5
-
6
- import type { AdType, AdSlotConfig } from '../types';
7
-
8
- // 간단한 설정 인터페이스
9
- export interface SimpleAdStageConfig {
10
- apiKey: string;
11
- debug?: boolean;
12
- baseUrl?: string;
13
- }
14
-
15
- let globalSDKInstance: any = null;
16
- let isInitializing = false;
17
-
18
- /**
19
- * SDK 초기화 (한 번만 호출)
20
- */
21
- export async function initAdStage(config: SimpleAdStageConfig): Promise<void> {
22
- if (globalSDKInstance) {
23
- console.warn('AdStage SDK가 이미 초기화되었습니다.');
24
- return;
25
- }
26
-
27
- if (isInitializing) {
28
- console.warn('AdStage SDK 초기화가 진행 중입니다.');
29
- return;
30
- }
31
-
32
- isInitializing = true;
33
-
34
- try {
35
- // 동적 import로 circular dependency 방지
36
- const { AdStageSDK } = await import('../index');
37
- globalSDKInstance = AdStageSDK.init({
38
- apiKey: config.apiKey,
39
- debug: config.debug || false
40
- });
41
- console.log('✅ AdStage SDK 초기화 완료');
42
- } catch (error) {
43
- console.error('❌ AdStage SDK 초기화 실패:', error);
44
- throw error;
45
- } finally {
46
- isInitializing = false;
47
- }
48
- }
49
-
50
- /**
51
- * 배너 광고 생성 (가장 간단한 API)
52
- */
53
- export async function createBanner(
54
- containerId: string,
55
- options?: {
56
- width?: string | number;
57
- height?: string | number;
58
- autoSlide?: boolean;
59
- slideInterval?: number;
60
- }
61
- ): Promise<void> {
62
- if (!globalSDKInstance) {
63
- throw new Error('AdStage SDK가 초기화되지 않았습니다. initAdStage()를 먼저 호출하세요.');
64
- }
65
-
66
- const slotId = `banner-${Date.now()}-${Math.random().toString(36).substr(2, 9)}`;
67
-
68
- return globalSDKInstance.createSlot(slotId, containerId, 'BANNER' as AdType, {
69
- width: options?.width || '100%',
70
- height: options?.height || 120,
71
- autoSlideInterval: options?.autoSlide ? (options.slideInterval || 5) : 0,
72
- sliderEffect: 'fade'
73
- });
74
- }
75
-
76
- /**
77
- * 텍스트 광고 생성
78
- */
79
- export async function createTextAd(
80
- containerId: string,
81
- options?: {
82
- maxLines?: number;
83
- style?: 'minimal' | 'card' | 'banner';
84
- }
85
- ): Promise<void> {
86
- if (!globalSDKInstance) {
87
- throw new Error('AdStage SDK가 초기화되지 않았습니다.');
88
- }
89
-
90
- const slotId = `text-${Date.now()}-${Math.random().toString(36).substr(2, 9)}`;
91
-
92
- return globalSDKInstance.createSlot(slotId, containerId, 'TEXT' as AdType, {
93
- maxLines: options?.maxLines || 3,
94
- style: options?.style || 'card'
95
- });
96
- }
97
-
98
- /**
99
- * 비디오 광고 생성
100
- */
101
- export async function createVideoAd(
102
- containerId: string,
103
- options?: {
104
- width?: string | number;
105
- height?: string | number;
106
- autoplay?: boolean;
107
- muted?: boolean;
108
- }
109
- ): Promise<void> {
110
- if (!globalSDKInstance) {
111
- throw new Error('AdStage SDK가 초기화되지 않았습니다.');
112
- }
113
-
114
- const slotId = `video-${Date.now()}-${Math.random().toString(36).substr(2, 9)}`;
115
-
116
- return globalSDKInstance.createSlot(slotId, containerId, 'VIDEO' as AdType, {
117
- width: options?.width || '100%',
118
- height: options?.height || 300,
119
- autoplay: options?.autoplay || false,
120
- muted: options?.muted || true
121
- });
122
- }
123
-
124
- /**
125
- * SDK 상태 확인
126
- */
127
- export function isAdStageReady(): boolean {
128
- return globalSDKInstance !== null && !isInitializing;
129
- }
130
-
131
- /**
132
- * SDK 인스턴스 가져오기 (고급 사용자용)
133
- */
134
- export function getAdStageInstance() {
135
- if (!globalSDKInstance) {
136
- console.warn('AdStage SDK가 초기화되지 않았습니다.');
137
- return null;
138
- }
139
- return globalSDKInstance;
140
- }
141
-
142
- /**
143
- * SDK 초기화 해제 (필요시)
144
- */
145
- export function destroyAdStage(): void {
146
- if (globalSDKInstance) {
147
- try {
148
- // SDK cleanup logic here
149
- globalSDKInstance = null;
150
- console.log('🧹 AdStage SDK 정리 완료');
151
- } catch (error) {
152
- console.error('SDK 정리 중 오류:', error);
153
- }
154
- }
155
- }