@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/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@adstage/web-sdk",
3
- "version": "1.3.4",
4
- "description": "AdStage Web SDK for displaying advertisements with auto DOM-ready detection",
3
+ "version": "2.0.0",
4
+ "description": "AdStage Web SDK - Production-ready marketing platform SDK with namespace architecture for ads, events, and config management",
5
5
  "type": "module",
6
6
  "main": "dist/index.cjs.js",
7
7
  "module": "dist/index.esm.js",
@@ -16,10 +16,8 @@
16
16
  "files": [
17
17
  "dist",
18
18
  "src",
19
- "examples",
20
19
  "README.md",
21
- "REACT_GUIDE.md",
22
- "PUBLISH_GUIDE.md"
20
+ "LICENSE"
23
21
  ],
24
22
  "scripts": {
25
23
  "build:types": "tsc --project tsconfig.types.json",
@@ -40,17 +38,18 @@
40
38
  "advertisement",
41
39
  "ads",
42
40
  "banner",
41
+ "text",
42
+ "video",
43
+ "native",
44
+ "interstitial",
43
45
  "sdk",
44
46
  "web",
45
- "react",
46
- "hooks",
47
- "component",
48
47
  "typescript",
49
- "text",
50
- "native",
51
- "video",
48
+ "namespace",
52
49
  "marketing",
53
- "monetization"
50
+ "tracking",
51
+ "deeplink",
52
+ "analytics"
54
53
  ],
55
54
  "author": "AdStage",
56
55
  "license": "MIT",
@@ -77,7 +76,7 @@
77
76
  },
78
77
  "repository": {
79
78
  "type": "git",
80
- "url": "https://github.com/nbase-io/adstage.git",
79
+ "url": "git+https://github.com/nbase-io/adstage.git",
81
80
  "directory": "sdk"
82
81
  },
