@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
package/dist/index.d.ts CHANGED
@@ -1,3 +1,60 @@
1
+ /**
2
+ * AdStage SDK 모듈 타입
3
+ */
4
+ type ModuleName = 'ads' | 'events' | 'config';
5
+ /**
6
+ * AdStage SDK 초기화 설정
7
+ */
8
+ interface AdStageConfig {
9
+ /** API 키 (조직 정보 자동 추출) */
10
+ apiKey: string;
11
+ /** 디버그 모드 활성화 */
12
+ debug?: boolean;
13
+ /** API 기본 URL (선택사항, 기본값: 환경 자동 감지) */
14
+ baseUrl?: string;
15
+ /** 로드할 모듈 선택 (기본값: 모든 모듈) */
16
+ modules?: ModuleName[];
17
+ /** 요청 타임아웃 (ms) */
18
+ timeout?: number;
19
+ /** 초기화시 API 키 검증 여부 (기본값: false) */
20
+ validateOnInit?: boolean;
21
+ /** 네트워크 오류시 fallback 모드 사용 (기본값: true) */
22
+ fallbackMode?: boolean;
23
+ /** 오프라인 모드 (기본값: false) */
24
+ offlineMode?: boolean;
25
+ /** 프로덕션 모드 (엄격한 검증, 기본값: false) */
26
+ productionMode?: boolean;
27
+ }
28
+ /**
29
+ * 모듈 기본 인터페이스
30
+ */
31
+ interface BaseModule {
32
+ /** 모듈 초기화 (동기) */
33
+ init(config: AdStageConfig): void;
34
+ /** 모듈 준비 상태 확인 */
35
+ isReady(): boolean;
36
+ /** 모듈 설정 반환 */
37
+ getConfig(): any;
38
+ }
39
+ /**
40
+ * API 응답 기본 타입
41
+ */
42
+ interface ApiResponse<T = any> {
43
+ success: boolean;
44
+ data?: T;
45
+ error?: string;
46
+ message?: string;
47
+ }
48
+ /**
49
+ * 조직 정보
50
+ */
51
+ interface OrganizationInfo {
52
+ id: string;
53
+ name: string;
54
+ slug: string;
55
+ settings: Record<string, any>;
56
+ }
57
+
1
58
  declare enum AdType {
2
59
  BANNER = "BANNER",
3
60
  POPUP = "POPUP",
@@ -153,141 +210,273 @@ interface AdSlot {
153
210
  }
154
211
 
155
212
  /**
156
- * AdStage SDK Standalone API
157
- * 간단하고 직관적인 사용을 위한 통합 API
213
+ * AdStage SDK - Ads 모듈
214
+ * 광고 관리 렌더링 기능
158
215
  */
159
- interface SimpleAdStageConfig {
160
- apiKey: string;
161
- debug?: boolean;
162
- baseUrl?: string;
163
- }
164
- /**
165
- * SDK 초기화 (한 번만 호출)
166
- */
167
- declare function initAdStage(config: SimpleAdStageConfig): Promise<void>;
168
- /**
169
- * 배너 광고 생성 (가장 간단한 API)
170
- */
171
- declare function createBanner(containerId: string, options?: {
216
+
217
+ interface AdOptions {
172
218
  width?: string | number;
173
- height?: string | number;
219
+ height?: number;
174
220
  autoSlide?: boolean;
175
221
  slideInterval?: number;
176
- }): Promise<void>;
177
- /**
178
- * 텍스트 광고 생성
179
- */
180
- declare function createTextAd(containerId: string, options?: {
181
222
  maxLines?: number;
182
- style?: 'minimal' | 'card' | 'banner';
183
- }): Promise<void>;
184
- /**
185
- * 비디오 광고 생성
186
- */
187
- declare function createVideoAd(containerId: string, options?: {
188
- width?: string | number;
189
- height?: string | number;
223
+ style?: string;
190
224
  autoplay?: boolean;
191
225
  muted?: boolean;
192
- }): Promise<void>;
193
- /**
194
- * SDK 상태 확인
195
- */
196
- declare function isAdStageReady(): boolean;
197
- /**
198
- * SDK 인스턴스 가져오기 (고급 사용자용)
199
- */
200
- declare function getAdStageInstance(): any;
201
- /**
202
- * SDK 초기화 해제 (필요시)
203
- */
204
- declare function destroyAdStage(): void;
205
-
206
- /**
207
- * AdStage SDK 설정
208
- */
209
- interface AdStageConfig {
210
- apiKey: string;
211
- debug?: boolean;
226
+ onClick?: (adData: any) => void;
212
227
  }
213
- /**
214
- * AdStage SDK 메인 클래스
215
- * - 간단한 API Key 기반 초기화
216
- * - 광고 슬롯 자동 관리
217
- * - 이벤트 자동 추적
218
- */
219
- declare class AdStageSDK {
220
- private static instance;
221
- private config;
222
- private baseUrl;
228
+ declare class AdsModule implements BaseModule {
229
+ private _isReady;
230
+ private _config;
223
231
  private slots;
224
- private initialized;
225
232
  private eventTracker;
226
- constructor(config: AdStageConfig);
227
233
  /**
228
- * SDK 초기화 및 인스턴스 반환
234
+ * Ads 모듈 초기화 (동기)
235
+ */
236
+ init(config: AdStageConfig): void;
237
+ /**
238
+ * 모듈 준비 상태 확인
229
239
  */
230
- static init(config: AdStageConfig): AdStageSDK;
240
+ isReady(): boolean;
231
241
  /**
232
- * SDK 인스턴스 반환 (이미 초기화된 경우)
242
+ * 모듈 설정 반환
233
243
  */
234
- static getInstance(): AdStageSDK;
244
+ getConfig(): AdStageConfig | null;
235
245
  /**
236
- * 광고 슬롯 생성 및 로드
246
+ * 배너 광고 생성 (동기)
237
247
  */
238
- createSlot(id: string, containerId: string, adType?: AdType, options?: {
239
- width?: number | string;
240
- height?: number | string;
241
- language?: string;
242
- deviceType?: string;
243
- country?: string;
244
- autoSlideInterval?: number;
245
- sliderEffect?: 'slide' | 'fade';
246
- }): Promise<void>;
248
+ banner(containerId: string, options?: AdOptions): string;
247
249
  /**
248
- * 광고 슬롯 로드
250
+ * 텍스트 광고 생성 (동기)
249
251
  */
250
- private loadSlot;
252
+ text(containerId: string, options?: AdOptions): string;
251
253
  /**
252
- * 광고 슬롯 렌더링 (슬라이더 포함)
254
+ * 비디오 광고 생성 (동기)
253
255
  */
254
- private renderSlotWithSlider;
256
+ video(containerId: string, options?: AdOptions): string;
255
257
  /**
256
- * 광고 슬롯 렌더링 (단일 광고용)
258
+ * 네이티브 광고 생성 (동기)
257
259
  */
258
- private renderSlot;
260
+ native(containerId: string, options?: AdOptions): string;
261
+ /**
262
+ * 전면 광고 생성 (동기)
263
+ */
264
+ interstitial(containerId: string, options?: AdOptions): string;
265
+ /**
266
+ * 광고 새로고침
267
+ */
268
+ refresh(slotId: string): void;
269
+ /**
270
+ * 광고 제거
271
+ */
272
+ destroy(slotId: string): void;
273
+ /**
274
+ * 모든 광고 슬롯 반환
275
+ */
276
+ getAllSlots(): AdSlot[];
277
+ /**
278
+ * 특정 광고 슬롯 반환
279
+ */
280
+ getSlotById(slotId: string): AdSlot | null;
281
+ /**
282
+ * 광고 생성 내부 메소드 (동기 + Lazy 로딩)
283
+ */
284
+ private createAd;
285
+ /**
286
+ * 즉시 광고 슬롯 생성 (placeholder)
287
+ */
288
+ private createAdSlot;
289
+ /**
290
+ * 백그라운드에서 광고 콘텐츠 로드
291
+ */
292
+ private loadAdContentInBackground;
293
+ /**
294
+ * Fallback 광고 렌더링
295
+ */
296
+ private renderFallback;
297
+ /**
298
+ * 광고 데이터 가져오기
299
+ */
300
+ private fetchAdData;
301
+ /**
302
+ * 광고 슬라이더 렌더링 (여러 광고 또는 autoSlide 옵션)
303
+ */
304
+ private renderAdSlider;
305
+ /**
306
+ * 광고 렌더링 (단일 광고용)
307
+ */
308
+ private renderAd;
309
+ /**
310
+ * 광고 요소 렌더링 (기본 구현)
311
+ */
312
+ private renderAdElement;
259
313
  /**
260
314
  * 광고 슬롯 새로고침
261
315
  */
262
- refreshSlot(slotId: string): Promise<void>;
316
+ private refreshAdSlot;
263
317
  /**
264
- * 광고 슬롯 제거
318
+ * 모듈 준비 상태 확인
265
319
  */
266
- destroySlot(slotId: string): void;
320
+ private ensureReady;
321
+ }
322
+
323
+ /**
324
+ * AdStage SDK - Config 모듈
325
+ * 설정 관리 및 API 키 검증
326
+ */
327
+
328
+ declare class ConfigModule implements BaseModule {
329
+ private _isReady;
330
+ private _config;
331
+ private _organizationInfo;
267
332
  /**
268
- * 자동 슬롯 검색 및 로드 (분리된 SDKUtils 사용)
333
+ * Config 모듈 초기화 (동기)
269
334
  */
270
- autoLoadSlots(): Promise<void>;
335
+ init(config: AdStageConfig): void;
271
336
  /**
272
- * SDK 정리
337
+ * 모듈 준비 상태 확인
273
338
  */
274
- destroy(): void;
339
+ isReady(): boolean;
340
+ /**
341
+ * 현재 설정 반환
342
+ */
343
+ getConfig(): AdStageConfig | null;
344
+ /**
345
+ * 조직 정보 반환
346
+ */
347
+ getOrganizationInfo(): OrganizationInfo | null;
348
+ /**
349
+ * API 엔드포인트 반환
350
+ */
351
+ getApiEndpoint(): string;
352
+ /**
353
+ * 디버그 모드 여부 확인
354
+ */
355
+ isDebugMode(): boolean;
356
+ /**
357
+ * 활성화된 모듈 목록 반환
358
+ */
359
+ getEnabledModules(): string[];
360
+ /**
361
+ * 특정 모듈이 활성화되어 있는지 확인
362
+ */
363
+ isModuleEnabled(moduleName: string): boolean;
364
+ /**
365
+ * 설정 업데이트 (런타임)
366
+ */
367
+ updateConfig(updates: Partial<AdStageConfig>): void;
368
+ /**
369
+ * API 헤더 생성 (공통 유틸리티 사용)
370
+ */
371
+ getApiHeaders(): Record<string, string>;
372
+ }
373
+
374
+ /**
375
+ * AdStage SDK - Events 모듈 (기본 구조)
376
+ * 이벤트 추적 시스템 - Q1 2025 구현 예정
377
+ */
378
+
379
+ interface EventProperties {
380
+ [key: string]: any;
381
+ }
382
+ interface PageData {
383
+ page?: string;
384
+ title?: string;
385
+ category?: string;
386
+ [key: string]: any;
387
+ }
388
+ declare class EventsModule implements BaseModule {
389
+ private _isReady;
390
+ private _config;
391
+ /**
392
+ * Events 모듈 초기화 (동기)
393
+ */
394
+ init(config: AdStageConfig): void;
395
+ /**
396
+ * 모듈 준비 상태 확인
397
+ */
398
+ isReady(): boolean;
399
+ /**
400
+ * 모듈 설정 반환
401
+ */
402
+ getConfig(): AdStageConfig | null;
403
+ /**
404
+ * 커스텀 이벤트 추적
405
+ * @example AdStage.events.track('page_view', { page: '/products' })
406
+ */
407
+ track(eventName: string, properties?: EventProperties): Promise<void>;
408
+ /**
409
+ * 페이지 뷰 이벤트
410
+ * @example AdStage.events.pageView({ page: '/home', title: 'Homepage' })
411
+ */
412
+ pageView(pageData?: PageData): Promise<void>;
413
+ /**
414
+ * 사용자 액션 이벤트
415
+ * @example AdStage.events.userAction('button_click', { button_id: 'cta' })
416
+ */
417
+ userAction(actionType: string, metadata?: EventProperties): Promise<void>;
418
+ /**
419
+ * 컨버전 이벤트
420
+ * @example AdStage.events.conversion({ type: 'purchase', value: 99.99 })
421
+ */
422
+ conversion(conversionData: EventProperties): Promise<void>;
423
+ batch: {
424
+ start: () => void;
425
+ add: (eventName: string, properties: EventProperties) => void;
426
+ flush: () => Promise<void>;
427
+ };
428
+ realtime: {
429
+ track: (eventName: string, properties: EventProperties) => Promise<void>;
430
+ };
431
+ }
432
+
433
+ /**
434
+ * AdStage SDK - 메인 네임스페이스 클래스
435
+ * v2.0.0 - 확장 가능한 모듈 아키텍처
436
+ */
437
+
438
+ declare class AdStage {
439
+ private static instance;
440
+ private _isInitialized;
441
+ private _config;
442
+ readonly ads: AdsModule;
443
+ readonly config: ConfigModule;
444
+ readonly events: EventsModule;
445
+ private constructor();
275
446
  /**
276
- * 디바이스 ID 가져오기
447
+ * AdStage SDK 초기화 (동기)
277
448
  */
278
- getDeviceId(): string;
449
+ static init(config: AdStageConfig): void;
279
450
  /**
280
- * 세션 ID 가져오기
451
+ * SDK 초기화 상태 확인
281
452
  */
282
- getSessionId(): string;
453
+ static isReady(): boolean;
283
454
  /**
284
- * 현재 로드된 슬롯 수 가져오기
455
+ * 현재 설정 반환
285
456
  */
286
- getLoadedSlotCount(): number;
457
+ static getConfig(): AdStageConfig | null;
287
458
  /**
288
- * 모든 슬롯 정보 가져오기
459
+ * SDK 인스턴스 반환 (공개 메소드로 변경)
289
460
  */
290
- getAllSlots(): Map<string, AdSlot>;
461
+ static getInstance(): AdStage;
462
+ /**
463
+ * 편의성을 위한 정적 모듈 접근자들
464
+ */
465
+ static get ads(): AdsModule;
466
+ static get events(): EventsModule;
467
+ static get config(): ConfigModule;
468
+ /**
469
+ * SDK 리셋 (테스트용)
470
+ */
471
+ static reset(): void;
291
472
  }
292
473
 
293
- export { AdEventType, AdSlot, AdStageConfig, AdStageSDK, AdType, Advertisement, SimpleAdStageConfig, createBanner, createTextAd, createVideoAd, AdStageSDK as default, destroyAdStage, getAdStageInstance, initAdStage, isAdStageReady };
474
+ /**
475
+ * AdStage Web SDK
476
+ * 네임스페이스 아키텍처 기반 SDK
477
+ */
478
+
479
+ declare const SDK_VERSION = "2.0.0";
480
+ declare const SUPPORTED_MODULES: readonly ["ads", "events", "config"];
481
+
482
+ export { AdEventType, AdOptions, AdSlot, AdStage, AdStageConfig, AdType, Advertisement, ApiResponse, BaseModule, EventProperties, ModuleName, OrganizationInfo, PageData, SDK_VERSION, SUPPORTED_MODULES };