@apps-in-toss/framework 0.0.23 → 0.0.24
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 +593 -483
- package/dist/index.d.cts +41 -26
- package/dist/index.d.ts +41 -26
- package/dist/index.js +557 -448
- package/package.json +9 -8
package/dist/index.js
CHANGED
|
@@ -4,84 +4,34 @@ var __export = (target, all) => {
|
|
|
4
4
|
__defProp(target, name, { get: all[name], enumerable: true });
|
|
5
5
|
};
|
|
6
6
|
|
|
7
|
+
// src/index.ts
|
|
8
|
+
import { Analytics as InternalAnalytics } from "@apps-in-toss/analytics";
|
|
9
|
+
|
|
7
10
|
// src/core/registerApp.tsx
|
|
11
|
+
import { Analytics } from "@apps-in-toss/analytics";
|
|
8
12
|
import { TDSProvider } from "@toss-design-system/react-native";
|
|
9
|
-
import { Bedrock } from "react-native-bedrock";
|
|
13
|
+
import { Bedrock as Bedrock2 } from "react-native-bedrock";
|
|
10
14
|
|
|
11
15
|
// src/core/components/AppEvent.tsx
|
|
12
16
|
import { useEffect } from "react";
|
|
13
|
-
import { getSchemeUri as getSchemeUri2 } from "react-native-bedrock";
|
|
14
|
-
|
|
15
|
-
// ../../.yarn/cache/es-toolkit-npm-1.34.1-4cd6371dcb-aab6d07be3.zip/node_modules/es-toolkit/dist/function/noop.mjs
|
|
16
|
-
function noop() {
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
// src/native-modules/AppsInTossModule.ts
|
|
20
|
-
import { NativeModules } from "react-native";
|
|
21
|
-
var AppsInTossModuleInstance = NativeModules.AppsInTossModule;
|
|
22
|
-
var AppsInTossModule = AppsInTossModuleInstance;
|
|
23
|
-
|
|
24
|
-
// src/utils/generateUUID.ts
|
|
25
|
-
function generateUUID(placeholder) {
|
|
26
|
-
return placeholder ? (placeholder ^ Math.random() * 16 >> placeholder / 4).toString(16) : (String(1e7) + 1e3 + 4e3 + 8e3 + 1e11).replace(/[018]/g, generateUUID);
|
|
27
|
-
}
|
|
17
|
+
import { Bedrock, getSchemeUri as getSchemeUri2 } from "react-native-bedrock";
|
|
28
18
|
|
|
29
|
-
// src/
|
|
30
|
-
var
|
|
31
|
-
|
|
32
|
-
const callback = INTERNAL__callbacks.get(id);
|
|
33
|
-
callback?.call(null, ...args);
|
|
34
|
-
return Boolean(callback);
|
|
35
|
-
}
|
|
36
|
-
function invokeAppBridgeMethod(methodName, params, callbacks) {
|
|
37
|
-
const { onSuccess, onError, ...appBridgeCallbacks } = callbacks;
|
|
38
|
-
const { callbackMap, unregisterAll } = registerCallbacks(appBridgeCallbacks);
|
|
39
|
-
const promise = AppsInTossModuleInstance[methodName]({
|
|
40
|
-
params,
|
|
41
|
-
callbacks: callbackMap
|
|
42
|
-
});
|
|
43
|
-
void promise.then(onSuccess).catch(onError);
|
|
44
|
-
return unregisterAll;
|
|
45
|
-
}
|
|
46
|
-
function registerCallbacks(callbacks) {
|
|
47
|
-
const callbackMap = {};
|
|
48
|
-
for (const [callbackName, callback] of Object.entries(callbacks)) {
|
|
49
|
-
const id = registerCallback(callback, callbackName);
|
|
50
|
-
callbackMap[callbackName] = id;
|
|
51
|
-
}
|
|
52
|
-
const unregisterAll = () => {
|
|
53
|
-
Object.values(callbackMap).forEach(unregisterCallback);
|
|
54
|
-
};
|
|
55
|
-
return { callbackMap, unregisterAll };
|
|
56
|
-
}
|
|
57
|
-
function registerCallback(callback, name = "unnamed") {
|
|
58
|
-
const uniqueId = generateUUID();
|
|
59
|
-
const callbackId = `${uniqueId}__${name}`;
|
|
60
|
-
INTERNAL__callbacks.set(callbackId, callback);
|
|
61
|
-
return callbackId;
|
|
62
|
-
}
|
|
63
|
-
function unregisterCallback(id) {
|
|
64
|
-
INTERNAL__callbacks.delete(id);
|
|
65
|
-
}
|
|
66
|
-
function getCallbackIds() {
|
|
67
|
-
return Array.from(INTERNAL__callbacks.keys());
|
|
68
|
-
}
|
|
69
|
-
var INTERNAL__appBridgeHandler = {
|
|
70
|
-
invokeAppBridgeCallback,
|
|
71
|
-
invokeAppBridgeMethod,
|
|
72
|
-
registerCallback,
|
|
73
|
-
unregisterCallback,
|
|
74
|
-
getCallbackIds
|
|
19
|
+
// src/env.ts
|
|
20
|
+
var env = {
|
|
21
|
+
getDeploymentId: () => __DEV__ ? "local" : global.__appsInToss?.deploymentId
|
|
75
22
|
};
|
|
76
23
|
|
|
77
|
-
// src/native-modules/
|
|
78
|
-
|
|
79
|
-
return AppsInTossModule.operationalEnvironment;
|
|
80
|
-
}
|
|
24
|
+
// src/native-modules/tossCore.ts
|
|
25
|
+
import { NativeModules as NativeModules2 } from "react-native";
|
|
81
26
|
|
|
82
27
|
// src/native-modules/isMinVersionSupported.ts
|
|
83
28
|
import { Platform } from "react-native";
|
|
84
29
|
|
|
30
|
+
// src/native-modules/AppsInTossModule.ts
|
|
31
|
+
import { NativeModules } from "react-native";
|
|
32
|
+
var AppsInTossModuleInstance = NativeModules.AppsInTossModule;
|
|
33
|
+
var AppsInTossModule = AppsInTossModuleInstance;
|
|
34
|
+
|
|
85
35
|
// src/utils/compareVersion.ts
|
|
86
36
|
var SEMVER_REGEX = /^[v^~<>=]*?(\d+)(?:\.([x*]|\d+)(?:\.([x*]|\d+)(?:\.([x*]|\d+))?(?:-([\da-z\\-]+(?:\.[\da-z\\-]+)*))?(?:\+[\da-z\\-]+(?:\.[\da-z\\-]+)*)?)?)?$/i;
|
|
87
37
|
var isWildcard = (val) => ["*", "x", "X"].includes(val);
|
|
@@ -170,113 +120,103 @@ function isMinVersionSupported(minVersions) {
|
|
|
170
120
|
return compareVersions(currentVersion, minVersion) >= 0;
|
|
171
121
|
}
|
|
172
122
|
|
|
173
|
-
// src/native-modules/
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
123
|
+
// src/native-modules/tossCore.ts
|
|
124
|
+
var TossCoreModule = NativeModules2.TossCoreModule;
|
|
125
|
+
function tossCoreEventLog(params) {
|
|
126
|
+
const supported = isMinVersionSupported({ ios: "5.210.0", android: "5.210.0" });
|
|
127
|
+
if (!supported) {
|
|
128
|
+
return;
|
|
178
129
|
}
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
onEvent({ type: "dismissed" });
|
|
186
|
-
},
|
|
187
|
-
onAdFailedToShow: () => {
|
|
188
|
-
onEvent({ type: "failedToShow" });
|
|
189
|
-
},
|
|
190
|
-
onAdImpression: () => {
|
|
191
|
-
onEvent({ type: "impression" });
|
|
192
|
-
},
|
|
193
|
-
onAdShow: () => {
|
|
194
|
-
onEvent({ type: "show" });
|
|
195
|
-
},
|
|
196
|
-
onSuccess: (result) => onEvent({ type: "loaded", data: result }),
|
|
197
|
-
onError
|
|
130
|
+
TossCoreModule.eventLog({
|
|
131
|
+
params: {
|
|
132
|
+
log_name: params.log_name,
|
|
133
|
+
log_type: params.log_type,
|
|
134
|
+
params: params.params
|
|
135
|
+
}
|
|
198
136
|
});
|
|
199
|
-
return unregisterCallbacks;
|
|
200
137
|
}
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
138
|
+
|
|
139
|
+
// src/core/hooks/useReferrer.ts
|
|
140
|
+
import { useMemo } from "react";
|
|
141
|
+
import { getSchemeUri } from "react-native-bedrock";
|
|
142
|
+
function useReferrer() {
|
|
143
|
+
return useMemo(() => {
|
|
144
|
+
try {
|
|
145
|
+
return new URL(getSchemeUri()).searchParams.get("referrer");
|
|
146
|
+
} catch {
|
|
147
|
+
return null;
|
|
148
|
+
}
|
|
149
|
+
}, []);
|
|
212
150
|
}
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
151
|
+
|
|
152
|
+
// src/core/components/AppEvent.tsx
|
|
153
|
+
var ENTRY_APP_EVENT_SCHEMA_ID = 1562181;
|
|
154
|
+
function isPrivateScheme() {
|
|
155
|
+
try {
|
|
156
|
+
return new URL(getSchemeUri2()).protocol === "intoss-private:";
|
|
157
|
+
} catch {
|
|
158
|
+
return false;
|
|
217
159
|
}
|
|
218
|
-
const { onEvent, onError, options } = params;
|
|
219
|
-
const unregisterCallbacks = INTERNAL__appBridgeHandler.invokeAppBridgeMethod("loadAdMobRewardedAd", options, {
|
|
220
|
-
onAdClicked: () => {
|
|
221
|
-
onEvent({ type: "clicked" });
|
|
222
|
-
},
|
|
223
|
-
onAdDismissed: () => {
|
|
224
|
-
onEvent({ type: "dismissed" });
|
|
225
|
-
},
|
|
226
|
-
onAdFailedToShow: () => {
|
|
227
|
-
onEvent({ type: "failedToShow" });
|
|
228
|
-
},
|
|
229
|
-
onAdImpression: () => {
|
|
230
|
-
onEvent({ type: "impression" });
|
|
231
|
-
},
|
|
232
|
-
onAdShow: () => {
|
|
233
|
-
onEvent({ type: "show" });
|
|
234
|
-
},
|
|
235
|
-
onUserEarnedReward: () => {
|
|
236
|
-
onEvent({ type: "userEarnedReward" });
|
|
237
|
-
},
|
|
238
|
-
onSuccess: (result) => onEvent({ type: "loaded", data: result }),
|
|
239
|
-
onError
|
|
240
|
-
});
|
|
241
|
-
return unregisterCallbacks;
|
|
242
160
|
}
|
|
243
|
-
function
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
161
|
+
function EntryAppEvent() {
|
|
162
|
+
const referrer = useReferrer() ?? "";
|
|
163
|
+
useEffect(() => {
|
|
164
|
+
tossCoreEventLog({
|
|
165
|
+
log_name: "appsintoss_app_visit::impression__enter_appsintoss",
|
|
166
|
+
log_type: "info",
|
|
167
|
+
params: {
|
|
168
|
+
is_transform: true,
|
|
169
|
+
schema_id: ENTRY_APP_EVENT_SCHEMA_ID,
|
|
170
|
+
referrer,
|
|
171
|
+
deployment_id: env.getDeploymentId(),
|
|
172
|
+
app_name: Bedrock.appName,
|
|
173
|
+
is_private: isPrivateScheme()
|
|
174
|
+
}
|
|
175
|
+
});
|
|
176
|
+
}, [referrer]);
|
|
177
|
+
return null;
|
|
254
178
|
}
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
ios: IOS_GOOGLE_AD_MOB_SUPPORTED_VERSION
|
|
179
|
+
function SystemAppEvent({ ...initialProps }) {
|
|
180
|
+
useEffect(() => {
|
|
181
|
+
tossCoreEventLog({
|
|
182
|
+
log_name: "AppsInTossInitialProps",
|
|
183
|
+
log_type: "debug",
|
|
184
|
+
params: {
|
|
185
|
+
...initialProps,
|
|
186
|
+
schemeUri: getSchemeUri2(),
|
|
187
|
+
deployment_id: env.getDeploymentId(),
|
|
188
|
+
app_name: Bedrock.appName,
|
|
189
|
+
is_private: isPrivateScheme()
|
|
190
|
+
}
|
|
268
191
|
});
|
|
269
|
-
};
|
|
192
|
+
}, [initialProps]);
|
|
193
|
+
return null;
|
|
270
194
|
}
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
195
|
+
var AppEvent = {
|
|
196
|
+
Entry: EntryAppEvent,
|
|
197
|
+
System: SystemAppEvent
|
|
198
|
+
};
|
|
275
199
|
|
|
276
|
-
// src/
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
200
|
+
// src/core/hooks/useAppsInTossBridge.ts
|
|
201
|
+
import { useBridge } from "@toss-design-system/react-native";
|
|
202
|
+
import { useEffect as useEffect2 } from "react";
|
|
203
|
+
|
|
204
|
+
// src/native-event-emitter/appsInTossEvent.ts
|
|
205
|
+
import { BedrockEvent } from "react-native-bedrock";
|
|
206
|
+
|
|
207
|
+
// src/native-event-emitter/event-plugins/EntryMessageExitedEvent.ts
|
|
208
|
+
import { BedrockEventDefinition } from "react-native-bedrock";
|
|
209
|
+
var EntryMessageExitedEvent = class extends BedrockEventDefinition {
|
|
210
|
+
name = "entryMessageExited";
|
|
211
|
+
remove() {
|
|
212
|
+
}
|
|
213
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
214
|
+
listener(_) {
|
|
215
|
+
}
|
|
216
|
+
};
|
|
217
|
+
|
|
218
|
+
// src/native-event-emitter/event-plugins/UpdateLocationEvent.ts
|
|
219
|
+
import { BedrockEventDefinition as BedrockEventDefinition2 } from "react-native-bedrock";
|
|
280
220
|
|
|
281
221
|
// src/native-modules/getPermission.ts
|
|
282
222
|
function getPermission(permission) {
|
|
@@ -300,189 +240,9 @@ async function requestPermission(permission) {
|
|
|
300
240
|
}
|
|
301
241
|
}
|
|
302
242
|
|
|
303
|
-
// src/native-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
if (permissionStatus === "denied") {
|
|
307
|
-
throw new Error("\uD074\uB9BD\uBCF4\uB4DC \uC4F0\uAE30 \uAD8C\uD55C\uC774 \uAC70\uBD80\uB418\uC5C8\uC5B4\uC694.");
|
|
308
|
-
}
|
|
309
|
-
return AppsInTossModule.setClipboardText({ text });
|
|
310
|
-
}
|
|
311
|
-
|
|
312
|
-
// src/native-modules/getClipboardText.ts
|
|
313
|
-
async function getClipboardText() {
|
|
314
|
-
const permissionStatus = await requestPermission({ name: "clipboard", access: "read" });
|
|
315
|
-
if (permissionStatus === "denied") {
|
|
316
|
-
throw new Error("\uD074\uB9BD\uBCF4\uB4DC \uC77D\uAE30 \uAD8C\uD55C\uC774 \uAC70\uBD80\uB418\uC5C8\uC5B4\uC694.");
|
|
317
|
-
}
|
|
318
|
-
return AppsInTossModule.getClipboardText({});
|
|
319
|
-
}
|
|
320
|
-
|
|
321
|
-
// src/native-modules/fetchContacts.ts
|
|
322
|
-
async function fetchContacts({
|
|
323
|
-
size,
|
|
324
|
-
offset,
|
|
325
|
-
query
|
|
326
|
-
}) {
|
|
327
|
-
const permissionStatus = await requestPermission({ name: "contacts", access: "read" });
|
|
328
|
-
if (permissionStatus === "denied") {
|
|
329
|
-
throw new Error("\uC5F0\uB77D\uCC98 \uAD8C\uD55C\uC774 \uAC70\uBD80\uB418\uC5C8\uC5B4\uC694.");
|
|
330
|
-
}
|
|
331
|
-
const contacts = await AppsInTossModule.fetchContacts({
|
|
332
|
-
size,
|
|
333
|
-
offset,
|
|
334
|
-
query
|
|
335
|
-
});
|
|
336
|
-
return {
|
|
337
|
-
result: contacts.result,
|
|
338
|
-
nextOffset: contacts.nextOffset ?? null,
|
|
339
|
-
done: contacts.done
|
|
340
|
-
};
|
|
341
|
-
}
|
|
342
|
-
|
|
343
|
-
// src/native-modules/fetchAlbumPhotos.ts
|
|
344
|
-
var DEFAULT_MAX_COUNT = 10;
|
|
345
|
-
var DEFAULT_MAX_WIDTH = 1024;
|
|
346
|
-
async function fetchAlbumPhotos(options) {
|
|
347
|
-
const permissionStatus = await requestPermission({ name: "photos", access: "read" });
|
|
348
|
-
if (permissionStatus === "denied") {
|
|
349
|
-
throw new Error("\uC0AC\uC9C4\uCCA9 \uAD8C\uD55C\uC774 \uAC70\uBD80\uB418\uC5C8\uC5B4\uC694.");
|
|
350
|
-
}
|
|
351
|
-
const albumPhotos = await AppsInTossModule.fetchAlbumPhotos({
|
|
352
|
-
...options,
|
|
353
|
-
maxCount: options.maxCount ?? DEFAULT_MAX_COUNT,
|
|
354
|
-
maxWidth: options.maxWidth ?? DEFAULT_MAX_WIDTH
|
|
355
|
-
});
|
|
356
|
-
return albumPhotos;
|
|
357
|
-
}
|
|
358
|
-
|
|
359
|
-
// src/native-modules/getCurrentLocation.ts
|
|
360
|
-
async function getCurrentLocation(options) {
|
|
361
|
-
const permissionStatus = await requestPermission({ name: "geolocation", access: "access" });
|
|
362
|
-
if (permissionStatus === "denied") {
|
|
363
|
-
throw new Error("\uC704\uCE58 \uAD8C\uD55C\uC774 \uAC70\uBD80\uB418\uC5C8\uC5B4\uC694.");
|
|
364
|
-
}
|
|
365
|
-
const position = await AppsInTossModule.getCurrentLocation(options);
|
|
366
|
-
return position;
|
|
367
|
-
}
|
|
368
|
-
|
|
369
|
-
// src/native-modules/openCamera.ts
|
|
370
|
-
async function openCamera(options) {
|
|
371
|
-
const permissionStatus = await requestPermission({ name: "camera", access: "access" });
|
|
372
|
-
if (permissionStatus === "denied") {
|
|
373
|
-
throw new Error("\uCE74\uBA54\uB77C \uAD8C\uD55C\uC774 \uAC70\uBD80\uB418\uC5C8\uC5B4\uC694.");
|
|
374
|
-
}
|
|
375
|
-
const photo = await AppsInTossModule.openCamera({ base64: false, maxWidth: 1024, ...options });
|
|
376
|
-
return photo;
|
|
377
|
-
}
|
|
378
|
-
|
|
379
|
-
// src/native-modules/appLogin.ts
|
|
380
|
-
async function appLogin() {
|
|
381
|
-
return AppsInTossModule.appLogin({});
|
|
382
|
-
}
|
|
383
|
-
|
|
384
|
-
// src/native-modules/getTossAppVersion.ts
|
|
385
|
-
function getTossAppVersion() {
|
|
386
|
-
return AppsInTossModule.tossAppVersion;
|
|
387
|
-
}
|
|
388
|
-
|
|
389
|
-
// src/native-modules/getDeviceId.ts
|
|
390
|
-
function getDeviceId() {
|
|
391
|
-
return AppsInTossModule.deviceId;
|
|
392
|
-
}
|
|
393
|
-
|
|
394
|
-
// src/native-modules/storage.ts
|
|
395
|
-
function getItem(key) {
|
|
396
|
-
return AppsInTossModule.getStorageItem({ key });
|
|
397
|
-
}
|
|
398
|
-
function setItem(key, value) {
|
|
399
|
-
return AppsInTossModule.setStorageItem({
|
|
400
|
-
key,
|
|
401
|
-
value
|
|
402
|
-
});
|
|
403
|
-
}
|
|
404
|
-
function removeItem(key) {
|
|
405
|
-
return AppsInTossModule.removeStorageItem({ key });
|
|
406
|
-
}
|
|
407
|
-
function clearItems() {
|
|
408
|
-
return AppsInTossModule.clearStorage({});
|
|
409
|
-
}
|
|
410
|
-
var Storage = {
|
|
411
|
-
getItem,
|
|
412
|
-
setItem,
|
|
413
|
-
removeItem,
|
|
414
|
-
clearItems
|
|
415
|
-
};
|
|
416
|
-
|
|
417
|
-
// src/native-modules/eventLog.ts
|
|
418
|
-
function normalizeParams(params) {
|
|
419
|
-
return Object.fromEntries(
|
|
420
|
-
Object.entries(params).filter(([, value]) => value !== void 0).map(([key, value]) => [key, String(value)])
|
|
421
|
-
);
|
|
422
|
-
}
|
|
423
|
-
async function eventLog(params) {
|
|
424
|
-
if (AppsInTossModule.operationalEnvironment === "sandbox") {
|
|
425
|
-
console.log("[eventLogDebug]", {
|
|
426
|
-
log_name: params.log_name,
|
|
427
|
-
log_type: params.log_type,
|
|
428
|
-
params: normalizeParams(params.params)
|
|
429
|
-
});
|
|
430
|
-
return;
|
|
431
|
-
}
|
|
432
|
-
const isSupported = isMinVersionSupported({
|
|
433
|
-
android: "5.208.0",
|
|
434
|
-
ios: "5.208.0"
|
|
435
|
-
});
|
|
436
|
-
if (!isSupported) {
|
|
437
|
-
return;
|
|
438
|
-
}
|
|
439
|
-
return AppsInTossModule.eventLog({
|
|
440
|
-
log_name: params.log_name,
|
|
441
|
-
log_type: params.log_type,
|
|
442
|
-
params: normalizeParams(params.params)
|
|
443
|
-
});
|
|
444
|
-
}
|
|
445
|
-
|
|
446
|
-
// src/native-modules/getTossShareLink.ts
|
|
447
|
-
async function getTossShareLink(path) {
|
|
448
|
-
const { shareLink } = await AppsInTossModule.getTossShareLink({});
|
|
449
|
-
const shareUrl = new URL(shareLink);
|
|
450
|
-
shareUrl.searchParams.set("deep_link_value", path);
|
|
451
|
-
shareUrl.searchParams.set("af_dp", path);
|
|
452
|
-
return shareUrl.toString();
|
|
453
|
-
}
|
|
454
|
-
|
|
455
|
-
// src/native-modules/index.ts
|
|
456
|
-
var TossPay = {
|
|
457
|
-
checkoutPayment
|
|
458
|
-
};
|
|
459
|
-
var GoogleAdMob = {
|
|
460
|
-
loadAdMobInterstitialAd,
|
|
461
|
-
showAdMobInterstitialAd,
|
|
462
|
-
loadAdMobRewardedAd,
|
|
463
|
-
showAdMobRewardedAd
|
|
464
|
-
};
|
|
465
|
-
|
|
466
|
-
// src/native-event-emitter/appsInTossEvent.ts
|
|
467
|
-
import { BedrockEvent } from "react-native-bedrock";
|
|
468
|
-
|
|
469
|
-
// src/native-event-emitter/event-plugins/EntryMessageExitedEvent.ts
|
|
470
|
-
import { BedrockEventDefinition } from "react-native-bedrock";
|
|
471
|
-
var EntryMessageExitedEvent = class extends BedrockEventDefinition {
|
|
472
|
-
name = "entryMessageExited";
|
|
473
|
-
remove() {
|
|
474
|
-
}
|
|
475
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
476
|
-
listener(_) {
|
|
477
|
-
}
|
|
478
|
-
};
|
|
479
|
-
|
|
480
|
-
// src/native-event-emitter/event-plugins/UpdateLocationEvent.ts
|
|
481
|
-
import { BedrockEventDefinition as BedrockEventDefinition2 } from "react-native-bedrock";
|
|
482
|
-
|
|
483
|
-
// src/native-event-emitter/nativeEventEmitter.ts
|
|
484
|
-
import { NativeEventEmitter } from "react-native";
|
|
485
|
-
var nativeEventEmitter = new NativeEventEmitter(AppsInTossModuleInstance);
|
|
243
|
+
// src/native-event-emitter/nativeEventEmitter.ts
|
|
244
|
+
import { NativeEventEmitter } from "react-native";
|
|
245
|
+
var nativeEventEmitter = new NativeEventEmitter(AppsInTossModuleInstance);
|
|
486
246
|
|
|
487
247
|
// src/native-event-emitter/event-plugins/UpdateLocationEvent.ts
|
|
488
248
|
var UpdateLocationEvent = class extends BedrockEventDefinition2 {
|
|
@@ -514,6 +274,61 @@ var UpdateLocationEvent = class extends BedrockEventDefinition2 {
|
|
|
514
274
|
|
|
515
275
|
// src/native-event-emitter/internal/AppBridgeCallbackEvent.ts
|
|
516
276
|
import { BedrockEventDefinition as BedrockEventDefinition3 } from "react-native-bedrock";
|
|
277
|
+
|
|
278
|
+
// src/utils/generateUUID.ts
|
|
279
|
+
function generateUUID(placeholder) {
|
|
280
|
+
return placeholder ? (placeholder ^ Math.random() * 16 >> placeholder / 4).toString(16) : (String(1e7) + 1e3 + 4e3 + 8e3 + 1e11).replace(/[018]/g, generateUUID);
|
|
281
|
+
}
|
|
282
|
+
|
|
283
|
+
// src/native-event-emitter/internal/appBridge.ts
|
|
284
|
+
var INTERNAL__callbacks = /* @__PURE__ */ new Map();
|
|
285
|
+
function invokeAppBridgeCallback(id, ...args) {
|
|
286
|
+
const callback = INTERNAL__callbacks.get(id);
|
|
287
|
+
callback?.call(null, ...args);
|
|
288
|
+
return Boolean(callback);
|
|
289
|
+
}
|
|
290
|
+
function invokeAppBridgeMethod(methodName, params, callbacks) {
|
|
291
|
+
const { onSuccess, onError, ...appBridgeCallbacks } = callbacks;
|
|
292
|
+
const { callbackMap, unregisterAll } = registerCallbacks(appBridgeCallbacks);
|
|
293
|
+
const promise = AppsInTossModuleInstance[methodName]({
|
|
294
|
+
params,
|
|
295
|
+
callbacks: callbackMap
|
|
296
|
+
});
|
|
297
|
+
void promise.then(onSuccess).catch(onError);
|
|
298
|
+
return unregisterAll;
|
|
299
|
+
}
|
|
300
|
+
function registerCallbacks(callbacks) {
|
|
301
|
+
const callbackMap = {};
|
|
302
|
+
for (const [callbackName, callback] of Object.entries(callbacks)) {
|
|
303
|
+
const id = registerCallback(callback, callbackName);
|
|
304
|
+
callbackMap[callbackName] = id;
|
|
305
|
+
}
|
|
306
|
+
const unregisterAll = () => {
|
|
307
|
+
Object.values(callbackMap).forEach(unregisterCallback);
|
|
308
|
+
};
|
|
309
|
+
return { callbackMap, unregisterAll };
|
|
310
|
+
}
|
|
311
|
+
function registerCallback(callback, name = "unnamed") {
|
|
312
|
+
const uniqueId = generateUUID();
|
|
313
|
+
const callbackId = `${uniqueId}__${name}`;
|
|
314
|
+
INTERNAL__callbacks.set(callbackId, callback);
|
|
315
|
+
return callbackId;
|
|
316
|
+
}
|
|
317
|
+
function unregisterCallback(id) {
|
|
318
|
+
INTERNAL__callbacks.delete(id);
|
|
319
|
+
}
|
|
320
|
+
function getCallbackIds() {
|
|
321
|
+
return Array.from(INTERNAL__callbacks.keys());
|
|
322
|
+
}
|
|
323
|
+
var INTERNAL__appBridgeHandler = {
|
|
324
|
+
invokeAppBridgeCallback,
|
|
325
|
+
invokeAppBridgeMethod,
|
|
326
|
+
registerCallback,
|
|
327
|
+
unregisterCallback,
|
|
328
|
+
getCallbackIds
|
|
329
|
+
};
|
|
330
|
+
|
|
331
|
+
// src/native-event-emitter/internal/AppBridgeCallbackEvent.ts
|
|
517
332
|
var UNSAFE__nativeEventEmitter = nativeEventEmitter;
|
|
518
333
|
var AppBridgeCallbackEvent = class _AppBridgeCallbackEvent extends BedrockEventDefinition3 {
|
|
519
334
|
static INTERNAL__appBridgeSubscription;
|
|
@@ -551,101 +366,176 @@ var appsInTossEvent = new BedrockEvent([
|
|
|
551
366
|
new EntryMessageExitedEvent()
|
|
552
367
|
]);
|
|
553
368
|
|
|
554
|
-
// src/
|
|
555
|
-
function
|
|
556
|
-
|
|
369
|
+
// src/core/utils/getAppsInTossGlobals.ts
|
|
370
|
+
function getAppsInTossGlobals() {
|
|
371
|
+
if (global.__appsInToss == null) {
|
|
372
|
+
throw new Error("invalid apps-in-toss globals");
|
|
373
|
+
}
|
|
374
|
+
return global.__appsInToss;
|
|
557
375
|
}
|
|
558
376
|
|
|
559
|
-
// src/
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
};
|
|
563
|
-
|
|
564
|
-
// src/core/hooks/useReferrer.ts
|
|
565
|
-
import { useMemo } from "react";
|
|
566
|
-
import { getSchemeUri } from "react-native-bedrock";
|
|
567
|
-
function useReferrer() {
|
|
568
|
-
return useMemo(() => {
|
|
569
|
-
try {
|
|
570
|
-
return new URL(getSchemeUri()).searchParams.get("referrer");
|
|
571
|
-
} catch {
|
|
572
|
-
return null;
|
|
573
|
-
}
|
|
574
|
-
}, []);
|
|
377
|
+
// src/core/utils/toIcon.ts
|
|
378
|
+
function toIcon(source) {
|
|
379
|
+
return source.startsWith("http") ? { source: { uri: source } } : { name: source };
|
|
575
380
|
}
|
|
576
381
|
|
|
577
|
-
// src/core/
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
const
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
382
|
+
// src/core/hooks/useAppsInTossBridge.ts
|
|
383
|
+
function useAppsInTossBridge() {
|
|
384
|
+
const controller = useBridge();
|
|
385
|
+
const appsInTossGlobals2 = getAppsInTossGlobals();
|
|
386
|
+
useEffect2(() => {
|
|
387
|
+
const commonProps = {
|
|
388
|
+
serviceName: appsInTossGlobals2.brandDisplayName,
|
|
389
|
+
icon: toIcon(appsInTossGlobals2.brandIcon),
|
|
390
|
+
color: appsInTossGlobals2.brandPrimaryColor,
|
|
391
|
+
colorMode: appsInTossGlobals2.brandBridgeColorMode
|
|
392
|
+
};
|
|
393
|
+
controller.open({
|
|
394
|
+
...commonProps,
|
|
395
|
+
onExited: () => {
|
|
396
|
+
appsInTossEvent.emit("entryMessageExited", void 0);
|
|
590
397
|
}
|
|
591
398
|
});
|
|
592
|
-
}, [
|
|
593
|
-
return null;
|
|
399
|
+
}, []);
|
|
594
400
|
}
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
401
|
+
|
|
402
|
+
// src/async-bridges.ts
|
|
403
|
+
var async_bridges_exports = {};
|
|
404
|
+
__export(async_bridges_exports, {
|
|
405
|
+
appLogin: () => appLogin,
|
|
406
|
+
checkoutPayment: () => checkoutPayment,
|
|
407
|
+
eventLog: () => eventLog,
|
|
408
|
+
fetchAlbumPhotos: () => fetchAlbumPhotos,
|
|
409
|
+
fetchContacts: () => fetchContacts,
|
|
410
|
+
getClipboardText: () => getClipboardText,
|
|
411
|
+
getCurrentLocation: () => getCurrentLocation,
|
|
412
|
+
getTossShareLink: () => getTossShareLink,
|
|
413
|
+
openCamera: () => openCamera,
|
|
414
|
+
setClipboardText: () => setClipboardText
|
|
415
|
+
});
|
|
416
|
+
|
|
417
|
+
// src/native-modules/setClipboardText.ts
|
|
418
|
+
async function setClipboardText(text) {
|
|
419
|
+
const permissionStatus = await requestPermission({ name: "clipboard", access: "write" });
|
|
420
|
+
if (permissionStatus === "denied") {
|
|
421
|
+
throw new Error("\uD074\uB9BD\uBCF4\uB4DC \uC4F0\uAE30 \uAD8C\uD55C\uC774 \uAC70\uBD80\uB418\uC5C8\uC5B4\uC694.");
|
|
422
|
+
}
|
|
423
|
+
return AppsInTossModule.setClipboardText({ text });
|
|
608
424
|
}
|
|
609
|
-
var AppEvent = {
|
|
610
|
-
Entry: EntryAppEvent,
|
|
611
|
-
System: SystemAppEvent
|
|
612
|
-
};
|
|
613
425
|
|
|
614
|
-
// src/
|
|
615
|
-
|
|
616
|
-
|
|
426
|
+
// src/native-modules/getClipboardText.ts
|
|
427
|
+
async function getClipboardText() {
|
|
428
|
+
const permissionStatus = await requestPermission({ name: "clipboard", access: "read" });
|
|
429
|
+
if (permissionStatus === "denied") {
|
|
430
|
+
throw new Error("\uD074\uB9BD\uBCF4\uB4DC \uC77D\uAE30 \uAD8C\uD55C\uC774 \uAC70\uBD80\uB418\uC5C8\uC5B4\uC694.");
|
|
431
|
+
}
|
|
432
|
+
return AppsInTossModule.getClipboardText({});
|
|
433
|
+
}
|
|
617
434
|
|
|
618
|
-
// src/
|
|
619
|
-
function
|
|
620
|
-
|
|
621
|
-
|
|
435
|
+
// src/native-modules/fetchContacts.ts
|
|
436
|
+
async function fetchContacts({
|
|
437
|
+
size,
|
|
438
|
+
offset,
|
|
439
|
+
query
|
|
440
|
+
}) {
|
|
441
|
+
const permissionStatus = await requestPermission({ name: "contacts", access: "read" });
|
|
442
|
+
if (permissionStatus === "denied") {
|
|
443
|
+
throw new Error("\uC5F0\uB77D\uCC98 \uAD8C\uD55C\uC774 \uAC70\uBD80\uB418\uC5C8\uC5B4\uC694.");
|
|
622
444
|
}
|
|
623
|
-
|
|
445
|
+
const contacts = await AppsInTossModule.fetchContacts({
|
|
446
|
+
size,
|
|
447
|
+
offset,
|
|
448
|
+
query
|
|
449
|
+
});
|
|
450
|
+
return {
|
|
451
|
+
result: contacts.result,
|
|
452
|
+
nextOffset: contacts.nextOffset ?? null,
|
|
453
|
+
done: contacts.done
|
|
454
|
+
};
|
|
455
|
+
}
|
|
456
|
+
|
|
457
|
+
// src/native-modules/fetchAlbumPhotos.ts
|
|
458
|
+
var DEFAULT_MAX_COUNT = 10;
|
|
459
|
+
var DEFAULT_MAX_WIDTH = 1024;
|
|
460
|
+
async function fetchAlbumPhotos(options) {
|
|
461
|
+
const permissionStatus = await requestPermission({ name: "photos", access: "read" });
|
|
462
|
+
if (permissionStatus === "denied") {
|
|
463
|
+
throw new Error("\uC0AC\uC9C4\uCCA9 \uAD8C\uD55C\uC774 \uAC70\uBD80\uB418\uC5C8\uC5B4\uC694.");
|
|
464
|
+
}
|
|
465
|
+
const albumPhotos = await AppsInTossModule.fetchAlbumPhotos({
|
|
466
|
+
...options,
|
|
467
|
+
maxCount: options.maxCount ?? DEFAULT_MAX_COUNT,
|
|
468
|
+
maxWidth: options.maxWidth ?? DEFAULT_MAX_WIDTH
|
|
469
|
+
});
|
|
470
|
+
return albumPhotos;
|
|
471
|
+
}
|
|
472
|
+
|
|
473
|
+
// src/native-modules/getCurrentLocation.ts
|
|
474
|
+
async function getCurrentLocation(options) {
|
|
475
|
+
const permissionStatus = await requestPermission({ name: "geolocation", access: "access" });
|
|
476
|
+
if (permissionStatus === "denied") {
|
|
477
|
+
throw new Error("\uC704\uCE58 \uAD8C\uD55C\uC774 \uAC70\uBD80\uB418\uC5C8\uC5B4\uC694.");
|
|
478
|
+
}
|
|
479
|
+
const position = await AppsInTossModule.getCurrentLocation(options);
|
|
480
|
+
return position;
|
|
481
|
+
}
|
|
482
|
+
|
|
483
|
+
// src/native-modules/openCamera.ts
|
|
484
|
+
async function openCamera(options) {
|
|
485
|
+
const permissionStatus = await requestPermission({ name: "camera", access: "access" });
|
|
486
|
+
if (permissionStatus === "denied") {
|
|
487
|
+
throw new Error("\uCE74\uBA54\uB77C \uAD8C\uD55C\uC774 \uAC70\uBD80\uB418\uC5C8\uC5B4\uC694.");
|
|
488
|
+
}
|
|
489
|
+
const photo = await AppsInTossModule.openCamera({ base64: false, maxWidth: 1024, ...options });
|
|
490
|
+
return photo;
|
|
491
|
+
}
|
|
492
|
+
|
|
493
|
+
// src/native-modules/appLogin.ts
|
|
494
|
+
async function appLogin() {
|
|
495
|
+
return AppsInTossModule.appLogin({});
|
|
624
496
|
}
|
|
625
497
|
|
|
626
|
-
// src/
|
|
627
|
-
function
|
|
628
|
-
return
|
|
498
|
+
// src/native-modules/checkoutPayment.ts
|
|
499
|
+
async function checkoutPayment(options) {
|
|
500
|
+
return AppsInTossModule.checkoutPayment({ params: options });
|
|
629
501
|
}
|
|
630
502
|
|
|
631
|
-
// src/
|
|
632
|
-
function
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
...commonProps,
|
|
644
|
-
onExited: () => {
|
|
645
|
-
appsInTossEvent.emit("entryMessageExited", void 0);
|
|
646
|
-
}
|
|
503
|
+
// src/native-modules/eventLog.ts
|
|
504
|
+
function normalizeParams(params) {
|
|
505
|
+
return Object.fromEntries(
|
|
506
|
+
Object.entries(params).filter(([, value]) => value !== void 0).map(([key, value]) => [key, String(value)])
|
|
507
|
+
);
|
|
508
|
+
}
|
|
509
|
+
async function eventLog(params) {
|
|
510
|
+
if (AppsInTossModule.operationalEnvironment === "sandbox") {
|
|
511
|
+
console.log("[eventLogDebug]", {
|
|
512
|
+
log_name: params.log_name,
|
|
513
|
+
log_type: params.log_type,
|
|
514
|
+
params: normalizeParams(params.params)
|
|
647
515
|
});
|
|
648
|
-
|
|
516
|
+
return;
|
|
517
|
+
}
|
|
518
|
+
const isSupported = isMinVersionSupported({
|
|
519
|
+
android: "5.208.0",
|
|
520
|
+
ios: "5.208.0"
|
|
521
|
+
});
|
|
522
|
+
if (!isSupported) {
|
|
523
|
+
return;
|
|
524
|
+
}
|
|
525
|
+
return AppsInTossModule.eventLog({
|
|
526
|
+
log_name: params.log_name,
|
|
527
|
+
log_type: params.log_type,
|
|
528
|
+
params: normalizeParams(params.params)
|
|
529
|
+
});
|
|
530
|
+
}
|
|
531
|
+
|
|
532
|
+
// src/native-modules/getTossShareLink.ts
|
|
533
|
+
async function getTossShareLink(path) {
|
|
534
|
+
const { shareLink } = await AppsInTossModule.getTossShareLink({});
|
|
535
|
+
const shareUrl = new URL(shareLink);
|
|
536
|
+
shareUrl.searchParams.set("deep_link_value", path);
|
|
537
|
+
shareUrl.searchParams.set("af_dp", path);
|
|
538
|
+
return shareUrl.toString();
|
|
649
539
|
}
|
|
650
540
|
|
|
651
541
|
// src/core/registerApp.tsx
|
|
@@ -661,12 +551,19 @@ function TDSContainer({ children }) {
|
|
|
661
551
|
useAppsInTossBridge();
|
|
662
552
|
return /* @__PURE__ */ jsx(Fragment, { children });
|
|
663
553
|
}
|
|
664
|
-
function registerApp(container, { context }) {
|
|
665
|
-
|
|
554
|
+
function registerApp(container, { context, analytics }) {
|
|
555
|
+
Analytics.init({
|
|
556
|
+
logger: (params) => void eventLog(params),
|
|
557
|
+
debug: analytics?.debug ?? __DEV__
|
|
558
|
+
});
|
|
559
|
+
return Bedrock2.registerApp(AppsInTossContainer.bind(null, container), {
|
|
666
560
|
appName: getAppName(),
|
|
667
561
|
context,
|
|
668
|
-
|
|
669
|
-
|
|
562
|
+
router: {
|
|
563
|
+
screenContainer: Analytics.Screen,
|
|
564
|
+
defaultScreenOption: {
|
|
565
|
+
statusBarStyle: "dark"
|
|
566
|
+
}
|
|
670
567
|
}
|
|
671
568
|
});
|
|
672
569
|
}
|
|
@@ -684,14 +581,175 @@ var AppsInToss = {
|
|
|
684
581
|
registerApp
|
|
685
582
|
};
|
|
686
583
|
|
|
584
|
+
// src/native-event-emitter/startUpdateLocation.ts
|
|
585
|
+
function startUpdateLocation(eventParams) {
|
|
586
|
+
return appsInTossEvent.addEventListener("updateLocationEvent", eventParams);
|
|
587
|
+
}
|
|
588
|
+
|
|
589
|
+
// ../../.yarn/cache/es-toolkit-npm-1.34.1-4cd6371dcb-aab6d07be3.zip/node_modules/es-toolkit/dist/function/noop.mjs
|
|
590
|
+
function noop() {
|
|
591
|
+
}
|
|
592
|
+
|
|
593
|
+
// src/native-modules/getOperationalEnvironment.ts
|
|
594
|
+
function getOperationalEnvironment() {
|
|
595
|
+
return AppsInTossModule.operationalEnvironment;
|
|
596
|
+
}
|
|
597
|
+
|
|
598
|
+
// src/native-modules/ads/googleAdMob.ts
|
|
599
|
+
function loadAdMobInterstitialAd(params) {
|
|
600
|
+
if (!loadAdMobInterstitialAd.isSupported()) {
|
|
601
|
+
params.onError(new Error(UNSUPPORTED_ERROR_MESSAGE));
|
|
602
|
+
return noop;
|
|
603
|
+
}
|
|
604
|
+
const { onEvent, onError, options } = params;
|
|
605
|
+
const unregisterCallbacks = INTERNAL__appBridgeHandler.invokeAppBridgeMethod("loadAdMobInterstitialAd", options, {
|
|
606
|
+
onAdClicked: () => {
|
|
607
|
+
onEvent({ type: "clicked" });
|
|
608
|
+
},
|
|
609
|
+
onAdDismissed: () => {
|
|
610
|
+
onEvent({ type: "dismissed" });
|
|
611
|
+
},
|
|
612
|
+
onAdFailedToShow: () => {
|
|
613
|
+
onEvent({ type: "failedToShow" });
|
|
614
|
+
},
|
|
615
|
+
onAdImpression: () => {
|
|
616
|
+
onEvent({ type: "impression" });
|
|
617
|
+
},
|
|
618
|
+
onAdShow: () => {
|
|
619
|
+
onEvent({ type: "show" });
|
|
620
|
+
},
|
|
621
|
+
onSuccess: (result) => onEvent({ type: "loaded", data: result }),
|
|
622
|
+
onError
|
|
623
|
+
});
|
|
624
|
+
return unregisterCallbacks;
|
|
625
|
+
}
|
|
626
|
+
function showAdMobInterstitialAd(params) {
|
|
627
|
+
if (!showAdMobInterstitialAd.isSupported()) {
|
|
628
|
+
params.onError(new Error(UNSUPPORTED_ERROR_MESSAGE));
|
|
629
|
+
return noop;
|
|
630
|
+
}
|
|
631
|
+
const { onEvent, onError, options } = params;
|
|
632
|
+
const unregisterCallbacks = INTERNAL__appBridgeHandler.invokeAppBridgeMethod("showAdMobInterstitialAd", options, {
|
|
633
|
+
onSuccess: () => onEvent({ type: "requested" }),
|
|
634
|
+
onError
|
|
635
|
+
});
|
|
636
|
+
return unregisterCallbacks;
|
|
637
|
+
}
|
|
638
|
+
function loadAdMobRewardedAd(params) {
|
|
639
|
+
if (!loadAdMobRewardedAd.isSupported()) {
|
|
640
|
+
params.onError(new Error(UNSUPPORTED_ERROR_MESSAGE));
|
|
641
|
+
return noop;
|
|
642
|
+
}
|
|
643
|
+
const { onEvent, onError, options } = params;
|
|
644
|
+
const unregisterCallbacks = INTERNAL__appBridgeHandler.invokeAppBridgeMethod("loadAdMobRewardedAd", options, {
|
|
645
|
+
onAdClicked: () => {
|
|
646
|
+
onEvent({ type: "clicked" });
|
|
647
|
+
},
|
|
648
|
+
onAdDismissed: () => {
|
|
649
|
+
onEvent({ type: "dismissed" });
|
|
650
|
+
},
|
|
651
|
+
onAdFailedToShow: () => {
|
|
652
|
+
onEvent({ type: "failedToShow" });
|
|
653
|
+
},
|
|
654
|
+
onAdImpression: () => {
|
|
655
|
+
onEvent({ type: "impression" });
|
|
656
|
+
},
|
|
657
|
+
onAdShow: () => {
|
|
658
|
+
onEvent({ type: "show" });
|
|
659
|
+
},
|
|
660
|
+
onUserEarnedReward: () => {
|
|
661
|
+
onEvent({ type: "userEarnedReward" });
|
|
662
|
+
},
|
|
663
|
+
onSuccess: (result) => onEvent({ type: "loaded", data: result }),
|
|
664
|
+
onError
|
|
665
|
+
});
|
|
666
|
+
return unregisterCallbacks;
|
|
667
|
+
}
|
|
668
|
+
function showAdMobRewardedAd(params) {
|
|
669
|
+
if (!showAdMobRewardedAd.isSupported()) {
|
|
670
|
+
params.onError(new Error(UNSUPPORTED_ERROR_MESSAGE));
|
|
671
|
+
return noop;
|
|
672
|
+
}
|
|
673
|
+
const { onEvent, onError, options } = params;
|
|
674
|
+
const unregisterCallbacks = INTERNAL__appBridgeHandler.invokeAppBridgeMethod("showAdMobRewardedAd", options, {
|
|
675
|
+
onSuccess: () => onEvent({ type: "requested" }),
|
|
676
|
+
onError
|
|
677
|
+
});
|
|
678
|
+
return unregisterCallbacks;
|
|
679
|
+
}
|
|
680
|
+
var ANDROID_GOOGLE_AD_MOB_SUPPORTED_VERSION = "5.209.0";
|
|
681
|
+
var IOS_GOOGLE_AD_MOB_SUPPORTED_VERSION = "5.209.0";
|
|
682
|
+
var UNSUPPORTED_ERROR_MESSAGE = "This feature is not supported in the current environment";
|
|
683
|
+
var ENVIRONMENT = getOperationalEnvironment();
|
|
684
|
+
function createIsSupported() {
|
|
685
|
+
return () => {
|
|
686
|
+
if (ENVIRONMENT !== "toss") {
|
|
687
|
+
console.warn("Google AdMob is not supported in the current environment");
|
|
688
|
+
return false;
|
|
689
|
+
}
|
|
690
|
+
return isMinVersionSupported({
|
|
691
|
+
android: ANDROID_GOOGLE_AD_MOB_SUPPORTED_VERSION,
|
|
692
|
+
ios: IOS_GOOGLE_AD_MOB_SUPPORTED_VERSION
|
|
693
|
+
});
|
|
694
|
+
};
|
|
695
|
+
}
|
|
696
|
+
loadAdMobInterstitialAd.isSupported = createIsSupported();
|
|
697
|
+
loadAdMobRewardedAd.isSupported = createIsSupported();
|
|
698
|
+
showAdMobInterstitialAd.isSupported = createIsSupported();
|
|
699
|
+
showAdMobRewardedAd.isSupported = createIsSupported();
|
|
700
|
+
|
|
701
|
+
// src/native-modules/getTossAppVersion.ts
|
|
702
|
+
function getTossAppVersion() {
|
|
703
|
+
return AppsInTossModule.tossAppVersion;
|
|
704
|
+
}
|
|
705
|
+
|
|
706
|
+
// src/native-modules/getDeviceId.ts
|
|
707
|
+
function getDeviceId() {
|
|
708
|
+
return AppsInTossModule.deviceId;
|
|
709
|
+
}
|
|
710
|
+
|
|
711
|
+
// src/native-modules/storage.ts
|
|
712
|
+
function getItem(key) {
|
|
713
|
+
return AppsInTossModule.getStorageItem({ key });
|
|
714
|
+
}
|
|
715
|
+
function setItem(key, value) {
|
|
716
|
+
return AppsInTossModule.setStorageItem({
|
|
717
|
+
key,
|
|
718
|
+
value
|
|
719
|
+
});
|
|
720
|
+
}
|
|
721
|
+
function removeItem(key) {
|
|
722
|
+
return AppsInTossModule.removeStorageItem({ key });
|
|
723
|
+
}
|
|
724
|
+
function clearItems() {
|
|
725
|
+
return AppsInTossModule.clearStorage({});
|
|
726
|
+
}
|
|
727
|
+
var Storage = {
|
|
728
|
+
getItem,
|
|
729
|
+
setItem,
|
|
730
|
+
removeItem,
|
|
731
|
+
clearItems
|
|
732
|
+
};
|
|
733
|
+
|
|
734
|
+
// src/native-modules/index.ts
|
|
735
|
+
var TossPay = {
|
|
736
|
+
checkoutPayment
|
|
737
|
+
};
|
|
738
|
+
var GoogleAdMob = {
|
|
739
|
+
loadAdMobInterstitialAd,
|
|
740
|
+
showAdMobInterstitialAd,
|
|
741
|
+
loadAdMobRewardedAd,
|
|
742
|
+
showAdMobRewardedAd
|
|
743
|
+
};
|
|
744
|
+
|
|
687
745
|
// src/components/WebView.tsx
|
|
688
746
|
import {
|
|
689
747
|
PartnerWebViewScreen,
|
|
690
748
|
ExternalWebViewScreen
|
|
691
749
|
} from "@toss-design-system/react-native";
|
|
692
750
|
import { useSafeAreaBottom, useSafeAreaTop as useSafeAreaTop2 } from "@toss-design-system/react-native/private";
|
|
693
|
-
import { useMemo as useMemo3 } from "react";
|
|
694
|
-
import { getSchemeUri as
|
|
751
|
+
import { useCallback as useCallback3, useMemo as useMemo3 } from "react";
|
|
752
|
+
import { getSchemeUri as getSchemeUri4, useBedrockEvent } from "react-native-bedrock";
|
|
695
753
|
import * as bedrockAsyncBridges from "react-native-bedrock/async-bridges";
|
|
696
754
|
import * as bedrockConstantBridges from "react-native-bedrock/constant-bridges";
|
|
697
755
|
|
|
@@ -842,21 +900,6 @@ var GameWebView = forwardRef(function GameWebView2(props, ref) {
|
|
|
842
900
|
] });
|
|
843
901
|
});
|
|
844
902
|
|
|
845
|
-
// src/async-bridges.ts
|
|
846
|
-
var async_bridges_exports = {};
|
|
847
|
-
__export(async_bridges_exports, {
|
|
848
|
-
appLogin: () => appLogin,
|
|
849
|
-
checkoutPayment: () => checkoutPayment,
|
|
850
|
-
eventLog: () => eventLog,
|
|
851
|
-
fetchAlbumPhotos: () => fetchAlbumPhotos,
|
|
852
|
-
fetchContacts: () => fetchContacts,
|
|
853
|
-
getClipboardText: () => getClipboardText,
|
|
854
|
-
getCurrentLocation: () => getCurrentLocation,
|
|
855
|
-
getTossShareLink: () => getTossShareLink,
|
|
856
|
-
openCamera: () => openCamera,
|
|
857
|
-
setClipboardText: () => setClipboardText
|
|
858
|
-
});
|
|
859
|
-
|
|
860
903
|
// src/bridge-handler/useBridgeHandler.tsx
|
|
861
904
|
import { useCallback as useCallback2, useMemo as useMemo2, useRef } from "react";
|
|
862
905
|
function serializeError(error) {
|
|
@@ -998,6 +1041,54 @@ __export(event_bridges_exports, {
|
|
|
998
1041
|
startUpdateLocation: () => startUpdateLocation
|
|
999
1042
|
});
|
|
1000
1043
|
|
|
1044
|
+
// src/utils/log.ts
|
|
1045
|
+
import { getSchemeUri as getSchemeUri3 } from "react-native-bedrock";
|
|
1046
|
+
|
|
1047
|
+
// src/utils/extractDateFromUUIDv7.ts
|
|
1048
|
+
var extractDateFromUUIDv7 = (uuid) => {
|
|
1049
|
+
const timestampHex = uuid.split("-").join("").slice(0, 12);
|
|
1050
|
+
const timestamp = Number.parseInt(timestampHex, 16);
|
|
1051
|
+
return new Date(timestamp);
|
|
1052
|
+
};
|
|
1053
|
+
|
|
1054
|
+
// src/utils/log.ts
|
|
1055
|
+
var getGroupId = (url) => {
|
|
1056
|
+
try {
|
|
1057
|
+
const urlObject = new URL(url);
|
|
1058
|
+
return {
|
|
1059
|
+
groupId: urlObject.pathname,
|
|
1060
|
+
search: urlObject.search.startsWith("?") ? urlObject.search.substring(1) : urlObject.search
|
|
1061
|
+
};
|
|
1062
|
+
} catch {
|
|
1063
|
+
return {
|
|
1064
|
+
groupId: "unknown",
|
|
1065
|
+
search: "unknown"
|
|
1066
|
+
};
|
|
1067
|
+
}
|
|
1068
|
+
};
|
|
1069
|
+
var getReferrer = () => {
|
|
1070
|
+
try {
|
|
1071
|
+
const referrer = new URL(getSchemeUri3());
|
|
1072
|
+
return referrer.searchParams.get("referrer");
|
|
1073
|
+
} catch {
|
|
1074
|
+
return "";
|
|
1075
|
+
}
|
|
1076
|
+
};
|
|
1077
|
+
var trackScreen = (url) => {
|
|
1078
|
+
const { groupId, search } = getGroupId(url);
|
|
1079
|
+
const log = {
|
|
1080
|
+
log_type: "screen",
|
|
1081
|
+
log_name: `${groupId}::screen`,
|
|
1082
|
+
params: {
|
|
1083
|
+
search,
|
|
1084
|
+
referrer: getReferrer(),
|
|
1085
|
+
deployment_id: env.getDeploymentId(),
|
|
1086
|
+
deployment_timestamp: extractDateFromUUIDv7(env.getDeploymentId()).getTime()
|
|
1087
|
+
}
|
|
1088
|
+
};
|
|
1089
|
+
return eventLog(log);
|
|
1090
|
+
};
|
|
1091
|
+
|
|
1001
1092
|
// src/components/WebView.tsx
|
|
1002
1093
|
import { jsx as jsx5 } from "react/jsx-runtime";
|
|
1003
1094
|
var appsInTossGlobals = getAppsInTossGlobals();
|
|
@@ -1010,7 +1101,7 @@ var WEBVIEW_TYPES = {
|
|
|
1010
1101
|
};
|
|
1011
1102
|
function mergeSchemeQueryParamsInto(url) {
|
|
1012
1103
|
const baseUrl = new URL(url);
|
|
1013
|
-
const schemeUrl = new URL(
|
|
1104
|
+
const schemeUrl = new URL(getSchemeUri4());
|
|
1014
1105
|
baseUrl.pathname = schemeUrl.pathname;
|
|
1015
1106
|
for (const [key, value] of schemeUrl.searchParams.entries()) {
|
|
1016
1107
|
baseUrl.searchParams.set(key, value);
|
|
@@ -1065,7 +1156,9 @@ function WebView({ type, local, onMessage, ...props }) {
|
|
|
1065
1156
|
loadAdMobInterstitialAd_isSupported: GoogleAdMob.loadAdMobInterstitialAd.isSupported,
|
|
1066
1157
|
showAdMobInterstitialAd_isSupported: GoogleAdMob.showAdMobInterstitialAd.isSupported,
|
|
1067
1158
|
loadAdMobRewardedAd_isSupported: GoogleAdMob.loadAdMobRewardedAd.isSupported,
|
|
1068
|
-
showAdMobRewardedAd_isSupported: GoogleAdMob.showAdMobRewardedAd.isSupported
|
|
1159
|
+
showAdMobRewardedAd_isSupported: GoogleAdMob.showAdMobRewardedAd.isSupported,
|
|
1160
|
+
/** env */
|
|
1161
|
+
getDeploymentId: env.getDeploymentId
|
|
1069
1162
|
},
|
|
1070
1163
|
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
1071
1164
|
// @ts-expect-error
|
|
@@ -1112,6 +1205,11 @@ function WebView({ type, local, onMessage, ...props }) {
|
|
|
1112
1205
|
}, [type, props]);
|
|
1113
1206
|
const BaseWebView = WEBVIEW_TYPES[type];
|
|
1114
1207
|
const webViewDebuggingEnabled = operationalEnvironment === "sandbox";
|
|
1208
|
+
const handleNavigationStateChange = useCallback3((event) => {
|
|
1209
|
+
if (event.url) {
|
|
1210
|
+
trackScreen(event.url);
|
|
1211
|
+
}
|
|
1212
|
+
}, []);
|
|
1115
1213
|
return /* @__PURE__ */ jsx5(
|
|
1116
1214
|
BaseWebView,
|
|
1117
1215
|
{
|
|
@@ -1123,6 +1221,7 @@ function WebView({ type, local, onMessage, ...props }) {
|
|
|
1123
1221
|
webviewDebuggingEnabled: webViewDebuggingEnabled,
|
|
1124
1222
|
thirdPartyCookiesEnabled: true,
|
|
1125
1223
|
onMessage: handler.onMessage,
|
|
1224
|
+
onNavigationStateChange: handleNavigationStateChange,
|
|
1126
1225
|
injectedJavaScript: handler.injectedJavaScript,
|
|
1127
1226
|
injectedJavaScriptBeforeContentLoaded: handler.injectedJavaScript
|
|
1128
1227
|
}
|
|
@@ -1168,8 +1267,18 @@ var Accuracy2 = /* @__PURE__ */ ((Accuracy3) => {
|
|
|
1168
1267
|
Accuracy3[Accuracy3["BestForNavigation"] = 6] = "BestForNavigation";
|
|
1169
1268
|
return Accuracy3;
|
|
1170
1269
|
})(Accuracy2 || {});
|
|
1270
|
+
|
|
1271
|
+
// src/index.ts
|
|
1272
|
+
export * from "@apps-in-toss/analytics";
|
|
1273
|
+
var Analytics2 = {
|
|
1274
|
+
init: InternalAnalytics.init,
|
|
1275
|
+
Impression: InternalAnalytics.Impression,
|
|
1276
|
+
Press: InternalAnalytics.Press,
|
|
1277
|
+
Area: InternalAnalytics.Area
|
|
1278
|
+
};
|
|
1171
1279
|
export {
|
|
1172
1280
|
Accuracy2 as Accuracy,
|
|
1281
|
+
Analytics2 as Analytics,
|
|
1173
1282
|
AppsInToss,
|
|
1174
1283
|
GoogleAdMob,
|
|
1175
1284
|
Storage,
|