@apps-in-toss/framework 0.0.23 → 0.0.25

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 CHANGED
@@ -17,6 +17,7 @@ var __copyProps = (to, from, except, desc) => {
17
17
  }
18
18
  return to;
19
19
  };
20
+ var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
20
21
  var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
22
  // If the importer is in node compatibility mode or this is not an ESM
22
23
  // file that has been converted to a CommonJS file using a Babel-
@@ -31,6 +32,7 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
31
32
  var src_exports = {};
32
33
  __export(src_exports, {
33
34
  Accuracy: () => Accuracy2,
35
+ Analytics: () => Analytics2,
34
36
  AppsInToss: () => AppsInToss,
35
37
  GoogleAdMob: () => GoogleAdMob,
36
38
  Storage: () => Storage,
@@ -55,77 +57,30 @@ __export(src_exports, {
55
57
  useGeolocation: () => useGeolocation
56
58
  });
57
59
  module.exports = __toCommonJS(src_exports);
60
+ var import_analytics2 = require("@apps-in-toss/analytics");
58
61
 
59
62
  // src/core/registerApp.tsx
60
- var import_react_native5 = require("@toss-design-system/react-native");
63
+ var import_analytics = require("@apps-in-toss/analytics");
64
+ var import_react_native6 = require("@toss-design-system/react-native");
61
65
  var import_react_native_bedrock7 = require("react-native-bedrock");
62
66
 
63
67
  // src/core/components/AppEvent.tsx
64
68
  var import_react2 = require("react");
65
- var import_react_native_bedrock6 = require("react-native-bedrock");
69
+ var import_react_native_bedrock2 = require("react-native-bedrock");
66
70
 
67
- // ../../.yarn/cache/es-toolkit-npm-1.34.1-4cd6371dcb-aab6d07be3.zip/node_modules/es-toolkit/dist/function/noop.mjs
68
- function noop() {
69
- }
71
+ // src/env.ts
72
+ var env = {
73
+ getDeploymentId: () => __DEV__ ? "local" : global.__appsInToss?.deploymentId
74
+ };
75
+
76
+ // src/native-modules/tossCore.ts
77
+ var import_react_native3 = require("react-native");
70
78
 
71
79
  // src/native-modules/AppsInTossModule.ts
72
80
  var import_react_native = require("react-native");
73
81
  var AppsInTossModuleInstance = import_react_native.NativeModules.AppsInTossModule;
74
82
  var AppsInTossModule = AppsInTossModuleInstance;
75
83
 
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);
79
- }
80
-
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);
87
- }
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
94
- });
95
- void promise.then(onSuccess).catch(onError);
96
- return unregisterAll;
97
- }
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;
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);
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
- };
128
-
129
84
  // src/native-modules/getOperationalEnvironment.ts
