@apps-in-toss/framework 1.4.4 → 1.4.6

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
@@ -40,7 +40,7 @@ __export(src_exports, {
40
40
  useCreateUserAgent: () => useCreateUserAgent,
41
41
  useGeolocation: () => useGeolocation,
42
42
  useOverlay: () => import_private10.useOverlay,
43
- useTopNavigation: () => import_private10.useTopNavigation,
43
+ useTopNavigation: () => useTopNavigation,
44
44
  useWaitForReturnNavigator: () => useWaitForReturnNavigator
45
45
  });
46
46
  module.exports = __toCommonJS(src_exports);
@@ -194,9 +194,7 @@ function AppUpdate() {
194
194
  return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_jsx_runtime.Fragment, {});
195
195
  }
196
196
 
197
- // src/core/hooks/useAppsInTossBridge.ts
198
- var import_native_modules3 = require("@apps-in-toss/native-modules");
199
- var import_tds_react_native = require("@toss/tds-react-native");
197
+ // src/core/context/NavigationBarContext.tsx
200
198
  var import_react5 = require("react");
201
199
 
202
200
  // src/core/utils/getAppsInTossGlobals.ts
@@ -207,6 +205,54 @@ function getAppsInTossGlobals() {
207
205
  return global.__appsInToss;
208
206
  }
209
207
 
208
+ // src/core/utils/safeParseNavigationBar.ts
209
+ function safeParseNavigationBar(navigationBar) {
210
+ if (typeof navigationBar === "object") {
211
+ return navigationBar;
212
+ }
213
+ try {
214
+ return JSON.parse(navigationBar);
215
+ } catch {
216
+ return null;
217
+ }
218
+ }
219
+
220
+ // src/core/context/NavigationBarContext.tsx
221
+ var import_jsx_runtime2 = require("react/jsx-runtime");
222
+ var NavigationBarContext = (0, import_react5.createContext)(null);
223
+ function NavigationBarContextProvider({ children }) {
224
+ const globals = getAppsInTossGlobals();
225
+ const parsedNavigationBar = globals.navigationBar != null ? safeParseNavigationBar(globals.navigationBar) : null;
226
+ const [navigationRightButton, setNavigationRightButton] = (0, import_react5.useState)(
227
+ parsedNavigationBar?.initialAccessoryButton
228
+ );
229
+ const addNavigationRightButton = (button) => {
230
+ setNavigationRightButton(button);
231
+ };
232
+ const removeNavigationRightButton = () => {
233
+ setNavigationRightButton(void 0);
234
+ };
235
+ return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
236
+ NavigationBarContext.Provider,
237
+ {
238
+ value: { navigationRightButton, addNavigationRightButton, removeNavigationRightButton },
239
+ children
240
+ }
241
+ );
242
+ }
243
+ function useNavigationBarContext() {
244
+ const context = (0, import_react5.useContext)(NavigationBarContext);
245
+ if (context == null) {
246
+ throw Error("useNavigationBarContext must be used within NavigationBarContextProvider");
247
+ }
248
+ return context;
249
+ }
250
+
251
+ // src/core/hooks/useAppsInTossBridge.ts
252
+ var import_native_modules3 = require("@apps-in-toss/native-modules");
253
+ var import_tds_react_native = require("@toss/tds-react-native");
254
+ var import_react6 = require("react");
255
+
210
256
  // src/core/utils/toIcon.ts
