@apps-in-toss/framework 0.0.34 → 0.0.36

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.js CHANGED
@@ -10,17 +10,34 @@ import { Analytics as InternalAnalytics } from "@apps-in-toss/analytics";
10
10
  // src/core/registerApp.tsx
11
11
  import { Analytics } from "@apps-in-toss/analytics";
12
12
  import { TDSProvider } from "@toss-design-system/react-native";
13
- import { Bedrock as Bedrock2 } from "react-native-bedrock";
13
+ import { Bedrock as Bedrock3 } from "react-native-bedrock";
14
14
 
15
15
  // src/core/components/AppEvent.tsx
16
- import { useEffect } from "react";
17
- import { Bedrock, getSchemeUri as getSchemeUri2 } from "react-native-bedrock";
16
+ import { useEffect as useEffect2 } from "react";
17
+ import { Bedrock as Bedrock2, getSchemeUri as getSchemeUri3, useVisibility as useVisibility2 } from "react-native-bedrock";
18
18
 
19
19
  // src/env.ts
20
20
  var env = {
21
21
  getDeploymentId: () => __DEV__ ? "local" : global.__appsInToss?.deploymentId
22
22
  };
23
23
 
24
+ // src/hooks/useCaptureExitLog.ts
25
+ import { useCallback, useEffect, useRef } from "react";
26
+ import { Bedrock, useVisibility } from "react-native-bedrock";
27
+
28
+ // src/core/hooks/useReferrer.ts
29
+ import { useMemo } from "react";
30
+ import { getSchemeUri } from "react-native-bedrock";
31
+ function useReferrer() {
32
+ return useMemo(() => {
33
+ try {
34
+ return new URL(getSchemeUri()).searchParams.get("referrer");
35
+ } catch {
36
+ return null;
37
+ }
38
+ }, []);
39
+ }
40
+
24
41
  // src/native-modules/tossCore.ts
25
42
  import { NativeModules as NativeModules2 } from "react-native";
26
43
 
@@ -142,21 +159,8 @@ function tossCoreEventLog(params) {
142
159
  });
143
160
  }
144
161
 