130
85
  function getOperationalEnvironment() {
131
86
  return AppsInTossModule.operationalEnvironment;
@@ -222,113 +177,104 @@ function isMinVersionSupported(minVersions) {
222
177
  return compareVersions(currentVersion, minVersion) >= 0;
223
178
  }
224
179
 
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;
180
+ // src/native-modules/tossCore.ts
181
+ var TossCoreModule = import_react_native3.NativeModules.TossCoreModule;
182
+ function tossCoreEventLog(params) {
183
+ const supported = isMinVersionSupported({ ios: "5.210.0", android: "5.210.0" });
184
+ const isSandbox = getOperationalEnvironment() === "sandbox";
185
+ if (!supported || isSandbox) {
186
+ return;
230
187
  }
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
188
+ TossCoreModule.eventLog({
189
+ params: {
190
+ log_name: params.log_name,
191
+ log_type: params.log_type,
192
+ params: params.params
193
+ }
250
194
  });
251
- return unregisterCallbacks;
252
195
  }
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;
196
+
197
+ // src/core/hooks/useReferrer.ts
198
+ var import_react = require("react");
199
+ var import_react_native_bedrock = require("react-native-bedrock");
200
+ function useReferrer() {
201
+ return (0, import_react.useMemo)(() => {
202
+ try {
203
+ return new URL((0, import_react_native_bedrock.getSchemeUri)()).searchParams.get("referrer");
204
+ } catch {
205
+ return null;
206
+ }
207
+ }, []);
264
208
  }
265
- function loadAdMobRewardedAd(params) {
266
- if (!loadAdMobRewardedAd.isSupported()) {
267
- params.onError(new Error(UNSUPPORTED_ERROR_MESSAGE));
268
- return noop;
209
+
210
+ // src/core/components/AppEvent.tsx
211
+ var ENTRY_APP_EVENT_SCHEMA_ID = 1562181;
212
+ function isPrivateScheme() {
213
+ try {
214
+ return new URL((0, import_react_native_bedrock2.getSchemeUri)()).protocol === "intoss-private:";
215
+ } catch {
216
+ return false;
269
217
  }
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
218
  }
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;
219
+ function EntryAppEvent() {
220
+ const referrer = useReferrer() ?? "";
221
+ (0, import_react2.useEffect)(() => {
222
+ tossCoreEventLog({
223
+ log_name: "appsintoss_app_visit::impression__enter_appsintoss",
224
+ log_type: "info",
225
+ params: {
226
+ is_transform: true,
227
+ schema_id: ENTRY_APP_EVENT_SCHEMA_ID,
228
+ referrer,
229
+ deployment_id: env.getDeploymentId(),
230
+ app_name: import_react_native_bedrock2.Bedrock.appName,
231
+ is_private: isPrivateScheme()
232
+ }
233
+ });
234
+ }, [referrer]);
235
+ return null;
306
236
  }
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
237
+ function SystemAppEvent({ ...initialProps }) {
238
+ (0, import_react2.useEffect)(() => {
239
+ tossCoreEventLog({
240
+ log_name: "AppsInTossInitialProps",
241
+ log_type: "debug",
242
+ params: {
243
+ ...initialProps,
244
+ schemeUri: (0, import_react_native_bedrock2.getSchemeUri)(),
245
+ deployment_id: env.getDeploymentId(),
246
+ app_name: import_react_native_bedrock2.Bedrock.appName,
247
+ is_private: isPrivateScheme()
248
+ }
320
249
  });
321
- };
250
+ }, [initialProps]);
251
+ return null;
322
252
  }
323
- loadAdMobInterstitialAd.isSupported = createIsSupported();
324
- loadAdMobRewardedAd.isSupported = createIsSupported();
325
- showAdMobInterstitialAd.isSupported = createIsSupported();
326
- showAdMobRewardedAd.isSupported = createIsSupported();
253
+ var AppEvent = {
254
+ Entry: EntryAppEvent,
255
+ System: SystemAppEvent
256
+ };
327
257
 
328
- // src/native-modules/checkoutPayment.ts
329
- async function checkoutPayment(options) {
330
- return AppsInTossModule.checkoutPayment({ params: options });
331
- }
258
+ // src/core/hooks/useAppsInTossBridge.ts
259
+ var import_react_native5 = require("@toss-design-system/react-native");
260
+ var import_react3 = require("react");
261
+
262
+ // src/native-event-emitter/appsInTossEvent.ts
263
+ var import_react_native_bedrock6 = require("react-native-bedrock");
264
+
265
+ // src/native-event-emitter/event-plugins/EntryMessageExitedEvent.ts
266
+ var import_react_native_bedrock3 = require("react-native-bedrock");
267
+ var EntryMessageExitedEvent = class extends import_react_native_bedrock3.BedrockEventDefinition {
268
+ name = "entryMessageExited";
269
+ remove() {
270
+ }
271
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
272
+ listener(_) {
273
+ }
274
+ };
275
+
276
+ // src/native-event-emitter/event-plugins/UpdateLocationEvent.ts
277
+ var import_react_native_bedrock4 = require("react-native-bedrock");
332
278
 
333
279
  // src/native-modules/getPermission.ts
334
280
  function getPermission(permission) {
@@ -352,201 +298,21 @@ async function requestPermission(permission) {
352
298
  }
353
299
  }
354
300
 
355
- // src/native-modules/setClipboardText.ts
356
- async function setClipboardText(text) {
357
- const permissionStatus = await requestPermission({ name: "clipboard", access: "write" });
358
- if (permissionStatus === "denied") {
359
- throw new Error("\uD074\uB9BD\uBCF4\uB4DC \uC4F0\uAE30 \uAD8C\uD55C\uC774 \uAC70\uBD80\uB418\uC5C8\uC5B4\uC694.");
360
- }
361
- return AppsInTossModule.setClipboardText({ text });
362
- }
301
+ // src/native-event-emitter/nativeEventEmitter.ts
302
+ var import_react_native4 = require("react-native");
303
+ var nativeEventEmitter = new import_react_native4.NativeEventEmitter(AppsInTossModuleInstance);
363
304
 
364
- // src/native-modules/getClipboardText.ts
365
- async function getClipboardText() {
366
- const permissionStatus = await requestPermission({ name: "clipboard", access: "read" });
367
- if (permissionStatus === "denied") {
368
- throw new Error("\uD074\uB9BD\uBCF4\uB4DC \uC77D\uAE30 \uAD8C\uD55C\uC774 \uAC70\uBD80\uB418\uC5C8\uC5B4\uC694.");
369
- }
370
- return AppsInTossModule.getClipboardText({});
371
- }
372
-
373
- // src/native-modules/fetchContacts.ts
374
- async function fetchContacts({
375
- size,
376
- offset,
377
- query
378
- }) {
379
- const permissionStatus = await requestPermission({ name: "contacts", access: "read" });
380
- if (permissionStatus === "denied") {
381
- throw new Error("\uC5F0\uB77D\uCC98 \uAD8C\uD55C\uC774 \uAC70\uBD80\uB418\uC5C8\uC5B4\uC694.");
382
- }
383
- const contacts = await AppsInTossModule.fetchContacts({
384
- size,
385
- offset,
386
- query
387
- });
388
- return {
389
- result: contacts.result,
390
- nextOffset: contacts.nextOffset ?? null,
391
- done: contacts.done
392
- };
393
- }
394
-
395
- // src/native-modules/fetchAlbumPhotos.ts
396
- var DEFAULT_MAX_COUNT = 10;
397
- var DEFAULT_MAX_WIDTH = 1024;
398
- async function fetchAlbumPhotos(options) {
399
- const permissionStatus = await requestPermission({ name: "photos", access: "read" });
400
- if (permissionStatus === "denied") {
401
- throw new Error("\uC0AC\uC9C4\uCCA9 \uAD8C\uD55C\uC774 \uAC70\uBD80\uB418\uC5C8\uC5B4\uC694.");
402
- }
403
- const albumPhotos = await AppsInTossModule.fetchAlbumPhotos({
404
- ...options,
405
- maxCount: options.maxCount ?? DEFAULT_MAX_COUNT,
406
- maxWidth: options.maxWidth ?? DEFAULT_MAX_WIDTH
407
- });
408
- return albumPhotos;
409
- }
410
-
411
- // src/native-modules/getCurrentLocation.ts
412
- async function getCurrentLocation(options) {
413
- const permissionStatus = await requestPermission({ name: "geolocation", access: "access" });
414
- if (permissionStatus === "denied") {
415
- throw new Error("\uC704\uCE58 \uAD8C\uD55C\uC774 \uAC70\uBD80\uB418\uC5C8\uC5B4\uC694.");
416
- }
417
- const position = await AppsInTossModule.getCurrentLocation(options);
418
- return position;
419
- }
420
-
421
- // src/native-modules/openCamera.ts
422
- async function openCamera(options) {
423
- const permissionStatus = await requestPermission({ name: "camera", access: "access" });
424
- if (permissionStatus === "denied") {
425
- throw new Error("\uCE74\uBA54\uB77C \uAD8C\uD55C\uC774 \uAC70\uBD80\uB418\uC5C8\uC5B4\uC694.");
426
- }
427
- const photo = await AppsInTossModule.openCamera({ base64: false, maxWidth: 1024, ...options });
428
- return photo;
429
- }
430
-
431
- // src/native-modules/appLogin.ts
432
- async function appLogin() {
433
- return AppsInTossModule.appLogin({});
434
- }
435
-
436
- // src/native-modules/getTossAppVersion.ts
437
- function getTossAppVersion() {
438
- return AppsInTossModule.tossAppVersion;
439
- }
440
-
441
- // src/native-modules/getDeviceId.ts
442
- function getDeviceId() {
443
- return AppsInTossModule.deviceId;
444
- }
445
-
446
- // src/native-modules/storage.ts
447
- function getItem(key) {
448
- return AppsInTossModule.getStorageItem({ key });
449
- }
450
- function setItem(key, value) {
451
- return AppsInTossModule.setStorageItem({
452
- key,
453
- value
454
- });
455
- }
456
- function removeItem(key) {
457
- return AppsInTossModule.removeStorageItem({ key });
458
- }
459
- function clearItems() {
460
- return AppsInTossModule.clearStorage({});
461
- }
462
- var Storage = {
463
- getItem,
464
- setItem,
465
- removeItem,
466
- clearItems
467
- };
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
-
507
- // src/native-modules/index.ts
508
- var TossPay = {
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();
305
+ // src/native-event-emitter/event-plugins/UpdateLocationEvent.ts
306
+ var UpdateLocationEvent = class extends import_react_native_bedrock4.BedrockEventDefinition {
307
+ name = "updateLocationEvent";
308
+ subscriptionCount = 0;
309
+ ref = {
310
+ remove: () => {
311
+ }
312
+ };
313
+ remove() {
314
+ --this.subscriptionCount === 0 && AppsInTossModuleInstance.stopUpdateLocation({});
315
+ this.ref.remove();
550
316
  }
551
317
  listener(options, onEvent, onError) {
552
318
  requestPermission({ name: "geolocation", access: "access" }).then((permissionStatus) => {
@@ -565,9 +331,64 @@ var UpdateLocationEvent = class extends import_react_native_bedrock2.BedrockEven
565
331
  };
566
332
 
567
333
  // src/native-event-emitter/internal/AppBridgeCallbackEvent.ts
568
- var import_react_native_bedrock3 = require("react-native-bedrock");
334
+ var import_react_native_bedrock5 = require("react-native-bedrock");
335
+
336
+ // src/utils/generateUUID.ts
337
+ function generateUUID(placeholder) {
338
+ return placeholder ? (placeholder ^ Math.random() * 16 >> placeholder / 4).toString(16) : (String(1e7) + 1e3 + 4e3 + 8e3 + 1e11).replace(/[018]/g, generateUUID);
339
+ }
340
+
341
+ // src/native-event-emitter/internal/appBridge.ts
342
+ var INTERNAL__callbacks = /* @__PURE__ */ new Map();
343
+ function invokeAppBridgeCallback(id, ...args) {
344
+ const callback = INTERNAL__callbacks.get(id);
345
+ callback?.call(null, ...args);
346
+ return Boolean(callback);
347
+ }
348
+ function invokeAppBridgeMethod(methodName, params, callbacks) {
349
+ const { onSuccess, onError, ...appBridgeCallbacks } = callbacks;
350
+ const { callbackMap, unregisterAll } = registerCallbacks(appBridgeCallbacks);
351
+ const promise = AppsInTossModuleInstance[methodName]({
352
+ params,
353
+ callbacks: callbackMap
354
+ });
355
+ void promise.then(onSuccess).catch(onError);
356
+ return unregisterAll;
357
+ }
358
+ function registerCallbacks(callbacks) {
359
+ const callbackMap = {};
360
+ for (const [callbackName, callback] of Object.entries(callbacks)) {
361
+ const id = registerCallback(callback, callbackName);
362
+ callbackMap[callbackName] = id;
363
+ }
364
+ const unregisterAll = () => {
365
+ Object.values(callbackMap).forEach(unregisterCallback);
366
+ };
367
+ return { callbackMap, unregisterAll };
368
+ }
369
+ function registerCallback(callback, name = "unnamed") {
370
+ const uniqueId = generateUUID();
371
+ const callbackId = `${uniqueId}__${name}`;
372
+ INTERNAL__callbacks.set(callbackId, callback);
373
+ return callbackId;
374
+ }
375
+ function unregisterCallback(id) {
376
+ INTERNAL__callbacks.delete(id);
377
+ }
378
+ function getCallbackIds() {
379
+ return Array.from(INTERNAL__callbacks.keys());
380
+ }
381
+ var INTERNAL__appBridgeHandler = {
382
+ invokeAppBridgeCallback,
383
+ invokeAppBridgeMethod,
384
+ registerCallback,
385
+ unregisterCallback,
386
+ getCallbackIds
387
+ };
388
+
389
+ // src/native-event-emitter/internal/AppBridgeCallbackEvent.ts
569
390
  var UNSAFE__nativeEventEmitter = nativeEventEmitter;
570
- var AppBridgeCallbackEvent = class _AppBridgeCallbackEvent extends import_react_native_bedrock3.BedrockEventDefinition {
391
+ var AppBridgeCallbackEvent = class _AppBridgeCallbackEvent extends import_react_native_bedrock5.BedrockEventDefinition {
571
392
  static INTERNAL__appBridgeSubscription;
572
393
  name = "appBridgeCallbackEvent";
573
394
  constructor() {
@@ -597,107 +418,182 @@ var AppBridgeCallbackEvent = class _AppBridgeCallbackEvent extends import_react_
597
418
  };
598
419
 
599
420
  // src/native-event-emitter/appsInTossEvent.ts
600
- var appsInTossEvent = new import_react_native_bedrock4.BedrockEvent([
421
+ var appsInTossEvent = new import_react_native_bedrock6.BedrockEvent([
601
422
  new AppBridgeCallbackEvent(),
602
423
  new UpdateLocationEvent(),
603
424
  new EntryMessageExitedEvent()
604
425
  ]);
605
426
 
606
- // src/native-event-emitter/startUpdateLocation.ts
607
- function startUpdateLocation(eventParams) {
608
- return appsInTossEvent.addEventListener("updateLocationEvent", eventParams);
427
+ // src/core/utils/getAppsInTossGlobals.ts
428
+ function getAppsInTossGlobals() {
429
+ if (global.__appsInToss == null) {
430
+ throw new Error("invalid apps-in-toss globals");
431
+ }
432
+ return global.__appsInToss;
609
433
  }
610
434
 
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
- }, []);
435
+ // src/core/utils/toIcon.ts
436
+ function toIcon(source) {
437
+ return source.startsWith("http") ? { source: { uri: source } } : { name: source };
627
438
  }
628
439
 
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
440
+ // src/core/hooks/useAppsInTossBridge.ts
441
+ function useAppsInTossBridge() {
442
+ const controller = (0, import_react_native5.useBridge)();
443
+ const appsInTossGlobals2 = getAppsInTossGlobals();
444
+ (0, import_react3.useEffect)(() => {
445
+ const commonProps = {
446
+ serviceName: appsInTossGlobals2.brandDisplayName,
447
+ icon: toIcon(appsInTossGlobals2.brandIcon),
448
+ color: appsInTossGlobals2.brandPrimaryColor,
449
+ colorMode: appsInTossGlobals2.brandBridgeColorMode
450
+ };
451
+ controller.open({
452
+ ...commonProps,
453
+ onExited: () => {
454
+ appsInTossEvent.emit("entryMessageExited", void 0);
642
455
  }
643
456
  });
644
- }, [referrer]);
645
- return null;
457
+ }, []);
646
458
  }
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;
459
+
460
+ // src/async-bridges.ts
461
+ var async_bridges_exports = {};
462
+ __export(async_bridges_exports, {
463
+ appLogin: () => appLogin,
464
+ checkoutPayment: () => checkoutPayment,
465
+ eventLog: () => eventLog,
466
+ fetchAlbumPhotos: () => fetchAlbumPhotos,
467
+ fetchContacts: () => fetchContacts,
468
+ getClipboardText: () => getClipboardText,
469
+ getCurrentLocation: () => getCurrentLocation,
470
+ getTossShareLink: () => getTossShareLink,
471
+ openCamera: () => openCamera,
472
+ setClipboardText: () => setClipboardText
473
+ });
474
+
475
+ // src/native-modules/setClipboardText.ts
476
+ async function setClipboardText(text) {
477
+ const permissionStatus = await requestPermission({ name: "clipboard", access: "write" });
478
+ if (permissionStatus === "denied") {
479
+ throw new Error("\uD074\uB9BD\uBCF4\uB4DC \uC4F0\uAE30 \uAD8C\uD55C\uC774 \uAC70\uBD80\uB418\uC5C8\uC5B4\uC694.");
480
+ }
481
+ return AppsInTossModule.setClipboardText({ text });
660
482
  }
661
- var AppEvent = {
662
- Entry: EntryAppEvent,
663
- System: SystemAppEvent
664
- };
665
483
 
666
- // src/core/hooks/useAppsInTossBridge.ts
667
- var import_react_native4 = require("@toss-design-system/react-native");
668
- var import_react3 = require("react");
484
+ // src/native-modules/getClipboardText.ts
485
+ async function getClipboardText() {
486
+ const permissionStatus = await requestPermission({ name: "clipboard", access: "read" });
487
+ if (permissionStatus === "denied") {
488
+ throw new Error("\uD074\uB9BD\uBCF4\uB4DC \uC77D\uAE30 \uAD8C\uD55C\uC774 \uAC70\uBD80\uB418\uC5C8\uC5B4\uC694.");
489
+ }
490
+ return AppsInTossModule.getClipboardText({});
491
+ }
669
492
 
670
- // src/core/utils/getAppsInTossGlobals.ts
671
- function getAppsInTossGlobals() {
672
- if (global.__appsInToss == null) {
673
- throw new Error("invalid apps-in-toss globals");
493
+ // src/native-modules/fetchContacts.ts
494
+ async function fetchContacts({
495
+ size,
496
+ offset,
497
+ query
498
+ }) {
499
+ const permissionStatus = await requestPermission({ name: "contacts", access: "read" });
500
+ if (permissionStatus === "denied") {
501
+ throw new Error("\uC5F0\uB77D\uCC98 \uAD8C\uD55C\uC774 \uAC70\uBD80\uB418\uC5C8\uC5B4\uC694.");
674
502
  }
675
- return global.__appsInToss;
503
+ const contacts = await AppsInTossModule.fetchContacts({
504
+ size,
505
+ offset,
506
+ query
507
+ });
508
+ return {
509
+ result: contacts.result,
510
+ nextOffset: contacts.nextOffset ?? null,
511
+ done: contacts.done
512
+ };
513
+ }
514
+
515
+ // src/native-modules/fetchAlbumPhotos.ts
516
+ var DEFAULT_MAX_COUNT = 10;
517
+ var DEFAULT_MAX_WIDTH = 1024;
518
+ async function fetchAlbumPhotos(options) {
519
+ const permissionStatus = await requestPermission({ name: "photos", access: "read" });
520
+ if (permissionStatus === "denied") {
521
+ throw new Error("\uC0AC\uC9C4\uCCA9 \uAD8C\uD55C\uC774 \uAC70\uBD80\uB418\uC5C8\uC5B4\uC694.");
522
+ }
523
+ const albumPhotos = await AppsInTossModule.fetchAlbumPhotos({
524
+ ...options,
525
+ maxCount: options.maxCount ?? DEFAULT_MAX_COUNT,
526
+ maxWidth: options.maxWidth ?? DEFAULT_MAX_WIDTH
527
+ });
528
+ return albumPhotos;
529
+ }
530
+
531
+ // src/native-modules/getCurrentLocation.ts
532
+ async function getCurrentLocation(options) {
533
+ const permissionStatus = await requestPermission({ name: "geolocation", access: "access" });
534
+ if (permissionStatus === "denied") {
535
+ throw new Error("\uC704\uCE58 \uAD8C\uD55C\uC774 \uAC70\uBD80\uB418\uC5C8\uC5B4\uC694.");
536
+ }
537
+ const position = await AppsInTossModule.getCurrentLocation(options);
538
+ return position;
539
+ }
540
+
541
+ // src/native-modules/openCamera.ts
542
+ async function openCamera(options) {
543
+ const permissionStatus = await requestPermission({ name: "camera", access: "access" });
544
+ if (permissionStatus === "denied") {
545
+ throw new Error("\uCE74\uBA54\uB77C \uAD8C\uD55C\uC774 \uAC70\uBD80\uB418\uC5C8\uC5B4\uC694.");
546
+ }
547
+ const photo = await AppsInTossModule.openCamera({ base64: false, maxWidth: 1024, ...options });
548
+ return photo;
549
+ }
550
+
551
+ // src/native-modules/appLogin.ts
552
+ async function appLogin() {
553
+ return AppsInTossModule.appLogin({});
554
+ }
555
+
556
+ // src/native-modules/checkoutPayment.ts
557
+ async function checkoutPayment(options) {
558
+ return AppsInTossModule.checkoutPayment({ params: options });
676
559
  }
677
560
 
678
- // src/core/utils/toIcon.ts
679
- function toIcon(source) {
680
- return source.startsWith("http") ? { source: { uri: source } } : { name: source };
561
+ // src/native-modules/eventLog.ts
562
+ function normalizeParams(params) {
563
+ return Object.fromEntries(
564
+ Object.entries(params).filter(([, value]) => value !== void 0).map(([key, value]) => [key, String(value)])
565
+ );
681
566
  }
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
- }
567
+ async function eventLog(params) {
568
+ if (AppsInTossModule.operationalEnvironment === "sandbox") {
569
+ console.log("[eventLogDebug]", {
570
+ log_name: params.log_name,
571
+ log_type: params.log_type,
572
+ params: normalizeParams(params.params)
699
573
  });
700
- }, []);
574
+ return;
575
+ }
576
+ const isSupported = isMinVersionSupported({
577
+ android: "5.208.0",
578
+ ios: "5.208.0"
579
+ });
580
+ if (!isSupported) {
581
+ return;
582
+ }
583
+ return AppsInTossModule.eventLog({
584
+ log_name: params.log_name,
585
+ log_type: params.log_type,
586
+ params: normalizeParams(params.params)
587
+ });
588
+ }
589
+
590
+ // src/native-modules/getTossShareLink.ts
591
+ async function getTossShareLink(path) {
592
+ const { shareLink } = await AppsInTossModule.getTossShareLink({});
593
+ const shareUrl = new URL(shareLink);
594
+ shareUrl.searchParams.set("deep_link_value", path);
595
+ shareUrl.searchParams.set("af_dp", path);
596
+ return shareUrl.toString();
701
597
  }
702
598
 
703
599
  // src/core/registerApp.tsx
@@ -706,19 +602,26 @@ function AppsInTossContainer(Container, { children, ...initialProps }) {
706
602
  return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [
707
603
  /* @__PURE__ */ (0, import_jsx_runtime.jsx)(AppEvent.Entry, {}),
708
604
  /* @__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 }) }) })
605
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Container, { ...initialProps, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_react_native6.TDSProvider, { colorPreference: "light", token: { color: { primary: getAppsInTossGlobals().brandPrimaryColor } }, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(TDSContainer, { ...initialProps, children }) }) })
710
606
  ] });
711
607
  }
712
608
  function TDSContainer({ children }) {
713
609
  useAppsInTossBridge();
714
610
  return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_jsx_runtime.Fragment, { children });
715
611
  }
716
- function registerApp(container, { context }) {
612
+ function registerApp(container, { context, analytics }) {
613
+ import_analytics.Analytics.init({
614
+ logger: (params) => void eventLog(params),
615
+ debug: analytics?.debug ?? __DEV__
616
+ });
717
617
  return import_react_native_bedrock7.Bedrock.registerApp(AppsInTossContainer.bind(null, container), {
718
618
  appName: getAppName(),
719
619
  context,
720
- defaultScreenOption: {
721
- statusBarStyle: "dark"
620
+ router: {
621
+ screenContainer: import_analytics.Analytics.Screen,
622
+ defaultScreenOption: {
623
+ statusBarStyle: "dark"
624
+ }
722
625
  }
723
626
  });
724
627
  }
@@ -736,36 +639,192 @@ var AppsInToss = {
736
639
  registerApp
737
640
  };
738
641
 
642
+ // src/native-event-emitter/startUpdateLocation.ts
643
+ function startUpdateLocation(eventParams) {
644
+ return appsInTossEvent.addEventListener("updateLocationEvent", eventParams);
645
+ }
646
+
647
+ // ../../.yarn/cache/es-toolkit-npm-1.34.1-4cd6371dcb-aab6d07be3.zip/node_modules/es-toolkit/dist/function/noop.mjs
648
+ function noop() {
649
+ }
650
+
651
+ // src/native-modules/ads/googleAdMob.ts
652
+ function loadAdMobInterstitialAd(params) {
653
+ if (!loadAdMobInterstitialAd.isSupported()) {
654
+ params.onError(new Error(UNSUPPORTED_ERROR_MESSAGE));
655
+ return noop;
656
+ }
657
+ const { onEvent, onError, options } = params;
658
+ const unregisterCallbacks = INTERNAL__appBridgeHandler.invokeAppBridgeMethod("loadAdMobInterstitialAd", options, {
659
+ onAdClicked: () => {
660
+ onEvent({ type: "clicked" });
661
+ },
662
+ onAdDismissed: () => {
663
+ onEvent({ type: "dismissed" });
664
+ },
665
+ onAdFailedToShow: () => {
666
+ onEvent({ type: "failedToShow" });
667
+ },
668
+ onAdImpression: () => {
669
+ onEvent({ type: "impression" });
670
+ },
671
+ onAdShow: () => {
672
+ onEvent({ type: "show" });
673
+ },
674
+ onSuccess: (result) => onEvent({ type: "loaded", data: result }),
675
+ onError
676
+ });
677
+ return unregisterCallbacks;
678
+ }
679
+ function showAdMobInterstitialAd(params) {
680
+ if (!showAdMobInterstitialAd.isSupported()) {
681
+ params.onError(new Error(UNSUPPORTED_ERROR_MESSAGE));
682
+ return noop;
683
+ }
684
+ const { onEvent, onError, options } = params;
685
+ const unregisterCallbacks = INTERNAL__appBridgeHandler.invokeAppBridgeMethod("showAdMobInterstitialAd", options, {
686
+ onSuccess: () => onEvent({ type: "requested" }),
687
+ onError
688
+ });
689
+ return unregisterCallbacks;
690
+ }
691
+ function loadAdMobRewardedAd(params) {
692
+ if (!loadAdMobRewardedAd.isSupported()) {
693
+ params.onError(new Error(UNSUPPORTED_ERROR_MESSAGE));
694
+ return noop;
695
+ }
696
+ const { onEvent, onError, options } = params;
697
+ const unregisterCallbacks = INTERNAL__appBridgeHandler.invokeAppBridgeMethod("loadAdMobRewardedAd", options, {
698
+ onAdClicked: () => {
699
+ onEvent({ type: "clicked" });
700
+ },
701
+ onAdDismissed: () => {
702
+ onEvent({ type: "dismissed" });
703
+ },
704
+ onAdFailedToShow: () => {
705
+ onEvent({ type: "failedToShow" });
706
+ },
707
+ onAdImpression: () => {
708
+ onEvent({ type: "impression" });
709
+ },
710
+ onAdShow: () => {
711
+ onEvent({ type: "show" });
712
+ },
713
+ onUserEarnedReward: () => {
714
+ onEvent({ type: "userEarnedReward" });
715
+ },
716
+ onSuccess: (result) => onEvent({ type: "loaded", data: result }),
717
+ onError
718
+ });
719
+ return unregisterCallbacks;
720
+ }
721
+ function showAdMobRewardedAd(params) {
722
+ if (!showAdMobRewardedAd.isSupported()) {
723
+ params.onError(new Error(UNSUPPORTED_ERROR_MESSAGE));
724
+ return noop;
725
+ }
726
+ const { onEvent, onError, options } = params;
727
+ const unregisterCallbacks = INTERNAL__appBridgeHandler.invokeAppBridgeMethod("showAdMobRewardedAd", options, {
728
+ onSuccess: () => onEvent({ type: "requested" }),
729
+ onError
730
+ });
731
+ return unregisterCallbacks;
732
+ }
733
+ var ANDROID_GOOGLE_AD_MOB_SUPPORTED_VERSION = "5.209.0";
734
+ var IOS_GOOGLE_AD_MOB_SUPPORTED_VERSION = "5.209.0";
735
+ var UNSUPPORTED_ERROR_MESSAGE = "This feature is not supported in the current environment";
736
+ var ENVIRONMENT = getOperationalEnvironment();
737
+ function createIsSupported() {
738
+ return () => {
739
+ if (ENVIRONMENT !== "toss") {
740
+ console.warn("Google AdMob is not supported in the current environment");
741
+ return false;
742
+ }
743
+ return isMinVersionSupported({
744
+ android: ANDROID_GOOGLE_AD_MOB_SUPPORTED_VERSION,
745
+ ios: IOS_GOOGLE_AD_MOB_SUPPORTED_VERSION
746
+ });
747
+ };
748
+ }
749
+ loadAdMobInterstitialAd.isSupported = createIsSupported();
750
+ loadAdMobRewardedAd.isSupported = createIsSupported();
751
+ showAdMobInterstitialAd.isSupported = createIsSupported();
752
+ showAdMobRewardedAd.isSupported = createIsSupported();
753
+
754
+ // src/native-modules/getTossAppVersion.ts
755
+ function getTossAppVersion() {
756
+ return AppsInTossModule.tossAppVersion;
757
+ }
758
+
759
+ // src/native-modules/getDeviceId.ts
760
+ function getDeviceId() {
761
+ return AppsInTossModule.deviceId;
762
+ }
763
+
764
+ // src/native-modules/storage.ts
765
+ function getItem(key) {
766
+ return AppsInTossModule.getStorageItem({ key });
767
+ }
768
+ function setItem(key, value) {
769
+ return AppsInTossModule.setStorageItem({
770
+ key,
771
+ value
772
+ });
773
+ }
774
+ function removeItem(key) {
775
+ return AppsInTossModule.removeStorageItem({ key });
776
+ }
777
+ function clearItems() {
778
+ return AppsInTossModule.clearStorage({});
779
+ }
780
+ var Storage = {
781
+ getItem,
782
+ setItem,
783
+ removeItem,
784
+ clearItems
785
+ };
786
+
787
+ // src/native-modules/index.ts
788
+ var TossPay = {
789
+ checkoutPayment
790
+ };
791
+ var GoogleAdMob = {
792
+ loadAdMobInterstitialAd,
793
+ showAdMobInterstitialAd,
794
+ loadAdMobRewardedAd,
795
+ showAdMobRewardedAd
796
+ };
797
+
739
798
  // src/components/WebView.tsx
740
- var import_react_native13 = require("@toss-design-system/react-native");
799
+ var import_react_native14 = require("@toss-design-system/react-native");
741
800
  var import_private = require("@toss-design-system/react-native/private");
742
801
  var import_react6 = require("react");
743
- var import_react_native_bedrock9 = require("react-native-bedrock");
802
+ var import_react_native_bedrock10 = require("react-native-bedrock");
744
803
  var bedrockAsyncBridges = __toESM(require("react-native-bedrock/async-bridges"), 1);
745
804
  var bedrockConstantBridges = __toESM(require("react-native-bedrock/constant-bridges"), 1);
746
805
 
747
806
  // src/components/GameWebView.tsx
748
807
  var import_react_native_webview = require("@react-native-bedrock/native/react-native-webview");
749
- var import_react_native11 = require("@toss-design-system/react-native");
808
+ var import_react_native12 = require("@toss-design-system/react-native");
750
809
  var import_es_hangul = require("es-hangul");
751
810
  var import_react4 = require("react");
752
- var import_react_native12 = require("react-native");
811
+ var import_react_native13 = require("react-native");
753
812
  var import_react_native_bedrock8 = require("react-native-bedrock");
754
813
 
755
814
  // src/components/GameWebViewNavigationBar/GameNavigationBar.tsx
756
815
  var import_react_native_svg = require("@react-native-bedrock/native/react-native-svg");
757
- var import_react_native9 = require("@toss-design-system/react-native");
758
- var import_react_native10 = require("react-native");
816
+ var import_react_native10 = require("@toss-design-system/react-native");
817
+ var import_react_native11 = require("react-native");
759
818
 
760
819
  // src/components/GameWebViewNavigationBar/HeaderRight.tsx
761
- var import_react_native7 = require("react-native");
820
+ var import_react_native8 = require("react-native");
762
821
 
763
822
  // src/components/GameWebViewNavigationBar/byPlatform.ts
764
- var import_react_native6 = require("react-native");
823
+ var import_react_native7 = require("react-native");
765
824
  function byPlatform({
766
825
  ...props
767
826
  }) {
768
- return (props[import_react_native6.Platform.OS] ?? props.fallback)();
827
+ return (props[import_react_native7.Platform.OS] ?? props.fallback)();
769
828
  }
770
829
 
771
830
  // src/components/GameWebViewNavigationBar/constants.ts
@@ -775,10 +834,10 @@ var IOS_DEFAULT_MARGIN = 20;
775
834
  // src/components/GameWebViewNavigationBar/HeaderRight.tsx
776
835
  var import_jsx_runtime2 = require("react/jsx-runtime");
777
836
  function IOSHeaderRight(props) {
778
- return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_react_native7.View, { style: styles.ios, ...props });
837
+ return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_react_native8.View, { style: styles.ios, ...props });
779
838
  }
780
839
  function AndroidHeaderRight(props) {
781
- return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_react_native7.View, { style: styles.android, ...props });
840
+ return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_react_native8.View, { style: styles.android, ...props });
782
841
  }
783
842
  function HeaderRight(props) {
784
843
  return byPlatform({
@@ -787,7 +846,7 @@ function HeaderRight(props) {
787
846
  fallback: () => /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(IOSHeaderRight, { ...props })
788
847
  });
789
848
  }
790
- var styles = import_react_native7.StyleSheet.create({
849
+ var styles = import_react_native8.StyleSheet.create({
791
850
  ios: {
792
851
  marginRight: -IOS_DEFAULT_MARGIN + RIGHT_MARGIN,
793
852
  flexDirection: "row"
@@ -799,10 +858,10 @@ var styles = import_react_native7.StyleSheet.create({
799
858
 
800
859
  // src/components/GameWebViewNavigationBar/useSafeAreaTop.ts
801
860
  var import_react_native_safe_area_context = require("@react-native-bedrock/native/react-native-safe-area-context");
802
- var import_react_native8 = require("react-native");
861
+ var import_react_native9 = require("react-native");
803
862
  function useSafeAreaTop() {
804
863
  const safeAreaInsets = (0, import_react_native_safe_area_context.useSafeAreaInsets)();
805
- const hasDynamicIsland = import_react_native8.Platform.OS === "ios" && safeAreaInsets.top > 50;
864
+ const hasDynamicIsland = import_react_native9.Platform.OS === "ios" && safeAreaInsets.top > 50;
806
865
  const safeAreaTop = hasDynamicIsland ? safeAreaInsets.top - 5 : safeAreaInsets.top;
807
866
  return safeAreaTop;
808
867
  }
@@ -813,31 +872,31 @@ var originXML = '<svg fill="none" height="30" viewBox="0 0 30 30" width="30" xml
813
872
  function GameNavigationBar({ onClose }) {
814
873
  const safeAreaTop = useSafeAreaTop();
815
874
  return /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(import_jsx_runtime3.Fragment, { children: [
816
- /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_react_native9.PageNavbar, { preference: { type: "none" } }),
875
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_react_native10.PageNavbar, { preference: { type: "none" } }),
817
876
  /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
818
- import_react_native10.View,
877
+ import_react_native11.View,
819
878
  {
820
879
  style: {
821
880
  width: "100%",
822
- height: import_react_native10.Platform.OS === "ios" ? 44 : 54,
881
+ height: import_react_native11.Platform.OS === "ios" ? 44 : 54,
823
882
  flexDirection: "row",
824
883
  alignItems: "center",
825
884
  justifyContent: "flex-end",
826
885
  position: "absolute",
827
886
  zIndex: 9999,
828
887
  marginTop: safeAreaTop,
829
- paddingRight: import_react_native10.Platform.OS === "ios" ? 10 : 8
888
+ paddingRight: import_react_native11.Platform.OS === "ios" ? 10 : 8
830
889
  },
831
890
  pointerEvents: "box-none",
832
891
  children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(HeaderRight, { children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
833
- import_react_native10.TouchableOpacity,
892
+ import_react_native11.TouchableOpacity,
834
893
  {
835
894
  hitSlop: { left: 8, right: 8 },
836
895
  accessibilityRole: "button",
837
896
  accessible: true,
838
897
  accessibilityLabel: "\uAC8C\uC784\uC885\uB8CC",
839
898
  style: {
840
- padding: import_react_native10.Platform.OS === "ios" ? 7 : 9
899
+ padding: import_react_native11.Platform.OS === "ios" ? 7 : 9
841
900
  },
842
901
  onPress: onClose,
843
902
  children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_react_native_svg.SvgXml, { xml: originXML, width: 30, height: 30 })
@@ -851,7 +910,7 @@ function GameNavigationBar({ onClose }) {
851
910
  // src/components/GameWebView.tsx
852
911
  var import_jsx_runtime4 = require("react/jsx-runtime");
853
912
  var GameWebView = (0, import_react4.forwardRef)(function GameWebView2(props, ref) {
854
- const { openConfirm } = (0, import_react_native11.useDialog)();
913
+ const { openConfirm } = (0, import_react_native12.useDialog)();
855
914
  const { brandDisplayName } = getAppsInTossGlobals();
856
915
  const handleClose = (0, import_react4.useCallback)(async () => {
857
916
  const isConfirmed = await openConfirm({
@@ -865,7 +924,7 @@ var GameWebView = (0, import_react4.forwardRef)(function GameWebView2(props, ref
865
924
  }
866
925
  }, [brandDisplayName, openConfirm]);
867
926
  (0, import_react4.useEffect)(() => {
868
- if (import_react_native12.Platform.OS === "ios") {
927
+ if (import_react_native13.Platform.OS === "ios") {
869
928
  (0, import_react_native_bedrock8.setIosSwipeGestureEnabled)({ isEnabled: false });
870
929
  return () => {
871
930
  (0, import_react_native_bedrock8.setIosSwipeGestureEnabled)({ isEnabled: true });
@@ -878,32 +937,17 @@ var GameWebView = (0, import_react4.forwardRef)(function GameWebView2(props, ref
878
937
  handleClose();
879
938
  return true;
880
939
  };
881
- import_react_native12.BackHandler.addEventListener("hardwareBackPress", backHandler);
940
+ import_react_native13.BackHandler.addEventListener("hardwareBackPress", backHandler);
882
941
  return () => {
883
- import_react_native12.BackHandler.removeEventListener("hardwareBackPress", backHandler);
942
+ import_react_native13.BackHandler.removeEventListener("hardwareBackPress", backHandler);
884
943
  };
885
944
  }, [handleClose]);
886
945
  return /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(import_jsx_runtime4.Fragment, { children: [
887
946
  /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(GameNavigationBar, { onClose: handleClose }),
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 }) })
947
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_react_native13.View, { style: { flex: 1 }, children: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_react_native_webview.WebView, { ref, ...props }) })
889
948
  ] });
890
949
  });
891
950
 
892
- // src/async-bridges.ts
893
- var async_bridges_exports = {};
894
- __export(async_bridges_exports, {
895
- appLogin: () => appLogin,
896
- checkoutPayment: () => checkoutPayment,
897
- eventLog: () => eventLog,
898
- fetchAlbumPhotos: () => fetchAlbumPhotos,
899
- fetchContacts: () => fetchContacts,
900
- getClipboardText: () => getClipboardText,
901
- getCurrentLocation: () => getCurrentLocation,
902
- getTossShareLink: () => getTossShareLink,
903
- openCamera: () => openCamera,
904
- setClipboardText: () => setClipboardText
905
- });
906
-
907
951
  // src/bridge-handler/useBridgeHandler.tsx
908
952
  var import_react5 = require("react");
909
953
  function serializeError(error) {
@@ -1045,19 +1089,67 @@ __export(event_bridges_exports, {
1045
1089
  startUpdateLocation: () => startUpdateLocation
1046
1090
  });
1047
1091
 
1092
+ // src/utils/log.ts
1093
+ var import_react_native_bedrock9 = require("react-native-bedrock");
1094
+
1095
+ // src/utils/extractDateFromUUIDv7.ts
1096
+ var extractDateFromUUIDv7 = (uuid) => {
1097
+ const timestampHex = uuid.split("-").join("").slice(0, 12);
1098
+ const timestamp = Number.parseInt(timestampHex, 16);
1099
+ return new Date(timestamp);
1100
+ };
1101
+
1102
+ // src/utils/log.ts
1103
+ var getGroupId = (url) => {
1104
+ try {
1105
+ const urlObject = new URL(url);
1106
+ return {
1107
+ groupId: urlObject.pathname,
1108
+ search: urlObject.search.startsWith("?") ? urlObject.search.substring(1) : urlObject.search
1109
+ };
1110
+ } catch {
1111
+ return {
1112
+ groupId: "unknown",
1113
+ search: "unknown"
1114
+ };
1115
+ }
1116
+ };
1117
+ var getReferrer = () => {
1118
+ try {
1119
+ const referrer = new URL((0, import_react_native_bedrock9.getSchemeUri)());
1120
+ return referrer.searchParams.get("referrer");
1121
+ } catch {
1122
+ return "";
1123
+ }
1124
+ };
1125
+ var trackScreen = (url) => {
1126
+ const { groupId, search } = getGroupId(url);
1127
+ const log = {
1128
+ log_type: "screen",
1129
+ log_name: `${groupId}::screen`,
1130
+ params: {
1131
+ search,
1132
+ referrer: getReferrer(),
1133
+ deployment_id: env.getDeploymentId(),
1134
+ deployment_timestamp: extractDateFromUUIDv7(env.getDeploymentId()).getTime()
1135
+ }
1136
+ };
1137
+ return eventLog(log);
1138
+ };
1139
+
1048
1140
  // src/components/WebView.tsx
1049
1141
  var import_jsx_runtime5 = require("react/jsx-runtime");
1050
1142
  var appsInTossGlobals = getAppsInTossGlobals();
1051
1143
  var operationalEnvironment = getOperationalEnvironment();
1052
1144
  var TYPES = ["partner", "external", "game"];
1053
1145
  var WEBVIEW_TYPES = {
1054
- partner: import_react_native13.PartnerWebViewScreen,
1055
- external: import_react_native13.ExternalWebViewScreen,
1146
+ partner: import_react_native14.PartnerWebViewScreen,
1147
+ external: import_react_native14.ExternalWebViewScreen,
1056
1148
  game: GameWebView
1057
1149
  };
1058
1150
  function mergeSchemeQueryParamsInto(url) {
1059
1151
  const baseUrl = new URL(url);
1060
- const schemeUrl = new URL((0, import_react_native_bedrock9.getSchemeUri)());
1152
+ const schemeUrl = new URL((0, import_react_native_bedrock10.getSchemeUri)());
1061
1153
  baseUrl.pathname = schemeUrl.pathname;
1062
1154
  for (const [key, value] of schemeUrl.searchParams.entries()) {
1063
1155
  baseUrl.searchParams.set(key, value);
@@ -1081,7 +1173,7 @@ function WebView({ type, local, onMessage, ...props }) {
1081
1173
  if (!TYPES.includes(type)) {
1082
1174
  throw new Error(`Invalid WebView type: '${type}'`);
1083
1175
  }
1084
- const bedrockEvent = (0, import_react_native_bedrock9.useBedrockEvent)();
1176
+ const bedrockEvent = (0, import_react_native_bedrock10.useBedrockEvent)();
1085
1177
  const uri = (0, import_react6.useMemo)(() => getWebViewUri(local), [local]);
1086
1178
  const top = (0, import_private.useSafeAreaTop)();
1087
1179
  const bottom = (0, import_private.useSafeAreaBottom)();
@@ -1112,7 +1204,9 @@ function WebView({ type, local, onMessage, ...props }) {
1112
1204
  loadAdMobInterstitialAd_isSupported: GoogleAdMob.loadAdMobInterstitialAd.isSupported,
1113
1205
  showAdMobInterstitialAd_isSupported: GoogleAdMob.showAdMobInterstitialAd.isSupported,
1114
1206
  loadAdMobRewardedAd_isSupported: GoogleAdMob.loadAdMobRewardedAd.isSupported,
1115
- showAdMobRewardedAd_isSupported: GoogleAdMob.showAdMobRewardedAd.isSupported
1207
+ showAdMobRewardedAd_isSupported: GoogleAdMob.showAdMobRewardedAd.isSupported,
1208
+ /** env */
1209
+ getDeploymentId: env.getDeploymentId
1116
1210
  },
1117
1211
  // eslint-disable-next-line @typescript-eslint/ban-ts-comment
1118
1212
  // @ts-expect-error
@@ -1159,6 +1253,11 @@ function WebView({ type, local, onMessage, ...props }) {
1159
1253
  }, [type, props]);
1160
1254
  const BaseWebView = WEBVIEW_TYPES[type];
1161
1255
  const webViewDebuggingEnabled = operationalEnvironment === "sandbox";
1256
+ const handleNavigationStateChange = (0, import_react6.useCallback)((event) => {
1257
+ if (event.url) {
1258
+ trackScreen(event.url);
1259
+ }
1260
+ }, []);
1162
1261
  return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
1163
1262
  BaseWebView,
1164
1263
  {
@@ -1170,6 +1269,7 @@ function WebView({ type, local, onMessage, ...props }) {
1170
1269
  webviewDebuggingEnabled: webViewDebuggingEnabled,
1171
1270
  thirdPartyCookiesEnabled: true,
1172
1271
  onMessage: handler.onMessage,
1272
+ onNavigationStateChange: handleNavigationStateChange,
1173
1273
  injectedJavaScript: handler.injectedJavaScript,
1174
1274
  injectedJavaScriptBeforeContentLoaded: handler.injectedJavaScript
1175
1275
  }
@@ -1184,9 +1284,9 @@ function ensureValue(value, name) {
1184
1284
 
1185
1285
  // src/hooks/useGeolocation.ts
1186
1286
  var import_react7 = require("react");
1187
- var import_react_native_bedrock10 = require("react-native-bedrock");
1287
+ var import_react_native_bedrock11 = require("react-native-bedrock");
1188
1288
  function useGeolocation({ accuracy, distanceInterval, timeInterval }) {
1189
- const isVisible = (0, import_react_native_bedrock10.useVisibility)();
1289
+ const isVisible = (0, import_react_native_bedrock11.useVisibility)();
1190
1290
  const [location, setLocation] = (0, import_react7.useState)(null);
1191
1291
  (0, import_react7.useEffect)(() => {
1192
1292
  if (!isVisible) {
@@ -1215,9 +1315,19 @@ var Accuracy2 = /* @__PURE__ */ ((Accuracy3) => {
1215
1315
  Accuracy3[Accuracy3["BestForNavigation"] = 6] = "BestForNavigation";
1216
1316
  return Accuracy3;
1217
1317
  })(Accuracy2 || {});
1318
+
1319
+ // src/index.ts
1320
+ __reExport(src_exports, require("@apps-in-toss/analytics"), module.exports);
1321
+ var Analytics2 = {
1322
+ init: import_analytics2.Analytics.init,
1323
+ Impression: import_analytics2.Analytics.Impression,
1324
+ Press: import_analytics2.Analytics.Press,
1325
+ Area: import_analytics2.Analytics.Area
1326
+ };
1218
1327
  // Annotate the CommonJS export names for ESM import in node:
1219
1328
  0 && (module.exports = {
1220
1329
  Accuracy,
1330
+ Analytics,
1221
1331
  AppsInToss,
1222
1332
  GoogleAdMob,
1223
1333
  Storage,
@@ -1239,5 +1349,6 @@ var Accuracy2 = /* @__PURE__ */ ((Accuracy3) => {
1239
1349
  openCamera,
1240
1350
  setClipboardText,
1241
1351
  startUpdateLocation,
1242
- useGeolocation
1352
+ useGeolocation,
1353
+ ...require("@apps-in-toss/analytics")
1243
1354
  });