@apps-in-toss/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/index.cjs +726 -174
- package/dist/index.d.cts +670 -334
- package/dist/index.d.ts +670 -334
- package/dist/index.js +695 -148
- package/package.json +10 -9
- package/src/async-bridges.ts +2 -1
package/dist/index.js
CHANGED
|
@@ -8,77 +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
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
useAppsInTossBridge();
|
|
50
|
-
return /* @__PURE__ */ jsx(Fragment, { children });
|
|
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);
|
|
51
35
|
}
|
|
52
|
-
function
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
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
|
|
56
42
|
});
|
|
43
|
+
void promise.then(onSuccess).catch(onError);
|
|
44
|
+
return unregisterAll;
|
|
57
45
|
}
|
|
58
|
-
function
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
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;
|
|
64
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;
|
|
65
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
|
+
};
|
|
66
76
|
|
|
67
|
-
// src/
|
|
68
|
-
|
|
69
|
-
|
|
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;
|
|
70
150
|
};
|
|
71
151
|
|
|
72
|
-
// src/native-
|
|
73
|
-
|
|
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
|
+
}
|
|
74
172
|
|
|
75
|
-
// src/native-
|
|
76
|
-
|
|
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();
|
|
77
275
|
|
|
78
|
-
// src/native-modules/
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
276
|
+
// src/native-modules/checkoutPayment.ts
|
|
277
|
+
async function checkoutPayment(options) {
|
|
278
|
+
return AppsInTossModule.checkoutPayment({ params: options });
|
|
279
|
+
}
|
|
82
280
|
|
|
83
281
|
// src/native-modules/getPermission.ts
|
|
84
282
|
function getPermission(permission) {
|
|
@@ -102,56 +300,6 @@ async function requestPermission(permission) {
|
|
|
102
300
|
}
|
|
103
301
|
}
|
|
104
302
|
|
|
105
|
-
// src/native-event-emitter/nativeEventEmitter.ts
|
|
106
|
-
import { NativeEventEmitter } from "react-native";
|
|
107
|
-
var nativeEventEmitter = new NativeEventEmitter(AppsInTossModuleInstance);
|
|
108
|
-
|
|
109
|
-
// src/native-event-emitter/event-plugins/UpdateLocationEvent.ts
|
|
110
|
-
var UpdateLocationEvent = class extends BedrockEventDefinition {
|
|
111
|
-
name = "updateLocationEvent";
|
|
112
|
-
subscriptionCount = 0;
|
|
113
|
-
ref = {
|
|
114
|
-
remove: () => {
|
|
115
|
-
}
|
|
116
|
-
};
|
|
117
|
-
remove() {
|
|
118
|
-
--this.subscriptionCount === 0 && AppsInTossModuleInstance.stopUpdateLocation({});
|
|
119
|
-
this.ref.remove();
|
|
120
|
-
}
|
|
121
|
-
listener(options, onEvent, onError) {
|
|
122
|
-
requestPermission({ name: "geolocation", access: "access" }).then((permissionStatus) => {
|
|
123
|
-
if (permissionStatus === "denied") {
|
|
124
|
-
onError(new Error("\uC704\uCE58 \uAD8C\uD55C\uC774 \uAC70\uBD80\uB418\uC5C8\uC5B4\uC694."));
|
|
125
|
-
return;
|
|
126
|
-
}
|
|
127
|
-
void AppsInTossModuleInstance.startUpdateLocation(options).catch(onError);
|
|
128
|
-
const subscription = nativeEventEmitter.addListener("updateLocation", onEvent);
|
|
129
|
-
this.ref = {
|
|
130
|
-
remove: () => subscription?.remove()
|
|
131
|
-
};
|
|
132
|
-
this.subscriptionCount++;
|
|
133
|
-
}).catch(onError);
|
|
134
|
-
}
|
|
135
|
-
};
|
|
136
|
-
|
|
137
|
-
// src/native-event-emitter/bedrock-event.ts
|
|
138
|
-
var appsInTossEvent = new BedrockEvent([new UpdateLocationEvent()]);
|
|
139
|
-
|
|
140
|
-
// src/native-event-emitter/startUpdateLocation.ts
|
|
141
|
-
function startUpdateLocation(eventParams) {
|
|
142
|
-
return appsInTossEvent.addEventListener("updateLocationEvent", eventParams);
|
|
143
|
-
}
|
|
144
|
-
|
|
145
|
-
// src/native-modules/checkoutPayment.ts
|
|
146
|
-
async function checkoutPayment(options) {
|
|
147
|
-
return AppsInTossModule.checkoutPayment(options);
|
|
148
|
-
}
|
|
149
|
-
|
|
150
|
-
// src/native-modules/executePayment.ts
|
|
151
|
-
async function executePayment(options) {
|
|
152
|
-
return AppsInTossModule.executePayment(options);
|
|
153
|
-
}
|
|
154
|
-
|
|
155
303
|
// src/native-modules/setClipboardText.ts
|
|
156
304
|
async function setClipboardText(text) {
|
|
157
305
|
const permissionStatus = await requestPermission({ name: "clipboard", access: "write" });
|
|
@@ -233,11 +381,6 @@ async function appLogin() {
|
|
|
233
381
|
return AppsInTossModule.appLogin({});
|
|
234
382
|
}
|
|
235
383
|
|
|
236
|
-
// src/native-modules/getOperationalEnvironment.ts
|
|
237
|
-
function getOperationalEnvironment() {
|
|
238
|
-
return AppsInTossModule.operationalEnvironment;
|
|
239
|
-
}
|
|
240
|
-
|
|
241
384
|
// src/native-modules/getTossAppVersion.ts
|
|
242
385
|
function getTossAppVersion() {
|
|
243
386
|
return AppsInTossModule.tossAppVersion;
|
|
@@ -271,10 +414,274 @@ var Storage = {
|
|
|
271
414
|
clearItems
|
|
272
415
|
};
|
|
273
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
|
+
|
|
446
|
+
// src/native-modules/getTossShareLink.ts
|
|
447
|
+
async function getTossShareLink(path) {
|
|
448
|
+
const { shareLink } = await AppsInTossModule.getTossShareLink({});
|
|
449
|
+
const shareUrl = new URL(shareLink);
|
|
450
|
+
shareUrl.searchParams.set("deep_link_value", path);
|
|
451
|
+
shareUrl.searchParams.set("af_dp", path);
|
|
452
|
+
return shareUrl.toString();
|
|
453
|
+
}
|
|
454
|
+
|
|
274
455
|
// src/native-modules/index.ts
|
|
275
456
|
var TossPay = {
|
|
276
|
-
checkoutPayment
|
|
277
|
-
|
|
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
|
|
278
685
|
};
|
|
279
686
|
|
|
280
687
|
// src/components/WebView.tsx
|
|
@@ -283,8 +690,8 @@ import {
|
|
|
283
690
|
ExternalWebViewScreen
|
|
284
691
|
} from "@toss-design-system/react-native";
|
|
285
692
|
import { useSafeAreaBottom, useSafeAreaTop as useSafeAreaTop2 } from "@toss-design-system/react-native/private";
|
|
286
|
-
import { useMemo } from "react";
|
|
287
|
-
import { getSchemeUri
|
|
693
|
+
import { useMemo as useMemo3 } from "react";
|
|
694
|
+
import { getSchemeUri as getSchemeUri3, useBedrockEvent } from "react-native-bedrock";
|
|
288
695
|
import * as bedrockAsyncBridges from "react-native-bedrock/async-bridges";
|
|
289
696
|
import * as bedrockConstantBridges from "react-native-bedrock/constant-bridges";
|
|
290
697
|
|
|
@@ -294,24 +701,24 @@ import {
|
|
|
294
701
|
} from "@react-native-bedrock/native/react-native-webview";
|
|
295
702
|
import { useDialog } from "@toss-design-system/react-native";
|
|
296
703
|
import { josa } from "es-hangul";
|
|
297
|
-
import { forwardRef, useCallback, useEffect as
|
|
298
|
-
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";
|
|
299
706
|
import { closeView, setIosSwipeGestureEnabled } from "react-native-bedrock";
|
|
300
707
|
|
|
301
708
|
// src/components/GameWebViewNavigationBar/GameNavigationBar.tsx
|
|
302
709
|
import { SvgXml } from "@react-native-bedrock/native/react-native-svg";
|
|
303
710
|
import { PageNavbar } from "@toss-design-system/react-native";
|
|
304
|
-
import { Platform as
|
|
711
|
+
import { Platform as Platform4, TouchableOpacity, View as View2 } from "react-native";
|
|
305
712
|
|
|
306
713
|
// src/components/GameWebViewNavigationBar/HeaderRight.tsx
|
|
307
714
|
import { StyleSheet, View } from "react-native";
|
|
308
715
|
|
|
309
716
|
// src/components/GameWebViewNavigationBar/byPlatform.ts
|
|
310
|
-
import { Platform } from "react-native";
|
|
717
|
+
import { Platform as Platform2 } from "react-native";
|
|
311
718
|
function byPlatform({
|
|
312
719
|
...props
|
|
313
720
|
}) {
|
|
314
|
-
return (props[
|
|
721
|
+
return (props[Platform2.OS] ?? props.fallback)();
|
|
315
722
|
}
|
|
316
723
|
|
|
317
724
|
// src/components/GameWebViewNavigationBar/constants.ts
|
|
@@ -345,34 +752,34 @@ var styles = StyleSheet.create({
|
|
|
345
752
|
|
|
346
753
|
// src/components/GameWebViewNavigationBar/useSafeAreaTop.ts
|
|
347
754
|
import { useSafeAreaInsets } from "@react-native-bedrock/native/react-native-safe-area-context";
|
|
348
|
-
import { Platform as
|
|
755
|
+
import { Platform as Platform3 } from "react-native";
|
|
349
756
|
function useSafeAreaTop() {
|
|
350
757
|
const safeAreaInsets = useSafeAreaInsets();
|
|
351
|
-
const hasDynamicIsland =
|
|
758
|
+
const hasDynamicIsland = Platform3.OS === "ios" && safeAreaInsets.top > 50;
|
|
352
759
|
const safeAreaTop = hasDynamicIsland ? safeAreaInsets.top - 5 : safeAreaInsets.top;
|
|
353
760
|
return safeAreaTop;
|
|
354
761
|
}
|
|
355
762
|
|
|
356
763
|
// src/components/GameWebViewNavigationBar/GameNavigationBar.tsx
|
|
357
|
-
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";
|
|
358
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>';
|
|
359
766
|
function GameNavigationBar({ onClose }) {
|
|
360
767
|
const safeAreaTop = useSafeAreaTop();
|
|
361
|
-
return /* @__PURE__ */
|
|
768
|
+
return /* @__PURE__ */ jsxs2(Fragment2, { children: [
|
|
362
769
|
/* @__PURE__ */ jsx3(PageNavbar, { preference: { type: "none" } }),
|
|
363
770
|
/* @__PURE__ */ jsx3(
|
|
364
771
|
View2,
|
|
365
772
|
{
|
|
366
773
|
style: {
|
|
367
774
|
width: "100%",
|
|
368
|
-
height:
|
|
775
|
+
height: Platform4.OS === "ios" ? 44 : 54,
|
|
369
776
|
flexDirection: "row",
|
|
370
777
|
alignItems: "center",
|
|
371
778
|
justifyContent: "flex-end",
|
|
372
779
|
position: "absolute",
|
|
373
780
|
zIndex: 9999,
|
|
374
781
|
marginTop: safeAreaTop,
|
|
375
|
-
paddingRight:
|
|
782
|
+
paddingRight: Platform4.OS === "ios" ? 10 : 8
|
|
376
783
|
},
|
|
377
784
|
pointerEvents: "box-none",
|
|
378
785
|
children: /* @__PURE__ */ jsx3(HeaderRight, { children: /* @__PURE__ */ jsx3(
|
|
@@ -383,7 +790,7 @@ function GameNavigationBar({ onClose }) {
|
|
|
383
790
|
accessible: true,
|
|
384
791
|
accessibilityLabel: "\uAC8C\uC784\uC885\uB8CC",
|
|
385
792
|
style: {
|
|
386
|
-
padding:
|
|
793
|
+
padding: Platform4.OS === "ios" ? 7 : 9
|
|
387
794
|
},
|
|
388
795
|
onPress: onClose,
|
|
389
796
|
children: /* @__PURE__ */ jsx3(SvgXml, { xml: originXML, width: 30, height: 30 })
|
|
@@ -395,7 +802,7 @@ function GameNavigationBar({ onClose }) {
|
|
|
395
802
|
}
|
|
396
803
|
|
|
397
804
|
// src/components/GameWebView.tsx
|
|
398
|
-
import { Fragment as Fragment3, jsx as jsx4, jsxs as
|
|
805
|
+
import { Fragment as Fragment3, jsx as jsx4, jsxs as jsxs3 } from "react/jsx-runtime";
|
|
399
806
|
var GameWebView = forwardRef(function GameWebView2(props, ref) {
|
|
400
807
|
const { openConfirm } = useDialog();
|
|
401
808
|
const { brandDisplayName } = getAppsInTossGlobals();
|
|
@@ -410,8 +817,8 @@ var GameWebView = forwardRef(function GameWebView2(props, ref) {
|
|
|
410
817
|
closeView();
|
|
411
818
|
}
|
|
412
819
|
}, [brandDisplayName, openConfirm]);
|
|
413
|
-
|
|
414
|
-
if (
|
|
820
|
+
useEffect3(() => {
|
|
821
|
+
if (Platform5.OS === "ios") {
|
|
415
822
|
setIosSwipeGestureEnabled({ isEnabled: false });
|
|
416
823
|
return () => {
|
|
417
824
|
setIosSwipeGestureEnabled({ isEnabled: true });
|
|
@@ -419,7 +826,7 @@ var GameWebView = forwardRef(function GameWebView2(props, ref) {
|
|
|
419
826
|
}
|
|
420
827
|
return;
|
|
421
828
|
}, []);
|
|
422
|
-
|
|
829
|
+
useEffect3(() => {
|
|
423
830
|
const backHandler = () => {
|
|
424
831
|
handleClose();
|
|
425
832
|
return true;
|
|
@@ -429,7 +836,7 @@ var GameWebView = forwardRef(function GameWebView2(props, ref) {
|
|
|
429
836
|
BackHandler.removeEventListener("hardwareBackPress", backHandler);
|
|
430
837
|
};
|
|
431
838
|
}, [handleClose]);
|
|
432
|
-
return /* @__PURE__ */
|
|
839
|
+
return /* @__PURE__ */ jsxs3(Fragment3, { children: [
|
|
433
840
|
/* @__PURE__ */ jsx4(GameNavigationBar, { onClose: handleClose }),
|
|
434
841
|
/* @__PURE__ */ jsx4(View3, { style: { flex: 1 }, children: /* @__PURE__ */ jsx4(PlainWebView, { ref, ...props }) })
|
|
435
842
|
] });
|
|
@@ -440,15 +847,143 @@ var async_bridges_exports = {};
|
|
|
440
847
|
__export(async_bridges_exports, {
|
|
441
848
|
appLogin: () => appLogin,
|
|
442
849
|
checkoutPayment: () => checkoutPayment,
|
|
443
|
-
|
|
850
|
+
eventLog: () => eventLog,
|
|
444
851
|
fetchAlbumPhotos: () => fetchAlbumPhotos,
|
|
445
852
|
fetchContacts: () => fetchContacts,
|
|
446
853
|
getClipboardText: () => getClipboardText,
|
|
447
854
|
getCurrentLocation: () => getCurrentLocation,
|
|
855
|
+
getTossShareLink: () => getTossShareLink,
|
|
448
856
|
openCamera: () => openCamera,
|
|
449
857
|
setClipboardText: () => setClipboardText
|
|
450
858
|
});
|
|
451
859
|
|
|
860
|
+
// src/bridge-handler/useBridgeHandler.tsx
|
|
861
|
+
import { useCallback as useCallback2, useMemo as useMemo2, useRef } from "react";
|
|
862
|
+
function serializeError(error) {
|
|
863
|
+
return JSON.stringify(error, (_, value) => {
|
|
864
|
+
if (value instanceof Error) {
|
|
865
|
+
return {
|
|
866
|
+
name: value.name,
|
|
867
|
+
message: value.message,
|
|
868
|
+
stack: value.stack,
|
|
869
|
+
__isError: true
|
|
870
|
+
};
|
|
871
|
+
}
|
|
872
|
+
return value;
|
|
873
|
+
});
|
|
874
|
+
}
|
|
875
|
+
function methodHandler({
|
|
876
|
+
args,
|
|
877
|
+
eventId,
|
|
878
|
+
functionName,
|
|
879
|
+
handlerMap,
|
|
880
|
+
injectJavaScript
|
|
881
|
+
}) {
|
|
882
|
+
const func = handlerMap[functionName];
|
|
883
|
+
if (!func) {
|
|
884
|
+
console.error(`${functionName} is not a function`);
|
|
885
|
+
return;
|
|
886
|
+
}
|
|
887
|
+
const wrappedFunc = async (...args2) => {
|
|
888
|
+
const result = await func(...args2);
|
|
889
|
+
return result;
|
|
890
|
+
};
|
|
891
|
+
wrappedFunc(...args).then((result) => {
|
|
892
|
+
injectJavaScript?.(`
|
|
893
|
+
window.__BEDROCK_NATIVE_EMITTER.emit('${functionName}/resolve/${eventId}', ${JSON.stringify(result, null, 0)});
|
|
894
|
+
`);
|
|
895
|
+
}).catch((error) => {
|
|
896
|
+
const serializedError = serializeError(error);
|
|
897
|
+
injectJavaScript?.(`
|
|
898
|
+
window.__BEDROCK_NATIVE_EMITTER.emit('${functionName}/reject/${eventId}', ${serializedError});
|
|
899
|
+
`);
|
|
900
|
+
});
|
|
901
|
+
}
|
|
902
|
+
var globalEventListenerMap = /* @__PURE__ */ new Map();
|
|
903
|
+
function useBridgeHandler({
|
|
904
|
+
onMessage,
|
|
905
|
+
constantHandlerMap,
|
|
906
|
+
asyncHandlerMap,
|
|
907
|
+
eventListenerMap,
|
|
908
|
+
injectedJavaScript: originalInjectedJavaScript
|
|
909
|
+
}) {
|
|
910
|
+
const ref = useRef(null);
|
|
911
|
+
const injectedJavaScript = useMemo2(
|
|
912
|
+
() => [
|
|
913
|
+
`window.__CONSTANT_HANDLER_MAP = ${JSON.stringify(
|
|
914
|
+
Object.entries(constantHandlerMap).reduce(
|
|
915
|
+
(acc, [key, value]) => {
|
|
916
|
+
acc[key] = typeof value === "function" ? value() : value;
|
|
917
|
+
return acc;
|
|
918
|
+
},
|
|
919
|
+
{}
|
|
920
|
+
)
|
|
921
|
+
)}`,
|
|
922
|
+
originalInjectedJavaScript,
|
|
923
|
+
"true"
|
|
924
|
+
].join("\n"),
|
|
925
|
+
[constantHandlerMap, originalInjectedJavaScript]
|
|
926
|
+
);
|
|
927
|
+
const createHandleOnEvent = (functionName, eventId) => (response) => {
|
|
928
|
+
ref.current?.injectJavaScript(`
|
|
929
|
+
window.__BEDROCK_NATIVE_EMITTER.emit('${functionName}/onEvent/${eventId}', ${JSON.stringify(response, null, 0)});
|
|
930
|
+
`);
|
|
931
|
+
};
|
|
932
|
+
const createHandleOnError = (functionName, eventId) => (error) => {
|
|
933
|
+
ref.current?.injectJavaScript(`
|
|
934
|
+
window.__BEDROCK_NATIVE_EMITTER.emit('${functionName}/onError/${eventId}', ${JSON.stringify(error, null, 0)});
|
|
935
|
+
`);
|
|
936
|
+
};
|
|
937
|
+
const $onMessage = useCallback2(
|
|
938
|
+
async (e) => {
|
|
939
|
+
onMessage?.(e);
|
|
940
|
+
const data = JSON.parse(e.nativeEvent.data);
|
|
941
|
+
if (typeof data !== "object" || data === null || typeof data.functionName !== "string" || typeof data.eventId !== "string" || typeof data.type !== "string" || !["addEventListener", "removeEventListener", "method"].includes(data.type)) {
|
|
942
|
+
return;
|
|
943
|
+
}
|
|
944
|
+
switch (data.type) {
|
|
945
|
+
case "addEventListener": {
|
|
946
|
+
const handleOnEvent = createHandleOnEvent(data.functionName, data.eventId);
|
|
947
|
+
const handleOnError = createHandleOnError(data.functionName, data.eventId);
|
|
948
|
+
const remove = eventListenerMap[data.functionName]?.({
|
|
949
|
+
onEvent: handleOnEvent,
|
|
950
|
+
onError: handleOnError,
|
|
951
|
+
options: data.args
|
|
952
|
+
});
|
|
953
|
+
if (remove) {
|
|
954
|
+
globalEventListenerMap.set(`${data.functionName}/${data.eventId}`, remove);
|
|
955
|
+
}
|
|
956
|
+
break;
|
|
957
|
+
}
|
|
958
|
+
case "removeEventListener": {
|
|
959
|
+
const key = `${data.functionName}/${data.eventId}`;
|
|
960
|
+
const remove = globalEventListenerMap.get(key);
|
|
961
|
+
remove?.();
|
|
962
|
+
globalEventListenerMap.delete(key);
|
|
963
|
+
break;
|
|
964
|
+
}
|
|
965
|
+
case "method": {
|
|
966
|
+
methodHandler({
|
|
967
|
+
args: data.args,
|
|
968
|
+
eventId: data.eventId,
|
|
969
|
+
functionName: data.functionName,
|
|
970
|
+
handlerMap: asyncHandlerMap,
|
|
971
|
+
injectJavaScript: ref.current?.injectJavaScript
|
|
972
|
+
});
|
|
973
|
+
break;
|
|
974
|
+
}
|
|
975
|
+
}
|
|
976
|
+
},
|
|
977
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
978
|
+
[onMessage]
|
|
979
|
+
);
|
|
980
|
+
return {
|
|
981
|
+
ref,
|
|
982
|
+
injectedJavaScript,
|
|
983
|
+
onMessage: $onMessage
|
|
984
|
+
};
|
|
985
|
+
}
|
|
986
|
+
|
|
452
987
|
// src/constant-bridges.ts
|
|
453
988
|
var constant_bridges_exports = {};
|
|
454
989
|
__export(constant_bridges_exports, {
|
|
@@ -457,11 +992,6 @@ __export(constant_bridges_exports, {
|
|
|
457
992
|
getTossAppVersion: () => getTossAppVersion
|
|
458
993
|
});
|
|
459
994
|
|
|
460
|
-
// src/env.ts
|
|
461
|
-
var env = {
|
|
462
|
-
getDeploymentId: () => __DEV__ ? "local" : global.__appsInToss?.deploymentId
|
|
463
|
-
};
|
|
464
|
-
|
|
465
995
|
// src/event-bridges.ts
|
|
466
996
|
var event_bridges_exports = {};
|
|
467
997
|
__export(event_bridges_exports, {
|
|
@@ -471,6 +1001,7 @@ __export(event_bridges_exports, {
|
|
|
471
1001
|
// src/components/WebView.tsx
|
|
472
1002
|
import { jsx as jsx5 } from "react/jsx-runtime";
|
|
473
1003
|
var appsInTossGlobals = getAppsInTossGlobals();
|
|
1004
|
+
var operationalEnvironment = getOperationalEnvironment();
|
|
474
1005
|
var TYPES = ["partner", "external", "game"];
|
|
475
1006
|
var WEBVIEW_TYPES = {
|
|
476
1007
|
partner: PartnerWebViewScreen,
|
|
@@ -479,7 +1010,7 @@ var WEBVIEW_TYPES = {
|
|
|
479
1010
|
};
|
|
480
1011
|
function mergeSchemeQueryParamsInto(url) {
|
|
481
1012
|
const baseUrl = new URL(url);
|
|
482
|
-
const schemeUrl = new URL(
|
|
1013
|
+
const schemeUrl = new URL(getSchemeUri3());
|
|
483
1014
|
baseUrl.pathname = schemeUrl.pathname;
|
|
484
1015
|
for (const [key, value] of schemeUrl.searchParams.entries()) {
|
|
485
1016
|
baseUrl.searchParams.set(key, value);
|
|
@@ -504,7 +1035,7 @@ function WebView({ type, local, onMessage, ...props }) {
|
|
|
504
1035
|
throw new Error(`Invalid WebView type: '${type}'`);
|
|
505
1036
|
}
|
|
506
1037
|
const bedrockEvent = useBedrockEvent();
|
|
507
|
-
const uri =
|
|
1038
|
+
const uri = useMemo3(() => getWebViewUri(local), [local]);
|
|
508
1039
|
const top = useSafeAreaTop2();
|
|
509
1040
|
const bottom = useSafeAreaBottom();
|
|
510
1041
|
const handler = useBridgeHandler({
|
|
@@ -512,7 +1043,16 @@ function WebView({ type, local, onMessage, ...props }) {
|
|
|
512
1043
|
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
513
1044
|
eventListenerMap: {
|
|
514
1045
|
...event_bridges_exports,
|
|
515
|
-
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
|
|
516
1056
|
},
|
|
517
1057
|
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
518
1058
|
// @ts-expect-error
|
|
@@ -520,7 +1060,12 @@ function WebView({ type, local, onMessage, ...props }) {
|
|
|
520
1060
|
...bedrockConstantBridges,
|
|
521
1061
|
...constant_bridges_exports,
|
|
522
1062
|
getSafeAreaTop: () => top,
|
|
523
|
-
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
|
|
524
1069
|
},
|
|
525
1070
|
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
526
1071
|
// @ts-expect-error
|
|
@@ -536,7 +1081,7 @@ function WebView({ type, local, onMessage, ...props }) {
|
|
|
536
1081
|
clearItems: Storage.clearItems
|
|
537
1082
|
}
|
|
538
1083
|
});
|
|
539
|
-
const baseProps =
|
|
1084
|
+
const baseProps = useMemo3(() => {
|
|
540
1085
|
switch (type) {
|
|
541
1086
|
case "partner": {
|
|
542
1087
|
const headerOnlyProp = {
|
|
@@ -566,10 +1111,7 @@ function WebView({ type, local, onMessage, ...props }) {
|
|
|
566
1111
|
}
|
|
567
1112
|
}, [type, props]);
|
|
568
1113
|
const BaseWebView = WEBVIEW_TYPES[type];
|
|
569
|
-
const
|
|
570
|
-
() => getOperationalEnvironment() === "sandbox",
|
|
571
|
-
[]
|
|
572
|
-
);
|
|
1114
|
+
const webViewDebuggingEnabled = operationalEnvironment === "sandbox";
|
|
573
1115
|
return /* @__PURE__ */ jsx5(
|
|
574
1116
|
BaseWebView,
|
|
575
1117
|
{
|
|
@@ -578,7 +1120,7 @@ function WebView({ type, local, onMessage, ...props }) {
|
|
|
578
1120
|
...baseProps,
|
|
579
1121
|
source: { uri },
|
|
580
1122
|
sharedCookiesEnabled: true,
|
|
581
|
-
webviewDebuggingEnabled,
|
|
1123
|
+
webviewDebuggingEnabled: webViewDebuggingEnabled,
|
|
582
1124
|
thirdPartyCookiesEnabled: true,
|
|
583
1125
|
onMessage: handler.onMessage,
|
|
584
1126
|
injectedJavaScript: handler.injectedJavaScript,
|
|
@@ -594,12 +1136,12 @@ function ensureValue(value, name) {
|
|
|
594
1136
|
}
|
|
595
1137
|
|
|
596
1138
|
// src/hooks/useGeolocation.ts
|
|
597
|
-
import { useState, useEffect as
|
|
1139
|
+
import { useState, useEffect as useEffect4 } from "react";
|
|
598
1140
|
import { useVisibility } from "react-native-bedrock";
|
|
599
1141
|
function useGeolocation({ accuracy, distanceInterval, timeInterval }) {
|
|
600
1142
|
const isVisible = useVisibility();
|
|
601
1143
|
const [location, setLocation] = useState(null);
|
|
602
|
-
|
|
1144
|
+
useEffect4(() => {
|
|
603
1145
|
if (!isVisible) {
|
|
604
1146
|
return;
|
|
605
1147
|
}
|
|
@@ -629,11 +1171,14 @@ var Accuracy2 = /* @__PURE__ */ ((Accuracy3) => {
|
|
|
629
1171
|
export {
|
|
630
1172
|
Accuracy2 as Accuracy,
|
|
631
1173
|
AppsInToss,
|
|
1174
|
+
GoogleAdMob,
|
|
632
1175
|
Storage,
|
|
633
1176
|
TossPay,
|
|
634
1177
|
WebView,
|
|
635
1178
|
appLogin,
|
|
1179
|
+
appsInTossEvent,
|
|
636
1180
|
env,
|
|
1181
|
+
eventLog,
|
|
637
1182
|
fetchAlbumPhotos,
|
|
638
1183
|
fetchContacts,
|
|
639
1184
|
getClipboardText,
|
|
@@ -641,6 +1186,8 @@ export {
|
|
|
641
1186
|
getDeviceId,
|
|
642
1187
|
getOperationalEnvironment,
|
|
643
1188
|
getTossAppVersion,
|
|
1189
|
+
getTossShareLink,
|
|
1190
|
+
isMinVersionSupported,
|
|
644
1191
|
openCamera,
|
|
645
1192
|
setClipboardText,
|
|
646
1193
|
startUpdateLocation,
|