83
82
  "bugs": {
@@ -0,0 +1,93 @@
1
+ /**
2
+ * AdStage SDK 엔드포인트 상수 관리
3
+ * 모든 API URL을 중앙에서 관리
4
+ */
5
+
6
+ /**
7
+ * 환경별 API 엔드포인트 (읽기 전용)
8
+ */
9
+ export const API_ENDPOINTS = {
10
+ /** 프로덕션 환경 */
11
+ production: 'https://api.adstage.io',
12
+
13
+ /** 베타 환경 (기본값) */
14
+ beta: 'https://beta-api.adstage.app'
15
+ } as const;
16
+
17
+ /**
18
+ * 기본 엔드포인트 (베타 환경)
19
+ */
20
+ export const DEFAULT_API_ENDPOINT = API_ENDPOINTS.beta;
21
+
22
+ /**
23
+ * API 경로 상수
24
+ */
25
+ export const API_PATHS = {
26
+ /** 광고 관련 */
27
+ advertisements: {
28
+ list: '/advertisements/list',
29
+ events: '/advertisements/events'
30
+ },
31
+
32
+ /** 이벤트 관련 */
33
+ events: {
34
+ track: '/events/track',
35
+ batch: '/events/batch'
36
+ }
37
+ } as const;
38
+
39
+ /**
40
+ * 완전한 API URL 생성 헬퍼
41
+ */
42
+ export class EndpointBuilder {
43
+ private baseUrl: string;
44
+
45
+ constructor(baseUrl?: string) {
46
+ // 기본값은 베타 환경 사용
47
+ this.baseUrl = baseUrl || API_ENDPOINTS.beta;
48
+ }
49
+
50
+ /**
51
+ * 기본 URL 변경
52
+ */
53
+ setBaseUrl(url: string): void {
54
+ this.baseUrl = url;
55
+ console.log('🔄 API endpoint changed:', url);
56
+ }
57
+
58
+ /**
59
+ * 기본 URL 반환
60
+ */
61
+ getBaseUrl(): string {
62
+ return this.baseUrl;
63
+ }
64
+
65
+ /**
66
+ * 광고 엔드포인트
67
+ */
68
+ advertisements = {
69
+ list: () => `${this.baseUrl}${API_PATHS.advertisements.list}`,
70
+ events: (adId: string, eventType: string) =>
71
+ `${this.baseUrl}${API_PATHS.advertisements.events}/${adId}/${eventType}`
72
+ };
73
+
74
+ /**
75
+ * 이벤트 엔드포인트
76
+ */
77
+ events = {
78
+ track: () => `${this.baseUrl}${API_PATHS.events.track}`,
79
+ batch: () => `${this.baseUrl}${API_PATHS.events.batch}`
80
+ };
81
+
82
+ /**
83
+ * 커스텀 경로 생성
84
+ */
85
+ custom(path: string): string {
86
+ return `${this.baseUrl}${path.startsWith('/') ? path : `/${path}`}`;
87
+ }
88
+ }
89
+
90
+ /**
91
+ * 전역 엔드포인트 빌더 인스턴스 (기본: 베타 환경)
92
+ */
93
+ export const endpoints = new EndpointBuilder();
@@ -0,0 +1,128 @@
1
+ /**
2
+ * AdStage SDK - 메인 네임스페이스 클래스
3
+ * v2.0.0 - 확장 가능한 모듈 아키텍처
4
+ */
5
+
6
+ import { AdStageConfig, ModuleName } from '../types/config';
7
+ import { AdsModule } from '../modules/ads/AdsModule';
8
+ import { ConfigModule } from '../modules/config/ConfigModule';
9
+ import { EventsModule } from '../modules/events/EventsModule';
10
+
11
+ export class AdStage {
12
+ private static instance: AdStage;
13
+ private _isInitialized = false;
14
+ private _config: AdStageConfig | null = null;
15
+
16
+ // 모듈 인스턴스들
17
+ public readonly ads: AdsModule;
18
+ public readonly config: ConfigModule;
19
+ public readonly events: EventsModule;
20
+
21
+ private constructor() {
22
+ // 모듈 초기화 (ads, config는 완전 구현, events는 기본 구조)
23
+ this.config = new ConfigModule();
24
+ this.ads = new AdsModule();
25
+ this.events = new EventsModule();
26
+ }
27
+
28
+ /**
29
+ * AdStage SDK 초기화 (동기)
30
+ */
31
+ public static init(config: AdStageConfig): void {
32
+ if (!AdStage.instance) {
33
+ AdStage.instance = new AdStage();
34
+ }
35
+
36
+ const instance = AdStage.instance;
37
+
38
+ // 설정 검증
39
+ if (!config.apiKey) {
40
+ throw new Error('API key is required for AdStage initialization');
41
+ }
42
+
43
+ // 설정 저장 (서버 검증 없음)
44
+ instance._config = {
45
+ timeout: 30000,
46
+ debug: false,
47
+ modules: ['ads', 'events', 'config'],
48
+ validateOnInit: false,
49
+ fallbackMode: true,
50
+ offlineMode: false,
51
+ productionMode: false,
52
+ ...config
53
+ };
54
+
55
+ // 모듈 동기 초기화
56
+ const enabledModules = instance._config.modules || ['ads', 'events', 'config'];
57
+
58
+ for (const moduleName of enabledModules) {
59
+ const module = instance[moduleName as keyof AdStage] as any;
60
+ if (module && typeof module.init === 'function') {
61
+ module.init(instance._config);
62
+ }
63
+ }
64
+
65
+ instance._isInitialized = true;
66
+
67
+ if (config.debug) {
68
+ console.log('🚀 AdStage SDK initialized (sync mode)', {
69
+ version: '2.0.0',
70
+ modules: enabledModules,
71
+ apiKey: config.apiKey.substring(0, 8) + '...',
72
+ mode: config.productionMode ? 'production' : 'development'
73
+ });
74
+ }
75
+ }
76
+
77
+ /**
78
+ * SDK 초기화 상태 확인
79
+ */
80
+ public static isReady(): boolean {
81
+ return AdStage.instance?._isInitialized || false;
82
+ }
83
+
84
+ /**
85
+ * 현재 설정 반환
86
+ */
87
+ public static getConfig(): AdStageConfig | null {
88
+ return AdStage.instance?._config || null;
89
+ }
90
+
91
+ /**
92
+ * SDK 인스턴스 반환 (공개 메소드로 변경)
93
+ */
94
+ public static getInstance(): AdStage {
95
+ if (!AdStage.instance) {
96
+ throw new Error('AdStage not initialized. Call AdStage.init() first.');
97
+ }
98
+ return AdStage.instance;
99
+ }
100
+
101
+ /**
102
+ * 편의성을 위한 정적 모듈 접근자들
103
+ */
104
+ public static get ads() {
105
+ return AdStage.getInstance().ads;
106
+ }
107
+
108
+ public static get events() {
109
+ return AdStage.getInstance().events;
110
+ }
111
+
112
+ public static get config() {
113
+ return AdStage.getInstance().config;
114
+ }
115
+
116
+ /**
117
+ * SDK 리셋 (테스트용)
118
+ */
119
+ public static reset(): void {
120
+ if (AdStage.instance) {
121
+ AdStage.instance._isInitialized = false;
122
+ AdStage.instance._config = null;
123
+ }
124
+ }
125
+ }
126
+
127
+ // 전역 네임스페이스로 내보내기
128
+ export default AdStage;