@adstage/web-sdk 2.4.1 → 2.4.2
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/dist/index.cjs.js +81 -0
- package/dist/index.d.ts +19 -1
- package/dist/index.esm.js +80 -1
- package/dist/index.standalone.js +152 -1
- package/package.json +1 -1
- package/src/index.ts +3 -0
- package/src/react/index.ts +1 -1
package/dist/index.cjs.js
CHANGED
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
+
var jsxRuntime = require('react/jsx-runtime');
|
|
4
|
+
var react = require('react');
|
|
5
|
+
|
|
3
6
|
// 광고 타입 정의
|
|
4
7
|
var AdType;
|
|
5
8
|
(function (AdType) {
|
|
@@ -3311,6 +3314,82 @@ class AdStage {
|
|
|
3311
3314
|
}
|
|
3312
3315
|
}
|
|
3313
3316
|
|
|
3317
|
+
const AdStageContext = react.createContext(null);
|
|
3318
|
+
function AdStageProvider({ children, config }) {
|
|
3319
|
+
const [isInitialized, setIsInitialized] = react.useState(false);
|
|
3320
|
+
const [currentConfig, setCurrentConfig] = react.useState(null);
|
|
3321
|
+
const [error, setError] = react.useState(null);
|
|
3322
|
+
const initialize = (newConfig) => {
|
|
3323
|
+
try {
|
|
3324
|
+
setError(null);
|
|
3325
|
+
// 기존 인스턴스가 있으면 리셋
|
|
3326
|
+
if (isInitialized) {
|
|
3327
|
+
AdStage.reset();
|
|
3328
|
+
}
|
|
3329
|
+
AdStage.init(newConfig);
|
|
3330
|
+
setCurrentConfig(newConfig);
|
|
3331
|
+
setIsInitialized(true);
|
|
3332
|
+
if (newConfig.debug) {
|
|
3333
|
+
console.log('✅ AdStage SDK initialized successfully via React Provider');
|
|
3334
|
+
}
|
|
3335
|
+
}
|
|
3336
|
+
catch (err) {
|
|
3337
|
+
const errorMessage = err instanceof Error ? err.message : 'Unknown error';
|
|
3338
|
+
setError(errorMessage);
|
|
3339
|
+
console.error('❌ AdStage SDK initialization failed:', err);
|
|
3340
|
+
setIsInitialized(false);
|
|
3341
|
+
setCurrentConfig(null);
|
|
3342
|
+
}
|
|
3343
|
+
};
|
|
3344
|
+
const reset = () => {
|
|
3345
|
+
try {
|
|
3346
|
+
AdStage.reset();
|
|
3347
|
+
setIsInitialized(false);
|
|
3348
|
+
setCurrentConfig(null);
|
|
3349
|
+
setError(null);
|
|
3350
|
+
}
|
|
3351
|
+
catch (err) {
|
|
3352
|
+
console.error('❌ AdStage SDK reset failed:', err);
|
|
3353
|
+
}
|
|
3354
|
+
};
|
|
3355
|
+
// 자동 초기화
|
|
3356
|
+
react.useEffect(() => {
|
|
3357
|
+
if (config && !isInitialized) {
|
|
3358
|
+
initialize(config);
|
|
3359
|
+
}
|
|
3360
|
+
}, [config, isInitialized]);
|
|
3361
|
+
const contextValue = {
|
|
3362
|
+
isInitialized,
|
|
3363
|
+
config: currentConfig,
|
|
3364
|
+
initialize,
|
|
3365
|
+
reset,
|
|
3366
|
+
error
|
|
3367
|
+
};
|
|
3368
|
+
return (jsxRuntime.jsx(AdStageContext.Provider, { value: contextValue, children: children }));
|
|
3369
|
+
}
|
|
3370
|
+
/**
|
|
3371
|
+
* AdStage Context Hook
|
|
3372
|
+
* AdStageProvider 내에서 SDK 상태에 접근할 수 있습니다.
|
|
3373
|
+
*/
|
|
3374
|
+
function useAdStage() {
|
|
3375
|
+
const context = react.useContext(AdStageContext);
|
|
3376
|
+
if (!context) {
|
|
3377
|
+
throw new Error('useAdStage must be used within an AdStageProvider');
|
|
3378
|
+
}
|
|
3379
|
+
return context;
|
|
3380
|
+
}
|
|
3381
|
+
/**
|
|
3382
|
+
* AdStage SDK Hook
|
|
3383
|
+
* 초기화된 AdStage 인스턴스에 직접 접근할 수 있습니다.
|
|
3384
|
+
*/
|
|
3385
|
+
function useAdStageSDK() {
|
|
3386
|
+
const { isInitialized } = useAdStage();
|
|
3387
|
+
if (!isInitialized) {
|
|
3388
|
+
throw new Error('AdStage SDK is not initialized. Please call initialize() first or provide config to AdStageProvider.');
|
|
3389
|
+
}
|
|
3390
|
+
return AdStage;
|
|
3391
|
+
}
|
|
3392
|
+
|
|
3314
3393
|
/**
|
|
3315
3394
|
* AdStage Web SDK
|
|
3316
3395
|
* 네임스페이스 아키텍처 기반 SDK
|
|
@@ -3321,5 +3400,7 @@ const SDK_VERSION = '2.0.0';
|
|
|
3321
3400
|
const SUPPORTED_MODULES = ['ads', 'events', 'config'];
|
|
3322
3401
|
|
|
3323
3402
|
exports.AdStage = AdStage;
|
|
3403
|
+
exports.AdStageProvider = AdStageProvider;
|
|
3324
3404
|
exports.SDK_VERSION = SDK_VERSION;
|
|
3325
3405
|
exports.SUPPORTED_MODULES = SUPPORTED_MODULES;
|
|
3406
|
+
exports.useAdStage = useAdStageSDK;
|
package/dist/index.d.ts
CHANGED
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
+
import { ReactNode } from 'react';
|
|
3
|
+
|
|
1
4
|
/**
|
|
2
5
|
* AdStage SDK 모듈 타입
|
|
3
6
|
*/
|
|
@@ -483,6 +486,21 @@ declare class AdStage {
|
|
|
483
486
|
static reset(): void;
|
|
484
487
|
}
|
|
485
488
|
|
|
489
|
+
interface AdStageProviderProps {
|
|
490
|
+
children: ReactNode;
|
|
491
|
+
/**
|
|
492
|
+
* 자동 초기화를 위한 설정 (선택사항)
|
|
493
|
+
* 제공되면 Provider 마운트 시 자동으로 초기화됩니다.
|
|
494
|
+
*/
|
|
495
|
+
config?: AdStageConfig;
|
|
496
|
+
}
|
|
497
|
+
declare function AdStageProvider({ children, config }: AdStageProviderProps): react_jsx_runtime.JSX.Element;
|
|
498
|
+
/**
|
|
499
|
+
* AdStage SDK Hook
|
|
500
|
+
* 초기화된 AdStage 인스턴스에 직접 접근할 수 있습니다.
|
|
501
|
+
*/
|
|
502
|
+
declare function useAdStageSDK(): typeof AdStage;
|
|
503
|
+
|
|
486
504
|
/**
|
|
487
505
|
* AdStage Web SDK
|
|
488
506
|
* 네임스페이스 아키텍처 기반 SDK
|
|
@@ -491,4 +509,4 @@ declare class AdStage {
|
|
|
491
509
|
declare const SDK_VERSION = "2.0.0";
|
|
492
510
|
declare const SUPPORTED_MODULES: readonly ["ads", "events", "config"];
|
|
493
511
|
|
|
494
|
-
export { AdEventType, AdOptions, AdSlot, AdStage, AdStageConfig, AdType, Advertisement, ApiResponse, BaseModule, EventProperties, ModuleName, OrganizationInfo, PageData, SDK_VERSION, SUPPORTED_MODULES };
|
|
512
|
+
export { AdEventType, AdOptions, AdSlot, AdStage, AdStageConfig, AdStageProvider, AdType, Advertisement, ApiResponse, BaseModule, EventProperties, ModuleName, OrganizationInfo, PageData, SDK_VERSION, SUPPORTED_MODULES, useAdStageSDK as useAdStage };
|
package/dist/index.esm.js
CHANGED
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
import { jsx } from 'react/jsx-runtime';
|
|
2
|
+
import { createContext, useState, useEffect, useContext } from 'react';
|
|
3
|
+
|
|
1
4
|
// 광고 타입 정의
|
|
2
5
|
var AdType;
|
|
3
6
|
(function (AdType) {
|
|
@@ -3309,6 +3312,82 @@ class AdStage {
|
|
|
3309
3312
|
}
|
|
3310
3313
|
}
|
|
3311
3314
|
|
|
3315
|
+
const AdStageContext = createContext(null);
|
|
3316
|
+
function AdStageProvider({ children, config }) {
|
|
3317
|
+
const [isInitialized, setIsInitialized] = useState(false);
|
|
3318
|
+
const [currentConfig, setCurrentConfig] = useState(null);
|
|
3319
|
+
const [error, setError] = useState(null);
|
|
3320
|
+
const initialize = (newConfig) => {
|
|
3321
|
+
try {
|
|
3322
|
+
setError(null);
|
|
3323
|
+
// 기존 인스턴스가 있으면 리셋
|
|
3324
|
+
if (isInitialized) {
|
|
3325
|
+
AdStage.reset();
|
|
3326
|
+
}
|
|
3327
|
+
AdStage.init(newConfig);
|
|
3328
|
+
setCurrentConfig(newConfig);
|
|
3329
|
+
setIsInitialized(true);
|
|
3330
|
+
if (newConfig.debug) {
|
|
3331
|
+
console.log('✅ AdStage SDK initialized successfully via React Provider');
|
|
3332
|
+
}
|
|
3333
|
+
}
|
|
3334
|
+
catch (err) {
|
|
3335
|
+
const errorMessage = err instanceof Error ? err.message : 'Unknown error';
|
|
3336
|
+
setError(errorMessage);
|
|
3337
|
+
console.error('❌ AdStage SDK initialization failed:', err);
|
|
3338
|
+
setIsInitialized(false);
|
|
3339
|
+
setCurrentConfig(null);
|
|
3340
|
+
}
|
|
3341
|
+
};
|
|
3342
|
+
const reset = () => {
|
|
3343
|
+
try {
|
|
3344
|
+
AdStage.reset();
|
|
3345
|
+
setIsInitialized(false);
|
|
3346
|
+
setCurrentConfig(null);
|
|
3347
|
+
setError(null);
|
|
3348
|
+
}
|
|
3349
|
+
catch (err) {
|
|
3350
|
+
console.error('❌ AdStage SDK reset failed:', err);
|
|
3351
|
+
}
|
|
3352
|
+
};
|
|
3353
|
+
// 자동 초기화
|
|
3354
|
+
useEffect(() => {
|
|
3355
|
+
if (config && !isInitialized) {
|
|
3356
|
+
initialize(config);
|
|
3357
|
+
}
|
|
3358
|
+
}, [config, isInitialized]);
|
|
3359
|
+
const contextValue = {
|
|
3360
|
+
isInitialized,
|
|
3361
|
+
config: currentConfig,
|
|
3362
|
+
initialize,
|
|
3363
|
+
reset,
|
|
3364
|
+
error
|
|
3365
|
+
};
|
|
3366
|
+
return (jsx(AdStageContext.Provider, { value: contextValue, children: children }));
|
|
3367
|
+
}
|
|
3368
|
+
/**
|
|
3369
|
+
* AdStage Context Hook
|
|
3370
|
+
* AdStageProvider 내에서 SDK 상태에 접근할 수 있습니다.
|
|
3371
|
+
*/
|
|
3372
|
+
function useAdStage() {
|
|
3373
|
+
const context = useContext(AdStageContext);
|
|
3374
|
+
if (!context) {
|
|
3375
|
+
throw new Error('useAdStage must be used within an AdStageProvider');
|
|
3376
|
+
}
|
|
3377
|
+
return context;
|
|
3378
|
+
}
|
|
3379
|
+
/**
|
|
3380
|
+
* AdStage SDK Hook
|
|
3381
|
+
* 초기화된 AdStage 인스턴스에 직접 접근할 수 있습니다.
|
|
3382
|
+
*/
|
|
3383
|
+
function useAdStageSDK() {
|
|
3384
|
+
const { isInitialized } = useAdStage();
|
|
3385
|
+
if (!isInitialized) {
|
|
3386
|
+
throw new Error('AdStage SDK is not initialized. Please call initialize() first or provide config to AdStageProvider.');
|
|
3387
|
+
}
|
|
3388
|
+
return AdStage;
|
|
3389
|
+
}
|
|
3390
|
+
|
|
3312
3391
|
/**
|
|
3313
3392
|
* AdStage Web SDK
|
|
3314
3393
|
* 네임스페이스 아키텍처 기반 SDK
|
|
@@ -3318,4 +3397,4 @@ class AdStage {
|
|
|
3318
3397
|
const SDK_VERSION = '2.0.0';
|
|
3319
3398
|
const SUPPORTED_MODULES = ['ads', 'events', 'config'];
|
|
3320
3399
|
|
|
3321
|
-
export { AdStage, SDK_VERSION, SUPPORTED_MODULES };
|
|
3400
|
+
export { AdStage, AdStageProvider, SDK_VERSION, SUPPORTED_MODULES, useAdStageSDK as useAdStage };
|
package/dist/index.standalone.js
CHANGED
|
@@ -3309,6 +3309,157 @@ class AdStage {
|
|
|
3309
3309
|
}
|
|
3310
3310
|
}
|
|
3311
3311
|
|
|
3312
|
+
var jsxRuntime = {exports: {}};
|
|
3313
|
+
|
|
3314
|
+
var reactJsxRuntime_production_min = {};
|
|
3315
|
+
|
|
3316
|
+
var react = {exports: {}};
|
|
3317
|
+
|
|
3318
|
+
var react_production_min = {};
|
|
3319
|
+
|
|
3320
|
+
/**
|
|
3321
|
+
* @license React
|
|
3322
|
+
* react.production.min.js
|
|
3323
|
+
*
|
|
3324
|
+
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
3325
|
+
*
|
|
3326
|
+
* This source code is licensed under the MIT license found in the
|
|
3327
|
+
* LICENSE file in the root directory of this source tree.
|
|
3328
|
+
*/
|
|
3329
|
+
|
|
3330
|
+
var hasRequiredReact_production_min;
|
|
3331
|
+
|
|
3332
|
+
function requireReact_production_min () {
|
|
3333
|
+
if (hasRequiredReact_production_min) return react_production_min;
|
|
3334
|
+
hasRequiredReact_production_min = 1;
|
|
3335
|
+
var l=Symbol.for("react.element"),n=Symbol.for("react.portal"),p=Symbol.for("react.fragment"),q=Symbol.for("react.strict_mode"),r=Symbol.for("react.profiler"),t=Symbol.for("react.provider"),u=Symbol.for("react.context"),v=Symbol.for("react.forward_ref"),w=Symbol.for("react.suspense"),x=Symbol.for("react.memo"),y=Symbol.for("react.lazy"),z=Symbol.iterator;function A(a){if(null===a||"object"!==typeof a)return null;a=z&&a[z]||a["@@iterator"];return "function"===typeof a?a:null}
|
|
3336
|
+
var B={isMounted:function(){return !1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},C=Object.assign,D={};function E(a,b,e){this.props=a;this.context=b;this.refs=D;this.updater=e||B;}E.prototype.isReactComponent={};
|
|
3337
|
+
E.prototype.setState=function(a,b){if("object"!==typeof a&&"function"!==typeof a&&null!=a)throw Error("setState(...): takes an object of state variables to update or a function which returns an object of state variables.");this.updater.enqueueSetState(this,a,b,"setState");};E.prototype.forceUpdate=function(a){this.updater.enqueueForceUpdate(this,a,"forceUpdate");};function F(){}F.prototype=E.prototype;function G(a,b,e){this.props=a;this.context=b;this.refs=D;this.updater=e||B;}var H=G.prototype=new F;
|
|
3338
|
+
H.constructor=G;C(H,E.prototype);H.isPureReactComponent=!0;var I=Array.isArray,J=Object.prototype.hasOwnProperty,K={current:null},L={key:!0,ref:!0,__self:!0,__source:!0};
|
|
3339
|
+
function M(a,b,e){var d,c={},k=null,h=null;if(null!=b)for(d in void 0!==b.ref&&(h=b.ref),void 0!==b.key&&(k=""+b.key),b)J.call(b,d)&&!L.hasOwnProperty(d)&&(c[d]=b[d]);var g=arguments.length-2;if(1===g)c.children=e;else if(1<g){for(var f=Array(g),m=0;m<g;m++)f[m]=arguments[m+2];c.children=f;}if(a&&a.defaultProps)for(d in g=a.defaultProps,g)void 0===c[d]&&(c[d]=g[d]);return {$$typeof:l,type:a,key:k,ref:h,props:c,_owner:K.current}}
|
|
3340
|
+
function N(a,b){return {$$typeof:l,type:a.type,key:b,ref:a.ref,props:a.props,_owner:a._owner}}function O(a){return "object"===typeof a&&null!==a&&a.$$typeof===l}function escape(a){var b={"=":"=0",":":"=2"};return "$"+a.replace(/[=:]/g,function(a){return b[a]})}var P=/\/+/g;function Q(a,b){return "object"===typeof a&&null!==a&&null!=a.key?escape(""+a.key):b.toString(36)}
|
|
3341
|
+
function R(a,b,e,d,c){var k=typeof a;if("undefined"===k||"boolean"===k)a=null;var h=!1;if(null===a)h=!0;else switch(k){case "string":case "number":h=!0;break;case "object":switch(a.$$typeof){case l:case n:h=!0;}}if(h)return h=a,c=c(h),a=""===d?"."+Q(h,0):d,I(c)?(e="",null!=a&&(e=a.replace(P,"$&/")+"/"),R(c,b,e,"",function(a){return a})):null!=c&&(O(c)&&(c=N(c,e+(!c.key||h&&h.key===c.key?"":(""+c.key).replace(P,"$&/")+"/")+a)),b.push(c)),1;h=0;d=""===d?".":d+":";if(I(a))for(var g=0;g<a.length;g++){k=
|
|
3342
|
+
a[g];var f=d+Q(k,g);h+=R(k,b,e,f,c);}else if(f=A(a),"function"===typeof f)for(a=f.call(a),g=0;!(k=a.next()).done;)k=k.value,f=d+Q(k,g++),h+=R(k,b,e,f,c);else if("object"===k)throw b=String(a),Error("Objects are not valid as a React child (found: "+("[object Object]"===b?"object with keys {"+Object.keys(a).join(", ")+"}":b)+"). If you meant to render a collection of children, use an array instead.");return h}
|
|
3343
|
+
function S(a,b,e){if(null==a)return a;var d=[],c=0;R(a,d,"","",function(a){return b.call(e,a,c++)});return d}function T(a){if(-1===a._status){var b=a._result;b=b();b.then(function(b){if(0===a._status||-1===a._status)a._status=1,a._result=b;},function(b){if(0===a._status||-1===a._status)a._status=2,a._result=b;});-1===a._status&&(a._status=0,a._result=b);}if(1===a._status)return a._result.default;throw a._result;}
|
|
3344
|
+
var U={current:null},V={transition:null},W={ReactCurrentDispatcher:U,ReactCurrentBatchConfig:V,ReactCurrentOwner:K};function X(){throw Error("act(...) is not supported in production builds of React.");}
|
|
3345
|
+
react_production_min.Children={map:S,forEach:function(a,b,e){S(a,function(){b.apply(this,arguments);},e);},count:function(a){var b=0;S(a,function(){b++;});return b},toArray:function(a){return S(a,function(a){return a})||[]},only:function(a){if(!O(a))throw Error("React.Children.only expected to receive a single React element child.");return a}};react_production_min.Component=E;react_production_min.Fragment=p;react_production_min.Profiler=r;react_production_min.PureComponent=G;react_production_min.StrictMode=q;react_production_min.Suspense=w;
|
|
3346
|
+
react_production_min.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=W;react_production_min.act=X;
|
|
3347
|
+
react_production_min.cloneElement=function(a,b,e){if(null===a||void 0===a)throw Error("React.cloneElement(...): The argument must be a React element, but you passed "+a+".");var d=C({},a.props),c=a.key,k=a.ref,h=a._owner;if(null!=b){void 0!==b.ref&&(k=b.ref,h=K.current);void 0!==b.key&&(c=""+b.key);if(a.type&&a.type.defaultProps)var g=a.type.defaultProps;for(f in b)J.call(b,f)&&!L.hasOwnProperty(f)&&(d[f]=void 0===b[f]&&void 0!==g?g[f]:b[f]);}var f=arguments.length-2;if(1===f)d.children=e;else if(1<f){g=Array(f);
|
|
3348
|
+
for(var m=0;m<f;m++)g[m]=arguments[m+2];d.children=g;}return {$$typeof:l,type:a.type,key:c,ref:k,props:d,_owner:h}};react_production_min.createContext=function(a){a={$$typeof:u,_currentValue:a,_currentValue2:a,_threadCount:0,Provider:null,Consumer:null,_defaultValue:null,_globalName:null};a.Provider={$$typeof:t,_context:a};return a.Consumer=a};react_production_min.createElement=M;react_production_min.createFactory=function(a){var b=M.bind(null,a);b.type=a;return b};react_production_min.createRef=function(){return {current:null}};
|
|
3349
|
+
react_production_min.forwardRef=function(a){return {$$typeof:v,render:a}};react_production_min.isValidElement=O;react_production_min.lazy=function(a){return {$$typeof:y,_payload:{_status:-1,_result:a},_init:T}};react_production_min.memo=function(a,b){return {$$typeof:x,type:a,compare:void 0===b?null:b}};react_production_min.startTransition=function(a){var b=V.transition;V.transition={};try{a();}finally{V.transition=b;}};react_production_min.unstable_act=X;react_production_min.useCallback=function(a,b){return U.current.useCallback(a,b)};react_production_min.useContext=function(a){return U.current.useContext(a)};
|
|
3350
|
+
react_production_min.useDebugValue=function(){};react_production_min.useDeferredValue=function(a){return U.current.useDeferredValue(a)};react_production_min.useEffect=function(a,b){return U.current.useEffect(a,b)};react_production_min.useId=function(){return U.current.useId()};react_production_min.useImperativeHandle=function(a,b,e){return U.current.useImperativeHandle(a,b,e)};react_production_min.useInsertionEffect=function(a,b){return U.current.useInsertionEffect(a,b)};react_production_min.useLayoutEffect=function(a,b){return U.current.useLayoutEffect(a,b)};
|
|
3351
|
+
react_production_min.useMemo=function(a,b){return U.current.useMemo(a,b)};react_production_min.useReducer=function(a,b,e){return U.current.useReducer(a,b,e)};react_production_min.useRef=function(a){return U.current.useRef(a)};react_production_min.useState=function(a){return U.current.useState(a)};react_production_min.useSyncExternalStore=function(a,b,e){return U.current.useSyncExternalStore(a,b,e)};react_production_min.useTransition=function(){return U.current.useTransition()};react_production_min.version="18.3.1";
|
|
3352
|
+
return react_production_min;
|
|
3353
|
+
}
|
|
3354
|
+
|
|
3355
|
+
{
|
|
3356
|
+
react.exports = requireReact_production_min();
|
|
3357
|
+
}
|
|
3358
|
+
|
|
3359
|
+
var reactExports = react.exports;
|
|
3360
|
+
|
|
3361
|
+
/**
|
|
3362
|
+
* @license React
|
|
3363
|
+
* react-jsx-runtime.production.min.js
|
|
3364
|
+
*
|
|
3365
|
+
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
3366
|
+
*
|
|
3367
|
+
* This source code is licensed under the MIT license found in the
|
|
3368
|
+
* LICENSE file in the root directory of this source tree.
|
|
3369
|
+
*/
|
|
3370
|
+
|
|
3371
|
+
var hasRequiredReactJsxRuntime_production_min;
|
|
3372
|
+
|
|
3373
|
+
function requireReactJsxRuntime_production_min () {
|
|
3374
|
+
if (hasRequiredReactJsxRuntime_production_min) return reactJsxRuntime_production_min;
|
|
3375
|
+
hasRequiredReactJsxRuntime_production_min = 1;
|
|
3376
|
+
var f=reactExports,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};
|
|
3377
|
+
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;
|
|
3378
|
+
return reactJsxRuntime_production_min;
|
|
3379
|
+
}
|
|
3380
|
+
|
|
3381
|
+
{
|
|
3382
|
+
jsxRuntime.exports = requireReactJsxRuntime_production_min();
|
|
3383
|
+
}
|
|
3384
|
+
|
|
3385
|
+
var jsxRuntimeExports = jsxRuntime.exports;
|
|
3386
|
+
|
|
3387
|
+
const AdStageContext = reactExports.createContext(null);
|
|
3388
|
+
function AdStageProvider({ children, config }) {
|
|
3389
|
+
const [isInitialized, setIsInitialized] = reactExports.useState(false);
|
|
3390
|
+
const [currentConfig, setCurrentConfig] = reactExports.useState(null);
|
|
3391
|
+
const [error, setError] = reactExports.useState(null);
|
|
3392
|
+
const initialize = (newConfig) => {
|
|
3393
|
+
try {
|
|
3394
|
+
setError(null);
|
|
3395
|
+
// 기존 인스턴스가 있으면 리셋
|
|
3396
|
+
if (isInitialized) {
|
|
3397
|
+
AdStage.reset();
|
|
3398
|
+
}
|
|
3399
|
+
AdStage.init(newConfig);
|
|
3400
|
+
setCurrentConfig(newConfig);
|
|
3401
|
+
setIsInitialized(true);
|
|
3402
|
+
if (newConfig.debug) {
|
|
3403
|
+
console.log('✅ AdStage SDK initialized successfully via React Provider');
|
|
3404
|
+
}
|
|
3405
|
+
}
|
|
3406
|
+
catch (err) {
|
|
3407
|
+
const errorMessage = err instanceof Error ? err.message : 'Unknown error';
|
|
3408
|
+
setError(errorMessage);
|
|
3409
|
+
console.error('❌ AdStage SDK initialization failed:', err);
|
|
3410
|
+
setIsInitialized(false);
|
|
3411
|
+
setCurrentConfig(null);
|
|
3412
|
+
}
|
|
3413
|
+
};
|
|
3414
|
+
const reset = () => {
|
|
3415
|
+
try {
|
|
3416
|
+
AdStage.reset();
|
|
3417
|
+
setIsInitialized(false);
|
|
3418
|
+
setCurrentConfig(null);
|
|
3419
|
+
setError(null);
|
|
3420
|
+
}
|
|
3421
|
+
catch (err) {
|
|
3422
|
+
console.error('❌ AdStage SDK reset failed:', err);
|
|
3423
|
+
}
|
|
3424
|
+
};
|
|
3425
|
+
// 자동 초기화
|
|
3426
|
+
reactExports.useEffect(() => {
|
|
3427
|
+
if (config && !isInitialized) {
|
|
3428
|
+
initialize(config);
|
|
3429
|
+
}
|
|
3430
|
+
}, [config, isInitialized]);
|
|
3431
|
+
const contextValue = {
|
|
3432
|
+
isInitialized,
|
|
3433
|
+
config: currentConfig,
|
|
3434
|
+
initialize,
|
|
3435
|
+
reset,
|
|
3436
|
+
error
|
|
3437
|
+
};
|
|
3438
|
+
return (jsxRuntimeExports.jsx(AdStageContext.Provider, { value: contextValue, children: children }));
|
|
3439
|
+
}
|
|
3440
|
+
/**
|
|
3441
|
+
* AdStage Context Hook
|
|
3442
|
+
* AdStageProvider 내에서 SDK 상태에 접근할 수 있습니다.
|
|
3443
|
+
*/
|
|
3444
|
+
function useAdStage() {
|
|
3445
|
+
const context = reactExports.useContext(AdStageContext);
|
|
3446
|
+
if (!context) {
|
|
3447
|
+
throw new Error('useAdStage must be used within an AdStageProvider');
|
|
3448
|
+
}
|
|
3449
|
+
return context;
|
|
3450
|
+
}
|
|
3451
|
+
/**
|
|
3452
|
+
* AdStage SDK Hook
|
|
3453
|
+
* 초기화된 AdStage 인스턴스에 직접 접근할 수 있습니다.
|
|
3454
|
+
*/
|
|
3455
|
+
function useAdStageSDK() {
|
|
3456
|
+
const { isInitialized } = useAdStage();
|
|
3457
|
+
if (!isInitialized) {
|
|
3458
|
+
throw new Error('AdStage SDK is not initialized. Please call initialize() first or provide config to AdStageProvider.');
|
|
3459
|
+
}
|
|
3460
|
+
return AdStage;
|
|
3461
|
+
}
|
|
3462
|
+
|
|
3312
3463
|
/**
|
|
3313
3464
|
* AdStage Web SDK
|
|
3314
3465
|
* 네임스페이스 아키텍처 기반 SDK
|
|
@@ -3318,4 +3469,4 @@ class AdStage {
|
|
|
3318
3469
|
const SDK_VERSION = '2.0.0';
|
|
3319
3470
|
const SUPPORTED_MODULES = ['ads', 'events', 'config'];
|
|
3320
3471
|
|
|
3321
|
-
export { AdStage, SDK_VERSION, SUPPORTED_MODULES };
|
|
3472
|
+
export { AdStage, AdStageProvider, SDK_VERSION, SUPPORTED_MODULES, useAdStageSDK as useAdStage };
|
package/package.json
CHANGED
package/src/index.ts
CHANGED
|
@@ -6,6 +6,9 @@
|
|
|
6
6
|
// 메인 네임스페이스 클래스
|
|
7
7
|
export { default as AdStage } from './core/AdStage';
|
|
8
8
|
|
|
9
|
+
// React 통합
|
|
10
|
+
export { AdStageProvider, useAdStage } from './react';
|
|
11
|
+
|
|
9
12
|
// 설정 및 타입
|
|
10
13
|
export type { AdStageConfig, ModuleName, BaseModule, ApiResponse, OrganizationInfo } from './types/config';
|
|
11
14
|
|
package/src/react/index.ts
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* React 애플리케이션을 위한 컴포넌트와 훅들
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
|
-
export { AdStageProvider, useAdStage, useAdStageSDK } from './AdStageProvider';
|
|
6
|
+
export { AdStageProvider, useAdStage as useAdStageContext, useAdStageSDK as useAdStage } from './AdStageProvider';
|
|
7
7
|
|
|
8
8
|
// 타입들도 재export
|
|
9
9
|
export type { AdStageConfig, ModuleName, BaseModule } from '../types/config';
|