@apps-in-toss/framework 1.13.0 → 1.14.1
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 +62 -42
- package/dist/index.d.cts +17 -1
- package/dist/index.d.ts +17 -1
- package/dist/index.js +68 -50
- package/package.json +7 -7
package/dist/index.cjs
CHANGED
|
@@ -38,7 +38,9 @@ __export(src_exports, {
|
|
|
38
38
|
OverlayProvider: () => import_private10.OverlayProvider,
|
|
39
39
|
WebView: () => WebView,
|
|
40
40
|
env: () => env,
|
|
41
|
+
homeEvent: () => homeEvent,
|
|
41
42
|
loadFullScreenAd: () => loadFullScreenAd,
|
|
43
|
+
safeAreaInsetsChange: () => safeAreaInsetsChange,
|
|
42
44
|
showFullScreenAd: () => showFullScreenAd,
|
|
43
45
|
useCreateUserAgent: () => useCreateUserAgent,
|
|
44
46
|
useGeolocation: () => useGeolocation,
|
|
@@ -741,6 +743,46 @@ function useCloseConfirm() {
|
|
|
741
743
|
);
|
|
742
744
|
}
|
|
743
745
|
|
|
746
|
+
// src/utils/eventEmitter.ts
|
|
747
|
+
var EventEmitter = class {
|
|
748
|
+
listeners = {};
|
|
749
|
+
subscribe(event, listener) {
|
|
750
|
+
if (!this.listeners[event]) {
|
|
751
|
+
this.listeners[event] = [];
|
|
752
|
+
}
|
|
753
|
+
this.listeners[event].push(listener);
|
|
754
|
+
return () => {
|
|
755
|
+
this.listeners[event] = this.listeners[event]?.filter((l) => l !== listener) ?? [];
|
|
756
|
+
};
|
|
757
|
+
}
|
|
758
|
+
hasSubscriptions(event) {
|
|
759
|
+
return this.listeners[event] != null && this.listeners[event].length > 0;
|
|
760
|
+
}
|
|
761
|
+
clearSubscriptions(event) {
|
|
762
|
+
this.listeners[event] = [];
|
|
763
|
+
}
|
|
764
|
+
emit(event, ...args) {
|
|
765
|
+
if (!this.listeners[event]) {
|
|
766
|
+
return;
|
|
767
|
+
}
|
|
768
|
+
this.listeners[event].forEach((listener) => listener(...args));
|
|
769
|
+
}
|
|
770
|
+
};
|
|
771
|
+
var eventEmitter = new EventEmitter();
|
|
772
|
+
function createEvent(event) {
|
|
773
|
+
return {
|
|
774
|
+
name: event,
|
|
775
|
+
subscribe: (listener) => eventEmitter.subscribe(event, listener),
|
|
776
|
+
hasSubscriptions: () => eventEmitter.hasSubscriptions(event),
|
|
777
|
+
clearSubscriptions: () => eventEmitter.clearSubscriptions(event),
|
|
778
|
+
emit: (data) => eventEmitter.emit(event, data)
|
|
779
|
+
};
|
|
780
|
+
}
|
|
781
|
+
|
|
782
|
+
// src/events.ts
|
|
783
|
+
var homeEvent = createEvent("homeEvent");
|
|
784
|
+
var safeAreaInsetsChange = createEvent("safeAreaInsetsChange");
|
|
785
|
+
|
|
744
786
|
// src/components/NavigationBar/common/useNavigationBarLogging.tsx
|
|
745
787
|
var import_native_modules7 = require("@apps-in-toss/native-modules");
|
|
746
788
|
var import_react_native13 = require("@granite-js/react-native");
|
|
@@ -855,7 +897,11 @@ function useNavigationEvent() {
|
|
|
855
897
|
},
|
|
856
898
|
handleHomeButtonClick: () => {
|
|
857
899
|
logging.homeButtonClick();
|
|
858
|
-
|
|
900
|
+
if (homeEvent.hasSubscriptions()) {
|
|
901
|
+
homeEvent.emit({});
|
|
902
|
+
} else {
|
|
903
|
+
navigation.navigate("/");
|
|
904
|
+
}
|
|
859
905
|
},
|
|
860
906
|
handleCloseButtonClick: () => {
|
|
861
907
|
logging.closeButtonClick();
|
|
@@ -2095,40 +2141,18 @@ function parseNativeEventData(data) {
|
|
|
2095
2141
|
}
|
|
2096
2142
|
}
|
|
2097
2143
|
|
|
2098
|
-
// src/core/hooks/
|
|
2144
|
+
// src/core/hooks/useSafeAreaInsetsEvent.tsx
|
|
2099
2145
|
var import_react_native_safe_area_context3 = require("@granite-js/native/react-native-safe-area-context");
|
|
2100
2146
|
var import_react23 = require("react");
|
|
2101
|
-
|
|
2102
|
-
listeners = {};
|
|
2103
|
-
on(event, listener) {
|
|
2104
|
-
if (!this.listeners[event]) {
|
|
2105
|
-
this.listeners[event] = [];
|
|
2106
|
-
}
|
|
2107
|
-
this.listeners[event].push(listener);
|
|
2108
|
-
}
|
|
2109
|
-
emit(event, ...args) {
|
|
2110
|
-
if (!this.listeners[event]) {
|
|
2111
|
-
return;
|
|
2112
|
-
}
|
|
2113
|
-
this.listeners[event].forEach((listener) => listener(...args));
|
|
2114
|
-
}
|
|
2115
|
-
off(event, listener) {
|
|
2116
|
-
if (!this.listeners[event]) {
|
|
2117
|
-
return;
|
|
2118
|
-
}
|
|
2119
|
-
this.listeners[event] = this.listeners[event].filter((l) => l !== listener);
|
|
2120
|
-
}
|
|
2121
|
-
};
|
|
2122
|
-
function useSafeAreaInsetsEmitter() {
|
|
2147
|
+
function useSafeAreaInsetsEvent() {
|
|
2123
2148
|
const insets = (0, import_react_native_safe_area_context3.useSafeAreaInsets)();
|
|
2124
|
-
const emitter = (0, import_react23.useMemo)(() => new EventEmitter(), []);
|
|
2125
2149
|
(0, import_react23.useEffect)(() => {
|
|
2126
|
-
|
|
2127
|
-
|
|
2128
|
-
|
|
2129
|
-
|
|
2130
|
-
}, [
|
|
2131
|
-
return
|
|
2150
|
+
safeAreaInsetsChange.emit(insets);
|
|
2151
|
+
}, [insets]);
|
|
2152
|
+
(0, import_react23.useEffect)(() => {
|
|
2153
|
+
return () => safeAreaInsetsChange.clearSubscriptions();
|
|
2154
|
+
}, []);
|
|
2155
|
+
return safeAreaInsetsChange;
|
|
2132
2156
|
}
|
|
2133
2157
|
|
|
2134
2158
|
// src/core/hooks/useWebBackHandler.tsx
|
|
@@ -2241,10 +2265,8 @@ function useWebBackHandler(webViewInitialURL, webViewRef) {
|
|
|
2241
2265
|
]);
|
|
2242
2266
|
const handleWebHome = (0, import_react25.useCallback)(() => {
|
|
2243
2267
|
logging.homeButtonClick();
|
|
2244
|
-
if (
|
|
2245
|
-
|
|
2246
|
-
handler();
|
|
2247
|
-
}
|
|
2268
|
+
if (homeEvent.hasSubscriptions()) {
|
|
2269
|
+
homeEvent.emit({});
|
|
2248
2270
|
return;
|
|
2249
2271
|
}
|
|
2250
2272
|
webViewRef.current?.injectJavaScript(`
|
|
@@ -2621,7 +2643,7 @@ function WebView({ type, local, onMessage, ...props }) {
|
|
|
2621
2643
|
const insets = (0, import_react_native_safe_area_context4.useSafeAreaInsets)();
|
|
2622
2644
|
const global2 = getAppsInTossGlobals();
|
|
2623
2645
|
const navigationBarContext = useNavigationBarContext();
|
|
2624
|
-
const
|
|
2646
|
+
const safeAreaInsetsEvent = useSafeAreaInsetsEvent();
|
|
2625
2647
|
const [allowsBackForwardNavigationGestures, setAllowsBackForwardNavigationGestures] = (0, import_react28.useState)(
|
|
2626
2648
|
props.allowsBackForwardNavigationGestures
|
|
2627
2649
|
);
|
|
@@ -2636,13 +2658,9 @@ function WebView({ type, local, onMessage, ...props }) {
|
|
|
2636
2658
|
webBackHandler.removeEventListener(onEvent);
|
|
2637
2659
|
};
|
|
2638
2660
|
},
|
|
2661
|
+
homeEvent: ({ onEvent }) => homeEvent.subscribe(onEvent),
|
|
2639
2662
|
updateLocationEvent: ({ onEvent, onError, options }) => import_native_modules24.appsInTossEvent.addEventListener("updateLocationEvent", { onEvent, onError, options }),
|
|
2640
|
-
safeAreaInsetsChange: ({ onEvent }) =>
|
|
2641
|
-
safeAreaInsetsEmitter.on("safeAreaInsetsChange", onEvent);
|
|
2642
|
-
return () => {
|
|
2643
|
-
safeAreaInsetsEmitter.off("safeAreaInsetsChange", onEvent);
|
|
2644
|
-
};
|
|
2645
|
-
},
|
|
2663
|
+
safeAreaInsetsChange: ({ onEvent }) => safeAreaInsetsEvent.subscribe(onEvent),
|
|
2646
2664
|
/** @internal */
|
|
2647
2665
|
appBridgeCallbackEvent: ({ onEvent, onError, options }) => import_native_modules24.appsInTossEvent.addEventListener("appBridgeCallbackEvent", { onEvent, onError, options }),
|
|
2648
2666
|
/** AdMobV2 */
|
|
@@ -4086,7 +4104,9 @@ var Analytics2 = {
|
|
|
4086
4104
|
OverlayProvider,
|
|
4087
4105
|
WebView,
|
|
4088
4106
|
env,
|
|
4107
|
+
homeEvent,
|
|
4089
4108
|
loadFullScreenAd,
|
|
4109
|
+
safeAreaInsetsChange,
|
|
4090
4110
|
showFullScreenAd,
|
|
4091
4111
|
useCreateUserAgent,
|
|
4092
4112
|
useGeolocation,
|
package/dist/index.d.cts
CHANGED
|
@@ -9,6 +9,7 @@ import { ExternalWebViewScreenProps } from '@toss/tds-react-native';
|
|
|
9
9
|
import { StartUpdateLocationOptions, Location, LoadFullScreenAdParams, ShowFullScreenAdParams } from '@apps-in-toss/types';
|
|
10
10
|
export * from '@apps-in-toss/types';
|
|
11
11
|
export { FetchTossAdOptions, LoadFullScreenAdEvent, LoadFullScreenAdOptions, LoadFullScreenAdParams, ShowFullScreenAdEvent, ShowFullScreenAdOptions, ShowFullScreenAdParams, TossAdEventLogParams } from '@apps-in-toss/types';
|
|
12
|
+
import { EdgeInsets } from '@granite-js/native/react-native-safe-area-context';
|
|
12
13
|
import { onVisibilityChangedByTransparentServiceWeb } from '@apps-in-toss/native-modules';
|
|
13
14
|
export * from '@apps-in-toss/native-modules';
|
|
14
15
|
export { OverlayProvider, useOverlay } from '@toss/tds-react-native/private';
|
|
@@ -171,6 +172,21 @@ declare const env: {
|
|
|
171
172
|
getAppName: () => string;
|
|
172
173
|
};
|
|
173
174
|
|
|
175
|
+
declare const homeEvent: {
|
|
176
|
+
name: string;
|
|
177
|
+
subscribe: (listener: (data: any) => void) => () => void;
|
|
178
|
+
hasSubscriptions: () => boolean;
|
|
179
|
+
clearSubscriptions: () => void;
|
|
180
|
+
emit: (data: any) => void;
|
|
181
|
+
};
|
|
182
|
+
declare const safeAreaInsetsChange: {
|
|
183
|
+
name: string;
|
|
184
|
+
subscribe: (listener: (data: EdgeInsets) => void) => () => void;
|
|
185
|
+
hasSubscriptions: () => boolean;
|
|
186
|
+
clearSubscriptions: () => void;
|
|
187
|
+
emit: (data: EdgeInsets) => void;
|
|
188
|
+
};
|
|
189
|
+
|
|
174
190
|
declare const INTERNAL__onVisibilityChangedByTransparentServiceWeb: typeof onVisibilityChangedByTransparentServiceWeb;
|
|
175
191
|
|
|
176
192
|
declare const loadFullScreenAd: {
|
|
@@ -238,4 +254,4 @@ declare const Analytics: {
|
|
|
238
254
|
Area: ({ children, params: _params, ...props }: _apps_in_toss_analytics.LoggingAreaProps) => react_jsx_runtime.JSX.Element;
|
|
239
255
|
};
|
|
240
256
|
|
|
241
|
-
export { type AdError, Analytics, AppsInToss, type BannerSlotCallbacks, type BannerSlotErrorPayload, type BannerSlotEventPayload, type ExternalWebViewProps, type GameWebViewProps, INTERNAL__onVisibilityChangedByTransparentServiceWeb, InlineAd, type InlineAdProps, type InlineAdTheme, type InlineAdTone, type InlineAdVariant, type PartnerWebViewProps, type UseGeolocationOptions, WebView, type WebViewProps, env, loadFullScreenAd, showFullScreenAd, useCreateUserAgent, useGeolocation, useTopNavigation, useWaitForReturnNavigator };
|
|
257
|
+
export { type AdError, Analytics, AppsInToss, type BannerSlotCallbacks, type BannerSlotErrorPayload, type BannerSlotEventPayload, type ExternalWebViewProps, type GameWebViewProps, INTERNAL__onVisibilityChangedByTransparentServiceWeb, InlineAd, type InlineAdProps, type InlineAdTheme, type InlineAdTone, type InlineAdVariant, type PartnerWebViewProps, type UseGeolocationOptions, WebView, type WebViewProps, env, homeEvent, loadFullScreenAd, safeAreaInsetsChange, showFullScreenAd, useCreateUserAgent, useGeolocation, useTopNavigation, useWaitForReturnNavigator };
|
package/dist/index.d.ts
CHANGED
|
@@ -9,6 +9,7 @@ import { ExternalWebViewScreenProps } from '@toss/tds-react-native';
|
|
|
9
9
|
import { StartUpdateLocationOptions, Location, LoadFullScreenAdParams, ShowFullScreenAdParams } from '@apps-in-toss/types';
|
|
10
10
|
export * from '@apps-in-toss/types';
|
|
11
11
|
export { FetchTossAdOptions, LoadFullScreenAdEvent, LoadFullScreenAdOptions, LoadFullScreenAdParams, ShowFullScreenAdEvent, ShowFullScreenAdOptions, ShowFullScreenAdParams, TossAdEventLogParams } from '@apps-in-toss/types';
|
|
12
|
+
import { EdgeInsets } from '@granite-js/native/react-native-safe-area-context';
|
|
12
13
|
import { onVisibilityChangedByTransparentServiceWeb } from '@apps-in-toss/native-modules';
|
|
13
14
|
export * from '@apps-in-toss/native-modules';
|
|
14
15
|
export { OverlayProvider, useOverlay } from '@toss/tds-react-native/private';
|
|
@@ -171,6 +172,21 @@ declare const env: {
|
|
|
171
172
|
getAppName: () => string;
|
|
172
173
|
};
|
|
173
174
|
|
|
175
|
+
declare const homeEvent: {
|
|
176
|
+
name: string;
|
|
177
|
+
subscribe: (listener: (data: any) => void) => () => void;
|
|
178
|
+
hasSubscriptions: () => boolean;
|
|
179
|
+
clearSubscriptions: () => void;
|
|
180
|
+
emit: (data: any) => void;
|
|
181
|
+
};
|
|
182
|
+
declare const safeAreaInsetsChange: {
|
|
183
|
+
name: string;
|
|
184
|
+
subscribe: (listener: (data: EdgeInsets) => void) => () => void;
|
|
185
|
+
hasSubscriptions: () => boolean;
|
|
186
|
+
clearSubscriptions: () => void;
|
|
187
|
+
emit: (data: EdgeInsets) => void;
|
|
188
|
+
};
|
|
189
|
+
|
|
174
190
|
declare const INTERNAL__onVisibilityChangedByTransparentServiceWeb: typeof onVisibilityChangedByTransparentServiceWeb;
|
|
175
191
|
|
|
176
192
|
declare const loadFullScreenAd: {
|
|
@@ -238,4 +254,4 @@ declare const Analytics: {
|
|
|
238
254
|
Area: ({ children, params: _params, ...props }: _apps_in_toss_analytics.LoggingAreaProps) => react_jsx_runtime.JSX.Element;
|
|
239
255
|
};
|
|
240
256
|
|
|
241
|
-
export { type AdError, Analytics, AppsInToss, type BannerSlotCallbacks, type BannerSlotErrorPayload, type BannerSlotEventPayload, type ExternalWebViewProps, type GameWebViewProps, INTERNAL__onVisibilityChangedByTransparentServiceWeb, InlineAd, type InlineAdProps, type InlineAdTheme, type InlineAdTone, type InlineAdVariant, type PartnerWebViewProps, type UseGeolocationOptions, WebView, type WebViewProps, env, loadFullScreenAd, showFullScreenAd, useCreateUserAgent, useGeolocation, useTopNavigation, useWaitForReturnNavigator };
|
|
257
|
+
export { type AdError, Analytics, AppsInToss, type BannerSlotCallbacks, type BannerSlotErrorPayload, type BannerSlotEventPayload, type ExternalWebViewProps, type GameWebViewProps, INTERNAL__onVisibilityChangedByTransparentServiceWeb, InlineAd, type InlineAdProps, type InlineAdTheme, type InlineAdTone, type InlineAdVariant, type PartnerWebViewProps, type UseGeolocationOptions, WebView, type WebViewProps, env, homeEvent, loadFullScreenAd, safeAreaInsetsChange, showFullScreenAd, useCreateUserAgent, useGeolocation, useTopNavigation, useWaitForReturnNavigator };
|
package/dist/index.js
CHANGED
|
@@ -707,6 +707,46 @@ function useCloseConfirm() {
|
|
|
707
707
|
);
|
|
708
708
|
}
|
|
709
709
|
|
|
710
|
+
// src/utils/eventEmitter.ts
|
|
711
|
+
var EventEmitter = class {
|
|
712
|
+
listeners = {};
|
|
713
|
+
subscribe(event, listener) {
|
|
714
|
+
if (!this.listeners[event]) {
|
|
715
|
+
this.listeners[event] = [];
|
|
716
|
+
}
|
|
717
|
+
this.listeners[event].push(listener);
|
|
718
|
+
return () => {
|
|
719
|
+
this.listeners[event] = this.listeners[event]?.filter((l) => l !== listener) ?? [];
|
|
720
|
+
};
|
|
721
|
+
}
|
|
722
|
+
hasSubscriptions(event) {
|
|
723
|
+
return this.listeners[event] != null && this.listeners[event].length > 0;
|
|
724
|
+
}
|
|
725
|
+
clearSubscriptions(event) {
|
|
726
|
+
this.listeners[event] = [];
|
|
727
|
+
}
|
|
728
|
+
emit(event, ...args) {
|
|
729
|
+
if (!this.listeners[event]) {
|
|
730
|
+
return;
|
|
731
|
+
}
|
|
732
|
+
this.listeners[event].forEach((listener) => listener(...args));
|
|
733
|
+
}
|
|
734
|
+
};
|
|
735
|
+
var eventEmitter = new EventEmitter();
|
|
736
|
+
function createEvent(event) {
|
|
737
|
+
return {
|
|
738
|
+
name: event,
|
|
739
|
+
subscribe: (listener) => eventEmitter.subscribe(event, listener),
|
|
740
|
+
hasSubscriptions: () => eventEmitter.hasSubscriptions(event),
|
|
741
|
+
clearSubscriptions: () => eventEmitter.clearSubscriptions(event),
|
|
742
|
+
emit: (data) => eventEmitter.emit(event, data)
|
|
743
|
+
};
|
|
744
|
+
}
|
|
745
|
+
|
|
746
|
+
// src/events.ts
|
|
747
|
+
var homeEvent = createEvent("homeEvent");
|
|
748
|
+
var safeAreaInsetsChange = createEvent("safeAreaInsetsChange");
|
|
749
|
+
|
|
710
750
|
// src/components/NavigationBar/common/useNavigationBarLogging.tsx
|
|
711
751
|
import { INTERNAL__module as INTERNAL__module4 } from "@apps-in-toss/native-modules";
|
|
712
752
|
import { Granite as Granite4 } from "@granite-js/react-native";
|
|
@@ -821,7 +861,11 @@ function useNavigationEvent() {
|
|
|
821
861
|
},
|
|
822
862
|
handleHomeButtonClick: () => {
|
|
823
863
|
logging.homeButtonClick();
|
|
824
|
-
|
|
864
|
+
if (homeEvent.hasSubscriptions()) {
|
|
865
|
+
homeEvent.emit({});
|
|
866
|
+
} else {
|
|
867
|
+
navigation.navigate("/");
|
|
868
|
+
}
|
|
825
869
|
},
|
|
826
870
|
handleCloseButtonClick: () => {
|
|
827
871
|
logging.closeButtonClick();
|
|
@@ -1416,7 +1460,7 @@ import { useSafeAreaInsets as useSafeAreaInsets4 } from "@granite-js/native/reac
|
|
|
1416
1460
|
import { getSchemeUri as getSchemeUri8 } from "@granite-js/react-native";
|
|
1417
1461
|
import { ExternalWebViewScreen, tdsEvent } from "@toss/tds-react-native";
|
|
1418
1462
|
import { useSafeAreaBottom, useSafeAreaTop as useSafeAreaTop3 } from "@toss/tds-react-native/private";
|
|
1419
|
-
import { useEffect as useEffect13, useMemo as
|
|
1463
|
+
import { useEffect as useEffect13, useMemo as useMemo6, useRef as useRef6, useState as useState6 } from "react";
|
|
1420
1464
|
import { BackHandler as BackHandler2, Linking, NativeModules as NativeModules3, Platform as Platform6 } from "react-native";
|
|
1421
1465
|
|
|
1422
1466
|
// src/components/GameWebView.tsx
|
|
@@ -2082,50 +2126,28 @@ function parseNativeEventData(data) {
|
|
|
2082
2126
|
}
|
|
2083
2127
|
}
|
|
2084
2128
|
|
|
2085
|
-
// src/core/hooks/
|
|
2129
|
+
// src/core/hooks/useSafeAreaInsetsEvent.tsx
|
|
2086
2130
|
import { useSafeAreaInsets as useSafeAreaInsets3 } from "@granite-js/native/react-native-safe-area-context";
|
|
2087
|
-
import { useEffect as useEffect11
|
|
2088
|
-
|
|
2089
|
-
listeners = {};
|
|
2090
|
-
on(event, listener) {
|
|
2091
|
-
if (!this.listeners[event]) {
|
|
2092
|
-
this.listeners[event] = [];
|
|
2093
|
-
}
|
|
2094
|
-
this.listeners[event].push(listener);
|
|
2095
|
-
}
|
|
2096
|
-
emit(event, ...args) {
|
|
2097
|
-
if (!this.listeners[event]) {
|
|
2098
|
-
return;
|
|
2099
|
-
}
|
|
2100
|
-
this.listeners[event].forEach((listener) => listener(...args));
|
|
2101
|
-
}
|
|
2102
|
-
off(event, listener) {
|
|
2103
|
-
if (!this.listeners[event]) {
|
|
2104
|
-
return;
|
|
2105
|
-
}
|
|
2106
|
-
this.listeners[event] = this.listeners[event].filter((l) => l !== listener);
|
|
2107
|
-
}
|
|
2108
|
-
};
|
|
2109
|
-
function useSafeAreaInsetsEmitter() {
|
|
2131
|
+
import { useEffect as useEffect11 } from "react";
|
|
2132
|
+
function useSafeAreaInsetsEvent() {
|
|
2110
2133
|
const insets = useSafeAreaInsets3();
|
|
2111
|
-
const emitter = useMemo4(() => new EventEmitter(), []);
|
|
2112
2134
|
useEffect11(() => {
|
|
2113
|
-
|
|
2114
|
-
|
|
2115
|
-
|
|
2116
|
-
|
|
2117
|
-
}, [
|
|
2118
|
-
return
|
|
2135
|
+
safeAreaInsetsChange.emit(insets);
|
|
2136
|
+
}, [insets]);
|
|
2137
|
+
useEffect11(() => {
|
|
2138
|
+
return () => safeAreaInsetsChange.clearSubscriptions();
|
|
2139
|
+
}, []);
|
|
2140
|
+
return safeAreaInsetsChange;
|
|
2119
2141
|
}
|
|
2120
2142
|
|
|
2121
2143
|
// src/core/hooks/useWebBackHandler.tsx
|
|
2122
2144
|
import { closeView as closeView6, useBackEventState } from "@granite-js/react-native";
|
|
2123
2145
|
import { useDialog as useDialog7 } from "@toss/tds-react-native";
|
|
2124
2146
|
import { josa as josa5 } from "es-hangul";
|
|
2125
|
-
import { useCallback as useCallback12, useMemo as
|
|
2147
|
+
import { useCallback as useCallback12, useMemo as useMemo5 } from "react";
|
|
2126
2148
|
|
|
2127
2149
|
// src/hooks/useWebviewHistoryStack.tsx
|
|
2128
|
-
import { useCallback as useCallback11, useMemo as
|
|
2150
|
+
import { useCallback as useCallback11, useMemo as useMemo4, useReducer } from "react";
|
|
2129
2151
|
var INITIAL_STATE = { stack: [], index: -1 };
|
|
2130
2152
|
function reducer(state, action) {
|
|
2131
2153
|
switch (action.type) {
|
|
@@ -2160,7 +2182,7 @@ function useWebViewHistory() {
|
|
|
2160
2182
|
const onNavigationStateChange = useCallback11(({ url, canGoForward: canGoForward2 }) => {
|
|
2161
2183
|
dispatch({ type: "NAVIGATION_CHANGE", url, canGoForward: canGoForward2 });
|
|
2162
2184
|
}, []);
|
|
2163
|
-
const { canGoBack, canGoForward } =
|
|
2185
|
+
const { canGoBack, canGoForward } = useMemo4(() => {
|
|
2164
2186
|
const canBack = state.index > 0;
|
|
2165
2187
|
const canFwd = state.index >= 0 && state.index < state.stack.length - 1;
|
|
2166
2188
|
return { canGoBack: canBack, canGoForward: canFwd };
|
|
@@ -2228,10 +2250,8 @@ function useWebBackHandler(webViewInitialURL, webViewRef) {
|
|
|
2228
2250
|
]);
|
|
2229
2251
|
const handleWebHome = useCallback12(() => {
|
|
2230
2252
|
logging.homeButtonClick();
|
|
2231
|
-
if (
|
|
2232
|
-
|
|
2233
|
-
handler();
|
|
2234
|
-
}
|
|
2253
|
+
if (homeEvent.hasSubscriptions()) {
|
|
2254
|
+
homeEvent.emit({});
|
|
2235
2255
|
return;
|
|
2236
2256
|
}
|
|
2237
2257
|
webViewRef.current?.injectJavaScript(`
|
|
@@ -2241,7 +2261,7 @@ function useWebBackHandler(webViewInitialURL, webViewRef) {
|
|
|
2241
2261
|
})();
|
|
2242
2262
|
`);
|
|
2243
2263
|
}, [hasWebBackEvent, webBackHandlersRef, logging, webViewInitialURL, webViewRef]);
|
|
2244
|
-
return
|
|
2264
|
+
return useMemo5(
|
|
2245
2265
|
() => ({ addEventListener, removeEventListener, handleWebBack, handleWebHome, onNavigationStateChange }),
|
|
2246
2266
|
[addEventListener, removeEventListener, handleWebBack, handleWebHome, onNavigationStateChange]
|
|
2247
2267
|
);
|
|
@@ -2601,14 +2621,14 @@ function WebView({ type, local, onMessage, ...props }) {
|
|
|
2601
2621
|
throw new Error(`Invalid WebView type: '${type}'`);
|
|
2602
2622
|
}
|
|
2603
2623
|
const webViewRef = useRef6(null);
|
|
2604
|
-
const url =
|
|
2624
|
+
const url = useMemo6(() => getWebViewURL(local), [local]);
|
|
2605
2625
|
const webBackHandler = useWebBackHandler(url, webViewRef);
|
|
2606
2626
|
const top = useSafeAreaTop3();
|
|
2607
2627
|
const bottom = useSafeAreaBottom();
|
|
2608
2628
|
const insets = useSafeAreaInsets4();
|
|
2609
2629
|
const global2 = getAppsInTossGlobals();
|
|
2610
2630
|
const navigationBarContext = useNavigationBarContext();
|
|
2611
|
-
const
|
|
2631
|
+
const safeAreaInsetsEvent = useSafeAreaInsetsEvent();
|
|
2612
2632
|
const [allowsBackForwardNavigationGestures, setAllowsBackForwardNavigationGestures] = useState6(
|
|
2613
2633
|
props.allowsBackForwardNavigationGestures
|
|
2614
2634
|
);
|
|
@@ -2623,13 +2643,9 @@ function WebView({ type, local, onMessage, ...props }) {
|
|
|
2623
2643
|
webBackHandler.removeEventListener(onEvent);
|
|
2624
2644
|
};
|
|
2625
2645
|
},
|
|
2646
|
+
homeEvent: ({ onEvent }) => homeEvent.subscribe(onEvent),
|
|
2626
2647
|
updateLocationEvent: ({ onEvent, onError, options }) => appsInTossEvent.addEventListener("updateLocationEvent", { onEvent, onError, options }),
|
|
2627
|
-
safeAreaInsetsChange: ({ onEvent }) =>
|
|
2628
|
-
safeAreaInsetsEmitter.on("safeAreaInsetsChange", onEvent);
|
|
2629
|
-
return () => {
|
|
2630
|
-
safeAreaInsetsEmitter.off("safeAreaInsetsChange", onEvent);
|
|
2631
|
-
};
|
|
2632
|
-
},
|
|
2648
|
+
safeAreaInsetsChange: ({ onEvent }) => safeAreaInsetsEvent.subscribe(onEvent),
|
|
2633
2649
|
/** @internal */
|
|
2634
2650
|
appBridgeCallbackEvent: ({ onEvent, onError, options }) => appsInTossEvent.addEventListener("appBridgeCallbackEvent", { onEvent, onError, options }),
|
|
2635
2651
|
/** AdMobV2 */
|
|
@@ -2712,7 +2728,7 @@ function WebView({ type, local, onMessage, ...props }) {
|
|
|
2712
2728
|
}
|
|
2713
2729
|
}
|
|
2714
2730
|
});
|
|
2715
|
-
const headerPropForExternalWebView =
|
|
2731
|
+
const headerPropForExternalWebView = useMemo6(() => {
|
|
2716
2732
|
const parsedNavigationBar = global2.navigationBar != null ? safeParseNavigationBar(global2.navigationBar) : null;
|
|
2717
2733
|
const initialAccessoryButton = parsedNavigationBar?.initialAccessoryButton;
|
|
2718
2734
|
const withBackButton = parsedNavigationBar?.withBackButton ?? true;
|
|
@@ -4080,7 +4096,9 @@ export {
|
|
|
4080
4096
|
OverlayProvider,
|
|
4081
4097
|
WebView,
|
|
4082
4098
|
env,
|
|
4099
|
+
homeEvent,
|
|
4083
4100
|
loadFullScreenAd,
|
|
4101
|
+
safeAreaInsetsChange,
|
|
4084
4102
|
showFullScreenAd,
|
|
4085
4103
|
useCreateUserAgent,
|
|
4086
4104
|
useGeolocation,
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@apps-in-toss/framework",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "1.
|
|
4
|
+
"version": "1.14.1",
|
|
5
5
|
"description": "The framework for Apps In Toss",
|
|
6
6
|
"scripts": {
|
|
7
7
|
"typecheck": "tsc --noEmit",
|
|
@@ -55,12 +55,12 @@
|
|
|
55
55
|
"ait": "./bin/ait.js"
|
|
56
56
|
},
|
|
57
57
|
"dependencies": {
|
|
58
|
-
"@apps-in-toss/analytics": "1.
|
|
59
|
-
"@apps-in-toss/cli": "1.
|
|
60
|
-
"@apps-in-toss/native-modules": "1.
|
|
61
|
-
"@apps-in-toss/plugins": "1.
|
|
62
|
-
"@apps-in-toss/types": "1.
|
|
63
|
-
"@apps-in-toss/user-scripts": "^1.
|
|
58
|
+
"@apps-in-toss/analytics": "1.14.1",
|
|
59
|
+
"@apps-in-toss/cli": "1.14.1",
|
|
60
|
+
"@apps-in-toss/native-modules": "1.14.1",
|
|
61
|
+
"@apps-in-toss/plugins": "1.14.1",
|
|
62
|
+
"@apps-in-toss/types": "1.14.1",
|
|
63
|
+
"@apps-in-toss/user-scripts": "^1.14.1",
|
|
64
64
|
"es-hangul": "^2.3.2"
|
|
65
65
|
},
|
|
66
66
|
"devDependencies": {
|