@apps-in-toss/web-bridge 1.10.1 → 1.11.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/dist/index.cjs CHANGED
@@ -1072,26 +1072,33 @@ function createCustomAdFetcher() {
1072
1072
  var pendingLoad2 = null;
1073
1073
  function initialize(options) {
1074
1074
  const { callbacks } = options;
1075
- if (window.TossAdsSpaceKit != null && window.TossAdsSpaceKit.isInitialized()) {
1076
- callbacks?.onInitializationFailed?.(new Error("[toss-ad] Already initialized."));
1077
- return;
1078
- }
1079
- if (pendingLoad2 != null) {
1080
- callbacks?.onInitializationFailed?.(new Error("[toss-ad] initialization already in progress."));
1081
- }
1082
1075
  const resolveInitialized = () => callbacks?.onInitialized?.();
1083
1076
  const rejectInitialized = (error) => {
1084
1077
  const normalizedError = error instanceof Error ? error : new Error(String(error));
1085
1078
  callbacks?.onInitializationFailed?.(normalizedError);
1086
1079
  };
1087
- pendingLoad2 = loadAdsSdk().then((sdk) => {
1080
+ const existingSdk = getAdsSdk();
1081
+ if (existingSdk?.isInitialized()) {
1082
+ resolveInitialized();
1083
+ return;
1084
+ }
1085
+ if (pendingLoad2 != null) {
1086
+ pendingLoad2.then(resolveInitialized).catch(rejectInitialized);
1087
+ return;
1088
+ }
1089
+ const initPromise = loadAdsSdk().then((sdk) => {
1090
+ if (sdk.isInitialized()) {
1091
+ return;
1092
+ }
1088
1093
  const customAdFetcher = createCustomAdFetcher();
1089
1094
  const config = { environment: "live", customAdFetcher, opener: openUrlOpener };
1090
1095
  sdk.init(config);
1091
- resolveInitialized();
1092
- }).catch((error) => {
1093
- pendingLoad2 = null;
1094
- rejectInitialized(error);
1096
+ });
1097
+ pendingLoad2 = initPromise;
1098
+ initPromise.then(resolveInitialized).catch(rejectInitialized).finally(() => {
1099
+ if (pendingLoad2 === initPromise) {
1100
+ pendingLoad2 = null;
1101
+ }
1095
1102
  });
1096
1103
  }
1097
1104
  function attach(adGroupId, target, options = {}) {
@@ -1130,6 +1137,131 @@ function attach(adGroupId, target, options = {}) {
1130
1137
  rejectAttached(error);
1131
1138
  }
1132
1139
  }
1140
+ var DEFAULT_ATTACH_PADDING_BANNER = "16px 20px";
1141
+ var DEFAULT_ATTACH_PADDING_NATIVE_IMAGE = "20px";
1142
+ var DEFAULT_ATTACH_THEME = "auto";
1143
+ var DEFAULT_ATTACH_TONE = "blackAndWhite";
1144
+ var DEFAULT_ATTACH_VARIANT = "expanded";
1145
+ var ATTACH_CLASS_NAME = "toss-ads-attach";
1146
+ var ATTACH_STYLE_ID = "toss-ads-attach-style";
1147
+ function ensureAttachStyles(container) {
1148
+ const documentRef = container.ownerDocument;
1149
+ if (!documentRef) {
1150
+ return;
1151
+ }
1152
+ if (documentRef.getElementById(ATTACH_STYLE_ID)) {
1153
+ return;
1154
+ }
1155
+ const style = documentRef.createElement("style");
1156
+ style.id = ATTACH_STYLE_ID;
1157
+ style.textContent = `
1158
+ .${ATTACH_CLASS_NAME} { background: #ffffff; }
1159
+ .${ATTACH_CLASS_NAME}.toss-ads-tone-grey { background: #f2f4f7; }
1160
+ @media (prefers-color-scheme: dark) {
1161
+ .${ATTACH_CLASS_NAME} { background: #17171c; }
1162
+ .${ATTACH_CLASS_NAME}.toss-ads-tone-grey { background: #101013; }
1163
+ }
1164
+ .${ATTACH_CLASS_NAME}.toss-ads-theme-light { background: #ffffff; }
1165
+ .${ATTACH_CLASS_NAME}.toss-ads-theme-light.toss-ads-tone-grey { background: #f2f4f7; }
1166
+ .${ATTACH_CLASS_NAME}.toss-ads-theme-dark { background: #17171c; }
1167
+ .${ATTACH_CLASS_NAME}.toss-ads-theme-dark.toss-ads-tone-grey { background: #101013; }
1168
+ `;
1169
+ const styleContainer = documentRef.head ?? documentRef.body ?? documentRef.documentElement;
1170
+ if (!styleContainer) {
1171
+ return;
1172
+ }
1173
+ styleContainer.appendChild(style);
1174
+ }
1175
+ function attachBanner(adGroupId, target, options = {}) {
1176
+ const {
1177
+ callbacks,
1178
+ theme = DEFAULT_ATTACH_THEME,
1179
+ tone = DEFAULT_ATTACH_TONE,
1180
+ variant = DEFAULT_ATTACH_VARIANT
1181
+ } = options;
1182
+ const wrapper = document.createElement("div");
1183
+ wrapper.style.width = "100%";
1184
+ wrapper.style.height = "100%";
1185
+ wrapper.style.boxSizing = "border-box";
1186
+ wrapper.style.display = "flex";
1187
+ wrapper.style.flexDirection = "column";
1188
+ wrapper.style.justifyContent = "center";
1189
+ wrapper.style.overflow = "hidden";
1190
+ if (variant === "card") {
1191
+ wrapper.style.padding = "0 10px";
1192
+ }
1193
+ const element = document.createElement("div");
1194
+ element.classList.add(ATTACH_CLASS_NAME);
1195
+ if (tone === "grey") {
1196
+ element.classList.add("toss-ads-tone-grey");
1197
+ }
1198
+ if (theme === "light") {
1199
+ element.classList.add("toss-ads-theme-light");
1200
+ } else if (theme === "dark") {
1201
+ element.classList.add("toss-ads-theme-dark");
1202
+ }
1203
+ if (variant === "card") {
1204
+ element.style.borderRadius = "16px";
1205
+ element.style.overflow = "hidden";
1206
+ }
1207
+ wrapper.appendChild(element);
1208
+ let isAttached = false;
1209
+ let slot = null;
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
+ const wrappedCallbacks = wrapCallbacks(adGroupId, callbacks);
1220
+ try {
1221
+ const spaceId = adGroupId;
1222
+ const sdk = getAdsSdk();
1223
+ if (!sdk) {
1224
+ throw new Error("[toss-ad] Call initialize() before attaching an ad.");
1225
+ }
1226
+ if (!sdk.banner) {
1227
+ throw new Error("[toss-ad] Loaded TossAdsSpaceKit does not support banner ads.");
1228
+ }
1229
+ const container = typeof target === "string" ? document.querySelector(target) : target;
1230
+ if (!container) {
1231
+ throw new Error(`[toss-ad] Failed to find target element: ${target}`);
1232
+ }
1233
+ ensureAttachStyles(container);
1234
+ container.appendChild(wrapper);
1235
+ isAttached = true;
1236
+ const slotOptions = {
1237
+ spaceId,
1238
+ autoLoad: true,
1239
+ theme: theme === "auto" ? void 0 : theme,
1240
+ renderPadding: (styleId) => {
1241
+ if (styleId === "1") {
1242
+ return DEFAULT_ATTACH_PADDING_BANNER;
1243
+ } else {
1244
+ return DEFAULT_ATTACH_PADDING_NATIVE_IMAGE;
1245
+ }
1246
+ },
1247
+ callbacks: wrappedCallbacks
1248
+ };
1249
+ slot = sdk.banner.createSlot(element, slotOptions);
1250
+ } catch (error) {
1251
+ if (isAttached && wrapper.parentNode) {
1252
+ wrapper.parentNode.removeChild(wrapper);
1253
+ }
1254
+ rejectAttached(error);
1255
+ }
1256
+ return {
1257
+ destroy() {
1258
+ slot?.destroy();
1259
+ if (isAttached && wrapper.parentNode) {
1260
+ wrapper.parentNode.removeChild(wrapper);
1261
+ }
1262
+ }
1263
+ };
1264
+ }
1133
1265
  function destroy(slotId) {
1134
1266
  const sdk = getAdsSdk();
1135
1267
  if (!sdk?.banner) {
@@ -1184,6 +1316,9 @@ var TossAds = {
1184
1316
  attach: Object.assign(attach, {
1185
1317
  isSupported: fetchTossAd.isSupported
1186
1318
  }),
1319
+ attachBanner: Object.assign(attachBanner, {
1320
+ isSupported: fetchTossAd.isSupported
1321
+ }),
1187
1322
  destroy: Object.assign(destroy, {
1188
1323
  isSupported: fetchTossAd.isSupported
1189
1324
  }),
package/dist/index.d.cts CHANGED
@@ -842,6 +842,7 @@ interface BannerSlotOptions {
842
842
  refetchIntervalMs?: number;
843
843
  theme?: 'light' | 'dark';
844
844
  padding?: string;
845
+ renderPadding?: (styleId: string) => string;
845
846
  callbacks?: BannerSlotCallbacks;
846
847
  }
847
848
  interface BannerSlot {
@@ -868,9 +869,19 @@ interface AttachOptions {
868
869
  padding?: string;
869
870
  callbacks?: BannerSlotCallbacks;
870
871
  }
872
+ interface AttachBannerOptions {
873
+ theme?: 'auto' | 'light' | 'dark';
874
+ tone?: 'blackAndWhite' | 'grey';
875
+ variant?: 'card' | 'expanded';
876
+ callbacks?: BannerSlotCallbacks;
877
+ }
878
+ interface AttachBannerResult {
879
+ destroy: () => void;
880
+ }
871
881
 
872
882
  declare function initialize(options: InitializeOptions): void;
873
883
  declare function attach(adGroupId: string, target: string | HTMLElement, options?: AttachOptions): void;
884
+ declare function attachBanner(adGroupId: string, target: string | HTMLElement, options?: AttachBannerOptions): AttachBannerResult;
874
885
  declare function destroy(slotId: string): void;
875
886
  declare function destroyAll(): void;
876
887
  declare const TossAds: {
@@ -880,6 +891,9 @@ declare const TossAds: {
880
891
  attach: typeof attach & {
881
892
  isSupported: () => boolean;
882
893
  };
894
+ attachBanner: typeof attachBanner & {
895
+ isSupported: () => boolean;
896
+ };
883
897
  destroy: typeof destroy & {
884
898
  isSupported: () => boolean;
885
899
  };
@@ -892,4 +906,4 @@ declare const getServerTime: (() => Promise<number | undefined>) & {
892
906
  isSupported: () => boolean;
893
907
  };
894
908
 
895
- 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, getServerTime, graniteEvent, isMinVersionSupported, loadFullScreenAd, openCamera, partner, setClipboardText, showFullScreenAd, startUpdateLocation, tdsEvent };
909
+ 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 AttachBannerOptions as TossAdsAttachBannerOptions, type AttachBannerResult as TossAdsAttachBannerResult, 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, getServerTime, graniteEvent, isMinVersionSupported, loadFullScreenAd, openCamera, partner, setClipboardText, showFullScreenAd, startUpdateLocation, tdsEvent };
package/dist/index.d.ts CHANGED
@@ -842,6 +842,7 @@ interface BannerSlotOptions {
842
842
  refetchIntervalMs?: number;
843
843
  theme?: 'light' | 'dark';
844
844
  padding?: string;
845
+ renderPadding?: (styleId: string) => string;
845
846
  callbacks?: BannerSlotCallbacks;
846
847
  }
847
848
  interface BannerSlot {
@@ -868,9 +869,19 @@ interface AttachOptions {
868
869
  padding?: string;
869
870
  callbacks?: BannerSlotCallbacks;
870
871
  }
872
+ interface AttachBannerOptions {
873
+ theme?: 'auto' | 'light' | 'dark';
874
+ tone?: 'blackAndWhite' | 'grey';
875
+ variant?: 'card' | 'expanded';
876
+ callbacks?: BannerSlotCallbacks;
877
+ }
878
+ interface AttachBannerResult {
879
+ destroy: () => void;
880
+ }
871
881
 
872
882
  declare function initialize(options: InitializeOptions): void;
873
883
  declare function attach(adGroupId: string, target: string | HTMLElement, options?: AttachOptions): void;
884
+ declare function attachBanner(adGroupId: string, target: string | HTMLElement, options?: AttachBannerOptions): AttachBannerResult;
874
885
  declare function destroy(slotId: string): void;
875
886
  declare function destroyAll(): void;
876
887
  declare const TossAds: {
@@ -880,6 +891,9 @@ declare const TossAds: {
880
891
  attach: typeof attach & {
881
892
  isSupported: () => boolean;
882
893
  };
894
+ attachBanner: typeof attachBanner & {
895
+ isSupported: () => boolean;
896
+ };
883
897
  destroy: typeof destroy & {
884
898
  isSupported: () => boolean;
885
899
  };
@@ -892,4 +906,4 @@ declare const getServerTime: (() => Promise<number | undefined>) & {
892
906
  isSupported: () => boolean;
893
907
  };
894
908
 
895
- 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, getServerTime, graniteEvent, isMinVersionSupported, loadFullScreenAd, openCamera, partner, setClipboardText, showFullScreenAd, startUpdateLocation, tdsEvent };
909
+ 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 AttachBannerOptions as TossAdsAttachBannerOptions, type AttachBannerResult as TossAdsAttachBannerResult, 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, getServerTime, graniteEvent, isMinVersionSupported, loadFullScreenAd, openCamera, partner, setClipboardText, showFullScreenAd, startUpdateLocation, tdsEvent };
package/dist/index.js CHANGED
@@ -1025,26 +1025,33 @@ function createCustomAdFetcher() {
1025
1025
  var pendingLoad2 = null;
1026
1026
  function initialize(options) {
1027
1027
  const { callbacks } = options;
1028
- if (window.TossAdsSpaceKit != null && window.TossAdsSpaceKit.isInitialized()) {
1029
- callbacks?.onInitializationFailed?.(new Error("[toss-ad] Already initialized."));
1030
- return;
1031
- }
1032
- if (pendingLoad2 != null) {
1033
- callbacks?.onInitializationFailed?.(new Error("[toss-ad] initialization already in progress."));
1034
- }
1035
1028
  const resolveInitialized = () => callbacks?.onInitialized?.();
1036
1029
  const rejectInitialized = (error) => {
1037
1030
  const normalizedError = error instanceof Error ? error : new Error(String(error));
1038
1031
  callbacks?.onInitializationFailed?.(normalizedError);
1039
1032
  };
1040
- pendingLoad2 = loadAdsSdk().then((sdk) => {
1033
+ const existingSdk = getAdsSdk();
1034
+ if (existingSdk?.isInitialized()) {
1035
+ resolveInitialized();
1036
+ return;
1037
+ }
1038
+ if (pendingLoad2 != null) {
1039
+ pendingLoad2.then(resolveInitialized).catch(rejectInitialized);
1040
+ return;
1041
+ }
1042
+ const initPromise = loadAdsSdk().then((sdk) => {
1043
+ if (sdk.isInitialized()) {
1044
+ return;
1045
+ }
1041
1046
  const customAdFetcher = createCustomAdFetcher();
1042
1047
  const config = { environment: "live", customAdFetcher, opener: openUrlOpener };
1043
1048
  sdk.init(config);
1044
- resolveInitialized();
1045
- }).catch((error) => {
1046
- pendingLoad2 = null;
1047
- rejectInitialized(error);
1049
+ });
1050
+ pendingLoad2 = initPromise;
1051
+ initPromise.then(resolveInitialized).catch(rejectInitialized).finally(() => {
1052
+ if (pendingLoad2 === initPromise) {
1053
+ pendingLoad2 = null;
1054
+ }
1048
1055
  });
1049
1056
  }
1050
1057
  function attach(adGroupId, target, options = {}) {
@@ -1083,6 +1090,131 @@ function attach(adGroupId, target, options = {}) {
1083
1090
  rejectAttached(error);
1084
1091
  }
1085
1092
  }
1093
+ var DEFAULT_ATTACH_PADDING_BANNER = "16px 20px";
1094
+ var DEFAULT_ATTACH_PADDING_NATIVE_IMAGE = "20px";
1095
+ var DEFAULT_ATTACH_THEME = "auto";
1096
+ var DEFAULT_ATTACH_TONE = "blackAndWhite";
1097
+ var DEFAULT_ATTACH_VARIANT = "expanded";
1098
+ var ATTACH_CLASS_NAME = "toss-ads-attach";
1099
+ var ATTACH_STYLE_ID = "toss-ads-attach-style";
1100
+ function ensureAttachStyles(container) {
1101
+ const documentRef = container.ownerDocument;
1102
+ if (!documentRef) {
1103
+ return;
1104
+ }
1105
+ if (documentRef.getElementById(ATTACH_STYLE_ID)) {
1106
+ return;
1107
+ }
1108
+ const style = documentRef.createElement("style");
1109
+ style.id = ATTACH_STYLE_ID;
1110
+ style.textContent = `
1111
+ .${ATTACH_CLASS_NAME} { background: #ffffff; }
1112
+ .${ATTACH_CLASS_NAME}.toss-ads-tone-grey { background: #f2f4f7; }
1113
+ @media (prefers-color-scheme: dark) {
1114
+ .${ATTACH_CLASS_NAME} { background: #17171c; }
1115
+ .${ATTACH_CLASS_NAME}.toss-ads-tone-grey { background: #101013; }
1116
+ }
1117
+ .${ATTACH_CLASS_NAME}.toss-ads-theme-light { background: #ffffff; }
1118
+ .${ATTACH_CLASS_NAME}.toss-ads-theme-light.toss-ads-tone-grey { background: #f2f4f7; }
1119
+ .${ATTACH_CLASS_NAME}.toss-ads-theme-dark { background: #17171c; }
1120
+ .${ATTACH_CLASS_NAME}.toss-ads-theme-dark.toss-ads-tone-grey { background: #101013; }
1121
+ `;
1122
+ const styleContainer = documentRef.head ?? documentRef.body ?? documentRef.documentElement;
1123
+ if (!styleContainer) {
1124
+ return;
1125
+ }
1126
+ styleContainer.appendChild(style);
1127
+ }
1128
+ function attachBanner(adGroupId, target, options = {}) {
1129
+ const {
1130
+ callbacks,
1131
+ theme = DEFAULT_ATTACH_THEME,
1132
+ tone = DEFAULT_ATTACH_TONE,
1133
+ variant = DEFAULT_ATTACH_VARIANT
1134
+ } = options;
1135
+ const wrapper = document.createElement("div");
1136
+ wrapper.style.width = "100%";
1137
+ wrapper.style.height = "100%";
1138
+ wrapper.style.boxSizing = "border-box";
1139
+ wrapper.style.display = "flex";
1140
+ wrapper.style.flexDirection = "column";
1141
+ wrapper.style.justifyContent = "center";
1142
+ wrapper.style.overflow = "hidden";
1143
+ if (variant === "card") {
1144
+ wrapper.style.padding = "0 10px";
1145
+ }
1146
+ const element = document.createElement("div");
1147
+ element.classList.add(ATTACH_CLASS_NAME);
1148
+ if (tone === "grey") {
1149
+ element.classList.add("toss-ads-tone-grey");
1150
+ }
1151
+ if (theme === "light") {
1152
+ element.classList.add("toss-ads-theme-light");
1153
+ } else if (theme === "dark") {
1154
+ element.classList.add("toss-ads-theme-dark");
1155
+ }
1156
+ if (variant === "card") {
1157
+ element.style.borderRadius = "16px";
1158
+ element.style.overflow = "hidden";
1159
+ }
1160
+ wrapper.appendChild(element);
1161
+ let isAttached = false;
1162
+ let slot = null;
1163
+ const rejectAttached = (error) => {
1164
+ const normalizedError = error instanceof Error ? error : new Error(String(error));
1165
+ callbacks?.onAdFailedToRender?.({
1166
+ slotId: "",
1167
+ adGroupId,
1168
+ adMetadata: {},
1169
+ error: { code: 0, message: normalizedError.message }
1170
+ });
1171
+ };
1172
+ const wrappedCallbacks = wrapCallbacks(adGroupId, callbacks);
1173
+ try {
1174
+ const spaceId = adGroupId;
1175
+ const sdk = getAdsSdk();
1176
+ if (!sdk) {
1177
+ throw new Error("[toss-ad] Call initialize() before attaching an ad.");
1178
+ }
1179
+ if (!sdk.banner) {
1180
+ throw new Error("[toss-ad] Loaded TossAdsSpaceKit does not support banner ads.");
1181
+ }
1182
+ const container = typeof target === "string" ? document.querySelector(target) : target;
1183
+ if (!container) {
1184
+ throw new Error(`[toss-ad] Failed to find target element: ${target}`);
1185
+ }
1186
+ ensureAttachStyles(container);
1187
+ container.appendChild(wrapper);
1188
+ isAttached = true;
1189
+ const slotOptions = {
1190
+ spaceId,
1191
+ autoLoad: true,
1192
+ theme: theme === "auto" ? void 0 : theme,
1193
+ renderPadding: (styleId) => {
1194
+ if (styleId === "1") {
1195
+ return DEFAULT_ATTACH_PADDING_BANNER;
1196
+ } else {
1197
+ return DEFAULT_ATTACH_PADDING_NATIVE_IMAGE;
1198
+ }
1199
+ },
1200
+ callbacks: wrappedCallbacks
1201
+ };
1202
+ slot = sdk.banner.createSlot(element, slotOptions);
1203
+ } catch (error) {
1204
+ if (isAttached && wrapper.parentNode) {
1205
+ wrapper.parentNode.removeChild(wrapper);
1206
+ }
1207
+ rejectAttached(error);
1208
+ }
1209
+ return {
1210
+ destroy() {
1211
+ slot?.destroy();
1212
+ if (isAttached && wrapper.parentNode) {
1213
+ wrapper.parentNode.removeChild(wrapper);
1214
+ }
1215
+ }
1216
+ };
1217
+ }
1086
1218
  function destroy(slotId) {
1087
1219
  const sdk = getAdsSdk();
1088
1220
  if (!sdk?.banner) {
@@ -1137,6 +1269,9 @@ var TossAds = {
1137
1269
  attach: Object.assign(attach, {
1138
1270
  isSupported: fetchTossAd.isSupported
1139
1271
  }),
1272
+ attachBanner: Object.assign(attachBanner, {
1273
+ isSupported: fetchTossAd.isSupported
1274
+ }),
1140
1275
  destroy: Object.assign(destroy, {
1141
1276
  isSupported: fetchTossAd.isSupported
1142
1277
  }),
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.10.1",
4
+ "version": "1.11.0",
5
5
  "description": "Web Bridge for Apps In Toss",
6
6
  "scripts": {
7
7
  "typecheck": "tsc --noEmit",
@@ -27,11 +27,11 @@
27
27
  "dist"
28
28
  ],
29
29
  "dependencies": {
30
- "@apps-in-toss/types": "1.10.1"
30
+ "@apps-in-toss/types": "1.11.0"
31
31
  },
32
32
  "devDependencies": {
33
- "@apps-in-toss/bridge-core": "1.10.1",
34
- "@apps-in-toss/native-modules": "^1.10.1",
33
+ "@apps-in-toss/bridge-core": "1.11.0",
34
+ "@apps-in-toss/native-modules": "^1.11.0",
35
35
  "@swc/core": "^1.12.7",
36
36
  "picocolors": "^1.1.1",
37
37
  "ts-morph": "^26.0.0",