@apps-in-toss/web-framework 0.0.21 → 0.0.23
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/cli/index.js +4 -4
- package/dist/config/index.js +1 -0
- package/dist/prebuilt/dev.android.js +44463 -43819
- package/dist/prebuilt/dev.ios.js +44457 -43813
- package/dist/prebuilt/prod.android.js +1 -1
- package/dist/prebuilt/prod.ios.js +1 -1
- package/dist/prebuilt/prod.json +6 -6
- package/dist-web/bridge.d.ts +2 -1
- package/dist-web/bridge.js +1 -1
- package/dist-web/checkoutPayment.d.ts +41 -91
- package/dist-web/eventLog.d.ts +43 -0
- package/dist-web/getTossShareLink.d.ts +32 -0
- package/dist-web/index.d.ts +347 -69
- package/dist-web/index.js +393 -142
- package/package.json +16 -13
- package/dist-web/executePayment.d.ts +0 -266
package/dist-web/index.js
CHANGED
|
@@ -1,144 +1,10 @@
|
|
|
1
1
|
export * from './bridge.js'
|
|
2
2
|
|
|
3
|
-
// src-web/
|
|
4
|
-
|
|
5
|
-
get _window() {
|
|
6
|
-
return window;
|
|
7
|
-
}
|
|
8
|
-
/**
|
|
9
|
-
* ReactNativeWebView를 이용해 메시지를 전송합니다.
|
|
10
|
-
* @param message 전송할 메시지(JSON 문자열)
|
|
11
|
-
* @example
|
|
12
|
-
* const nativeWindow = new NativeWindow();
|
|
13
|
-
* nativeWindow.postMessage({ type: 'method', functionName: 'getDeviceId', eventId: '123', args: [] });
|
|
14
|
-
*/
|
|
15
|
-
postMessage(message) {
|
|
16
|
-
const webView = this._window.ReactNativeWebView;
|
|
17
|
-
if (!webView) {
|
|
18
|
-
throw new Error("ReactNativeWebView is not available in browser environment");
|
|
19
|
-
}
|
|
20
|
-
webView.postMessage(JSON.stringify(message));
|
|
21
|
-
}
|
|
22
|
-
/**
|
|
23
|
-
* __BEDROCK_NATIVE_EMITTER를 이용해 이벤트 리스너를 등록합니다.
|
|
24
|
-
* @param event 이벤트 이름
|
|
25
|
-
* @param callback 데이터가 도착했을 때 호출되는 콜백
|
|
26
|
-
* @returns 리스너 해제 함수
|
|
27
|
-
* @example
|
|
28
|
-
* const nativeWindow = new NativeWindow();
|
|
29
|
-
* const unsubscribe = nativeWindow.on('deviceInfo', (data) => {
|
|
30
|
-
* console.log('Device info received:', data);
|
|
31
|
-
* });
|
|
32
|
-
*
|
|
33
|
-
* // 리스너 해제
|
|
34
|
-
* unsubscribe();
|
|
35
|
-
*/
|
|
36
|
-
on(event, callback) {
|
|
37
|
-
const emitter = this._window.__BEDROCK_NATIVE_EMITTER;
|
|
38
|
-
if (!emitter) {
|
|
39
|
-
throw new Error("__BEDROCK_NATIVE_EMITTER is not available");
|
|
40
|
-
}
|
|
41
|
-
return emitter.on(event, callback);
|
|
42
|
-
}
|
|
43
|
-
/**
|
|
44
|
-
* __CONSTANT_HANDLER_MAP에 등록된 상수 값을 반환합니다.
|
|
45
|
-
* @param method 상수 핸들러 이름
|
|
46
|
-
* @returns 상수 값
|
|
47
|
-
* @example
|
|
48
|
-
* const nativeWindow = new NativeWindow();
|
|
49
|
-
* const deviceId = nativeWindow.getConstant('getDeviceId');
|
|
50
|
-
* console.log('Device ID:', deviceId);
|
|
51
|
-
*/
|
|
52
|
-
getConstant(method) {
|
|
53
|
-
const constantHandlerMap = this._window.__CONSTANT_HANDLER_MAP;
|
|
54
|
-
if (constantHandlerMap && method in constantHandlerMap) {
|
|
55
|
-
return constantHandlerMap[method];
|
|
56
|
-
}
|
|
57
|
-
throw new Error(`${method} is not a constant handler`);
|
|
58
|
-
}
|
|
59
|
-
};
|
|
60
|
-
var nativeWindow = new NativeWindow();
|
|
61
|
-
var createEventId = () => Math.random().toString(36).substring(2, 15);
|
|
62
|
-
var deserializeError = (value) => {
|
|
63
|
-
if (value && value.__isError) {
|
|
64
|
-
const err = new Error(value.message);
|
|
65
|
-
err.name = value.name;
|
|
66
|
-
err.stack = value.stack;
|
|
67
|
-
return err;
|
|
68
|
-
}
|
|
69
|
-
return value;
|
|
70
|
-
};
|
|
71
|
-
|
|
72
|
-
// src-web/createAsyncBridge.ts
|
|
73
|
-
function createAsyncBridge(method) {
|
|
74
|
-
return (...args) => {
|
|
75
|
-
const eventId = createEventId();
|
|
76
|
-
const emitters = [];
|
|
77
|
-
const unsubscribe = () => {
|
|
78
|
-
for (const remove of emitters) {
|
|
79
|
-
remove();
|
|
80
|
-
}
|
|
81
|
-
};
|
|
82
|
-
return new Promise((resolve, reject) => {
|
|
83
|
-
emitters.push(
|
|
84
|
-
nativeWindow.on(`${method}/resolve/${eventId}`, (data) => {
|
|
85
|
-
unsubscribe();
|
|
86
|
-
resolve(data);
|
|
87
|
-
})
|
|
88
|
-
);
|
|
89
|
-
emitters.push(
|
|
90
|
-
nativeWindow.on(`${method}/reject/${eventId}`, (error) => {
|
|
91
|
-
unsubscribe();
|
|
92
|
-
reject(deserializeError(error));
|
|
93
|
-
})
|
|
94
|
-
);
|
|
95
|
-
nativeWindow.postMessage({
|
|
96
|
-
type: "method",
|
|
97
|
-
functionName: method,
|
|
98
|
-
eventId,
|
|
99
|
-
args
|
|
100
|
-
});
|
|
101
|
-
});
|
|
102
|
-
};
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
// src-web/createConstantBridge.ts
|
|
106
|
-
function createConstantBridge(method) {
|
|
107
|
-
return () => {
|
|
108
|
-
return nativeWindow.getConstant(method);
|
|
109
|
-
};
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
// src-web/createEventBridge.ts
|
|
113
|
-
function createEventBridge(method) {
|
|
114
|
-
return (args) => {
|
|
115
|
-
const eventId = createEventId();
|
|
116
|
-
const removes = [
|
|
117
|
-
nativeWindow.on(`${method}/onEvent/${eventId}`, (data) => {
|
|
118
|
-
args.onEvent(data);
|
|
119
|
-
}),
|
|
120
|
-
nativeWindow.on(`${method}/onError/${eventId}`, (error) => {
|
|
121
|
-
args.onError(deserializeError(error));
|
|
122
|
-
})
|
|
123
|
-
];
|
|
124
|
-
nativeWindow.postMessage({
|
|
125
|
-
type: "addEventListener",
|
|
126
|
-
functionName: method,
|
|
127
|
-
eventId,
|
|
128
|
-
args: args.options
|
|
129
|
-
});
|
|
130
|
-
return () => {
|
|
131
|
-
nativeWindow.postMessage({
|
|
132
|
-
type: "removeEventListener",
|
|
133
|
-
functionName: method,
|
|
134
|
-
eventId
|
|
135
|
-
});
|
|
136
|
-
removes.forEach((remove) => remove());
|
|
137
|
-
};
|
|
138
|
-
};
|
|
139
|
-
}
|
|
3
|
+
// src-web/index.ts
|
|
4
|
+
export * from "@apps-in-toss/bridge-core";
|
|
140
5
|
|
|
141
6
|
// src-web/storage.ts
|
|
7
|
+
import { createAsyncBridge } from "@apps-in-toss/bridge-core";
|
|
142
8
|
var Storage = {
|
|
143
9
|
/**
|
|
144
10
|
* @public
|
|
@@ -210,19 +76,404 @@ var Storage = {
|
|
|
210
76
|
};
|
|
211
77
|
|
|
212
78
|
// src-web/getSafeAreaInsets.ts
|
|
79
|
+
import { createConstantBridge } from "@apps-in-toss/bridge-core";
|
|
213
80
|
var getSafeAreaBottom = createConstantBridge("getSafeAreaBottom");
|
|
214
81
|
var getSafeAreaTop = createConstantBridge("getSafeAreaTop");
|
|
215
82
|
function getSafeAreaInsets() {
|
|
216
83
|
return { top: getSafeAreaTop(), bottom: getSafeAreaBottom() };
|
|
217
84
|
}
|
|
218
85
|
|
|
86
|
+
// src-web/googleAdMob.ts
|
|
87
|
+
import { createEventBridge, createConstantBridge as createConstantBridge2 } from "@apps-in-toss/bridge-core";
|
|
88
|
+
var GoogleAdMob = {
|
|
89
|
+
/**
|
|
90
|
+
* @public
|
|
91
|
+
* @category 광고
|
|
92
|
+
* @name loadAdMobInterstitialAd
|
|
93
|
+
* @description 앱 화면 전체를 덮는 전면 광고를 미리 불러와서, 광고가 필요한 시점에 바로 보여줄 수 있도록 준비하는 함수예요.
|
|
94
|
+
* @param {LoadAdMobInterstitialAdParams} params 광고를 불러올 때 사용할 설정 값이에요. 광고 ID와 광고의 동작에 대한 콜백을 설정할 수 있어요.
|
|
95
|
+
* @param {LoadAdMobInterstitialAdOptions} params.options 광고를 불러올 때 전달할 옵션 객체예요.
|
|
96
|
+
* @param {string} params.options.adUnitId 광고 단위 ID예요. 발급받은 전면 광고용 ID를 입력해요.
|
|
97
|
+
* @param {(event: LoadAdMobInterstitialAdEvent) => void} [params.onEvent] 광고 관련 이벤트가 발생했을 때 호출돼요. (예시: 광고가 닫히거나 클릭됐을 때). 자세한 이벤트 타입은 [LoadAdMobInterstitialAdEvent](/react-native/reference/framework/광고/LoadAdMobInterstitialAdEvent.html)를 참고하세요.
|
|
98
|
+
* @param {(reason: unknown) => void} [params.onError] 광고를 불러오지 못했을 때 호출돼요. (예시: 네트워크 오류나 지원하지 않는 환경일 때)
|
|
99
|
+
* @property {() => boolean} [isSupported] 현재 실행 중인 앱(예: 토스 앱, 개발용 샌드박스 앱 등)에서 Google AdMob 광고 기능을 지원하는지 확인하는 함수예요. 기능을 사용하기 전에 지원 여부를 확인해야 해요.
|
|
100
|
+
*
|
|
101
|
+
* @example
|
|
102
|
+
* ### 뷰 진입 시 전면광고 불러오기
|
|
103
|
+
* ```tsx
|
|
104
|
+
* import { GoogleAdMob } from '@apps-in-toss/framework';
|
|
105
|
+
* import { useEffect } from 'react';
|
|
106
|
+
* import { View, Text } from 'react-native';
|
|
107
|
+
*
|
|
108
|
+
* const AD_UNIT_ID = '<YOUR_AD_UNIT_ID>';
|
|
109
|
+
*
|
|
110
|
+
* function Page() {
|
|
111
|
+
* useEffect(() => {
|
|
112
|
+
* if (GoogleAdMob.loadAdMobInterstitialAd.isSupported() !== true) {
|
|
113
|
+
* return;
|
|
114
|
+
* }
|
|
115
|
+
*
|
|
116
|
+
* const cleanup = GoogleAdMob.loadAdMobInterstitialAd({
|
|
117
|
+
* options: {
|
|
118
|
+
* adUnitId: AD_UNIT_ID,
|
|
119
|
+
* },
|
|
120
|
+
* onEvent: (event) => {
|
|
121
|
+
* switch (event.type) {
|
|
122
|
+
* case 'loaded':
|
|
123
|
+
* console.log('광고 로드 성공', event.data);
|
|
124
|
+
* break;
|
|
125
|
+
*
|
|
126
|
+
* case 'clicked':
|
|
127
|
+
* console.log('광고 클릭');
|
|
128
|
+
* break;
|
|
129
|
+
*
|
|
130
|
+
* case 'dismissed':
|
|
131
|
+
* console.log('광고 닫힘');
|
|
132
|
+
* break;
|
|
133
|
+
*
|
|
134
|
+
* case 'failedToShow':
|
|
135
|
+
* console.log('광고 보여주기 실패');
|
|
136
|
+
* break;
|
|
137
|
+
*
|
|
138
|
+
* case 'impression':
|
|
139
|
+
* console.log('광고 노출');
|
|
140
|
+
* break;
|
|
141
|
+
*
|
|
142
|
+
* case 'show':
|
|
143
|
+
* console.log('광고 컨텐츠 보여졌음');
|
|
144
|
+
* break;
|
|
145
|
+
* }
|
|
146
|
+
* },
|
|
147
|
+
* onError: (error) => {
|
|
148
|
+
* console.error('광고 불러오기 실패', error);
|
|
149
|
+
* },
|
|
150
|
+
* });
|
|
151
|
+
*
|
|
152
|
+
* return cleanup;
|
|
153
|
+
* }, []);
|
|
154
|
+
*
|
|
155
|
+
* return (
|
|
156
|
+
* <View>
|
|
157
|
+
* <Text>Page</Text>
|
|
158
|
+
* </View>
|
|
159
|
+
* );
|
|
160
|
+
* }
|
|
161
|
+
* ```
|
|
162
|
+
*/
|
|
163
|
+
loadAdMobInterstitialAd: Object.assign(
|
|
164
|
+
createEventBridge("loadAdMobInterstitialAd"),
|
|
165
|
+
{
|
|
166
|
+
isSupported: createConstantBridge2("loadAdMobInterstitialAd_isSupported")
|
|
167
|
+
}
|
|
168
|
+
),
|
|
169
|
+
/**
|
|
170
|
+
* @public
|
|
171
|
+
* @category 광고
|
|
172
|
+
* @name showAdMobInterstitialAd
|
|
173
|
+
* @description 앱 화면 전체를 덮는 전면 광고를 사용자에게 노출해요. 이 함수는 `loadAdMobInterstitialAd` 로 미리 불러온 광고를 실제로 사용자에게 노출해요.
|
|
174
|
+
* @param {ShowAdMobInterstitialAdParams} params 광고를 보여주기 위해 사용할 설정 값이에요. 광고 ID와과 광고의 동작에 대한 콜백을 설정할 수 있어요.
|
|
175
|
+
* @param {ShowAdMobInterstitialAdOptions} params.options 광고를 보여줄 때 전달할 옵션 객체예요.
|
|
176
|
+
* @param {string} params.options.adUnitId 광고 단위 ID예요. `loadAdMobInterstitialAd` 로 불러온 전면 광고용 ID를 입력해요.
|
|
177
|
+
* @param {(event: ShowAdMobInterstitialAdEvent) => void} [params.onEvent] 광고 관련 이벤트가 발생했을 때 호출돼요. (예시: 광고 노출을 요청했을 때). 자세한 이벤트 타입은 [ShowAdMobInterstitialAdEvent](/react-native/reference/framework/광고/ShowAdMobInterstitialAdEvent.html)를 참고하세요.
|
|
178
|
+
* @param {(reason: unknown) => void} [params.onError] 광고를 노출하지 못했을 때 호출돼요. (예시: 네트워크 오류나 지원하지 않는 환경일 때)
|
|
179
|
+
* @property {() => boolean} [isSupported] 현재 실행 중인 앱(예: 토스 앱, 개발용 샌드박스 앱 등)에서 Google AdMob 광고 기능을 지원하는지 확인하는 함수예요. 기능을 사용하기 전에 지원 여부를 확인해야 해요.
|
|
180
|
+
*
|
|
181
|
+
* @example
|
|
182
|
+
* ### 버튼 눌러 불러온 전면 광고 보여주기
|
|
183
|
+
* ```tsx
|
|
184
|
+
* import { GoogleAdMob } from '@apps-in-toss/framework';
|
|
185
|
+
* import { View, Text, Button } from 'react-native';
|
|
186
|
+
*
|
|
187
|
+
* const AD_UNIT_ID = '<YOUR_AD_UNIT_ID>';
|
|
188
|
+
*
|
|
189
|
+
* function Page() {
|
|
190
|
+
* const handlePress = () => {
|
|
191
|
+
* if (GoogleAdMob.showAdMobInterstitialAd.isSupported() !== true) {
|
|
192
|
+
* return;
|
|
193
|
+
* }
|
|
194
|
+
*
|
|
195
|
+
* GoogleAdMob.showAdMobInterstitialAd({
|
|
196
|
+
* options: {
|
|
197
|
+
* adUnitId: AD_UNIT_ID,
|
|
198
|
+
* },
|
|
199
|
+
* onEvent: (event) => {
|
|
200
|
+
* switch (event.type) {
|
|
201
|
+
* case 'requested':
|
|
202
|
+
* console.log('광고 보여주기 요청 완료');
|
|
203
|
+
* break;
|
|
204
|
+
* }
|
|
205
|
+
* },
|
|
206
|
+
* onError: (error) => {
|
|
207
|
+
* console.error('광고 보여주기 실패', error);
|
|
208
|
+
* },
|
|
209
|
+
* });
|
|
210
|
+
* }
|
|
211
|
+
*
|
|
212
|
+
* return (
|
|
213
|
+
* <Button onPress={handlePress}>
|
|
214
|
+
* <Text>광고 보기</Text>
|
|
215
|
+
* </Button>
|
|
216
|
+
* );
|
|
217
|
+
* }
|
|
218
|
+
* ```
|
|
219
|
+
*/
|
|
220
|
+
showAdMobInterstitialAd: Object.assign(
|
|
221
|
+
createEventBridge("showAdMobInterstitialAd"),
|
|
222
|
+
{
|
|
223
|
+
isSupported: createConstantBridge2("showAdMobInterstitialAd_isSupported")
|
|
224
|
+
}
|
|
225
|
+
),
|
|
226
|
+
/**
|
|
227
|
+
* @public
|
|
228
|
+
* @category 광고
|
|
229
|
+
* @name loadAdMobRewardedAd
|
|
230
|
+
* @description 사용자가 광고를 끝까지 시청하면 리워드를 제공할 수 있는 보상형 광고를 미리 불러와서, 광고가 필요한 시점에 바로 보여줄 수 있도록 준비하는 함수예요.
|
|
231
|
+
* @param {LoadAdMobRewardedAdParams} params 광고를 불러올 때 사용할 설정 값이에요. 광고 ID와 광고의 동작에 대한 콜백을 설정할 수 있어요.
|
|
232
|
+
* @param {LoadAdMobRewardedAdOptions} params.options 광고를 불러올 때 전달할 옵션 객체예요.
|
|
233
|
+
* @param {string} params.options.adUnitId 광고 단위 ID예요. 발급받은 보상형 광고용 ID를 입력해요.
|
|
234
|
+
* @param {(event: LoadAdMobRewardedAdEvent) => void} [params.onEvent] 광고 관련 이벤트가 발생했을 때 호출돼요. (예시: 광고가 닫히거나 클릭됐을 때). 자세한 이벤트 타입은 [LoadAdMobRewardedAdEvent](/react-native/reference/framework/광고/LoadAdMobRewardedAdEvent.html)를 참고하세요.
|
|
235
|
+
* @param {(reason: unknown) => void} [params.onError] 광고를 불러오지 못했을 때 호출돼요. (예시: 네트워크 오류나 지원하지 않는 환경일 때)
|
|
236
|
+
* @property {() => boolean} [isSupported] 현재 실행 중인 앱(예: 토스 앱, 개발용 샌드박스 앱 등)에서 Google AdMob 광고 기능을 지원하는지 확인하는 함수예요. 기능을 사용하기 전에 지원 여부를 확인해야 해요.
|
|
237
|
+
*
|
|
238
|
+
* @example
|
|
239
|
+
* ### 뷰 진입 시 보상형 광고 불러오기
|
|
240
|
+
* ```tsx
|
|
241
|
+
* import { GoogleAdMob } from '@apps-in-toss/framework';
|
|
242
|
+
* import { useEffect } from 'react';
|
|
243
|
+
* import { View, Text } from 'react-native';
|
|
244
|
+
*
|
|
245
|
+
* const AD_UNIT_ID = '<YOUR_AD_UNIT_ID>';
|
|
246
|
+
*
|
|
247
|
+
* function Page() {
|
|
248
|
+
* useEffect(() => {
|
|
249
|
+
* if (GoogleAdMob.loadAdMobRewardedAd.isSupported() !== true) {
|
|
250
|
+
* return;
|
|
251
|
+
* }
|
|
252
|
+
*
|
|
253
|
+
* const cleanup = GoogleAdMob.loadAdMobRewardedAd({
|
|
254
|
+
* options: {
|
|
255
|
+
* adUnitId: AD_UNIT_ID,
|
|
256
|
+
* },
|
|
257
|
+
* onEvent: (event) => {
|
|
258
|
+
* switch (event.type) {
|
|
259
|
+
* case 'loaded':
|
|
260
|
+
* console.log('광고 로드 성공', event.data);
|
|
261
|
+
* break;
|
|
262
|
+
*
|
|
263
|
+
* case 'clicked':
|
|
264
|
+
* console.log('광고 클릭');
|
|
265
|
+
* break;
|
|
266
|
+
*
|
|
267
|
+
* case 'dismissed':
|
|
268
|
+
* console.log('광고 닫힘');
|
|
269
|
+
* break;
|
|
270
|
+
*
|
|
271
|
+
* case 'failedToShow':
|
|
272
|
+
* console.log('광고 보여주기 실패');
|
|
273
|
+
* break;
|
|
274
|
+
*
|
|
275
|
+
* case 'impression':
|
|
276
|
+
* console.log('광고 노출');
|
|
277
|
+
* break;
|
|
278
|
+
*
|
|
279
|
+
* case 'show':
|
|
280
|
+
* console.log('광고 컨텐츠 보여졌음');
|
|
281
|
+
* break;
|
|
282
|
+
*
|
|
283
|
+
* case 'userEarnedReward':
|
|
284
|
+
* console.log('사용자가 광고 시청을 완료했음');
|
|
285
|
+
* break;
|
|
286
|
+
* }
|
|
287
|
+
* },
|
|
288
|
+
* onError: (error) => {
|
|
289
|
+
* console.error('광고 불러오기 실패', error);
|
|
290
|
+
* },
|
|
291
|
+
* });
|
|
292
|
+
*
|
|
293
|
+
* return cleanup;
|
|
294
|
+
* }, []);
|
|
295
|
+
*
|
|
296
|
+
* return (
|
|
297
|
+
* <View>
|
|
298
|
+
* <Text>Page</Text>
|
|
299
|
+
* </View>
|
|
300
|
+
* );
|
|
301
|
+
* }
|
|
302
|
+
* ```
|
|
303
|
+
*/
|
|
304
|
+
loadAdMobRewardedAd: Object.assign(createEventBridge("loadAdMobRewardedAd"), {
|
|
305
|
+
isSupported: createConstantBridge2("loadAdMobRewardedAd_isSupported")
|
|
306
|
+
}),
|
|
307
|
+
/**
|
|
308
|
+
* @public
|
|
309
|
+
* @category 광고
|
|
310
|
+
* @name showAdMobRewardedAd
|
|
311
|
+
* @description 사용자가 광고를 끝까지 보면 리워드를 받을 수 있도록, 보상형 광고를 화면에 보여줘요. 이 함수는 `loadAdMobRewardedAd` 로 미리 불러온 광고를 실제로 사용자에게 노출해요.
|
|
312
|
+
* @param {ShowAdMobRewardedAdParams} params 광고를 보여주기 위해 사용할 설정 값이에요. 광고 ID와 광고의 동작에 대한 콜백을 설정할 수 있어요.
|
|
313
|
+
* @param {ShowAdMobRewardedAdOptions} params.options 광고를 보여줄 때 전달할 옵션 객체예요.
|
|
314
|
+
* @param {string} params.options.adUnitId 광고 단위 ID예요. `loadAdMobRewardedAd` 로 불러온 보상형 광고용 ID를 입력해요.
|
|
315
|
+
* @param {(event: ShowAdMobRewardedAdEvent) => void} [params.onEvent] 광고 관련 이벤트가 발생했을 때 호출돼요. (예시: 광고 노출을 요청했을 때). 자세한 이벤트 타입은 [ShowAdMobRewardedAdEvent](/react-native/reference/framework/광고/ShowAdMobRewardedAdEvent.html)를 참고하세요.
|
|
316
|
+
* @param {(reason: unknown) => void} [params.onError] 광고를 불러오지 못했을 때 호출돼요. (예시: 네트워크 오류나 지원하지 않는 환경일 때)
|
|
317
|
+
* @property {() => boolean} [isSupported] 현재 실행 중인 앱(예: 토스 앱, 개발용 샌드박스 앱 등)에서 Google AdMob 광고 기능을 지원하는지 확인하는 함수예요. 기능을 사용하기 전에 지원 여부를 확인해야 해요.
|
|
318
|
+
*
|
|
319
|
+
* @example
|
|
320
|
+
* ### 버튼 눌러 불러온 보상형 광고 보여주기
|
|
321
|
+
* ```tsx
|
|
322
|
+
* import { GoogleAdMob } from '@apps-in-toss/framework';
|
|
323
|
+
* import { View, Text, Button } from 'react-native';
|
|
324
|
+
*
|
|
325
|
+
* const AD_UNIT_ID = '<YOUR_AD_UNIT_ID>';
|
|
326
|
+
*
|
|
327
|
+
* function Page() {
|
|
328
|
+
* const handlePress = () => {
|
|
329
|
+
* if (GoogleAdMob.showAdMobRewardedAd.isSupported() !== true) {
|
|
330
|
+
* return;
|
|
331
|
+
* }
|
|
332
|
+
*
|
|
333
|
+
* GoogleAdMob.showAdMobRewardedAd({
|
|
334
|
+
* options: {
|
|
335
|
+
* adUnitId: AD_UNIT_ID,
|
|
336
|
+
* },
|
|
337
|
+
* onEvent: (event) => {
|
|
338
|
+
* switch (event.type) {
|
|
339
|
+
* case 'requested':
|
|
340
|
+
* console.log('광고 보여주기 요청 완료');
|
|
341
|
+
* break;
|
|
342
|
+
* }
|
|
343
|
+
* },
|
|
344
|
+
* onError: (error) => {
|
|
345
|
+
* console.error('광고 보여주기 실패', error);
|
|
346
|
+
* },
|
|
347
|
+
* });
|
|
348
|
+
* }
|
|
349
|
+
*
|
|
350
|
+
* return (
|
|
351
|
+
* <Button onPress={handlePress}>
|
|
352
|
+
* <Text>광고 보기</Text>
|
|
353
|
+
* </Button>
|
|
354
|
+
* );
|
|
355
|
+
* }
|
|
356
|
+
* ```
|
|
357
|
+
*/
|
|
358
|
+
showAdMobRewardedAd: Object.assign(createEventBridge("showAdMobRewardedAd"), {
|
|
359
|
+
isSupported: createConstantBridge2("showAdMobRewardedAd_isSupported")
|
|
360
|
+
})
|
|
361
|
+
};
|
|
362
|
+
|
|
219
363
|
// src-web/bedrockEvent.ts
|
|
364
|
+
import { createEventBridge as createEventBridge2 } from "@apps-in-toss/bridge-core";
|
|
220
365
|
var bedrockEvent = {
|
|
221
366
|
addEventListener: (event, {
|
|
222
367
|
onEvent,
|
|
223
368
|
onError,
|
|
224
369
|
options
|
|
225
|
-
}) =>
|
|
370
|
+
}) => createEventBridge2(event)({
|
|
371
|
+
onEvent,
|
|
372
|
+
onError: onError ?? (() => {
|
|
373
|
+
}),
|
|
374
|
+
options
|
|
375
|
+
})
|
|
376
|
+
};
|
|
377
|
+
|
|
378
|
+
// src-web/isMinVersionSupported.ts
|
|
379
|
+
import { createConstantBridge as createConstantBridge3 } from "@apps-in-toss/bridge-core";
|
|
380
|
+
|
|
381
|
+
// src-web/utils/compareVersion.ts
|
|
382
|
+
var SEMVER_REGEX = /^[v^~<>=]*?(\d+)(?:\.([x*]|\d+)(?:\.([x*]|\d+)(?:\.([x*]|\d+))?(?:-([\da-z\\-]+(?:\.[\da-z\\-]+)*))?(?:\+[\da-z\\-]+(?:\.[\da-z\\-]+)*)?)?)?$/i;
|
|
383
|
+
var isWildcard = (val) => ["*", "x", "X"].includes(val);
|
|
384
|
+
var tryParse = (val) => {
|
|
385
|
+
const num = parseInt(val, 10);
|
|
386
|
+
return isNaN(num) ? val : num;
|
|
387
|
+
};
|
|
388
|
+
var coerceTypes = (a, b) => {
|
|
389
|
+
return typeof a === typeof b ? [a, b] : [String(a), String(b)];
|
|
390
|
+
};
|
|
391
|
+
var compareValues = (a, b) => {
|
|
392
|
+
if (isWildcard(a) || isWildcard(b)) {
|
|
393
|
+
return 0;
|
|
394
|
+
}
|
|
395
|
+
const [aVal, bVal] = coerceTypes(tryParse(a), tryParse(b));
|
|
396
|
+
if (aVal > bVal) {
|
|
397
|
+
return 1;
|
|
398
|
+
}
|
|
399
|
+
if (aVal < bVal) {
|
|
400
|
+
return -1;
|
|
401
|
+
}
|
|
402
|
+
return 0;
|
|
403
|
+
};
|
|
404
|
+
var parseVersion = (version) => {
|
|
405
|
+
if (typeof version !== "string") {
|
|
406
|
+
throw new TypeError("Invalid argument: expected a string");
|
|
407
|
+
}
|
|
408
|
+
const match = version.match(SEMVER_REGEX);
|
|
409
|
+
if (!match) {
|
|
410
|
+
throw new Error(`Invalid semver: '${version}'`);
|
|
411
|
+
}
|
|
412
|
+
const [, major, minor, patch, build, preRelease] = match;
|
|
413
|
+
return [major, minor, patch, build, preRelease];
|
|
414
|
+
};
|
|
415
|
+
var compareSegments = (a, b) => {
|
|
416
|
+
const maxLength = Math.max(a.length, b.length);
|
|
417
|
+
for (let i = 0; i < maxLength; i++) {
|
|
418
|
+
const segA = a[i] ?? "0";
|
|
419
|
+
const segB = b[i] ?? "0";
|
|
420
|
+
const result = compareValues(segA, segB);
|
|
421
|
+
if (result !== 0) {
|
|
422
|
+
return result;
|
|
423
|
+
}
|
|
424
|
+
}
|
|
425
|
+
return 0;
|
|
426
|
+
};
|
|
427
|
+
var compareVersions = (v1, v2) => {
|
|
428
|
+
const seg1 = parseVersion(v1);
|
|
429
|
+
const seg2 = parseVersion(v2);
|
|
430
|
+
const preRelease1 = seg1.pop();
|
|
431
|
+
const preRelease2 = seg2.pop();
|
|
432
|
+
const mainCompare = compareSegments(seg1, seg2);
|
|
433
|
+
if (mainCompare !== 0) {
|
|
434
|
+
return mainCompare;
|
|
435
|
+
}
|
|
436
|
+
if (preRelease1 && preRelease2) {
|
|
437
|
+
return compareSegments(preRelease1.split("."), preRelease2.split("."));
|
|
438
|
+
}
|
|
439
|
+
if (preRelease1) {
|
|
440
|
+
return -1;
|
|
441
|
+
}
|
|
442
|
+
if (preRelease2) {
|
|
443
|
+
return 1;
|
|
444
|
+
}
|
|
445
|
+
return 0;
|
|
446
|
+
};
|
|
447
|
+
|
|
448
|
+
// src-web/isMinVersionSupported.ts
|
|
449
|
+
function isMinVersionSupported(minVersions) {
|
|
450
|
+
const operationalEnvironment = createConstantBridge3("getOperationalEnvironment")();
|
|
451
|
+
if (operationalEnvironment === "sandbox") {
|
|
452
|
+
return true;
|
|
453
|
+
}
|
|
454
|
+
const currentVersion = createConstantBridge3("getTossAppVersion")();
|
|
455
|
+
const isIOS = createConstantBridge3("getPlatformOS")() === "ios";
|
|
456
|
+
const minVersion = isIOS ? minVersions.ios : minVersions.android;
|
|
457
|
+
if (minVersion === void 0) {
|
|
458
|
+
return false;
|
|
459
|
+
}
|
|
460
|
+
if (minVersion === "always") {
|
|
461
|
+
return true;
|
|
462
|
+
}
|
|
463
|
+
if (minVersion === "never") {
|
|
464
|
+
return false;
|
|
465
|
+
}
|
|
466
|
+
return compareVersions(currentVersion, minVersion) >= 0;
|
|
467
|
+
}
|
|
468
|
+
|
|
469
|
+
// src-web/appsInTossEvent.ts
|
|
470
|
+
import { createEventBridge as createEventBridge3 } from "@apps-in-toss/bridge-core";
|
|
471
|
+
var appsInTossEvent = {
|
|
472
|
+
addEventListener: (event, {
|
|
473
|
+
onEvent,
|
|
474
|
+
onError,
|
|
475
|
+
options
|
|
476
|
+
}) => createEventBridge3(event)({
|
|
226
477
|
onEvent,
|
|
227
478
|
onError: onError ?? (() => {
|
|
228
479
|
}),
|
|
@@ -230,10 +481,10 @@ var bedrockEvent = {
|
|
|
230
481
|
})
|
|
231
482
|
};
|
|
232
483
|
export {
|
|
484
|
+
GoogleAdMob,
|
|
233
485
|
Storage,
|
|
486
|
+
appsInTossEvent,
|
|
234
487
|
bedrockEvent,
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
createEventBridge,
|
|
238
|
-
getSafeAreaInsets
|
|
488
|
+
getSafeAreaInsets,
|
|
489
|
+
isMinVersionSupported
|
|
239
490
|
};
|
package/package.json
CHANGED
|
@@ -1,14 +1,15 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@apps-in-toss/web-framework",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.0.
|
|
4
|
+
"version": "0.0.23",
|
|
5
5
|
"description": "Web Framework for Apps In Toss",
|
|
6
6
|
"scripts": {
|
|
7
7
|
"prepack": "yarn build",
|
|
8
8
|
"typecheck": "tsc --noEmit",
|
|
9
9
|
"lint": "eslint .",
|
|
10
10
|
"build": "tsup",
|
|
11
|
-
"test
|
|
11
|
+
"test": "vitest --no-watch",
|
|
12
|
+
"test:no-parallel": "vitest --no-watch --config=vitest.no-parallel.config.mts",
|
|
12
13
|
"sync-bridge": "bridgepack build"
|
|
13
14
|
},
|
|
14
15
|
"main": "./dist-web/index.js",
|
|
@@ -51,7 +52,9 @@
|
|
|
51
52
|
"config.d.ts"
|
|
52
53
|
],
|
|
53
54
|
"devDependencies": {
|
|
54
|
-
"@apps-in-toss/
|
|
55
|
+
"@apps-in-toss-internal/bridgepack": "^0.0.23",
|
|
56
|
+
"@apps-in-toss/bridge-core": "workspace:*",
|
|
57
|
+
"@apps-in-toss/framework": "0.0.23",
|
|
55
58
|
"@babel/plugin-proposal-class-properties": "^7.16.7",
|
|
56
59
|
"@babel/plugin-proposal-nullish-coalescing-operator": "^7.16.7",
|
|
57
60
|
"@babel/plugin-proposal-numeric-separator": "^7.16.7",
|
|
@@ -67,10 +70,9 @@
|
|
|
67
70
|
"@babel/types": "^7.26.9",
|
|
68
71
|
"@clack/prompts": "^0.10.0",
|
|
69
72
|
"@hono/node-server": "^1.13.8",
|
|
70
|
-
"@react-native-bedrock/
|
|
71
|
-
"@react-native-bedrock/
|
|
72
|
-
"@react-native-bedrock/
|
|
73
|
-
"@react-native-bedrock/native": "0.0.20",
|
|
73
|
+
"@react-native-bedrock/cli": "0.0.22",
|
|
74
|
+
"@react-native-bedrock/mpack-next": "0.0.22",
|
|
75
|
+
"@react-native-bedrock/native": "0.0.22",
|
|
74
76
|
"@toss-design-system/react-native": "^0.5.1",
|
|
75
77
|
"@types/babel__core": "^7.20.5",
|
|
76
78
|
"@types/babel__traverse": "^7",
|
|
@@ -91,23 +93,24 @@
|
|
|
91
93
|
"picocolors": "^1.1.1",
|
|
92
94
|
"react": "18.2.0",
|
|
93
95
|
"react-native": "0.72.6",
|
|
94
|
-
"react-native-bedrock": "0.0.
|
|
96
|
+
"react-native-bedrock": "0.0.22",
|
|
95
97
|
"tsup": "^8.3.5",
|
|
96
98
|
"typescript": "4.9.5",
|
|
97
99
|
"uuidv7": "^1.0.2",
|
|
98
100
|
"vitest": "^3.0.5",
|
|
99
101
|
"wait-port": "^1.1.0",
|
|
100
102
|
"workspace-tools": "^0.38.2",
|
|
103
|
+
"yauzl": "^3.2.0",
|
|
101
104
|
"zod": "^3.24.1"
|
|
102
105
|
},
|
|
103
106
|
"dependencies": {
|
|
104
|
-
"@apps-in-toss/
|
|
105
|
-
"@apps-in-toss/
|
|
106
|
-
"@
|
|
107
|
-
"
|
|
107
|
+
"@apps-in-toss/bridge-core": "0.0.23",
|
|
108
|
+
"@apps-in-toss/cli": "0.0.23",
|
|
109
|
+
"@apps-in-toss/plugins": "0.0.23",
|
|
110
|
+
"@babel/core": "7.23.9"
|
|
108
111
|
},
|
|
109
112
|
"publishConfig": {
|
|
110
113
|
"access": "public"
|
|
111
114
|
},
|
|
112
|
-
"gitHead": "
|
|
115
|
+
"gitHead": "92c6637381f3fc20dfa1870075f22ef108c62873"
|
|
113
116
|
}
|