@apps-in-toss/framework 0.0.22 → 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/index.cjs +596 -185
- package/dist/index.d.cts +642 -336
- package/dist/index.d.ts +642 -336
- package/dist/index.js +565 -158
- package/package.json +10 -9
- package/src/async-bridges.ts +1 -1
package/dist/index.js
CHANGED
|
@@ -8,80 +8,275 @@ var __export = (target, all) => {
|
|
|
8
8
|
import { TDSProvider } from "@toss-design-system/react-native";
|
|
9
9
|
import { Bedrock } from "react-native-bedrock";
|
|
10
10
|
|
|
11
|
-
// src/core/
|
|
12
|
-
import { useBridge } from "@toss-design-system/react-native";
|
|
11
|
+
// src/core/components/AppEvent.tsx
|
|
13
12
|
import { useEffect } from "react";
|
|
13
|
+
import { getSchemeUri as getSchemeUri2 } from "react-native-bedrock";
|
|
14
14
|
|
|
15
|
-
//
|
|
16
|
-
function
|
|
17
|
-
if (global.__appsInToss == null) {
|
|
18
|
-
throw new Error("invalid apps-in-toss globals");
|
|
19
|
-
}
|
|
20
|
-
return global.__appsInToss;
|
|
15
|
+
// ../../.yarn/cache/es-toolkit-npm-1.34.1-4cd6371dcb-aab6d07be3.zip/node_modules/es-toolkit/dist/function/noop.mjs
|
|
16
|
+
function noop() {
|
|
21
17
|
}
|
|
22
18
|
|
|
23
|
-
// src/
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
19
|
+
// src/native-modules/AppsInTossModule.ts
|
|
20
|
+
import { NativeModules } from "react-native";
|
|
21
|
+
var AppsInTossModuleInstance = NativeModules.AppsInTossModule;
|
|
22
|
+
var AppsInTossModule = AppsInTossModuleInstance;
|
|
27
23
|
|
|
28
|
-
// src/
|
|
29
|
-
function
|
|
30
|
-
|
|
31
|
-
const appsInTossGlobals2 = getAppsInTossGlobals();
|
|
32
|
-
useEffect(() => {
|
|
33
|
-
const commonProps = {
|
|
34
|
-
serviceName: appsInTossGlobals2.brandDisplayName,
|
|
35
|
-
icon: toIcon(appsInTossGlobals2.brandIcon),
|
|
36
|
-
color: appsInTossGlobals2.brandPrimaryColor,
|
|
37
|
-
colorMode: appsInTossGlobals2.brandBridgeColorMode
|
|
38
|
-
};
|
|
39
|
-
controller.open({ ...commonProps });
|
|
40
|
-
}, []);
|
|
24
|
+
// src/utils/generateUUID.ts
|
|
25
|
+
function generateUUID(placeholder) {
|
|
26
|
+
return placeholder ? (placeholder ^ Math.random() * 16 >> placeholder / 4).toString(16) : (String(1e7) + 1e3 + 4e3 + 8e3 + 1e11).replace(/[018]/g, generateUUID);
|
|
41
27
|
}
|
|
42
28
|
|
|
43
|
-
// src/
|
|
44
|
-
|
|
45
|
-
function
|
|
46
|
-
|
|
29
|
+
// src/native-event-emitter/internal/appBridge.ts
|
|
30
|
+
var INTERNAL__callbacks = /* @__PURE__ */ new Map();
|
|
31
|
+
function invokeAppBridgeCallback(id, ...args) {
|
|
32
|
+
const callback = INTERNAL__callbacks.get(id);
|
|
33
|
+
callback?.call(null, ...args);
|
|
34
|
+
return Boolean(callback);
|
|
47
35
|
}
|
|
48
|
-
function
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
appName: getAppName(),
|
|
55
|
-
context,
|
|
56
|
-
defaultScreenOption: {
|
|
57
|
-
statusBarStyle: "dark"
|
|
58
|
-
}
|
|
36
|
+
function invokeAppBridgeMethod(methodName, params, callbacks) {
|
|
37
|
+
const { onSuccess, onError, ...appBridgeCallbacks } = callbacks;
|
|
38
|
+
const { callbackMap, unregisterAll } = registerCallbacks(appBridgeCallbacks);
|
|
39
|
+
const promise = AppsInTossModuleInstance[methodName]({
|
|
40
|
+
params,
|
|
41
|
+
callbacks: callbackMap
|
|
59
42
|
});
|
|
43
|
+
void promise.then(onSuccess).catch(onError);
|
|
44
|
+
return unregisterAll;
|
|
60
45
|
}
|
|
61
|
-
function
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
throw error;
|
|
46
|
+
function registerCallbacks(callbacks) {
|
|
47
|
+
const callbackMap = {};
|
|
48
|
+
for (const [callbackName, callback] of Object.entries(callbacks)) {
|
|
49
|
+
const id = registerCallback(callback, callbackName);
|
|
50
|
+
callbackMap[callbackName] = id;
|
|
67
51
|
}
|
|
52
|
+
const unregisterAll = () => {
|
|
53
|
+
Object.values(callbackMap).forEach(unregisterCallback);
|
|
54
|
+
};
|
|
55
|
+
return { callbackMap, unregisterAll };
|
|
56
|
+
}
|
|
57
|
+
function registerCallback(callback, name = "unnamed") {
|
|
58
|
+
const uniqueId = generateUUID();
|
|
59
|
+
const callbackId = `${uniqueId}__${name}`;
|
|
60
|
+
INTERNAL__callbacks.set(callbackId, callback);
|
|
61
|
+
return callbackId;
|
|
68
62
|
}
|
|
63
|
+
function unregisterCallback(id) {
|
|
64
|
+
INTERNAL__callbacks.delete(id);
|
|
65
|
+
}
|
|
66
|
+
function getCallbackIds() {
|
|
67
|
+
return Array.from(INTERNAL__callbacks.keys());
|
|
68
|
+
}
|
|
69
|
+
var INTERNAL__appBridgeHandler = {
|
|
70
|
+
invokeAppBridgeCallback,
|
|
71
|
+
invokeAppBridgeMethod,
|
|
72
|
+
registerCallback,
|
|
73
|
+
unregisterCallback,
|
|
74
|
+
getCallbackIds
|
|
75
|
+
};
|
|
69
76
|
|
|
70
|
-
// src/
|
|
71
|
-
|
|
72
|
-
|
|
77
|
+
// src/native-modules/getOperationalEnvironment.ts
|
|
78
|
+
function getOperationalEnvironment() {
|
|
79
|
+
return AppsInTossModule.operationalEnvironment;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
// src/native-modules/isMinVersionSupported.ts
|
|
83
|
+
import { Platform } from "react-native";
|
|
84
|
+
|
|
85
|
+
// src/utils/compareVersion.ts
|
|
86
|
+
var SEMVER_REGEX = /^[v^~<>=]*?(\d+)(?:\.([x*]|\d+)(?:\.([x*]|\d+)(?:\.([x*]|\d+))?(?:-([\da-z\\-]+(?:\.[\da-z\\-]+)*))?(?:\+[\da-z\\-]+(?:\.[\da-z\\-]+)*)?)?)?$/i;
|
|
87
|
+
var isWildcard = (val) => ["*", "x", "X"].includes(val);
|
|
88
|
+
var tryParse = (val) => {
|
|
89
|
+
const num = parseInt(val, 10);
|
|
90
|
+
return isNaN(num) ? val : num;
|
|
91
|
+
};
|
|
92
|
+
var coerceTypes = (a, b) => {
|
|
93
|
+
return typeof a === typeof b ? [a, b] : [String(a), String(b)];
|
|
94
|
+
};
|
|
95
|
+
var compareValues = (a, b) => {
|
|
96
|
+
if (isWildcard(a) || isWildcard(b)) {
|
|
97
|
+
return 0;
|
|
98
|
+
}
|
|
99
|
+
const [aVal, bVal] = coerceTypes(tryParse(a), tryParse(b));
|
|
100
|
+
if (aVal > bVal) {
|
|
101
|
+
return 1;
|
|
102
|
+
}
|
|
103
|
+
if (aVal < bVal) {
|
|
104
|
+
return -1;
|
|
105
|
+
}
|
|
106
|
+
return 0;
|
|
107
|
+
};
|
|
108
|
+
var parseVersion = (version) => {
|
|
109
|
+
if (typeof version !== "string") {
|
|
110
|
+
throw new TypeError("Invalid argument: expected a string");
|
|
111
|
+
}
|
|
112
|
+
const match = version.match(SEMVER_REGEX);
|
|
113
|
+
if (!match) {
|
|
114
|
+
throw new Error(`Invalid semver: '${version}'`);
|
|
115
|
+
}
|
|
116
|
+
const [, major, minor, patch, build, preRelease] = match;
|
|
117
|
+
return [major, minor, patch, build, preRelease];
|
|
118
|
+
};
|
|
119
|
+
var compareSegments = (a, b) => {
|
|
120
|
+
const maxLength = Math.max(a.length, b.length);
|
|
121
|
+
for (let i = 0; i < maxLength; i++) {
|
|
122
|
+
const segA = a[i] ?? "0";
|
|
123
|
+
const segB = b[i] ?? "0";
|
|
124
|
+
const result = compareValues(segA, segB);
|
|
125
|
+
if (result !== 0) {
|
|
126
|
+
return result;
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
return 0;
|
|
130
|
+
};
|
|
131
|
+
var compareVersions = (v1, v2) => {
|
|
132
|
+
const seg1 = parseVersion(v1);
|
|
133
|
+
const seg2 = parseVersion(v2);
|
|
134
|
+
const preRelease1 = seg1.pop();
|
|
135
|
+
const preRelease2 = seg2.pop();
|
|
136
|
+
const mainCompare = compareSegments(seg1, seg2);
|
|
137
|
+
if (mainCompare !== 0) {
|
|
138
|
+
return mainCompare;
|
|
139
|
+
}
|
|
140
|
+
if (preRelease1 && preRelease2) {
|
|
141
|
+
return compareSegments(preRelease1.split("."), preRelease2.split("."));
|
|
142
|
+
}
|
|
143
|
+
if (preRelease1) {
|
|
144
|
+
return -1;
|
|
145
|
+
}
|
|
146
|
+
if (preRelease2) {
|
|
147
|
+
return 1;
|
|
148
|
+
}
|
|
149
|
+
return 0;
|
|
73
150
|
};
|
|
74
151
|
|
|
75
|
-
// src/native-
|
|
76
|
-
|
|
152
|
+
// src/native-modules/isMinVersionSupported.ts
|
|
153
|
+
function isMinVersionSupported(minVersions) {
|
|
154
|
+
const operationalEnvironment2 = AppsInTossModule.operationalEnvironment;
|
|
155
|
+
if (operationalEnvironment2 === "sandbox") {
|
|
156
|
+
return true;
|
|
157
|
+
}
|
|
158
|
+
const currentVersion = AppsInTossModule.tossAppVersion;
|
|
159
|
+
const isIOS = Platform.OS === "ios";
|
|
160
|
+
const minVersion = isIOS ? minVersions.ios : minVersions.android;
|
|
161
|
+
if (minVersion === void 0) {
|
|
162
|
+
return false;
|
|
163
|
+
}
|
|
164
|
+
if (minVersion === "always") {
|
|
165
|
+
return true;
|
|
166
|
+
}
|
|
167
|
+
if (minVersion === "never") {
|
|
168
|
+
return false;
|
|
169
|
+
}
|
|
170
|
+
return compareVersions(currentVersion, minVersion) >= 0;
|
|
171
|
+
}
|
|
77
172
|
|
|
78
|
-
// src/native-
|
|
79
|
-
|
|
173
|
+
// src/native-modules/ads/googleAdMob.ts
|
|
174
|
+
function loadAdMobInterstitialAd(params) {
|
|
175
|
+
if (!loadAdMobInterstitialAd.isSupported()) {
|
|
176
|
+
params.onError(new Error(UNSUPPORTED_ERROR_MESSAGE));
|
|
177
|
+
return noop;
|
|
178
|
+
}
|
|
179
|
+
const { onEvent, onError, options } = params;
|
|
180
|
+
const unregisterCallbacks = INTERNAL__appBridgeHandler.invokeAppBridgeMethod("loadAdMobInterstitialAd", options, {
|
|
181
|
+
onAdClicked: () => {
|
|
182
|
+
onEvent({ type: "clicked" });
|
|
183
|
+
},
|
|
184
|
+
onAdDismissed: () => {
|
|
185
|
+
onEvent({ type: "dismissed" });
|
|
186
|
+
},
|
|
187
|
+
onAdFailedToShow: () => {
|
|
188
|
+
onEvent({ type: "failedToShow" });
|
|
189
|
+
},
|
|
190
|
+
onAdImpression: () => {
|
|
191
|
+
onEvent({ type: "impression" });
|
|
192
|
+
},
|
|
193
|
+
onAdShow: () => {
|
|
194
|
+
onEvent({ type: "show" });
|
|
195
|
+
},
|
|
196
|
+
onSuccess: (result) => onEvent({ type: "loaded", data: result }),
|
|
197
|
+
onError
|
|
198
|
+
});
|
|
199
|
+
return unregisterCallbacks;
|
|
200
|
+
}
|
|
201
|
+
function showAdMobInterstitialAd(params) {
|
|
202
|
+
if (!showAdMobInterstitialAd.isSupported()) {
|
|
203
|
+
params.onError(new Error(UNSUPPORTED_ERROR_MESSAGE));
|
|
204
|
+
return noop;
|
|
205
|
+
}
|
|
206
|
+
const { onEvent, onError, options } = params;
|
|
207
|
+
const unregisterCallbacks = INTERNAL__appBridgeHandler.invokeAppBridgeMethod("showAdMobInterstitialAd", options, {
|
|
208
|
+
onSuccess: () => onEvent({ type: "requested" }),
|
|
209
|
+
onError
|
|
210
|
+
});
|
|
211
|
+
return unregisterCallbacks;
|
|
212
|
+
}
|
|
213
|
+
function loadAdMobRewardedAd(params) {
|
|
214
|
+
if (!loadAdMobRewardedAd.isSupported()) {
|
|
215
|
+
params.onError(new Error(UNSUPPORTED_ERROR_MESSAGE));
|
|
216
|
+
return noop;
|
|
217
|
+
}
|
|
218
|
+
const { onEvent, onError, options } = params;
|
|
219
|
+
const unregisterCallbacks = INTERNAL__appBridgeHandler.invokeAppBridgeMethod("loadAdMobRewardedAd", options, {
|
|
220
|
+
onAdClicked: () => {
|
|
221
|
+
onEvent({ type: "clicked" });
|
|
222
|
+
},
|
|
223
|
+
onAdDismissed: () => {
|
|
224
|
+
onEvent({ type: "dismissed" });
|
|
225
|
+
},
|
|
226
|
+
onAdFailedToShow: () => {
|
|
227
|
+
onEvent({ type: "failedToShow" });
|
|
228
|
+
},
|
|
229
|
+
onAdImpression: () => {
|
|
230
|
+
onEvent({ type: "impression" });
|
|
231
|
+
},
|
|
232
|
+
onAdShow: () => {
|
|
233
|
+
onEvent({ type: "show" });
|
|
234
|
+
},
|
|
235
|
+
onUserEarnedReward: () => {
|
|
236
|
+
onEvent({ type: "userEarnedReward" });
|
|
237
|
+
},
|
|
238
|
+
onSuccess: (result) => onEvent({ type: "loaded", data: result }),
|
|
239
|
+
onError
|
|
240
|
+
});
|
|
241
|
+
return unregisterCallbacks;
|
|
242
|
+
}
|
|
243
|
+
function showAdMobRewardedAd(params) {
|
|
244
|
+
if (!showAdMobRewardedAd.isSupported()) {
|
|
245
|
+
params.onError(new Error(UNSUPPORTED_ERROR_MESSAGE));
|
|
246
|
+
return noop;
|
|
247
|
+
}
|
|
248
|
+
const { onEvent, onError, options } = params;
|
|
249
|
+
const unregisterCallbacks = INTERNAL__appBridgeHandler.invokeAppBridgeMethod("showAdMobRewardedAd", options, {
|
|
250
|
+
onSuccess: () => onEvent({ type: "requested" }),
|
|
251
|
+
onError
|
|
252
|
+
});
|
|
253
|
+
return unregisterCallbacks;
|
|
254
|
+
}
|
|
255
|
+
var ANDROID_GOOGLE_AD_MOB_SUPPORTED_VERSION = "5.209.0";
|
|
256
|
+
var IOS_GOOGLE_AD_MOB_SUPPORTED_VERSION = "5.209.0";
|
|
257
|
+
var UNSUPPORTED_ERROR_MESSAGE = "This feature is not supported in the current environment";
|
|
258
|
+
var ENVIRONMENT = getOperationalEnvironment();
|
|
259
|
+
function createIsSupported() {
|
|
260
|
+
return () => {
|
|
261
|
+
if (ENVIRONMENT !== "toss") {
|
|
262
|
+
console.warn("Google AdMob is not supported in the current environment");
|
|
263
|
+
return false;
|
|
264
|
+
}
|
|
265
|
+
return isMinVersionSupported({
|
|
266
|
+
android: ANDROID_GOOGLE_AD_MOB_SUPPORTED_VERSION,
|
|
267
|
+
ios: IOS_GOOGLE_AD_MOB_SUPPORTED_VERSION
|
|
268
|
+
});
|
|
269
|
+
};
|
|
270
|
+
}
|
|
271
|
+
loadAdMobInterstitialAd.isSupported = createIsSupported();
|
|
272
|
+
loadAdMobRewardedAd.isSupported = createIsSupported();
|
|
273
|
+
showAdMobInterstitialAd.isSupported = createIsSupported();
|
|
274
|
+
showAdMobRewardedAd.isSupported = createIsSupported();
|
|
80
275
|
|
|
81
|
-
// src/native-modules/
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
276
|
+
// src/native-modules/checkoutPayment.ts
|
|
277
|
+
async function checkoutPayment(options) {
|
|
278
|
+
return AppsInTossModule.checkoutPayment({ params: options });
|
|
279
|
+
}
|
|
85
280
|
|
|
86
281
|
// src/native-modules/getPermission.ts
|
|
87
282
|
function getPermission(permission) {
|
|
@@ -105,56 +300,6 @@ async function requestPermission(permission) {
|
|
|
105
300
|
}
|
|
106
301
|
}
|
|
107
302
|
|
|
108
|
-
// src/native-event-emitter/nativeEventEmitter.ts
|
|
109
|
-
import { NativeEventEmitter } from "react-native";
|
|
110
|
-
var nativeEventEmitter = new NativeEventEmitter(AppsInTossModuleInstance);
|
|
111
|
-
|
|
112
|
-
// src/native-event-emitter/event-plugins/UpdateLocationEvent.ts
|
|
113
|
-
var UpdateLocationEvent = class extends BedrockEventDefinition {
|
|
114
|
-
name = "updateLocationEvent";
|
|
115
|
-
subscriptionCount = 0;
|
|
116
|
-
ref = {
|
|
117
|
-
remove: () => {
|
|
118
|
-
}
|
|
119
|
-
};
|
|
120
|
-
remove() {
|
|
121
|
-
--this.subscriptionCount === 0 && AppsInTossModuleInstance.stopUpdateLocation({});
|
|
122
|
-
this.ref.remove();
|
|
123
|
-
}
|
|
124
|
-
listener(options, onEvent, onError) {
|
|
125
|
-
requestPermission({ name: "geolocation", access: "access" }).then((permissionStatus) => {
|
|
126
|
-
if (permissionStatus === "denied") {
|
|
127
|
-
onError(new Error("\uC704\uCE58 \uAD8C\uD55C\uC774 \uAC70\uBD80\uB418\uC5C8\uC5B4\uC694."));
|
|
128
|
-
return;
|
|
129
|
-
}
|
|
130
|
-
void AppsInTossModuleInstance.startUpdateLocation(options).catch(onError);
|
|
131
|
-
const subscription = nativeEventEmitter.addListener("updateLocation", onEvent);
|
|
132
|
-
this.ref = {
|
|
133
|
-
remove: () => subscription?.remove()
|
|
134
|
-
};
|
|
135
|
-
this.subscriptionCount++;
|
|
136
|
-
}).catch(onError);
|
|
137
|
-
}
|
|
138
|
-
};
|
|
139
|
-
|
|
140
|
-
// src/native-event-emitter/bedrock-event.ts
|
|
141
|
-
var appsInTossEvent = new BedrockEvent([new UpdateLocationEvent()]);
|
|
142
|
-
|
|
143
|
-
// src/native-event-emitter/startUpdateLocation.ts
|
|
144
|
-
function startUpdateLocation(eventParams) {
|
|
145
|
-
return appsInTossEvent.addEventListener("updateLocationEvent", eventParams);
|
|
146
|
-
}
|
|
147
|
-
|
|
148
|
-
// src/native-modules/checkoutPayment.ts
|
|
149
|
-
async function checkoutPayment(options) {
|
|
150
|
-
return AppsInTossModule.checkoutPayment(options);
|
|
151
|
-
}
|
|
152
|
-
|
|
153
|
-
// src/native-modules/executePayment.ts
|
|
154
|
-
async function executePayment(options) {
|
|
155
|
-
return AppsInTossModule.executePayment(options);
|
|
156
|
-
}
|
|
157
|
-
|
|
158
303
|
// src/native-modules/setClipboardText.ts
|
|
159
304
|
async function setClipboardText(text) {
|
|
160
305
|
const permissionStatus = await requestPermission({ name: "clipboard", access: "write" });
|
|
@@ -236,11 +381,6 @@ async function appLogin() {
|
|
|
236
381
|
return AppsInTossModule.appLogin({});
|
|
237
382
|
}
|
|
238
383
|
|
|
239
|
-
// src/native-modules/getOperationalEnvironment.ts
|
|
240
|
-
function getOperationalEnvironment() {
|
|
241
|
-
return AppsInTossModule.operationalEnvironment;
|
|
242
|
-
}
|
|
243
|
-
|
|
244
384
|
// src/native-modules/getTossAppVersion.ts
|
|
245
385
|
function getTossAppVersion() {
|
|
246
386
|
return AppsInTossModule.tossAppVersion;
|
|
@@ -274,6 +414,35 @@ var Storage = {
|
|
|
274
414
|
clearItems
|
|
275
415
|
};
|
|
276
416
|
|
|
417
|
+
// src/native-modules/eventLog.ts
|
|
418
|
+
function normalizeParams(params) {
|
|
419
|
+
return Object.fromEntries(
|
|
420
|
+
Object.entries(params).filter(([, value]) => value !== void 0).map(([key, value]) => [key, String(value)])
|
|
421
|
+
);
|
|
422
|
+
}
|
|
423
|
+
async function eventLog(params) {
|
|
424
|
+
if (AppsInTossModule.operationalEnvironment === "sandbox") {
|
|
425
|
+
console.log("[eventLogDebug]", {
|
|
426
|
+
log_name: params.log_name,
|
|
427
|
+
log_type: params.log_type,
|
|
428
|
+
params: normalizeParams(params.params)
|
|
429
|
+
});
|
|
430
|
+
return;
|
|
431
|
+
}
|
|
432
|
+
const isSupported = isMinVersionSupported({
|
|
433
|
+
android: "5.208.0",
|
|
434
|
+
ios: "5.208.0"
|
|
435
|
+
});
|
|
436
|
+
if (!isSupported) {
|
|
437
|
+
return;
|
|
438
|
+
}
|
|
439
|
+
return AppsInTossModule.eventLog({
|
|
440
|
+
log_name: params.log_name,
|
|
441
|
+
log_type: params.log_type,
|
|
442
|
+
params: normalizeParams(params.params)
|
|
443
|
+
});
|
|
444
|
+
}
|
|
445
|
+
|
|
277
446
|
// src/native-modules/getTossShareLink.ts
|
|
278
447
|
async function getTossShareLink(path) {
|
|
279
448
|
const { shareLink } = await AppsInTossModule.getTossShareLink({});
|
|
@@ -285,8 +454,234 @@ async function getTossShareLink(path) {
|
|
|
285
454
|
|
|
286
455
|
// src/native-modules/index.ts
|
|
287
456
|
var TossPay = {
|
|
288
|
-
checkoutPayment
|
|
289
|
-
|
|
457
|
+
checkoutPayment
|
|
458
|
+
};
|
|
459
|
+
var GoogleAdMob = {
|
|
460
|
+
loadAdMobInterstitialAd,
|
|
461
|
+
showAdMobInterstitialAd,
|
|
462
|
+
loadAdMobRewardedAd,
|
|
463
|
+
showAdMobRewardedAd
|
|
464
|
+
};
|
|
465
|
+
|
|
466
|
+
// src/native-event-emitter/appsInTossEvent.ts
|
|
467
|
+
import { BedrockEvent } from "react-native-bedrock";
|
|
468
|
+
|
|
469
|
+
// src/native-event-emitter/event-plugins/EntryMessageExitedEvent.ts
|
|
470
|
+
import { BedrockEventDefinition } from "react-native-bedrock";
|
|
471
|
+
var EntryMessageExitedEvent = class extends BedrockEventDefinition {
|
|
472
|
+
name = "entryMessageExited";
|
|
473
|
+
remove() {
|
|
474
|
+
}
|
|
475
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
476
|
+
listener(_) {
|
|
477
|
+
}
|
|
478
|
+
};
|
|
479
|
+
|
|
480
|
+
// src/native-event-emitter/event-plugins/UpdateLocationEvent.ts
|
|
481
|
+
import { BedrockEventDefinition as BedrockEventDefinition2 } from "react-native-bedrock";
|
|
482
|
+
|
|
483
|
+
// src/native-event-emitter/nativeEventEmitter.ts
|
|
484
|
+
import { NativeEventEmitter } from "react-native";
|
|
485
|
+
var nativeEventEmitter = new NativeEventEmitter(AppsInTossModuleInstance);
|
|
486
|
+
|
|
487
|
+
// src/native-event-emitter/event-plugins/UpdateLocationEvent.ts
|
|
488
|
+
var UpdateLocationEvent = class extends BedrockEventDefinition2 {
|
|
489
|
+
name = "updateLocationEvent";
|
|
490
|
+
subscriptionCount = 0;
|
|
491
|
+
ref = {
|
|
492
|
+
remove: () => {
|
|
493
|
+
}
|
|
494
|
+
};
|
|
495
|
+
remove() {
|
|
496
|
+
--this.subscriptionCount === 0 && AppsInTossModuleInstance.stopUpdateLocation({});
|
|
497
|
+
this.ref.remove();
|
|
498
|
+
}
|
|
499
|
+
listener(options, onEvent, onError) {
|
|
500
|
+
requestPermission({ name: "geolocation", access: "access" }).then((permissionStatus) => {
|
|
501
|
+
if (permissionStatus === "denied") {
|
|
502
|
+
onError(new Error("\uC704\uCE58 \uAD8C\uD55C\uC774 \uAC70\uBD80\uB418\uC5C8\uC5B4\uC694."));
|
|
503
|
+
return;
|
|
504
|
+
}
|
|
505
|
+
void AppsInTossModuleInstance.startUpdateLocation(options).catch(onError);
|
|
506
|
+
const subscription = nativeEventEmitter.addListener("updateLocation", onEvent);
|
|
507
|
+
this.ref = {
|
|
508
|
+
remove: () => subscription?.remove()
|
|
509
|
+
};
|
|
510
|
+
this.subscriptionCount++;
|
|
511
|
+
}).catch(onError);
|
|
512
|
+
}
|
|
513
|
+
};
|
|
514
|
+
|
|
515
|
+
// src/native-event-emitter/internal/AppBridgeCallbackEvent.ts
|
|
516
|
+
import { BedrockEventDefinition as BedrockEventDefinition3 } from "react-native-bedrock";
|
|
517
|
+
var UNSAFE__nativeEventEmitter = nativeEventEmitter;
|
|
518
|
+
var AppBridgeCallbackEvent = class _AppBridgeCallbackEvent extends BedrockEventDefinition3 {
|
|
519
|
+
static INTERNAL__appBridgeSubscription;
|
|
520
|
+
name = "appBridgeCallbackEvent";
|
|
521
|
+
constructor() {
|
|
522
|
+
super();
|
|
523
|
+
this.registerAppBridgeCallbackEventListener();
|
|
524
|
+
}
|
|
525
|
+
remove() {
|
|
526
|
+
}
|
|
527
|
+
listener() {
|
|
528
|
+
}
|
|
529
|
+
registerAppBridgeCallbackEventListener() {
|
|
530
|
+
if (_AppBridgeCallbackEvent.INTERNAL__appBridgeSubscription != null) {
|
|
531
|
+
return;
|
|
532
|
+
}
|
|
533
|
+
_AppBridgeCallbackEvent.INTERNAL__appBridgeSubscription = UNSAFE__nativeEventEmitter.addListener(
|
|
534
|
+
"appBridgeCallback",
|
|
535
|
+
this.ensureInvokeAppBridgeCallback
|
|
536
|
+
);
|
|
537
|
+
}
|
|
538
|
+
ensureInvokeAppBridgeCallback(result) {
|
|
539
|
+
if (typeof result === "object" && typeof result.name === "string") {
|
|
540
|
+
INTERNAL__appBridgeHandler.invokeAppBridgeCallback(result.name, result.params);
|
|
541
|
+
} else {
|
|
542
|
+
console.warn("Invalid app bridge callback result:", result);
|
|
543
|
+
}
|
|
544
|
+
}
|
|
545
|
+
};
|
|
546
|
+
|
|
547
|
+
// src/native-event-emitter/appsInTossEvent.ts
|
|
548
|
+
var appsInTossEvent = new BedrockEvent([
|
|
549
|
+
new AppBridgeCallbackEvent(),
|
|
550
|
+
new UpdateLocationEvent(),
|
|
551
|
+
new EntryMessageExitedEvent()
|
|
552
|
+
]);
|
|
553
|
+
|
|
554
|
+
// src/native-event-emitter/startUpdateLocation.ts
|
|
555
|
+
function startUpdateLocation(eventParams) {
|
|
556
|
+
return appsInTossEvent.addEventListener("updateLocationEvent", eventParams);
|
|
557
|
+
}
|
|
558
|
+
|
|
559
|
+
// src/env.ts
|
|
560
|
+
var env = {
|
|
561
|
+
getDeploymentId: () => __DEV__ ? "local" : global.__appsInToss?.deploymentId
|
|
562
|
+
};
|
|
563
|
+
|
|
564
|
+
// src/core/hooks/useReferrer.ts
|
|
565
|
+
import { useMemo } from "react";
|
|
566
|
+
import { getSchemeUri } from "react-native-bedrock";
|
|
567
|
+
function useReferrer() {
|
|
568
|
+
return useMemo(() => {
|
|
569
|
+
try {
|
|
570
|
+
return new URL(getSchemeUri()).searchParams.get("referrer");
|
|
571
|
+
} catch {
|
|
572
|
+
return null;
|
|
573
|
+
}
|
|
574
|
+
}, []);
|
|
575
|
+
}
|
|
576
|
+
|
|
577
|
+
// src/core/components/AppEvent.tsx
|
|
578
|
+
var ENTRY_APP_EVENT_SCHEMA_ID = 1562181;
|
|
579
|
+
function EntryAppEvent() {
|
|
580
|
+
const referrer = useReferrer() ?? "";
|
|
581
|
+
useEffect(() => {
|
|
582
|
+
eventLog({
|
|
583
|
+
log_name: "appsintoss_app_visit::impression__enter_appsintoss",
|
|
584
|
+
log_type: "info",
|
|
585
|
+
params: {
|
|
586
|
+
is_transform: true,
|
|
587
|
+
schema_id: ENTRY_APP_EVENT_SCHEMA_ID,
|
|
588
|
+
deployment_id: env.getDeploymentId(),
|
|
589
|
+
referrer
|
|
590
|
+
}
|
|
591
|
+
});
|
|
592
|
+
}, [referrer]);
|
|
593
|
+
return null;
|
|
594
|
+
}
|
|
595
|
+
function SystemAppEvent({ ...initialProps }) {
|
|
596
|
+
useEffect(() => {
|
|
597
|
+
eventLog({
|
|
598
|
+
log_name: "AppsInTossInitialProps",
|
|
599
|
+
log_type: "debug",
|
|
600
|
+
params: {
|
|
601
|
+
...initialProps,
|
|
602
|
+
deployment_id: env.getDeploymentId(),
|
|
603
|
+
schemeUri: getSchemeUri2()
|
|
604
|
+
}
|
|
605
|
+
});
|
|
606
|
+
}, [initialProps]);
|
|
607
|
+
return null;
|
|
608
|
+
}
|
|
609
|
+
var AppEvent = {
|
|
610
|
+
Entry: EntryAppEvent,
|
|
611
|
+
System: SystemAppEvent
|
|
612
|
+
};
|
|
613
|
+
|
|
614
|
+
// src/core/hooks/useAppsInTossBridge.ts
|
|
615
|
+
import { useBridge } from "@toss-design-system/react-native";
|
|
616
|
+
import { useEffect as useEffect2 } from "react";
|
|
617
|
+
|
|
618
|
+
// src/core/utils/getAppsInTossGlobals.ts
|
|
619
|
+
function getAppsInTossGlobals() {
|
|
620
|
+
if (global.__appsInToss == null) {
|
|
621
|
+
throw new Error("invalid apps-in-toss globals");
|
|
622
|
+
}
|
|
623
|
+
return global.__appsInToss;
|
|
624
|
+
}
|
|
625
|
+
|
|
626
|
+
// src/core/utils/toIcon.ts
|
|
627
|
+
function toIcon(source) {
|
|
628
|
+
return source.startsWith("http") ? { source: { uri: source } } : { name: source };
|
|
629
|
+
}
|
|
630
|
+
|
|
631
|
+
// src/core/hooks/useAppsInTossBridge.ts
|
|
632
|
+
function useAppsInTossBridge() {
|
|
633
|
+
const controller = useBridge();
|
|
634
|
+
const appsInTossGlobals2 = getAppsInTossGlobals();
|
|
635
|
+
useEffect2(() => {
|
|
636
|
+
const commonProps = {
|
|
637
|
+
serviceName: appsInTossGlobals2.brandDisplayName,
|
|
638
|
+
icon: toIcon(appsInTossGlobals2.brandIcon),
|
|
639
|
+
color: appsInTossGlobals2.brandPrimaryColor,
|
|
640
|
+
colorMode: appsInTossGlobals2.brandBridgeColorMode
|
|
641
|
+
};
|
|
642
|
+
controller.open({
|
|
643
|
+
...commonProps,
|
|
644
|
+
onExited: () => {
|
|
645
|
+
appsInTossEvent.emit("entryMessageExited", void 0);
|
|
646
|
+
}
|
|
647
|
+
});
|
|
648
|
+
}, []);
|
|
649
|
+
}
|
|
650
|
+
|
|
651
|
+
// src/core/registerApp.tsx
|
|
652
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
653
|
+
function AppsInTossContainer(Container, { children, ...initialProps }) {
|
|
654
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
655
|
+
/* @__PURE__ */ jsx(AppEvent.Entry, {}),
|
|
656
|
+
/* @__PURE__ */ jsx(AppEvent.System, { ...initialProps }),
|
|
657
|
+
/* @__PURE__ */ jsx(Container, { ...initialProps, children: /* @__PURE__ */ jsx(TDSProvider, { colorPreference: "light", token: { color: { primary: getAppsInTossGlobals().brandPrimaryColor } }, children: /* @__PURE__ */ jsx(TDSContainer, { ...initialProps, children }) }) })
|
|
658
|
+
] });
|
|
659
|
+
}
|
|
660
|
+
function TDSContainer({ children }) {
|
|
661
|
+
useAppsInTossBridge();
|
|
662
|
+
return /* @__PURE__ */ jsx(Fragment, { children });
|
|
663
|
+
}
|
|
664
|
+
function registerApp(container, { context }) {
|
|
665
|
+
return Bedrock.registerApp(AppsInTossContainer.bind(null, container), {
|
|
666
|
+
appName: getAppName(),
|
|
667
|
+
context,
|
|
668
|
+
defaultScreenOption: {
|
|
669
|
+
statusBarStyle: "dark"
|
|
670
|
+
}
|
|
671
|
+
});
|
|
672
|
+
}
|
|
673
|
+
function getAppName() {
|
|
674
|
+
try {
|
|
675
|
+
return global.__bedrock.app.name;
|
|
676
|
+
} catch (error) {
|
|
677
|
+
console.error("unexpected error occurred while getting app name");
|
|
678
|
+
throw error;
|
|
679
|
+
}
|
|
680
|
+
}
|
|
681
|
+
|
|
682
|
+
// src/core/index.ts
|
|
683
|
+
var AppsInToss = {
|
|
684
|
+
registerApp
|
|
290
685
|
};
|
|
291
686
|
|
|
292
687
|
// src/components/WebView.tsx
|
|
@@ -295,8 +690,8 @@ import {
|
|
|
295
690
|
ExternalWebViewScreen
|
|
296
691
|
} from "@toss-design-system/react-native";
|
|
297
692
|
import { useSafeAreaBottom, useSafeAreaTop as useSafeAreaTop2 } from "@toss-design-system/react-native/private";
|
|
298
|
-
import { useMemo as
|
|
299
|
-
import { getSchemeUri, useBedrockEvent } from "react-native-bedrock";
|
|
693
|
+
import { useMemo as useMemo3 } from "react";
|
|
694
|
+
import { getSchemeUri as getSchemeUri3, useBedrockEvent } from "react-native-bedrock";
|
|
300
695
|
import * as bedrockAsyncBridges from "react-native-bedrock/async-bridges";
|
|
301
696
|
import * as bedrockConstantBridges from "react-native-bedrock/constant-bridges";
|
|
302
697
|
|
|
@@ -306,24 +701,24 @@ import {
|
|
|
306
701
|
} from "@react-native-bedrock/native/react-native-webview";
|
|
307
702
|
import { useDialog } from "@toss-design-system/react-native";
|
|
308
703
|
import { josa } from "es-hangul";
|
|
309
|
-
import { forwardRef, useCallback, useEffect as
|
|
310
|
-
import { BackHandler, Platform as
|
|
704
|
+
import { forwardRef, useCallback, useEffect as useEffect3 } from "react";
|
|
705
|
+
import { BackHandler, Platform as Platform5, View as View3 } from "react-native";
|
|
311
706
|
import { closeView, setIosSwipeGestureEnabled } from "react-native-bedrock";
|
|
312
707
|
|
|
313
708
|
// src/components/GameWebViewNavigationBar/GameNavigationBar.tsx
|
|
314
709
|
import { SvgXml } from "@react-native-bedrock/native/react-native-svg";
|
|
315
710
|
import { PageNavbar } from "@toss-design-system/react-native";
|
|
316
|
-
import { Platform as
|
|
711
|
+
import { Platform as Platform4, TouchableOpacity, View as View2 } from "react-native";
|
|
317
712
|
|
|
318
713
|
// src/components/GameWebViewNavigationBar/HeaderRight.tsx
|
|
319
714
|
import { StyleSheet, View } from "react-native";
|
|
320
715
|
|
|
321
716
|
// src/components/GameWebViewNavigationBar/byPlatform.ts
|
|
322
|
-
import { Platform } from "react-native";
|
|
717
|
+
import { Platform as Platform2 } from "react-native";
|
|
323
718
|
function byPlatform({
|
|
324
719
|
...props
|
|
325
720
|
}) {
|
|
326
|
-
return (props[
|
|
721
|
+
return (props[Platform2.OS] ?? props.fallback)();
|
|
327
722
|
}
|
|
328
723
|
|
|
329
724
|
// src/components/GameWebViewNavigationBar/constants.ts
|
|
@@ -357,34 +752,34 @@ var styles = StyleSheet.create({
|
|
|
357
752
|
|
|
358
753
|
// src/components/GameWebViewNavigationBar/useSafeAreaTop.ts
|
|
359
754
|
import { useSafeAreaInsets } from "@react-native-bedrock/native/react-native-safe-area-context";
|
|
360
|
-
import { Platform as
|
|
755
|
+
import { Platform as Platform3 } from "react-native";
|
|
361
756
|
function useSafeAreaTop() {
|
|
362
757
|
const safeAreaInsets = useSafeAreaInsets();
|
|
363
|
-
const hasDynamicIsland =
|
|
758
|
+
const hasDynamicIsland = Platform3.OS === "ios" && safeAreaInsets.top > 50;
|
|
364
759
|
const safeAreaTop = hasDynamicIsland ? safeAreaInsets.top - 5 : safeAreaInsets.top;
|
|
365
760
|
return safeAreaTop;
|
|
366
761
|
}
|
|
367
762
|
|
|
368
763
|
// src/components/GameWebViewNavigationBar/GameNavigationBar.tsx
|
|
369
|
-
import { Fragment as Fragment2, jsx as jsx3, jsxs } from "react/jsx-runtime";
|
|
764
|
+
import { Fragment as Fragment2, jsx as jsx3, jsxs as jsxs2 } from "react/jsx-runtime";
|
|
370
765
|
var originXML = '<svg fill="none" height="30" viewBox="0 0 30 30" width="30" xmlns="https://www.w3.org/2000/svg"><rect fill="#031832" fill-opacity=".46" height="30" rx="15" width="30"/><rect height="29.5" rx="14.75" stroke="#d9d9ff" stroke-opacity=".11" stroke-width=".5" width="29.5" x=".25" y=".25"/><path clip-rule="evenodd" d="m16.5119 15.0014 4.7092-4.7092c.0929-.0928.1666-.2031.2169-.32441.0503-.12134.0762-.25141.0762-.38276.0001-.13136-.0258-.26144-.076-.38281s-.1239-.23166-.2167-.32457c-.0929-.09291-.2031-.16662-.3245-.21692-.1213-.05031-.2514-.07622-.3827-.07626-.1314-.00004-.2615.0258-.3828.07603-.1214.05023-.2317.12388-.3246.21673l-4.7092 4.70997-4.71-4.70997c-.1897-.17718-.4408-.27373-.70034-.26927s-.5072.10959-.69069.2932c-.1835.1836-.28848.43132-.29279.69087-.00432.25954.09238.51057.26968.70017l4.71004 4.7092-4.71004 4.7092c-.1392.1401-.23385.3183-.27204.5121-.0382.1939-.01823.3946.05739.5771s.20351.3386.36759.4486.35702.169.55456.1697c.25583 0 .51164-.0975.70664-.2925l4.71-4.71 4.7092 4.71c.0927.093.2029.1668.3243.2172.1213.0504.2514.0763.3828.0763s.2614-.0259.3828-.0763c.1213-.0504.2315-.1242.3243-.2172.0929-.0929.1667-.2032.217-.3246s.0762-.2515.0762-.3829-.0259-.2616-.0762-.383-.1241-.2317-.217-.3245z" fill="#fdfdfe" fill-opacity=".89" fill-rule="evenodd"/></svg>';
|
|
371
766
|
function GameNavigationBar({ onClose }) {
|
|
372
767
|
const safeAreaTop = useSafeAreaTop();
|
|
373
|
-
return /* @__PURE__ */
|
|
768
|
+
return /* @__PURE__ */ jsxs2(Fragment2, { children: [
|
|
374
769
|
/* @__PURE__ */ jsx3(PageNavbar, { preference: { type: "none" } }),
|
|
375
770
|
/* @__PURE__ */ jsx3(
|
|
376
771
|
View2,
|
|
377
772
|
{
|
|
378
773
|
style: {
|
|
379
774
|
width: "100%",
|
|
380
|
-
height:
|
|
775
|
+
height: Platform4.OS === "ios" ? 44 : 54,
|
|
381
776
|
flexDirection: "row",
|
|
382
777
|
alignItems: "center",
|
|
383
778
|
justifyContent: "flex-end",
|
|
384
779
|
position: "absolute",
|
|
385
780
|
zIndex: 9999,
|
|
386
781
|
marginTop: safeAreaTop,
|
|
387
|
-
paddingRight:
|
|
782
|
+
paddingRight: Platform4.OS === "ios" ? 10 : 8
|
|
388
783
|
},
|
|
389
784
|
pointerEvents: "box-none",
|
|
390
785
|
children: /* @__PURE__ */ jsx3(HeaderRight, { children: /* @__PURE__ */ jsx3(
|
|
@@ -395,7 +790,7 @@ function GameNavigationBar({ onClose }) {
|
|
|
395
790
|
accessible: true,
|
|
396
791
|
accessibilityLabel: "\uAC8C\uC784\uC885\uB8CC",
|
|
397
792
|
style: {
|
|
398
|
-
padding:
|
|
793
|
+
padding: Platform4.OS === "ios" ? 7 : 9
|
|
399
794
|
},
|
|
400
795
|
onPress: onClose,
|
|
401
796
|
children: /* @__PURE__ */ jsx3(SvgXml, { xml: originXML, width: 30, height: 30 })
|
|
@@ -407,7 +802,7 @@ function GameNavigationBar({ onClose }) {
|
|
|
407
802
|
}
|
|
408
803
|
|
|
409
804
|
// src/components/GameWebView.tsx
|
|
410
|
-
import { Fragment as Fragment3, jsx as jsx4, jsxs as
|
|
805
|
+
import { Fragment as Fragment3, jsx as jsx4, jsxs as jsxs3 } from "react/jsx-runtime";
|
|
411
806
|
var GameWebView = forwardRef(function GameWebView2(props, ref) {
|
|
412
807
|
const { openConfirm } = useDialog();
|
|
413
808
|
const { brandDisplayName } = getAppsInTossGlobals();
|
|
@@ -422,8 +817,8 @@ var GameWebView = forwardRef(function GameWebView2(props, ref) {
|
|
|
422
817
|
closeView();
|
|
423
818
|
}
|
|
424
819
|
}, [brandDisplayName, openConfirm]);
|
|
425
|
-
|
|
426
|
-
if (
|
|
820
|
+
useEffect3(() => {
|
|
821
|
+
if (Platform5.OS === "ios") {
|
|
427
822
|
setIosSwipeGestureEnabled({ isEnabled: false });
|
|
428
823
|
return () => {
|
|
429
824
|
setIosSwipeGestureEnabled({ isEnabled: true });
|
|
@@ -431,7 +826,7 @@ var GameWebView = forwardRef(function GameWebView2(props, ref) {
|
|
|
431
826
|
}
|
|
432
827
|
return;
|
|
433
828
|
}, []);
|
|
434
|
-
|
|
829
|
+
useEffect3(() => {
|
|
435
830
|
const backHandler = () => {
|
|
436
831
|
handleClose();
|
|
437
832
|
return true;
|
|
@@ -441,7 +836,7 @@ var GameWebView = forwardRef(function GameWebView2(props, ref) {
|
|
|
441
836
|
BackHandler.removeEventListener("hardwareBackPress", backHandler);
|
|
442
837
|
};
|
|
443
838
|
}, [handleClose]);
|
|
444
|
-
return /* @__PURE__ */
|
|
839
|
+
return /* @__PURE__ */ jsxs3(Fragment3, { children: [
|
|
445
840
|
/* @__PURE__ */ jsx4(GameNavigationBar, { onClose: handleClose }),
|
|
446
841
|
/* @__PURE__ */ jsx4(View3, { style: { flex: 1 }, children: /* @__PURE__ */ jsx4(PlainWebView, { ref, ...props }) })
|
|
447
842
|
] });
|
|
@@ -452,7 +847,7 @@ var async_bridges_exports = {};
|
|
|
452
847
|
__export(async_bridges_exports, {
|
|
453
848
|
appLogin: () => appLogin,
|
|
454
849
|
checkoutPayment: () => checkoutPayment,
|
|
455
|
-
|
|
850
|
+
eventLog: () => eventLog,
|
|
456
851
|
fetchAlbumPhotos: () => fetchAlbumPhotos,
|
|
457
852
|
fetchContacts: () => fetchContacts,
|
|
458
853
|
getClipboardText: () => getClipboardText,
|
|
@@ -463,7 +858,7 @@ __export(async_bridges_exports, {
|
|
|
463
858
|
});
|
|
464
859
|
|
|
465
860
|
// src/bridge-handler/useBridgeHandler.tsx
|
|
466
|
-
import { useCallback as useCallback2, useMemo, useRef } from "react";
|
|
861
|
+
import { useCallback as useCallback2, useMemo as useMemo2, useRef } from "react";
|
|
467
862
|
function serializeError(error) {
|
|
468
863
|
return JSON.stringify(error, (_, value) => {
|
|
469
864
|
if (value instanceof Error) {
|
|
@@ -484,15 +879,16 @@ function methodHandler({
|
|
|
484
879
|
handlerMap,
|
|
485
880
|
injectJavaScript
|
|
486
881
|
}) {
|
|
487
|
-
const func =
|
|
488
|
-
const result = await handlerMap[functionName](...args2);
|
|
489
|
-
return result;
|
|
490
|
-
};
|
|
882
|
+
const func = handlerMap[functionName];
|
|
491
883
|
if (!func) {
|
|
492
884
|
console.error(`${functionName} is not a function`);
|
|
493
885
|
return;
|
|
494
886
|
}
|
|
495
|
-
|
|
887
|
+
const wrappedFunc = async (...args2) => {
|
|
888
|
+
const result = await func(...args2);
|
|
889
|
+
return result;
|
|
890
|
+
};
|
|
891
|
+
wrappedFunc(...args).then((result) => {
|
|
496
892
|
injectJavaScript?.(`
|
|
497
893
|
window.__BEDROCK_NATIVE_EMITTER.emit('${functionName}/resolve/${eventId}', ${JSON.stringify(result, null, 0)});
|
|
498
894
|
`);
|
|
@@ -512,7 +908,7 @@ function useBridgeHandler({
|
|
|
512
908
|
injectedJavaScript: originalInjectedJavaScript
|
|
513
909
|
}) {
|
|
514
910
|
const ref = useRef(null);
|
|
515
|
-
const injectedJavaScript =
|
|
911
|
+
const injectedJavaScript = useMemo2(
|
|
516
912
|
() => [
|
|
517
913
|
`window.__CONSTANT_HANDLER_MAP = ${JSON.stringify(
|
|
518
914
|
Object.entries(constantHandlerMap).reduce(
|
|
@@ -596,11 +992,6 @@ __export(constant_bridges_exports, {
|
|
|
596
992
|
getTossAppVersion: () => getTossAppVersion
|
|
597
993
|
});
|
|
598
994
|
|
|
599
|
-
// src/env.ts
|
|
600
|
-
var env = {
|
|
601
|
-
getDeploymentId: () => __DEV__ ? "local" : global.__appsInToss?.deploymentId
|
|
602
|
-
};
|
|
603
|
-
|
|
604
995
|
// src/event-bridges.ts
|
|
605
996
|
var event_bridges_exports = {};
|
|
606
997
|
__export(event_bridges_exports, {
|
|
@@ -610,6 +1001,7 @@ __export(event_bridges_exports, {
|
|
|
610
1001
|
// src/components/WebView.tsx
|
|
611
1002
|
import { jsx as jsx5 } from "react/jsx-runtime";
|
|
612
1003
|
var appsInTossGlobals = getAppsInTossGlobals();
|
|
1004
|
+
var operationalEnvironment = getOperationalEnvironment();
|
|
613
1005
|
var TYPES = ["partner", "external", "game"];
|
|
614
1006
|
var WEBVIEW_TYPES = {
|
|
615
1007
|
partner: PartnerWebViewScreen,
|
|
@@ -618,7 +1010,7 @@ var WEBVIEW_TYPES = {
|
|
|
618
1010
|
};
|
|
619
1011
|
function mergeSchemeQueryParamsInto(url) {
|
|
620
1012
|
const baseUrl = new URL(url);
|
|
621
|
-
const schemeUrl = new URL(
|
|
1013
|
+
const schemeUrl = new URL(getSchemeUri3());
|
|
622
1014
|
baseUrl.pathname = schemeUrl.pathname;
|
|
623
1015
|
for (const [key, value] of schemeUrl.searchParams.entries()) {
|
|
624
1016
|
baseUrl.searchParams.set(key, value);
|
|
@@ -643,7 +1035,7 @@ function WebView({ type, local, onMessage, ...props }) {
|
|
|
643
1035
|
throw new Error(`Invalid WebView type: '${type}'`);
|
|
644
1036
|
}
|
|
645
1037
|
const bedrockEvent = useBedrockEvent();
|
|
646
|
-
const uri =
|
|
1038
|
+
const uri = useMemo3(() => getWebViewUri(local), [local]);
|
|
647
1039
|
const top = useSafeAreaTop2();
|
|
648
1040
|
const bottom = useSafeAreaBottom();
|
|
649
1041
|
const handler = useBridgeHandler({
|
|
@@ -651,7 +1043,16 @@ function WebView({ type, local, onMessage, ...props }) {
|
|
|
651
1043
|
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
652
1044
|
eventListenerMap: {
|
|
653
1045
|
...event_bridges_exports,
|
|
654
|
-
backEvent: ({ onEvent, onError, options }) => bedrockEvent.addEventListener("backEvent", { onEvent, onError, options })
|
|
1046
|
+
backEvent: ({ onEvent, onError, options }) => bedrockEvent.addEventListener("backEvent", { onEvent, onError, options }),
|
|
1047
|
+
entryMessageExited: ({ onEvent, onError }) => appsInTossEvent.addEventListener("entryMessageExited", { onEvent, onError }),
|
|
1048
|
+
updateLocationEvent: ({ onEvent, onError, options }) => appsInTossEvent.addEventListener("updateLocationEvent", { onEvent, onError, options }),
|
|
1049
|
+
/** @internal */
|
|
1050
|
+
appBridgeCallbackEvent: ({ onEvent, onError, options }) => appsInTossEvent.addEventListener("appBridgeCallbackEvent", { onEvent, onError, options }),
|
|
1051
|
+
/** AdMob */
|
|
1052
|
+
loadAdMobInterstitialAd: GoogleAdMob.loadAdMobInterstitialAd,
|
|
1053
|
+
showAdMobInterstitialAd: GoogleAdMob.showAdMobInterstitialAd,
|
|
1054
|
+
loadAdMobRewardedAd: GoogleAdMob.loadAdMobRewardedAd,
|
|
1055
|
+
showAdMobRewardedAd: GoogleAdMob.showAdMobRewardedAd
|
|
655
1056
|
},
|
|
656
1057
|
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
657
1058
|
// @ts-expect-error
|
|
@@ -659,7 +1060,12 @@ function WebView({ type, local, onMessage, ...props }) {
|
|
|
659
1060
|
...bedrockConstantBridges,
|
|
660
1061
|
...constant_bridges_exports,
|
|
661
1062
|
getSafeAreaTop: () => top,
|
|
662
|
-
getSafeAreaBottom: () => bottom
|
|
1063
|
+
getSafeAreaBottom: () => bottom,
|
|
1064
|
+
/** AdMob */
|
|
1065
|
+
loadAdMobInterstitialAd_isSupported: GoogleAdMob.loadAdMobInterstitialAd.isSupported,
|
|
1066
|
+
showAdMobInterstitialAd_isSupported: GoogleAdMob.showAdMobInterstitialAd.isSupported,
|
|
1067
|
+
loadAdMobRewardedAd_isSupported: GoogleAdMob.loadAdMobRewardedAd.isSupported,
|
|
1068
|
+
showAdMobRewardedAd_isSupported: GoogleAdMob.showAdMobRewardedAd.isSupported
|
|
663
1069
|
},
|
|
664
1070
|
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
665
1071
|
// @ts-expect-error
|
|
@@ -675,7 +1081,7 @@ function WebView({ type, local, onMessage, ...props }) {
|
|
|
675
1081
|
clearItems: Storage.clearItems
|
|
676
1082
|
}
|
|
677
1083
|
});
|
|
678
|
-
const baseProps =
|
|
1084
|
+
const baseProps = useMemo3(() => {
|
|
679
1085
|
switch (type) {
|
|
680
1086
|
case "partner": {
|
|
681
1087
|
const headerOnlyProp = {
|
|
@@ -705,10 +1111,7 @@ function WebView({ type, local, onMessage, ...props }) {
|
|
|
705
1111
|
}
|
|
706
1112
|
}, [type, props]);
|
|
707
1113
|
const BaseWebView = WEBVIEW_TYPES[type];
|
|
708
|
-
const
|
|
709
|
-
() => getOperationalEnvironment() === "sandbox",
|
|
710
|
-
[]
|
|
711
|
-
);
|
|
1114
|
+
const webViewDebuggingEnabled = operationalEnvironment === "sandbox";
|
|
712
1115
|
return /* @__PURE__ */ jsx5(
|
|
713
1116
|
BaseWebView,
|
|
714
1117
|
{
|
|
@@ -717,7 +1120,7 @@ function WebView({ type, local, onMessage, ...props }) {
|
|
|
717
1120
|
...baseProps,
|
|
718
1121
|
source: { uri },
|
|
719
1122
|
sharedCookiesEnabled: true,
|
|
720
|
-
webviewDebuggingEnabled,
|
|
1123
|
+
webviewDebuggingEnabled: webViewDebuggingEnabled,
|
|
721
1124
|
thirdPartyCookiesEnabled: true,
|
|
722
1125
|
onMessage: handler.onMessage,
|
|
723
1126
|
injectedJavaScript: handler.injectedJavaScript,
|
|
@@ -733,12 +1136,12 @@ function ensureValue(value, name) {
|
|
|
733
1136
|
}
|
|
734
1137
|
|
|
735
1138
|
// src/hooks/useGeolocation.ts
|
|
736
|
-
import { useState, useEffect as
|
|
1139
|
+
import { useState, useEffect as useEffect4 } from "react";
|
|
737
1140
|
import { useVisibility } from "react-native-bedrock";
|
|
738
1141
|
function useGeolocation({ accuracy, distanceInterval, timeInterval }) {
|
|
739
1142
|
const isVisible = useVisibility();
|
|
740
1143
|
const [location, setLocation] = useState(null);
|
|
741
|
-
|
|
1144
|
+
useEffect4(() => {
|
|
742
1145
|
if (!isVisible) {
|
|
743
1146
|
return;
|
|
744
1147
|
}
|
|
@@ -768,11 +1171,14 @@ var Accuracy2 = /* @__PURE__ */ ((Accuracy3) => {
|
|
|
768
1171
|
export {
|
|
769
1172
|
Accuracy2 as Accuracy,
|
|
770
1173
|
AppsInToss,
|
|
1174
|
+
GoogleAdMob,
|
|
771
1175
|
Storage,
|
|
772
1176
|
TossPay,
|
|
773
1177
|
WebView,
|
|
774
1178
|
appLogin,
|
|
1179
|
+
appsInTossEvent,
|
|
775
1180
|
env,
|
|
1181
|
+
eventLog,
|
|
776
1182
|
fetchAlbumPhotos,
|
|
777
1183
|
fetchContacts,
|
|
778
1184
|
getClipboardText,
|
|
@@ -781,6 +1187,7 @@ export {
|
|
|
781
1187
|
getOperationalEnvironment,
|
|
782
1188
|
getTossAppVersion,
|
|
783
1189
|
getTossShareLink,
|
|
1190
|
+
isMinVersionSupported,
|
|
784
1191
|
openCamera,
|
|
785
1192
|
setClipboardText,
|
|
786
1193
|
startUpdateLocation,
|