@adstage/web-sdk 1.1.0 → 1.3.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 +39 -47
- package/dist/index.cjs.js +124 -352
- package/dist/index.d.ts +34 -153
- package/dist/index.esm.js +117 -342
- package/dist/index.standalone.js +117 -385
- package/package.json +6 -2
- package/src/index.ts +5 -2
- package/src/utils/sdk-standalone.ts +175 -0
package/README.md
CHANGED
|
@@ -1,70 +1,62 @@
|
|
|
1
1
|
# AdStage Web SDK
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
> 🚀 **v1.2.0**: Standalone-First API로 더욱 간단해졌습니다!
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
모든 웹 프레임워크에서 사용 가능한 AdStage 광고 SDK입니다.
|
|
6
|
+
|
|
7
|
+
## 🎯 특징
|
|
8
|
+
|
|
9
|
+
- **프레임워크 독립적**: React, Vue, Angular, Vanilla JS 모든 환경 지원
|
|
10
|
+
- **초간단 API**: Provider나 Hook 없이 함수 호출만으로 사용
|
|
11
|
+
- **자동 최적화**: 중복 방지, ID 자동 생성, 스마트 캐싱
|
|
12
|
+
- **완전한 TypeScript 지원**
|
|
13
|
+
|
|
14
|
+
## 📦 설치
|
|
6
15
|
|
|
7
16
|
```bash
|
|
8
17
|
npm install @adstage/web-sdk
|
|
9
18
|
```
|
|
10
19
|
|
|
11
|
-
##
|
|
12
|
-
|
|
13
|
-
### 기본 사용법
|
|
20
|
+
## 🚀 빠른 시작
|
|
14
21
|
|
|
22
|
+
### 1. SDK 초기화
|
|
15
23
|
```javascript
|
|
16
|
-
import {
|
|
24
|
+
import { initAdStage } from '@adstage/web-sdk';
|
|
17
25
|
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
apiKey: 'your-api-key',
|
|
21
|
-
debug: true
|
|
26
|
+
await initAdStage({
|
|
27
|
+
apiKey: 'your-api-key'
|
|
22
28
|
});
|
|
23
|
-
|
|
24
|
-
// 광고 슬롯 생성
|
|
25
|
-
await sdk.createSlot(
|
|
26
|
-
'banner-slot-1',
|
|
27
|
-
'banner-container',
|
|
28
|
-
AdType.BANNER,
|
|
29
|
-
{
|
|
30
|
-
width: '100%',
|
|
31
|
-
height: 200
|
|
32
|
-
}
|
|
33
|
-
);
|
|
34
29
|
```
|
|
35
30
|
|
|
36
|
-
###
|
|
31
|
+
### 2. 광고 생성
|
|
32
|
+
```javascript
|
|
33
|
+
import { createBanner } from '@adstage/web-sdk';
|
|
37
34
|
|
|
38
|
-
|
|
39
|
-
|
|
35
|
+
// HTML에 <div id="banner"></div> 준비 후
|
|
36
|
+
await createBanner('banner');
|
|
37
|
+
```
|
|
40
38
|
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
<MyComponent />
|
|
45
|
-
</AdStageProvider>
|
|
46
|
-
);
|
|
47
|
-
}
|
|
39
|
+
### 3. 이벤트 추적
|
|
40
|
+
```javascript
|
|
41
|
+
import { trackEvent } from '@adstage/web-sdk';
|
|
48
42
|
|
|
49
|
-
|
|
50
|
-
const { sdk, isLoading, isInitialized } = useAdStage();
|
|
51
|
-
|
|
52
|
-
// SDK 사용...
|
|
53
|
-
}
|
|
43
|
+
trackEvent('button_click', { page: 'home' });
|
|
54
44
|
```
|
|
55
45
|
|
|
56
|
-
##
|
|
57
|
-
|
|
58
|
-
- BANNER: 배너 광고
|
|
59
|
-
- SLIDER: 슬라이더 광고
|
|
60
|
-
- TEXT: 텍스트 광고
|
|
61
|
-
- NATIVE: 네이티브 광고
|
|
62
|
-
- VIDEO: 비디오 광고
|
|
46
|
+
## 📋 API 레퍼런스
|
|
63
47
|
|
|
64
|
-
|
|
48
|
+
### 초기화
|
|
49
|
+
- `initAdStage(config)` - SDK 초기화
|
|
50
|
+
- `isAdStageReady()` - 초기화 상태 확인
|
|
65
51
|
|
|
66
|
-
|
|
52
|
+
### 광고 생성
|
|
53
|
+
- `createBanner(containerId, options?)` - 배너 광고
|
|
54
|
+
- `createTextAd(containerId, options?)` - 텍스트 광고
|
|
55
|
+
- `createVideoAd(containerId, options?)` - 비디오 광고
|
|
67
56
|
|
|
68
|
-
|
|
57
|
+
### 유틸리티
|
|
58
|
+
- `trackEvent(name, params?)` - 이벤트 추적
|
|
59
|
+
- `getAdStageInstance()` - SDK 인스턴스 (고급)
|
|
60
|
+
- `destroyAdStage()` - SDK 정리
|
|
69
61
|
|
|
70
|
-
|
|
62
|
+
자세한 사용법은 [STANDALONE_GUIDE.md](./STANDALONE_GUIDE.md)를 참고하세요.
|
package/dist/index.cjs.js
CHANGED
|
@@ -2,8 +2,6 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
-
var require$$0 = require('react');
|
|
6
|
-
|
|
7
5
|
// 광고 타입 정의
|
|
8
6
|
exports.AdType = void 0;
|
|
9
7
|
(function (AdType) {
|
|
@@ -1666,357 +1664,135 @@ class SDKUtils {
|
|
|
1666
1664
|
}
|
|
1667
1665
|
}
|
|
1668
1666
|
|
|
1669
|
-
var jsxRuntime = {exports: {}};
|
|
1670
|
-
|
|
1671
|
-
var reactJsxRuntime_production_min = {};
|
|
1672
|
-
|
|
1673
1667
|
/**
|
|
1674
|
-
*
|
|
1675
|
-
*
|
|
1676
|
-
*
|
|
1677
|
-
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
1678
|
-
*
|
|
1679
|
-
* This source code is licensed under the MIT license found in the
|
|
1680
|
-
* LICENSE file in the root directory of this source tree.
|
|
1668
|
+
* AdStage SDK Standalone API
|
|
1669
|
+
* 간단하고 직관적인 사용을 위한 통합 API
|
|
1681
1670
|
*/
|
|
1682
|
-
|
|
1683
|
-
|
|
1684
|
-
|
|
1685
|
-
function requireReactJsxRuntime_production_min () {
|
|
1686
|
-
if (hasRequiredReactJsxRuntime_production_min) return reactJsxRuntime_production_min;
|
|
1687
|
-
hasRequiredReactJsxRuntime_production_min = 1;
|
|
1688
|
-
var f=require$$0,k=Symbol.for("react.element"),l=Symbol.for("react.fragment"),m=Object.prototype.hasOwnProperty,n=f.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,p={key:!0,ref:!0,__self:!0,__source:!0};
|
|
1689
|
-
function q(c,a,g){var b,d={},e=null,h=null;void 0!==g&&(e=""+g);void 0!==a.key&&(e=""+a.key);void 0!==a.ref&&(h=a.ref);for(b in a)m.call(a,b)&&!p.hasOwnProperty(b)&&(d[b]=a[b]);if(c&&c.defaultProps)for(b in a=c.defaultProps,a)void 0===d[b]&&(d[b]=a[b]);return {$$typeof:k,type:c,key:e,ref:h,props:d,_owner:n.current}}reactJsxRuntime_production_min.Fragment=l;reactJsxRuntime_production_min.jsx=q;reactJsxRuntime_production_min.jsxs=q;
|
|
1690
|
-
return reactJsxRuntime_production_min;
|
|
1691
|
-
}
|
|
1692
|
-
|
|
1693
|
-
{
|
|
1694
|
-
jsxRuntime.exports = requireReactJsxRuntime_production_min();
|
|
1695
|
-
}
|
|
1696
|
-
|
|
1697
|
-
var jsxRuntimeExports = jsxRuntime.exports;
|
|
1698
|
-
|
|
1699
|
-
const AdStageContext = require$$0.createContext({
|
|
1700
|
-
sdk: null,
|
|
1701
|
-
isLoading: true,
|
|
1702
|
-
error: null,
|
|
1703
|
-
isInitialized: false,
|
|
1704
|
-
});
|
|
1705
|
-
const AdStageProvider = ({ config, children, autoInit = true, }) => {
|
|
1706
|
-
const [sdk, setSdk] = require$$0.useState(null);
|
|
1707
|
-
const [isLoading, setIsLoading] = require$$0.useState(true);
|
|
1708
|
-
const [error, setError] = require$$0.useState(null);
|
|
1709
|
-
const [isInitialized, setIsInitialized] = require$$0.useState(false);
|
|
1710
|
-
require$$0.useEffect(() => {
|
|
1711
|
-
const initializeSDK = async () => {
|
|
1712
|
-
try {
|
|
1713
|
-
setIsLoading(true);
|
|
1714
|
-
setError(null);
|
|
1715
|
-
// Dynamic import를 사용해서 circular dependency 방지
|
|
1716
|
-
const { AdStageSDK } = await Promise.resolve().then(function () { return index; });
|
|
1717
|
-
// SDK 인스턴스 생성
|
|
1718
|
-
const sdkInstance = AdStageSDK.init(config);
|
|
1719
|
-
setSdk(sdkInstance);
|
|
1720
|
-
setIsInitialized(true);
|
|
1721
|
-
setIsLoading(false);
|
|
1722
|
-
}
|
|
1723
|
-
catch (err) {
|
|
1724
|
-
const errorMessage = err instanceof Error ? err.message : 'SDK 초기화 중 오류가 발생했습니다.';
|
|
1725
|
-
setError(errorMessage);
|
|
1726
|
-
setIsLoading(false);
|
|
1727
|
-
console.error('AdStage SDK initialization failed:', err);
|
|
1728
|
-
}
|
|
1729
|
-
};
|
|
1730
|
-
initializeSDK();
|
|
1731
|
-
}, [config.apiKey, config.debug, autoInit]);
|
|
1732
|
-
const value = {
|
|
1733
|
-
sdk,
|
|
1734
|
-
isLoading,
|
|
1735
|
-
error,
|
|
1736
|
-
isInitialized,
|
|
1737
|
-
};
|
|
1738
|
-
return (jsxRuntimeExports.jsx(AdStageContext.Provider, { value: value, children: children }));
|
|
1739
|
-
};
|
|
1740
|
-
|
|
1671
|
+
let globalSDKInstance = null;
|
|
1672
|
+
let isInitializing = false;
|
|
1741
1673
|
/**
|
|
1742
|
-
*
|
|
1743
|
-
* AdStageProvider 내부에서만 사용 가능
|
|
1674
|
+
* SDK 초기화 (한 번만 호출)
|
|
1744
1675
|
*/
|
|
1745
|
-
|
|
1746
|
-
|
|
1747
|
-
|
|
1748
|
-
|
|
1676
|
+
async function initAdStage(config) {
|
|
1677
|
+
if (globalSDKInstance) {
|
|
1678
|
+
console.warn('AdStage SDK가 이미 초기화되었습니다.');
|
|
1679
|
+
return;
|
|
1680
|
+
}
|
|
1681
|
+
if (isInitializing) {
|
|
1682
|
+
console.warn('AdStage SDK 초기화가 진행 중입니다.');
|
|
1683
|
+
return;
|
|
1684
|
+
}
|
|
1685
|
+
isInitializing = true;
|
|
1686
|
+
try {
|
|
1687
|
+
// 동적 import로 circular dependency 방지
|
|
1688
|
+
const { AdStageSDK } = await Promise.resolve().then(function () { return index; });
|
|
1689
|
+
globalSDKInstance = AdStageSDK.init({
|
|
1690
|
+
apiKey: config.apiKey,
|
|
1691
|
+
debug: config.debug || false
|
|
1692
|
+
});
|
|
1693
|
+
console.log('✅ AdStage SDK 초기화 완료');
|
|
1749
1694
|
}
|
|
1750
|
-
|
|
1751
|
-
|
|
1752
|
-
|
|
1753
|
-
|
|
1754
|
-
|
|
1755
|
-
|
|
1756
|
-
|
|
1757
|
-
|
|
1758
|
-
const containerRef = require$$0.useRef(null);
|
|
1759
|
-
const { sdk, isLoading, error } = useAdStage();
|
|
1760
|
-
const containerId = require$$0.useMemo(() => `adstage-${slotId}`, [slotId]);
|
|
1761
|
-
require$$0.useEffect(() => {
|
|
1762
|
-
if (!sdk || !containerRef.current || isLoading || error) {
|
|
1763
|
-
return;
|
|
1764
|
-
}
|
|
1765
|
-
// 컨테이너에 ID 설정
|
|
1766
|
-
containerRef.current.id = containerId;
|
|
1767
|
-
// 광고 슬롯 생성
|
|
1768
|
-
const createSlot = async () => {
|
|
1769
|
-
try {
|
|
1770
|
-
await sdk.createSlot(slotId, containerId, adType, {
|
|
1771
|
-
width,
|
|
1772
|
-
height,
|
|
1773
|
-
language,
|
|
1774
|
-
deviceType,
|
|
1775
|
-
country,
|
|
1776
|
-
autoSlideInterval,
|
|
1777
|
-
sliderEffect,
|
|
1778
|
-
});
|
|
1779
|
-
}
|
|
1780
|
-
catch (err) {
|
|
1781
|
-
console.error(`Failed to create ad slot ${slotId}:`, err);
|
|
1782
|
-
}
|
|
1783
|
-
};
|
|
1784
|
-
createSlot();
|
|
1785
|
-
// 클린업 함수
|
|
1786
|
-
return () => {
|
|
1787
|
-
// SDK에 removeSlot 메서드가 없으므로 DOM 정리만 수행
|
|
1788
|
-
if (containerRef.current) {
|
|
1789
|
-
containerRef.current.innerHTML = '';
|
|
1790
|
-
}
|
|
1791
|
-
};
|
|
1792
|
-
}, [
|
|
1793
|
-
sdk,
|
|
1794
|
-
slotId,
|
|
1795
|
-
containerId,
|
|
1796
|
-
adType,
|
|
1797
|
-
width,
|
|
1798
|
-
height,
|
|
1799
|
-
language,
|
|
1800
|
-
deviceType,
|
|
1801
|
-
country,
|
|
1802
|
-
autoSlideInterval,
|
|
1803
|
-
sliderEffect,
|
|
1804
|
-
isLoading,
|
|
1805
|
-
error,
|
|
1806
|
-
]);
|
|
1807
|
-
const containerStyle = {
|
|
1808
|
-
width: typeof width === 'number' ? `${width}px` : width,
|
|
1809
|
-
height: typeof height === 'number' ? `${height}px` : height,
|
|
1810
|
-
...style,
|
|
1811
|
-
};
|
|
1812
|
-
// 로딩 상태 표시
|
|
1813
|
-
if (isLoading) {
|
|
1814
|
-
return (jsxRuntimeExports.jsx("div", { className: className, style: {
|
|
1815
|
-
...containerStyle,
|
|
1816
|
-
display: 'flex',
|
|
1817
|
-
alignItems: 'center',
|
|
1818
|
-
justifyContent: 'center',
|
|
1819
|
-
backgroundColor: '#f5f5f5',
|
|
1820
|
-
border: '1px dashed #ccc',
|
|
1821
|
-
color: '#999',
|
|
1822
|
-
}, children: "Loading Ad..." }));
|
|
1823
|
-
}
|
|
1824
|
-
// 에러 상태 표시
|
|
1825
|
-
if (error) {
|
|
1826
|
-
return (jsxRuntimeExports.jsx("div", { className: className, style: {
|
|
1827
|
-
...containerStyle,
|
|
1828
|
-
display: 'flex',
|
|
1829
|
-
alignItems: 'center',
|
|
1830
|
-
justifyContent: 'center',
|
|
1831
|
-
backgroundColor: '#fee',
|
|
1832
|
-
border: '1px solid #fcc',
|
|
1833
|
-
color: '#c00',
|
|
1834
|
-
}, children: "Ad Load Error" }));
|
|
1835
|
-
}
|
|
1836
|
-
return (jsxRuntimeExports.jsx("div", { ref: containerRef, className: className, style: containerStyle }));
|
|
1837
|
-
};
|
|
1838
|
-
|
|
1695
|
+
catch (error) {
|
|
1696
|
+
console.error('❌ AdStage SDK 초기화 실패:', error);
|
|
1697
|
+
throw error;
|
|
1698
|
+
}
|
|
1699
|
+
finally {
|
|
1700
|
+
isInitializing = false;
|
|
1701
|
+
}
|
|
1702
|
+
}
|
|
1839
1703
|
/**
|
|
1840
|
-
* 배너 광고
|
|
1841
|
-
* AdSlot의 래퍼로 adType이 BANNER로 고정됨
|
|
1704
|
+
* 배너 광고 생성 (가장 간단한 API)
|
|
1842
1705
|
*/
|
|
1843
|
-
|
|
1844
|
-
|
|
1845
|
-
|
|
1846
|
-
|
|
1706
|
+
async function createBanner(containerId, options) {
|
|
1707
|
+
if (!globalSDKInstance) {
|
|
1708
|
+
throw new Error('AdStage SDK가 초기화되지 않았습니다. initAdStage()를 먼저 호출하세요.');
|
|
1709
|
+
}
|
|
1710
|
+
const slotId = `banner-${Date.now()}-${Math.random().toString(36).substr(2, 9)}`;
|
|
1711
|
+
return globalSDKInstance.createSlot(slotId, containerId, 'BANNER', {
|
|
1712
|
+
width: options?.width || '100%',
|
|
1713
|
+
height: options?.height || 120,
|
|
1714
|
+
autoSlideInterval: options?.autoSlide ? (options.slideInterval || 5) : 0,
|
|
1715
|
+
sliderEffect: 'fade'
|
|
1716
|
+
});
|
|
1717
|
+
}
|
|
1847
1718
|
/**
|
|
1848
|
-
* 텍스트 광고
|
|
1849
|
-
* AdSlot의 래퍼로 adType이 TEXT로 고정됨
|
|
1719
|
+
* 텍스트 광고 생성
|
|
1850
1720
|
*/
|
|
1851
|
-
|
|
1852
|
-
|
|
1853
|
-
|
|
1854
|
-
|
|
1721
|
+
async function createTextAd(containerId, options) {
|
|
1722
|
+
if (!globalSDKInstance) {
|
|
1723
|
+
throw new Error('AdStage SDK가 초기화되지 않았습니다.');
|
|
1724
|
+
}
|
|
1725
|
+
const slotId = `text-${Date.now()}-${Math.random().toString(36).substr(2, 9)}`;
|
|
1726
|
+
return globalSDKInstance.createSlot(slotId, containerId, 'TEXT', {
|
|
1727
|
+
maxLines: options?.maxLines || 3,
|
|
1728
|
+
style: options?.style || 'card'
|
|
1729
|
+
});
|
|
1730
|
+
}
|
|
1855
1731
|
/**
|
|
1856
|
-
*
|
|
1857
|
-
* AdSlot의 래퍼로 adType이 NATIVE로 고정됨
|
|
1732
|
+
* 비디오 광고 생성
|
|
1858
1733
|
*/
|
|
1859
|
-
|
|
1860
|
-
|
|
1861
|
-
|
|
1862
|
-
|
|
1734
|
+
async function createVideoAd(containerId, options) {
|
|
1735
|
+
if (!globalSDKInstance) {
|
|
1736
|
+
throw new Error('AdStage SDK가 초기화되지 않았습니다.');
|
|
1737
|
+
}
|
|
1738
|
+
const slotId = `video-${Date.now()}-${Math.random().toString(36).substr(2, 9)}`;
|
|
1739
|
+
return globalSDKInstance.createSlot(slotId, containerId, 'VIDEO', {
|
|
1740
|
+
width: options?.width || '100%',
|
|
1741
|
+
height: options?.height || 300,
|
|
1742
|
+
autoplay: options?.autoplay || false,
|
|
1743
|
+
muted: options?.muted || true
|
|
1744
|
+
});
|
|
1745
|
+
}
|
|
1863
1746
|
/**
|
|
1864
|
-
*
|
|
1865
|
-
* AdSlot의 래퍼로 adType이 VIDEO로 고정됨
|
|
1747
|
+
* 커스텀 이벤트 추적
|
|
1866
1748
|
*/
|
|
1867
|
-
|
|
1868
|
-
|
|
1869
|
-
|
|
1870
|
-
|
|
1749
|
+
function trackEvent(eventName, params) {
|
|
1750
|
+
if (!globalSDKInstance) {
|
|
1751
|
+
console.warn('AdStage SDK가 초기화되지 않았습니다. 이벤트 추적을 건너뜁니다.');
|
|
1752
|
+
return;
|
|
1753
|
+
}
|
|
1754
|
+
try {
|
|
1755
|
+
globalSDKInstance.trackEvent(eventName, {
|
|
1756
|
+
timestamp: new Date().toISOString(),
|
|
1757
|
+
...params
|
|
1758
|
+
});
|
|
1759
|
+
console.log(`📊 이벤트 추적: ${eventName}`, params);
|
|
1760
|
+
}
|
|
1761
|
+
catch (error) {
|
|
1762
|
+
console.error('이벤트 추적 실패:', error);
|
|
1763
|
+
}
|
|
1764
|
+
}
|
|
1871
1765
|
/**
|
|
1872
|
-
*
|
|
1873
|
-
* AdSlot의 래퍼로 adType이 INTERSTITIAL로 고정됨
|
|
1766
|
+
* SDK 상태 확인
|
|
1874
1767
|
*/
|
|
1875
|
-
|
|
1876
|
-
return
|
|
1877
|
-
}
|
|
1878
|
-
|
|
1768
|
+
function isAdStageReady() {
|
|
1769
|
+
return globalSDKInstance !== null && !isInitializing;
|
|
1770
|
+
}
|
|
1879
1771
|
/**
|
|
1880
|
-
*
|
|
1881
|
-
* 광고 로딩 실패 시 fallback UI를 표시하고 앱 전체가 크래시되는 것을 방지
|
|
1772
|
+
* SDK 인스턴스 가져오기 (고급 사용자용)
|
|
1882
1773
|
*/
|
|
1883
|
-
|
|
1884
|
-
|
|
1885
|
-
|
|
1886
|
-
|
|
1887
|
-
}
|
|
1888
|
-
static getDerivedStateFromError(error) {
|
|
1889
|
-
return { hasError: true, error };
|
|
1890
|
-
}
|
|
1891
|
-
componentDidCatch(error, errorInfo) {
|
|
1892
|
-
console.error('AdStage Error Boundary caught an error:', error, errorInfo);
|
|
1893
|
-
// 사용자 정의 에러 핸들러 호출
|
|
1894
|
-
if (this.props.onError) {
|
|
1895
|
-
this.props.onError(error, errorInfo);
|
|
1896
|
-
}
|
|
1897
|
-
}
|
|
1898
|
-
render() {
|
|
1899
|
-
if (this.state.hasError) {
|
|
1900
|
-
// 사용자 정의 fallback이 있으면 사용, 없으면 기본 fallback 표시
|
|
1901
|
-
if (this.props.fallback) {
|
|
1902
|
-
return this.props.fallback;
|
|
1903
|
-
}
|
|
1904
|
-
return (jsxRuntimeExports.jsxs("div", { style: {
|
|
1905
|
-
padding: '20px',
|
|
1906
|
-
textAlign: 'center',
|
|
1907
|
-
backgroundColor: '#fee',
|
|
1908
|
-
border: '1px solid #fcc',
|
|
1909
|
-
borderRadius: '4px',
|
|
1910
|
-
color: '#c00',
|
|
1911
|
-
}, children: [jsxRuntimeExports.jsx("h3", { children: "\uAD11\uACE0 \uB85C\uB529 \uC624\uB958" }), jsxRuntimeExports.jsx("p", { children: "\uAD11\uACE0\uB97C \uBD88\uB7EC\uC624\uB294 \uC911 \uBB38\uC81C\uAC00 \uBC1C\uC0DD\uD588\uC2B5\uB2C8\uB2E4." }), jsxRuntimeExports.jsx("button", { onClick: () => this.setState({ hasError: false, error: null }), style: {
|
|
1912
|
-
padding: '8px 16px',
|
|
1913
|
-
backgroundColor: '#fff',
|
|
1914
|
-
border: '1px solid #ccc',
|
|
1915
|
-
borderRadius: '4px',
|
|
1916
|
-
cursor: 'pointer',
|
|
1917
|
-
}, children: "\uB2E4\uC2DC \uC2DC\uB3C4" })] }));
|
|
1918
|
-
}
|
|
1919
|
-
return this.props.children;
|
|
1774
|
+
function getAdStageInstance() {
|
|
1775
|
+
if (!globalSDKInstance) {
|
|
1776
|
+
console.warn('AdStage SDK가 초기화되지 않았습니다.');
|
|
1777
|
+
return null;
|
|
1920
1778
|
}
|
|
1779
|
+
return globalSDKInstance;
|
|
1921
1780
|
}
|
|
1922
|
-
|
|
1923
1781
|
/**
|
|
1924
|
-
*
|
|
1925
|
-
* 컴포넌트에서 직접 슬롯을 제어하고 싶을 때 사용
|
|
1782
|
+
* SDK 초기화 해제 (필요시)
|
|
1926
1783
|
*/
|
|
1927
|
-
|
|
1928
|
-
|
|
1929
|
-
const [isLoading, setIsLoading] = require$$0.useState(false);
|
|
1930
|
-
const [error, setError] = require$$0.useState(null);
|
|
1931
|
-
const [isCreated, setIsCreated] = require$$0.useState(false);
|
|
1932
|
-
const createSlot = async () => {
|
|
1933
|
-
if (!sdk) {
|
|
1934
|
-
setError('SDK not initialized');
|
|
1935
|
-
return;
|
|
1936
|
-
}
|
|
1937
|
-
setIsLoading(true);
|
|
1938
|
-
setError(null);
|
|
1784
|
+
function destroyAdStage() {
|
|
1785
|
+
if (globalSDKInstance) {
|
|
1939
1786
|
try {
|
|
1940
|
-
|
|
1941
|
-
|
|
1942
|
-
|
|
1943
|
-
language: options.language,
|
|
1944
|
-
deviceType: options.deviceType,
|
|
1945
|
-
country: options.country,
|
|
1946
|
-
autoSlideInterval: options.autoSlideInterval,
|
|
1947
|
-
sliderEffect: options.sliderEffect,
|
|
1948
|
-
});
|
|
1949
|
-
setIsCreated(true);
|
|
1950
|
-
}
|
|
1951
|
-
catch (err) {
|
|
1952
|
-
const errorMessage = err instanceof Error ? err.message : '슬롯 생성 중 오류가 발생했습니다.';
|
|
1953
|
-
setError(errorMessage);
|
|
1954
|
-
setIsCreated(false);
|
|
1955
|
-
}
|
|
1956
|
-
finally {
|
|
1957
|
-
setIsLoading(false);
|
|
1958
|
-
}
|
|
1959
|
-
};
|
|
1960
|
-
const resetSlot = () => {
|
|
1961
|
-
setIsLoading(false);
|
|
1962
|
-
setError(null);
|
|
1963
|
-
setIsCreated(false);
|
|
1964
|
-
};
|
|
1965
|
-
// SDK가 변경되면 상태 초기화
|
|
1966
|
-
require$$0.useEffect(() => {
|
|
1967
|
-
resetSlot();
|
|
1968
|
-
}, [sdk]);
|
|
1969
|
-
return {
|
|
1970
|
-
isLoading,
|
|
1971
|
-
error,
|
|
1972
|
-
isCreated,
|
|
1973
|
-
createSlot,
|
|
1974
|
-
resetSlot,
|
|
1975
|
-
};
|
|
1976
|
-
};
|
|
1977
|
-
|
|
1978
|
-
/**
|
|
1979
|
-
* 광고 이벤트 추적을 위한 Hook
|
|
1980
|
-
* 커스텀 이벤트 추적이 필요할 때 사용
|
|
1981
|
-
*/
|
|
1982
|
-
const useAdTracking = () => {
|
|
1983
|
-
const { sdk } = useAdStage();
|
|
1984
|
-
const trackEvent = require$$0.useCallback((adId, slotId, eventType) => {
|
|
1985
|
-
if (!sdk) {
|
|
1986
|
-
console.warn('SDK not initialized - cannot track event');
|
|
1987
|
-
return;
|
|
1787
|
+
// SDK cleanup logic here
|
|
1788
|
+
globalSDKInstance = null;
|
|
1789
|
+
console.log('🧹 AdStage SDK 정리 완료');
|
|
1988
1790
|
}
|
|
1989
|
-
|
|
1990
|
-
|
|
1991
|
-
|
|
1992
|
-
|
|
1993
|
-
|
|
1994
|
-
// sdk.trackEvent(adId, slotId, eventType);
|
|
1995
|
-
}
|
|
1996
|
-
catch (err) {
|
|
1997
|
-
console.error('Failed to track event:', err);
|
|
1998
|
-
}
|
|
1999
|
-
}, [sdk]);
|
|
2000
|
-
const trackClick = require$$0.useCallback((adId, slotId) => {
|
|
2001
|
-
trackEvent(adId, slotId, exports.AdEventType.CLICK);
|
|
2002
|
-
}, [trackEvent]);
|
|
2003
|
-
const trackImpression = require$$0.useCallback((adId, slotId) => {
|
|
2004
|
-
trackEvent(adId, slotId, exports.AdEventType.IMPRESSION);
|
|
2005
|
-
}, [trackEvent]);
|
|
2006
|
-
const trackView = require$$0.useCallback((adId, slotId) => {
|
|
2007
|
-
trackEvent(adId, slotId, exports.AdEventType.VIEWABLE);
|
|
2008
|
-
}, [trackEvent]);
|
|
2009
|
-
const trackClose = require$$0.useCallback((adId, slotId) => {
|
|
2010
|
-
trackEvent(adId, slotId, exports.AdEventType.COMPLETED);
|
|
2011
|
-
}, [trackEvent]);
|
|
2012
|
-
return {
|
|
2013
|
-
trackEvent,
|
|
2014
|
-
trackClick,
|
|
2015
|
-
trackImpression,
|
|
2016
|
-
trackView,
|
|
2017
|
-
trackClose,
|
|
2018
|
-
};
|
|
2019
|
-
};
|
|
1791
|
+
catch (error) {
|
|
1792
|
+
console.error('SDK 정리 중 오류:', error);
|
|
1793
|
+
}
|
|
1794
|
+
}
|
|
1795
|
+
}
|
|
2020
1796
|
|
|
2021
1797
|
/**
|
|
2022
1798
|
* AdStage SDK 메인 클래스
|
|
@@ -2269,36 +2045,32 @@ if (DOMUtils.isBrowser()) {
|
|
|
2269
2045
|
DOMUtils.waitForDOM().then(autoInit);
|
|
2270
2046
|
}
|
|
2271
2047
|
}
|
|
2048
|
+
// React exports (React가 있을 때만 사용 - 레거시)
|
|
2049
|
+
// export * from './react';
|
|
2272
2050
|
|
|
2273
2051
|
var index = /*#__PURE__*/Object.freeze({
|
|
2274
2052
|
__proto__: null,
|
|
2275
|
-
AdErrorBoundary: AdErrorBoundary,
|
|
2276
2053
|
get AdEventType () { return exports.AdEventType; },
|
|
2277
|
-
AdSlot: AdSlot,
|
|
2278
|
-
AdStageProvider: AdStageProvider,
|
|
2279
2054
|
AdStageSDK: AdStageSDK,
|
|
2280
2055
|
get AdType () { return exports.AdType; },
|
|
2281
|
-
|
|
2282
|
-
|
|
2283
|
-
|
|
2284
|
-
TextAd: TextAd,
|
|
2285
|
-
VideoAd: VideoAd,
|
|
2056
|
+
createBanner: createBanner,
|
|
2057
|
+
createTextAd: createTextAd,
|
|
2058
|
+
createVideoAd: createVideoAd,
|
|
2286
2059
|
default: AdStageSDK,
|
|
2287
|
-
|
|
2288
|
-
|
|
2289
|
-
|
|
2060
|
+
destroyAdStage: destroyAdStage,
|
|
2061
|
+
getAdStageInstance: getAdStageInstance,
|
|
2062
|
+
initAdStage: initAdStage,
|
|
2063
|
+
isAdStageReady: isAdStageReady,
|
|
2064
|
+
trackEvent: trackEvent
|
|
2290
2065
|
});
|
|
2291
2066
|
|
|
2292
|
-
exports.AdErrorBoundary = AdErrorBoundary;
|
|
2293
|
-
exports.AdSlot = AdSlot;
|
|
2294
|
-
exports.AdStageProvider = AdStageProvider;
|
|
2295
2067
|
exports.AdStageSDK = AdStageSDK;
|
|
2296
|
-
exports.
|
|
2297
|
-
exports.
|
|
2298
|
-
exports.
|
|
2299
|
-
exports.TextAd = TextAd;
|
|
2300
|
-
exports.VideoAd = VideoAd;
|
|
2068
|
+
exports.createBanner = createBanner;
|
|
2069
|
+
exports.createTextAd = createTextAd;
|
|
2070
|
+
exports.createVideoAd = createVideoAd;
|
|
2301
2071
|
exports.default = AdStageSDK;
|
|
2302
|
-
exports.
|
|
2303
|
-
exports.
|
|
2304
|
-
exports.
|
|
2072
|
+
exports.destroyAdStage = destroyAdStage;
|
|
2073
|
+
exports.getAdStageInstance = getAdStageInstance;
|
|
2074
|
+
exports.initAdStage = initAdStage;
|
|
2075
|
+
exports.isAdStageReady = isAdStageReady;
|
|
2076
|
+
exports.trackEvent = trackEvent;
|