@apps-in-toss/web-bridge 1.5.3 → 1.6.1
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/CHANGELOG.md +3 -0
- package/built/index.cjs +293 -0
- package/built/index.d.cts +190 -5
- package/built/index.d.ts +190 -5
- package/built/index.js +290 -0
- package/package.json +6 -11
package/CHANGELOG.md
ADDED
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,293 @@ 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(
|
|
1069
|
+
(0, import_bridge_core21.createEventBridge)("loadFullScreenAd"),
|
|
1070
|
+
{
|
|
1071
|
+
isSupported: (0, import_bridge_core21.createConstantBridge)("loadFullScreenAd_isSupported")
|
|
1072
|
+
}
|
|
1073
|
+
);
|
|
1074
|
+
var showFullScreenAd = Object.assign(
|
|
1075
|
+
(0, import_bridge_core21.createEventBridge)("showFullScreenAd"),
|
|
1076
|
+
{
|
|
1077
|
+
isSupported: (0, import_bridge_core21.createConstantBridge)("showFullScreenAd_isSupported")
|
|
1078
|
+
}
|
|
1079
|
+
);
|
|
1080
|
+
|
|
1081
|
+
// src/toss-ad/index.ts
|
|
1082
|
+
var import_bridge_core23 = require("@apps-in-toss/bridge-core");
|
|
1083
|
+
|
|
1084
|
+
// src/toss-ad/opener.ts
|
|
1085
|
+
var import_bridge_core22 = require("@apps-in-toss/bridge-core");
|
|
1086
|
+
var openURL = (0, import_bridge_core22.createAsyncBridge)("openURL");
|
|
1087
|
+
function openUrlOpener(url) {
|
|
1088
|
+
const transformed = getWebSchemeOrUri(url);
|
|
1089
|
+
return openURL(transformed);
|
|
1090
|
+
}
|
|
1091
|
+
function getWebSchemeOrUri(uri) {
|
|
1092
|
+
const isHttp = ["http://", "https://"].some((protocol) => uri.startsWith(protocol));
|
|
1093
|
+
return isHttp ? supertossWeb(uri) : uri;
|
|
1094
|
+
}
|
|
1095
|
+
function supertossWeb(uri) {
|
|
1096
|
+
return `supertoss://web?url=${encodeURIComponent(uri)}&external=true`;
|
|
1097
|
+
}
|
|
1098
|
+
|
|
1099
|
+
// src/toss-ad/scriptLoader.ts
|
|
1100
|
+
var DEFAULT_SDK_URL = "https://static.toss.im/ads/sdk/toss-ads-space-kit-1.3.0.js";
|
|
1101
|
+
var DEFAULT_TIMEOUT_MS = 15e3;
|
|
1102
|
+
var pendingLoad = null;
|
|
1103
|
+
function getAdsSdk() {
|
|
1104
|
+
if (typeof window === "undefined") {
|
|
1105
|
+
return void 0;
|
|
1106
|
+
}
|
|
1107
|
+
return window.TossAdsSpaceKit;
|
|
1108
|
+
}
|
|
1109
|
+
function loadAdsSdk() {
|
|
1110
|
+
if (typeof window === "undefined" || typeof document === "undefined") {
|
|
1111
|
+
return Promise.reject(new Error("Ads SDK can only be loaded in a browser environment."));
|
|
1112
|
+
}
|
|
1113
|
+
const existing = getAdsSdk();
|
|
1114
|
+
if (existing) {
|
|
1115
|
+
return Promise.resolve(existing);
|
|
1116
|
+
}
|
|
1117
|
+
if (pendingLoad) {
|
|
1118
|
+
return pendingLoad;
|
|
1119
|
+
}
|
|
1120
|
+
const promise = new Promise((resolve, reject) => {
|
|
1121
|
+
const script = document.createElement("script");
|
|
1122
|
+
const cleanup = () => {
|
|
1123
|
+
script.removeEventListener("load", handleLoad);
|
|
1124
|
+
script.removeEventListener("error", handleError);
|
|
1125
|
+
window.clearTimeout(timeoutId);
|
|
1126
|
+
pendingLoad = null;
|
|
1127
|
+
};
|
|
1128
|
+
const handleLoad = () => {
|
|
1129
|
+
const sdk = getAdsSdk();
|
|
1130
|
+
if (sdk) {
|
|
1131
|
+
cleanup();
|
|
1132
|
+
resolve(sdk);
|
|
1133
|
+
return;
|
|
1134
|
+
}
|
|
1135
|
+
cleanup();
|
|
1136
|
+
reject(new Error("Ads SDK script loaded but window.TossAdsSpaceKit was not exposed."));
|
|
1137
|
+
};
|
|
1138
|
+
const handleError = () => {
|
|
1139
|
+
cleanup();
|
|
1140
|
+
reject(new Error(`Failed to load Ads SDK script from ${DEFAULT_SDK_URL}.`));
|
|
1141
|
+
};
|
|
1142
|
+
const timeoutId = window.setTimeout(() => {
|
|
1143
|
+
cleanup();
|
|
1144
|
+
reject(new Error(`Loading Ads SDK timed out after ${DEFAULT_TIMEOUT_MS}ms.`));
|
|
1145
|
+
}, DEFAULT_TIMEOUT_MS);
|
|
1146
|
+
script.addEventListener("load", handleLoad);
|
|
1147
|
+
script.addEventListener("error", handleError);
|
|
1148
|
+
script.async = true;
|
|
1149
|
+
script.src = DEFAULT_SDK_URL;
|
|
1150
|
+
document.head.appendChild(script);
|
|
1151
|
+
});
|
|
1152
|
+
pendingLoad = promise;
|
|
1153
|
+
return promise;
|
|
1154
|
+
}
|
|
1155
|
+
|
|
1156
|
+
// src/toss-ad/index.ts
|
|
1157
|
+
var fetchTossAd = Object.assign((0, import_bridge_core23.createEventBridge)("fetchTossAd"), {
|
|
1158
|
+
isSupported: (0, import_bridge_core23.createConstantBridge)("fetchTossAd_isSupported")
|
|
1159
|
+
});
|
|
1160
|
+
var tossAdEventLog = (0, import_bridge_core23.createAsyncBridge)("tossAdEventLog");
|
|
1161
|
+
var SUPPORTED_STYLE_IDS = /* @__PURE__ */ new Set(["1", "2"]);
|
|
1162
|
+
function fetchTossAdPromise(options) {
|
|
1163
|
+
return new Promise((resolve, reject) => {
|
|
1164
|
+
if (!fetchTossAd.isSupported()) {
|
|
1165
|
+
reject(new Error("fetchTossAd is not supported in this environment."));
|
|
1166
|
+
return;
|
|
1167
|
+
}
|
|
1168
|
+
return fetchTossAd({
|
|
1169
|
+
options,
|
|
1170
|
+
onEvent: resolve,
|
|
1171
|
+
onError: reject
|
|
1172
|
+
});
|
|
1173
|
+
});
|
|
1174
|
+
}
|
|
1175
|
+
function normalizeAdResponse(adResponse) {
|
|
1176
|
+
const ads = Array.isArray(adResponse.ads) ? adResponse.ads.filter((ad) => SUPPORTED_STYLE_IDS.has(String(ad.styleId))) : [];
|
|
1177
|
+
return {
|
|
1178
|
+
requestId: adResponse.requestId ?? "",
|
|
1179
|
+
status: adResponse.status ?? "OK",
|
|
1180
|
+
ads,
|
|
1181
|
+
ext: adResponse.ext
|
|
1182
|
+
};
|
|
1183
|
+
}
|
|
1184
|
+
function normalizeApiResponse(raw) {
|
|
1185
|
+
if (isApiResponse(raw)) {
|
|
1186
|
+
if (raw.resultType !== "SUCCESS") {
|
|
1187
|
+
return raw;
|
|
1188
|
+
}
|
|
1189
|
+
if (!raw.success) {
|
|
1190
|
+
return {
|
|
1191
|
+
resultType: "FAIL",
|
|
1192
|
+
error: { reason: "fetchTossAd returned SUCCESS without payload" }
|
|
1193
|
+
};
|
|
1194
|
+
}
|
|
1195
|
+
return { ...raw, success: normalizeAdResponse(raw.success) };
|
|
1196
|
+
}
|
|
1197
|
+
if (isAdResponse(raw)) {
|
|
1198
|
+
return {
|
|
1199
|
+
resultType: "SUCCESS",
|
|
1200
|
+
success: normalizeAdResponse(raw)
|
|
1201
|
+
};
|
|
1202
|
+
}
|
|
1203
|
+
return { resultType: "FAIL", error: { reason: "Invalid response from fetchTossAd" } };
|
|
1204
|
+
}
|
|
1205
|
+
function isApiResponse(payload) {
|
|
1206
|
+
return Boolean(payload && typeof payload === "object" && "resultType" in payload);
|
|
1207
|
+
}
|
|
1208
|
+
function isAdResponse(payload) {
|
|
1209
|
+
return Boolean(payload && typeof payload === "object" && "ads" in payload);
|
|
1210
|
+
}
|
|
1211
|
+
function createCustomAdFetcher() {
|
|
1212
|
+
return async (_endpoint, request) => {
|
|
1213
|
+
try {
|
|
1214
|
+
const raw = await fetchTossAdPromise({
|
|
1215
|
+
adGroupId: request.spaceUnitId,
|
|
1216
|
+
sdkId: "108",
|
|
1217
|
+
availableStyleIds: ["1", "2"]
|
|
1218
|
+
});
|
|
1219
|
+
return normalizeApiResponse(raw);
|
|
1220
|
+
} catch (error) {
|
|
1221
|
+
return {
|
|
1222
|
+
resultType: "FAIL",
|
|
1223
|
+
error: {
|
|
1224
|
+
reason: error instanceof Error ? error.message : "Unknown fetchTossAd error"
|
|
1225
|
+
}
|
|
1226
|
+
};
|
|
1227
|
+
}
|
|
1228
|
+
};
|
|
1229
|
+
}
|
|
1230
|
+
var pendingLoad2 = null;
|
|
1231
|
+
function initialize(options) {
|
|
1232
|
+
const { callbacks } = options;
|
|
1233
|
+
if (window.TossAdsSpaceKit != null && window.TossAdsSpaceKit.isInitialized()) {
|
|
1234
|
+
callbacks?.onInitializationFailed?.(new Error("[toss-ad] Already initialized."));
|
|
1235
|
+
return;
|
|
1236
|
+
}
|
|
1237
|
+
if (pendingLoad2 != null) {
|
|
1238
|
+
callbacks?.onInitializationFailed?.(new Error("[toss-ad] initialization already in progress."));
|
|
1239
|
+
}
|
|
1240
|
+
const resolveInitialized = () => callbacks?.onInitialized?.();
|
|
1241
|
+
const rejectInitialized = (error) => {
|
|
1242
|
+
const normalizedError = error instanceof Error ? error : new Error(String(error));
|
|
1243
|
+
callbacks?.onInitializationFailed?.(normalizedError);
|
|
1244
|
+
};
|
|
1245
|
+
pendingLoad2 = loadAdsSdk().then((sdk) => {
|
|
1246
|
+
const customAdFetcher = createCustomAdFetcher();
|
|
1247
|
+
const config = { environment: "live", customAdFetcher, opener: openUrlOpener };
|
|
1248
|
+
sdk.init(config);
|
|
1249
|
+
resolveInitialized();
|
|
1250
|
+
}).catch((error) => {
|
|
1251
|
+
pendingLoad2 = null;
|
|
1252
|
+
rejectInitialized(error);
|
|
1253
|
+
});
|
|
1254
|
+
}
|
|
1255
|
+
function attach(adGroupId, target, options = {}) {
|
|
1256
|
+
const { callbacks } = options;
|
|
1257
|
+
const rejectAttached = (error) => {
|
|
1258
|
+
const normalizedError = error instanceof Error ? error : new Error(String(error));
|
|
1259
|
+
callbacks?.onAdFailedToRender?.({
|
|
1260
|
+
slotId: "",
|
|
1261
|
+
adGroupId,
|
|
1262
|
+
adMetadata: {},
|
|
1263
|
+
error: { code: 0, message: normalizedError.message }
|
|
1264
|
+
});
|
|
1265
|
+
};
|
|
1266
|
+
try {
|
|
1267
|
+
const spaceId = adGroupId;
|
|
1268
|
+
const sdk = getAdsSdk();
|
|
1269
|
+
if (!sdk) {
|
|
1270
|
+
throw new Error("[toss-ad] Call initialize() before attaching an ad.");
|
|
1271
|
+
}
|
|
1272
|
+
if (!sdk.banner) {
|
|
1273
|
+
throw new Error("[toss-ad] Loaded TossAdsSpaceKit does not support banner ads.");
|
|
1274
|
+
}
|
|
1275
|
+
const element = typeof target === "string" ? document.querySelector(target) : target;
|
|
1276
|
+
if (!element) {
|
|
1277
|
+
throw new Error(`[toss-ad] Failed to find target element: ${target}`);
|
|
1278
|
+
}
|
|
1279
|
+
const slotOptions = {
|
|
1280
|
+
spaceId,
|
|
1281
|
+
autoLoad: true,
|
|
1282
|
+
theme: options.theme,
|
|
1283
|
+
padding: options.padding,
|
|
1284
|
+
callbacks: wrapCallbacks(adGroupId, options.callbacks)
|
|
1285
|
+
};
|
|
1286
|
+
sdk.banner.createSlot(element, slotOptions);
|
|
1287
|
+
} catch (error) {
|
|
1288
|
+
rejectAttached(error);
|
|
1289
|
+
}
|
|
1290
|
+
}
|
|
1291
|
+
function destroy(slotId) {
|
|
1292
|
+
const sdk = getAdsSdk();
|
|
1293
|
+
if (!sdk?.banner) {
|
|
1294
|
+
return;
|
|
1295
|
+
}
|
|
1296
|
+
sdk.banner.destroy(slotId);
|
|
1297
|
+
}
|
|
1298
|
+
function destroyAll() {
|
|
1299
|
+
const sdk = getAdsSdk();
|
|
1300
|
+
if (!sdk?.banner) {
|
|
1301
|
+
return;
|
|
1302
|
+
}
|
|
1303
|
+
sdk.banner.destroyAll();
|
|
1304
|
+
}
|
|
1305
|
+
function wrapCallbacks(adGroupId, callbacks) {
|
|
1306
|
+
if (!callbacks) {
|
|
1307
|
+
return void 0;
|
|
1308
|
+
}
|
|
1309
|
+
const mapEvent = (payload) => {
|
|
1310
|
+
const next = { ...payload ?? {} };
|
|
1311
|
+
next.adGroupId = next.adGroupId ?? next.spaceId ?? adGroupId;
|
|
1312
|
+
delete next.spaceId;
|
|
1313
|
+
return next;
|
|
1314
|
+
};
|
|
1315
|
+
return {
|
|
1316
|
+
onAdRendered: (payload) => callbacks.onAdRendered?.(mapEvent(payload)),
|
|
1317
|
+
onAdViewable: (payload) => callbacks.onAdViewable?.(mapEvent(payload)),
|
|
1318
|
+
onAdClicked: (payload) => callbacks.onAdClicked?.(mapEvent(payload)),
|
|
1319
|
+
onAdImpression: (payload) => {
|
|
1320
|
+
tossAdEventLog({
|
|
1321
|
+
log_name: "display_ads_all::impression__1px_banner",
|
|
1322
|
+
log_type: "event",
|
|
1323
|
+
params: {
|
|
1324
|
+
event_type: "impression",
|
|
1325
|
+
schema_id: 1812034,
|
|
1326
|
+
request_id: payload?.adMetadata?.requestId ?? ""
|
|
1327
|
+
}
|
|
1328
|
+
});
|
|
1329
|
+
callbacks.onAdImpression?.(mapEvent(payload));
|
|
1330
|
+
},
|
|
1331
|
+
onAdFailedToRender: (payload) => callbacks.onAdFailedToRender?.({
|
|
1332
|
+
...mapEvent(payload),
|
|
1333
|
+
error: payload?.error ?? { code: 0, message: "UNKNOWN" }
|
|
1334
|
+
}),
|
|
1335
|
+
onNoFill: (payload) => callbacks.onNoFill?.(mapEvent(payload))
|
|
1336
|
+
};
|
|
1337
|
+
}
|
|
1338
|
+
var TossAds = {
|
|
1339
|
+
initialize: Object.assign(initialize, {
|
|
1340
|
+
isSupported: fetchTossAd.isSupported
|
|
1341
|
+
}),
|
|
1342
|
+
attach: Object.assign(attach, {
|
|
1343
|
+
isSupported: fetchTossAd.isSupported
|
|
1344
|
+
}),
|
|
1345
|
+
destroy: Object.assign(destroy, {
|
|
1346
|
+
isSupported: fetchTossAd.isSupported
|
|
1347
|
+
}),
|
|
1348
|
+
destroyAll: Object.assign(destroyAll, {
|
|
1349
|
+
isSupported: fetchTossAd.isSupported
|
|
1350
|
+
})
|
|
1351
|
+
};
|
|
1352
|
+
|
|
1063
1353
|
// src/index.ts
|
|
1064
1354
|
__reExport(index_exports, require("@apps-in-toss/types"), module.exports);
|
|
1065
1355
|
// Annotate the CommonJS export names for ESM import in node:
|
|
@@ -1068,6 +1358,7 @@ __reExport(index_exports, require("@apps-in-toss/types"), module.exports);
|
|
|
1068
1358
|
IAP,
|
|
1069
1359
|
SafeAreaInsets,
|
|
1070
1360
|
Storage,
|
|
1361
|
+
TossAds,
|
|
1071
1362
|
appsInTossEvent,
|
|
1072
1363
|
env,
|
|
1073
1364
|
fetchAlbumPhotos,
|
|
@@ -1078,9 +1369,11 @@ __reExport(index_exports, require("@apps-in-toss/types"), module.exports);
|
|
|
1078
1369
|
getSafeAreaInsets,
|
|
1079
1370
|
graniteEvent,
|
|
1080
1371
|
isMinVersionSupported,
|
|
1372
|
+
loadFullScreenAd,
|
|
1081
1373
|
openCamera,
|
|
1082
1374
|
partner,
|
|
1083
1375
|
setClipboardText,
|
|
1376
|
+
showFullScreenAd,
|
|
1084
1377
|
startUpdateLocation,
|
|
1085
1378
|
tdsEvent,
|
|
1086
1379
|
...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,293 @@ 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(
|
|
1028
|
+
createEventBridge8("loadFullScreenAd"),
|
|
1029
|
+
{
|
|
1030
|
+
isSupported: createConstantBridge6("loadFullScreenAd_isSupported")
|
|
1031
|
+
}
|
|
1032
|
+
);
|
|
1033
|
+
var showFullScreenAd = Object.assign(
|
|
1034
|
+
createEventBridge8("showFullScreenAd"),
|
|
1035
|
+
{
|
|
1036
|
+
isSupported: createConstantBridge6("showFullScreenAd_isSupported")
|
|
1037
|
+
}
|
|
1038
|
+
);
|
|
1039
|
+
|
|
1040
|
+
// src/toss-ad/index.ts
|
|
1041
|
+
import { createAsyncBridge as createAsyncBridge13, createConstantBridge as createConstantBridge7, createEventBridge as createEventBridge9 } from "@apps-in-toss/bridge-core";
|
|
1042
|
+
|
|
1043
|
+
// src/toss-ad/opener.ts
|
|
1044
|
+
import { createAsyncBridge as createAsyncBridge12 } from "@apps-in-toss/bridge-core";
|
|
1045
|
+
var openURL = createAsyncBridge12("openURL");
|
|
1046
|
+
function openUrlOpener(url) {
|
|
1047
|
+
const transformed = getWebSchemeOrUri(url);
|
|
1048
|
+
return openURL(transformed);
|
|
1049
|
+
}
|
|
1050
|
+
function getWebSchemeOrUri(uri) {
|
|
1051
|
+
const isHttp = ["http://", "https://"].some((protocol) => uri.startsWith(protocol));
|
|
1052
|
+
return isHttp ? supertossWeb(uri) : uri;
|
|
1053
|
+
}
|
|
1054
|
+
function supertossWeb(uri) {
|
|
1055
|
+
return `supertoss://web?url=${encodeURIComponent(uri)}&external=true`;
|
|
1056
|
+
}
|
|
1057
|
+
|
|
1058
|
+
// src/toss-ad/scriptLoader.ts
|
|
1059
|
+
var DEFAULT_SDK_URL = "https://static.toss.im/ads/sdk/toss-ads-space-kit-1.3.0.js";
|
|
1060
|
+
var DEFAULT_TIMEOUT_MS = 15e3;
|
|
1061
|
+
var pendingLoad = null;
|
|
1062
|
+
function getAdsSdk() {
|
|
1063
|
+
if (typeof window === "undefined") {
|
|
1064
|
+
return void 0;
|
|
1065
|
+
}
|
|
1066
|
+
return window.TossAdsSpaceKit;
|
|
1067
|
+
}
|
|
1068
|
+
function loadAdsSdk() {
|
|
1069
|
+
if (typeof window === "undefined" || typeof document === "undefined") {
|
|
1070
|
+
return Promise.reject(new Error("Ads SDK can only be loaded in a browser environment."));
|
|
1071
|
+
}
|
|
1072
|
+
const existing = getAdsSdk();
|
|
1073
|
+
if (existing) {
|
|
1074
|
+
return Promise.resolve(existing);
|
|
1075
|
+
}
|
|
1076
|
+
if (pendingLoad) {
|
|
1077
|
+
return pendingLoad;
|
|
1078
|
+
}
|
|
1079
|
+
const promise = new Promise((resolve, reject) => {
|
|
1080
|
+
const script = document.createElement("script");
|
|
1081
|
+
const cleanup = () => {
|
|
1082
|
+
script.removeEventListener("load", handleLoad);
|
|
1083
|
+
script.removeEventListener("error", handleError);
|
|
1084
|
+
window.clearTimeout(timeoutId);
|
|
1085
|
+
pendingLoad = null;
|
|
1086
|
+
};
|
|
1087
|
+
const handleLoad = () => {
|
|
1088
|
+
const sdk = getAdsSdk();
|
|
1089
|
+
if (sdk) {
|
|
1090
|
+
cleanup();
|
|
1091
|
+
resolve(sdk);
|
|
1092
|
+
return;
|
|
1093
|
+
}
|
|
1094
|
+
cleanup();
|
|
1095
|
+
reject(new Error("Ads SDK script loaded but window.TossAdsSpaceKit was not exposed."));
|
|
1096
|
+
};
|
|
1097
|
+
const handleError = () => {
|
|
1098
|
+
cleanup();
|
|
1099
|
+
reject(new Error(`Failed to load Ads SDK script from ${DEFAULT_SDK_URL}.`));
|
|
1100
|
+
};
|
|
1101
|
+
const timeoutId = window.setTimeout(() => {
|
|
1102
|
+
cleanup();
|
|
1103
|
+
reject(new Error(`Loading Ads SDK timed out after ${DEFAULT_TIMEOUT_MS}ms.`));
|
|
1104
|
+
}, DEFAULT_TIMEOUT_MS);
|
|
1105
|
+
script.addEventListener("load", handleLoad);
|
|
1106
|
+
script.addEventListener("error", handleError);
|
|
1107
|
+
script.async = true;
|
|
1108
|
+
script.src = DEFAULT_SDK_URL;
|
|
1109
|
+
document.head.appendChild(script);
|
|
1110
|
+
});
|
|
1111
|
+
pendingLoad = promise;
|
|
1112
|
+
return promise;
|
|
1113
|
+
}
|
|
1114
|
+
|
|
1115
|
+
// src/toss-ad/index.ts
|
|
1116
|
+
var fetchTossAd = Object.assign(createEventBridge9("fetchTossAd"), {
|
|
1117
|
+
isSupported: createConstantBridge7("fetchTossAd_isSupported")
|
|
1118
|
+
});
|
|
1119
|
+
var tossAdEventLog = createAsyncBridge13("tossAdEventLog");
|
|
1120
|
+
var SUPPORTED_STYLE_IDS = /* @__PURE__ */ new Set(["1", "2"]);
|
|
1121
|
+
function fetchTossAdPromise(options) {
|
|
1122
|
+
return new Promise((resolve, reject) => {
|
|
1123
|
+
if (!fetchTossAd.isSupported()) {
|
|
1124
|
+
reject(new Error("fetchTossAd is not supported in this environment."));
|
|
1125
|
+
return;
|
|
1126
|
+
}
|
|
1127
|
+
return fetchTossAd({
|
|
1128
|
+
options,
|
|
1129
|
+
onEvent: resolve,
|
|
1130
|
+
onError: reject
|
|
1131
|
+
});
|
|
1132
|
+
});
|
|
1133
|
+
}
|
|
1134
|
+
function normalizeAdResponse(adResponse) {
|
|
1135
|
+
const ads = Array.isArray(adResponse.ads) ? adResponse.ads.filter((ad) => SUPPORTED_STYLE_IDS.has(String(ad.styleId))) : [];
|
|
1136
|
+
return {
|
|
1137
|
+
requestId: adResponse.requestId ?? "",
|
|
1138
|
+
status: adResponse.status ?? "OK",
|
|
1139
|
+
ads,
|
|
1140
|
+
ext: adResponse.ext
|
|
1141
|
+
};
|
|
1142
|
+
}
|
|
1143
|
+
function normalizeApiResponse(raw) {
|
|
1144
|
+
if (isApiResponse(raw)) {
|
|
1145
|
+
if (raw.resultType !== "SUCCESS") {
|
|
1146
|
+
return raw;
|
|
1147
|
+
}
|
|
1148
|
+
if (!raw.success) {
|
|
1149
|
+
return {
|
|
1150
|
+
resultType: "FAIL",
|
|
1151
|
+
error: { reason: "fetchTossAd returned SUCCESS without payload" }
|
|
1152
|
+
};
|
|
1153
|
+
}
|
|
1154
|
+
return { ...raw, success: normalizeAdResponse(raw.success) };
|
|
1155
|
+
}
|
|
1156
|
+
if (isAdResponse(raw)) {
|
|
1157
|
+
return {
|
|
1158
|
+
resultType: "SUCCESS",
|
|
1159
|
+
success: normalizeAdResponse(raw)
|
|
1160
|
+
};
|
|
1161
|
+
}
|
|
1162
|
+
return { resultType: "FAIL", error: { reason: "Invalid response from fetchTossAd" } };
|
|
1163
|
+
}
|
|
1164
|
+
function isApiResponse(payload) {
|
|
1165
|
+
return Boolean(payload && typeof payload === "object" && "resultType" in payload);
|
|
1166
|
+
}
|
|
1167
|
+
function isAdResponse(payload) {
|
|
1168
|
+
return Boolean(payload && typeof payload === "object" && "ads" in payload);
|
|
1169
|
+
}
|
|
1170
|
+
function createCustomAdFetcher() {
|
|
1171
|
+
return async (_endpoint, request) => {
|
|
1172
|
+
try {
|
|
1173
|
+
const raw = await fetchTossAdPromise({
|
|
1174
|
+
adGroupId: request.spaceUnitId,
|
|
1175
|
+
sdkId: "108",
|
|
1176
|
+
availableStyleIds: ["1", "2"]
|
|
1177
|
+
});
|
|
1178
|
+
return normalizeApiResponse(raw);
|
|
1179
|
+
} catch (error) {
|
|
1180
|
+
return {
|
|
1181
|
+
resultType: "FAIL",
|
|
1182
|
+
error: {
|
|
1183
|
+
reason: error instanceof Error ? error.message : "Unknown fetchTossAd error"
|
|
1184
|
+
}
|
|
1185
|
+
};
|
|
1186
|
+
}
|
|
1187
|
+
};
|
|
1188
|
+
}
|
|
1189
|
+
var pendingLoad2 = null;
|
|
1190
|
+
function initialize(options) {
|
|
1191
|
+
const { callbacks } = options;
|
|
1192
|
+
if (window.TossAdsSpaceKit != null && window.TossAdsSpaceKit.isInitialized()) {
|
|
1193
|
+
callbacks?.onInitializationFailed?.(new Error("[toss-ad] Already initialized."));
|
|
1194
|
+
return;
|
|
1195
|
+
}
|
|
1196
|
+
if (pendingLoad2 != null) {
|
|
1197
|
+
callbacks?.onInitializationFailed?.(new Error("[toss-ad] initialization already in progress."));
|
|
1198
|
+
}
|
|
1199
|
+
const resolveInitialized = () => callbacks?.onInitialized?.();
|
|
1200
|
+
const rejectInitialized = (error) => {
|
|
1201
|
+
const normalizedError = error instanceof Error ? error : new Error(String(error));
|
|
1202
|
+
callbacks?.onInitializationFailed?.(normalizedError);
|
|
1203
|
+
};
|
|
1204
|
+
pendingLoad2 = loadAdsSdk().then((sdk) => {
|
|
1205
|
+
const customAdFetcher = createCustomAdFetcher();
|
|
1206
|
+
const config = { environment: "live", customAdFetcher, opener: openUrlOpener };
|
|
1207
|
+
sdk.init(config);
|
|
1208
|
+
resolveInitialized();
|
|
1209
|
+
}).catch((error) => {
|
|
1210
|
+
pendingLoad2 = null;
|
|
1211
|
+
rejectInitialized(error);
|
|
1212
|
+
});
|
|
1213
|
+
}
|
|
1214
|
+
function attach(adGroupId, target, options = {}) {
|
|
1215
|
+
const { callbacks } = options;
|
|
1216
|
+
const rejectAttached = (error) => {
|
|
1217
|
+
const normalizedError = error instanceof Error ? error : new Error(String(error));
|
|
1218
|
+
callbacks?.onAdFailedToRender?.({
|
|
1219
|
+
slotId: "",
|
|
1220
|
+
adGroupId,
|
|
1221
|
+
adMetadata: {},
|
|
1222
|
+
error: { code: 0, message: normalizedError.message }
|
|
1223
|
+
});
|
|
1224
|
+
};
|
|
1225
|
+
try {
|
|
1226
|
+
const spaceId = adGroupId;
|
|
1227
|
+
const sdk = getAdsSdk();
|
|
1228
|
+
if (!sdk) {
|
|
1229
|
+
throw new Error("[toss-ad] Call initialize() before attaching an ad.");
|
|
1230
|
+
}
|
|
1231
|
+
if (!sdk.banner) {
|
|
1232
|
+
throw new Error("[toss-ad] Loaded TossAdsSpaceKit does not support banner ads.");
|
|
1233
|
+
}
|
|
1234
|
+
const element = typeof target === "string" ? document.querySelector(target) : target;
|
|
1235
|
+
if (!element) {
|
|
1236
|
+
throw new Error(`[toss-ad] Failed to find target element: ${target}`);
|
|
1237
|
+
}
|
|
1238
|
+
const slotOptions = {
|
|
1239
|
+
spaceId,
|
|
1240
|
+
autoLoad: true,
|
|
1241
|
+
theme: options.theme,
|
|
1242
|
+
padding: options.padding,
|
|
1243
|
+
callbacks: wrapCallbacks(adGroupId, options.callbacks)
|
|
1244
|
+
};
|
|
1245
|
+
sdk.banner.createSlot(element, slotOptions);
|
|
1246
|
+
} catch (error) {
|
|
1247
|
+
rejectAttached(error);
|
|
1248
|
+
}
|
|
1249
|
+
}
|
|
1250
|
+
function destroy(slotId) {
|
|
1251
|
+
const sdk = getAdsSdk();
|
|
1252
|
+
if (!sdk?.banner) {
|
|
1253
|
+
return;
|
|
1254
|
+
}
|
|
1255
|
+
sdk.banner.destroy(slotId);
|
|
1256
|
+
}
|
|
1257
|
+
function destroyAll() {
|
|
1258
|
+
const sdk = getAdsSdk();
|
|
1259
|
+
if (!sdk?.banner) {
|
|
1260
|
+
return;
|
|
1261
|
+
}
|
|
1262
|
+
sdk.banner.destroyAll();
|
|
1263
|
+
}
|
|
1264
|
+
function wrapCallbacks(adGroupId, callbacks) {
|
|
1265
|
+
if (!callbacks) {
|
|
1266
|
+
return void 0;
|
|
1267
|
+
}
|
|
1268
|
+
const mapEvent = (payload) => {
|
|
1269
|
+
const next = { ...payload ?? {} };
|
|
1270
|
+
next.adGroupId = next.adGroupId ?? next.spaceId ?? adGroupId;
|
|
1271
|
+
delete next.spaceId;
|
|
1272
|
+
return next;
|
|
1273
|
+
};
|
|
1274
|
+
return {
|
|
1275
|
+
onAdRendered: (payload) => callbacks.onAdRendered?.(mapEvent(payload)),
|
|
1276
|
+
onAdViewable: (payload) => callbacks.onAdViewable?.(mapEvent(payload)),
|
|
1277
|
+
onAdClicked: (payload) => callbacks.onAdClicked?.(mapEvent(payload)),
|
|
1278
|
+
onAdImpression: (payload) => {
|
|
1279
|
+
tossAdEventLog({
|
|
1280
|
+
log_name: "display_ads_all::impression__1px_banner",
|
|
1281
|
+
log_type: "event",
|
|
1282
|
+
params: {
|
|
1283
|
+
event_type: "impression",
|
|
1284
|
+
schema_id: 1812034,
|
|
1285
|
+
request_id: payload?.adMetadata?.requestId ?? ""
|
|
1286
|
+
}
|
|
1287
|
+
});
|
|
1288
|
+
callbacks.onAdImpression?.(mapEvent(payload));
|
|
1289
|
+
},
|
|
1290
|
+
onAdFailedToRender: (payload) => callbacks.onAdFailedToRender?.({
|
|
1291
|
+
...mapEvent(payload),
|
|
1292
|
+
error: payload?.error ?? { code: 0, message: "UNKNOWN" }
|
|
1293
|
+
}),
|
|
1294
|
+
onNoFill: (payload) => callbacks.onNoFill?.(mapEvent(payload))
|
|
1295
|
+
};
|
|
1296
|
+
}
|
|
1297
|
+
var TossAds = {
|
|
1298
|
+
initialize: Object.assign(initialize, {
|
|
1299
|
+
isSupported: fetchTossAd.isSupported
|
|
1300
|
+
}),
|
|
1301
|
+
attach: Object.assign(attach, {
|
|
1302
|
+
isSupported: fetchTossAd.isSupported
|
|
1303
|
+
}),
|
|
1304
|
+
destroy: Object.assign(destroy, {
|
|
1305
|
+
isSupported: fetchTossAd.isSupported
|
|
1306
|
+
}),
|
|
1307
|
+
destroyAll: Object.assign(destroyAll, {
|
|
1308
|
+
isSupported: fetchTossAd.isSupported
|
|
1309
|
+
})
|
|
1310
|
+
};
|
|
1311
|
+
|
|
1025
1312
|
// src/index.ts
|
|
1026
1313
|
export * from "@apps-in-toss/types";
|
|
1027
1314
|
export {
|
|
@@ -1029,6 +1316,7 @@ export {
|
|
|
1029
1316
|
IAP,
|
|
1030
1317
|
SafeAreaInsets,
|
|
1031
1318
|
Storage,
|
|
1319
|
+
TossAds,
|
|
1032
1320
|
appsInTossEvent,
|
|
1033
1321
|
env,
|
|
1034
1322
|
fetchAlbumPhotos,
|
|
@@ -1039,9 +1327,11 @@ export {
|
|
|
1039
1327
|
getSafeAreaInsets,
|
|
1040
1328
|
graniteEvent,
|
|
1041
1329
|
isMinVersionSupported,
|
|
1330
|
+
loadFullScreenAd,
|
|
1042
1331
|
openCamera,
|
|
1043
1332
|
partner,
|
|
1044
1333
|
setClipboardText,
|
|
1334
|
+
showFullScreenAd,
|
|
1045
1335
|
startUpdateLocation,
|
|
1046
1336
|
tdsEvent
|
|
1047
1337
|
};
|
package/package.json
CHANGED
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@apps-in-toss/web-bridge",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "1.
|
|
4
|
+
"version": "1.6.1",
|
|
5
5
|
"description": "Web Bridge for Apps In Toss",
|
|
6
6
|
"scripts": {
|
|
7
|
-
"prepack": "yarn build",
|
|
8
7
|
"typecheck": "tsc --noEmit",
|
|
9
8
|
"lint": "eslint .",
|
|
10
9
|
"build": "tsup"
|
|
@@ -28,11 +27,11 @@
|
|
|
28
27
|
"built"
|
|
29
28
|
],
|
|
30
29
|
"dependencies": {
|
|
31
|
-
"@apps-in-toss/types": "1.
|
|
30
|
+
"@apps-in-toss/types": "1.6.1"
|
|
32
31
|
},
|
|
33
32
|
"devDependencies": {
|
|
34
|
-
"@apps-in-toss/bridge-core": "1.
|
|
35
|
-
"@apps-in-toss/framework": "1.
|
|
33
|
+
"@apps-in-toss/bridge-core": "1.6.1",
|
|
34
|
+
"@apps-in-toss/framework": "1.6.1",
|
|
36
35
|
"@swc/core": "^1.12.7",
|
|
37
36
|
"picocolors": "^1.1.1",
|
|
38
37
|
"ts-morph": "^26.0.0",
|
|
@@ -42,9 +41,5 @@
|
|
|
42
41
|
},
|
|
43
42
|
"peerDependencies": {
|
|
44
43
|
"@apps-in-toss/bridge-core": "*"
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
"access": "public"
|
|
48
|
-
},
|
|
49
|
-
"gitHead": "b6152cb5bd176d6fd1863ff00638b38f17269e09"
|
|
50
|
-
}
|
|
44
|
+
}
|
|
45
|
+
}
|