@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.cjs
CHANGED
|
@@ -32,11 +32,14 @@ var src_exports = {};
|
|
|
32
32
|
__export(src_exports, {
|
|
33
33
|
Accuracy: () => Accuracy2,
|
|
34
34
|
AppsInToss: () => AppsInToss,
|
|
35
|
+
GoogleAdMob: () => GoogleAdMob,
|
|
35
36
|
Storage: () => Storage,
|
|
36
37
|
TossPay: () => TossPay,
|
|
37
38
|
WebView: () => WebView,
|
|
38
39
|
appLogin: () => appLogin,
|
|
40
|
+
appsInTossEvent: () => appsInTossEvent,
|
|
39
41
|
env: () => env,
|
|
42
|
+
eventLog: () => eventLog,
|
|
40
43
|
fetchAlbumPhotos: () => fetchAlbumPhotos,
|
|
41
44
|
fetchContacts: () => fetchContacts,
|
|
42
45
|
getClipboardText: () => getClipboardText,
|
|
@@ -45,6 +48,7 @@ __export(src_exports, {
|
|
|
45
48
|
getOperationalEnvironment: () => getOperationalEnvironment,
|
|
46
49
|
getTossAppVersion: () => getTossAppVersion,
|
|
47
50
|
getTossShareLink: () => getTossShareLink,
|
|
51
|
+
isMinVersionSupported: () => isMinVersionSupported,
|
|
48
52
|
openCamera: () => openCamera,
|
|
49
53
|
setClipboardText: () => setClipboardText,
|
|
50
54
|
startUpdateLocation: () => startUpdateLocation,
|
|
@@ -53,83 +57,278 @@ __export(src_exports, {
|
|
|
53
57
|
module.exports = __toCommonJS(src_exports);
|
|
54
58
|
|
|
55
59
|
// src/core/registerApp.tsx
|
|
56
|
-
var
|
|
57
|
-
var
|
|
60
|
+
var import_react_native5 = require("@toss-design-system/react-native");
|
|
61
|
+
var import_react_native_bedrock7 = require("react-native-bedrock");
|
|
58
62
|
|
|
59
|
-
// src/core/
|
|
60
|
-
var
|
|
61
|
-
var
|
|
63
|
+
// src/core/components/AppEvent.tsx
|
|
64
|
+
var import_react2 = require("react");
|
|
65
|
+
var import_react_native_bedrock6 = require("react-native-bedrock");
|
|
62
66
|
|
|
63
|
-
//
|
|
64
|
-
function
|
|
65
|
-
if (global.__appsInToss == null) {
|
|
66
|
-
throw new Error("invalid apps-in-toss globals");
|
|
67
|
-
}
|
|
68
|
-
return global.__appsInToss;
|
|
67
|
+
// ../../.yarn/cache/es-toolkit-npm-1.34.1-4cd6371dcb-aab6d07be3.zip/node_modules/es-toolkit/dist/function/noop.mjs
|
|
68
|
+
function noop() {
|
|
69
69
|
}
|
|
70
70
|
|
|
71
|
-
// src/
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
71
|
+
// src/native-modules/AppsInTossModule.ts
|
|
72
|
+
var import_react_native = require("react-native");
|
|
73
|
+
var AppsInTossModuleInstance = import_react_native.NativeModules.AppsInTossModule;
|
|
74
|
+
var AppsInTossModule = AppsInTossModuleInstance;
|
|
75
75
|
|
|
76
|
-
// src/
|
|
77
|
-
function
|
|
78
|
-
|
|
79
|
-
const appsInTossGlobals2 = getAppsInTossGlobals();
|
|
80
|
-
(0, import_react.useEffect)(() => {
|
|
81
|
-
const commonProps = {
|
|
82
|
-
serviceName: appsInTossGlobals2.brandDisplayName,
|
|
83
|
-
icon: toIcon(appsInTossGlobals2.brandIcon),
|
|
84
|
-
color: appsInTossGlobals2.brandPrimaryColor,
|
|
85
|
-
colorMode: appsInTossGlobals2.brandBridgeColorMode
|
|
86
|
-
};
|
|
87
|
-
controller.open({ ...commonProps });
|
|
88
|
-
}, []);
|
|
76
|
+
// src/utils/generateUUID.ts
|
|
77
|
+
function generateUUID(placeholder) {
|
|
78
|
+
return placeholder ? (placeholder ^ Math.random() * 16 >> placeholder / 4).toString(16) : (String(1e7) + 1e3 + 4e3 + 8e3 + 1e11).replace(/[018]/g, generateUUID);
|
|
89
79
|
}
|
|
90
80
|
|
|
91
|
-
// src/
|
|
92
|
-
var
|
|
93
|
-
function
|
|
94
|
-
|
|
81
|
+
// src/native-event-emitter/internal/appBridge.ts
|
|
82
|
+
var INTERNAL__callbacks = /* @__PURE__ */ new Map();
|
|
83
|
+
function invokeAppBridgeCallback(id, ...args) {
|
|
84
|
+
const callback = INTERNAL__callbacks.get(id);
|
|
85
|
+
callback?.call(null, ...args);
|
|
86
|
+
return Boolean(callback);
|
|
95
87
|
}
|
|
96
|
-
function
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
appName: getAppName(),
|
|
103
|
-
context,
|
|
104
|
-
defaultScreenOption: {
|
|
105
|
-
statusBarStyle: "dark"
|
|
106
|
-
}
|
|
88
|
+
function invokeAppBridgeMethod(methodName, params, callbacks) {
|
|
89
|
+
const { onSuccess, onError, ...appBridgeCallbacks } = callbacks;
|
|
90
|
+
const { callbackMap, unregisterAll } = registerCallbacks(appBridgeCallbacks);
|
|
91
|
+
const promise = AppsInTossModuleInstance[methodName]({
|
|
92
|
+
params,
|
|
93
|
+
callbacks: callbackMap
|
|
107
94
|
});
|
|
95
|
+
void promise.then(onSuccess).catch(onError);
|
|
96
|
+
return unregisterAll;
|
|
108
97
|
}
|
|
109
|
-
function
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
throw error;
|
|
98
|
+
function registerCallbacks(callbacks) {
|
|
99
|
+
const callbackMap = {};
|
|
100
|
+
for (const [callbackName, callback] of Object.entries(callbacks)) {
|
|
101
|
+
const id = registerCallback(callback, callbackName);
|
|
102
|
+
callbackMap[callbackName] = id;
|
|
115
103
|
}
|
|
104
|
+
const unregisterAll = () => {
|
|
105
|
+
Object.values(callbackMap).forEach(unregisterCallback);
|
|
106
|
+
};
|
|
107
|
+
return { callbackMap, unregisterAll };
|
|
108
|
+
}
|
|
109
|
+
function registerCallback(callback, name = "unnamed") {
|
|
110
|
+
const uniqueId = generateUUID();
|
|
111
|
+
const callbackId = `${uniqueId}__${name}`;
|
|
112
|
+
INTERNAL__callbacks.set(callbackId, callback);
|
|
113
|
+
return callbackId;
|
|
114
|
+
}
|
|
115
|
+
function unregisterCallback(id) {
|
|
116
|
+
INTERNAL__callbacks.delete(id);
|
|
116
117
|
}
|
|
118
|
+
function getCallbackIds() {
|
|
119
|
+
return Array.from(INTERNAL__callbacks.keys());
|
|
120
|
+
}
|
|
121
|
+
var INTERNAL__appBridgeHandler = {
|
|
122
|
+
invokeAppBridgeCallback,
|
|
123
|
+
invokeAppBridgeMethod,
|
|
124
|
+
registerCallback,
|
|
125
|
+
unregisterCallback,
|
|
126
|
+
getCallbackIds
|
|
127
|
+
};
|
|
117
128
|
|
|
118
|
-
// src/
|
|
119
|
-
|
|
120
|
-
|
|
129
|
+
// src/native-modules/getOperationalEnvironment.ts
|
|
130
|
+
function getOperationalEnvironment() {
|
|
131
|
+
return AppsInTossModule.operationalEnvironment;
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
// src/native-modules/isMinVersionSupported.ts
|
|
135
|
+
var import_react_native2 = require("react-native");
|
|
136
|
+
|
|
137
|
+
// src/utils/compareVersion.ts
|
|
138
|
+
var SEMVER_REGEX = /^[v^~<>=]*?(\d+)(?:\.([x*]|\d+)(?:\.([x*]|\d+)(?:\.([x*]|\d+))?(?:-([\da-z\\-]+(?:\.[\da-z\\-]+)*))?(?:\+[\da-z\\-]+(?:\.[\da-z\\-]+)*)?)?)?$/i;
|
|
139
|
+
var isWildcard = (val) => ["*", "x", "X"].includes(val);
|
|
140
|
+
var tryParse = (val) => {
|
|
141
|
+
const num = parseInt(val, 10);
|
|
142
|
+
return isNaN(num) ? val : num;
|
|
143
|
+
};
|
|
144
|
+
var coerceTypes = (a, b) => {
|
|
145
|
+
return typeof a === typeof b ? [a, b] : [String(a), String(b)];
|
|
146
|
+
};
|
|
147
|
+
var compareValues = (a, b) => {
|
|
148
|
+
if (isWildcard(a) || isWildcard(b)) {
|
|
149
|
+
return 0;
|
|
150
|
+
}
|
|
151
|
+
const [aVal, bVal] = coerceTypes(tryParse(a), tryParse(b));
|
|
152
|
+
if (aVal > bVal) {
|
|
153
|
+
return 1;
|
|
154
|
+
}
|
|
155
|
+
if (aVal < bVal) {
|
|
156
|
+
return -1;
|
|
157
|
+
}
|
|
158
|
+
return 0;
|
|
159
|
+
};
|
|
160
|
+
var parseVersion = (version) => {
|
|
161
|
+
if (typeof version !== "string") {
|
|
162
|
+
throw new TypeError("Invalid argument: expected a string");
|
|
163
|
+
}
|
|
164
|
+
const match = version.match(SEMVER_REGEX);
|
|
165
|
+
if (!match) {
|
|
166
|
+
throw new Error(`Invalid semver: '${version}'`);
|
|
167
|
+
}
|
|
168
|
+
const [, major, minor, patch, build, preRelease] = match;
|
|
169
|
+
return [major, minor, patch, build, preRelease];
|
|
170
|
+
};
|
|
171
|
+
var compareSegments = (a, b) => {
|
|
172
|
+
const maxLength = Math.max(a.length, b.length);
|
|
173
|
+
for (let i = 0; i < maxLength; i++) {
|
|
174
|
+
const segA = a[i] ?? "0";
|
|
175
|
+
const segB = b[i] ?? "0";
|
|
176
|
+
const result = compareValues(segA, segB);
|
|
177
|
+
if (result !== 0) {
|
|
178
|
+
return result;
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
return 0;
|
|
182
|
+
};
|
|
183
|
+
var compareVersions = (v1, v2) => {
|
|
184
|
+
const seg1 = parseVersion(v1);
|
|
185
|
+
const seg2 = parseVersion(v2);
|
|
186
|
+
const preRelease1 = seg1.pop();
|
|
187
|
+
const preRelease2 = seg2.pop();
|
|
188
|
+
const mainCompare = compareSegments(seg1, seg2);
|
|
189
|
+
if (mainCompare !== 0) {
|
|
190
|
+
return mainCompare;
|
|
191
|
+
}
|
|
192
|
+
if (preRelease1 && preRelease2) {
|
|
193
|
+
return compareSegments(preRelease1.split("."), preRelease2.split("."));
|
|
194
|
+
}
|
|
195
|
+
if (preRelease1) {
|
|
196
|
+
return -1;
|
|
197
|
+
}
|
|
198
|
+
if (preRelease2) {
|
|
199
|
+
return 1;
|
|
200
|
+
}
|
|
201
|
+
return 0;
|
|
121
202
|
};
|
|
122
203
|
|
|
123
|
-
// src/native-
|
|
124
|
-
|
|
204
|
+
// src/native-modules/isMinVersionSupported.ts
|
|
205
|
+
function isMinVersionSupported(minVersions) {
|
|
206
|
+
const operationalEnvironment2 = AppsInTossModule.operationalEnvironment;
|
|
207
|
+
if (operationalEnvironment2 === "sandbox") {
|
|
208
|
+
return true;
|
|
209
|
+
}
|
|
210
|
+
const currentVersion = AppsInTossModule.tossAppVersion;
|
|
211
|
+
const isIOS = import_react_native2.Platform.OS === "ios";
|
|
212
|
+
const minVersion = isIOS ? minVersions.ios : minVersions.android;
|
|
213
|
+
if (minVersion === void 0) {
|
|
214
|
+
return false;
|
|
215
|
+
}
|
|
216
|
+
if (minVersion === "always") {
|
|
217
|
+
return true;
|
|
218
|
+
}
|
|
219
|
+
if (minVersion === "never") {
|
|
220
|
+
return false;
|
|
221
|
+
}
|
|
222
|
+
return compareVersions(currentVersion, minVersion) >= 0;
|
|
223
|
+
}
|
|
125
224
|
|
|
126
|
-
// src/native-
|
|
127
|
-
|
|
225
|
+
// src/native-modules/ads/googleAdMob.ts
|
|
226
|
+
function loadAdMobInterstitialAd(params) {
|
|
227
|
+
if (!loadAdMobInterstitialAd.isSupported()) {
|
|
228
|
+
params.onError(new Error(UNSUPPORTED_ERROR_MESSAGE));
|
|
229
|
+
return noop;
|
|
230
|
+
}
|
|
231
|
+
const { onEvent, onError, options } = params;
|
|
232
|
+
const unregisterCallbacks = INTERNAL__appBridgeHandler.invokeAppBridgeMethod("loadAdMobInterstitialAd", options, {
|
|
233
|
+
onAdClicked: () => {
|
|
234
|
+
onEvent({ type: "clicked" });
|
|
235
|
+
},
|
|
236
|
+
onAdDismissed: () => {
|
|
237
|
+
onEvent({ type: "dismissed" });
|
|
238
|
+
},
|
|
239
|
+
onAdFailedToShow: () => {
|
|
240
|
+
onEvent({ type: "failedToShow" });
|
|
241
|
+
},
|
|
242
|
+
onAdImpression: () => {
|
|
243
|
+
onEvent({ type: "impression" });
|
|
244
|
+
},
|
|
245
|
+
onAdShow: () => {
|
|
246
|
+
onEvent({ type: "show" });
|
|
247
|
+
},
|
|
248
|
+
onSuccess: (result) => onEvent({ type: "loaded", data: result }),
|
|
249
|
+
onError
|
|
250
|
+
});
|
|
251
|
+
return unregisterCallbacks;
|
|
252
|
+
}
|
|
253
|
+
function showAdMobInterstitialAd(params) {
|
|
254
|
+
if (!showAdMobInterstitialAd.isSupported()) {
|
|
255
|
+
params.onError(new Error(UNSUPPORTED_ERROR_MESSAGE));
|
|
256
|
+
return noop;
|
|
257
|
+
}
|
|
258
|
+
const { onEvent, onError, options } = params;
|
|
259
|
+
const unregisterCallbacks = INTERNAL__appBridgeHandler.invokeAppBridgeMethod("showAdMobInterstitialAd", options, {
|
|
260
|
+
onSuccess: () => onEvent({ type: "requested" }),
|
|
261
|
+
onError
|
|
262
|
+
});
|
|
263
|
+
return unregisterCallbacks;
|
|
264
|
+
}
|
|
265
|
+
function loadAdMobRewardedAd(params) {
|
|
266
|
+
if (!loadAdMobRewardedAd.isSupported()) {
|
|
267
|
+
params.onError(new Error(UNSUPPORTED_ERROR_MESSAGE));
|
|
268
|
+
return noop;
|
|
269
|
+
}
|
|
270
|
+
const { onEvent, onError, options } = params;
|
|
271
|
+
const unregisterCallbacks = INTERNAL__appBridgeHandler.invokeAppBridgeMethod("loadAdMobRewardedAd", options, {
|
|
272
|
+
onAdClicked: () => {
|
|
273
|
+
onEvent({ type: "clicked" });
|
|
274
|
+
},
|
|
275
|
+
onAdDismissed: () => {
|
|
276
|
+
onEvent({ type: "dismissed" });
|
|
277
|
+
},
|
|
278
|
+
onAdFailedToShow: () => {
|
|
279
|
+
onEvent({ type: "failedToShow" });
|
|
280
|
+
},
|
|
281
|
+
onAdImpression: () => {
|
|
282
|
+
onEvent({ type: "impression" });
|
|
283
|
+
},
|
|
284
|
+
onAdShow: () => {
|
|
285
|
+
onEvent({ type: "show" });
|
|
286
|
+
},
|
|
287
|
+
onUserEarnedReward: () => {
|
|
288
|
+
onEvent({ type: "userEarnedReward" });
|
|
289
|
+
},
|
|
290
|
+
onSuccess: (result) => onEvent({ type: "loaded", data: result }),
|
|
291
|
+
onError
|
|
292
|
+
});
|
|
293
|
+
return unregisterCallbacks;
|
|
294
|
+
}
|
|
295
|
+
function showAdMobRewardedAd(params) {
|
|
296
|
+
if (!showAdMobRewardedAd.isSupported()) {
|
|
297
|
+
params.onError(new Error(UNSUPPORTED_ERROR_MESSAGE));
|
|
298
|
+
return noop;
|
|
299
|
+
}
|
|
300
|
+
const { onEvent, onError, options } = params;
|
|
301
|
+
const unregisterCallbacks = INTERNAL__appBridgeHandler.invokeAppBridgeMethod("showAdMobRewardedAd", options, {
|
|
302
|
+
onSuccess: () => onEvent({ type: "requested" }),
|
|
303
|
+
onError
|
|
304
|
+
});
|
|
305
|
+
return unregisterCallbacks;
|
|
306
|
+
}
|
|
307
|
+
var ANDROID_GOOGLE_AD_MOB_SUPPORTED_VERSION = "5.209.0";
|
|
308
|
+
var IOS_GOOGLE_AD_MOB_SUPPORTED_VERSION = "5.209.0";
|
|
309
|
+
var UNSUPPORTED_ERROR_MESSAGE = "This feature is not supported in the current environment";
|
|
310
|
+
var ENVIRONMENT = getOperationalEnvironment();
|
|
311
|
+
function createIsSupported() {
|
|
312
|
+
return () => {
|
|
313
|
+
if (ENVIRONMENT !== "toss") {
|
|
314
|
+
console.warn("Google AdMob is not supported in the current environment");
|
|
315
|
+
return false;
|
|
316
|
+
}
|
|
317
|
+
return isMinVersionSupported({
|
|
318
|
+
android: ANDROID_GOOGLE_AD_MOB_SUPPORTED_VERSION,
|
|
319
|
+
ios: IOS_GOOGLE_AD_MOB_SUPPORTED_VERSION
|
|
320
|
+
});
|
|
321
|
+
};
|
|
322
|
+
}
|
|
323
|
+
loadAdMobInterstitialAd.isSupported = createIsSupported();
|
|
324
|
+
loadAdMobRewardedAd.isSupported = createIsSupported();
|
|
325
|
+
showAdMobInterstitialAd.isSupported = createIsSupported();
|
|
326
|
+
showAdMobRewardedAd.isSupported = createIsSupported();
|
|
128
327
|
|
|
129
|
-
// src/native-modules/
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
328
|
+
// src/native-modules/checkoutPayment.ts
|
|
329
|
+
async function checkoutPayment(options) {
|
|
330
|
+
return AppsInTossModule.checkoutPayment({ params: options });
|
|
331
|
+
}
|
|
133
332
|
|
|
134
333
|
// src/native-modules/getPermission.ts
|
|
135
334
|
function getPermission(permission) {
|
|
@@ -153,56 +352,6 @@ async function requestPermission(permission) {
|
|
|
153
352
|
}
|
|
154
353
|
}
|
|
155
354
|
|
|
156
|
-
// src/native-event-emitter/nativeEventEmitter.ts
|
|
157
|
-
var import_react_native4 = require("react-native");
|
|
158
|
-
var nativeEventEmitter = new import_react_native4.NativeEventEmitter(AppsInTossModuleInstance);
|
|
159
|
-
|
|
160
|
-
// src/native-event-emitter/event-plugins/UpdateLocationEvent.ts
|
|
161
|
-
var UpdateLocationEvent = class extends import_react_native_bedrock2.BedrockEventDefinition {
|
|
162
|
-
name = "updateLocationEvent";
|
|
163
|
-
subscriptionCount = 0;
|
|
164
|
-
ref = {
|
|
165
|
-
remove: () => {
|
|
166
|
-
}
|
|
167
|
-
};
|
|
168
|
-
remove() {
|
|
169
|
-
--this.subscriptionCount === 0 && AppsInTossModuleInstance.stopUpdateLocation({});
|
|
170
|
-
this.ref.remove();
|
|
171
|
-
}
|
|
172
|
-
listener(options, onEvent, onError) {
|
|
173
|
-
requestPermission({ name: "geolocation", access: "access" }).then((permissionStatus) => {
|
|
174
|
-
if (permissionStatus === "denied") {
|
|
175
|
-
onError(new Error("\uC704\uCE58 \uAD8C\uD55C\uC774 \uAC70\uBD80\uB418\uC5C8\uC5B4\uC694."));
|
|
176
|
-
return;
|
|
177
|
-
}
|
|
178
|
-
void AppsInTossModuleInstance.startUpdateLocation(options).catch(onError);
|
|
179
|
-
const subscription = nativeEventEmitter.addListener("updateLocation", onEvent);
|
|
180
|
-
this.ref = {
|
|
181
|
-
remove: () => subscription?.remove()
|
|
182
|
-
};
|
|
183
|
-
this.subscriptionCount++;
|
|
184
|
-
}).catch(onError);
|
|
185
|
-
}
|
|
186
|
-
};
|
|
187
|
-
|
|
188
|
-
// src/native-event-emitter/bedrock-event.ts
|
|
189
|
-
var appsInTossEvent = new import_react_native_bedrock3.BedrockEvent([new UpdateLocationEvent()]);
|
|
190
|
-
|
|
191
|
-
// src/native-event-emitter/startUpdateLocation.ts
|
|
192
|
-
function startUpdateLocation(eventParams) {
|
|
193
|
-
return appsInTossEvent.addEventListener("updateLocationEvent", eventParams);
|
|
194
|
-
}
|
|
195
|
-
|
|
196
|
-
// src/native-modules/checkoutPayment.ts
|
|
197
|
-
async function checkoutPayment(options) {
|
|
198
|
-
return AppsInTossModule.checkoutPayment(options);
|
|
199
|
-
}
|
|
200
|
-
|
|
201
|
-
// src/native-modules/executePayment.ts
|
|
202
|
-
async function executePayment(options) {
|
|
203
|
-
return AppsInTossModule.executePayment(options);
|
|
204
|
-
}
|
|
205
|
-
|
|
206
355
|
// src/native-modules/setClipboardText.ts
|
|
207
356
|
async function setClipboardText(text) {
|
|
208
357
|
const permissionStatus = await requestPermission({ name: "clipboard", access: "write" });
|
|
@@ -284,11 +433,6 @@ async function appLogin() {
|
|
|
284
433
|
return AppsInTossModule.appLogin({});
|
|
285
434
|
}
|
|
286
435
|
|
|
287
|
-
// src/native-modules/getOperationalEnvironment.ts
|
|
288
|
-
function getOperationalEnvironment() {
|
|
289
|
-
return AppsInTossModule.operationalEnvironment;
|
|
290
|
-
}
|
|
291
|
-
|
|
292
436
|
// src/native-modules/getTossAppVersion.ts
|
|
293
437
|
function getTossAppVersion() {
|
|
294
438
|
return AppsInTossModule.tossAppVersion;
|
|
@@ -322,6 +466,35 @@ var Storage = {
|
|
|
322
466
|
clearItems
|
|
323
467
|
};
|
|
324
468
|
|
|
469
|
+
// src/native-modules/eventLog.ts
|
|
470
|
+
function normalizeParams(params) {
|
|
471
|
+
return Object.fromEntries(
|
|
472
|
+
Object.entries(params).filter(([, value]) => value !== void 0).map(([key, value]) => [key, String(value)])
|
|
473
|
+
);
|
|
474
|
+
}
|
|
475
|
+
async function eventLog(params) {
|
|
476
|
+
if (AppsInTossModule.operationalEnvironment === "sandbox") {
|
|
477
|
+
console.log("[eventLogDebug]", {
|
|
478
|
+
log_name: params.log_name,
|
|
479
|
+
log_type: params.log_type,
|
|
480
|
+
params: normalizeParams(params.params)
|
|
481
|
+
});
|
|
482
|
+
return;
|
|
483
|
+
}
|
|
484
|
+
const isSupported = isMinVersionSupported({
|
|
485
|
+
android: "5.208.0",
|
|
486
|
+
ios: "5.208.0"
|
|
487
|
+
});
|
|
488
|
+
if (!isSupported) {
|
|
489
|
+
return;
|
|
490
|
+
}
|
|
491
|
+
return AppsInTossModule.eventLog({
|
|
492
|
+
log_name: params.log_name,
|
|
493
|
+
log_type: params.log_type,
|
|
494
|
+
params: normalizeParams(params.params)
|
|
495
|
+
});
|
|
496
|
+
}
|
|
497
|
+
|
|
325
498
|
// src/native-modules/getTossShareLink.ts
|
|
326
499
|
async function getTossShareLink(path) {
|
|
327
500
|
const { shareLink } = await AppsInTossModule.getTossShareLink({});
|
|
@@ -333,40 +506,266 @@ async function getTossShareLink(path) {
|
|
|
333
506
|
|
|
334
507
|
// src/native-modules/index.ts
|
|
335
508
|
var TossPay = {
|
|
336
|
-
checkoutPayment
|
|
337
|
-
|
|
509
|
+
checkoutPayment
|
|
510
|
+
};
|
|
511
|
+
var GoogleAdMob = {
|
|
512
|
+
loadAdMobInterstitialAd,
|
|
513
|
+
showAdMobInterstitialAd,
|
|
514
|
+
loadAdMobRewardedAd,
|
|
515
|
+
showAdMobRewardedAd
|
|
516
|
+
};
|
|
517
|
+
|
|
518
|
+
// src/native-event-emitter/appsInTossEvent.ts
|
|
519
|
+
var import_react_native_bedrock4 = require("react-native-bedrock");
|
|
520
|
+
|
|
521
|
+
// src/native-event-emitter/event-plugins/EntryMessageExitedEvent.ts
|
|
522
|
+
var import_react_native_bedrock = require("react-native-bedrock");
|
|
523
|
+
var EntryMessageExitedEvent = class extends import_react_native_bedrock.BedrockEventDefinition {
|
|
524
|
+
name = "entryMessageExited";
|
|
525
|
+
remove() {
|
|
526
|
+
}
|
|
527
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
528
|
+
listener(_) {
|
|
529
|
+
}
|
|
530
|
+
};
|
|
531
|
+
|
|
532
|
+
// src/native-event-emitter/event-plugins/UpdateLocationEvent.ts
|
|
533
|
+
var import_react_native_bedrock2 = require("react-native-bedrock");
|
|
534
|
+
|
|
535
|
+
// src/native-event-emitter/nativeEventEmitter.ts
|
|
536
|
+
var import_react_native3 = require("react-native");
|
|
537
|
+
var nativeEventEmitter = new import_react_native3.NativeEventEmitter(AppsInTossModuleInstance);
|
|
538
|
+
|
|
539
|
+
// src/native-event-emitter/event-plugins/UpdateLocationEvent.ts
|
|
540
|
+
var UpdateLocationEvent = class extends import_react_native_bedrock2.BedrockEventDefinition {
|
|
541
|
+
name = "updateLocationEvent";
|
|
542
|
+
subscriptionCount = 0;
|
|
543
|
+
ref = {
|
|
544
|
+
remove: () => {
|
|
545
|
+
}
|
|
546
|
+
};
|
|
547
|
+
remove() {
|
|
548
|
+
--this.subscriptionCount === 0 && AppsInTossModuleInstance.stopUpdateLocation({});
|
|
549
|
+
this.ref.remove();
|
|
550
|
+
}
|
|
551
|
+
listener(options, onEvent, onError) {
|
|
552
|
+
requestPermission({ name: "geolocation", access: "access" }).then((permissionStatus) => {
|
|
553
|
+
if (permissionStatus === "denied") {
|
|
554
|
+
onError(new Error("\uC704\uCE58 \uAD8C\uD55C\uC774 \uAC70\uBD80\uB418\uC5C8\uC5B4\uC694."));
|
|
555
|
+
return;
|
|
556
|
+
}
|
|
557
|
+
void AppsInTossModuleInstance.startUpdateLocation(options).catch(onError);
|
|
558
|
+
const subscription = nativeEventEmitter.addListener("updateLocation", onEvent);
|
|
559
|
+
this.ref = {
|
|
560
|
+
remove: () => subscription?.remove()
|
|
561
|
+
};
|
|
562
|
+
this.subscriptionCount++;
|
|
563
|
+
}).catch(onError);
|
|
564
|
+
}
|
|
565
|
+
};
|
|
566
|
+
|
|
567
|
+
// src/native-event-emitter/internal/AppBridgeCallbackEvent.ts
|
|
568
|
+
var import_react_native_bedrock3 = require("react-native-bedrock");
|
|
569
|
+
var UNSAFE__nativeEventEmitter = nativeEventEmitter;
|
|
570
|
+
var AppBridgeCallbackEvent = class _AppBridgeCallbackEvent extends import_react_native_bedrock3.BedrockEventDefinition {
|
|
571
|
+
static INTERNAL__appBridgeSubscription;
|
|
572
|
+
name = "appBridgeCallbackEvent";
|
|
573
|
+
constructor() {
|
|
574
|
+
super();
|
|
575
|
+
this.registerAppBridgeCallbackEventListener();
|
|
576
|
+
}
|
|
577
|
+
remove() {
|
|
578
|
+
}
|
|
579
|
+
listener() {
|
|
580
|
+
}
|
|
581
|
+
registerAppBridgeCallbackEventListener() {
|
|
582
|
+
if (_AppBridgeCallbackEvent.INTERNAL__appBridgeSubscription != null) {
|
|
583
|
+
return;
|
|
584
|
+
}
|
|
585
|
+
_AppBridgeCallbackEvent.INTERNAL__appBridgeSubscription = UNSAFE__nativeEventEmitter.addListener(
|
|
586
|
+
"appBridgeCallback",
|
|
587
|
+
this.ensureInvokeAppBridgeCallback
|
|
588
|
+
);
|
|
589
|
+
}
|
|
590
|
+
ensureInvokeAppBridgeCallback(result) {
|
|
591
|
+
if (typeof result === "object" && typeof result.name === "string") {
|
|
592
|
+
INTERNAL__appBridgeHandler.invokeAppBridgeCallback(result.name, result.params);
|
|
593
|
+
} else {
|
|
594
|
+
console.warn("Invalid app bridge callback result:", result);
|
|
595
|
+
}
|
|
596
|
+
}
|
|
597
|
+
};
|
|
598
|
+
|
|
599
|
+
// src/native-event-emitter/appsInTossEvent.ts
|
|
600
|
+
var appsInTossEvent = new import_react_native_bedrock4.BedrockEvent([
|
|
601
|
+
new AppBridgeCallbackEvent(),
|
|
602
|
+
new UpdateLocationEvent(),
|
|
603
|
+
new EntryMessageExitedEvent()
|
|
604
|
+
]);
|
|
605
|
+
|
|
606
|
+
// src/native-event-emitter/startUpdateLocation.ts
|
|
607
|
+
function startUpdateLocation(eventParams) {
|
|
608
|
+
return appsInTossEvent.addEventListener("updateLocationEvent", eventParams);
|
|
609
|
+
}
|
|
610
|
+
|
|
611
|
+
// src/env.ts
|
|
612
|
+
var env = {
|
|
613
|
+
getDeploymentId: () => __DEV__ ? "local" : global.__appsInToss?.deploymentId
|
|
614
|
+
};
|
|
615
|
+
|
|
616
|
+
// src/core/hooks/useReferrer.ts
|
|
617
|
+
var import_react = require("react");
|
|
618
|
+
var import_react_native_bedrock5 = require("react-native-bedrock");
|
|
619
|
+
function useReferrer() {
|
|
620
|
+
return (0, import_react.useMemo)(() => {
|
|
621
|
+
try {
|
|
622
|
+
return new URL((0, import_react_native_bedrock5.getSchemeUri)()).searchParams.get("referrer");
|
|
623
|
+
} catch {
|
|
624
|
+
return null;
|
|
625
|
+
}
|
|
626
|
+
}, []);
|
|
627
|
+
}
|
|
628
|
+
|
|
629
|
+
// src/core/components/AppEvent.tsx
|
|
630
|
+
var ENTRY_APP_EVENT_SCHEMA_ID = 1562181;
|
|
631
|
+
function EntryAppEvent() {
|
|
632
|
+
const referrer = useReferrer() ?? "";
|
|
633
|
+
(0, import_react2.useEffect)(() => {
|
|
634
|
+
eventLog({
|
|
635
|
+
log_name: "appsintoss_app_visit::impression__enter_appsintoss",
|
|
636
|
+
log_type: "info",
|
|
637
|
+
params: {
|
|
638
|
+
is_transform: true,
|
|
639
|
+
schema_id: ENTRY_APP_EVENT_SCHEMA_ID,
|
|
640
|
+
deployment_id: env.getDeploymentId(),
|
|
641
|
+
referrer
|
|
642
|
+
}
|
|
643
|
+
});
|
|
644
|
+
}, [referrer]);
|
|
645
|
+
return null;
|
|
646
|
+
}
|
|
647
|
+
function SystemAppEvent({ ...initialProps }) {
|
|
648
|
+
(0, import_react2.useEffect)(() => {
|
|
649
|
+
eventLog({
|
|
650
|
+
log_name: "AppsInTossInitialProps",
|
|
651
|
+
log_type: "debug",
|
|
652
|
+
params: {
|
|
653
|
+
...initialProps,
|
|
654
|
+
deployment_id: env.getDeploymentId(),
|
|
655
|
+
schemeUri: (0, import_react_native_bedrock6.getSchemeUri)()
|
|
656
|
+
}
|
|
657
|
+
});
|
|
658
|
+
}, [initialProps]);
|
|
659
|
+
return null;
|
|
660
|
+
}
|
|
661
|
+
var AppEvent = {
|
|
662
|
+
Entry: EntryAppEvent,
|
|
663
|
+
System: SystemAppEvent
|
|
664
|
+
};
|
|
665
|
+
|
|
666
|
+
// src/core/hooks/useAppsInTossBridge.ts
|
|
667
|
+
var import_react_native4 = require("@toss-design-system/react-native");
|
|
668
|
+
var import_react3 = require("react");
|
|
669
|
+
|
|
670
|
+
// src/core/utils/getAppsInTossGlobals.ts
|
|
671
|
+
function getAppsInTossGlobals() {
|
|
672
|
+
if (global.__appsInToss == null) {
|
|
673
|
+
throw new Error("invalid apps-in-toss globals");
|
|
674
|
+
}
|
|
675
|
+
return global.__appsInToss;
|
|
676
|
+
}
|
|
677
|
+
|
|
678
|
+
// src/core/utils/toIcon.ts
|
|
679
|
+
function toIcon(source) {
|
|
680
|
+
return source.startsWith("http") ? { source: { uri: source } } : { name: source };
|
|
681
|
+
}
|
|
682
|
+
|
|
683
|
+
// src/core/hooks/useAppsInTossBridge.ts
|
|
684
|
+
function useAppsInTossBridge() {
|
|
685
|
+
const controller = (0, import_react_native4.useBridge)();
|
|
686
|
+
const appsInTossGlobals2 = getAppsInTossGlobals();
|
|
687
|
+
(0, import_react3.useEffect)(() => {
|
|
688
|
+
const commonProps = {
|
|
689
|
+
serviceName: appsInTossGlobals2.brandDisplayName,
|
|
690
|
+
icon: toIcon(appsInTossGlobals2.brandIcon),
|
|
691
|
+
color: appsInTossGlobals2.brandPrimaryColor,
|
|
692
|
+
colorMode: appsInTossGlobals2.brandBridgeColorMode
|
|
693
|
+
};
|
|
694
|
+
controller.open({
|
|
695
|
+
...commonProps,
|
|
696
|
+
onExited: () => {
|
|
697
|
+
appsInTossEvent.emit("entryMessageExited", void 0);
|
|
698
|
+
}
|
|
699
|
+
});
|
|
700
|
+
}, []);
|
|
701
|
+
}
|
|
702
|
+
|
|
703
|
+
// src/core/registerApp.tsx
|
|
704
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
|
705
|
+
function AppsInTossContainer(Container, { children, ...initialProps }) {
|
|
706
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [
|
|
707
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(AppEvent.Entry, {}),
|
|
708
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(AppEvent.System, { ...initialProps }),
|
|
709
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Container, { ...initialProps, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_react_native5.TDSProvider, { colorPreference: "light", token: { color: { primary: getAppsInTossGlobals().brandPrimaryColor } }, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(TDSContainer, { ...initialProps, children }) }) })
|
|
710
|
+
] });
|
|
711
|
+
}
|
|
712
|
+
function TDSContainer({ children }) {
|
|
713
|
+
useAppsInTossBridge();
|
|
714
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_jsx_runtime.Fragment, { children });
|
|
715
|
+
}
|
|
716
|
+
function registerApp(container, { context }) {
|
|
717
|
+
return import_react_native_bedrock7.Bedrock.registerApp(AppsInTossContainer.bind(null, container), {
|
|
718
|
+
appName: getAppName(),
|
|
719
|
+
context,
|
|
720
|
+
defaultScreenOption: {
|
|
721
|
+
statusBarStyle: "dark"
|
|
722
|
+
}
|
|
723
|
+
});
|
|
724
|
+
}
|
|
725
|
+
function getAppName() {
|
|
726
|
+
try {
|
|
727
|
+
return global.__bedrock.app.name;
|
|
728
|
+
} catch (error) {
|
|
729
|
+
console.error("unexpected error occurred while getting app name");
|
|
730
|
+
throw error;
|
|
731
|
+
}
|
|
732
|
+
}
|
|
733
|
+
|
|
734
|
+
// src/core/index.ts
|
|
735
|
+
var AppsInToss = {
|
|
736
|
+
registerApp
|
|
338
737
|
};
|
|
339
738
|
|
|
340
739
|
// src/components/WebView.tsx
|
|
341
|
-
var
|
|
740
|
+
var import_react_native13 = require("@toss-design-system/react-native");
|
|
342
741
|
var import_private = require("@toss-design-system/react-native/private");
|
|
343
|
-
var
|
|
344
|
-
var
|
|
742
|
+
var import_react6 = require("react");
|
|
743
|
+
var import_react_native_bedrock9 = require("react-native-bedrock");
|
|
345
744
|
var bedrockAsyncBridges = __toESM(require("react-native-bedrock/async-bridges"), 1);
|
|
346
745
|
var bedrockConstantBridges = __toESM(require("react-native-bedrock/constant-bridges"), 1);
|
|
347
746
|
|
|
348
747
|
// src/components/GameWebView.tsx
|
|
349
748
|
var import_react_native_webview = require("@react-native-bedrock/native/react-native-webview");
|
|
350
|
-
var
|
|
749
|
+
var import_react_native11 = require("@toss-design-system/react-native");
|
|
351
750
|
var import_es_hangul = require("es-hangul");
|
|
352
|
-
var
|
|
353
|
-
var
|
|
354
|
-
var
|
|
751
|
+
var import_react4 = require("react");
|
|
752
|
+
var import_react_native12 = require("react-native");
|
|
753
|
+
var import_react_native_bedrock8 = require("react-native-bedrock");
|
|
355
754
|
|
|
356
755
|
// src/components/GameWebViewNavigationBar/GameNavigationBar.tsx
|
|
357
756
|
var import_react_native_svg = require("@react-native-bedrock/native/react-native-svg");
|
|
358
|
-
var
|
|
359
|
-
var
|
|
757
|
+
var import_react_native9 = require("@toss-design-system/react-native");
|
|
758
|
+
var import_react_native10 = require("react-native");
|
|
360
759
|
|
|
361
760
|
// src/components/GameWebViewNavigationBar/HeaderRight.tsx
|
|
362
|
-
var
|
|
761
|
+
var import_react_native7 = require("react-native");
|
|
363
762
|
|
|
364
763
|
// src/components/GameWebViewNavigationBar/byPlatform.ts
|
|
365
|
-
var
|
|
764
|
+
var import_react_native6 = require("react-native");
|
|
366
765
|
function byPlatform({
|
|
367
766
|
...props
|
|
368
767
|
}) {
|
|
369
|
-
return (props[
|
|
768
|
+
return (props[import_react_native6.Platform.OS] ?? props.fallback)();
|
|
370
769
|
}
|
|
371
770
|
|
|
372
771
|
// src/components/GameWebViewNavigationBar/constants.ts
|
|
@@ -376,10 +775,10 @@ var IOS_DEFAULT_MARGIN = 20;
|
|
|
376
775
|
// src/components/GameWebViewNavigationBar/HeaderRight.tsx
|
|
377
776
|
var import_jsx_runtime2 = require("react/jsx-runtime");
|
|
378
777
|
function IOSHeaderRight(props) {
|
|
379
|
-
return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
778
|
+
return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_react_native7.View, { style: styles.ios, ...props });
|
|
380
779
|
}
|
|
381
780
|
function AndroidHeaderRight(props) {
|
|
382
|
-
return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
781
|
+
return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_react_native7.View, { style: styles.android, ...props });
|
|
383
782
|
}
|
|
384
783
|
function HeaderRight(props) {
|
|
385
784
|
return byPlatform({
|
|
@@ -388,7 +787,7 @@ function HeaderRight(props) {
|
|
|
388
787
|
fallback: () => /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(IOSHeaderRight, { ...props })
|
|
389
788
|
});
|
|
390
789
|
}
|
|
391
|
-
var styles =
|
|
790
|
+
var styles = import_react_native7.StyleSheet.create({
|
|
392
791
|
ios: {
|
|
393
792
|
marginRight: -IOS_DEFAULT_MARGIN + RIGHT_MARGIN,
|
|
394
793
|
flexDirection: "row"
|
|
@@ -400,10 +799,10 @@ var styles = import_react_native6.StyleSheet.create({
|
|
|
400
799
|
|
|
401
800
|
// src/components/GameWebViewNavigationBar/useSafeAreaTop.ts
|
|
402
801
|
var import_react_native_safe_area_context = require("@react-native-bedrock/native/react-native-safe-area-context");
|
|
403
|
-
var
|
|
802
|
+
var import_react_native8 = require("react-native");
|
|
404
803
|
function useSafeAreaTop() {
|
|
405
804
|
const safeAreaInsets = (0, import_react_native_safe_area_context.useSafeAreaInsets)();
|
|
406
|
-
const hasDynamicIsland =
|
|
805
|
+
const hasDynamicIsland = import_react_native8.Platform.OS === "ios" && safeAreaInsets.top > 50;
|
|
407
806
|
const safeAreaTop = hasDynamicIsland ? safeAreaInsets.top - 5 : safeAreaInsets.top;
|
|
408
807
|
return safeAreaTop;
|
|
409
808
|
}
|
|
@@ -414,31 +813,31 @@ var originXML = '<svg fill="none" height="30" viewBox="0 0 30 30" width="30" xml
|
|
|
414
813
|
function GameNavigationBar({ onClose }) {
|
|
415
814
|
const safeAreaTop = useSafeAreaTop();
|
|
416
815
|
return /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(import_jsx_runtime3.Fragment, { children: [
|
|
417
|
-
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
816
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_react_native9.PageNavbar, { preference: { type: "none" } }),
|
|
418
817
|
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
419
|
-
|
|
818
|
+
import_react_native10.View,
|
|
420
819
|
{
|
|
421
820
|
style: {
|
|
422
821
|
width: "100%",
|
|
423
|
-
height:
|
|
822
|
+
height: import_react_native10.Platform.OS === "ios" ? 44 : 54,
|
|
424
823
|
flexDirection: "row",
|
|
425
824
|
alignItems: "center",
|
|
426
825
|
justifyContent: "flex-end",
|
|
427
826
|
position: "absolute",
|
|
428
827
|
zIndex: 9999,
|
|
429
828
|
marginTop: safeAreaTop,
|
|
430
|
-
paddingRight:
|
|
829
|
+
paddingRight: import_react_native10.Platform.OS === "ios" ? 10 : 8
|
|
431
830
|
},
|
|
432
831
|
pointerEvents: "box-none",
|
|
433
832
|
children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(HeaderRight, { children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
434
|
-
|
|
833
|
+
import_react_native10.TouchableOpacity,
|
|
435
834
|
{
|
|
436
835
|
hitSlop: { left: 8, right: 8 },
|
|
437
836
|
accessibilityRole: "button",
|
|
438
837
|
accessible: true,
|
|
439
838
|
accessibilityLabel: "\uAC8C\uC784\uC885\uB8CC",
|
|
440
839
|
style: {
|
|
441
|
-
padding:
|
|
840
|
+
padding: import_react_native10.Platform.OS === "ios" ? 7 : 9
|
|
442
841
|
},
|
|
443
842
|
onPress: onClose,
|
|
444
843
|
children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_react_native_svg.SvgXml, { xml: originXML, width: 30, height: 30 })
|
|
@@ -451,10 +850,10 @@ function GameNavigationBar({ onClose }) {
|
|
|
451
850
|
|
|
452
851
|
// src/components/GameWebView.tsx
|
|
453
852
|
var import_jsx_runtime4 = require("react/jsx-runtime");
|
|
454
|
-
var GameWebView = (0,
|
|
455
|
-
const { openConfirm } = (0,
|
|
853
|
+
var GameWebView = (0, import_react4.forwardRef)(function GameWebView2(props, ref) {
|
|
854
|
+
const { openConfirm } = (0, import_react_native11.useDialog)();
|
|
456
855
|
const { brandDisplayName } = getAppsInTossGlobals();
|
|
457
|
-
const handleClose = (0,
|
|
856
|
+
const handleClose = (0, import_react4.useCallback)(async () => {
|
|
458
857
|
const isConfirmed = await openConfirm({
|
|
459
858
|
title: `${(0, import_es_hangul.josa)(brandDisplayName, "\uC744/\uB97C")} \uC885\uB8CC\uD560\uAE4C\uC694?`,
|
|
460
859
|
leftButton: "\uCDE8\uC18C",
|
|
@@ -462,31 +861,31 @@ var GameWebView = (0, import_react2.forwardRef)(function GameWebView2(props, ref
|
|
|
462
861
|
closeOnDimmerClick: true
|
|
463
862
|
});
|
|
464
863
|
if (isConfirmed) {
|
|
465
|
-
(0,
|
|
864
|
+
(0, import_react_native_bedrock8.closeView)();
|
|
466
865
|
}
|
|
467
866
|
}, [brandDisplayName, openConfirm]);
|
|
468
|
-
(0,
|
|
469
|
-
if (
|
|
470
|
-
(0,
|
|
867
|
+
(0, import_react4.useEffect)(() => {
|
|
868
|
+
if (import_react_native12.Platform.OS === "ios") {
|
|
869
|
+
(0, import_react_native_bedrock8.setIosSwipeGestureEnabled)({ isEnabled: false });
|
|
471
870
|
return () => {
|
|
472
|
-
(0,
|
|
871
|
+
(0, import_react_native_bedrock8.setIosSwipeGestureEnabled)({ isEnabled: true });
|
|
473
872
|
};
|
|
474
873
|
}
|
|
475
874
|
return;
|
|
476
875
|
}, []);
|
|
477
|
-
(0,
|
|
876
|
+
(0, import_react4.useEffect)(() => {
|
|
478
877
|
const backHandler = () => {
|
|
479
878
|
handleClose();
|
|
480
879
|
return true;
|
|
481
880
|
};
|
|
482
|
-
|
|
881
|
+
import_react_native12.BackHandler.addEventListener("hardwareBackPress", backHandler);
|
|
483
882
|
return () => {
|
|
484
|
-
|
|
883
|
+
import_react_native12.BackHandler.removeEventListener("hardwareBackPress", backHandler);
|
|
485
884
|
};
|
|
486
885
|
}, [handleClose]);
|
|
487
886
|
return /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(import_jsx_runtime4.Fragment, { children: [
|
|
488
887
|
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)(GameNavigationBar, { onClose: handleClose }),
|
|
489
|
-
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
888
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_react_native12.View, { style: { flex: 1 }, children: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_react_native_webview.WebView, { ref, ...props }) })
|
|
490
889
|
] });
|
|
491
890
|
});
|
|
492
891
|
|
|
@@ -495,7 +894,7 @@ var async_bridges_exports = {};
|
|
|
495
894
|
__export(async_bridges_exports, {
|
|
496
895
|
appLogin: () => appLogin,
|
|
497
896
|
checkoutPayment: () => checkoutPayment,
|
|
498
|
-
|
|
897
|
+
eventLog: () => eventLog,
|
|
499
898
|
fetchAlbumPhotos: () => fetchAlbumPhotos,
|
|
500
899
|
fetchContacts: () => fetchContacts,
|
|
501
900
|
getClipboardText: () => getClipboardText,
|
|
@@ -506,7 +905,7 @@ __export(async_bridges_exports, {
|
|
|
506
905
|
});
|
|
507
906
|
|
|
508
907
|
// src/bridge-handler/useBridgeHandler.tsx
|
|
509
|
-
var
|
|
908
|
+
var import_react5 = require("react");
|
|
510
909
|
function serializeError(error) {
|
|
511
910
|
return JSON.stringify(error, (_, value) => {
|
|
512
911
|
if (value instanceof Error) {
|
|
@@ -527,15 +926,16 @@ function methodHandler({
|
|
|
527
926
|
handlerMap,
|
|
528
927
|
injectJavaScript
|
|
529
928
|
}) {
|
|
530
|
-
const func =
|
|
531
|
-
const result = await handlerMap[functionName](...args2);
|
|
532
|
-
return result;
|
|
533
|
-
};
|
|
929
|
+
const func = handlerMap[functionName];
|
|
534
930
|
if (!func) {
|
|
535
931
|
console.error(`${functionName} is not a function`);
|
|
536
932
|
return;
|
|
537
933
|
}
|
|
538
|
-
|
|
934
|
+
const wrappedFunc = async (...args2) => {
|
|
935
|
+
const result = await func(...args2);
|
|
936
|
+
return result;
|
|
937
|
+
};
|
|
938
|
+
wrappedFunc(...args).then((result) => {
|
|
539
939
|
injectJavaScript?.(`
|
|
540
940
|
window.__BEDROCK_NATIVE_EMITTER.emit('${functionName}/resolve/${eventId}', ${JSON.stringify(result, null, 0)});
|
|
541
941
|
`);
|
|
@@ -554,8 +954,8 @@ function useBridgeHandler({
|
|
|
554
954
|
eventListenerMap,
|
|
555
955
|
injectedJavaScript: originalInjectedJavaScript
|
|
556
956
|
}) {
|
|
557
|
-
const ref = (0,
|
|
558
|
-
const injectedJavaScript = (0,
|
|
957
|
+
const ref = (0, import_react5.useRef)(null);
|
|
958
|
+
const injectedJavaScript = (0, import_react5.useMemo)(
|
|
559
959
|
() => [
|
|
560
960
|
`window.__CONSTANT_HANDLER_MAP = ${JSON.stringify(
|
|
561
961
|
Object.entries(constantHandlerMap).reduce(
|
|
@@ -581,7 +981,7 @@ function useBridgeHandler({
|
|
|
581
981
|
window.__BEDROCK_NATIVE_EMITTER.emit('${functionName}/onError/${eventId}', ${JSON.stringify(error, null, 0)});
|
|
582
982
|
`);
|
|
583
983
|
};
|
|
584
|
-
const $onMessage = (0,
|
|
984
|
+
const $onMessage = (0, import_react5.useCallback)(
|
|
585
985
|
async (e) => {
|
|
586
986
|
onMessage?.(e);
|
|
587
987
|
const data = JSON.parse(e.nativeEvent.data);
|
|
@@ -639,11 +1039,6 @@ __export(constant_bridges_exports, {
|
|
|
639
1039
|
getTossAppVersion: () => getTossAppVersion
|
|
640
1040
|
});
|
|
641
1041
|
|
|
642
|
-
// src/env.ts
|
|
643
|
-
var env = {
|
|
644
|
-
getDeploymentId: () => __DEV__ ? "local" : global.__appsInToss?.deploymentId
|
|
645
|
-
};
|
|
646
|
-
|
|
647
1042
|
// src/event-bridges.ts
|
|
648
1043
|
var event_bridges_exports = {};
|
|
649
1044
|
__export(event_bridges_exports, {
|
|
@@ -653,15 +1048,16 @@ __export(event_bridges_exports, {
|
|
|
653
1048
|
// src/components/WebView.tsx
|
|
654
1049
|
var import_jsx_runtime5 = require("react/jsx-runtime");
|
|
655
1050
|
var appsInTossGlobals = getAppsInTossGlobals();
|
|
1051
|
+
var operationalEnvironment = getOperationalEnvironment();
|
|
656
1052
|
var TYPES = ["partner", "external", "game"];
|
|
657
1053
|
var WEBVIEW_TYPES = {
|
|
658
|
-
partner:
|
|
659
|
-
external:
|
|
1054
|
+
partner: import_react_native13.PartnerWebViewScreen,
|
|
1055
|
+
external: import_react_native13.ExternalWebViewScreen,
|
|
660
1056
|
game: GameWebView
|
|
661
1057
|
};
|
|
662
1058
|
function mergeSchemeQueryParamsInto(url) {
|
|
663
1059
|
const baseUrl = new URL(url);
|
|
664
|
-
const schemeUrl = new URL((0,
|
|
1060
|
+
const schemeUrl = new URL((0, import_react_native_bedrock9.getSchemeUri)());
|
|
665
1061
|
baseUrl.pathname = schemeUrl.pathname;
|
|
666
1062
|
for (const [key, value] of schemeUrl.searchParams.entries()) {
|
|
667
1063
|
baseUrl.searchParams.set(key, value);
|
|
@@ -685,8 +1081,8 @@ function WebView({ type, local, onMessage, ...props }) {
|
|
|
685
1081
|
if (!TYPES.includes(type)) {
|
|
686
1082
|
throw new Error(`Invalid WebView type: '${type}'`);
|
|
687
1083
|
}
|
|
688
|
-
const bedrockEvent = (0,
|
|
689
|
-
const uri = (0,
|
|
1084
|
+
const bedrockEvent = (0, import_react_native_bedrock9.useBedrockEvent)();
|
|
1085
|
+
const uri = (0, import_react6.useMemo)(() => getWebViewUri(local), [local]);
|
|
690
1086
|
const top = (0, import_private.useSafeAreaTop)();
|
|
691
1087
|
const bottom = (0, import_private.useSafeAreaBottom)();
|
|
692
1088
|
const handler = useBridgeHandler({
|
|
@@ -694,7 +1090,16 @@ function WebView({ type, local, onMessage, ...props }) {
|
|
|
694
1090
|
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
695
1091
|
eventListenerMap: {
|
|
696
1092
|
...event_bridges_exports,
|
|
697
|
-
backEvent: ({ onEvent, onError, options }) => bedrockEvent.addEventListener("backEvent", { onEvent, onError, options })
|
|
1093
|
+
backEvent: ({ onEvent, onError, options }) => bedrockEvent.addEventListener("backEvent", { onEvent, onError, options }),
|
|
1094
|
+
entryMessageExited: ({ onEvent, onError }) => appsInTossEvent.addEventListener("entryMessageExited", { onEvent, onError }),
|
|
1095
|
+
updateLocationEvent: ({ onEvent, onError, options }) => appsInTossEvent.addEventListener("updateLocationEvent", { onEvent, onError, options }),
|
|
1096
|
+
/** @internal */
|
|
1097
|
+
appBridgeCallbackEvent: ({ onEvent, onError, options }) => appsInTossEvent.addEventListener("appBridgeCallbackEvent", { onEvent, onError, options }),
|
|
1098
|
+
/** AdMob */
|
|
1099
|
+
loadAdMobInterstitialAd: GoogleAdMob.loadAdMobInterstitialAd,
|
|
1100
|
+
showAdMobInterstitialAd: GoogleAdMob.showAdMobInterstitialAd,
|
|
1101
|
+
loadAdMobRewardedAd: GoogleAdMob.loadAdMobRewardedAd,
|
|
1102
|
+
showAdMobRewardedAd: GoogleAdMob.showAdMobRewardedAd
|
|
698
1103
|
},
|
|
699
1104
|
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
700
1105
|
// @ts-expect-error
|
|
@@ -702,7 +1107,12 @@ function WebView({ type, local, onMessage, ...props }) {
|
|
|
702
1107
|
...bedrockConstantBridges,
|
|
703
1108
|
...constant_bridges_exports,
|
|
704
1109
|
getSafeAreaTop: () => top,
|
|
705
|
-
getSafeAreaBottom: () => bottom
|
|
1110
|
+
getSafeAreaBottom: () => bottom,
|
|
1111
|
+
/** AdMob */
|
|
1112
|
+
loadAdMobInterstitialAd_isSupported: GoogleAdMob.loadAdMobInterstitialAd.isSupported,
|
|
1113
|
+
showAdMobInterstitialAd_isSupported: GoogleAdMob.showAdMobInterstitialAd.isSupported,
|
|
1114
|
+
loadAdMobRewardedAd_isSupported: GoogleAdMob.loadAdMobRewardedAd.isSupported,
|
|
1115
|
+
showAdMobRewardedAd_isSupported: GoogleAdMob.showAdMobRewardedAd.isSupported
|
|
706
1116
|
},
|
|
707
1117
|
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
708
1118
|
// @ts-expect-error
|
|
@@ -718,7 +1128,7 @@ function WebView({ type, local, onMessage, ...props }) {
|
|
|
718
1128
|
clearItems: Storage.clearItems
|
|
719
1129
|
}
|
|
720
1130
|
});
|
|
721
|
-
const baseProps = (0,
|
|
1131
|
+
const baseProps = (0, import_react6.useMemo)(() => {
|
|
722
1132
|
switch (type) {
|
|
723
1133
|
case "partner": {
|
|
724
1134
|
const headerOnlyProp = {
|
|
@@ -748,10 +1158,7 @@ function WebView({ type, local, onMessage, ...props }) {
|
|
|
748
1158
|
}
|
|
749
1159
|
}, [type, props]);
|
|
750
1160
|
const BaseWebView = WEBVIEW_TYPES[type];
|
|
751
|
-
const
|
|
752
|
-
() => getOperationalEnvironment() === "sandbox",
|
|
753
|
-
[]
|
|
754
|
-
);
|
|
1161
|
+
const webViewDebuggingEnabled = operationalEnvironment === "sandbox";
|
|
755
1162
|
return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
756
1163
|
BaseWebView,
|
|
757
1164
|
{
|
|
@@ -760,7 +1167,7 @@ function WebView({ type, local, onMessage, ...props }) {
|
|
|
760
1167
|
...baseProps,
|
|
761
1168
|
source: { uri },
|
|
762
1169
|
sharedCookiesEnabled: true,
|
|
763
|
-
webviewDebuggingEnabled,
|
|
1170
|
+
webviewDebuggingEnabled: webViewDebuggingEnabled,
|
|
764
1171
|
thirdPartyCookiesEnabled: true,
|
|
765
1172
|
onMessage: handler.onMessage,
|
|
766
1173
|
injectedJavaScript: handler.injectedJavaScript,
|
|
@@ -776,12 +1183,12 @@ function ensureValue(value, name) {
|
|
|
776
1183
|
}
|
|
777
1184
|
|
|
778
1185
|
// src/hooks/useGeolocation.ts
|
|
779
|
-
var
|
|
780
|
-
var
|
|
1186
|
+
var import_react7 = require("react");
|
|
1187
|
+
var import_react_native_bedrock10 = require("react-native-bedrock");
|
|
781
1188
|
function useGeolocation({ accuracy, distanceInterval, timeInterval }) {
|
|
782
|
-
const isVisible = (0,
|
|
783
|
-
const [location, setLocation] = (0,
|
|
784
|
-
(0,
|
|
1189
|
+
const isVisible = (0, import_react_native_bedrock10.useVisibility)();
|
|
1190
|
+
const [location, setLocation] = (0, import_react7.useState)(null);
|
|
1191
|
+
(0, import_react7.useEffect)(() => {
|
|
785
1192
|
if (!isVisible) {
|
|
786
1193
|
return;
|
|
787
1194
|
}
|
|
@@ -812,11 +1219,14 @@ var Accuracy2 = /* @__PURE__ */ ((Accuracy3) => {
|
|
|
812
1219
|
0 && (module.exports = {
|
|
813
1220
|
Accuracy,
|
|
814
1221
|
AppsInToss,
|
|
1222
|
+
GoogleAdMob,
|
|
815
1223
|
Storage,
|
|
816
1224
|
TossPay,
|
|
817
1225
|
WebView,
|
|
818
1226
|
appLogin,
|
|
1227
|
+
appsInTossEvent,
|
|
819
1228
|
env,
|
|
1229
|
+
eventLog,
|
|
820
1230
|
fetchAlbumPhotos,
|
|
821
1231
|
fetchContacts,
|
|
822
1232
|
getClipboardText,
|
|
@@ -825,6 +1235,7 @@ var Accuracy2 = /* @__PURE__ */ ((Accuracy3) => {
|
|
|
825
1235
|
getOperationalEnvironment,
|
|
826
1236
|
getTossAppVersion,
|
|
827
1237
|
getTossShareLink,
|
|
1238
|
+
isMinVersionSupported,
|
|
828
1239
|
openCamera,
|
|
829
1240
|
setClipboardText,
|
|
830
1241
|
startUpdateLocation,
|