@apps-in-toss/web-bridge 1.5.3 → 1.6.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/built/index.cjs +287 -0
- package/built/index.d.cts +190 -5
- package/built/index.d.ts +190 -5
- package/built/index.js +284 -0
- package/package.json +5 -5
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
|
});
|
|
@@ -1060,6 +1063,287 @@ var startUpdateLocation = (params) => {
|
|
|
1060
1063
|
startUpdateLocation.getPermission = () => getPermission2({ name: "geolocation", access: "access" });
|
|
1061
1064
|
startUpdateLocation.openPermissionDialog = () => openPermissionDialog2({ name: "geolocation", access: "access" });
|
|
1062
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.3.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({
|
|
1209
|
+
adGroupId: request.spaceUnitId,
|
|
1210
|
+
sdkId: "108",
|
|
1211
|
+
availableStyleIds: ["1", "2"]
|
|
1212
|
+
});
|
|
1213
|
+
return normalizeApiResponse(raw);
|
|
1214
|
+
} catch (error) {
|
|
1215
|
+
return {
|
|
1216
|
+
resultType: "FAIL",
|
|
1217
|
+
error: {
|
|
1218
|
+
reason: error instanceof Error ? error.message : "Unknown fetchTossAd error"
|
|
1219
|
+
}
|
|
1220
|
+
};
|
|
1221
|
+
}
|
|
1222
|
+
};
|
|
1223
|
+
}
|
|
1224
|
+
var pendingLoad2 = null;
|
|
1225
|
+
function initialize(options) {
|
|
1226
|
+
const { callbacks } = options;
|
|
1227
|
+
if (window.TossAdsSpaceKit != null && window.TossAdsSpaceKit.isInitialized()) {
|
|
1228
|
+
callbacks?.onInitializationFailed?.(new Error("[toss-ad] Already initialized."));
|
|
1229
|
+
return;
|
|
1230
|
+
}
|
|
1231
|
+
if (pendingLoad2 != null) {
|
|
1232
|
+
callbacks?.onInitializationFailed?.(new Error("[toss-ad] initialization already in progress."));
|
|
1233
|
+
}
|
|
1234
|
+
const resolveInitialized = () => callbacks?.onInitialized?.();
|
|
1235
|
+
const rejectInitialized = (error) => {
|
|
1236
|
+
const normalizedError = error instanceof Error ? error : new Error(String(error));
|
|
1237
|
+
callbacks?.onInitializationFailed?.(normalizedError);
|
|
1238
|
+
};
|
|
1239
|
+
pendingLoad2 = loadAdsSdk().then((sdk) => {
|
|
1240
|
+
const customAdFetcher = createCustomAdFetcher();
|
|
1241
|
+
const config = { environment: "live", customAdFetcher, opener: openUrlOpener };
|
|
1242
|
+
sdk.init(config);
|
|
1243
|
+
resolveInitialized();
|
|
1244
|
+
}).catch((error) => {
|
|
1245
|
+
pendingLoad2 = null;
|
|
1246
|
+
rejectInitialized(error);
|
|
1247
|
+
});
|
|
1248
|
+
}
|
|
1249
|
+
function attach(adGroupId, target, options = {}) {
|
|
1250
|
+
const { callbacks } = options;
|
|
1251
|
+
const rejectAttached = (error) => {
|
|
1252
|
+
const normalizedError = error instanceof Error ? error : new Error(String(error));
|
|
1253
|
+
callbacks?.onAdFailedToRender?.({
|
|
1254
|
+
slotId: "",
|
|
1255
|
+
adGroupId,
|
|
1256
|
+
adMetadata: {},
|
|
1257
|
+
error: { code: 0, message: normalizedError.message }
|
|
1258
|
+
});
|
|
1259
|
+
};
|
|
1260
|
+
try {
|
|
1261
|
+
const spaceId = adGroupId;
|
|
1262
|
+
const sdk = getAdsSdk();
|
|
1263
|
+
if (!sdk) {
|
|
1264
|
+
throw new Error("[toss-ad] Call initialize() before attaching an ad.");
|
|
1265
|
+
}
|
|
1266
|
+
if (!sdk.banner) {
|
|
1267
|
+
throw new Error("[toss-ad] Loaded TossAdsSpaceKit does not support banner ads.");
|
|
1268
|
+
}
|
|
1269
|
+
const element = typeof target === "string" ? document.querySelector(target) : target;
|
|
1270
|
+
if (!element) {
|
|
1271
|
+
throw new Error(`[toss-ad] Failed to find target element: ${target}`);
|
|
1272
|
+
}
|
|
1273
|
+
const slotOptions = {
|
|
1274
|
+
spaceId,
|
|
1275
|
+
autoLoad: true,
|
|
1276
|
+
theme: options.theme,
|
|
1277
|
+
padding: options.padding,
|
|
1278
|
+
callbacks: wrapCallbacks(adGroupId, options.callbacks)
|
|
1279
|
+
};
|
|
1280
|
+
sdk.banner.createSlot(element, slotOptions);
|
|
1281
|
+
} catch (error) {
|
|
1282
|
+
rejectAttached(error);
|
|
1283
|
+
}
|
|
1284
|
+
}
|
|
1285
|
+
function destroy(slotId) {
|
|
1286
|
+
const sdk = getAdsSdk();
|
|
1287
|
+
if (!sdk?.banner) {
|
|
1288
|
+
return;
|
|
1289
|
+
}
|
|
1290
|
+
sdk.banner.destroy(slotId);
|
|
1291
|
+
}
|
|
1292
|
+
function destroyAll() {
|
|
1293
|
+
const sdk = getAdsSdk();
|
|
1294
|
+
if (!sdk?.banner) {
|
|
1295
|
+
return;
|
|
1296
|
+
}
|
|
1297
|
+
sdk.banner.destroyAll();
|
|
1298
|
+
}
|
|
1299
|
+
function wrapCallbacks(adGroupId, callbacks) {
|
|
1300
|
+
if (!callbacks) {
|
|
1301
|
+
return void 0;
|
|
1302
|
+
}
|
|
1303
|
+
const mapEvent = (payload) => {
|
|
1304
|
+
const next = { ...payload ?? {} };
|
|
1305
|
+
next.adGroupId = next.adGroupId ?? next.spaceId ?? adGroupId;
|
|
1306
|
+
delete next.spaceId;
|
|
1307
|
+
return next;
|
|
1308
|
+
};
|
|
1309
|
+
return {
|
|
1310
|
+
onAdRendered: (payload) => callbacks.onAdRendered?.(mapEvent(payload)),
|
|
1311
|
+
onAdViewable: (payload) => callbacks.onAdViewable?.(mapEvent(payload)),
|
|
1312
|
+
onAdClicked: (payload) => callbacks.onAdClicked?.(mapEvent(payload)),
|
|
1313
|
+
onAdImpression: (payload) => {
|
|
1314
|
+
tossAdEventLog({
|
|
1315
|
+
log_name: "display_ads_all::impression__1px_banner",
|
|
1316
|
+
log_type: "event",
|
|
1317
|
+
params: {
|
|
1318
|
+
event_type: "impression",
|
|
1319
|
+
schema_id: 1812034,
|
|
1320
|
+
request_id: payload?.adMetadata?.requestId ?? ""
|
|
1321
|
+
}
|
|
1322
|
+
});
|
|
1323
|
+
callbacks.onAdImpression?.(mapEvent(payload));
|
|
1324
|
+
},
|
|
1325
|
+
onAdFailedToRender: (payload) => callbacks.onAdFailedToRender?.({
|
|
1326
|
+
...mapEvent(payload),
|
|
1327
|
+
error: payload?.error ?? { code: 0, message: "UNKNOWN" }
|
|
1328
|
+
}),
|
|
1329
|
+
onNoFill: (payload) => callbacks.onNoFill?.(mapEvent(payload))
|
|
1330
|
+
};
|
|
1331
|
+
}
|
|
1332
|
+
var TossAds = {
|
|
1333
|
+
initialize: Object.assign(initialize, {
|
|
1334
|
+
isSupported: fetchTossAd.isSupported
|
|
1335
|
+
}),
|
|
1336
|
+
attach: Object.assign(attach, {
|
|
1337
|
+
isSupported: fetchTossAd.isSupported
|
|
1338
|
+
}),
|
|
1339
|
+
destroy: Object.assign(destroy, {
|
|
1340
|
+
isSupported: fetchTossAd.isSupported
|
|
1341
|
+
}),
|
|
1342
|
+
destroyAll: Object.assign(destroyAll, {
|
|
1343
|
+
isSupported: fetchTossAd.isSupported
|
|
1344
|
+
})
|
|
1345
|
+
};
|
|
1346
|
+
|
|
1063
1347
|
// src/index.ts
|
|
1064
1348
|
__reExport(index_exports, require("@apps-in-toss/types"), module.exports);
|
|
1065
1349
|
// Annotate the CommonJS export names for ESM import in node:
|
|
@@ -1068,6 +1352,7 @@ __reExport(index_exports, require("@apps-in-toss/types"), module.exports);
|
|
|
1068
1352
|
IAP,
|
|
1069
1353
|
SafeAreaInsets,
|
|
1070
1354
|
Storage,
|
|
1355
|
+
TossAds,
|
|
1071
1356
|
appsInTossEvent,
|
|
1072
1357
|
env,
|
|
1073
1358
|
fetchAlbumPhotos,
|
|
@@ -1078,9 +1363,11 @@ __reExport(index_exports, require("@apps-in-toss/types"), module.exports);
|
|
|
1078
1363
|
getSafeAreaInsets,
|
|
1079
1364
|
graniteEvent,
|
|
1080
1365
|
isMinVersionSupported,
|
|
1366
|
+
loadFullScreenAd,
|
|
1081
1367
|
openCamera,
|
|
1082
1368
|
partner,
|
|
1083
1369
|
setClipboardText,
|
|
1370
|
+
showFullScreenAd,
|
|
1084
1371
|
startUpdateLocation,
|
|
1085
1372
|
tdsEvent,
|
|
1086
1373
|
...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';
|
|
@@ -342,15 +342,15 @@ declare function getSafeAreaInsets(): {
|
|
|
342
342
|
* ```
|
|
343
343
|
*/
|
|
344
344
|
declare function subscribeSafeAreaInsets({ onEvent }: {
|
|
345
|
-
onEvent: (data: SafeAreaInsets) => void;
|
|
345
|
+
onEvent: (data: SafeAreaInsets$1) => void;
|
|
346
346
|
}): () => void;
|
|
347
|
-
interface SafeAreaInsets {
|
|
347
|
+
interface SafeAreaInsets$1 {
|
|
348
348
|
top: number;
|
|
349
349
|
bottom: number;
|
|
350
350
|
left: number;
|
|
351
351
|
right: number;
|
|
352
352
|
}
|
|
353
|
-
declare const SafeAreaInsets: {
|
|
353
|
+
declare const SafeAreaInsets$1: {
|
|
354
354
|
get: typeof getSafeAreaInsets;
|
|
355
355
|
subscribe: typeof subscribeSafeAreaInsets;
|
|
356
356
|
};
|
|
@@ -961,4 +961,189 @@ declare const startUpdateLocation: {
|
|
|
961
961
|
openPermissionDialog(): Promise<"denied" | "allowed">;
|
|
962
962
|
};
|
|
963
963
|
|
|
964
|
-
|
|
964
|
+
declare const loadFullScreenAd: ((args: {
|
|
965
|
+
onEvent: (data: LoadFullScreenAdEvent) => void;
|
|
966
|
+
onError: (error: Error) => void;
|
|
967
|
+
options?: LoadFullScreenAdOptions | undefined;
|
|
968
|
+
}) => () => void) & {
|
|
969
|
+
isSupported: () => boolean;
|
|
970
|
+
};
|
|
971
|
+
declare const showFullScreenAd: ((args: {
|
|
972
|
+
onEvent: (data: ShowFullScreenAdEvent) => void;
|
|
973
|
+
onError: (error: Error) => void;
|
|
974
|
+
options?: ShowFullScreenAdOptions | undefined;
|
|
975
|
+
}) => () => void) & {
|
|
976
|
+
isSupported: () => boolean;
|
|
977
|
+
};
|
|
978
|
+
|
|
979
|
+
type Environment = 'alpha' | 'live';
|
|
980
|
+
type DeviceOS = 'IOS' | 'ANDROID';
|
|
981
|
+
type DeviceAttStatus = 'NOT_DETERMINED' | 'RESTRICTED' | 'DENIED' | 'AUTHORIZED';
|
|
982
|
+
type DeviceCarrier = 'SKT' | 'KT' | 'LGU' | 'SKT_MVNO' | 'KT_MVNO' | 'LG_MVNO';
|
|
983
|
+
type RequestHeaders = Record<string, string>;
|
|
984
|
+
interface DeviceInfo {
|
|
985
|
+
os?: DeviceOS;
|
|
986
|
+
osVersion?: string;
|
|
987
|
+
ua?: string;
|
|
988
|
+
ifa?: string;
|
|
989
|
+
ifv?: string | null;
|
|
990
|
+
attStatus?: DeviceAttStatus | null;
|
|
991
|
+
model?: string;
|
|
992
|
+
carrier?: DeviceCarrier;
|
|
993
|
+
}
|
|
994
|
+
interface SafeAreaInsets {
|
|
995
|
+
top: string;
|
|
996
|
+
bottom: string;
|
|
997
|
+
left: string;
|
|
998
|
+
right: string;
|
|
999
|
+
}
|
|
1000
|
+
interface RuntimeInfo {
|
|
1001
|
+
safeAreaInsets?: SafeAreaInsets;
|
|
1002
|
+
}
|
|
1003
|
+
type AdOpener = (url: string, target?: string, features?: string) => void;
|
|
1004
|
+
interface AdConfig {
|
|
1005
|
+
environment: Environment;
|
|
1006
|
+
apiEndpoint?: string;
|
|
1007
|
+
deviceInfo?: DeviceInfo;
|
|
1008
|
+
requestHeaders?: RequestHeaders;
|
|
1009
|
+
runtimeInfo?: RuntimeInfo;
|
|
1010
|
+
opener?: AdOpener;
|
|
1011
|
+
customAdFetcher?: CustomAdFetcher;
|
|
1012
|
+
}
|
|
1013
|
+
interface AdRequest {
|
|
1014
|
+
spaceUnitId: string;
|
|
1015
|
+
options?: {
|
|
1016
|
+
dummyAdFormat?: string;
|
|
1017
|
+
maxSize?: number;
|
|
1018
|
+
video?: {
|
|
1019
|
+
maxDurationMs?: number;
|
|
1020
|
+
};
|
|
1021
|
+
};
|
|
1022
|
+
}
|
|
1023
|
+
type AdResponseStatus = 'OK' | 'NO_AD' | 'BLOCKED' | 'ERROR' | 'TIMEOUT' | 'INVALID_SPACE' | 'INVALID_REQUEST' | 'LIMITED_AD' | 'CONSENT_REQUIRED' | 'TEST_MODE';
|
|
1024
|
+
interface AdResponse {
|
|
1025
|
+
requestId?: string;
|
|
1026
|
+
status?: AdResponseStatus;
|
|
1027
|
+
ads: Ad[];
|
|
1028
|
+
ext?: AdResponseExt;
|
|
1029
|
+
}
|
|
1030
|
+
interface Ad {
|
|
1031
|
+
styleId: string;
|
|
1032
|
+
creative: Record<string, any>;
|
|
1033
|
+
eventTrackingUrls?: string[];
|
|
1034
|
+
eventTypes?: string[];
|
|
1035
|
+
eventPayload?: string;
|
|
1036
|
+
requestId?: string;
|
|
1037
|
+
}
|
|
1038
|
+
interface AdResponseExt {
|
|
1039
|
+
skippableOffsetSeconds?: number;
|
|
1040
|
+
reward?: {
|
|
1041
|
+
type: string;
|
|
1042
|
+
amount: number;
|
|
1043
|
+
};
|
|
1044
|
+
isAdBadgeEnabled?: boolean;
|
|
1045
|
+
refetchSeconds?: number | null;
|
|
1046
|
+
}
|
|
1047
|
+
interface ApiResponse<T> {
|
|
1048
|
+
resultType: 'SUCCESS' | 'HTTP_TIMEOUT' | 'NETWORK_ERROR' | 'EXECUTION_FAIL' | 'INTERRUPTED' | 'INTERNAL_ERROR' | 'FAIL';
|
|
1049
|
+
success?: T;
|
|
1050
|
+
error?: {
|
|
1051
|
+
errorType?: number;
|
|
1052
|
+
errorCode?: string;
|
|
1053
|
+
reason?: string;
|
|
1054
|
+
data?: Record<string, any>;
|
|
1055
|
+
title?: string;
|
|
1056
|
+
};
|
|
1057
|
+
}
|
|
1058
|
+
type CustomAdFetcher = (endpoint: string, request: AdRequest, headers?: RequestHeaders) => Promise<ApiResponse<AdResponse>>;
|
|
1059
|
+
interface InitializeOptions {
|
|
1060
|
+
callbacks?: {
|
|
1061
|
+
onInitialized?: () => void;
|
|
1062
|
+
onInitializationFailed?: (error: Error) => void;
|
|
1063
|
+
};
|
|
1064
|
+
}
|
|
1065
|
+
interface BannerSlotEventPayload {
|
|
1066
|
+
slotId: string;
|
|
1067
|
+
adGroupId: string;
|
|
1068
|
+
adMetadata: {
|
|
1069
|
+
creativeId: string;
|
|
1070
|
+
requestId: string;
|
|
1071
|
+
};
|
|
1072
|
+
}
|
|
1073
|
+
interface BannerSlotErrorPayload {
|
|
1074
|
+
slotId: string;
|
|
1075
|
+
adGroupId: string;
|
|
1076
|
+
adMetadata: Record<string, never>;
|
|
1077
|
+
error: {
|
|
1078
|
+
code: number;
|
|
1079
|
+
message: string;
|
|
1080
|
+
domain?: string;
|
|
1081
|
+
};
|
|
1082
|
+
}
|
|
1083
|
+
interface BannerSlotCallbacks {
|
|
1084
|
+
onAdRendered?: (payload: BannerSlotEventPayload) => void;
|
|
1085
|
+
onAdViewable?: (payload: BannerSlotEventPayload) => void;
|
|
1086
|
+
onAdClicked?: (payload: BannerSlotEventPayload) => void;
|
|
1087
|
+
onAdImpression?: (payload: BannerSlotEventPayload) => void;
|
|
1088
|
+
onAdFailedToRender?: (payload: BannerSlotErrorPayload) => void;
|
|
1089
|
+
onNoFill?: (payload: {
|
|
1090
|
+
slotId: string;
|
|
1091
|
+
adGroupId: string;
|
|
1092
|
+
adMetadata: Record<string, never>;
|
|
1093
|
+
}) => void;
|
|
1094
|
+
}
|
|
1095
|
+
interface BannerSlotOptions {
|
|
1096
|
+
spaceId: string;
|
|
1097
|
+
autoLoad?: boolean;
|
|
1098
|
+
dummyAdFormat?: string;
|
|
1099
|
+
maxVideoDurationMs?: number;
|
|
1100
|
+
refetchIntervalMs?: number;
|
|
1101
|
+
theme?: 'light' | 'dark';
|
|
1102
|
+
padding?: string;
|
|
1103
|
+
callbacks?: BannerSlotCallbacks;
|
|
1104
|
+
}
|
|
1105
|
+
interface BannerSlot {
|
|
1106
|
+
load(): void | Promise<void>;
|
|
1107
|
+
destroy(): void;
|
|
1108
|
+
}
|
|
1109
|
+
interface BannerNamespace {
|
|
1110
|
+
createSlot(target: string | HTMLElement, options: BannerSlotOptions): BannerSlot;
|
|
1111
|
+
destroy(slotId: string): void;
|
|
1112
|
+
destroyAll(): void;
|
|
1113
|
+
}
|
|
1114
|
+
interface AdsSdkGlobal {
|
|
1115
|
+
init(config: AdConfig): void;
|
|
1116
|
+
banner: BannerNamespace;
|
|
1117
|
+
isInitialized(): boolean;
|
|
1118
|
+
}
|
|
1119
|
+
declare global {
|
|
1120
|
+
interface Window {
|
|
1121
|
+
TossAdsSpaceKit?: AdsSdkGlobal;
|
|
1122
|
+
}
|
|
1123
|
+
}
|
|
1124
|
+
interface AttachOptions {
|
|
1125
|
+
theme?: 'light' | 'dark';
|
|
1126
|
+
padding?: string;
|
|
1127
|
+
callbacks?: BannerSlotCallbacks;
|
|
1128
|
+
}
|
|
1129
|
+
|
|
1130
|
+
declare function initialize(options: InitializeOptions): void;
|
|
1131
|
+
declare function attach(adGroupId: string, target: string | HTMLElement, options?: AttachOptions): void;
|
|
1132
|
+
declare function destroy(slotId: string): void;
|
|
1133
|
+
declare function destroyAll(): void;
|
|
1134
|
+
declare const TossAds: {
|
|
1135
|
+
initialize: typeof initialize & {
|
|
1136
|
+
isSupported: () => boolean;
|
|
1137
|
+
};
|
|
1138
|
+
attach: typeof attach & {
|
|
1139
|
+
isSupported: () => boolean;
|
|
1140
|
+
};
|
|
1141
|
+
destroy: typeof destroy & {
|
|
1142
|
+
isSupported: () => boolean;
|
|
1143
|
+
};
|
|
1144
|
+
destroyAll: typeof destroyAll & {
|
|
1145
|
+
isSupported: () => boolean;
|
|
1146
|
+
};
|
|
1147
|
+
};
|
|
1148
|
+
|
|
1149
|
+
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';
|
|
@@ -342,15 +342,15 @@ declare function getSafeAreaInsets(): {
|
|
|
342
342
|
* ```
|
|
343
343
|
*/
|
|
344
344
|
declare function subscribeSafeAreaInsets({ onEvent }: {
|
|
345
|
-
onEvent: (data: SafeAreaInsets) => void;
|
|
345
|
+
onEvent: (data: SafeAreaInsets$1) => void;
|
|
346
346
|
}): () => void;
|
|
347
|
-
interface SafeAreaInsets {
|
|
347
|
+
interface SafeAreaInsets$1 {
|
|
348
348
|
top: number;
|
|
349
349
|
bottom: number;
|
|
350
350
|
left: number;
|
|
351
351
|
right: number;
|
|
352
352
|
}
|
|
353
|
-
declare const SafeAreaInsets: {
|
|
353
|
+
declare const SafeAreaInsets$1: {
|
|
354
354
|
get: typeof getSafeAreaInsets;
|
|
355
355
|
subscribe: typeof subscribeSafeAreaInsets;
|
|
356
356
|
};
|
|
@@ -961,4 +961,189 @@ declare const startUpdateLocation: {
|
|
|
961
961
|
openPermissionDialog(): Promise<"denied" | "allowed">;
|
|
962
962
|
};
|
|
963
963
|
|
|
964
|
-
|
|
964
|
+
declare const loadFullScreenAd: ((args: {
|
|
965
|
+
onEvent: (data: LoadFullScreenAdEvent) => void;
|
|
966
|
+
onError: (error: Error) => void;
|
|
967
|
+
options?: LoadFullScreenAdOptions | undefined;
|
|
968
|
+
}) => () => void) & {
|
|
969
|
+
isSupported: () => boolean;
|
|
970
|
+
};
|
|
971
|
+
declare const showFullScreenAd: ((args: {
|
|
972
|
+
onEvent: (data: ShowFullScreenAdEvent) => void;
|
|
973
|
+
onError: (error: Error) => void;
|
|
974
|
+
options?: ShowFullScreenAdOptions | undefined;
|
|
975
|
+
}) => () => void) & {
|
|
976
|
+
isSupported: () => boolean;
|
|
977
|
+
};
|
|
978
|
+
|
|
979
|
+
type Environment = 'alpha' | 'live';
|
|
980
|
+
type DeviceOS = 'IOS' | 'ANDROID';
|
|
981
|
+
type DeviceAttStatus = 'NOT_DETERMINED' | 'RESTRICTED' | 'DENIED' | 'AUTHORIZED';
|
|
982
|
+
type DeviceCarrier = 'SKT' | 'KT' | 'LGU' | 'SKT_MVNO' | 'KT_MVNO' | 'LG_MVNO';
|
|
983
|
+
type RequestHeaders = Record<string, string>;
|
|
984
|
+
interface DeviceInfo {
|
|
985
|
+
os?: DeviceOS;
|
|
986
|
+
osVersion?: string;
|
|
987
|
+
ua?: string;
|
|
988
|
+
ifa?: string;
|
|
989
|
+
ifv?: string | null;
|
|
990
|
+
attStatus?: DeviceAttStatus | null;
|
|
991
|
+
model?: string;
|
|
992
|
+
carrier?: DeviceCarrier;
|
|
993
|
+
}
|
|
994
|
+
interface SafeAreaInsets {
|
|
995
|
+
top: string;
|
|
996
|
+
bottom: string;
|
|
997
|
+
left: string;
|
|
998
|
+
right: string;
|
|
999
|
+
}
|
|
1000
|
+
interface RuntimeInfo {
|
|
1001
|
+
safeAreaInsets?: SafeAreaInsets;
|
|
1002
|
+
}
|
|
1003
|
+
type AdOpener = (url: string, target?: string, features?: string) => void;
|
|
1004
|
+
interface AdConfig {
|
|
1005
|
+
environment: Environment;
|
|
1006
|
+
apiEndpoint?: string;
|
|
1007
|
+
deviceInfo?: DeviceInfo;
|
|
1008
|
+
requestHeaders?: RequestHeaders;
|
|
1009
|
+
runtimeInfo?: RuntimeInfo;
|
|
1010
|
+
opener?: AdOpener;
|
|
1011
|
+
customAdFetcher?: CustomAdFetcher;
|
|
1012
|
+
}
|
|
1013
|
+
interface AdRequest {
|
|
1014
|
+
spaceUnitId: string;
|
|
1015
|
+
options?: {
|
|
1016
|
+
dummyAdFormat?: string;
|
|
1017
|
+
maxSize?: number;
|
|
1018
|
+
video?: {
|
|
1019
|
+
maxDurationMs?: number;
|
|
1020
|
+
};
|
|
1021
|
+
};
|
|
1022
|
+
}
|
|
1023
|
+
type AdResponseStatus = 'OK' | 'NO_AD' | 'BLOCKED' | 'ERROR' | 'TIMEOUT' | 'INVALID_SPACE' | 'INVALID_REQUEST' | 'LIMITED_AD' | 'CONSENT_REQUIRED' | 'TEST_MODE';
|
|
1024
|
+
interface AdResponse {
|
|
1025
|
+
requestId?: string;
|
|
1026
|
+
status?: AdResponseStatus;
|
|
1027
|
+
ads: Ad[];
|
|
1028
|
+
ext?: AdResponseExt;
|
|
1029
|
+
}
|
|
1030
|
+
interface Ad {
|
|
1031
|
+
styleId: string;
|
|
1032
|
+
creative: Record<string, any>;
|
|
1033
|
+
eventTrackingUrls?: string[];
|
|
1034
|
+
eventTypes?: string[];
|
|
1035
|
+
eventPayload?: string;
|
|
1036
|
+
requestId?: string;
|
|
1037
|
+
}
|
|
1038
|
+
interface AdResponseExt {
|
|
1039
|
+
skippableOffsetSeconds?: number;
|
|
1040
|
+
reward?: {
|
|
1041
|
+
type: string;
|
|
1042
|
+
amount: number;
|
|
1043
|
+
};
|
|
1044
|
+
isAdBadgeEnabled?: boolean;
|
|
1045
|
+
refetchSeconds?: number | null;
|
|
1046
|
+
}
|
|
1047
|
+
interface ApiResponse<T> {
|
|
1048
|
+
resultType: 'SUCCESS' | 'HTTP_TIMEOUT' | 'NETWORK_ERROR' | 'EXECUTION_FAIL' | 'INTERRUPTED' | 'INTERNAL_ERROR' | 'FAIL';
|
|
1049
|
+
success?: T;
|
|
1050
|
+
error?: {
|
|
1051
|
+
errorType?: number;
|
|
1052
|
+
errorCode?: string;
|
|
1053
|
+
reason?: string;
|
|
1054
|
+
data?: Record<string, any>;
|
|
1055
|
+
title?: string;
|
|
1056
|
+
};
|
|
1057
|
+
}
|
|
1058
|
+
type CustomAdFetcher = (endpoint: string, request: AdRequest, headers?: RequestHeaders) => Promise<ApiResponse<AdResponse>>;
|
|
1059
|
+
interface InitializeOptions {
|
|
1060
|
+
callbacks?: {
|
|
1061
|
+
onInitialized?: () => void;
|
|
1062
|
+
onInitializationFailed?: (error: Error) => void;
|
|
1063
|
+
};
|
|
1064
|
+
}
|
|
1065
|
+
interface BannerSlotEventPayload {
|
|
1066
|
+
slotId: string;
|
|
1067
|
+
adGroupId: string;
|
|
1068
|
+
adMetadata: {
|
|
1069
|
+
creativeId: string;
|
|
1070
|
+
requestId: string;
|
|
1071
|
+
};
|
|
1072
|
+
}
|
|
1073
|
+
interface BannerSlotErrorPayload {
|
|
1074
|
+
slotId: string;
|
|
1075
|
+
adGroupId: string;
|
|
1076
|
+
adMetadata: Record<string, never>;
|
|
1077
|
+
error: {
|
|
1078
|
+
code: number;
|
|
1079
|
+
message: string;
|
|
1080
|
+
domain?: string;
|
|
1081
|
+
};
|
|
1082
|
+
}
|
|
1083
|
+
interface BannerSlotCallbacks {
|
|
1084
|
+
onAdRendered?: (payload: BannerSlotEventPayload) => void;
|
|
1085
|
+
onAdViewable?: (payload: BannerSlotEventPayload) => void;
|
|
1086
|
+
onAdClicked?: (payload: BannerSlotEventPayload) => void;
|
|
1087
|
+
onAdImpression?: (payload: BannerSlotEventPayload) => void;
|
|
1088
|
+
onAdFailedToRender?: (payload: BannerSlotErrorPayload) => void;
|
|
1089
|
+
onNoFill?: (payload: {
|
|
1090
|
+
slotId: string;
|
|
1091
|
+
adGroupId: string;
|
|
1092
|
+
adMetadata: Record<string, never>;
|
|
1093
|
+
}) => void;
|
|
1094
|
+
}
|
|
1095
|
+
interface BannerSlotOptions {
|
|
1096
|
+
spaceId: string;
|
|
1097
|
+
autoLoad?: boolean;
|
|
1098
|
+
dummyAdFormat?: string;
|
|
1099
|
+
maxVideoDurationMs?: number;
|
|
1100
|
+
refetchIntervalMs?: number;
|
|
1101
|
+
theme?: 'light' | 'dark';
|
|
1102
|
+
padding?: string;
|
|
1103
|
+
callbacks?: BannerSlotCallbacks;
|
|
1104
|
+
}
|
|
1105
|
+
interface BannerSlot {
|
|
1106
|
+
load(): void | Promise<void>;
|
|
1107
|
+
destroy(): void;
|
|
1108
|
+
}
|
|
1109
|
+
interface BannerNamespace {
|
|
1110
|
+
createSlot(target: string | HTMLElement, options: BannerSlotOptions): BannerSlot;
|
|
1111
|
+
destroy(slotId: string): void;
|
|
1112
|
+
destroyAll(): void;
|
|
1113
|
+
}
|
|
1114
|
+
interface AdsSdkGlobal {
|
|
1115
|
+
init(config: AdConfig): void;
|
|
1116
|
+
banner: BannerNamespace;
|
|
1117
|
+
isInitialized(): boolean;
|
|
1118
|
+
}
|
|
1119
|
+
declare global {
|
|
1120
|
+
interface Window {
|
|
1121
|
+
TossAdsSpaceKit?: AdsSdkGlobal;
|
|
1122
|
+
}
|
|
1123
|
+
}
|
|
1124
|
+
interface AttachOptions {
|
|
1125
|
+
theme?: 'light' | 'dark';
|
|
1126
|
+
padding?: string;
|
|
1127
|
+
callbacks?: BannerSlotCallbacks;
|
|
1128
|
+
}
|
|
1129
|
+
|
|
1130
|
+
declare function initialize(options: InitializeOptions): void;
|
|
1131
|
+
declare function attach(adGroupId: string, target: string | HTMLElement, options?: AttachOptions): void;
|
|
1132
|
+
declare function destroy(slotId: string): void;
|
|
1133
|
+
declare function destroyAll(): void;
|
|
1134
|
+
declare const TossAds: {
|
|
1135
|
+
initialize: typeof initialize & {
|
|
1136
|
+
isSupported: () => boolean;
|
|
1137
|
+
};
|
|
1138
|
+
attach: typeof attach & {
|
|
1139
|
+
isSupported: () => boolean;
|
|
1140
|
+
};
|
|
1141
|
+
destroy: typeof destroy & {
|
|
1142
|
+
isSupported: () => boolean;
|
|
1143
|
+
};
|
|
1144
|
+
destroyAll: typeof destroyAll & {
|
|
1145
|
+
isSupported: () => boolean;
|
|
1146
|
+
};
|
|
1147
|
+
};
|
|
1148
|
+
|
|
1149
|
+
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
|
@@ -1022,6 +1022,287 @@ var startUpdateLocation = (params) => {
|
|
|
1022
1022
|
startUpdateLocation.getPermission = () => getPermission2({ name: "geolocation", access: "access" });
|
|
1023
1023
|
startUpdateLocation.openPermissionDialog = () => openPermissionDialog2({ name: "geolocation", access: "access" });
|
|
1024
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.3.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({
|
|
1168
|
+
adGroupId: request.spaceUnitId,
|
|
1169
|
+
sdkId: "108",
|
|
1170
|
+
availableStyleIds: ["1", "2"]
|
|
1171
|
+
});
|
|
1172
|
+
return normalizeApiResponse(raw);
|
|
1173
|
+
} catch (error) {
|
|
1174
|
+
return {
|
|
1175
|
+
resultType: "FAIL",
|
|
1176
|
+
error: {
|
|
1177
|
+
reason: error instanceof Error ? error.message : "Unknown fetchTossAd error"
|
|
1178
|
+
}
|
|
1179
|
+
};
|
|
1180
|
+
}
|
|
1181
|
+
};
|
|
1182
|
+
}
|
|
1183
|
+
var pendingLoad2 = null;
|
|
1184
|
+
function initialize(options) {
|
|
1185
|
+
const { callbacks } = options;
|
|
1186
|
+
if (window.TossAdsSpaceKit != null && window.TossAdsSpaceKit.isInitialized()) {
|
|
1187
|
+
callbacks?.onInitializationFailed?.(new Error("[toss-ad] Already initialized."));
|
|
1188
|
+
return;
|
|
1189
|
+
}
|
|
1190
|
+
if (pendingLoad2 != null) {
|
|
1191
|
+
callbacks?.onInitializationFailed?.(new Error("[toss-ad] initialization already in progress."));
|
|
1192
|
+
}
|
|
1193
|
+
const resolveInitialized = () => callbacks?.onInitialized?.();
|
|
1194
|
+
const rejectInitialized = (error) => {
|
|
1195
|
+
const normalizedError = error instanceof Error ? error : new Error(String(error));
|
|
1196
|
+
callbacks?.onInitializationFailed?.(normalizedError);
|
|
1197
|
+
};
|
|
1198
|
+
pendingLoad2 = loadAdsSdk().then((sdk) => {
|
|
1199
|
+
const customAdFetcher = createCustomAdFetcher();
|
|
1200
|
+
const config = { environment: "live", customAdFetcher, opener: openUrlOpener };
|
|
1201
|
+
sdk.init(config);
|
|
1202
|
+
resolveInitialized();
|
|
1203
|
+
}).catch((error) => {
|
|
1204
|
+
pendingLoad2 = null;
|
|
1205
|
+
rejectInitialized(error);
|
|
1206
|
+
});
|
|
1207
|
+
}
|
|
1208
|
+
function attach(adGroupId, target, options = {}) {
|
|
1209
|
+
const { callbacks } = options;
|
|
1210
|
+
const rejectAttached = (error) => {
|
|
1211
|
+
const normalizedError = error instanceof Error ? error : new Error(String(error));
|
|
1212
|
+
callbacks?.onAdFailedToRender?.({
|
|
1213
|
+
slotId: "",
|
|
1214
|
+
adGroupId,
|
|
1215
|
+
adMetadata: {},
|
|
1216
|
+
error: { code: 0, message: normalizedError.message }
|
|
1217
|
+
});
|
|
1218
|
+
};
|
|
1219
|
+
try {
|
|
1220
|
+
const spaceId = adGroupId;
|
|
1221
|
+
const sdk = getAdsSdk();
|
|
1222
|
+
if (!sdk) {
|
|
1223
|
+
throw new Error("[toss-ad] Call initialize() before attaching an ad.");
|
|
1224
|
+
}
|
|
1225
|
+
if (!sdk.banner) {
|
|
1226
|
+
throw new Error("[toss-ad] Loaded TossAdsSpaceKit does not support banner ads.");
|
|
1227
|
+
}
|
|
1228
|
+
const element = typeof target === "string" ? document.querySelector(target) : target;
|
|
1229
|
+
if (!element) {
|
|
1230
|
+
throw new Error(`[toss-ad] Failed to find target element: ${target}`);
|
|
1231
|
+
}
|
|
1232
|
+
const slotOptions = {
|
|
1233
|
+
spaceId,
|
|
1234
|
+
autoLoad: true,
|
|
1235
|
+
theme: options.theme,
|
|
1236
|
+
padding: options.padding,
|
|
1237
|
+
callbacks: wrapCallbacks(adGroupId, options.callbacks)
|
|
1238
|
+
};
|
|
1239
|
+
sdk.banner.createSlot(element, slotOptions);
|
|
1240
|
+
} catch (error) {
|
|
1241
|
+
rejectAttached(error);
|
|
1242
|
+
}
|
|
1243
|
+
}
|
|
1244
|
+
function destroy(slotId) {
|
|
1245
|
+
const sdk = getAdsSdk();
|
|
1246
|
+
if (!sdk?.banner) {
|
|
1247
|
+
return;
|
|
1248
|
+
}
|
|
1249
|
+
sdk.banner.destroy(slotId);
|
|
1250
|
+
}
|
|
1251
|
+
function destroyAll() {
|
|
1252
|
+
const sdk = getAdsSdk();
|
|
1253
|
+
if (!sdk?.banner) {
|
|
1254
|
+
return;
|
|
1255
|
+
}
|
|
1256
|
+
sdk.banner.destroyAll();
|
|
1257
|
+
}
|
|
1258
|
+
function wrapCallbacks(adGroupId, callbacks) {
|
|
1259
|
+
if (!callbacks) {
|
|
1260
|
+
return void 0;
|
|
1261
|
+
}
|
|
1262
|
+
const mapEvent = (payload) => {
|
|
1263
|
+
const next = { ...payload ?? {} };
|
|
1264
|
+
next.adGroupId = next.adGroupId ?? next.spaceId ?? adGroupId;
|
|
1265
|
+
delete next.spaceId;
|
|
1266
|
+
return next;
|
|
1267
|
+
};
|
|
1268
|
+
return {
|
|
1269
|
+
onAdRendered: (payload) => callbacks.onAdRendered?.(mapEvent(payload)),
|
|
1270
|
+
onAdViewable: (payload) => callbacks.onAdViewable?.(mapEvent(payload)),
|
|
1271
|
+
onAdClicked: (payload) => callbacks.onAdClicked?.(mapEvent(payload)),
|
|
1272
|
+
onAdImpression: (payload) => {
|
|
1273
|
+
tossAdEventLog({
|
|
1274
|
+
log_name: "display_ads_all::impression__1px_banner",
|
|
1275
|
+
log_type: "event",
|
|
1276
|
+
params: {
|
|
1277
|
+
event_type: "impression",
|
|
1278
|
+
schema_id: 1812034,
|
|
1279
|
+
request_id: payload?.adMetadata?.requestId ?? ""
|
|
1280
|
+
}
|
|
1281
|
+
});
|
|
1282
|
+
callbacks.onAdImpression?.(mapEvent(payload));
|
|
1283
|
+
},
|
|
1284
|
+
onAdFailedToRender: (payload) => callbacks.onAdFailedToRender?.({
|
|
1285
|
+
...mapEvent(payload),
|
|
1286
|
+
error: payload?.error ?? { code: 0, message: "UNKNOWN" }
|
|
1287
|
+
}),
|
|
1288
|
+
onNoFill: (payload) => callbacks.onNoFill?.(mapEvent(payload))
|
|
1289
|
+
};
|
|
1290
|
+
}
|
|
1291
|
+
var TossAds = {
|
|
1292
|
+
initialize: Object.assign(initialize, {
|
|
1293
|
+
isSupported: fetchTossAd.isSupported
|
|
1294
|
+
}),
|
|
1295
|
+
attach: Object.assign(attach, {
|
|
1296
|
+
isSupported: fetchTossAd.isSupported
|
|
1297
|
+
}),
|
|
1298
|
+
destroy: Object.assign(destroy, {
|
|
1299
|
+
isSupported: fetchTossAd.isSupported
|
|
1300
|
+
}),
|
|
1301
|
+
destroyAll: Object.assign(destroyAll, {
|
|
1302
|
+
isSupported: fetchTossAd.isSupported
|
|
1303
|
+
})
|
|
1304
|
+
};
|
|
1305
|
+
|
|
1025
1306
|
// src/index.ts
|
|
1026
1307
|
export * from "@apps-in-toss/types";
|
|
1027
1308
|
export {
|
|
@@ -1029,6 +1310,7 @@ export {
|
|
|
1029
1310
|
IAP,
|
|
1030
1311
|
SafeAreaInsets,
|
|
1031
1312
|
Storage,
|
|
1313
|
+
TossAds,
|
|
1032
1314
|
appsInTossEvent,
|
|
1033
1315
|
env,
|
|
1034
1316
|
fetchAlbumPhotos,
|
|
@@ -1039,9 +1321,11 @@ export {
|
|
|
1039
1321
|
getSafeAreaInsets,
|
|
1040
1322
|
graniteEvent,
|
|
1041
1323
|
isMinVersionSupported,
|
|
1324
|
+
loadFullScreenAd,
|
|
1042
1325
|
openCamera,
|
|
1043
1326
|
partner,
|
|
1044
1327
|
setClipboardText,
|
|
1328
|
+
showFullScreenAd,
|
|
1045
1329
|
startUpdateLocation,
|
|
1046
1330
|
tdsEvent
|
|
1047
1331
|
};
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@apps-in-toss/web-bridge",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "1.
|
|
4
|
+
"version": "1.6.0",
|
|
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": "1.
|
|
31
|
+
"@apps-in-toss/types": "1.6.0"
|
|
32
32
|
},
|
|
33
33
|
"devDependencies": {
|
|
34
|
-
"@apps-in-toss/bridge-core": "1.
|
|
35
|
-
"@apps-in-toss/framework": "1.
|
|
34
|
+
"@apps-in-toss/bridge-core": "1.6.0",
|
|
35
|
+
"@apps-in-toss/framework": "1.6.0",
|
|
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": "ee1ce0d363246b54246472599e0312cd2d2c1ff5"
|
|
50
50
|
}
|