@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.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,
|
|
@@ -44,6 +47,8 @@ __export(src_exports, {
|
|
|
44
47
|
getDeviceId: () => getDeviceId,
|
|
45
48
|
getOperationalEnvironment: () => getOperationalEnvironment,
|
|
46
49
|
getTossAppVersion: () => getTossAppVersion,
|
|
50
|
+
getTossShareLink: () => getTossShareLink,
|
|
51
|
+
isMinVersionSupported: () => isMinVersionSupported,
|
|
47
52
|
openCamera: () => openCamera,
|
|
48
53
|
setClipboardText: () => setClipboardText,
|
|
49
54
|
startUpdateLocation: () => startUpdateLocation,
|
|
@@ -52,80 +57,278 @@ __export(src_exports, {
|
|
|
52
57
|
module.exports = __toCommonJS(src_exports);
|
|
53
58
|
|
|
54
59
|
// src/core/registerApp.tsx
|
|
55
|
-
var
|
|
56
|
-
var
|
|
60
|
+
var import_react_native5 = require("@toss-design-system/react-native");
|
|
61
|
+
var import_react_native_bedrock7 = require("react-native-bedrock");
|
|
57
62
|
|
|
58
|
-
// src/core/
|
|
59
|
-
var
|
|
60
|
-
var
|
|
63
|
+
// src/core/components/AppEvent.tsx
|
|
64
|
+
var import_react2 = require("react");
|
|
65
|
+
var import_react_native_bedrock6 = require("react-native-bedrock");
|
|
61
66
|
|
|
62
|
-
//
|
|
63
|
-
function
|
|
64
|
-
if (global.__appsInToss == null) {
|
|
65
|
-
throw new Error("invalid apps-in-toss globals");
|
|
66
|
-
}
|
|
67
|
-
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() {
|
|
68
69
|
}
|
|
69
70
|
|
|
70
|
-
// src/
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
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;
|
|
74
75
|
|
|
75
|
-
// src/
|
|
76
|
-
function
|
|
77
|
-
|
|
78
|
-
const appsInTossGlobals2 = getAppsInTossGlobals();
|
|
79
|
-
(0, import_react.useEffect)(() => {
|
|
80
|
-
const commonProps = {
|
|
81
|
-
serviceName: appsInTossGlobals2.brandDisplayName,
|
|
82
|
-
icon: toIcon(appsInTossGlobals2.brandIcon),
|
|
83
|
-
color: appsInTossGlobals2.brandPrimaryColor,
|
|
84
|
-
colorMode: appsInTossGlobals2.brandBridgeColorMode
|
|
85
|
-
};
|
|
86
|
-
controller.open({ ...commonProps });
|
|
87
|
-
}, []);
|
|
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);
|
|
88
79
|
}
|
|
89
80
|
|
|
90
|
-
// src/
|
|
91
|
-
var
|
|
92
|
-
function
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
useAppsInTossBridge();
|
|
97
|
-
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_jsx_runtime.Fragment, { children });
|
|
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);
|
|
98
87
|
}
|
|
99
|
-
function
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
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
|
|
103
94
|
});
|
|
95
|
+
void promise.then(onSuccess).catch(onError);
|
|
96
|
+
return unregisterAll;
|
|
104
97
|
}
|
|
105
|
-
function
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
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;
|
|
111
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);
|
|
112
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
|
+
};
|
|
113
128
|
|
|
114
|
-
// src/
|
|
115
|
-
|
|
116
|
-
|
|
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;
|
|
117
202
|
};
|
|
118
203
|
|
|
119
|
-
// src/native-
|
|
120
|
-
|
|
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
|
+
}
|
|
121
224
|
|
|
122
|
-
// src/native-
|
|
123
|
-
|
|
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();
|
|
124
327
|
|
|
125
|
-
// src/native-modules/
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
328
|
+
// src/native-modules/checkoutPayment.ts
|
|
329
|
+
async function checkoutPayment(options) {
|
|
330
|
+
return AppsInTossModule.checkoutPayment({ params: options });
|
|
331
|
+
}
|
|
129
332
|
|
|
130
333
|
// src/native-modules/getPermission.ts
|
|
131
334
|
function getPermission(permission) {
|
|
@@ -149,56 +352,6 @@ async function requestPermission(permission) {
|
|
|
149
352
|
}
|
|
150
353
|
}
|
|
151
354
|
|
|
152
|
-
// src/native-event-emitter/nativeEventEmitter.ts
|
|
153
|
-
var import_react_native4 = require("react-native");
|
|
154
|
-
var nativeEventEmitter = new import_react_native4.NativeEventEmitter(AppsInTossModuleInstance);
|
|
155
|
-
|
|
156
|
-
// src/native-event-emitter/event-plugins/UpdateLocationEvent.ts
|
|
157
|
-
var UpdateLocationEvent = class extends import_react_native_bedrock2.BedrockEventDefinition {
|
|
158
|
-
name = "updateLocationEvent";
|
|
159
|
-
subscriptionCount = 0;
|
|
160
|
-
ref = {
|
|
161
|
-
remove: () => {
|
|
162
|
-
}
|
|
163
|
-
};
|
|
164
|
-
remove() {
|
|
165
|
-
--this.subscriptionCount === 0 && AppsInTossModuleInstance.stopUpdateLocation({});
|
|
166
|
-
this.ref.remove();
|
|
167
|
-
}
|
|
168
|
-
listener(options, onEvent, onError) {
|
|
169
|
-
requestPermission({ name: "geolocation", access: "access" }).then((permissionStatus) => {
|
|
170
|
-
if (permissionStatus === "denied") {
|
|
171
|
-
onError(new Error("\uC704\uCE58 \uAD8C\uD55C\uC774 \uAC70\uBD80\uB418\uC5C8\uC5B4\uC694."));
|
|
172
|
-
return;
|
|
173
|
-
}
|
|
174
|
-
void AppsInTossModuleInstance.startUpdateLocation(options).catch(onError);
|
|
175
|
-
const subscription = nativeEventEmitter.addListener("updateLocation", onEvent);
|
|
176
|
-
this.ref = {
|
|
177
|
-
remove: () => subscription?.remove()
|
|
178
|
-
};
|
|
179
|
-
this.subscriptionCount++;
|
|
180
|
-
}).catch(onError);
|
|
181
|
-
}
|
|
182
|
-
};
|
|
183
|
-
|
|
184
|
-
// src/native-event-emitter/bedrock-event.ts
|
|
185
|
-
var appsInTossEvent = new import_react_native_bedrock3.BedrockEvent([new UpdateLocationEvent()]);
|
|
186
|
-
|
|
187
|
-
// src/native-event-emitter/startUpdateLocation.ts
|
|
188
|
-
function startUpdateLocation(eventParams) {
|
|
189
|
-
return appsInTossEvent.addEventListener("updateLocationEvent", eventParams);
|
|
190
|
-
}
|
|
191
|
-
|
|
192
|
-
// src/native-modules/checkoutPayment.ts
|
|
193
|
-
async function checkoutPayment(options) {
|
|
194
|
-
return AppsInTossModule.checkoutPayment(options);
|
|
195
|
-
}
|
|
196
|
-
|
|
197
|
-
// src/native-modules/executePayment.ts
|
|
198
|
-
async function executePayment(options) {
|
|
199
|
-
return AppsInTossModule.executePayment(options);
|
|
200
|
-
}
|
|
201
|
-
|
|
202
355
|
// src/native-modules/setClipboardText.ts
|
|
203
356
|
async function setClipboardText(text) {
|
|
204
357
|
const permissionStatus = await requestPermission({ name: "clipboard", access: "write" });
|
|
@@ -280,11 +433,6 @@ async function appLogin() {
|
|
|
280
433
|
return AppsInTossModule.appLogin({});
|
|
281
434
|
}
|
|
282
435
|
|
|
283
|
-
// src/native-modules/getOperationalEnvironment.ts
|
|
284
|
-
function getOperationalEnvironment() {
|
|
285
|
-
return AppsInTossModule.operationalEnvironment;
|
|
286
|
-
}
|
|
287
|
-
|
|
288
436
|
// src/native-modules/getTossAppVersion.ts
|
|
289
437
|
function getTossAppVersion() {
|
|
290
438
|
return AppsInTossModule.tossAppVersion;
|
|
@@ -318,42 +466,306 @@ var Storage = {
|
|
|
318
466
|
clearItems
|
|
319
467
|
};
|
|
320
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
|
+
|
|
498
|
+
// src/native-modules/getTossShareLink.ts
|
|
499
|
+
async function getTossShareLink(path) {
|
|
500
|
+
const { shareLink } = await AppsInTossModule.getTossShareLink({});
|
|
501
|
+
const shareUrl = new URL(shareLink);
|
|
502
|
+
shareUrl.searchParams.set("deep_link_value", path);
|
|
503
|
+
shareUrl.searchParams.set("af_dp", path);
|
|
504
|
+
return shareUrl.toString();
|
|
505
|
+
}
|
|
506
|
+
|
|
321
507
|
// src/native-modules/index.ts
|
|
322
508
|
var TossPay = {
|
|
323
|
-
checkoutPayment
|
|
324
|
-
|
|
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
|
|
325
737
|
};
|
|
326
738
|
|
|
327
739
|
// src/components/WebView.tsx
|
|
328
|
-
var
|
|
740
|
+
var import_react_native13 = require("@toss-design-system/react-native");
|
|
329
741
|
var import_private = require("@toss-design-system/react-native/private");
|
|
330
|
-
var
|
|
331
|
-
var
|
|
742
|
+
var import_react6 = require("react");
|
|
743
|
+
var import_react_native_bedrock9 = require("react-native-bedrock");
|
|
332
744
|
var bedrockAsyncBridges = __toESM(require("react-native-bedrock/async-bridges"), 1);
|
|
333
745
|
var bedrockConstantBridges = __toESM(require("react-native-bedrock/constant-bridges"), 1);
|
|
334
746
|
|
|
335
747
|
// src/components/GameWebView.tsx
|
|
336
748
|
var import_react_native_webview = require("@react-native-bedrock/native/react-native-webview");
|
|
337
|
-
var
|
|
749
|
+
var import_react_native11 = require("@toss-design-system/react-native");
|
|
338
750
|
var import_es_hangul = require("es-hangul");
|
|
339
|
-
var
|
|
340
|
-
var
|
|
341
|
-
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");
|
|
342
754
|
|
|
343
755
|
// src/components/GameWebViewNavigationBar/GameNavigationBar.tsx
|
|
344
756
|
var import_react_native_svg = require("@react-native-bedrock/native/react-native-svg");
|
|
345
|
-
var
|
|
346
|
-
var
|
|
757
|
+
var import_react_native9 = require("@toss-design-system/react-native");
|
|
758
|
+
var import_react_native10 = require("react-native");
|
|
347
759
|
|
|
348
760
|
// src/components/GameWebViewNavigationBar/HeaderRight.tsx
|
|
349
|
-
var
|
|
761
|
+
var import_react_native7 = require("react-native");
|
|
350
762
|
|
|
351
763
|
// src/components/GameWebViewNavigationBar/byPlatform.ts
|
|
352
|
-
var
|
|
764
|
+
var import_react_native6 = require("react-native");
|
|
353
765
|
function byPlatform({
|
|
354
766
|
...props
|
|
355
767
|
}) {
|
|
356
|
-
return (props[
|
|
768
|
+
return (props[import_react_native6.Platform.OS] ?? props.fallback)();
|
|
357
769
|
}
|
|
358
770
|
|
|
359
771
|
// src/components/GameWebViewNavigationBar/constants.ts
|
|
@@ -363,10 +775,10 @@ var IOS_DEFAULT_MARGIN = 20;
|
|
|
363
775
|
// src/components/GameWebViewNavigationBar/HeaderRight.tsx
|
|
364
776
|
var import_jsx_runtime2 = require("react/jsx-runtime");
|
|
365
777
|
function IOSHeaderRight(props) {
|
|
366
|
-
return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
778
|
+
return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_react_native7.View, { style: styles.ios, ...props });
|
|
367
779
|
}
|
|
368
780
|
function AndroidHeaderRight(props) {
|
|
369
|
-
return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
781
|
+
return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_react_native7.View, { style: styles.android, ...props });
|
|
370
782
|
}
|
|
371
783
|
function HeaderRight(props) {
|
|
372
784
|
return byPlatform({
|
|
@@ -375,7 +787,7 @@ function HeaderRight(props) {
|
|
|
375
787
|
fallback: () => /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(IOSHeaderRight, { ...props })
|
|
376
788
|
});
|
|
377
789
|
}
|
|
378
|
-
var styles =
|
|
790
|
+
var styles = import_react_native7.StyleSheet.create({
|
|
379
791
|
ios: {
|
|
380
792
|
marginRight: -IOS_DEFAULT_MARGIN + RIGHT_MARGIN,
|
|
381
793
|
flexDirection: "row"
|
|
@@ -387,10 +799,10 @@ var styles = import_react_native6.StyleSheet.create({
|
|
|
387
799
|
|
|
388
800
|
// src/components/GameWebViewNavigationBar/useSafeAreaTop.ts
|
|
389
801
|
var import_react_native_safe_area_context = require("@react-native-bedrock/native/react-native-safe-area-context");
|
|
390
|
-
var
|
|
802
|
+
var import_react_native8 = require("react-native");
|
|
391
803
|
function useSafeAreaTop() {
|
|
392
804
|
const safeAreaInsets = (0, import_react_native_safe_area_context.useSafeAreaInsets)();
|
|
393
|
-
const hasDynamicIsland =
|
|
805
|
+
const hasDynamicIsland = import_react_native8.Platform.OS === "ios" && safeAreaInsets.top > 50;
|
|
394
806
|
const safeAreaTop = hasDynamicIsland ? safeAreaInsets.top - 5 : safeAreaInsets.top;
|
|
395
807
|
return safeAreaTop;
|
|
396
808
|
}
|
|
@@ -401,31 +813,31 @@ var originXML = '<svg fill="none" height="30" viewBox="0 0 30 30" width="30" xml
|
|
|
401
813
|
function GameNavigationBar({ onClose }) {
|
|
402
814
|
const safeAreaTop = useSafeAreaTop();
|
|
403
815
|
return /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(import_jsx_runtime3.Fragment, { children: [
|
|
404
|
-
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
816
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_react_native9.PageNavbar, { preference: { type: "none" } }),
|
|
405
817
|
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
406
|
-
|
|
818
|
+
import_react_native10.View,
|
|
407
819
|
{
|
|
408
820
|
style: {
|
|
409
821
|
width: "100%",
|
|
410
|
-
height:
|
|
822
|
+
height: import_react_native10.Platform.OS === "ios" ? 44 : 54,
|
|
411
823
|
flexDirection: "row",
|
|
412
824
|
alignItems: "center",
|
|
413
825
|
justifyContent: "flex-end",
|
|
414
826
|
position: "absolute",
|
|
415
827
|
zIndex: 9999,
|
|
416
828
|
marginTop: safeAreaTop,
|
|
417
|
-
paddingRight:
|
|
829
|
+
paddingRight: import_react_native10.Platform.OS === "ios" ? 10 : 8
|
|
418
830
|
},
|
|
419
831
|
pointerEvents: "box-none",
|
|
420
832
|
children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(HeaderRight, { children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
421
|
-
|
|
833
|
+
import_react_native10.TouchableOpacity,
|
|
422
834
|
{
|
|
423
835
|
hitSlop: { left: 8, right: 8 },
|
|
424
836
|
accessibilityRole: "button",
|
|
425
837
|
accessible: true,
|
|
426
838
|
accessibilityLabel: "\uAC8C\uC784\uC885\uB8CC",
|
|
427
839
|
style: {
|
|
428
|
-
padding:
|
|
840
|
+
padding: import_react_native10.Platform.OS === "ios" ? 7 : 9
|
|
429
841
|
},
|
|
430
842
|
onPress: onClose,
|
|
431
843
|
children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_react_native_svg.SvgXml, { xml: originXML, width: 30, height: 30 })
|
|
@@ -438,10 +850,10 @@ function GameNavigationBar({ onClose }) {
|
|
|
438
850
|
|
|
439
851
|
// src/components/GameWebView.tsx
|
|
440
852
|
var import_jsx_runtime4 = require("react/jsx-runtime");
|
|
441
|
-
var GameWebView = (0,
|
|
442
|
-
const { openConfirm } = (0,
|
|
853
|
+
var GameWebView = (0, import_react4.forwardRef)(function GameWebView2(props, ref) {
|
|
854
|
+
const { openConfirm } = (0, import_react_native11.useDialog)();
|
|
443
855
|
const { brandDisplayName } = getAppsInTossGlobals();
|
|
444
|
-
const handleClose = (0,
|
|
856
|
+
const handleClose = (0, import_react4.useCallback)(async () => {
|
|
445
857
|
const isConfirmed = await openConfirm({
|
|
446
858
|
title: `${(0, import_es_hangul.josa)(brandDisplayName, "\uC744/\uB97C")} \uC885\uB8CC\uD560\uAE4C\uC694?`,
|
|
447
859
|
leftButton: "\uCDE8\uC18C",
|
|
@@ -449,31 +861,31 @@ var GameWebView = (0, import_react2.forwardRef)(function GameWebView2(props, ref
|
|
|
449
861
|
closeOnDimmerClick: true
|
|
450
862
|
});
|
|
451
863
|
if (isConfirmed) {
|
|
452
|
-
(0,
|
|
864
|
+
(0, import_react_native_bedrock8.closeView)();
|
|
453
865
|
}
|
|
454
866
|
}, [brandDisplayName, openConfirm]);
|
|
455
|
-
(0,
|
|
456
|
-
if (
|
|
457
|
-
(0,
|
|
867
|
+
(0, import_react4.useEffect)(() => {
|
|
868
|
+
if (import_react_native12.Platform.OS === "ios") {
|
|
869
|
+
(0, import_react_native_bedrock8.setIosSwipeGestureEnabled)({ isEnabled: false });
|
|
458
870
|
return () => {
|
|
459
|
-
(0,
|
|
871
|
+
(0, import_react_native_bedrock8.setIosSwipeGestureEnabled)({ isEnabled: true });
|
|
460
872
|
};
|
|
461
873
|
}
|
|
462
874
|
return;
|
|
463
875
|
}, []);
|
|
464
|
-
(0,
|
|
876
|
+
(0, import_react4.useEffect)(() => {
|
|
465
877
|
const backHandler = () => {
|
|
466
878
|
handleClose();
|
|
467
879
|
return true;
|
|
468
880
|
};
|
|
469
|
-
|
|
881
|
+
import_react_native12.BackHandler.addEventListener("hardwareBackPress", backHandler);
|
|
470
882
|
return () => {
|
|
471
|
-
|
|
883
|
+
import_react_native12.BackHandler.removeEventListener("hardwareBackPress", backHandler);
|
|
472
884
|
};
|
|
473
885
|
}, [handleClose]);
|
|
474
886
|
return /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(import_jsx_runtime4.Fragment, { children: [
|
|
475
887
|
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)(GameNavigationBar, { onClose: handleClose }),
|
|
476
|
-
/* @__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 }) })
|
|
477
889
|
] });
|
|
478
890
|
});
|
|
479
891
|
|
|
@@ -482,15 +894,143 @@ var async_bridges_exports = {};
|
|
|
482
894
|
__export(async_bridges_exports, {
|
|
483
895
|
appLogin: () => appLogin,
|
|
484
896
|
checkoutPayment: () => checkoutPayment,
|
|
485
|
-
|
|
897
|
+
eventLog: () => eventLog,
|
|
486
898
|
fetchAlbumPhotos: () => fetchAlbumPhotos,
|
|
487
899
|
fetchContacts: () => fetchContacts,
|
|
488
900
|
getClipboardText: () => getClipboardText,
|
|
489
901
|
getCurrentLocation: () => getCurrentLocation,
|
|
902
|
+
getTossShareLink: () => getTossShareLink,
|
|
490
903
|
openCamera: () => openCamera,
|
|
491
904
|
setClipboardText: () => setClipboardText
|
|
492
905
|
});
|
|
493
906
|
|
|
907
|
+
// src/bridge-handler/useBridgeHandler.tsx
|
|
908
|
+
var import_react5 = require("react");
|
|
909
|
+
function serializeError(error) {
|
|
910
|
+
return JSON.stringify(error, (_, value) => {
|
|
911
|
+
if (value instanceof Error) {
|
|
912
|
+
return {
|
|
913
|
+
name: value.name,
|
|
914
|
+
message: value.message,
|
|
915
|
+
stack: value.stack,
|
|
916
|
+
__isError: true
|
|
917
|
+
};
|
|
918
|
+
}
|
|
919
|
+
return value;
|
|
920
|
+
});
|
|
921
|
+
}
|
|
922
|
+
function methodHandler({
|
|
923
|
+
args,
|
|
924
|
+
eventId,
|
|
925
|
+
functionName,
|
|
926
|
+
handlerMap,
|
|
927
|
+
injectJavaScript
|
|
928
|
+
}) {
|
|
929
|
+
const func = handlerMap[functionName];
|
|
930
|
+
if (!func) {
|
|
931
|
+
console.error(`${functionName} is not a function`);
|
|
932
|
+
return;
|
|
933
|
+
}
|
|
934
|
+
const wrappedFunc = async (...args2) => {
|
|
935
|
+
const result = await func(...args2);
|
|
936
|
+
return result;
|
|
937
|
+
};
|
|
938
|
+
wrappedFunc(...args).then((result) => {
|
|
939
|
+
injectJavaScript?.(`
|
|
940
|
+
window.__BEDROCK_NATIVE_EMITTER.emit('${functionName}/resolve/${eventId}', ${JSON.stringify(result, null, 0)});
|
|
941
|
+
`);
|
|
942
|
+
}).catch((error) => {
|
|
943
|
+
const serializedError = serializeError(error);
|
|
944
|
+
injectJavaScript?.(`
|
|
945
|
+
window.__BEDROCK_NATIVE_EMITTER.emit('${functionName}/reject/${eventId}', ${serializedError});
|
|
946
|
+
`);
|
|
947
|
+
});
|
|
948
|
+
}
|
|
949
|
+
var globalEventListenerMap = /* @__PURE__ */ new Map();
|
|
950
|
+
function useBridgeHandler({
|
|
951
|
+
onMessage,
|
|
952
|
+
constantHandlerMap,
|
|
953
|
+
asyncHandlerMap,
|
|
954
|
+
eventListenerMap,
|
|
955
|
+
injectedJavaScript: originalInjectedJavaScript
|
|
956
|
+
}) {
|
|
957
|
+
const ref = (0, import_react5.useRef)(null);
|
|
958
|
+
const injectedJavaScript = (0, import_react5.useMemo)(
|
|
959
|
+
() => [
|
|
960
|
+
`window.__CONSTANT_HANDLER_MAP = ${JSON.stringify(
|
|
961
|
+
Object.entries(constantHandlerMap).reduce(
|
|
962
|
+
(acc, [key, value]) => {
|
|
963
|
+
acc[key] = typeof value === "function" ? value() : value;
|
|
964
|
+
return acc;
|
|
965
|
+
},
|
|
966
|
+
{}
|
|
967
|
+
)
|
|
968
|
+
)}`,
|
|
969
|
+
originalInjectedJavaScript,
|
|
970
|
+
"true"
|
|
971
|
+
].join("\n"),
|
|
972
|
+
[constantHandlerMap, originalInjectedJavaScript]
|
|
973
|
+
);
|
|
974
|
+
const createHandleOnEvent = (functionName, eventId) => (response) => {
|
|
975
|
+
ref.current?.injectJavaScript(`
|
|
976
|
+
window.__BEDROCK_NATIVE_EMITTER.emit('${functionName}/onEvent/${eventId}', ${JSON.stringify(response, null, 0)});
|
|
977
|
+
`);
|
|
978
|
+
};
|
|
979
|
+
const createHandleOnError = (functionName, eventId) => (error) => {
|
|
980
|
+
ref.current?.injectJavaScript(`
|
|
981
|
+
window.__BEDROCK_NATIVE_EMITTER.emit('${functionName}/onError/${eventId}', ${JSON.stringify(error, null, 0)});
|
|
982
|
+
`);
|
|
983
|
+
};
|
|
984
|
+
const $onMessage = (0, import_react5.useCallback)(
|
|
985
|
+
async (e) => {
|
|
986
|
+
onMessage?.(e);
|
|
987
|
+
const data = JSON.parse(e.nativeEvent.data);
|
|
988
|
+
if (typeof data !== "object" || data === null || typeof data.functionName !== "string" || typeof data.eventId !== "string" || typeof data.type !== "string" || !["addEventListener", "removeEventListener", "method"].includes(data.type)) {
|
|
989
|
+
return;
|
|
990
|
+
}
|
|
991
|
+
switch (data.type) {
|
|
992
|
+
case "addEventListener": {
|
|
993
|
+
const handleOnEvent = createHandleOnEvent(data.functionName, data.eventId);
|
|
994
|
+
const handleOnError = createHandleOnError(data.functionName, data.eventId);
|
|
995
|
+
const remove = eventListenerMap[data.functionName]?.({
|
|
996
|
+
onEvent: handleOnEvent,
|
|
997
|
+
onError: handleOnError,
|
|
998
|
+
options: data.args
|
|
999
|
+
});
|
|
1000
|
+
if (remove) {
|
|
1001
|
+
globalEventListenerMap.set(`${data.functionName}/${data.eventId}`, remove);
|
|
1002
|
+
}
|
|
1003
|
+
break;
|
|
1004
|
+
}
|
|
1005
|
+
case "removeEventListener": {
|
|
1006
|
+
const key = `${data.functionName}/${data.eventId}`;
|
|
1007
|
+
const remove = globalEventListenerMap.get(key);
|
|
1008
|
+
remove?.();
|
|
1009
|
+
globalEventListenerMap.delete(key);
|
|
1010
|
+
break;
|
|
1011
|
+
}
|
|
1012
|
+
case "method": {
|
|
1013
|
+
methodHandler({
|
|
1014
|
+
args: data.args,
|
|
1015
|
+
eventId: data.eventId,
|
|
1016
|
+
functionName: data.functionName,
|
|
1017
|
+
handlerMap: asyncHandlerMap,
|
|
1018
|
+
injectJavaScript: ref.current?.injectJavaScript
|
|
1019
|
+
});
|
|
1020
|
+
break;
|
|
1021
|
+
}
|
|
1022
|
+
}
|
|
1023
|
+
},
|
|
1024
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
1025
|
+
[onMessage]
|
|
1026
|
+
);
|
|
1027
|
+
return {
|
|
1028
|
+
ref,
|
|
1029
|
+
injectedJavaScript,
|
|
1030
|
+
onMessage: $onMessage
|
|
1031
|
+
};
|
|
1032
|
+
}
|
|
1033
|
+
|
|
494
1034
|
// src/constant-bridges.ts
|
|
495
1035
|
var constant_bridges_exports = {};
|
|
496
1036
|
__export(constant_bridges_exports, {
|
|
@@ -499,11 +1039,6 @@ __export(constant_bridges_exports, {
|
|
|
499
1039
|
getTossAppVersion: () => getTossAppVersion
|
|
500
1040
|
});
|
|
501
1041
|
|
|
502
|
-
// src/env.ts
|
|
503
|
-
var env = {
|
|
504
|
-
getDeploymentId: () => __DEV__ ? "local" : global.__appsInToss?.deploymentId
|
|
505
|
-
};
|
|
506
|
-
|
|
507
1042
|
// src/event-bridges.ts
|
|
508
1043
|
var event_bridges_exports = {};
|
|
509
1044
|
__export(event_bridges_exports, {
|
|
@@ -513,15 +1048,16 @@ __export(event_bridges_exports, {
|
|
|
513
1048
|
// src/components/WebView.tsx
|
|
514
1049
|
var import_jsx_runtime5 = require("react/jsx-runtime");
|
|
515
1050
|
var appsInTossGlobals = getAppsInTossGlobals();
|
|
1051
|
+
var operationalEnvironment = getOperationalEnvironment();
|
|
516
1052
|
var TYPES = ["partner", "external", "game"];
|
|
517
1053
|
var WEBVIEW_TYPES = {
|
|
518
|
-
partner:
|
|
519
|
-
external:
|
|
1054
|
+
partner: import_react_native13.PartnerWebViewScreen,
|
|
1055
|
+
external: import_react_native13.ExternalWebViewScreen,
|
|
520
1056
|
game: GameWebView
|
|
521
1057
|
};
|
|
522
1058
|
function mergeSchemeQueryParamsInto(url) {
|
|
523
1059
|
const baseUrl = new URL(url);
|
|
524
|
-
const schemeUrl = new URL((0,
|
|
1060
|
+
const schemeUrl = new URL((0, import_react_native_bedrock9.getSchemeUri)());
|
|
525
1061
|
baseUrl.pathname = schemeUrl.pathname;
|
|
526
1062
|
for (const [key, value] of schemeUrl.searchParams.entries()) {
|
|
527
1063
|
baseUrl.searchParams.set(key, value);
|
|
@@ -545,16 +1081,25 @@ function WebView({ type, local, onMessage, ...props }) {
|
|
|
545
1081
|
if (!TYPES.includes(type)) {
|
|
546
1082
|
throw new Error(`Invalid WebView type: '${type}'`);
|
|
547
1083
|
}
|
|
548
|
-
const bedrockEvent = (0,
|
|
549
|
-
const uri = (0,
|
|
1084
|
+
const bedrockEvent = (0, import_react_native_bedrock9.useBedrockEvent)();
|
|
1085
|
+
const uri = (0, import_react6.useMemo)(() => getWebViewUri(local), [local]);
|
|
550
1086
|
const top = (0, import_private.useSafeAreaTop)();
|
|
551
1087
|
const bottom = (0, import_private.useSafeAreaBottom)();
|
|
552
|
-
const handler =
|
|
1088
|
+
const handler = useBridgeHandler({
|
|
553
1089
|
onMessage,
|
|
554
1090
|
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
555
1091
|
eventListenerMap: {
|
|
556
1092
|
...event_bridges_exports,
|
|
557
|
-
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
|
|
558
1103
|
},
|
|
559
1104
|
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
560
1105
|
// @ts-expect-error
|
|
@@ -562,7 +1107,12 @@ function WebView({ type, local, onMessage, ...props }) {
|
|
|
562
1107
|
...bedrockConstantBridges,
|
|
563
1108
|
...constant_bridges_exports,
|
|
564
1109
|
getSafeAreaTop: () => top,
|
|
565
|
-
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
|
|
566
1116
|
},
|
|
567
1117
|
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
568
1118
|
// @ts-expect-error
|
|
@@ -578,7 +1128,7 @@ function WebView({ type, local, onMessage, ...props }) {
|
|
|
578
1128
|
clearItems: Storage.clearItems
|
|
579
1129
|
}
|
|
580
1130
|
});
|
|
581
|
-
const baseProps = (0,
|
|
1131
|
+
const baseProps = (0, import_react6.useMemo)(() => {
|
|
582
1132
|
switch (type) {
|
|
583
1133
|
case "partner": {
|
|
584
1134
|
const headerOnlyProp = {
|
|
@@ -608,10 +1158,7 @@ function WebView({ type, local, onMessage, ...props }) {
|
|
|
608
1158
|
}
|
|
609
1159
|
}, [type, props]);
|
|
610
1160
|
const BaseWebView = WEBVIEW_TYPES[type];
|
|
611
|
-
const
|
|
612
|
-
() => getOperationalEnvironment() === "sandbox",
|
|
613
|
-
[]
|
|
614
|
-
);
|
|
1161
|
+
const webViewDebuggingEnabled = operationalEnvironment === "sandbox";
|
|
615
1162
|
return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
616
1163
|
BaseWebView,
|
|
617
1164
|
{
|
|
@@ -620,7 +1167,7 @@ function WebView({ type, local, onMessage, ...props }) {
|
|
|
620
1167
|
...baseProps,
|
|
621
1168
|
source: { uri },
|
|
622
1169
|
sharedCookiesEnabled: true,
|
|
623
|
-
webviewDebuggingEnabled,
|
|
1170
|
+
webviewDebuggingEnabled: webViewDebuggingEnabled,
|
|
624
1171
|
thirdPartyCookiesEnabled: true,
|
|
625
1172
|
onMessage: handler.onMessage,
|
|
626
1173
|
injectedJavaScript: handler.injectedJavaScript,
|
|
@@ -636,12 +1183,12 @@ function ensureValue(value, name) {
|
|
|
636
1183
|
}
|
|
637
1184
|
|
|
638
1185
|
// src/hooks/useGeolocation.ts
|
|
639
|
-
var
|
|
640
|
-
var
|
|
1186
|
+
var import_react7 = require("react");
|
|
1187
|
+
var import_react_native_bedrock10 = require("react-native-bedrock");
|
|
641
1188
|
function useGeolocation({ accuracy, distanceInterval, timeInterval }) {
|
|
642
|
-
const isVisible = (0,
|
|
643
|
-
const [location, setLocation] = (0,
|
|
644
|
-
(0,
|
|
1189
|
+
const isVisible = (0, import_react_native_bedrock10.useVisibility)();
|
|
1190
|
+
const [location, setLocation] = (0, import_react7.useState)(null);
|
|
1191
|
+
(0, import_react7.useEffect)(() => {
|
|
645
1192
|
if (!isVisible) {
|
|
646
1193
|
return;
|
|
647
1194
|
}
|
|
@@ -672,11 +1219,14 @@ var Accuracy2 = /* @__PURE__ */ ((Accuracy3) => {
|
|
|
672
1219
|
0 && (module.exports = {
|
|
673
1220
|
Accuracy,
|
|
674
1221
|
AppsInToss,
|
|
1222
|
+
GoogleAdMob,
|
|
675
1223
|
Storage,
|
|
676
1224
|
TossPay,
|
|
677
1225
|
WebView,
|
|
678
1226
|
appLogin,
|
|
1227
|
+
appsInTossEvent,
|
|
679
1228
|
env,
|
|
1229
|
+
eventLog,
|
|
680
1230
|
fetchAlbumPhotos,
|
|
681
1231
|
fetchContacts,
|
|
682
1232
|
getClipboardText,
|
|
@@ -684,6 +1234,8 @@ var Accuracy2 = /* @__PURE__ */ ((Accuracy3) => {
|
|
|
684
1234
|
getDeviceId,
|
|
685
1235
|
getOperationalEnvironment,
|
|
686
1236
|
getTossAppVersion,
|
|
1237
|
+
getTossShareLink,
|
|
1238
|
+
isMinVersionSupported,
|
|
687
1239
|
openCamera,
|
|
688
1240
|
setClipboardText,
|
|
689
1241
|
startUpdateLocation,
|