@apps-in-toss/framework 1.8.0 → 1.9.0

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/CHANGELOG.md CHANGED
@@ -1,5 +1,21 @@
1
1
  # @apps-in-toss/framework
2
2
 
3
+ ## 1.9.0
4
+
5
+ ### Minor Changes
6
+
7
+ [[AIT-3902] getServerTime 앱브릿지 추가](https://github.toss.bz/toss/apps-in-toss-sdk/pull/24)
8
+
9
+ 서버 시간을 가져오는 getServerTime 브릿지를 추가합니다.
10
+
11
+ ## 1.8.1
12
+
13
+ ### Patch Changes
14
+
15
+ [[AIT-3844]: 외부 사이트에서 네비바 홈 버튼을 누르면 해당 사이트의 루트가 아닌 미니앱의 루트로 이동하도록 수정](https://github.toss.bz/toss/apps-in-toss-sdk/pull/22)
16
+
17
+ 외부 사이트에서 네비바 홈 버튼을 누르면 미니앱 루트 페이지로 이동하도록 수정합니다.
18
+
3
19
  ## 1.8.0
4
20
 
5
21
  ### Minor Changes
package/dist/index.cjs CHANGED
@@ -2155,19 +2155,7 @@ function useWebViewHistory() {
2155
2155
  }
2156
2156
 
2157
2157
  // src/core/hooks/useWebBackHandler.tsx
2158
- var HISTORY_BACK_SCRIPT = `
2159
- (function() {
2160
- window.history.back();
2161
- true;
2162
- })();
2163
- `;
2164
- var HISTORY_HOME_SCRIPT = `
2165
- (function() {
2166
- window.location.href = '/';
2167
- true;
2168
- })();
2169
- `;
2170
- function useWebBackHandler(webViewRef) {
2158
+ function useWebBackHandler(webViewInitialURL, webViewRef) {
2171
2159
  const { captureExitLog } = useCaptureExitLog();
2172
2160
  const { hasHistory, onNavigationStateChange } = useWebViewHistory();
2173
2161
  const {
@@ -2199,7 +2187,7 @@ function useWebBackHandler(webViewRef) {
2199
2187
  return;
2200
2188
  }
2201
2189
  if (hasHistory) {
2202
- webViewRef.current?.injectJavaScript(HISTORY_BACK_SCRIPT);
2190
+ webViewRef.current?.injectJavaScript("window.history.back();");
2203
2191
  } else {
2204
2192
  const isConfirmed = await openConfirm({
2205
2193
  title: `${(0, import_es_hangul5.josa)(global2.brandDisplayName, "\uC744/\uB97C")} \uC885\uB8CC\uD560\uAE4C\uC694?`,
@@ -2232,8 +2220,13 @@ function useWebBackHandler(webViewRef) {
2232
2220
  }
2233
2221
  return;
2234
2222
  }
2235
- webViewRef.current?.injectJavaScript(HISTORY_HOME_SCRIPT);
2236
- }, [hasWebBackEvent, webBackHandlersRef, logging, webViewRef]);
2223
+ webViewRef.current?.injectJavaScript(`
2224
+ (function() {
2225
+ const webBundleOrigin = '${webViewInitialURL.origin}';
2226
+ window.location.href = window.location.origin === webBundleOrigin ? '/' : webBundleOrigin;
2227
+ })();
2228
+ `);
2229
+ }, [hasWebBackEvent, webBackHandlersRef, logging, webViewInitialURL, webViewRef]);
2237
2230
  return (0, import_react25.useMemo)(
2238
2231
  () => ({ addEventListener, removeEventListener, handleWebBack, handleWebHome, onNavigationStateChange }),
2239
2232
  [addEventListener, removeEventListener, handleWebBack, handleWebHome, onNavigationStateChange]
@@ -2576,10 +2569,10 @@ function mergeSchemeQueryParamsInto(url) {
2576
2569
  }
2577
2570
  return baseUrl;
2578
2571
  }
2579
- function getWebViewUri(local) {
2572
+ function getWebViewURL(local) {
2580
2573
  if (__DEV__) {
2581
2574
  const devUrl = `http://${local.host}:${local.port}`;
2582
- return mergeSchemeQueryParamsInto(devUrl).toString();
2575
+ return mergeSchemeQueryParamsInto(devUrl);
2583
2576
  }
2584
2577
  const { url: rawUrl } = import_native_modules23.AppsInTossModule.getWebBundleURL({});
2585
2578
  const url = mergeSchemeQueryParamsInto(rawUrl);
@@ -2587,15 +2580,15 @@ function getWebViewUri(local) {
2587
2580
  if (deploymentId) {
2588
2581
  url.searchParams.set("_deploymentId", deploymentId);
2589
2582
  }
2590
- return url.toString();
2583
+ return url;
2591
2584
  }
2592
2585
  function WebView({ type, local, onMessage, ...props }) {
2593
2586
  if (!TYPES.includes(type)) {
2594
2587
  throw new Error(`Invalid WebView type: '${type}'`);
2595
2588
  }
2596
2589
  const webViewRef = (0, import_react28.useRef)(null);
2597
- const webBackHandler = useWebBackHandler(webViewRef);
2598
- const uri = (0, import_react28.useMemo)(() => getWebViewUri(local), [local]);
2590
+ const url = (0, import_react28.useMemo)(() => getWebViewURL(local), [local]);
2591
+ const webBackHandler = useWebBackHandler(url, webViewRef);
2599
2592
  const top = (0, import_private9.useSafeAreaTop)();
2600
2593
  const bottom = (0, import_private9.useSafeAreaBottom)();
2601
2594
  const insets = (0, import_react_native_safe_area_context4.useSafeAreaInsets)();
@@ -2734,7 +2727,7 @@ function WebView({ type, local, onMessage, ...props }) {
2734
2727
  ...props,
2735
2728
  ...headerPropForExternalWebView,
2736
2729
  source: {
2737
- uri,
2730
+ uri: url.href,
2738
2731
  // NOTE: https://github.com/react-native-webview/react-native-webview/pull/3133
2739
2732
  headers: {
2740
2733
  "User-Agent": userAgent
@@ -2760,11 +2753,11 @@ function WebView({ type, local, onMessage, ...props }) {
2760
2753
  allowsBackForwardNavigationGestures,
2761
2754
  onShouldStartLoadWithRequest: (event) => {
2762
2755
  try {
2763
- const url = new URL(event.url);
2764
- if (["https:", "http:"].includes(url.protocol) || url.href === "about:blank") {
2756
+ const url2 = new URL(event.url);
2757
+ if (["https:", "http:"].includes(url2.protocol) || url2.href === "about:blank") {
2765
2758
  return true;
2766
2759
  } else {
2767
- import_react_native39.Linking.openURL(convertIntentURL(url) ?? url.href);
2760
+ import_react_native39.Linking.openURL(convertIntentURL(url2) ?? url2.href);
2768
2761
  return false;
2769
2762
  }
2770
2763
  } catch (error) {
package/dist/index.js CHANGED
@@ -2142,19 +2142,7 @@ function useWebViewHistory() {
2142
2142
  }
2143
2143
 
2144
2144
  // src/core/hooks/useWebBackHandler.tsx
2145
- var HISTORY_BACK_SCRIPT = `
2146
- (function() {
2147
- window.history.back();
2148
- true;
2149
- })();
2150
- `;
2151
- var HISTORY_HOME_SCRIPT = `
2152
- (function() {
2153
- window.location.href = '/';
2154
- true;
2155
- })();
2156
- `;
2157
- function useWebBackHandler(webViewRef) {
2145
+ function useWebBackHandler(webViewInitialURL, webViewRef) {
2158
2146
  const { captureExitLog } = useCaptureExitLog();
2159
2147
  const { hasHistory, onNavigationStateChange } = useWebViewHistory();
2160
2148
  const {
@@ -2186,7 +2174,7 @@ function useWebBackHandler(webViewRef) {
2186
2174
  return;
2187
2175
  }
2188
2176
  if (hasHistory) {
2189
- webViewRef.current?.injectJavaScript(HISTORY_BACK_SCRIPT);
2177
+ webViewRef.current?.injectJavaScript("window.history.back();");
2190
2178
  } else {
2191
2179
  const isConfirmed = await openConfirm({
2192
2180
  title: `${josa5(global2.brandDisplayName, "\uC744/\uB97C")} \uC885\uB8CC\uD560\uAE4C\uC694?`,
@@ -2219,8 +2207,13 @@ function useWebBackHandler(webViewRef) {
2219
2207
  }
2220
2208
  return;
2221
2209
  }
2222
- webViewRef.current?.injectJavaScript(HISTORY_HOME_SCRIPT);
2223
- }, [hasWebBackEvent, webBackHandlersRef, logging, webViewRef]);
2210
+ webViewRef.current?.injectJavaScript(`
2211
+ (function() {
2212
+ const webBundleOrigin = '${webViewInitialURL.origin}';
2213
+ window.location.href = window.location.origin === webBundleOrigin ? '/' : webBundleOrigin;
2214
+ })();
2215
+ `);
2216
+ }, [hasWebBackEvent, webBackHandlersRef, logging, webViewInitialURL, webViewRef]);
2224
2217
  return useMemo6(
2225
2218
  () => ({ addEventListener, removeEventListener, handleWebBack, handleWebHome, onNavigationStateChange }),
2226
2219
  [addEventListener, removeEventListener, handleWebBack, handleWebHome, onNavigationStateChange]
@@ -2563,10 +2556,10 @@ function mergeSchemeQueryParamsInto(url) {
2563
2556
  }
2564
2557
  return baseUrl;
2565
2558
  }
2566
- function getWebViewUri(local) {
2559
+ function getWebViewURL(local) {
2567
2560
  if (__DEV__) {
2568
2561
  const devUrl = `http://${local.host}:${local.port}`;
2569
- return mergeSchemeQueryParamsInto(devUrl).toString();
2562
+ return mergeSchemeQueryParamsInto(devUrl);
2570
2563
  }
2571
2564
  const { url: rawUrl } = AppsInTossModule.getWebBundleURL({});
2572
2565
  const url = mergeSchemeQueryParamsInto(rawUrl);
@@ -2574,15 +2567,15 @@ function getWebViewUri(local) {
2574
2567
  if (deploymentId) {
2575
2568
  url.searchParams.set("_deploymentId", deploymentId);
2576
2569
  }
2577
- return url.toString();
2570
+ return url;
2578
2571
  }
2579
2572
  function WebView({ type, local, onMessage, ...props }) {
2580
2573
  if (!TYPES.includes(type)) {
2581
2574
  throw new Error(`Invalid WebView type: '${type}'`);
2582
2575
  }
2583
2576
  const webViewRef = useRef6(null);
2584
- const webBackHandler = useWebBackHandler(webViewRef);
2585
- const uri = useMemo7(() => getWebViewUri(local), [local]);
2577
+ const url = useMemo7(() => getWebViewURL(local), [local]);
2578
+ const webBackHandler = useWebBackHandler(url, webViewRef);
2586
2579
  const top = useSafeAreaTop3();
2587
2580
  const bottom = useSafeAreaBottom();
2588
2581
  const insets = useSafeAreaInsets4();
@@ -2721,7 +2714,7 @@ function WebView({ type, local, onMessage, ...props }) {
2721
2714
  ...props,
2722
2715
  ...headerPropForExternalWebView,
2723
2716
  source: {
2724
- uri,
2717
+ uri: url.href,
2725
2718
  // NOTE: https://github.com/react-native-webview/react-native-webview/pull/3133
2726
2719
  headers: {
2727
2720
  "User-Agent": userAgent
@@ -2747,11 +2740,11 @@ function WebView({ type, local, onMessage, ...props }) {
2747
2740
  allowsBackForwardNavigationGestures,
2748
2741
  onShouldStartLoadWithRequest: (event) => {
2749
2742
  try {
2750
- const url = new URL(event.url);
2751
- if (["https:", "http:"].includes(url.protocol) || url.href === "about:blank") {
2743
+ const url2 = new URL(event.url);
2744
+ if (["https:", "http:"].includes(url2.protocol) || url2.href === "about:blank") {
2752
2745
  return true;
2753
2746
  } else {
2754
- Linking.openURL(convertIntentURL(url) ?? url.href);
2747
+ Linking.openURL(convertIntentURL(url2) ?? url2.href);
2755
2748
  return false;
2756
2749
  }
2757
2750
  } catch (error) {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@apps-in-toss/framework",
3
3
  "type": "module",
4
- "version": "1.8.0",
4
+ "version": "1.9.0",
5
5
  "description": "The framework for Apps In Toss",
6
6
  "scripts": {
7
7
  "typecheck": "tsc --noEmit",
@@ -55,11 +55,11 @@
55
55
  "ait": "./bin/ait.js"
56
56
  },
57
57
  "dependencies": {
58
- "@apps-in-toss/analytics": "1.8.0",
59
- "@apps-in-toss/cli": "1.8.0",
60
- "@apps-in-toss/native-modules": "1.8.0",
61
- "@apps-in-toss/plugins": "1.8.0",
62
- "@apps-in-toss/types": "1.8.0",
58
+ "@apps-in-toss/analytics": "1.9.0",
59
+ "@apps-in-toss/cli": "1.9.0",
60
+ "@apps-in-toss/native-modules": "1.9.0",
61
+ "@apps-in-toss/plugins": "1.9.0",
62
+ "@apps-in-toss/types": "1.9.0",
63
63
  "es-hangul": "^2.3.2"
64
64
  },
65
65
  "devDependencies": {