211
257
  function toIcon(source) {
212
258
  return source.startsWith("http") ? { source: { uri: source } } : { name: source };
@@ -216,7 +262,7 @@ function toIcon(source) {
216
262
  function useAppsInTossBridge() {
217
263
  const controller = (0, import_tds_react_native.useBridge)();
218
264
  const appsInTossGlobals = getAppsInTossGlobals();
219
- (0, import_react5.useEffect)(() => {
265
+ (0, import_react6.useEffect)(() => {
220
266
  const isGameApp = appsInTossGlobals.webViewType === "game" || appsInTossGlobals.appType === "game";
221
267
  controller.open({
222
268
  serviceName: appsInTossGlobals.brandDisplayName,
@@ -232,7 +278,7 @@ function useAppsInTossBridge() {
232
278
 
233
279
  // src/components/RNAppContainer.tsx
234
280
  var import_native_modules12 = require("@apps-in-toss/native-modules");
235
- var import_react17 = require("react");
281
+ var import_react18 = require("react");
236
282
  var import_react_native20 = require("react-native");
237
283
 
238
284
  // src/components/GameInitializer.tsx
@@ -240,7 +286,7 @@ var import_native_modules7 = require("@apps-in-toss/native-modules");
240
286
  var import_react_native10 = require("@granite-js/react-native");
241
287
  var import_tds_react_native5 = require("@toss/tds-react-native");
242
288
  var import_es_hangul = require("es-hangul");
243
- var import_react11 = require("react");
289
+ var import_react12 = require("react");
244
290
  var import_react_native11 = require("react-native");
245
291
 
246
292
  // src/constant/game-center.ts
@@ -254,7 +300,7 @@ var GAME_MIN_VERSION = {
254
300
  var import_native_modules4 = require("@apps-in-toss/native-modules");
255
301
  var import_react_native7 = require("@granite-js/react-native");
256
302
  var import_tds_react_native2 = require("@toss/tds-react-native");
257
- var import_react6 = require("react");
303
+ var import_react7 = require("react");
258
304
 
259
305
  // src/utils/market.ts
260
306
  var import_react_native6 = require("react-native");
@@ -268,7 +314,7 @@ var getMarketLink = () => {
268
314
  function useAppUpdateDialog() {
269
315
  const { openConfirm } = (0, import_tds_react_native2.useDialog)();
270
316
  const logging = useAppUpdateDialogLogging();
271
- const openAppUpdateDialog = (0, import_react6.useCallback)(
317
+ const openAppUpdateDialog = (0, import_react7.useCallback)(
272
318
  async ({
273
319
  title,
274
320
  description,
@@ -348,12 +394,12 @@ function useAppUpdateDialogLogging() {
348
394
 
349
395
  // src/hooks/useGameCenterProfile.ts
350
396
  var import_native_modules6 = require("@apps-in-toss/native-modules");
351
- var import_react10 = require("react");
397
+ var import_react11 = require("react");
352
398
 
353
399
  // src/hooks/useErrorAlert.ts
354
400
  var import_react_native8 = require("@granite-js/react-native");
355
401
  var import_tds_react_native3 = require("@toss/tds-react-native");
356
- var import_react7 = require("react");
402
+ var import_react8 = require("react");
357
403
 
358
404
  // src/utils/error.ts
359
405
  var DEFAULT_ERROR = {
@@ -364,7 +410,7 @@ var DEFAULT_ERROR = {
364
410
  // src/hooks/useErrorAlert.ts
365
411
  var useErrorAlert = () => {
366
412
  const { openAlert } = (0, import_tds_react_native3.useDialog)();
367
- const openErrorAlert = (0, import_react7.useCallback)(async () => {
413
+ const openErrorAlert = (0, import_react8.useCallback)(async () => {
368
414
  await openAlert({
369
415
  title: DEFAULT_ERROR.title,
370
416
  description: DEFAULT_ERROR.description
@@ -375,7 +421,7 @@ var useErrorAlert = () => {
375
421
  };
376
422
 
377
423
  // src/hooks/useTransparentWebview.tsx
378
- var import_react8 = require("react");
424
+ var import_react9 = require("react");
379
425
 
380
426
  // src/utils/openTransparentWebView.ts
381
427
  var import_react_native9 = require("@granite-js/react-native");
@@ -417,9 +463,9 @@ var openTransparentWebView = ({
417
463
 
418
464
  // src/hooks/useTransparentWebview.tsx
419
465
  var useTransparentWebview = () => {
420
- const [isWebviewLoading, setIsWebviewLoading] = (0, import_react8.useState)(false);
466
+ const [isWebviewLoading, setIsWebviewLoading] = (0, import_react9.useState)(false);
421
467
  const { open: openErrorAlert } = useErrorAlert();
422
- const _openTransparentWebview = (0, import_react8.useCallback)(
468
+ const _openTransparentWebview = (0, import_react9.useCallback)(
423
469
  ({ webUrl, onClose, onError }) => {
424
470
  if (isWebviewLoading) {
425
471
  return;
@@ -453,15 +499,15 @@ var useTransparentWebview = () => {
453
499
  // src/components/GameProfileToast.tsx
454
500
  var import_tds_react_native4 = require("@toss/tds-react-native");
455
501
  var import_private2 = require("@toss/tds-react-native/private");
456
- var import_react9 = require("react");
457
- var import_jsx_runtime2 = require("react/jsx-runtime");
502
+ var import_react10 = require("react");
503
+ var import_jsx_runtime3 = require("react/jsx-runtime");
458
504
  var useGameProfileToast = () => {
459
505
  const overlay = (0, import_private2.useOverlay)();
460
- const openGameProfileToast = (0, import_react9.useCallback)(
506
+ const openGameProfileToast = (0, import_react10.useCallback)(
461
507
  (nickname, profileImageUri) => {
462
508
  return new Promise((resolve) => {
463
509
  overlay.open(({ isOpen, close, exit }) => {
464
- return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_private2.ColorPreferenceProvider, { colorPreference: "dark", children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_private2.AdaptiveColorProvider, { children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
510
+ return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_private2.ColorPreferenceProvider, { colorPreference: "dark", children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_private2.AdaptiveColorProvider, { children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
465
511
  import_tds_react_native4.Toast,
466
512
  {
467
513
  open: isOpen,
@@ -472,7 +518,7 @@ var useGameProfileToast = () => {
472
518
  onExited: exit,
473
519
  position: "top",
474
520
  text: `${nickname}\uB2D8 \uBC18\uAC00\uC6CC\uC694!`,
475
- icon: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
521
+ icon: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
476
522
  import_tds_react_native4.Asset.Image,
477
523
  {
478
524
  style: { borderRadius: 64, overflow: "hidden" },
@@ -492,16 +538,16 @@ var useGameProfileToast = () => {
492
538
 
493
539
  // src/hooks/useGameCenterProfile.ts
494
540
  var useGameCenterProfile = (isReadyForProfileUI) => {
495
- const [profileData, setProfileData] = (0, import_react10.useState)(void 0);
496
- const [isProfileDataLoading, setIsProfileDataLoading] = (0, import_react10.useState)(true);
497
- const [isProfileDataRefetching, setIsProfileDataRefetching] = (0, import_react10.useState)(false);
541
+ const [profileData, setProfileData] = (0, import_react11.useState)(void 0);
542
+ const [isProfileDataLoading, setIsProfileDataLoading] = (0, import_react11.useState)(true);
543
+ const [isProfileDataRefetching, setIsProfileDataRefetching] = (0, import_react11.useState)(false);
498
544
  const shouldShowProfileLoadingOverlay = isProfileDataLoading && isReadyForProfileUI || isProfileDataRefetching;
499
545
  const shouldShowProfileNotFoundOverlay = profileData?.statusCode === "PROFILE_NOT_FOUND" && isReadyForProfileUI && !isProfileDataRefetching;
500
546
  const canShowBottomSheetOrToast = !isProfileDataLoading && isReadyForProfileUI;
501
547
  const { openGameProfileToast } = useGameProfileToast();
502
548
  const { open: openErrorAlert } = useErrorAlert();
503
549
  const { open: openTransparentWebView2 } = useTransparentWebview();
504
- const fetchProfileData = (0, import_react10.useCallback)(async () => {
550
+ const fetchProfileData = (0, import_react11.useCallback)(async () => {
505
551
  try {
506
552
  const data = await (0, import_native_modules6.getGameCenterGameProfile)();
507
553
  setProfileData(data);
@@ -511,7 +557,7 @@ var useGameCenterProfile = (isReadyForProfileUI) => {
511
557
  setIsProfileDataLoading(false);
512
558
  }
513
559
  }, [openErrorAlert]);
514
- const refetchProfileData = (0, import_react10.useCallback)(async () => {
560
+ const refetchProfileData = (0, import_react11.useCallback)(async () => {
515
561
  try {
516
562
  setIsProfileDataRefetching(true);
517
563
  const data = await (0, import_native_modules6.getGameCenterGameProfile)();
@@ -525,7 +571,7 @@ var useGameCenterProfile = (isReadyForProfileUI) => {
525
571
  openErrorAlert();
526
572
  }
527
573
  }, [openErrorAlert, openGameProfileToast]);
528
- const openProfileWebview = (0, import_react10.useCallback)(() => {
574
+ const openProfileWebview = (0, import_react11.useCallback)(() => {
529
575
  openTransparentWebView2({
530
576
  webUrl: `${GAME_PROFILE_WEBVIEW_URL}?appName=${getAppName()}&referrer=appsintoss.${getAppName()}`,
531
577
  onClose: async () => {
@@ -558,7 +604,7 @@ var Z_INDEX = {
558
604
  };
559
605
 
560
606
  // src/components/GameInitializer.tsx
561
- var import_jsx_runtime3 = require("react/jsx-runtime");
607
+ var import_jsx_runtime4 = require("react/jsx-runtime");
562
608
  var GameInitializer = ({ children, isReadyForProfileUI }) => {
563
609
  const {
564
610
  profileData,
@@ -569,12 +615,12 @@ var GameInitializer = ({ children, isReadyForProfileUI }) => {
569
615
  openGameProfileToast,
570
616
  fetchProfileData
571
617
  } = useGameCenterProfile(isReadyForProfileUI);
572
- const isCompletedFlow = (0, import_react11.useRef)(false);
618
+ const isCompletedFlow = (0, import_react12.useRef)(false);
573
619
  const { open: openAppUpdateDialog } = useAppUpdateDialog();
574
- (0, import_react11.useEffect)(() => {
620
+ (0, import_react12.useEffect)(() => {
575
621
  fetchProfileData();
576
622
  }, []);
577
- (0, import_react11.useEffect)(() => {
623
+ (0, import_react12.useEffect)(() => {
578
624
  const handleGameProfileFlow = async () => {
579
625
  if (!canShowBottomSheetOrToast) {
580
626
  return;
@@ -611,9 +657,9 @@ var GameInitializer = ({ children, isReadyForProfileUI }) => {
611
657
  profileData
612
658
  ]);
613
659
  if (!(0, import_native_modules7.isMinVersionSupported)(GAME_MIN_VERSION)) {
614
- return /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(import_jsx_runtime3.Fragment, { children: [
615
- /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_react_native11.View, { style: { flex: 1, position: "relative" }, children }),
616
- /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
660
+ return /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(import_jsx_runtime4.Fragment, { children: [
661
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_react_native11.View, { style: { flex: 1, position: "relative" }, children }),
662
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
617
663
  import_react_native11.Pressable,
618
664
  {
619
665
  style: {
@@ -633,9 +679,9 @@ var GameInitializer = ({ children, isReadyForProfileUI }) => {
633
679
  ] });
634
680
  }
635
681
  if (shouldShowProfileLoadingOverlay) {
636
- return /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(import_jsx_runtime3.Fragment, { children: [
637
- /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_react_native11.View, { style: { flex: 1, position: "relative" }, children }),
638
- /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
682
+ return /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(import_jsx_runtime4.Fragment, { children: [
683
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_react_native11.View, { style: { flex: 1, position: "relative" }, children }),
684
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
639
685
  import_react_native11.View,
640
686
  {
641
687
  style: {
@@ -644,15 +690,15 @@ var GameInitializer = ({ children, isReadyForProfileUI }) => {
644
690
  alignItems: "center",
645
691
  backgroundColor: "rgba(0, 0, 0, 0.2)"
646
692
  },
647
- children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_tds_react_native5.Loader, { size: "large", type: "light" })
693
+ children: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_tds_react_native5.Loader, { size: "large", type: "light" })
648
694
  }
649
695
  )
650
696
  ] });
651
697
  }
652
698
  if (shouldShowProfileNotFoundOverlay) {
653
- return /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(import_jsx_runtime3.Fragment, { children: [
654
- /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_react_native11.View, { style: { flex: 1, position: "relative" }, children }),
655
- shouldShowProfileNotFoundOverlay && /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
699
+ return /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(import_jsx_runtime4.Fragment, { children: [
700
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_react_native11.View, { style: { flex: 1, position: "relative" }, children }),
701
+ shouldShowProfileNotFoundOverlay && /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
656
702
  import_react_native11.Pressable,
657
703
  {
658
704
  style: {
@@ -665,7 +711,7 @@ var GameInitializer = ({ children, isReadyForProfileUI }) => {
665
711
  )
666
712
  ] });
667
713
  }
668
- return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_jsx_runtime3.Fragment, { children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_react_native11.View, { style: { flex: 1, position: "relative" }, children }) });
714
+ return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_jsx_runtime4.Fragment, { children: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_react_native11.View, { style: { flex: 1, position: "relative" }, children }) });
669
715
  };
670
716
  var overlayStyle = {
671
717
  position: "absolute",
@@ -680,10 +726,10 @@ var overlayStyle = {
680
726
  var import_private5 = require("@toss/tds-react-native/private");
681
727
 
682
728
  // src/components/NavigationBar/RNNavigationBar/hooks/useHardwareBackPress.ts
683
- var import_react12 = require("react");
729
+ var import_react13 = require("react");
684
730
  var import_react_native12 = require("react-native");
685
731
  function useHardwareBackPress(handler) {
686
- (0, import_react12.useEffect)(() => {
732
+ (0, import_react13.useEffect)(() => {
687
733
  const handleBackPress = () => {
688
734
  handler();
689
735
  return true;
@@ -695,16 +741,16 @@ function useHardwareBackPress(handler) {
695
741
 
696
742
  // src/components/NavigationBar/RNNavigationBar/hooks/useNavigationEvent.ts
697
743
  var import_react_native14 = require("@granite-js/react-native");
698
- var import_react14 = require("react");
744
+ var import_react15 = require("react");
699
745
 
700
746
  // src/components/NavigationBar/RNNavigationBar/hooks/useCloseConfirm.ts
701
747
  var import_tds_react_native6 = require("@toss/tds-react-native");
702
748
  var import_es_hangul2 = require("es-hangul");
703
- var import_react13 = require("react");
749
+ var import_react14 = require("react");
704
750
  function useCloseConfirm() {
705
751
  const { brandDisplayName } = getAppsInTossGlobals();
706
752
  const { openConfirm } = (0, import_tds_react_native6.useDialog)();
707
- return (0, import_react13.useCallback)(async ({ onEntered }) => {
753
+ return (0, import_react14.useCallback)(async ({ onEntered }) => {
708
754
  return await openConfirm({
709
755
  title: `${(0, import_es_hangul2.josa)(brandDisplayName, "\uC744/\uB97C")} \uC885\uB8CC\uD560\uAE4C\uC694?`,
710
756
  leftButton: "\uCDE8\uC18C",
@@ -806,7 +852,7 @@ function useNavigationEvent() {
806
852
  const navigation = (0, import_react_native14.useNavigation)();
807
853
  const closeConfirm = useCloseConfirm();
808
854
  const { captureExitLog } = useCaptureExitLog();
809
- return (0, import_react14.useMemo)(() => {
855
+ return (0, import_react15.useMemo)(() => {
810
856
  const close = async () => {
811
857
  const hasConfirmed = await closeConfirm({
812
858
  onEntered: logging.closePopupShow
@@ -844,7 +890,7 @@ var import_native_modules11 = require("@apps-in-toss/native-modules");
844
890
  var import_react_native18 = require("@granite-js/react-native");
845
891
  var import_tds_react_native8 = require("@toss/tds-react-native");
846
892
  var import_private4 = require("@toss/tds-react-native/private");
847
- var import_react15 = require("react");
893
+ var import_react16 = require("react");
848
894
 
849
895
  // src/core/hooks/useMoreButtonBottomSheet/AppShareListMenu.tsx
850
896
  var import_native_modules10 = require("@apps-in-toss/native-modules");
@@ -932,7 +978,7 @@ function addParamsToUrl(url, params) {
932
978
  }
933
979
 
934
980
  // src/core/hooks/useMoreButtonBottomSheet/AppShareListMenu.tsx
935
- var import_jsx_runtime4 = require("react/jsx-runtime");
981
+ var import_jsx_runtime5 = require("react/jsx-runtime");
936
982
  var SHARE_SCHEME_REFERRER = "appsintoss.common_module_share";
937
983
  var APP_SHARE_MENU_INFO = {
938
984
  contactItemName: "\uACF5\uC720\uD558\uAE30",
@@ -948,10 +994,10 @@ function AppShareListMenu() {
948
994
  const schemeForShare = addParamsToUrl(initialScheme, {
949
995
  referrer: SHARE_SCHEME_REFERRER
950
996
  });
951
- return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
997
+ return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
952
998
  import_tds_react_native7.ListRow,
953
999
  {
954
- left: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
1000
+ left: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
955
1001
  import_tds_react_native7.ListRow.Icon,
956
1002
  {
957
1003
  color: globals.brandPrimaryColor,
@@ -959,7 +1005,7 @@ function AppShareListMenu() {
959
1005
  type: "background"
960
1006
  }
961
1007
  ),
962
- contents: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
1008
+ contents: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
963
1009
  import_tds_react_native7.ListRow.Texts,
964
1010
  {
965
1011
  type: "1RowTypeA",
@@ -998,7 +1044,7 @@ function ensureValue(value, name) {
998
1044
  }
999
1045
 
1000
1046
  // src/core/hooks/useMoreButtonBottomSheet/index.tsx
1001
- var import_jsx_runtime5 = require("react/jsx-runtime");
1047
+ var import_jsx_runtime6 = require("react/jsx-runtime");
1002
1048
  var APP_BRIDGE_METHOD_NAME = "getMiniAppsSupportContact";
1003
1049
  var MIN_VERSION = {
1004
1050
  BOTTOM_SHEET: {
@@ -1013,14 +1059,14 @@ var MIN_VERSION = {
1013
1059
  function useMoreButtonBottomSheet() {
1014
1060
  const globals = getAppsInTossGlobals();
1015
1061
  const adaptive = (0, import_private4.useAdaptive)();
1016
- const [itemList, setItemList] = (0, import_react15.useState)([]);
1062
+ const [itemList, setItemList] = (0, import_react16.useState)([]);
1017
1063
  const appUpdateDialog = useAppUpdateDialog();
1018
1064
  const logging = useMoreButtonBottomSheetLogging();
1019
1065
  const overlay = (0, import_private4.useOverlay)();
1020
1066
  const title = ensureValue(globals.brandDisplayName, "displayName");
1021
1067
  const isBottomSheetSupported = (0, import_native_modules11.isMinVersionSupported)(MIN_VERSION.BOTTOM_SHEET);
1022
1068
  const isShareListMenuSupported = (0, import_native_modules11.isMinVersionSupported)(MIN_VERSION.SHARE_LIST_MENU);
1023
- (0, import_react15.useEffect)(() => {
1069
+ (0, import_react16.useEffect)(() => {
1024
1070
  if (!isBottomSheetSupported) {
1025
1071
  return;
1026
1072
  }
@@ -1047,17 +1093,17 @@ function useMoreButtonBottomSheet() {
1047
1093
  logging.close();
1048
1094
  close();
1049
1095
  };
1050
- return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(BottomSheetImpressionArea, { children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
1096
+ return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(BottomSheetImpressionArea, { children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
1051
1097
  import_tds_react_native8.BottomSheet.Root,
1052
1098
  {
1053
- header: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
1099
+ header: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
1054
1100
  import_tds_react_native8.ListHeader,
1055
1101
  {
1056
- title: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_tds_react_native8.ListHeader.TitleParagraph, { color: adaptive.grey800, fontWeight: "bold", typography: "t5", children: title })
1102
+ title: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_tds_react_native8.ListHeader.TitleParagraph, { color: adaptive.grey800, fontWeight: "bold", typography: "t5", children: title })
1057
1103
  }
1058
1104
  ),
1059
1105
  open: isOpen,
1060
- cta: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
1106
+ cta: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
1061
1107
  import_tds_react_native8.BottomSheet.CTA,
1062
1108
  {
1063
1109
  size: "large",
@@ -1071,12 +1117,12 @@ function useMoreButtonBottomSheet() {
1071
1117
  ),
1072
1118
  onClose: handleClose,
1073
1119
  onExited: exit,
1074
- children: /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(import_tds_react_native8.List, { rowSeparator: "none", children: [
1120
+ children: /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(import_tds_react_native8.List, { rowSeparator: "none", children: [
1075
1121
  itemList.map((item) => {
1076
- return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
1122
+ return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
1077
1123
  import_tds_react_native8.ListRow,
1078
1124
  {
1079
- left: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
1125
+ left: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
1080
1126
  import_tds_react_native8.ListRow.Icon,
1081
1127
  {
1082
1128
  color: globals.brandPrimaryColor,
@@ -1084,7 +1130,7 @@ function useMoreButtonBottomSheet() {
1084
1130
  type: "background"
1085
1131
  }
1086
1132
  ),
1087
- contents: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
1133
+ contents: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
1088
1134
  import_tds_react_native8.ListRow.Texts,
1089
1135
  {
1090
1136
  type: "1RowTypeA",
@@ -1101,7 +1147,7 @@ function useMoreButtonBottomSheet() {
1101
1147
  item.contactItemName
1102
1148
  );
1103
1149
  }),
1104
- isShareListMenuSupported && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(AppShareListMenu, {})
1150
+ isShareListMenuSupported && /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(AppShareListMenu, {})
1105
1151
  ] })
1106
1152
  }
1107
1153
  ) });
@@ -1111,54 +1157,42 @@ function useMoreButtonBottomSheet() {
1111
1157
  }
1112
1158
  function BottomSheetImpressionArea({ children }) {
1113
1159
  const logging = useMoreButtonBottomSheetLogging();
1114
- (0, import_react15.useEffect)(() => {
1160
+ (0, import_react16.useEffect)(() => {
1115
1161
  logging.show();
1116
1162
  }, [logging]);
1117
- return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_jsx_runtime5.Fragment, { children });
1118
- }
1119
-
1120
- // src/core/utils/safeParseNavigationBar.ts
1121
- function safeParseNavigationBar(navigationBar) {
1122
- if (typeof navigationBar === "object") {
1123
- return navigationBar;
1124
- }
1125
- try {
1126
- return JSON.parse(navigationBar);
1127
- } catch {
1128
- return null;
1129
- }
1163
+ return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_jsx_runtime6.Fragment, { children });
1130
1164
  }
1131
1165
 
1132
1166
  // src/components/NavigationBar/common/NavigationBarImpressionArea.tsx
1133
- var import_react16 = require("react");
1134
- var import_jsx_runtime6 = require("react/jsx-runtime");
1167
+ var import_react17 = require("react");
1168
+ var import_jsx_runtime7 = require("react/jsx-runtime");
1135
1169
  function NavigationBarImpressionArea({
1136
1170
  children,
1137
1171
  withHomeButton
1138
1172
  }) {
1139
- const hasLogged = (0, import_react16.useRef)(false);
1173
+ const hasLogged = (0, import_react17.useRef)(false);
1140
1174
  const logging = useNavigationBarLogging();
1141
- (0, import_react16.useEffect)(() => {
1175
+ (0, import_react17.useEffect)(() => {
1142
1176
  if (hasLogged.current === false) {
1143
1177
  logging.navBarImpression({ home_icon_yn: withHomeButton ? "Y" : "N" });
1144
1178
  hasLogged.current = true;
1145
1179
  }
1146
1180
  }, [logging, withHomeButton]);
1147
- return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_jsx_runtime6.Fragment, { children });
1181
+ return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_jsx_runtime7.Fragment, { children });
1148
1182
  }
1149
1183
 
1150
1184
  // src/components/NavigationBar/RNNavigationBar/Default.tsx
1151
- var import_jsx_runtime7 = require("react/jsx-runtime");
1185
+ var import_jsx_runtime8 = require("react/jsx-runtime");
1152
1186
  function DefaultNavigationBar() {
1153
1187
  const globals = getAppsInTossGlobals();
1154
1188
  const { open: openMoreButtonBottomSheet } = useMoreButtonBottomSheet();
1155
1189
  const parsedNavigationBar = globals.navigationBar != null ? safeParseNavigationBar(globals.navigationBar) : null;
1156
1190
  const withHomeButton = parsedNavigationBar?.withHomeButton ?? false;
1157
1191
  const withBackButton = parsedNavigationBar?.withBackButton ?? true;
1158
- const initialAccessoryButton = parsedNavigationBar?.initialAccessoryButton;
1192
+ const { navigationRightButton } = useNavigationBarContext();
1159
1193
  const navigationEvent = useNavigationEvent();
1160
1194
  useHardwareBackPress(navigationEvent.handleBack);
1161
- return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(NavigationBarImpressionArea, { withHomeButton, children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
1195
+ return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(NavigationBarImpressionArea, { withHomeButton, children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
1162
1196
  import_private5.TopNavigation,
1163
1197
  {
1164
1198
  title: globals.brandDisplayName,
@@ -1168,8 +1202,8 @@ function DefaultNavigationBar() {
1168
1202
  onPressTitle: withHomeButton ? navigationEvent.handleHomeButtonClick : void 0,
1169
1203
  onPressClose: navigationEvent.handleCloseButtonClick,
1170
1204
  withHome: withHomeButton,
1171
- fixedRightButton: initialAccessoryButton,
1172
- children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_private5.NavigationLeft, { visible: withBackButton, children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_private5.NavigationBackButton, { onPress: navigationEvent.handleBack, canGoBack: false }) })
1205
+ fixedRightButton: navigationRightButton,
1206
+ children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_private5.NavigationLeft, { visible: withBackButton, children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_private5.NavigationBackButton, { onPress: navigationEvent.handleBack, canGoBack: false }) })
1173
1207
  }
1174
1208
  ) });
1175
1209
  }
@@ -1179,19 +1213,17 @@ var import_react_native_safe_area_context = require("@granite-js/native/react-na
1179
1213
  var import_tds_react_native9 = require("@toss/tds-react-native");
1180
1214
  var import_private6 = require("@toss/tds-react-native/private");
1181
1215
  var import_react_native19 = require("react-native");
1182
- var import_jsx_runtime8 = require("react/jsx-runtime");
1216
+ var import_jsx_runtime9 = require("react/jsx-runtime");
1183
1217
  function GameNavigationBar() {
1184
1218
  const safeAreaTop = (0, import_private6.useSafeAreaTop)();
1185
- const global2 = getAppsInTossGlobals();
1186
1219
  const { open: openMoreButtonBottomSheet } = useMoreButtonBottomSheet();
1187
1220
  const navigationEvent = useNavigationEvent();
1221
+ const { navigationRightButton } = useNavigationBarContext();
1188
1222
  const { right: safeAreaRight } = (0, import_react_native_safe_area_context.useSafeAreaInsets)();
1189
1223
  useHardwareBackPress(navigationEvent.handleBack);
1190
- const parsedNavigationBar = global2.navigationBar != null ? safeParseNavigationBar(global2.navigationBar) : null;
1191
- const initialAccessoryButton = parsedNavigationBar?.initialAccessoryButton;
1192
- return /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(import_jsx_runtime8.Fragment, { children: [
1193
- /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_tds_react_native9.PageNavbar, { preference: { type: "none" } }),
1194
- /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
1224
+ return /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(import_jsx_runtime9.Fragment, { children: [
1225
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_tds_react_native9.PageNavbar, { preference: { type: "none" } }),
1226
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
1195
1227
  import_react_native19.View,
1196
1228
  {
1197
1229
  style: {
@@ -1207,10 +1239,10 @@ function GameNavigationBar() {
1207
1239
  paddingRight: safeAreaRight + 10
1208
1240
  },
1209
1241
  pointerEvents: "box-none",
1210
- children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
1242
+ children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
1211
1243
  import_private6.NavigationRightContent,
1212
1244
  {
1213
- fixedRightButton: initialAccessoryButton,
1245
+ fixedRightButton: navigationRightButton,
1214
1246
  onPressDots: openMoreButtonBottomSheet,
1215
1247
  onPressClose: navigationEvent.handleCloseButtonClick,
1216
1248
  theme: "dark"
@@ -1234,20 +1266,20 @@ __reExport(bridge_entry_exports, require("@apps-in-toss/native-modules/constant-
1234
1266
  __reExport(bridge_entry_exports, require("@apps-in-toss/native-modules/event-bridges"));
1235
1267
 
1236
1268
  // src/components/RNAppContainer.tsx
1237
- var import_jsx_runtime9 = require("react/jsx-runtime");
1269
+ var import_jsx_runtime10 = require("react/jsx-runtime");
1238
1270
  function RNAppContainer({ children }) {
1239
1271
  const global2 = getAppsInTossGlobals();
1240
1272
  switch (global2.appType) {
1241
1273
  case "game":
1242
- return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(GameAppContainer, { children });
1274
+ return /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(GameAppContainer, { children });
1243
1275
  case "general":
1244
1276
  default:
1245
- return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(GeneralAppContainer, { children });
1277
+ return /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(GeneralAppContainer, { children });
1246
1278
  }
1247
1279
  }
1248
1280
  function GameAppContainer({ children }) {
1249
- const [isEntryMessageExited, setIsEntryMessageExited] = (0, import_react17.useState)(false);
1250
- (0, import_react17.useEffect)(() => {
1281
+ const [isEntryMessageExited, setIsEntryMessageExited] = (0, import_react18.useState)(false);
1282
+ (0, import_react18.useEffect)(() => {
1251
1283
  if (import_react_native20.Platform.OS === "ios") {
1252
1284
  (0, import_native_modules12.setIosSwipeGestureEnabled)({ isEnabled: false });
1253
1285
  return () => {
@@ -1256,48 +1288,48 @@ function GameAppContainer({ children }) {
1256
1288
  }
1257
1289
  return;
1258
1290
  }, []);
1259
- (0, import_react17.useEffect)(() => {
1291
+ (0, import_react18.useEffect)(() => {
1260
1292
  import_native_modules12.appsInTossEvent.addEventListener("entryMessageExited", {
1261
1293
  onEvent: () => {
1262
1294
  setIsEntryMessageExited(true);
1263
1295
  }
1264
1296
  });
1265
1297
  }, []);
1266
- return /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(import_jsx_runtime9.Fragment, { children: [
1267
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(RNNavigationBar.Game, {}),
1268
- (0, bridge_entry_exports.getOperationalEnvironment)() === "toss" ? /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(GameInitializer, { isReadyForProfileUI: isEntryMessageExited, children }) : children
1298
+ return /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)(import_jsx_runtime10.Fragment, { children: [
1299
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(RNNavigationBar.Game, {}),
1300
+ (0, bridge_entry_exports.getOperationalEnvironment)() === "toss" ? /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(GameInitializer, { isReadyForProfileUI: isEntryMessageExited, children }) : children
1269
1301
  ] });
1270
1302
  }
1271
1303
  function GeneralAppContainer({ children }) {
1272
- return /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(import_jsx_runtime9.Fragment, { children: [
1273
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(RNNavigationBar.Default, {}),
1304
+ return /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)(import_jsx_runtime10.Fragment, { children: [
1305
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(RNNavigationBar.Default, {}),
1274
1306
  children
1275
1307
  ] });
1276
1308
  }
1277
1309
 
1278
1310
  // src/core/registerApp.tsx
1279
- var import_jsx_runtime10 = require("react/jsx-runtime");
1311
+ var import_jsx_runtime11 = require("react/jsx-runtime");
1280
1312
  function AppsInTossContainer(Container, { children, ...initialProps }) {
1281
1313
  if (!(0, import_native_modules13.isMinVersionSupported)({
1282
1314
  android: "5.220.0",
1283
1315
  ios: "5.221.0"
1284
1316
  })) {
1285
- return /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)(import_jsx_runtime10.Fragment, { children: [
1286
- /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(AppEvent.Entry, {}),
1287
- /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(AppEvent.System, { ...initialProps }),
1288
- /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(AppUpdate, {})
1317
+ return /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)(import_jsx_runtime11.Fragment, { children: [
1318
+ /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(AppEvent.Entry, {}),
1319
+ /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(AppEvent.System, { ...initialProps }),
1320
+ /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(AppUpdate, {})
1289
1321
  ] });
1290
1322
  }
1291
- return /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)(import_jsx_runtime10.Fragment, { children: [
1292
- /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(AppEvent.StayTime, {}),
1293
- /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(AppEvent.Entry, {}),
1294
- /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(AppEvent.System, { ...initialProps }),
1295
- /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(Container, { ...initialProps, children: /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(import_tds_react_native10.TDSProvider, { colorPreference: "light", token: { color: { primary: getAppsInTossGlobals().brandPrimaryColor } }, children: /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(TDSContainer, { ...initialProps, children }) }) })
1323
+ return /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)(import_jsx_runtime11.Fragment, { children: [
1324
+ /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(AppEvent.StayTime, {}),
1325
+ /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(AppEvent.Entry, {}),
1326
+ /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(AppEvent.System, { ...initialProps }),
1327
+ /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(Container, { ...initialProps, children: /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(import_tds_react_native10.TDSProvider, { colorPreference: "light", token: { color: { primary: getAppsInTossGlobals().brandPrimaryColor } }, children: /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(TDSContainer, { ...initialProps, children }) }) })
1296
1328
  ] });
1297
1329
  }
1298
1330
  function TDSContainer({ children }) {
1299
1331
  useAppsInTossBridge();
1300
- return /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(import_jsx_runtime10.Fragment, { children });
1332
+ return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(import_jsx_runtime11.Fragment, { children });
1301
1333
  }
1302
1334
  function registerApp(container, { context, analytics }) {
1303
1335
  const appName = getAppName();
@@ -1324,7 +1356,7 @@ function registerApp(container, { context, analytics }) {
1324
1356
  }
1325
1357
  function AppsInTossScreenContainer({ children }) {
1326
1358
  const isRNApp = getAppsInTossGlobals().webViewType == null;
1327
- return /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(import_analytics.Analytics.Screen, { children: isRNApp ? /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(RNAppContainer, { children }) : children });
1359
+ return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(NavigationBarContextProvider, { children: /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(import_analytics.Analytics.Screen, { children: isRNApp ? /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(RNAppContainer, { children }) : children }) });
1328
1360
  }
1329
1361
  function getAppName() {
1330
1362
  try {
@@ -1348,13 +1380,13 @@ var appsInTossEventBridges = __toESM(require("@apps-in-toss/native-modules/event
1348
1380
  var import_react_native32 = require("@granite-js/react-native");
1349
1381
  var import_tds_react_native14 = require("@toss/tds-react-native");
1350
1382
  var import_private9 = require("@toss/tds-react-native/private");
1351
- var import_react27 = require("react");
1383
+ var import_react28 = require("react");
1352
1384
  var import_react_native33 = require("react-native");
1353
1385
 
1354
1386
  // src/components/GameWebView.tsx
1355
1387
  var import_native_modules14 = require("@apps-in-toss/native-modules");
1356
1388
  var import_react_native_webview = require("@granite-js/native/react-native-webview");
1357
- var import_react19 = require("react");
1389
+ var import_react20 = require("react");
1358
1390
  var import_react_native25 = require("react-native");
1359
1391
 
1360
1392
  // src/components/NavigationBar/GameWebviewNavigationBar.tsx
@@ -1363,9 +1395,9 @@ var import_react_native23 = require("@granite-js/react-native");
1363
1395
  var import_tds_react_native11 = require("@toss/tds-react-native");
1364
1396
  var import_private7 = require("@toss/tds-react-native/private");
1365
1397
  var import_es_hangul3 = require("es-hangul");
1366
- var import_react18 = require("react");
1398
+ var import_react19 = require("react");
1367
1399
  var import_react_native24 = require("react-native");
1368
- var import_jsx_runtime11 = require("react/jsx-runtime");
1400
+ var import_jsx_runtime12 = require("react/jsx-runtime");
1369
1401
  function GameWebviewNavigationBar() {
1370
1402
  const safeAreaTop = (0, import_private7.useSafeAreaTop)();
1371
1403
  const { openConfirm } = (0, import_tds_react_native11.useDialog)();
@@ -1373,10 +1405,9 @@ function GameWebviewNavigationBar() {
1373
1405
  const global2 = getAppsInTossGlobals();
1374
1406
  const logging = useNavigationBarLogging();
1375
1407
  const { open: openMoreButtonBottomSheet } = useMoreButtonBottomSheet();
1408
+ const { navigationRightButton } = useNavigationBarContext();
1376
1409
  const { right: safeAreaRight } = (0, import_react_native_safe_area_context2.useSafeAreaInsets)();
1377
- const parsedNavigationBar = global2.navigationBar != null ? safeParseNavigationBar(global2.navigationBar) : null;
1378
- const initialAccessoryButton = parsedNavigationBar?.initialAccessoryButton;
1379
- const handleGameWebviewClose = (0, import_react18.useCallback)(async () => {
1410
+ const handleGameWebviewClose = (0, import_react19.useCallback)(async () => {
1380
1411
  logging.closeButtonClick();
1381
1412
  const isConfirmed = await openConfirm({
1382
1413
  title: `${(0, import_es_hangul3.josa)(global2.brandDisplayName, "\uC744/\uB97C")} \uC885\uB8CC\uD560\uAE4C\uC694?`,
@@ -1391,9 +1422,9 @@ function GameWebviewNavigationBar() {
1391
1422
  (0, import_react_native23.closeView)();
1392
1423
  }
1393
1424
  }, [captureExitLog, global2.brandDisplayName, logging, openConfirm]);
1394
- return /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)(import_jsx_runtime11.Fragment, { children: [
1395
- /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(import_tds_react_native11.PageNavbar, { preference: { type: "none" } }),
1396
- /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
1425
+ return /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)(import_jsx_runtime12.Fragment, { children: [
1426
+ /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(import_tds_react_native11.PageNavbar, { preference: { type: "none" } }),
1427
+ /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
1397
1428
  import_react_native24.View,
1398
1429
  {
1399
1430
  style: {
@@ -1409,10 +1440,10 @@ function GameWebviewNavigationBar() {
1409
1440
  paddingRight: safeAreaRight + 10
1410
1441
  },
1411
1442
  pointerEvents: "box-none",
1412
- children: /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
1443
+ children: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
1413
1444
  import_private7.NavigationRightContent,
1414
1445
  {
1415
- fixedRightButton: initialAccessoryButton,
1446
+ fixedRightButton: navigationRightButton,
1416
1447
  onPressDots: openMoreButtonBottomSheet,
1417
1448
  onPressClose: () => {
1418
1449
  handleGameWebviewClose();
@@ -1426,10 +1457,10 @@ function GameWebviewNavigationBar() {
1426
1457
  }
1427
1458
 
1428
1459
  // src/components/GameWebView.tsx
1429
- var import_jsx_runtime12 = require("react/jsx-runtime");
1430
- var GameWebView = (0, import_react19.forwardRef)(function GameWebView2(props, ref) {
1431
- const [isEntryMessageExited, setIsEntryMessageExited] = (0, import_react19.useState)(false);
1432
- (0, import_react19.useEffect)(() => {
1460
+ var import_jsx_runtime13 = require("react/jsx-runtime");
1461
+ var GameWebView = (0, import_react20.forwardRef)(function GameWebView2(props, ref) {
1462
+ const [isEntryMessageExited, setIsEntryMessageExited] = (0, import_react20.useState)(false);
1463
+ (0, import_react20.useEffect)(() => {
1433
1464
  if (import_react_native25.Platform.OS === "ios") {
1434
1465
  (0, import_native_modules14.setIosSwipeGestureEnabled)({ isEnabled: false });
1435
1466
  return () => {
@@ -1438,30 +1469,30 @@ var GameWebView = (0, import_react19.forwardRef)(function GameWebView2(props, re
1438
1469
  }
1439
1470
  return;
1440
1471
  }, []);
1441
- (0, import_react19.useEffect)(() => {
1472
+ (0, import_react20.useEffect)(() => {
1442
1473
  import_native_modules14.appsInTossEvent.addEventListener("entryMessageExited", {
1443
1474
  onEvent: () => {
1444
1475
  setIsEntryMessageExited(true);
1445
1476
  }
1446
1477
  });
1447
1478
  }, []);
1448
- return /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)(import_jsx_runtime12.Fragment, { children: [
1449
- /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(GameWebviewNavigationBar, {}),
1450
- (0, import_native_modules14.getOperationalEnvironment)() === "toss" ? /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(GameInitializer, { isReadyForProfileUI: isEntryMessageExited, children: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(import_react_native_webview.WebView, { ref, ...props }) }) : /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(import_react_native_webview.WebView, { ref, ...props })
1479
+ return /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)(import_jsx_runtime13.Fragment, { children: [
1480
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(GameWebviewNavigationBar, {}),
1481
+ (0, import_native_modules14.getOperationalEnvironment)() === "toss" ? /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(GameInitializer, { isReadyForProfileUI: isEntryMessageExited, children: /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_react_native_webview.WebView, { ref, ...props }) }) : /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_react_native_webview.WebView, { ref, ...props })
1451
1482
  ] });
1452
1483
  });
1453
1484
 
1454
1485
  // src/components/PartnerWebView.tsx
1455
1486
  var import_react_native_webview2 = require("@granite-js/native/react-native-webview");
1456
- var import_react21 = require("react");
1487
+ var import_react22 = require("react");
1457
1488
 
1458
1489
  // src/components/NavigationBar/PartnerWebviewNavigationBar.tsx
1459
1490
  var import_react_native26 = require("@granite-js/react-native");
1460
1491
  var import_tds_react_native12 = require("@toss/tds-react-native");
1461
1492
  var import_private8 = require("@toss/tds-react-native/private");
1462
1493
  var import_es_hangul4 = require("es-hangul");
1463
- var import_react20 = require("react");
1464
- var import_jsx_runtime13 = require("react/jsx-runtime");
1494
+ var import_react21 = require("react");
1495
+ var import_jsx_runtime14 = require("react/jsx-runtime");
1465
1496
  function PartnerWebviewNavigationBar({ onBackButtonClick, onHomeButtonClick }) {
1466
1497
  const globals = getAppsInTossGlobals();
1467
1498
  const { captureExitLog } = useCaptureExitLog();
@@ -1471,8 +1502,8 @@ function PartnerWebviewNavigationBar({ onBackButtonClick, onHomeButtonClick }) {
1471
1502
  const parsedNavigationBar = globals.navigationBar != null ? safeParseNavigationBar(globals.navigationBar) : null;
1472
1503
  const withHomeButton = parsedNavigationBar?.withHomeButton ?? false;
1473
1504
  const withBackButton = parsedNavigationBar?.withBackButton ?? true;
1474
- const initialAccessoryButton = parsedNavigationBar?.initialAccessoryButton;
1475
- const handleClose = (0, import_react20.useCallback)(async () => {
1505
+ const { navigationRightButton } = useNavigationBarContext();
1506
+ const handleClose = (0, import_react21.useCallback)(async () => {
1476
1507
  logging.closeButtonClick();
1477
1508
  const isConfirmed = await openConfirm({
1478
1509
  title: `${(0, import_es_hangul4.josa)(globals.brandDisplayName, "\uC744/\uB97C")} \uC885\uB8CC\uD560\uAE4C\uC694?`,
@@ -1487,7 +1518,7 @@ function PartnerWebviewNavigationBar({ onBackButtonClick, onHomeButtonClick }) {
1487
1518
  (0, import_react_native26.closeView)();
1488
1519
  }
1489
1520
  }, [captureExitLog, globals.brandDisplayName, logging, openConfirm]);
1490
- return /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(NavigationBarImpressionArea, { withHomeButton, children: /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
1521
+ return /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(NavigationBarImpressionArea, { withHomeButton, children: /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
1491
1522
  import_private8.TopNavigation,
1492
1523
  {
1493
1524
  title: globals.brandDisplayName,
@@ -1497,23 +1528,23 @@ function PartnerWebviewNavigationBar({ onBackButtonClick, onHomeButtonClick }) {
1497
1528
  onPressTitle: withHomeButton ? onHomeButtonClick : void 0,
1498
1529
  onPressClose: handleClose,
1499
1530
  withHome: withHomeButton,
1500
- fixedRightButton: initialAccessoryButton,
1501
- children: /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_private8.NavigationLeft, { visible: withBackButton, children: /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_private8.NavigationBackButton, { onPress: onBackButtonClick, canGoBack: false }) })
1531
+ fixedRightButton: navigationRightButton,
1532
+ children: /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(import_private8.NavigationLeft, { visible: withBackButton, children: /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(import_private8.NavigationBackButton, { onPress: onBackButtonClick, canGoBack: false }) })
1502
1533
  }
1503
1534
  ) });
1504
1535
  }
1505
1536
 
1506
1537
  // src/components/PartnerWebView.tsx
1507
- var import_jsx_runtime14 = require("react/jsx-runtime");
1508
- var PartnerWebView = (0, import_react21.forwardRef)(function PartnerWebViewScreen({ onBackButtonClick, onHomeButtonClick, ...webViewProps }, ref) {
1509
- return /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)(import_jsx_runtime14.Fragment, { children: [
1510
- /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(PartnerWebviewNavigationBar, { onBackButtonClick, onHomeButtonClick }),
1511
- /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(import_react_native_webview2.WebView, { ref, ...webViewProps, style: { flex: 1 } })
1538
+ var import_jsx_runtime15 = require("react/jsx-runtime");
1539
+ var PartnerWebView = (0, import_react22.forwardRef)(function PartnerWebViewScreen({ onBackButtonClick, onHomeButtonClick, ...webViewProps }, ref) {
1540
+ return /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)(import_jsx_runtime15.Fragment, { children: [
1541
+ /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(PartnerWebviewNavigationBar, { onBackButtonClick, onHomeButtonClick }),
1542
+ /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(import_react_native_webview2.WebView, { ref, ...webViewProps, style: { flex: 1 } })
1512
1543
  ] });
1513
1544
  });
1514
1545
 
1515
1546
  // src/bridge-handler/useBridgeHandler.tsx
1516
- var import_react22 = require("react");
1547
+ var import_react23 = require("react");
1517
1548
  function serializeError(error) {
1518
1549
  return JSON.stringify(error, (_, value) => {
1519
1550
  if (value instanceof Error) {
@@ -1563,25 +1594,20 @@ function useBridgeHandler({
1563
1594
  onMessage,
1564
1595
  constantHandlerMap,
1565
1596
  asyncHandlerMap,
1566
- eventListenerMap,
1567
- injectedJavaScript: originalInjectedJavaScript
1597
+ eventListenerMap
1568
1598
  }) {
1569
- const ref = (0, import_react22.useRef)(null);
1570
- const injectedJavaScript = (0, import_react22.useMemo)(
1571
- () => [
1572
- `window.__CONSTANT_HANDLER_MAP = ${JSON.stringify(
1573
- Object.entries(constantHandlerMap).reduce(
1574
- (acc, [key, value]) => {
1575
- acc[key] = typeof value === "function" ? value() : value;
1576
- return acc;
1577
- },
1578
- {}
1579
- )
1580
- )};`,
1581
- originalInjectedJavaScript,
1582
- "true"
1583
- ].join("\n"),
1584
- [constantHandlerMap, originalInjectedJavaScript]
1599
+ const ref = (0, import_react23.useRef)(null);
1600
+ const injectedJavaScript = (0, import_react23.useMemo)(
1601
+ () => `window.__CONSTANT_HANDLER_MAP = ${JSON.stringify(
1602
+ Object.entries(constantHandlerMap).reduce(
1603
+ (acc, [key, value]) => {
1604
+ acc[key] = typeof value === "function" ? value() : value;
1605
+ return acc;
1606
+ },
1607
+ {}
1608
+ )
1609
+ )};`,
1610
+ [constantHandlerMap]
1585
1611
  );
1586
1612
  const createHandleOnEvent = (functionName, eventId) => (response) => {
1587
1613
  ref.current?.injectJavaScript(`
@@ -1594,10 +1620,10 @@ function useBridgeHandler({
1594
1620
  window.__GRANITE_NATIVE_EMITTER.emit('${functionName}/onError/${eventId}', ${serializedError});
1595
1621
  `);
1596
1622
  };
1597
- const $onMessage = (0, import_react22.useCallback)(
1623
+ const $onMessage = (0, import_react23.useCallback)(
1598
1624
  async (e) => {
1599
1625
  onMessage?.(e);
1600
- const data = JSON.parse(e.nativeEvent.data);
1626
+ const data = parseNativeEventData(e.nativeEvent.data);
1601
1627
  if (typeof data !== "object" || data === null || typeof data.functionName !== "string" || typeof data.eventId !== "string" || typeof data.type !== "string" || !["addEventListener", "removeEventListener", "method"].includes(data.type)) {
1602
1628
  return;
1603
1629
  }
@@ -1643,15 +1669,23 @@ function useBridgeHandler({
1643
1669
  onMessage: $onMessage
1644
1670
  };
1645
1671
  }
1672
+ function parseNativeEventData(data) {
1673
+ try {
1674
+ return JSON.parse(data);
1675
+ } catch (error) {
1676
+ console.error(error);
1677
+ return null;
1678
+ }
1679
+ }
1646
1680
 
1647
1681
  // src/core/hooks/useWebBackHandler.tsx
1648
1682
  var import_react_native27 = require("@granite-js/react-native");
1649
1683
  var import_tds_react_native13 = require("@toss/tds-react-native");
1650
1684
  var import_es_hangul5 = require("es-hangul");
1651
- var import_react24 = require("react");
1685
+ var import_react25 = require("react");
1652
1686
 
1653
1687
  // src/hooks/useWebviewHistoryStack.tsx
1654
- var import_react23 = require("react");
1688
+ var import_react24 = require("react");
1655
1689
  var INITIAL_STATE = { stack: [], index: -1 };
1656
1690
  function reducer(state, action) {
1657
1691
  switch (action.type) {
@@ -1682,11 +1716,11 @@ function reducer(state, action) {
1682
1716
  }
1683
1717
  }
1684
1718
  function useWebViewHistory() {
1685
- const [state, dispatch] = (0, import_react23.useReducer)(reducer, INITIAL_STATE);
1686
- const onNavigationStateChange = (0, import_react23.useCallback)(({ url, canGoForward: canGoForward2 }) => {
1719
+ const [state, dispatch] = (0, import_react24.useReducer)(reducer, INITIAL_STATE);
1720
+ const onNavigationStateChange = (0, import_react24.useCallback)(({ url, canGoForward: canGoForward2 }) => {
1687
1721
  dispatch({ type: "NAVIGATION_CHANGE", url, canGoForward: canGoForward2 });
1688
1722
  }, []);
1689
- const { canGoBack, canGoForward } = (0, import_react23.useMemo)(() => {
1723
+ const { canGoBack, canGoForward } = (0, import_react24.useMemo)(() => {
1690
1724
  const canBack = state.index > 0;
1691
1725
  const canFwd = state.index >= 0 && state.index < state.stack.length - 1;
1692
1726
  return { canGoBack: canBack, canGoForward: canFwd };
@@ -1719,19 +1753,19 @@ function useWebBackHandler(webViewRef) {
1719
1753
  const logging = useNavigationBarLogging();
1720
1754
  const { openConfirm } = (0, import_tds_react_native13.useDialog)();
1721
1755
  const global2 = getAppsInTossGlobals();
1722
- const addEventListener = (0, import_react24.useCallback)(
1756
+ const addEventListener = (0, import_react25.useCallback)(
1723
1757
  (handler) => {
1724
1758
  addWebBackEventListener(handler);
1725
1759
  },
1726
1760
  [addWebBackEventListener]
1727
1761
  );
1728
- const removeEventListener = (0, import_react24.useCallback)(
1762
+ const removeEventListener = (0, import_react25.useCallback)(
1729
1763
  (handler) => {
1730
1764
  removeWebBackEventListener(handler);
1731
1765
  },
1732
1766
  [removeWebBackEventListener]
1733
1767
  );
1734
- const handleWebBack = (0, import_react24.useCallback)(async () => {
1768
+ const handleWebBack = (0, import_react25.useCallback)(async () => {
1735
1769
  if (hasWebBackEvent) {
1736
1770
  for (const handler of webBackHandlersRef) {
1737
1771
  handler();
@@ -1764,7 +1798,7 @@ function useWebBackHandler(webViewRef) {
1764
1798
  openConfirm,
1765
1799
  webViewRef
1766
1800
  ]);
1767
- const handleWebHome = (0, import_react24.useCallback)(() => {
1801
+ const handleWebHome = (0, import_react25.useCallback)(() => {
1768
1802
  logging.homeButtonClick();
1769
1803
  if (hasWebBackEvent) {
1770
1804
  for (const handler of webBackHandlersRef) {
@@ -1774,7 +1808,7 @@ function useWebBackHandler(webViewRef) {
1774
1808
  }
1775
1809
  webViewRef.current?.injectJavaScript(HISTORY_HOME_SCRIPT);
1776
1810
  }, [hasWebBackEvent, webBackHandlersRef, logging, webViewRef]);
1777
- return (0, import_react24.useMemo)(
1811
+ return (0, import_react25.useMemo)(
1778
1812
  () => ({ addEventListener, removeEventListener, handleWebBack, handleWebHome, onNavigationStateChange }),
1779
1813
  [addEventListener, removeEventListener, handleWebBack, handleWebHome, onNavigationStateChange]
1780
1814
  );
@@ -1952,11 +1986,11 @@ function useCreateUserAgent({
1952
1986
  // src/hooks/useGeolocation.ts
1953
1987
  var import_native_modules16 = require("@apps-in-toss/native-modules");
1954
1988
  var import_react_native29 = require("@granite-js/react-native");
1955
- var import_react25 = require("react");
1989
+ var import_react26 = require("react");
1956
1990
  function useGeolocation({ accuracy, distanceInterval, timeInterval }) {
1957
1991
  const isVisible = (0, import_react_native29.useVisibility)();
1958
- const [location, setLocation] = (0, import_react25.useState)(null);
1959
- (0, import_react25.useEffect)(() => {
1992
+ const [location, setLocation] = (0, import_react26.useState)(null);
1993
+ (0, import_react26.useEffect)(() => {
1960
1994
  if (!isVisible) {
1961
1995
  return;
1962
1996
  }
@@ -1975,11 +2009,11 @@ function useGeolocation({ accuracy, distanceInterval, timeInterval }) {
1975
2009
 
1976
2010
  // src/hooks/useWaitForReturnNavigator.tsx
1977
2011
  var import_react_native30 = require("@granite-js/react-native");
1978
- var import_react26 = require("react");
2012
+ var import_react27 = require("react");
1979
2013
  function useWaitForReturnNavigator() {
1980
- const callbacks = (0, import_react26.useRef)([]).current;
2014
+ const callbacks = (0, import_react27.useRef)([]).current;
1981
2015
  const navigation = (0, import_react_native30.useNavigation)();
1982
- const startNavigating = (0, import_react26.useCallback)(
2016
+ const startNavigating = (0, import_react27.useCallback)(
1983
2017
  (route, params) => {
1984
2018
  return new Promise((resolve) => {
1985
2019
  callbacks.push(resolve);
@@ -1988,7 +2022,7 @@ function useWaitForReturnNavigator() {
1988
2022
  },
1989
2023
  [callbacks, navigation]
1990
2024
  );
1991
- const handleVisibilityChange = (0, import_react26.useCallback)(
2025
+ const handleVisibilityChange = (0, import_react27.useCallback)(
1992
2026
  (state) => {
1993
2027
  if (state === "visible" && callbacks.length > 0) {
1994
2028
  for (const callback of callbacks) {
@@ -2003,6 +2037,15 @@ function useWaitForReturnNavigator() {
2003
2037
  return startNavigating;
2004
2038
  }
2005
2039
 
2040
+ // src/hooks/useTopNavigation.tsx
2041
+ function useTopNavigation() {
2042
+ const { addNavigationRightButton, removeNavigationRightButton } = useNavigationBarContext();
2043
+ return {
2044
+ addAccessoryButton: addNavigationRightButton,
2045
+ removeAccessoryButton: removeNavigationRightButton
2046
+ };
2047
+ }
2048
+
2006
2049
  // src/utils/log.ts
2007
2050
  var import_native_modules17 = require("@apps-in-toss/native-modules");
2008
2051
  var import_react_native31 = require("@granite-js/react-native");
@@ -2053,7 +2096,7 @@ var trackScreen = (url) => {
2053
2096
  };
2054
2097
 
2055
2098
  // src/components/WebView.tsx
2056
- var import_jsx_runtime15 = require("react/jsx-runtime");
2099
+ var import_jsx_runtime16 = require("react/jsx-runtime");
2057
2100
  var operationalEnvironment = appsInTossConstantBridges.getOperationalEnvironment();
2058
2101
  var TYPES = ["partner", "external", "game"];
2059
2102
  var WEBVIEW_TYPES = {
@@ -2087,26 +2130,18 @@ function WebView({ type, local, onMessage, ...props }) {
2087
2130
  if (!TYPES.includes(type)) {
2088
2131
  throw new Error(`Invalid WebView type: '${type}'`);
2089
2132
  }
2090
- const webViewRef = (0, import_react27.useRef)(null);
2133
+ const webViewRef = (0, import_react28.useRef)(null);
2091
2134
  const webBackHandler = useWebBackHandler(webViewRef);
2092
- const uri = (0, import_react27.useMemo)(() => getWebViewUri(local), [local]);
2135
+ const uri = (0, import_react28.useMemo)(() => getWebViewUri(local), [local]);
2093
2136
  const top = (0, import_private9.useSafeAreaTop)();
2094
2137
  const bottom = (0, import_private9.useSafeAreaBottom)();
2095
2138
  const global2 = getAppsInTossGlobals();
2096
- const topNavigation = (0, import_private9.useTopNavigation)();
2097
- const disableTextSelectionCSS = `
2098
- (function() {
2099
- const style = document.createElement('style');
2100
- style.textContent = '*:not(input):not(textarea) { -webkit-user-select: none; -moz-user-select: none; -ms-user-select: none; user-select: none; -webkit-touch-callout: none; }';
2101
- document.head.appendChild(style);
2102
- })();
2103
- `;
2104
- const [allowsBackForwardNavigationGestures, setAllowsBackForwardNavigationGestures] = (0, import_react27.useState)(
2139
+ const navigationBarContext = useNavigationBarContext();
2140
+ const [allowsBackForwardNavigationGestures, setAllowsBackForwardNavigationGestures] = (0, import_react28.useState)(
2105
2141
  props.allowsBackForwardNavigationGestures
2106
2142
  );
2107
2143
  const handler = useBridgeHandler({
2108
2144
  onMessage,
2109
- injectedJavaScript: [disableTextSelectionCSS].join("\n"),
2110
2145
  // eslint-disable-next-line @typescript-eslint/ban-ts-comment
2111
2146
  eventListenerMap: {
2112
2147
  ...appsInTossEventBridges,
@@ -2155,8 +2190,8 @@ function WebView({ type, local, onMessage, ...props }) {
2155
2190
  setAllowsBackForwardNavigationGestures(options.isEnabled);
2156
2191
  return appsInTossAsyncBridges.setIosSwipeGestureEnabled(options);
2157
2192
  },
2158
- addAccessoryButton: async (params) => topNavigation.addAccessoryButton(params),
2159
- removeAccessoryButton: async () => topNavigation.removeAccessoryButton(),
2193
+ addAccessoryButton: async (params) => navigationBarContext.addNavigationRightButton(params),
2194
+ removeAccessoryButton: async () => navigationBarContext.removeNavigationRightButton(),
2160
2195
  /** permissions */
2161
2196
  requestPermission: appsInTossAsyncBridges.requestPermission,
2162
2197
  openPermissionDialog: appsInTossAsyncBridges.openPermissionDialog,
@@ -2181,7 +2216,7 @@ function WebView({ type, local, onMessage, ...props }) {
2181
2216
  completeProductGrant: import_native_modules18.IAP.completeProductGrant
2182
2217
  }
2183
2218
  });
2184
- const headerPropForExternalWebView = (0, import_react27.useMemo)(() => {
2219
+ const headerPropForExternalWebView = (0, import_react28.useMemo)(() => {
2185
2220
  const parsedNavigationBar = global2.navigationBar != null ? safeParseNavigationBar(global2.navigationBar) : null;
2186
2221
  const initialAccessoryButton = parsedNavigationBar?.initialAccessoryButton;
2187
2222
  const withBackButton = parsedNavigationBar?.withBackButton ?? true;
@@ -2202,7 +2237,7 @@ function WebView({ type, local, onMessage, ...props }) {
2202
2237
  colorPreference: "light"
2203
2238
  });
2204
2239
  const refs = mergeRefs(handler.ref, webViewRef);
2205
- (0, import_react27.useEffect)(() => {
2240
+ (0, import_react28.useEffect)(() => {
2206
2241
  const callback = () => {
2207
2242
  webBackHandler.handleWebBack();
2208
2243
  return true;
@@ -2210,7 +2245,8 @@ function WebView({ type, local, onMessage, ...props }) {
2210
2245
  import_react_native33.BackHandler.addEventListener("hardwareBackPress", callback);
2211
2246
  return () => import_react_native33.BackHandler.removeEventListener("hardwareBackPress", callback);
2212
2247
  }, [webBackHandler]);
2213
- return /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
2248
+ const globalScripts = useGlobalScripts();
2249
+ return /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
2214
2250
  BaseWebView,
2215
2251
  {
2216
2252
  ref: refs,
@@ -2237,13 +2273,78 @@ function WebView({ type, local, onMessage, ...props }) {
2237
2273
  webviewDebuggingEnabled: webViewDebuggingEnabled,
2238
2274
  thirdPartyCookiesEnabled: true,
2239
2275
  onMessage: handler.onMessage,
2240
- injectedJavaScript: handler.injectedJavaScript,
2241
- injectedJavaScriptBeforeContentLoaded: handler.injectedJavaScript,
2276
+ injectedJavaScript: globalScripts.afterLoad,
2277
+ injectedJavaScriptBeforeContentLoaded: mergeScripts(handler.injectedJavaScript, globalScripts.beforeLoad),
2242
2278
  decelerationRate: import_react_native33.Platform.OS === "ios" ? 1 : void 0,
2243
2279
  allowsBackForwardNavigationGestures
2244
2280
  }
2245
2281
  );
2246
2282
  }
2283
+ function useGlobalScripts() {
2284
+ const global2 = getAppsInTossGlobals();
2285
+ const disableTextSelectionCSS = `
2286
+ const style = document.createElement('style');
2287
+ style.textContent = '*:not(input):not(textarea) { -webkit-user-select: none; -moz-user-select: none; -ms-user-select: none; user-select: none; -webkit-touch-callout: none; }';
2288
+ document.head.appendChild(style);
2289
+ `;
2290
+ const applyGameResourcesCache = `
2291
+ (function () {
2292
+ if (typeof caches === 'undefined') {
2293
+ return;
2294
+ }
2295
+ const cacheKeyPrefix = '@apps-in-toss/caches/';
2296
+ const cacheKey = \`\${cacheKeyPrefix}${global2.deploymentId}\`;
2297
+ window.addEventListener('load', async () => {
2298
+ const keys = await caches.keys();
2299
+ for (const key of keys) {
2300
+ if (key.startsWith(cacheKeyPrefix) && key !== cacheKey) {
2301
+ await caches.delete(key);
2302
+ }
2303
+ }
2304
+ });
2305
+ window.fetch = new Proxy(window.fetch, {
2306
+ async apply(originalFetch, thisArg, args) {
2307
+ const request = new Request(args[0], args[1]);
2308
+ if (!/\\.(data|wasm|framework\\.js)(?:\\.gz|\\.br|\\.unityweb)?$/.test(request.url)) {
2309
+ return await originalFetch.call(thisArg, request);
2310
+ }
2311
+ const cache = await caches.open(cacheKey);
2312
+ const cached = await cache.match(request);
2313
+ if (cached) {
2314
+ const eTag = cached.headers.get('ETag');
2315
+ const lastModified = cached.headers.get('Last-Modified');
2316
+ if (eTag) {
2317
+ request.headers.set('If-None-Match', eTag);
2318
+ }
2319
+ if (lastModified) {
2320
+ request.headers.set('If-Modified-Since', lastModified);
2321
+ }
2322
+ const revalidated = await originalFetch.call(thisArg, request);
2323
+ if (revalidated.status === 304) {
2324
+ return cached;
2325
+ }
2326
+ cache.put(request, revalidated.clone());
2327
+ return revalidated;
2328
+ }
2329
+ const response = await originalFetch.call(thisArg, request);
2330
+ cache.put(request, response.clone());
2331
+ return response;
2332
+ },
2333
+ });
2334
+ })();
2335
+ `;
2336
+ return {
2337
+ beforeLoad: mergeScripts(
2338
+ global2.webViewType === "game" && applyGameResourcesCache
2339
+ ),
2340
+ afterLoad: mergeScripts(
2341
+ disableTextSelectionCSS
2342
+ )
2343
+ };
2344
+ }
2345
+ function mergeScripts(...scripts) {
2346
+ return scripts.filter((script) => typeof script === "string").join("\n");
2347
+ }
2247
2348
 
2248
2349
  // src/index.ts
2249
2350
  __reExport(src_exports, require("@apps-in-toss/analytics"), module.exports);