145
- // src/core/hooks/useReferrer.ts
146
- import { useMemo } from "react";
147
- import { getSchemeUri } from "react-native-bedrock";
148
- function useReferrer() {
149
- return useMemo(() => {
150
- try {
151
- return new URL(getSchemeUri()).searchParams.get("referrer");
152
- } catch {
153
- return null;
154
- }
155
- }, []);
156
- }
157
-
158
- // src/core/components/AppEvent.tsx
159
- var ENTRY_APP_EVENT_SCHEMA_ID = 1562181;
162
+ // src/utils/isPrivateScheme.ts
163
+ import { getSchemeUri as getSchemeUri2 } from "react-native-bedrock";
160
164
  function isPrivateScheme() {
161
165
  try {
162
166
  return new URL(getSchemeUri2()).protocol === "intoss-private:";
@@ -164,9 +168,51 @@ function isPrivateScheme() {
164
168
  return false;
165
169
  }
166
170
  }
171
+
172
+ // src/hooks/useCaptureExitLog.ts
173
+ var EXIT_IMPRESSION_LOG_NAME = "appsintoss_app_visit__common_module::impression__stay_time";
174
+ var EXIT_IMPRESSION_SCHEMA_ID = 1631628;
175
+ function useCaptureExitLog() {
176
+ const referrer = useReferrer();
177
+ const visible = useVisibility();
178
+ const enterTime = useRef(void 0);
179
+ useEffect(() => {
180
+ if (visible === true) {
181
+ enterTime.current = Date.now();
182
+ }
183
+ }, [visible]);
184
+ const captureExitLog = useCallback(
185
+ (exitTime) => {
186
+ if (enterTime.current == null) {
187
+ return;
188
+ }
189
+ const stayTime = Math.floor(exitTime - enterTime.current);
190
+ tossCoreEventLog({
191
+ log_name: EXIT_IMPRESSION_LOG_NAME,
192
+ log_type: "event",
193
+ params: {
194
+ schema_id: EXIT_IMPRESSION_SCHEMA_ID,
195
+ event_type: "impression",
196
+ referrer,
197
+ deployment_id: env.getDeploymentId(),
198
+ app_name: Bedrock.appName,
199
+ is_private: isPrivateScheme(),
200
+ stay_time: stayTime.toString(),
201
+ exit_time: exitTime.toString()
202
+ }
203
+ });
204
+ enterTime.current = void 0;
205
+ },
206
+ [referrer]
207
+ );
208
+ return { captureExitLog };
209
+ }
210
+
211
+ // src/core/components/AppEvent.tsx
212
+ var ENTRY_APP_EVENT_SCHEMA_ID = 1562181;
167
213
  function EntryAppEvent() {
168
214
  const referrer = useReferrer() ?? "";
169
- useEffect(() => {
215
+ useEffect2(() => {
170
216
  tossCoreEventLog({
171
217
  log_name: "appsintoss_app_visit::impression__enter_appsintoss",
172
218
  log_type: "info",
@@ -175,7 +221,7 @@ function EntryAppEvent() {
175
221
  schema_id: ENTRY_APP_EVENT_SCHEMA_ID,
176
222
  referrer,
177
223
  deployment_id: env.getDeploymentId(),
178
- app_name: Bedrock.appName,
224
+ app_name: Bedrock2.appName,
179
225
  is_private: isPrivateScheme()
180
226
  }
181
227
  });
@@ -183,29 +229,40 @@ function EntryAppEvent() {
183
229
  return null;
184
230
  }
185
231
  function SystemAppEvent({ ...initialProps }) {
186
- useEffect(() => {
232
+ useEffect2(() => {
187
233
  tossCoreEventLog({
188
234
  log_name: "AppsInTossInitialProps",
189
235
  log_type: "debug",
190
236
  params: {
191
237
  ...initialProps,
192
- schemeUri: getSchemeUri2(),
238
+ schemeUri: getSchemeUri3(),
193
239
  deployment_id: env.getDeploymentId(),
194
- app_name: Bedrock.appName,
240
+ app_name: Bedrock2.appName,
195
241
  is_private: isPrivateScheme()
196
242
  }
197
243
  });
198
244
  }, [initialProps]);
199
245
  return null;
200
246
  }
247
+ function StayTimeAppEvent() {
248
+ const visible = useVisibility2();
249
+ const { captureExitLog } = useCaptureExitLog();
250
+ useEffect2(() => {
251
+ if (visible === false) {
252
+ captureExitLog(Date.now());
253
+ }
254
+ }, [visible, captureExitLog]);
255
+ return null;
256
+ }
201
257
  var AppEvent = {
202
258
  Entry: EntryAppEvent,
203
- System: SystemAppEvent
259
+ System: SystemAppEvent,
260
+ StayTime: StayTimeAppEvent
204
261
  };
205
262
 
206
263
  // src/core/hooks/useAppsInTossBridge.ts
207
264
  import { useBridge } from "@toss-design-system/react-native";
208
- import { useEffect as useEffect2 } from "react";
265
+ import { useEffect as useEffect3 } from "react";
209
266
 
210
267
  // src/native-event-emitter/appsInTossEvent.ts
211
268
  import { BedrockEvent } from "react-native-bedrock";
@@ -419,7 +476,7 @@ function toIcon(source) {
419
476
  function useAppsInTossBridge() {
420
477
  const controller = useBridge();
421
478
  const appsInTossGlobals2 = getAppsInTossGlobals();
422
- useEffect2(() => {
479
+ useEffect3(() => {
423
480
  const commonProps = {
424
481
  serviceName: appsInTossGlobals2.brandDisplayName,
425
482
  icon: toIcon(appsInTossGlobals2.brandIcon),
@@ -645,6 +702,7 @@ async function submitGameCenterLeaderBoardScore(params) {
645
702
  import { Fragment, jsx, jsxs } from "react/jsx-runtime";
646
703
  function AppsInTossContainer(Container, { children, ...initialProps }) {
647
704
  return /* @__PURE__ */ jsxs(Fragment, { children: [
705
+ /* @__PURE__ */ jsx(AppEvent.StayTime, {}),
648
706
  /* @__PURE__ */ jsx(AppEvent.Entry, {}),
649
707
  /* @__PURE__ */ jsx(AppEvent.System, { ...initialProps }),
650
708
  /* @__PURE__ */ jsx(Container, { ...initialProps, children: /* @__PURE__ */ jsx(TDSProvider, { colorPreference: "light", token: { color: { primary: getAppsInTossGlobals().brandPrimaryColor } }, children: /* @__PURE__ */ jsx(TDSContainer, { ...initialProps, children }) }) })
@@ -659,7 +717,7 @@ function registerApp(container, { context, analytics }) {
659
717
  logger: (params) => void eventLog(params),
660
718
  debug: analytics?.debug ?? __DEV__
661
719
  });
662
- return Bedrock2.registerApp(AppsInTossContainer.bind(null, container), {
720
+ return Bedrock3.registerApp(AppsInTossContainer.bind(null, container), {
663
721
  appName: getAppName(),
664
722
  context,
665
723
  router: {
@@ -854,6 +912,29 @@ var Storage = {
854
912
  clearItems
855
913
  };
856
914
 
915
+ // src/native-modules/contactsViral.ts
916
+ function contactsViral(params) {
917
+ const isSupported = isMinVersionSupported({
918
+ android: "5.223.0",
919
+ ios: "5.223.0"
920
+ });
921
+ if (!isSupported) {
922
+ return () => {
923
+ };
924
+ }
925
+ const { onEvent, onError, options } = params;
926
+ const unregisterCallbacks = INTERNAL__appBridgeHandler.invokeAppBridgeMethod("contactsViral", options, {
927
+ onRewardFromContactsViral: (result) => {
928
+ onEvent({ type: "sendViral", data: result });
929
+ },
930
+ onSuccess: (result) => {
931
+ onEvent({ type: "close", data: result });
932
+ },
933
+ onError
934
+ });
935
+ return unregisterCallbacks;
936
+ }
937
+
857
938
  // src/native-modules/index.ts
858
939
  var TossPay = {
859
940
  checkoutPayment
@@ -873,9 +954,9 @@ import {
873
954
  usePartnerNavigation
874
955
  } from "@toss-design-system/react-native";
875
956
  import { useSafeAreaBottom, useSafeAreaTop as useSafeAreaTop2 } from "@toss-design-system/react-native/private";
876
- import { useCallback as useCallback4, useMemo as useMemo3 } from "react";
957
+ import { useCallback as useCallback5, useMemo as useMemo3 } from "react";
877
958
  import { Platform as Platform7 } from "react-native";
878
- import { getSchemeUri as getSchemeUri4, useBedrockEvent } from "react-native-bedrock";
959
+ import { getSchemeUri as getSchemeUri5, useBedrockEvent } from "react-native-bedrock";
879
960
  import * as bedrockAsyncBridges from "react-native-bedrock/async-bridges";
880
961
  import * as bedrockConstantBridges from "react-native-bedrock/constant-bridges";
881
962
 
@@ -885,19 +966,19 @@ import {
885
966
  } from "@react-native-bedrock/native/react-native-webview";
886
967
  import { useDialog as useDialog2 } from "@toss-design-system/react-native";
887
968
  import { josa as josa2 } from "es-hangul";
888
- import { forwardRef, useCallback as useCallback2, useEffect as useEffect4, useState as useState2 } from "react";
969
+ import { forwardRef, useCallback as useCallback3, useEffect as useEffect5, useState as useState2 } from "react";
889
970
  import { BackHandler, Platform as Platform6 } from "react-native";
890
971
  import { closeView as closeView2, setIosSwipeGestureEnabled } from "react-native-bedrock";
891
972
 
892
973
  // src/components/GameProfile.tsx
893
974
  import { Loader } from "@toss-design-system/react-native";
894
- import { useEffect as useEffect3 } from "react";
975
+ import { useEffect as useEffect4 } from "react";
895
976
  import { Pressable, View } from "react-native";
896
977
 
897
978
  // src/hooks/useGameCenterProfile.ts
898
979
  import { useDialog } from "@toss-design-system/react-native";
899
980
  import { josa } from "es-hangul";
900
- import { useCallback, useRef, useState } from "react";
981
+ import { useCallback as useCallback2, useRef as useRef2, useState } from "react";
901
982
  import { closeView, openURL as openURL3 } from "react-native-bedrock";
902
983
 
903
984
  // src/components/GameProfileToast.tsx
@@ -1001,17 +1082,17 @@ var useGameCenterProfile = (isReadyForProfileUI) => {
1001
1082
  const shouldShowProfileNotFoundOverlay = profileData?.statusCode === "PROFILE_NOT_FOUND" && isReadyForProfileUI && !isProfileDataRefetching;
1002
1083
  const canShowBottomSheetOrToast = !isProfileDataLoading && isReadyForProfileUI;
1003
1084
  const [isWebviewLoading, setIsWebviewLoading] = useState(false);
1004
- const isCompletedProfileFlow = useRef(false);
1085
+ const isCompletedProfileFlow = useRef2(false);
1005
1086
  const { openAlert, openConfirm } = useDialog();
1006
1087
  const { openGameProfileToast } = useGameProfileToast();
1007
- const openErrorAlert = useCallback(async () => {
1088
+ const openErrorAlert = useCallback2(async () => {
1008
1089
  await openAlert({
1009
1090
  title: DEFAULT_ERROR.title,
1010
1091
  description: DEFAULT_ERROR.description
1011
1092
  });
1012
1093
  closeView();
1013
1094
  }, [openAlert]);
1014
- const openProfileWebview = useCallback(() => {
1095
+ const openProfileWebview = useCallback2(() => {
1015
1096
  if (isWebviewLoading) {
1016
1097
  return;
1017
1098
  }
@@ -1040,7 +1121,7 @@ var useGameCenterProfile = (isReadyForProfileUI) => {
1040
1121
  }
1041
1122
  });
1042
1123
  }, [isWebviewLoading, openGameProfileToast, openErrorAlert]);
1043
- const updateAppToSupportedMinVersion = useCallback(async () => {
1124
+ const updateAppToSupportedMinVersion = useCallback2(async () => {
1044
1125
  const upddateConfirmDialogLabel = {
1045
1126
  title: `${josa(getAppsInTossGlobals().brandDisplayName, "\uC744/\uB97C")} \uD558\uB824\uBA74
1046
1127
  \uC571\uC744 \uC5C5\uB370\uC774\uD2B8\uD574\uC8FC\uC138\uC694`,
@@ -1103,7 +1184,7 @@ var GameProfile = ({ children, isReadyForProfileUI }) => {
1103
1184
  openErrorAlert,
1104
1185
  openGameProfileToast
1105
1186
  } = useGameCenterProfile(isReadyForProfileUI);
1106
- useEffect3(() => {
1187
+ useEffect4(() => {
1107
1188
  try {
1108
1189
  const getProfileData = async () => {
1109
1190
  const data = await getGameCenterGameProfile();
@@ -1116,7 +1197,7 @@ var GameProfile = ({ children, isReadyForProfileUI }) => {
1116
1197
  setIsProfileDataLoading(false);
1117
1198
  }
1118
1199
  }, []);
1119
- useEffect3(() => {
1200
+ useEffect4(() => {
1120
1201
  const handleGameProfileFlow = async () => {
1121
1202
  if (!canShowBottomSheetOrToast) {
1122
1203
  return;
@@ -1307,8 +1388,9 @@ import { Fragment as Fragment4, jsx as jsx6, jsxs as jsxs4 } from "react/jsx-run
1307
1388
  var GameWebView = forwardRef(function GameWebView2(props, ref) {
1308
1389
  const { openConfirm } = useDialog2();
1309
1390
  const { brandDisplayName } = getAppsInTossGlobals();
1391
+ const { captureExitLog } = useCaptureExitLog();
1310
1392
  const [isEntryMessageExited, setIsEntryMessageExited] = useState2(false);
1311
- const handleClose = useCallback2(async () => {
1393
+ const handleClose = useCallback3(async () => {
1312
1394
  const isConfirmed = await openConfirm({
1313
1395
  title: `${josa2(brandDisplayName, "\uC744/\uB97C")} \uC885\uB8CC\uD560\uAE4C\uC694?`,
1314
1396
  leftButton: "\uCDE8\uC18C",
@@ -1316,10 +1398,11 @@ var GameWebView = forwardRef(function GameWebView2(props, ref) {
1316
1398
  closeOnDimmerClick: true
1317
1399
  });
1318
1400
  if (isConfirmed) {
1401
+ captureExitLog(Date.now());
1319
1402
  closeView2();
1320
1403
  }
1321
- }, [brandDisplayName, openConfirm]);
1322
- useEffect4(() => {
1404
+ }, [brandDisplayName, captureExitLog, openConfirm]);
1405
+ useEffect5(() => {
1323
1406
  if (Platform6.OS === "ios") {
1324
1407
  setIosSwipeGestureEnabled({ isEnabled: false });
1325
1408
  return () => {
@@ -1328,7 +1411,7 @@ var GameWebView = forwardRef(function GameWebView2(props, ref) {
1328
1411
  }
1329
1412
  return;
1330
1413
  }, []);
1331
- useEffect4(() => {
1414
+ useEffect5(() => {
1332
1415
  const backHandler = () => {
1333
1416
  handleClose();
1334
1417
  return true;
@@ -1338,7 +1421,7 @@ var GameWebView = forwardRef(function GameWebView2(props, ref) {
1338
1421
  BackHandler.removeEventListener("hardwareBackPress", backHandler);
1339
1422
  };
1340
1423
  }, [handleClose]);
1341
- useEffect4(() => {
1424
+ useEffect5(() => {
1342
1425
  appsInTossEvent.addEventListener("entryMessageExited", {
1343
1426
  onEvent: () => {
1344
1427
  setIsEntryMessageExited(true);
@@ -1352,7 +1435,7 @@ var GameWebView = forwardRef(function GameWebView2(props, ref) {
1352
1435
  });
1353
1436
 
1354
1437
  // src/bridge-handler/useBridgeHandler.tsx
1355
- import { useCallback as useCallback3, useMemo as useMemo2, useRef as useRef2 } from "react";
1438
+ import { useCallback as useCallback4, useMemo as useMemo2, useRef as useRef3 } from "react";
1356
1439
  function serializeError(error) {
1357
1440
  return JSON.stringify(error, (_, value) => {
1358
1441
  if (value instanceof Error) {
@@ -1401,7 +1484,7 @@ function useBridgeHandler({
1401
1484
  eventListenerMap,
1402
1485
  injectedJavaScript: originalInjectedJavaScript
1403
1486
  }) {
1404
- const ref = useRef2(null);
1487
+ const ref = useRef3(null);
1405
1488
  const injectedJavaScript = useMemo2(
1406
1489
  () => [
1407
1490
  `window.__CONSTANT_HANDLER_MAP = ${JSON.stringify(
@@ -1428,7 +1511,7 @@ function useBridgeHandler({
1428
1511
  window.__BEDROCK_NATIVE_EMITTER.emit('${functionName}/onError/${eventId}', ${JSON.stringify(error, null, 0)});
1429
1512
  `);
1430
1513
  };
1431
- const $onMessage = useCallback3(
1514
+ const $onMessage = useCallback4(
1432
1515
  async (e) => {
1433
1516
  onMessage?.(e);
1434
1517
  const data = JSON.parse(e.nativeEvent.data);
@@ -1489,6 +1572,7 @@ __export(constant_bridges_exports, {
1489
1572
  // src/event-bridges.ts
1490
1573
  var event_bridges_exports = {};
1491
1574
  __export(event_bridges_exports, {
1575
+ contactsViral: () => contactsViral,
1492
1576
  startUpdateLocation: () => startUpdateLocation
1493
1577
  });
1494
1578
 
@@ -1649,12 +1733,12 @@ function useCreateUserAgent({
1649
1733
  }
1650
1734
 
1651
1735
  // src/hooks/useGeolocation.ts
1652
- import { useState as useState3, useEffect as useEffect5 } from "react";
1653
- import { useVisibility } from "react-native-bedrock";
1736
+ import { useState as useState3, useEffect as useEffect6 } from "react";
1737
+ import { useVisibility as useVisibility3 } from "react-native-bedrock";
1654
1738
  function useGeolocation({ accuracy, distanceInterval, timeInterval }) {
1655
- const isVisible = useVisibility();
1739
+ const isVisible = useVisibility3();
1656
1740
  const [location, setLocation] = useState3(null);
1657
- useEffect5(() => {
1741
+ useEffect6(() => {
1658
1742
  if (!isVisible) {
1659
1743
  return;
1660
1744
  }
@@ -1672,7 +1756,7 @@ function useGeolocation({ accuracy, distanceInterval, timeInterval }) {
1672
1756
  }
1673
1757
 
1674
1758
  // src/utils/log.ts
1675
- import { getSchemeUri as getSchemeUri3 } from "react-native-bedrock";
1759
+ import { getSchemeUri as getSchemeUri4 } from "react-native-bedrock";
1676
1760
 
1677
1761
  // src/utils/extractDateFromUUIDv7.ts
1678
1762
  var extractDateFromUUIDv7 = (uuid) => {
@@ -1698,7 +1782,7 @@ var getGroupId = (url) => {
1698
1782
  };
1699
1783
  var getReferrer = () => {
1700
1784
  try {
1701
- const referrer = new URL(getSchemeUri3());
1785
+ const referrer = new URL(getSchemeUri4());
1702
1786
  return referrer.searchParams.get("referrer");
1703
1787
  } catch {
1704
1788
  return "";
@@ -1731,7 +1815,7 @@ var WEBVIEW_TYPES = {
1731
1815
  };
1732
1816
  function mergeSchemeQueryParamsInto(url) {
1733
1817
  const baseUrl = new URL(url);
1734
- const schemeUrl = new URL(getSchemeUri4());
1818
+ const schemeUrl = new URL(getSchemeUri5());
1735
1819
  baseUrl.pathname = schemeUrl.pathname;
1736
1820
  for (const [key, value] of schemeUrl.searchParams.entries()) {
1737
1821
  baseUrl.searchParams.set(key, value);
@@ -1841,7 +1925,7 @@ function WebView({ type, local, onMessage, ...props }) {
1841
1925
  }, [type, props]);
1842
1926
  const BaseWebView = WEBVIEW_TYPES[type];
1843
1927
  const webViewDebuggingEnabled = operationalEnvironment === "sandbox";
1844
- const handleNavigationStateChange = useCallback4((event) => {
1928
+ const handleNavigationStateChange = useCallback5((event) => {
1845
1929
  if (event.url) {
1846
1930
  trackScreen(event.url);
1847
1931
  }
@@ -1912,6 +1996,7 @@ export {
1912
1996
  WebView,
1913
1997
  appLogin,
1914
1998
  appsInTossEvent,
1999
+ contactsViral,
1915
2000
  env,
1916
2001
  eventLog,
1917
2002
  fetchAlbumPhotos,
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@apps-in-toss/framework",
3
3
  "type": "module",
4
- "version": "0.0.34",
4
+ "version": "0.0.36",
5
5
  "description": "The framework for Apps In Toss",
6
6
  "scripts": {
7
7
  "prepack": "yarn build",
@@ -57,9 +57,9 @@
57
57
  "ait": "./bin/ait.js"
58
58
  },
59
59
  "dependencies": {
60
- "@apps-in-toss/analytics": "0.0.34",
61
- "@apps-in-toss/cli": "0.0.34",
62
- "@apps-in-toss/plugins": "0.0.34",
60
+ "@apps-in-toss/analytics": "0.0.36",
61
+ "@apps-in-toss/cli": "0.0.36",
62
+ "@apps-in-toss/plugins": "0.0.36",
63
63
  "es-hangul": "^2.3.2"
64
64
  },
65
65
  "devDependencies": {
@@ -94,5 +94,5 @@
94
94
  "publishConfig": {
95
95
  "access": "public"
96
96
  },
97
- "gitHead": "72db163ac0be186947e9b8db923e2e62b0973f73"
97
+ "gitHead": "b3b65b35bf9532480fcbd14f7d22b796644e2f2f"
98
98
  }
@@ -1 +1,2 @@
1
1
  export * from './native-event-emitter/startUpdateLocation';
2
+ export * from './native-modules/contactsViral';
@@ -1 +0,0 @@
1
- export { default } from '@apps-in-toss/native-modules/bridges-meta.json';