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