@apps-in-toss/web-bridge 0.0.0-dev.1763036638916 → 0.0.0-dev.1764816865438
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/built/bridge.d.ts +1 -0
- package/built/bridge.js +1 -1
- package/built/getIsTossLoginIntegratedService.d.ts +50 -0
- package/built/index.cjs +287 -2
- package/built/index.d.cts +192 -6
- package/built/index.d.ts +192 -6
- package/built/index.js +284 -2
- package/package.json +5 -5
package/built/bridge.d.ts
CHANGED
|
@@ -26,6 +26,7 @@ export * from './getGameCenterGameProfile';
|
|
|
26
26
|
export * from './openGameCenterLeaderboard';
|
|
27
27
|
export * from './submitGameCenterLeaderBoardScore';
|
|
28
28
|
export * from './getUserKeyForGame';
|
|
29
|
+
export * from './getIsTossLoginIntegratedService';
|
|
29
30
|
export * from './grantPromotionRewardForGame';
|
|
30
31
|
export * from './getLocale';
|
|
31
32
|
export * from './getSchemeUri';
|
package/built/bridge.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{createAsyncBridge,createConstantBridge,createEventBridge}from"@apps-in-toss/bridge-core";var createEvents=function(){return{emit:function emit(event,args){for(var callbacks=this.events[event]||[],i=0,length=callbacks.length;i<length;i++){callbacks[i](args)}},events:{},on:function on(event,cb){var _this=this;var _this_events,_event;((_this_events=this.events)[_event=event]||(_this_events[_event]=[])).push(cb);return function(){var _this_events_event;_this.events[event]=(_this_events_event=_this.events[event])===null||_this_events_event===void 0?void 0:_this_events_event.filter(function(i){return cb!==i})}}}};if(typeof window!=="undefined"){window.__GRANITE_NATIVE_EMITTER=createEvents()}export var closeView=createAsyncBridge("closeView");export var generateHapticFeedback=createAsyncBridge("generateHapticFeedback");export var share=createAsyncBridge("share");export var setSecureScreen=createAsyncBridge("setSecureScreen");export var setScreenAwakeMode=createAsyncBridge("setScreenAwakeMode");export var getNetworkStatus=createAsyncBridge("getNetworkStatus");export var setIosSwipeGestureEnabled=createAsyncBridge("setIosSwipeGestureEnabled");export var openURL=createAsyncBridge("openURL");export var openPermissionDialog=createAsyncBridge("openPermissionDialog");export var getPermission=createAsyncBridge("getPermission");export var requestPermission=createAsyncBridge("requestPermission");export var setClipboardText=createConstantBridge("setClipboardText");export var getClipboardText=createConstantBridge("getClipboardText");export var fetchContacts=createConstantBridge("fetchContacts");export var fetchAlbumPhotos=createConstantBridge("fetchAlbumPhotos");export var getCurrentLocation=createConstantBridge("getCurrentLocation");export var openCamera=createConstantBridge("openCamera");export var appLogin=createAsyncBridge("appLogin");export var eventLog=createAsyncBridge("eventLog");export var getTossShareLink=createAsyncBridge("getTossShareLink");export var setDeviceOrientation=createAsyncBridge("setDeviceOrientation");export var checkoutPayment=createAsyncBridge("checkoutPayment");export var saveBase64Data=createAsyncBridge("saveBase64Data");export var appsInTossSignTossCert=createAsyncBridge("appsInTossSignTossCert");export var getGameCenterGameProfile=createAsyncBridge("getGameCenterGameProfile");export var openGameCenterLeaderboard=createAsyncBridge("openGameCenterLeaderboard");export var submitGameCenterLeaderBoardScore=createAsyncBridge("submitGameCenterLeaderBoardScore");export var getUserKeyForGame=createAsyncBridge("getUserKeyForGame");export var grantPromotionRewardForGame=createAsyncBridge("grantPromotionRewardForGame");export var getLocale=createConstantBridge("getLocale");export var getSchemeUri=createConstantBridge("getSchemeUri");export var getPlatformOS=createConstantBridge("getPlatformOS");export var getOperationalEnvironment=createConstantBridge("getOperationalEnvironment");export var getTossAppVersion=createConstantBridge("getTossAppVersion");export var getDeviceId=createConstantBridge("getDeviceId");export var contactsViral=createEventBridge("contactsViral");export var startUpdateLocation=createEventBridge("startUpdateLocation");export var onVisibilityChangedByTransparentServiceWeb=createEventBridge("onVisibilityChangedByTransparentServiceWeb");
|
|
1
|
+
import{createAsyncBridge,createConstantBridge,createEventBridge}from"@apps-in-toss/bridge-core";var createEvents=function(){return{emit:function emit(event,args){for(var callbacks=this.events[event]||[],i=0,length=callbacks.length;i<length;i++){callbacks[i](args)}},events:{},on:function on(event,cb){var _this=this;var _this_events,_event;((_this_events=this.events)[_event=event]||(_this_events[_event]=[])).push(cb);return function(){var _this_events_event;_this.events[event]=(_this_events_event=_this.events[event])===null||_this_events_event===void 0?void 0:_this_events_event.filter(function(i){return cb!==i})}}}};if(typeof window!=="undefined"){window.__GRANITE_NATIVE_EMITTER=createEvents()}export var closeView=createAsyncBridge("closeView");export var generateHapticFeedback=createAsyncBridge("generateHapticFeedback");export var share=createAsyncBridge("share");export var setSecureScreen=createAsyncBridge("setSecureScreen");export var setScreenAwakeMode=createAsyncBridge("setScreenAwakeMode");export var getNetworkStatus=createAsyncBridge("getNetworkStatus");export var setIosSwipeGestureEnabled=createAsyncBridge("setIosSwipeGestureEnabled");export var openURL=createAsyncBridge("openURL");export var openPermissionDialog=createAsyncBridge("openPermissionDialog");export var getPermission=createAsyncBridge("getPermission");export var requestPermission=createAsyncBridge("requestPermission");export var setClipboardText=createConstantBridge("setClipboardText");export var getClipboardText=createConstantBridge("getClipboardText");export var fetchContacts=createConstantBridge("fetchContacts");export var fetchAlbumPhotos=createConstantBridge("fetchAlbumPhotos");export var getCurrentLocation=createConstantBridge("getCurrentLocation");export var openCamera=createConstantBridge("openCamera");export var appLogin=createAsyncBridge("appLogin");export var eventLog=createAsyncBridge("eventLog");export var getTossShareLink=createAsyncBridge("getTossShareLink");export var setDeviceOrientation=createAsyncBridge("setDeviceOrientation");export var checkoutPayment=createAsyncBridge("checkoutPayment");export var saveBase64Data=createAsyncBridge("saveBase64Data");export var appsInTossSignTossCert=createAsyncBridge("appsInTossSignTossCert");export var getGameCenterGameProfile=createAsyncBridge("getGameCenterGameProfile");export var openGameCenterLeaderboard=createAsyncBridge("openGameCenterLeaderboard");export var submitGameCenterLeaderBoardScore=createAsyncBridge("submitGameCenterLeaderBoardScore");export var getUserKeyForGame=createAsyncBridge("getUserKeyForGame");export var getIsTossLoginIntegratedService=createAsyncBridge("getIsTossLoginIntegratedService");export var grantPromotionRewardForGame=createAsyncBridge("grantPromotionRewardForGame");export var getLocale=createConstantBridge("getLocale");export var getSchemeUri=createConstantBridge("getSchemeUri");export var getPlatformOS=createConstantBridge("getPlatformOS");export var getOperationalEnvironment=createConstantBridge("getOperationalEnvironment");export var getTossAppVersion=createConstantBridge("getTossAppVersion");export var getDeviceId=createConstantBridge("getDeviceId");export var contactsViral=createEventBridge("contactsViral");export var startUpdateLocation=createEventBridge("startUpdateLocation");export var onVisibilityChangedByTransparentServiceWeb=createEventBridge("onVisibilityChangedByTransparentServiceWeb");
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @public
|
|
3
|
+
* @category 토스 로그인
|
|
4
|
+
* @name getIsTossLoginIntegratedService
|
|
5
|
+
* @description
|
|
6
|
+
* 유저가 토스 로그인을 연동했는지 여부를 확인해요.
|
|
7
|
+
* 기존 토스 로그인 사용자를 찾아서 게임 식별자로 전환하는 마이그레이션을 할 때 사용할 수 있어요.
|
|
8
|
+
* @returns {Promise<boolean | undefined>}
|
|
9
|
+
* 토스 로그인이 연동된 유저인지 여부를 반환해요.
|
|
10
|
+
* - `true`: 토스 로그인이 연동된 유저에요.
|
|
11
|
+
* - `false`: 토스 로그인이 연동되지 않은 유저에요.
|
|
12
|
+
* - `undefined`: 앱 버전이 최소 지원 버전보다 낮아요.
|
|
13
|
+
* @throw {message: "oauth2ClientId 설정이 필요합니다."} - 토스 로그인을 사용하지 않는 미니앱에서 호출했을 때 발생해요.
|
|
14
|
+
* @example
|
|
15
|
+
* ```tsx
|
|
16
|
+
* // react-native
|
|
17
|
+
*
|
|
18
|
+
* import { getIsTossLoginIntegratedService } from '@apps-in-toss/web-framework';
|
|
19
|
+
*
|
|
20
|
+
* function GetIsTossLoginIntegratedServiceButton() {
|
|
21
|
+
* async function handlePress() {
|
|
22
|
+
* try {
|
|
23
|
+
* const result = await getIsTossLoginIntegratedService();
|
|
24
|
+
*
|
|
25
|
+
* if (result === undefined) {
|
|
26
|
+
* console.warn('지원하지 않는 앱 버전이에요.');
|
|
27
|
+
* return;
|
|
28
|
+
* }
|
|
29
|
+
* if (result === true) {
|
|
30
|
+
* console.log('토스 로그인이 연동된 유저에요.');
|
|
31
|
+
* // 여기에서 토스 로그인 연동 유저에 대한 처리를 할 수 있어요.
|
|
32
|
+
* }
|
|
33
|
+
* if (result === false) {
|
|
34
|
+
* console.log('토스 로그인이 연동되지 않은 유저에요.');
|
|
35
|
+
* // 여기에서 토스 로그인 연동 유저가 아닌 경우에 대한 처리를 할 수 있어요.
|
|
36
|
+
* }
|
|
37
|
+
* } catch (error) {
|
|
38
|
+
* console.error(error);
|
|
39
|
+
* }
|
|
40
|
+
* }
|
|
41
|
+
*
|
|
42
|
+
* return (
|
|
43
|
+
* <input type="button" onClick={handlePress} value="토스 로그인 통합 서비스 여부 확인" />
|
|
44
|
+
* );
|
|
45
|
+
* }
|
|
46
|
+
* ```
|
|
47
|
+
*/
|
|
48
|
+
export declare function getIsTossLoginIntegratedService(): Promise<boolean | undefined>;
|
|
49
|
+
|
|
50
|
+
export {};
|
package/built/index.cjs
CHANGED
|
@@ -26,6 +26,7 @@ __export(index_exports, {
|
|
|
26
26
|
IAP: () => IAP,
|
|
27
27
|
SafeAreaInsets: () => SafeAreaInsets,
|
|
28
28
|
Storage: () => Storage,
|
|
29
|
+
TossAds: () => TossAds,
|
|
29
30
|
appsInTossEvent: () => appsInTossEvent,
|
|
30
31
|
env: () => env,
|
|
31
32
|
fetchAlbumPhotos: () => fetchAlbumPhotos,
|
|
@@ -36,9 +37,11 @@ __export(index_exports, {
|
|
|
36
37
|
getSafeAreaInsets: () => getSafeAreaInsets,
|
|
37
38
|
graniteEvent: () => graniteEvent,
|
|
38
39
|
isMinVersionSupported: () => isMinVersionSupported,
|
|
40
|
+
loadFullScreenAd: () => loadFullScreenAd,
|
|
39
41
|
openCamera: () => openCamera,
|
|
40
42
|
partner: () => partner,
|
|
41
43
|
setClipboardText: () => setClipboardText,
|
|
44
|
+
showFullScreenAd: () => showFullScreenAd,
|
|
42
45
|
startUpdateLocation: () => startUpdateLocation,
|
|
43
46
|
tdsEvent: () => tdsEvent
|
|
44
47
|
});
|
|
@@ -304,7 +307,7 @@ var IAP = {
|
|
|
304
307
|
* @category 인앱결제
|
|
305
308
|
* @name getPendingOrders
|
|
306
309
|
* @description 대기 중인 주문 목록을 가져와요. 이 함수를 사용하면 결제가 아직 완료되지 않은 주문 정보를 확인할 수 있어요.
|
|
307
|
-
* @returns {Promise<{ orders: { orderId: string; sku: string; }[]}}>} 대기 중인 주문의 배열을 반환해요. 앱 버전이 최소 지원 버전(안드로이드 5.234.0, iOS 5.231.0)보다 낮으면 `undefined`를 반환해요.
|
|
310
|
+
* @returns {Promise<{ orders: { orderId: string; sku: string; paymentCompletedDate: string; }[]}}>} 대기 중인 주문의 배열을 반환해요. 앱 버전이 최소 지원 버전(안드로이드 5.234.0, iOS 5.231.0)보다 낮으면 `undefined`를 반환해요.
|
|
308
311
|
*
|
|
309
312
|
* @example
|
|
310
313
|
* ### 대기 중인 주문 목록 가져오기
|
|
@@ -321,7 +324,9 @@ var IAP = {
|
|
|
321
324
|
* }
|
|
322
325
|
* ```
|
|
323
326
|
*/
|
|
324
|
-
getPendingOrders: (0, import_bridge_core3.createAsyncBridge)(
|
|
327
|
+
getPendingOrders: (0, import_bridge_core3.createAsyncBridge)(
|
|
328
|
+
"getPendingOrders"
|
|
329
|
+
),
|
|
325
330
|
/**
|
|
326
331
|
* @public
|
|
327
332
|
* @category 인앱결제
|
|
@@ -1058,6 +1063,283 @@ var startUpdateLocation = (params) => {
|
|
|
1058
1063
|
startUpdateLocation.getPermission = () => getPermission2({ name: "geolocation", access: "access" });
|
|
1059
1064
|
startUpdateLocation.openPermissionDialog = () => openPermissionDialog2({ name: "geolocation", access: "access" });
|
|
1060
1065
|
|
|
1066
|
+
// src/integratedAd.ts
|
|
1067
|
+
var import_bridge_core21 = require("@apps-in-toss/bridge-core");
|
|
1068
|
+
var loadFullScreenAd = Object.assign((0, import_bridge_core21.createEventBridge)("loadFullScreenAd"), {
|
|
1069
|
+
isSupported: (0, import_bridge_core21.createConstantBridge)("loadFullScreenAd_isSupported")
|
|
1070
|
+
});
|
|
1071
|
+
var showFullScreenAd = Object.assign((0, import_bridge_core21.createEventBridge)("showFullScreenAd"), {
|
|
1072
|
+
isSupported: (0, import_bridge_core21.createConstantBridge)("showFullScreenAd_isSupported")
|
|
1073
|
+
});
|
|
1074
|
+
|
|
1075
|
+
// src/toss-ad/index.ts
|
|
1076
|
+
var import_bridge_core23 = require("@apps-in-toss/bridge-core");
|
|
1077
|
+
|
|
1078
|
+
// src/toss-ad/opener.ts
|
|
1079
|
+
var import_bridge_core22 = require("@apps-in-toss/bridge-core");
|
|
1080
|
+
var openURL = (0, import_bridge_core22.createAsyncBridge)("openURL");
|
|
1081
|
+
function openUrlOpener(url) {
|
|
1082
|
+
const transformed = getWebSchemeOrUri(url);
|
|
1083
|
+
return openURL(transformed);
|
|
1084
|
+
}
|
|
1085
|
+
function getWebSchemeOrUri(uri) {
|
|
1086
|
+
const isHttp = ["http://", "https://"].some((protocol) => uri.startsWith(protocol));
|
|
1087
|
+
return isHttp ? supertossWeb(uri) : uri;
|
|
1088
|
+
}
|
|
1089
|
+
function supertossWeb(uri) {
|
|
1090
|
+
return `supertoss://web?url=${encodeURIComponent(uri)}&external=true`;
|
|
1091
|
+
}
|
|
1092
|
+
|
|
1093
|
+
// src/toss-ad/scriptLoader.ts
|
|
1094
|
+
var DEFAULT_SDK_URL = "https://static.toss.im/ads/sdk/toss-ads-space-kit-1.0.0.js";
|
|
1095
|
+
var DEFAULT_TIMEOUT_MS = 15e3;
|
|
1096
|
+
var pendingLoad = null;
|
|
1097
|
+
function getAdsSdk() {
|
|
1098
|
+
if (typeof window === "undefined") {
|
|
1099
|
+
return void 0;
|
|
1100
|
+
}
|
|
1101
|
+
return window.TossAdsSpaceKit;
|
|
1102
|
+
}
|
|
1103
|
+
function loadAdsSdk() {
|
|
1104
|
+
if (typeof window === "undefined" || typeof document === "undefined") {
|
|
1105
|
+
return Promise.reject(new Error("Ads SDK can only be loaded in a browser environment."));
|
|
1106
|
+
}
|
|
1107
|
+
const existing = getAdsSdk();
|
|
1108
|
+
if (existing) {
|
|
1109
|
+
return Promise.resolve(existing);
|
|
1110
|
+
}
|
|
1111
|
+
if (pendingLoad) {
|
|
1112
|
+
return pendingLoad;
|
|
1113
|
+
}
|
|
1114
|
+
const promise = new Promise((resolve, reject) => {
|
|
1115
|
+
const script = document.createElement("script");
|
|
1116
|
+
const cleanup = () => {
|
|
1117
|
+
script.removeEventListener("load", handleLoad);
|
|
1118
|
+
script.removeEventListener("error", handleError);
|
|
1119
|
+
window.clearTimeout(timeoutId);
|
|
1120
|
+
pendingLoad = null;
|
|
1121
|
+
};
|
|
1122
|
+
const handleLoad = () => {
|
|
1123
|
+
const sdk = getAdsSdk();
|
|
1124
|
+
if (sdk) {
|
|
1125
|
+
cleanup();
|
|
1126
|
+
resolve(sdk);
|
|
1127
|
+
return;
|
|
1128
|
+
}
|
|
1129
|
+
cleanup();
|
|
1130
|
+
reject(new Error("Ads SDK script loaded but window.TossAdsSpaceKit was not exposed."));
|
|
1131
|
+
};
|
|
1132
|
+
const handleError = () => {
|
|
1133
|
+
cleanup();
|
|
1134
|
+
reject(new Error(`Failed to load Ads SDK script from ${DEFAULT_SDK_URL}.`));
|
|
1135
|
+
};
|
|
1136
|
+
const timeoutId = window.setTimeout(() => {
|
|
1137
|
+
cleanup();
|
|
1138
|
+
reject(new Error(`Loading Ads SDK timed out after ${DEFAULT_TIMEOUT_MS}ms.`));
|
|
1139
|
+
}, DEFAULT_TIMEOUT_MS);
|
|
1140
|
+
script.addEventListener("load", handleLoad);
|
|
1141
|
+
script.addEventListener("error", handleError);
|
|
1142
|
+
script.async = true;
|
|
1143
|
+
script.src = DEFAULT_SDK_URL;
|
|
1144
|
+
document.head.appendChild(script);
|
|
1145
|
+
});
|
|
1146
|
+
pendingLoad = promise;
|
|
1147
|
+
return promise;
|
|
1148
|
+
}
|
|
1149
|
+
|
|
1150
|
+
// src/toss-ad/index.ts
|
|
1151
|
+
var fetchTossAd = Object.assign((0, import_bridge_core23.createEventBridge)("fetchTossAd"), {
|
|
1152
|
+
isSupported: (0, import_bridge_core23.createConstantBridge)("fetchTossAd_isSupported")
|
|
1153
|
+
});
|
|
1154
|
+
var tossAdEventLog = (0, import_bridge_core23.createAsyncBridge)("tossAdEventLog");
|
|
1155
|
+
var SUPPORTED_STYLE_IDS = /* @__PURE__ */ new Set(["1", "2"]);
|
|
1156
|
+
function fetchTossAdPromise(options) {
|
|
1157
|
+
return new Promise((resolve, reject) => {
|
|
1158
|
+
if (!fetchTossAd.isSupported()) {
|
|
1159
|
+
reject(new Error("fetchTossAd is not supported in this environment."));
|
|
1160
|
+
return;
|
|
1161
|
+
}
|
|
1162
|
+
return fetchTossAd({
|
|
1163
|
+
options,
|
|
1164
|
+
onEvent: resolve,
|
|
1165
|
+
onError: reject
|
|
1166
|
+
});
|
|
1167
|
+
});
|
|
1168
|
+
}
|
|
1169
|
+
function normalizeAdResponse(adResponse) {
|
|
1170
|
+
const ads = Array.isArray(adResponse.ads) ? adResponse.ads.filter((ad) => SUPPORTED_STYLE_IDS.has(String(ad.styleId))) : [];
|
|
1171
|
+
return {
|
|
1172
|
+
requestId: adResponse.requestId ?? "",
|
|
1173
|
+
status: adResponse.status ?? "OK",
|
|
1174
|
+
ads,
|
|
1175
|
+
ext: adResponse.ext
|
|
1176
|
+
};
|
|
1177
|
+
}
|
|
1178
|
+
function normalizeApiResponse(raw) {
|
|
1179
|
+
if (isApiResponse(raw)) {
|
|
1180
|
+
if (raw.resultType !== "SUCCESS") {
|
|
1181
|
+
return raw;
|
|
1182
|
+
}
|
|
1183
|
+
if (!raw.success) {
|
|
1184
|
+
return {
|
|
1185
|
+
resultType: "FAIL",
|
|
1186
|
+
error: { reason: "fetchTossAd returned SUCCESS without payload" }
|
|
1187
|
+
};
|
|
1188
|
+
}
|
|
1189
|
+
return { ...raw, success: normalizeAdResponse(raw.success) };
|
|
1190
|
+
}
|
|
1191
|
+
if (isAdResponse(raw)) {
|
|
1192
|
+
return {
|
|
1193
|
+
resultType: "SUCCESS",
|
|
1194
|
+
success: normalizeAdResponse(raw)
|
|
1195
|
+
};
|
|
1196
|
+
}
|
|
1197
|
+
return { resultType: "FAIL", error: { reason: "Invalid response from fetchTossAd" } };
|
|
1198
|
+
}
|
|
1199
|
+
function isApiResponse(payload) {
|
|
1200
|
+
return Boolean(payload && typeof payload === "object" && "resultType" in payload);
|
|
1201
|
+
}
|
|
1202
|
+
function isAdResponse(payload) {
|
|
1203
|
+
return Boolean(payload && typeof payload === "object" && "ads" in payload);
|
|
1204
|
+
}
|
|
1205
|
+
function createCustomAdFetcher() {
|
|
1206
|
+
return async (_endpoint, request) => {
|
|
1207
|
+
try {
|
|
1208
|
+
const raw = await fetchTossAdPromise({ adGroupId: request.spaceUnitId });
|
|
1209
|
+
return normalizeApiResponse(raw);
|
|
1210
|
+
} catch (error) {
|
|
1211
|
+
return {
|
|
1212
|
+
resultType: "FAIL",
|
|
1213
|
+
error: {
|
|
1214
|
+
reason: error instanceof Error ? error.message : "Unknown fetchTossAd error"
|
|
1215
|
+
}
|
|
1216
|
+
};
|
|
1217
|
+
}
|
|
1218
|
+
};
|
|
1219
|
+
}
|
|
1220
|
+
var pendingLoad2 = null;
|
|
1221
|
+
function initialize(options) {
|
|
1222
|
+
const { callbacks } = options;
|
|
1223
|
+
if (window.TossAdsSpaceKit != null && window.TossAdsSpaceKit.isInitialized()) {
|
|
1224
|
+
callbacks?.onInitializationFailed?.(new Error("[toss-ad] Already initialized."));
|
|
1225
|
+
return;
|
|
1226
|
+
}
|
|
1227
|
+
if (pendingLoad2 != null) {
|
|
1228
|
+
callbacks?.onInitializationFailed?.(new Error("[toss-ad] initialization already in progress."));
|
|
1229
|
+
}
|
|
1230
|
+
const resolveInitialized = () => callbacks?.onInitialized?.();
|
|
1231
|
+
const rejectInitialized = (error) => {
|
|
1232
|
+
const normalizedError = error instanceof Error ? error : new Error(String(error));
|
|
1233
|
+
callbacks?.onInitializationFailed?.(normalizedError);
|
|
1234
|
+
};
|
|
1235
|
+
pendingLoad2 = loadAdsSdk().then((sdk) => {
|
|
1236
|
+
const customAdFetcher = createCustomAdFetcher();
|
|
1237
|
+
const config = { environment: "live", customAdFetcher, opener: openUrlOpener };
|
|
1238
|
+
sdk.init(config);
|
|
1239
|
+
resolveInitialized();
|
|
1240
|
+
}).catch((error) => {
|
|
1241
|
+
pendingLoad2 = null;
|
|
1242
|
+
rejectInitialized(error);
|
|
1243
|
+
});
|
|
1244
|
+
}
|
|
1245
|
+
function attach(adGroupId, target, options = {}) {
|
|
1246
|
+
const { callbacks } = options;
|
|
1247
|
+
const rejectAttached = (error) => {
|
|
1248
|
+
const normalizedError = error instanceof Error ? error : new Error(String(error));
|
|
1249
|
+
callbacks?.onAdFailedToRender?.({
|
|
1250
|
+
slotId: "",
|
|
1251
|
+
adGroupId,
|
|
1252
|
+
adMetadata: {},
|
|
1253
|
+
error: { code: 0, message: normalizedError.message }
|
|
1254
|
+
});
|
|
1255
|
+
};
|
|
1256
|
+
try {
|
|
1257
|
+
const spaceId = adGroupId;
|
|
1258
|
+
const sdk = getAdsSdk();
|
|
1259
|
+
if (!sdk) {
|
|
1260
|
+
throw new Error("[toss-ad] Call initialize() before attaching an ad.");
|
|
1261
|
+
}
|
|
1262
|
+
if (!sdk.banner) {
|
|
1263
|
+
throw new Error("[toss-ad] Loaded TossAdsSpaceKit does not support banner ads.");
|
|
1264
|
+
}
|
|
1265
|
+
const element = typeof target === "string" ? document.querySelector(target) : target;
|
|
1266
|
+
if (!element) {
|
|
1267
|
+
throw new Error(`[toss-ad] Failed to find target element: ${target}`);
|
|
1268
|
+
}
|
|
1269
|
+
const slotOptions = {
|
|
1270
|
+
spaceId,
|
|
1271
|
+
autoLoad: true,
|
|
1272
|
+
theme: options.theme,
|
|
1273
|
+
padding: options.padding,
|
|
1274
|
+
callbacks: wrapCallbacks(adGroupId, options.callbacks)
|
|
1275
|
+
};
|
|
1276
|
+
sdk.banner.createSlot(element, slotOptions);
|
|
1277
|
+
} catch (error) {
|
|
1278
|
+
rejectAttached(error);
|
|
1279
|
+
}
|
|
1280
|
+
}
|
|
1281
|
+
function destroy(slotId) {
|
|
1282
|
+
const sdk = getAdsSdk();
|
|
1283
|
+
if (!sdk?.banner) {
|
|
1284
|
+
return;
|
|
1285
|
+
}
|
|
1286
|
+
sdk.banner.destroy(slotId);
|
|
1287
|
+
}
|
|
1288
|
+
function destroyAll() {
|
|
1289
|
+
const sdk = getAdsSdk();
|
|
1290
|
+
if (!sdk?.banner) {
|
|
1291
|
+
return;
|
|
1292
|
+
}
|
|
1293
|
+
sdk.banner.destroyAll();
|
|
1294
|
+
}
|
|
1295
|
+
function wrapCallbacks(adGroupId, callbacks) {
|
|
1296
|
+
if (!callbacks) {
|
|
1297
|
+
return void 0;
|
|
1298
|
+
}
|
|
1299
|
+
const mapEvent = (payload) => {
|
|
1300
|
+
const next = { ...payload ?? {} };
|
|
1301
|
+
next.adGroupId = next.adGroupId ?? next.spaceId ?? adGroupId;
|
|
1302
|
+
delete next.spaceId;
|
|
1303
|
+
return next;
|
|
1304
|
+
};
|
|
1305
|
+
return {
|
|
1306
|
+
onAdRendered: (payload) => callbacks.onAdRendered?.(mapEvent(payload)),
|
|
1307
|
+
onAdViewable: (payload) => callbacks.onAdViewable?.(mapEvent(payload)),
|
|
1308
|
+
onAdClicked: (payload) => callbacks.onAdClicked?.(mapEvent(payload)),
|
|
1309
|
+
onAdImpression: (payload) => {
|
|
1310
|
+
tossAdEventLog({
|
|
1311
|
+
log_name: "display_ads_all::impression__1px_banner",
|
|
1312
|
+
log_type: "event",
|
|
1313
|
+
params: {
|
|
1314
|
+
event_type: "impression",
|
|
1315
|
+
schema_id: 1812034,
|
|
1316
|
+
request_id: payload?.adMetadata?.requestId ?? ""
|
|
1317
|
+
}
|
|
1318
|
+
});
|
|
1319
|
+
callbacks.onAdImpression?.(mapEvent(payload));
|
|
1320
|
+
},
|
|
1321
|
+
onAdFailedToRender: (payload) => callbacks.onAdFailedToRender?.({
|
|
1322
|
+
...mapEvent(payload),
|
|
1323
|
+
error: payload?.error ?? { code: 0, message: "UNKNOWN" }
|
|
1324
|
+
}),
|
|
1325
|
+
onNoFill: (payload) => callbacks.onNoFill?.(mapEvent(payload))
|
|
1326
|
+
};
|
|
1327
|
+
}
|
|
1328
|
+
var TossAds = {
|
|
1329
|
+
initialize: Object.assign(initialize, {
|
|
1330
|
+
isSupported: fetchTossAd.isSupported
|
|
1331
|
+
}),
|
|
1332
|
+
attach: Object.assign(attach, {
|
|
1333
|
+
isSupported: fetchTossAd.isSupported
|
|
1334
|
+
}),
|
|
1335
|
+
destroy: Object.assign(destroy, {
|
|
1336
|
+
isSupported: fetchTossAd.isSupported
|
|
1337
|
+
}),
|
|
1338
|
+
destroyAll: Object.assign(destroyAll, {
|
|
1339
|
+
isSupported: fetchTossAd.isSupported
|
|
1340
|
+
})
|
|
1341
|
+
};
|
|
1342
|
+
|
|
1061
1343
|
// src/index.ts
|
|
1062
1344
|
__reExport(index_exports, require("@apps-in-toss/types"), module.exports);
|
|
1063
1345
|
// Annotate the CommonJS export names for ESM import in node:
|
|
@@ -1066,6 +1348,7 @@ __reExport(index_exports, require("@apps-in-toss/types"), module.exports);
|
|
|
1066
1348
|
IAP,
|
|
1067
1349
|
SafeAreaInsets,
|
|
1068
1350
|
Storage,
|
|
1351
|
+
TossAds,
|
|
1069
1352
|
appsInTossEvent,
|
|
1070
1353
|
env,
|
|
1071
1354
|
fetchAlbumPhotos,
|
|
@@ -1076,9 +1359,11 @@ __reExport(index_exports, require("@apps-in-toss/types"), module.exports);
|
|
|
1076
1359
|
getSafeAreaInsets,
|
|
1077
1360
|
graniteEvent,
|
|
1078
1361
|
isMinVersionSupported,
|
|
1362
|
+
loadFullScreenAd,
|
|
1079
1363
|
openCamera,
|
|
1080
1364
|
partner,
|
|
1081
1365
|
setClipboardText,
|
|
1366
|
+
showFullScreenAd,
|
|
1082
1367
|
startUpdateLocation,
|
|
1083
1368
|
tdsEvent,
|
|
1084
1369
|
...require("@apps-in-toss/bridge-core"),
|
package/built/index.d.cts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export * from './bridge';
|
|
2
2
|
export * from '@apps-in-toss/bridge-core';
|
|
3
|
-
import { LoadAdMobInterstitialAdEvent, LoadAdMobInterstitialAdOptions, ShowAdMobInterstitialAdEvent, ShowAdMobInterstitialAdOptions, LoadAdMobRewardedAdEvent, LoadAdMobRewardedAdOptions, ShowAdMobRewardedAdEvent, ShowAdMobRewardedAdOptions, LoadAdMobEvent, LoadAdMobOptions, ShowAdMobEvent, ShowAdMobOptions } from '@apps-in-toss/framework';
|
|
3
|
+
import { LoadAdMobInterstitialAdEvent, LoadAdMobInterstitialAdOptions, ShowAdMobInterstitialAdEvent, ShowAdMobInterstitialAdOptions, LoadAdMobRewardedAdEvent, LoadAdMobRewardedAdOptions, ShowAdMobRewardedAdEvent, ShowAdMobRewardedAdOptions, LoadAdMobEvent, LoadAdMobOptions, ShowAdMobEvent, ShowAdMobOptions, LoadFullScreenAdEvent, LoadFullScreenAdOptions, ShowFullScreenAdEvent, ShowFullScreenAdOptions } from '@apps-in-toss/framework';
|
|
4
4
|
import * as _apps_in_toss_types from '@apps-in-toss/types';
|
|
5
5
|
import { FetchAlbumPhotos, FetchContacts, GetCurrentLocation, OpenCamera, SetClipboardText, GetClipboardText, StartUpdateLocationEventParams } from '@apps-in-toss/types';
|
|
6
6
|
export * from '@apps-in-toss/types';
|
|
@@ -230,7 +230,7 @@ declare const IAP: {
|
|
|
230
230
|
* @category 인앱결제
|
|
231
231
|
* @name getPendingOrders
|
|
232
232
|
* @description 대기 중인 주문 목록을 가져와요. 이 함수를 사용하면 결제가 아직 완료되지 않은 주문 정보를 확인할 수 있어요.
|
|
233
|
-
* @returns {Promise<{ orders: { orderId: string; sku: string; }[]}}>} 대기 중인 주문의 배열을 반환해요. 앱 버전이 최소 지원 버전(안드로이드 5.234.0, iOS 5.231.0)보다 낮으면 `undefined`를 반환해요.
|
|
233
|
+
* @returns {Promise<{ orders: { orderId: string; sku: string; paymentCompletedDate: string; }[]}}>} 대기 중인 주문의 배열을 반환해요. 앱 버전이 최소 지원 버전(안드로이드 5.234.0, iOS 5.231.0)보다 낮으면 `undefined`를 반환해요.
|
|
234
234
|
*
|
|
235
235
|
* @example
|
|
236
236
|
* ### 대기 중인 주문 목록 가져오기
|
|
@@ -251,6 +251,7 @@ declare const IAP: {
|
|
|
251
251
|
orders: {
|
|
252
252
|
orderId: string;
|
|
253
253
|
sku: string;
|
|
254
|
+
paymentCompletedDate: string;
|
|
254
255
|
}[];
|
|
255
256
|
}>;
|
|
256
257
|
/**
|
|
@@ -341,15 +342,15 @@ declare function getSafeAreaInsets(): {
|
|
|
341
342
|
* ```
|
|
342
343
|
*/
|
|
343
344
|
declare function subscribeSafeAreaInsets({ onEvent }: {
|
|
344
|
-
onEvent: (data: SafeAreaInsets) => void;
|
|
345
|
+
onEvent: (data: SafeAreaInsets$1) => void;
|
|
345
346
|
}): () => void;
|
|
346
|
-
interface SafeAreaInsets {
|
|
347
|
+
interface SafeAreaInsets$1 {
|
|
347
348
|
top: number;
|
|
348
349
|
bottom: number;
|
|
349
350
|
left: number;
|
|
350
351
|
right: number;
|
|
351
352
|
}
|
|
352
|
-
declare const SafeAreaInsets: {
|
|
353
|
+
declare const SafeAreaInsets$1: {
|
|
353
354
|
get: typeof getSafeAreaInsets;
|
|
354
355
|
subscribe: typeof subscribeSafeAreaInsets;
|
|
355
356
|
};
|
|
@@ -966,4 +967,189 @@ declare const startUpdateLocation: {
|
|
|
966
967
|
openPermissionDialog(): Promise<"denied" | "allowed">;
|
|
967
968
|
};
|
|
968
969
|
|
|
969
|
-
|
|
970
|
+
declare const loadFullScreenAd: ((args: {
|
|
971
|
+
onEvent: (data: LoadFullScreenAdEvent) => void;
|
|
972
|
+
onError: (error: Error) => void;
|
|
973
|
+
options?: LoadFullScreenAdOptions | undefined;
|
|
974
|
+
}) => () => void) & {
|
|
975
|
+
isSupported: () => boolean;
|
|
976
|
+
};
|
|
977
|
+
declare const showFullScreenAd: ((args: {
|
|
978
|
+
onEvent: (data: ShowFullScreenAdEvent) => void;
|
|
979
|
+
onError: (error: Error) => void;
|
|
980
|
+
options?: ShowFullScreenAdOptions | undefined;
|
|
981
|
+
}) => () => void) & {
|
|
982
|
+
isSupported: () => boolean;
|
|
983
|
+
};
|
|
984
|
+
|
|
985
|
+
type Environment = 'alpha' | 'live';
|
|
986
|
+
type DeviceOS = 'IOS' | 'ANDROID';
|
|
987
|
+
type DeviceAttStatus = 'NOT_DETERMINED' | 'RESTRICTED' | 'DENIED' | 'AUTHORIZED';
|
|
988
|
+
type DeviceCarrier = 'SKT' | 'KT' | 'LGU' | 'SKT_MVNO' | 'KT_MVNO' | 'LG_MVNO';
|
|
989
|
+
type RequestHeaders = Record<string, string>;
|
|
990
|
+
interface DeviceInfo {
|
|
991
|
+
os?: DeviceOS;
|
|
992
|
+
osVersion?: string;
|
|
993
|
+
ua?: string;
|
|
994
|
+
ifa?: string;
|
|
995
|
+
ifv?: string | null;
|
|
996
|
+
attStatus?: DeviceAttStatus | null;
|
|
997
|
+
model?: string;
|
|
998
|
+
carrier?: DeviceCarrier;
|
|
999
|
+
}
|
|
1000
|
+
interface SafeAreaInsets {
|
|
1001
|
+
top: string;
|
|
1002
|
+
bottom: string;
|
|
1003
|
+
left: string;
|
|
1004
|
+
right: string;
|
|
1005
|
+
}
|
|
1006
|
+
interface RuntimeInfo {
|
|
1007
|
+
safeAreaInsets?: SafeAreaInsets;
|
|
1008
|
+
}
|
|
1009
|
+
type AdOpener = (url: string, target?: string, features?: string) => void;
|
|
1010
|
+
interface AdConfig {
|
|
1011
|
+
environment: Environment;
|
|
1012
|
+
apiEndpoint?: string;
|
|
1013
|
+
deviceInfo?: DeviceInfo;
|
|
1014
|
+
requestHeaders?: RequestHeaders;
|
|
1015
|
+
runtimeInfo?: RuntimeInfo;
|
|
1016
|
+
opener?: AdOpener;
|
|
1017
|
+
customAdFetcher?: CustomAdFetcher;
|
|
1018
|
+
}
|
|
1019
|
+
interface AdRequest {
|
|
1020
|
+
spaceUnitId: string;
|
|
1021
|
+
options?: {
|
|
1022
|
+
dummyAdFormat?: string;
|
|
1023
|
+
maxSize?: number;
|
|
1024
|
+
video?: {
|
|
1025
|
+
maxDurationMs?: number;
|
|
1026
|
+
};
|
|
1027
|
+
};
|
|
1028
|
+
}
|
|
1029
|
+
type AdResponseStatus = 'OK' | 'NO_AD' | 'BLOCKED' | 'ERROR' | 'TIMEOUT' | 'INVALID_SPACE' | 'INVALID_REQUEST' | 'LIMITED_AD' | 'CONSENT_REQUIRED' | 'TEST_MODE';
|
|
1030
|
+
interface AdResponse {
|
|
1031
|
+
requestId?: string;
|
|
1032
|
+
status?: AdResponseStatus;
|
|
1033
|
+
ads: Ad[];
|
|
1034
|
+
ext?: AdResponseExt;
|
|
1035
|
+
}
|
|
1036
|
+
interface Ad {
|
|
1037
|
+
styleId: string;
|
|
1038
|
+
creative: Record<string, any>;
|
|
1039
|
+
eventTrackingUrls?: string[];
|
|
1040
|
+
eventTypes?: string[];
|
|
1041
|
+
eventPayload?: string;
|
|
1042
|
+
requestId?: string;
|
|
1043
|
+
}
|
|
1044
|
+
interface AdResponseExt {
|
|
1045
|
+
skippableOffsetSeconds?: number;
|
|
1046
|
+
reward?: {
|
|
1047
|
+
type: string;
|
|
1048
|
+
amount: number;
|
|
1049
|
+
};
|
|
1050
|
+
isAdBadgeEnabled?: boolean;
|
|
1051
|
+
refetchSeconds?: number | null;
|
|
1052
|
+
}
|
|
1053
|
+
interface ApiResponse<T> {
|
|
1054
|
+
resultType: 'SUCCESS' | 'HTTP_TIMEOUT' | 'NETWORK_ERROR' | 'EXECUTION_FAIL' | 'INTERRUPTED' | 'INTERNAL_ERROR' | 'FAIL';
|
|
1055
|
+
success?: T;
|
|
1056
|
+
error?: {
|
|
1057
|
+
errorType?: number;
|
|
1058
|
+
errorCode?: string;
|
|
1059
|
+
reason?: string;
|
|
1060
|
+
data?: Record<string, any>;
|
|
1061
|
+
title?: string;
|
|
1062
|
+
};
|
|
1063
|
+
}
|
|
1064
|
+
type CustomAdFetcher = (endpoint: string, request: AdRequest, headers?: RequestHeaders) => Promise<ApiResponse<AdResponse>>;
|
|
1065
|
+
interface InitializeOptions {
|
|
1066
|
+
callbacks?: {
|
|
1067
|
+
onInitialized?: () => void;
|
|
1068
|
+
onInitializationFailed?: (error: Error) => void;
|
|
1069
|
+
};
|
|
1070
|
+
}
|
|
1071
|
+
interface BannerSlotEventPayload {
|
|
1072
|
+
slotId: string;
|
|
1073
|
+
adGroupId: string;
|
|
1074
|
+
adMetadata: {
|
|
1075
|
+
creativeId: string;
|
|
1076
|
+
requestId: string;
|
|
1077
|
+
};
|
|
1078
|
+
}
|
|
1079
|
+
interface BannerSlotErrorPayload {
|
|
1080
|
+
slotId: string;
|
|
1081
|
+
adGroupId: string;
|
|
1082
|
+
adMetadata: Record<string, never>;
|
|
1083
|
+
error: {
|
|
1084
|
+
code: number;
|
|
1085
|
+
message: string;
|
|
1086
|
+
domain?: string;
|
|
1087
|
+
};
|
|
1088
|
+
}
|
|
1089
|
+
interface BannerSlotCallbacks {
|
|
1090
|
+
onAdRendered?: (payload: BannerSlotEventPayload) => void;
|
|
1091
|
+
onAdViewable?: (payload: BannerSlotEventPayload) => void;
|
|
1092
|
+
onAdClicked?: (payload: BannerSlotEventPayload) => void;
|
|
1093
|
+
onAdImpression?: (payload: BannerSlotEventPayload) => void;
|
|
1094
|
+
onAdFailedToRender?: (payload: BannerSlotErrorPayload) => void;
|
|
1095
|
+
onNoFill?: (payload: {
|
|
1096
|
+
slotId: string;
|
|
1097
|
+
adGroupId: string;
|
|
1098
|
+
adMetadata: Record<string, never>;
|
|
1099
|
+
}) => void;
|
|
1100
|
+
}
|
|
1101
|
+
interface BannerSlotOptions {
|
|
1102
|
+
spaceId: string;
|
|
1103
|
+
autoLoad?: boolean;
|
|
1104
|
+
dummyAdFormat?: string;
|
|
1105
|
+
maxVideoDurationMs?: number;
|
|
1106
|
+
refetchIntervalMs?: number;
|
|
1107
|
+
theme?: 'light' | 'dark';
|
|
1108
|
+
padding?: string;
|
|
1109
|
+
callbacks?: BannerSlotCallbacks;
|
|
1110
|
+
}
|
|
1111
|
+
interface BannerSlot {
|
|
1112
|
+
load(): void | Promise<void>;
|
|
1113
|
+
destroy(): void;
|
|
1114
|
+
}
|
|
1115
|
+
interface BannerNamespace {
|
|
1116
|
+
createSlot(target: string | HTMLElement, options: BannerSlotOptions): BannerSlot;
|
|
1117
|
+
destroy(slotId: string): void;
|
|
1118
|
+
destroyAll(): void;
|
|
1119
|
+
}
|
|
1120
|
+
interface AdsSdkGlobal {
|
|
1121
|
+
init(config: AdConfig): void;
|
|
1122
|
+
banner: BannerNamespace;
|
|
1123
|
+
isInitialized(): boolean;
|
|
1124
|
+
}
|
|
1125
|
+
declare global {
|
|
1126
|
+
interface Window {
|
|
1127
|
+
TossAdsSpaceKit?: AdsSdkGlobal;
|
|
1128
|
+
}
|
|
1129
|
+
}
|
|
1130
|
+
interface AttachOptions {
|
|
1131
|
+
theme?: 'light' | 'dark';
|
|
1132
|
+
padding?: string;
|
|
1133
|
+
callbacks?: BannerSlotCallbacks;
|
|
1134
|
+
}
|
|
1135
|
+
|
|
1136
|
+
declare function initialize(options: InitializeOptions): void;
|
|
1137
|
+
declare function attach(adGroupId: string, target: string | HTMLElement, options?: AttachOptions): void;
|
|
1138
|
+
declare function destroy(slotId: string): void;
|
|
1139
|
+
declare function destroyAll(): void;
|
|
1140
|
+
declare const TossAds: {
|
|
1141
|
+
initialize: typeof initialize & {
|
|
1142
|
+
isSupported: () => boolean;
|
|
1143
|
+
};
|
|
1144
|
+
attach: typeof attach & {
|
|
1145
|
+
isSupported: () => boolean;
|
|
1146
|
+
};
|
|
1147
|
+
destroy: typeof destroy & {
|
|
1148
|
+
isSupported: () => boolean;
|
|
1149
|
+
};
|
|
1150
|
+
destroyAll: typeof destroyAll & {
|
|
1151
|
+
isSupported: () => boolean;
|
|
1152
|
+
};
|
|
1153
|
+
};
|
|
1154
|
+
|
|
1155
|
+
export { type AddAccessoryButtonOptions, type AppsInTossEvent, type AppsInTossGlobals, type CompletedOrRefundedOrdersResult, GoogleAdMob, type GraniteEvent, IAP, type IapCreateOneTimePurchaseOrderOptions, type IapProductListItem, SafeAreaInsets$1 as SafeAreaInsets, Storage, type TdsEvent, TossAds, type AttachOptions as TossAdsAttachOptions, type BannerSlotCallbacks as TossAdsBannerSlotCallbacks, type BannerSlotErrorPayload as TossAdsBannerSlotErrorPayload, type BannerSlotEventPayload as TossAdsBannerSlotEventPayload, type InitializeOptions as TossAdsInitializeOptions, appsInTossEvent, env, fetchAlbumPhotos, fetchContacts, getAppsInTossGlobals, getClipboardText, getCurrentLocation, getSafeAreaInsets, graniteEvent, isMinVersionSupported, loadFullScreenAd, openCamera, partner, setClipboardText, showFullScreenAd, startUpdateLocation, tdsEvent };
|
package/built/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export * from './bridge';
|
|
2
2
|
export * from '@apps-in-toss/bridge-core';
|
|
3
|
-
import { LoadAdMobInterstitialAdEvent, LoadAdMobInterstitialAdOptions, ShowAdMobInterstitialAdEvent, ShowAdMobInterstitialAdOptions, LoadAdMobRewardedAdEvent, LoadAdMobRewardedAdOptions, ShowAdMobRewardedAdEvent, ShowAdMobRewardedAdOptions, LoadAdMobEvent, LoadAdMobOptions, ShowAdMobEvent, ShowAdMobOptions } from '@apps-in-toss/framework';
|
|
3
|
+
import { LoadAdMobInterstitialAdEvent, LoadAdMobInterstitialAdOptions, ShowAdMobInterstitialAdEvent, ShowAdMobInterstitialAdOptions, LoadAdMobRewardedAdEvent, LoadAdMobRewardedAdOptions, ShowAdMobRewardedAdEvent, ShowAdMobRewardedAdOptions, LoadAdMobEvent, LoadAdMobOptions, ShowAdMobEvent, ShowAdMobOptions, LoadFullScreenAdEvent, LoadFullScreenAdOptions, ShowFullScreenAdEvent, ShowFullScreenAdOptions } from '@apps-in-toss/framework';
|
|
4
4
|
import * as _apps_in_toss_types from '@apps-in-toss/types';
|
|
5
5
|
import { FetchAlbumPhotos, FetchContacts, GetCurrentLocation, OpenCamera, SetClipboardText, GetClipboardText, StartUpdateLocationEventParams } from '@apps-in-toss/types';
|
|
6
6
|
export * from '@apps-in-toss/types';
|
|
@@ -230,7 +230,7 @@ declare const IAP: {
|
|
|
230
230
|
* @category 인앱결제
|
|
231
231
|
* @name getPendingOrders
|
|
232
232
|
* @description 대기 중인 주문 목록을 가져와요. 이 함수를 사용하면 결제가 아직 완료되지 않은 주문 정보를 확인할 수 있어요.
|
|
233
|
-
* @returns {Promise<{ orders: { orderId: string; sku: string; }[]}}>} 대기 중인 주문의 배열을 반환해요. 앱 버전이 최소 지원 버전(안드로이드 5.234.0, iOS 5.231.0)보다 낮으면 `undefined`를 반환해요.
|
|
233
|
+
* @returns {Promise<{ orders: { orderId: string; sku: string; paymentCompletedDate: string; }[]}}>} 대기 중인 주문의 배열을 반환해요. 앱 버전이 최소 지원 버전(안드로이드 5.234.0, iOS 5.231.0)보다 낮으면 `undefined`를 반환해요.
|
|
234
234
|
*
|
|
235
235
|
* @example
|
|
236
236
|
* ### 대기 중인 주문 목록 가져오기
|
|
@@ -251,6 +251,7 @@ declare const IAP: {
|
|
|
251
251
|
orders: {
|
|
252
252
|
orderId: string;
|
|
253
253
|
sku: string;
|
|
254
|
+
paymentCompletedDate: string;
|
|
254
255
|
}[];
|
|
255
256
|
}>;
|
|
256
257
|
/**
|
|
@@ -341,15 +342,15 @@ declare function getSafeAreaInsets(): {
|
|
|
341
342
|
* ```
|
|
342
343
|
*/
|
|
343
344
|
declare function subscribeSafeAreaInsets({ onEvent }: {
|
|
344
|
-
onEvent: (data: SafeAreaInsets) => void;
|
|
345
|
+
onEvent: (data: SafeAreaInsets$1) => void;
|
|
345
346
|
}): () => void;
|
|
346
|
-
interface SafeAreaInsets {
|
|
347
|
+
interface SafeAreaInsets$1 {
|
|
347
348
|
top: number;
|
|
348
349
|
bottom: number;
|
|
349
350
|
left: number;
|
|
350
351
|
right: number;
|
|
351
352
|
}
|
|
352
|
-
declare const SafeAreaInsets: {
|
|
353
|
+
declare const SafeAreaInsets$1: {
|
|
353
354
|
get: typeof getSafeAreaInsets;
|
|
354
355
|
subscribe: typeof subscribeSafeAreaInsets;
|
|
355
356
|
};
|
|
@@ -966,4 +967,189 @@ declare const startUpdateLocation: {
|
|
|
966
967
|
openPermissionDialog(): Promise<"denied" | "allowed">;
|
|
967
968
|
};
|
|
968
969
|
|
|
969
|
-
|
|
970
|
+
declare const loadFullScreenAd: ((args: {
|
|
971
|
+
onEvent: (data: LoadFullScreenAdEvent) => void;
|
|
972
|
+
onError: (error: Error) => void;
|
|
973
|
+
options?: LoadFullScreenAdOptions | undefined;
|
|
974
|
+
}) => () => void) & {
|
|
975
|
+
isSupported: () => boolean;
|
|
976
|
+
};
|
|
977
|
+
declare const showFullScreenAd: ((args: {
|
|
978
|
+
onEvent: (data: ShowFullScreenAdEvent) => void;
|
|
979
|
+
onError: (error: Error) => void;
|
|
980
|
+
options?: ShowFullScreenAdOptions | undefined;
|
|
981
|
+
}) => () => void) & {
|
|
982
|
+
isSupported: () => boolean;
|
|
983
|
+
};
|
|
984
|
+
|
|
985
|
+
type Environment = 'alpha' | 'live';
|
|
986
|
+
type DeviceOS = 'IOS' | 'ANDROID';
|
|
987
|
+
type DeviceAttStatus = 'NOT_DETERMINED' | 'RESTRICTED' | 'DENIED' | 'AUTHORIZED';
|
|
988
|
+
type DeviceCarrier = 'SKT' | 'KT' | 'LGU' | 'SKT_MVNO' | 'KT_MVNO' | 'LG_MVNO';
|
|
989
|
+
type RequestHeaders = Record<string, string>;
|
|
990
|
+
interface DeviceInfo {
|
|
991
|
+
os?: DeviceOS;
|
|
992
|
+
osVersion?: string;
|
|
993
|
+
ua?: string;
|
|
994
|
+
ifa?: string;
|
|
995
|
+
ifv?: string | null;
|
|
996
|
+
attStatus?: DeviceAttStatus | null;
|
|
997
|
+
model?: string;
|
|
998
|
+
carrier?: DeviceCarrier;
|
|
999
|
+
}
|
|
1000
|
+
interface SafeAreaInsets {
|
|
1001
|
+
top: string;
|
|
1002
|
+
bottom: string;
|
|
1003
|
+
left: string;
|
|
1004
|
+
right: string;
|
|
1005
|
+
}
|
|
1006
|
+
interface RuntimeInfo {
|
|
1007
|
+
safeAreaInsets?: SafeAreaInsets;
|
|
1008
|
+
}
|
|
1009
|
+
type AdOpener = (url: string, target?: string, features?: string) => void;
|
|
1010
|
+
interface AdConfig {
|
|
1011
|
+
environment: Environment;
|
|
1012
|
+
apiEndpoint?: string;
|
|
1013
|
+
deviceInfo?: DeviceInfo;
|
|
1014
|
+
requestHeaders?: RequestHeaders;
|
|
1015
|
+
runtimeInfo?: RuntimeInfo;
|
|
1016
|
+
opener?: AdOpener;
|
|
1017
|
+
customAdFetcher?: CustomAdFetcher;
|
|
1018
|
+
}
|
|
1019
|
+
interface AdRequest {
|
|
1020
|
+
spaceUnitId: string;
|
|
1021
|
+
options?: {
|
|
1022
|
+
dummyAdFormat?: string;
|
|
1023
|
+
maxSize?: number;
|
|
1024
|
+
video?: {
|
|
1025
|
+
maxDurationMs?: number;
|
|
1026
|
+
};
|
|
1027
|
+
};
|
|
1028
|
+
}
|
|
1029
|
+
type AdResponseStatus = 'OK' | 'NO_AD' | 'BLOCKED' | 'ERROR' | 'TIMEOUT' | 'INVALID_SPACE' | 'INVALID_REQUEST' | 'LIMITED_AD' | 'CONSENT_REQUIRED' | 'TEST_MODE';
|
|
1030
|
+
interface AdResponse {
|
|
1031
|
+
requestId?: string;
|
|
1032
|
+
status?: AdResponseStatus;
|
|
1033
|
+
ads: Ad[];
|
|
1034
|
+
ext?: AdResponseExt;
|
|
1035
|
+
}
|
|
1036
|
+
interface Ad {
|
|
1037
|
+
styleId: string;
|
|
1038
|
+
creative: Record<string, any>;
|
|
1039
|
+
eventTrackingUrls?: string[];
|
|
1040
|
+
eventTypes?: string[];
|
|
1041
|
+
eventPayload?: string;
|
|
1042
|
+
requestId?: string;
|
|
1043
|
+
}
|
|
1044
|
+
interface AdResponseExt {
|
|
1045
|
+
skippableOffsetSeconds?: number;
|
|
1046
|
+
reward?: {
|
|
1047
|
+
type: string;
|
|
1048
|
+
amount: number;
|
|
1049
|
+
};
|
|
1050
|
+
isAdBadgeEnabled?: boolean;
|
|
1051
|
+
refetchSeconds?: number | null;
|
|
1052
|
+
}
|
|
1053
|
+
interface ApiResponse<T> {
|
|
1054
|
+
resultType: 'SUCCESS' | 'HTTP_TIMEOUT' | 'NETWORK_ERROR' | 'EXECUTION_FAIL' | 'INTERRUPTED' | 'INTERNAL_ERROR' | 'FAIL';
|
|
1055
|
+
success?: T;
|
|
1056
|
+
error?: {
|
|
1057
|
+
errorType?: number;
|
|
1058
|
+
errorCode?: string;
|
|
1059
|
+
reason?: string;
|
|
1060
|
+
data?: Record<string, any>;
|
|
1061
|
+
title?: string;
|
|
1062
|
+
};
|
|
1063
|
+
}
|
|
1064
|
+
type CustomAdFetcher = (endpoint: string, request: AdRequest, headers?: RequestHeaders) => Promise<ApiResponse<AdResponse>>;
|
|
1065
|
+
interface InitializeOptions {
|
|
1066
|
+
callbacks?: {
|
|
1067
|
+
onInitialized?: () => void;
|
|
1068
|
+
onInitializationFailed?: (error: Error) => void;
|
|
1069
|
+
};
|
|
1070
|
+
}
|
|
1071
|
+
interface BannerSlotEventPayload {
|
|
1072
|
+
slotId: string;
|
|
1073
|
+
adGroupId: string;
|
|
1074
|
+
adMetadata: {
|
|
1075
|
+
creativeId: string;
|
|
1076
|
+
requestId: string;
|
|
1077
|
+
};
|
|
1078
|
+
}
|
|
1079
|
+
interface BannerSlotErrorPayload {
|
|
1080
|
+
slotId: string;
|
|
1081
|
+
adGroupId: string;
|
|
1082
|
+
adMetadata: Record<string, never>;
|
|
1083
|
+
error: {
|
|
1084
|
+
code: number;
|
|
1085
|
+
message: string;
|
|
1086
|
+
domain?: string;
|
|
1087
|
+
};
|
|
1088
|
+
}
|
|
1089
|
+
interface BannerSlotCallbacks {
|
|
1090
|
+
onAdRendered?: (payload: BannerSlotEventPayload) => void;
|
|
1091
|
+
onAdViewable?: (payload: BannerSlotEventPayload) => void;
|
|
1092
|
+
onAdClicked?: (payload: BannerSlotEventPayload) => void;
|
|
1093
|
+
onAdImpression?: (payload: BannerSlotEventPayload) => void;
|
|
1094
|
+
onAdFailedToRender?: (payload: BannerSlotErrorPayload) => void;
|
|
1095
|
+
onNoFill?: (payload: {
|
|
1096
|
+
slotId: string;
|
|
1097
|
+
adGroupId: string;
|
|
1098
|
+
adMetadata: Record<string, never>;
|
|
1099
|
+
}) => void;
|
|
1100
|
+
}
|
|
1101
|
+
interface BannerSlotOptions {
|
|
1102
|
+
spaceId: string;
|
|
1103
|
+
autoLoad?: boolean;
|
|
1104
|
+
dummyAdFormat?: string;
|
|
1105
|
+
maxVideoDurationMs?: number;
|
|
1106
|
+
refetchIntervalMs?: number;
|
|
1107
|
+
theme?: 'light' | 'dark';
|
|
1108
|
+
padding?: string;
|
|
1109
|
+
callbacks?: BannerSlotCallbacks;
|
|
1110
|
+
}
|
|
1111
|
+
interface BannerSlot {
|
|
1112
|
+
load(): void | Promise<void>;
|
|
1113
|
+
destroy(): void;
|
|
1114
|
+
}
|
|
1115
|
+
interface BannerNamespace {
|
|
1116
|
+
createSlot(target: string | HTMLElement, options: BannerSlotOptions): BannerSlot;
|
|
1117
|
+
destroy(slotId: string): void;
|
|
1118
|
+
destroyAll(): void;
|
|
1119
|
+
}
|
|
1120
|
+
interface AdsSdkGlobal {
|
|
1121
|
+
init(config: AdConfig): void;
|
|
1122
|
+
banner: BannerNamespace;
|
|
1123
|
+
isInitialized(): boolean;
|
|
1124
|
+
}
|
|
1125
|
+
declare global {
|
|
1126
|
+
interface Window {
|
|
1127
|
+
TossAdsSpaceKit?: AdsSdkGlobal;
|
|
1128
|
+
}
|
|
1129
|
+
}
|
|
1130
|
+
interface AttachOptions {
|
|
1131
|
+
theme?: 'light' | 'dark';
|
|
1132
|
+
padding?: string;
|
|
1133
|
+
callbacks?: BannerSlotCallbacks;
|
|
1134
|
+
}
|
|
1135
|
+
|
|
1136
|
+
declare function initialize(options: InitializeOptions): void;
|
|
1137
|
+
declare function attach(adGroupId: string, target: string | HTMLElement, options?: AttachOptions): void;
|
|
1138
|
+
declare function destroy(slotId: string): void;
|
|
1139
|
+
declare function destroyAll(): void;
|
|
1140
|
+
declare const TossAds: {
|
|
1141
|
+
initialize: typeof initialize & {
|
|
1142
|
+
isSupported: () => boolean;
|
|
1143
|
+
};
|
|
1144
|
+
attach: typeof attach & {
|
|
1145
|
+
isSupported: () => boolean;
|
|
1146
|
+
};
|
|
1147
|
+
destroy: typeof destroy & {
|
|
1148
|
+
isSupported: () => boolean;
|
|
1149
|
+
};
|
|
1150
|
+
destroyAll: typeof destroyAll & {
|
|
1151
|
+
isSupported: () => boolean;
|
|
1152
|
+
};
|
|
1153
|
+
};
|
|
1154
|
+
|
|
1155
|
+
export { type AddAccessoryButtonOptions, type AppsInTossEvent, type AppsInTossGlobals, type CompletedOrRefundedOrdersResult, GoogleAdMob, type GraniteEvent, IAP, type IapCreateOneTimePurchaseOrderOptions, type IapProductListItem, SafeAreaInsets$1 as SafeAreaInsets, Storage, type TdsEvent, TossAds, type AttachOptions as TossAdsAttachOptions, type BannerSlotCallbacks as TossAdsBannerSlotCallbacks, type BannerSlotErrorPayload as TossAdsBannerSlotErrorPayload, type BannerSlotEventPayload as TossAdsBannerSlotEventPayload, type InitializeOptions as TossAdsInitializeOptions, appsInTossEvent, env, fetchAlbumPhotos, fetchContacts, getAppsInTossGlobals, getClipboardText, getCurrentLocation, getSafeAreaInsets, graniteEvent, isMinVersionSupported, loadFullScreenAd, openCamera, partner, setClipboardText, showFullScreenAd, startUpdateLocation, tdsEvent };
|
package/built/index.js
CHANGED
|
@@ -262,7 +262,7 @@ var IAP = {
|
|
|
262
262
|
* @category 인앱결제
|
|
263
263
|
* @name getPendingOrders
|
|
264
264
|
* @description 대기 중인 주문 목록을 가져와요. 이 함수를 사용하면 결제가 아직 완료되지 않은 주문 정보를 확인할 수 있어요.
|
|
265
|
-
* @returns {Promise<{ orders: { orderId: string; sku: string; }[]}}>} 대기 중인 주문의 배열을 반환해요. 앱 버전이 최소 지원 버전(안드로이드 5.234.0, iOS 5.231.0)보다 낮으면 `undefined`를 반환해요.
|
|
265
|
+
* @returns {Promise<{ orders: { orderId: string; sku: string; paymentCompletedDate: string; }[]}}>} 대기 중인 주문의 배열을 반환해요. 앱 버전이 최소 지원 버전(안드로이드 5.234.0, iOS 5.231.0)보다 낮으면 `undefined`를 반환해요.
|
|
266
266
|
*
|
|
267
267
|
* @example
|
|
268
268
|
* ### 대기 중인 주문 목록 가져오기
|
|
@@ -279,7 +279,9 @@ var IAP = {
|
|
|
279
279
|
* }
|
|
280
280
|
* ```
|
|
281
281
|
*/
|
|
282
|
-
getPendingOrders: createAsyncBridge2(
|
|
282
|
+
getPendingOrders: createAsyncBridge2(
|
|
283
|
+
"getPendingOrders"
|
|
284
|
+
),
|
|
283
285
|
/**
|
|
284
286
|
* @public
|
|
285
287
|
* @category 인앱결제
|
|
@@ -1020,6 +1022,283 @@ var startUpdateLocation = (params) => {
|
|
|
1020
1022
|
startUpdateLocation.getPermission = () => getPermission2({ name: "geolocation", access: "access" });
|
|
1021
1023
|
startUpdateLocation.openPermissionDialog = () => openPermissionDialog2({ name: "geolocation", access: "access" });
|
|
1022
1024
|
|
|
1025
|
+
// src/integratedAd.ts
|
|
1026
|
+
import { createConstantBridge as createConstantBridge6, createEventBridge as createEventBridge8 } from "@apps-in-toss/bridge-core";
|
|
1027
|
+
var loadFullScreenAd = Object.assign(createEventBridge8("loadFullScreenAd"), {
|
|
1028
|
+
isSupported: createConstantBridge6("loadFullScreenAd_isSupported")
|
|
1029
|
+
});
|
|
1030
|
+
var showFullScreenAd = Object.assign(createEventBridge8("showFullScreenAd"), {
|
|
1031
|
+
isSupported: createConstantBridge6("showFullScreenAd_isSupported")
|
|
1032
|
+
});
|
|
1033
|
+
|
|
1034
|
+
// src/toss-ad/index.ts
|
|
1035
|
+
import { createAsyncBridge as createAsyncBridge13, createConstantBridge as createConstantBridge7, createEventBridge as createEventBridge9 } from "@apps-in-toss/bridge-core";
|
|
1036
|
+
|
|
1037
|
+
// src/toss-ad/opener.ts
|
|
1038
|
+
import { createAsyncBridge as createAsyncBridge12 } from "@apps-in-toss/bridge-core";
|
|
1039
|
+
var openURL = createAsyncBridge12("openURL");
|
|
1040
|
+
function openUrlOpener(url) {
|
|
1041
|
+
const transformed = getWebSchemeOrUri(url);
|
|
1042
|
+
return openURL(transformed);
|
|
1043
|
+
}
|
|
1044
|
+
function getWebSchemeOrUri(uri) {
|
|
1045
|
+
const isHttp = ["http://", "https://"].some((protocol) => uri.startsWith(protocol));
|
|
1046
|
+
return isHttp ? supertossWeb(uri) : uri;
|
|
1047
|
+
}
|
|
1048
|
+
function supertossWeb(uri) {
|
|
1049
|
+
return `supertoss://web?url=${encodeURIComponent(uri)}&external=true`;
|
|
1050
|
+
}
|
|
1051
|
+
|
|
1052
|
+
// src/toss-ad/scriptLoader.ts
|
|
1053
|
+
var DEFAULT_SDK_URL = "https://static.toss.im/ads/sdk/toss-ads-space-kit-1.0.0.js";
|
|
1054
|
+
var DEFAULT_TIMEOUT_MS = 15e3;
|
|
1055
|
+
var pendingLoad = null;
|
|
1056
|
+
function getAdsSdk() {
|
|
1057
|
+
if (typeof window === "undefined") {
|
|
1058
|
+
return void 0;
|
|
1059
|
+
}
|
|
1060
|
+
return window.TossAdsSpaceKit;
|
|
1061
|
+
}
|
|
1062
|
+
function loadAdsSdk() {
|
|
1063
|
+
if (typeof window === "undefined" || typeof document === "undefined") {
|
|
1064
|
+
return Promise.reject(new Error("Ads SDK can only be loaded in a browser environment."));
|
|
1065
|
+
}
|
|
1066
|
+
const existing = getAdsSdk();
|
|
1067
|
+
if (existing) {
|
|
1068
|
+
return Promise.resolve(existing);
|
|
1069
|
+
}
|
|
1070
|
+
if (pendingLoad) {
|
|
1071
|
+
return pendingLoad;
|
|
1072
|
+
}
|
|
1073
|
+
const promise = new Promise((resolve, reject) => {
|
|
1074
|
+
const script = document.createElement("script");
|
|
1075
|
+
const cleanup = () => {
|
|
1076
|
+
script.removeEventListener("load", handleLoad);
|
|
1077
|
+
script.removeEventListener("error", handleError);
|
|
1078
|
+
window.clearTimeout(timeoutId);
|
|
1079
|
+
pendingLoad = null;
|
|
1080
|
+
};
|
|
1081
|
+
const handleLoad = () => {
|
|
1082
|
+
const sdk = getAdsSdk();
|
|
1083
|
+
if (sdk) {
|
|
1084
|
+
cleanup();
|
|
1085
|
+
resolve(sdk);
|
|
1086
|
+
return;
|
|
1087
|
+
}
|
|
1088
|
+
cleanup();
|
|
1089
|
+
reject(new Error("Ads SDK script loaded but window.TossAdsSpaceKit was not exposed."));
|
|
1090
|
+
};
|
|
1091
|
+
const handleError = () => {
|
|
1092
|
+
cleanup();
|
|
1093
|
+
reject(new Error(`Failed to load Ads SDK script from ${DEFAULT_SDK_URL}.`));
|
|
1094
|
+
};
|
|
1095
|
+
const timeoutId = window.setTimeout(() => {
|
|
1096
|
+
cleanup();
|
|
1097
|
+
reject(new Error(`Loading Ads SDK timed out after ${DEFAULT_TIMEOUT_MS}ms.`));
|
|
1098
|
+
}, DEFAULT_TIMEOUT_MS);
|
|
1099
|
+
script.addEventListener("load", handleLoad);
|
|
1100
|
+
script.addEventListener("error", handleError);
|
|
1101
|
+
script.async = true;
|
|
1102
|
+
script.src = DEFAULT_SDK_URL;
|
|
1103
|
+
document.head.appendChild(script);
|
|
1104
|
+
});
|
|
1105
|
+
pendingLoad = promise;
|
|
1106
|
+
return promise;
|
|
1107
|
+
}
|
|
1108
|
+
|
|
1109
|
+
// src/toss-ad/index.ts
|
|
1110
|
+
var fetchTossAd = Object.assign(createEventBridge9("fetchTossAd"), {
|
|
1111
|
+
isSupported: createConstantBridge7("fetchTossAd_isSupported")
|
|
1112
|
+
});
|
|
1113
|
+
var tossAdEventLog = createAsyncBridge13("tossAdEventLog");
|
|
1114
|
+
var SUPPORTED_STYLE_IDS = /* @__PURE__ */ new Set(["1", "2"]);
|
|
1115
|
+
function fetchTossAdPromise(options) {
|
|
1116
|
+
return new Promise((resolve, reject) => {
|
|
1117
|
+
if (!fetchTossAd.isSupported()) {
|
|
1118
|
+
reject(new Error("fetchTossAd is not supported in this environment."));
|
|
1119
|
+
return;
|
|
1120
|
+
}
|
|
1121
|
+
return fetchTossAd({
|
|
1122
|
+
options,
|
|
1123
|
+
onEvent: resolve,
|
|
1124
|
+
onError: reject
|
|
1125
|
+
});
|
|
1126
|
+
});
|
|
1127
|
+
}
|
|
1128
|
+
function normalizeAdResponse(adResponse) {
|
|
1129
|
+
const ads = Array.isArray(adResponse.ads) ? adResponse.ads.filter((ad) => SUPPORTED_STYLE_IDS.has(String(ad.styleId))) : [];
|
|
1130
|
+
return {
|
|
1131
|
+
requestId: adResponse.requestId ?? "",
|
|
1132
|
+
status: adResponse.status ?? "OK",
|
|
1133
|
+
ads,
|
|
1134
|
+
ext: adResponse.ext
|
|
1135
|
+
};
|
|
1136
|
+
}
|
|
1137
|
+
function normalizeApiResponse(raw) {
|
|
1138
|
+
if (isApiResponse(raw)) {
|
|
1139
|
+
if (raw.resultType !== "SUCCESS") {
|
|
1140
|
+
return raw;
|
|
1141
|
+
}
|
|
1142
|
+
if (!raw.success) {
|
|
1143
|
+
return {
|
|
1144
|
+
resultType: "FAIL",
|
|
1145
|
+
error: { reason: "fetchTossAd returned SUCCESS without payload" }
|
|
1146
|
+
};
|
|
1147
|
+
}
|
|
1148
|
+
return { ...raw, success: normalizeAdResponse(raw.success) };
|
|
1149
|
+
}
|
|
1150
|
+
if (isAdResponse(raw)) {
|
|
1151
|
+
return {
|
|
1152
|
+
resultType: "SUCCESS",
|
|
1153
|
+
success: normalizeAdResponse(raw)
|
|
1154
|
+
};
|
|
1155
|
+
}
|
|
1156
|
+
return { resultType: "FAIL", error: { reason: "Invalid response from fetchTossAd" } };
|
|
1157
|
+
}
|
|
1158
|
+
function isApiResponse(payload) {
|
|
1159
|
+
return Boolean(payload && typeof payload === "object" && "resultType" in payload);
|
|
1160
|
+
}
|
|
1161
|
+
function isAdResponse(payload) {
|
|
1162
|
+
return Boolean(payload && typeof payload === "object" && "ads" in payload);
|
|
1163
|
+
}
|
|
1164
|
+
function createCustomAdFetcher() {
|
|
1165
|
+
return async (_endpoint, request) => {
|
|
1166
|
+
try {
|
|
1167
|
+
const raw = await fetchTossAdPromise({ adGroupId: request.spaceUnitId });
|
|
1168
|
+
return normalizeApiResponse(raw);
|
|
1169
|
+
} catch (error) {
|
|
1170
|
+
return {
|
|
1171
|
+
resultType: "FAIL",
|
|
1172
|
+
error: {
|
|
1173
|
+
reason: error instanceof Error ? error.message : "Unknown fetchTossAd error"
|
|
1174
|
+
}
|
|
1175
|
+
};
|
|
1176
|
+
}
|
|
1177
|
+
};
|
|
1178
|
+
}
|
|
1179
|
+
var pendingLoad2 = null;
|
|
1180
|
+
function initialize(options) {
|
|
1181
|
+
const { callbacks } = options;
|
|
1182
|
+
if (window.TossAdsSpaceKit != null && window.TossAdsSpaceKit.isInitialized()) {
|
|
1183
|
+
callbacks?.onInitializationFailed?.(new Error("[toss-ad] Already initialized."));
|
|
1184
|
+
return;
|
|
1185
|
+
}
|
|
1186
|
+
if (pendingLoad2 != null) {
|
|
1187
|
+
callbacks?.onInitializationFailed?.(new Error("[toss-ad] initialization already in progress."));
|
|
1188
|
+
}
|
|
1189
|
+
const resolveInitialized = () => callbacks?.onInitialized?.();
|
|
1190
|
+
const rejectInitialized = (error) => {
|
|
1191
|
+
const normalizedError = error instanceof Error ? error : new Error(String(error));
|
|
1192
|
+
callbacks?.onInitializationFailed?.(normalizedError);
|
|
1193
|
+
};
|
|
1194
|
+
pendingLoad2 = loadAdsSdk().then((sdk) => {
|
|
1195
|
+
const customAdFetcher = createCustomAdFetcher();
|
|
1196
|
+
const config = { environment: "live", customAdFetcher, opener: openUrlOpener };
|
|
1197
|
+
sdk.init(config);
|
|
1198
|
+
resolveInitialized();
|
|
1199
|
+
}).catch((error) => {
|
|
1200
|
+
pendingLoad2 = null;
|
|
1201
|
+
rejectInitialized(error);
|
|
1202
|
+
});
|
|
1203
|
+
}
|
|
1204
|
+
function attach(adGroupId, target, options = {}) {
|
|
1205
|
+
const { callbacks } = options;
|
|
1206
|
+
const rejectAttached = (error) => {
|
|
1207
|
+
const normalizedError = error instanceof Error ? error : new Error(String(error));
|
|
1208
|
+
callbacks?.onAdFailedToRender?.({
|
|
1209
|
+
slotId: "",
|
|
1210
|
+
adGroupId,
|
|
1211
|
+
adMetadata: {},
|
|
1212
|
+
error: { code: 0, message: normalizedError.message }
|
|
1213
|
+
});
|
|
1214
|
+
};
|
|
1215
|
+
try {
|
|
1216
|
+
const spaceId = adGroupId;
|
|
1217
|
+
const sdk = getAdsSdk();
|
|
1218
|
+
if (!sdk) {
|
|
1219
|
+
throw new Error("[toss-ad] Call initialize() before attaching an ad.");
|
|
1220
|
+
}
|
|
1221
|
+
if (!sdk.banner) {
|
|
1222
|
+
throw new Error("[toss-ad] Loaded TossAdsSpaceKit does not support banner ads.");
|
|
1223
|
+
}
|
|
1224
|
+
const element = typeof target === "string" ? document.querySelector(target) : target;
|
|
1225
|
+
if (!element) {
|
|
1226
|
+
throw new Error(`[toss-ad] Failed to find target element: ${target}`);
|
|
1227
|
+
}
|
|
1228
|
+
const slotOptions = {
|
|
1229
|
+
spaceId,
|
|
1230
|
+
autoLoad: true,
|
|
1231
|
+
theme: options.theme,
|
|
1232
|
+
padding: options.padding,
|
|
1233
|
+
callbacks: wrapCallbacks(adGroupId, options.callbacks)
|
|
1234
|
+
};
|
|
1235
|
+
sdk.banner.createSlot(element, slotOptions);
|
|
1236
|
+
} catch (error) {
|
|
1237
|
+
rejectAttached(error);
|
|
1238
|
+
}
|
|
1239
|
+
}
|
|
1240
|
+
function destroy(slotId) {
|
|
1241
|
+
const sdk = getAdsSdk();
|
|
1242
|
+
if (!sdk?.banner) {
|
|
1243
|
+
return;
|
|
1244
|
+
}
|
|
1245
|
+
sdk.banner.destroy(slotId);
|
|
1246
|
+
}
|
|
1247
|
+
function destroyAll() {
|
|
1248
|
+
const sdk = getAdsSdk();
|
|
1249
|
+
if (!sdk?.banner) {
|
|
1250
|
+
return;
|
|
1251
|
+
}
|
|
1252
|
+
sdk.banner.destroyAll();
|
|
1253
|
+
}
|
|
1254
|
+
function wrapCallbacks(adGroupId, callbacks) {
|
|
1255
|
+
if (!callbacks) {
|
|
1256
|
+
return void 0;
|
|
1257
|
+
}
|
|
1258
|
+
const mapEvent = (payload) => {
|
|
1259
|
+
const next = { ...payload ?? {} };
|
|
1260
|
+
next.adGroupId = next.adGroupId ?? next.spaceId ?? adGroupId;
|
|
1261
|
+
delete next.spaceId;
|
|
1262
|
+
return next;
|
|
1263
|
+
};
|
|
1264
|
+
return {
|
|
1265
|
+
onAdRendered: (payload) => callbacks.onAdRendered?.(mapEvent(payload)),
|
|
1266
|
+
onAdViewable: (payload) => callbacks.onAdViewable?.(mapEvent(payload)),
|
|
1267
|
+
onAdClicked: (payload) => callbacks.onAdClicked?.(mapEvent(payload)),
|
|
1268
|
+
onAdImpression: (payload) => {
|
|
1269
|
+
tossAdEventLog({
|
|
1270
|
+
log_name: "display_ads_all::impression__1px_banner",
|
|
1271
|
+
log_type: "event",
|
|
1272
|
+
params: {
|
|
1273
|
+
event_type: "impression",
|
|
1274
|
+
schema_id: 1812034,
|
|
1275
|
+
request_id: payload?.adMetadata?.requestId ?? ""
|
|
1276
|
+
}
|
|
1277
|
+
});
|
|
1278
|
+
callbacks.onAdImpression?.(mapEvent(payload));
|
|
1279
|
+
},
|
|
1280
|
+
onAdFailedToRender: (payload) => callbacks.onAdFailedToRender?.({
|
|
1281
|
+
...mapEvent(payload),
|
|
1282
|
+
error: payload?.error ?? { code: 0, message: "UNKNOWN" }
|
|
1283
|
+
}),
|
|
1284
|
+
onNoFill: (payload) => callbacks.onNoFill?.(mapEvent(payload))
|
|
1285
|
+
};
|
|
1286
|
+
}
|
|
1287
|
+
var TossAds = {
|
|
1288
|
+
initialize: Object.assign(initialize, {
|
|
1289
|
+
isSupported: fetchTossAd.isSupported
|
|
1290
|
+
}),
|
|
1291
|
+
attach: Object.assign(attach, {
|
|
1292
|
+
isSupported: fetchTossAd.isSupported
|
|
1293
|
+
}),
|
|
1294
|
+
destroy: Object.assign(destroy, {
|
|
1295
|
+
isSupported: fetchTossAd.isSupported
|
|
1296
|
+
}),
|
|
1297
|
+
destroyAll: Object.assign(destroyAll, {
|
|
1298
|
+
isSupported: fetchTossAd.isSupported
|
|
1299
|
+
})
|
|
1300
|
+
};
|
|
1301
|
+
|
|
1023
1302
|
// src/index.ts
|
|
1024
1303
|
export * from "@apps-in-toss/types";
|
|
1025
1304
|
export {
|
|
@@ -1027,6 +1306,7 @@ export {
|
|
|
1027
1306
|
IAP,
|
|
1028
1307
|
SafeAreaInsets,
|
|
1029
1308
|
Storage,
|
|
1309
|
+
TossAds,
|
|
1030
1310
|
appsInTossEvent,
|
|
1031
1311
|
env,
|
|
1032
1312
|
fetchAlbumPhotos,
|
|
@@ -1037,9 +1317,11 @@ export {
|
|
|
1037
1317
|
getSafeAreaInsets,
|
|
1038
1318
|
graniteEvent,
|
|
1039
1319
|
isMinVersionSupported,
|
|
1320
|
+
loadFullScreenAd,
|
|
1040
1321
|
openCamera,
|
|
1041
1322
|
partner,
|
|
1042
1323
|
setClipboardText,
|
|
1324
|
+
showFullScreenAd,
|
|
1043
1325
|
startUpdateLocation,
|
|
1044
1326
|
tdsEvent
|
|
1045
1327
|
};
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@apps-in-toss/web-bridge",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.0.0-dev.
|
|
4
|
+
"version": "0.0.0-dev.1764816865438",
|
|
5
5
|
"description": "Web Bridge for Apps In Toss",
|
|
6
6
|
"scripts": {
|
|
7
7
|
"prepack": "yarn build",
|
|
@@ -28,11 +28,11 @@
|
|
|
28
28
|
"built"
|
|
29
29
|
],
|
|
30
30
|
"dependencies": {
|
|
31
|
-
"@apps-in-toss/types": "0.0.0-dev.
|
|
31
|
+
"@apps-in-toss/types": "0.0.0-dev.1764816865438"
|
|
32
32
|
},
|
|
33
33
|
"devDependencies": {
|
|
34
|
-
"@apps-in-toss/bridge-core": "0.0.0-dev.
|
|
35
|
-
"@apps-in-toss/framework": "0.0.0-dev.
|
|
34
|
+
"@apps-in-toss/bridge-core": "0.0.0-dev.1764816865438",
|
|
35
|
+
"@apps-in-toss/framework": "0.0.0-dev.1764816865438",
|
|
36
36
|
"@swc/core": "^1.12.7",
|
|
37
37
|
"picocolors": "^1.1.1",
|
|
38
38
|
"ts-morph": "^26.0.0",
|
|
@@ -46,5 +46,5 @@
|
|
|
46
46
|
"publishConfig": {
|
|
47
47
|
"access": "public"
|
|
48
48
|
},
|
|
49
|
-
"gitHead": "
|
|
49
|
+
"gitHead": "d72f564708d831e445bf0ae4e1b9f8cce536dc16"
|
|
50
50
|
}
|