@applicaster/zapp-react-native-utils 16.0.0-alpha.1263110541 → 16.0.0-alpha.1314750780

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.
Files changed (120) hide show
  1. package/actionUtils/index.ts +3 -1
  2. package/actionsExecutor/ActionExecutor.ts +10 -1
  3. package/actionsExecutor/ActionExecutorContext.tsx +13 -1
  4. package/actionsExecutor/__tests__/ActionExecutor.test.ts +71 -0
  5. package/actionsExecutor/__tests__/StorageActions.test.ts +98 -0
  6. package/actionsExecutor/__tests__/feedDecorator.test.ts +30 -0
  7. package/actionsExecutor/__tests__/screenToggleFlag.test.ts +90 -0
  8. package/actionsExecutor/actions/__tests__/dismissBottomSheet.test.ts +3 -0
  9. package/actionsExecutor/actions/__tests__/navigateToScreen.test.ts +186 -5
  10. package/actionsExecutor/actions/__tests__/openBottomSheet.customContent.test.ts +24 -0
  11. package/actionsExecutor/actions/__tests__/openBottomSheet.inlineItems.test.ts +273 -1
  12. package/actionsExecutor/actions/__tests__/presentScreen.test.ts +127 -0
  13. package/actionsExecutor/actions/__tests__/showAlert.test.ts +49 -0
  14. package/actionsExecutor/actions/__tests__/showToast.test.ts +2 -2
  15. package/actionsExecutor/actions/dismissBottomSheet.ts +2 -1
  16. package/actionsExecutor/actions/index.ts +4 -0
  17. package/actionsExecutor/actions/navigateToScreen.ts +33 -43
  18. package/actionsExecutor/actions/openBottomSheet.ts +36 -16
  19. package/actionsExecutor/actions/presentScreen.ts +78 -0
  20. package/actionsExecutor/actions/screenToggleFlag.ts +1 -3
  21. package/actionsExecutor/actions/showAlert.ts +51 -0
  22. package/actionsExecutor/actions/showToast.ts +2 -2
  23. package/actionsExecutor/consts.ts +2 -0
  24. package/actionsExecutor/feedDecorator.ts +6 -0
  25. package/actionsExecutor/types.ts +7 -0
  26. package/appUtils/contextKeysManager/__tests__/getKey/failure.test.ts +1 -22
  27. package/appUtils/contextKeysManager/__tests__/getKey/success/fullSearch.test.ts +1 -25
  28. package/appUtils/contextKeysManager/__tests__/getKey/success/searchInSecure.test.ts +1 -7
  29. package/appUtils/contextKeysManager/__tests__/removeKey/failure.test.ts +0 -25
  30. package/appUtils/contextKeysManager/__tests__/removeKey/success.test.ts +0 -6
  31. package/appUtils/contextKeysManager/__tests__/setKey/failure/failedToSaveInStorage.test.ts +0 -40
  32. package/appUtils/contextKeysManager/__tests__/setKey/{success/saveItemAndReference.test.ts → success.test.ts} +2 -42
  33. package/appUtils/contextKeysManager/index.ts +28 -129
  34. package/appUtils/playerManager/OverlayObserver/OverlaysObserver.ts +4 -11
  35. package/appUtils/playerManager/OverlayObserver/__tests__/getUpcomingQueue.test.ts +67 -0
  36. package/appUtils/playerManager/OverlayObserver/__tests__/utils.test.ts +9 -2
  37. package/appUtils/playerManager/OverlayObserver/getUpcomingQueue.ts +15 -2
  38. package/appUtils/playerManager/OverlayObserver/utils.ts +2 -5
  39. package/appUtils/playerManager/__tests__/playerDiagnostics.test.ts +62 -0
  40. package/appUtils/playerManager/__tests__/playerNative.test.ts +76 -0
  41. package/appUtils/playerManager/__tests__/playerNativeCommand.test.ts +62 -0
  42. package/appUtils/playerManager/__tests__/playerToolbox.test.ts +281 -0
  43. package/appUtils/playerManager/__tests__/usePlayerControllerSetup.test.tsx +62 -0
  44. package/appUtils/playerManager/const.ts +13 -0
  45. package/appUtils/playerManager/index.ts +7 -0
  46. package/appUtils/playerManager/player.ts +25 -0
  47. package/appUtils/playerManager/playerNative.ts +22 -0
  48. package/appUtils/playerManager/playerNativeCommand.ts +3 -6
  49. package/appUtils/playerManager/playerToolbox.ts +196 -0
  50. package/appUtils/playerManager/usePlayerControllerSetup.tsx +6 -0
  51. package/arrayUtils/__tests__/reorderByIds.test.ts +13 -0
  52. package/arrayUtils/index.ts +26 -43
  53. package/cellUtils/__tests__/getButtonsEnabled.test.ts +28 -0
  54. package/cellUtils/__tests__/getCellNavigationEnabled.test.ts +36 -0
  55. package/cellUtils/__tests__/getIsCellNavigationEnabled.test.ts +35 -0
  56. package/cellUtils/__tests__/isCellNavigationEnabled.test.ts +21 -0
  57. package/cellUtils/index.ts +40 -0
  58. package/configurationUtils/__tests__/manifestKeyParser.test.ts +21 -0
  59. package/configurationUtils/__tests__/modalBlocksParser.test.ts +297 -1
  60. package/configurationUtils/manifestKeyParser.ts +12 -1
  61. package/configurationUtils/modalBlocksParser.ts +78 -4
  62. package/entryActions/__tests__/buildEntryActions.test.ts +97 -18
  63. package/entryActions/aliasPresentation.ts +26 -42
  64. package/entryActions/buildEntryActions.ts +1 -0
  65. package/entryActions/index.ts +0 -2
  66. package/focusManager/FocusManager.ts +26 -0
  67. package/focusManager/__tests__/FocusManager.test.ts +9 -0
  68. package/localizationUtils/index.ts +12 -6
  69. package/logger/__tests__/xrayToolbox.test.ts +69 -0
  70. package/logger/xrayToolbox.ts +67 -0
  71. package/manifestUtils/defaultManifestConfigurations/generalContent.js +6 -0
  72. package/manifestUtils/defaultManifestConfigurations/player.js +8 -0
  73. package/manifestUtils/keys.js +7 -2
  74. package/manifestUtils/mobileAction/container/__tests__/mobileActionButtonsContainer.test.js +21 -0
  75. package/manifestUtils/mobileAction/groups/__tests__/buildMobileActionButtonGroups.test.js +1 -1
  76. package/manifestUtils/mobileAction/groups/defaults.js +2 -1
  77. package/modalState/ModalOrchestrator.ts +23 -9
  78. package/modalState/RemoteEditableCollection.ts +9 -1
  79. package/modalState/__tests__/ModalOrchestrator.phase3.test.ts +39 -0
  80. package/modalState/__tests__/RemoteEditableCollection.test.ts +90 -1
  81. package/modalState/__tests__/index.test.ts +30 -1
  82. package/modalState/__tests__/useModalStoreState.test.ts +142 -0
  83. package/modalState/index.ts +8 -1
  84. package/modalState/store.ts +9 -2
  85. package/modalState/types.ts +42 -2
  86. package/modalState/useBottomSheetContent.ts +24 -17
  87. package/navigationUtils/xrayNavigator.ts +12 -0
  88. package/package.json +3 -2
  89. package/pluginUtils/__tests__/pluginUtils.test.js +32 -0
  90. package/pluginUtils/index.ts +29 -0
  91. package/quickBrickAssets/__tests__/index.test.ts +18 -0
  92. package/quickBrickAssets/index.ts +35 -0
  93. package/reactHooks/__tests__/getPluginConfiguration.test.ts +82 -0
  94. package/reactHooks/actions/index.ts +29 -23
  95. package/reactHooks/cell-click/__tests__/index.test.js +131 -1
  96. package/reactHooks/cell-click/index.ts +30 -15
  97. package/reactHooks/connection/index.tsx +8 -5
  98. package/reactHooks/feed/__tests__/feedInvalidation.test.tsx +338 -0
  99. package/reactHooks/feed/__tests__/useBatchLoading.test.tsx +8 -2
  100. package/reactHooks/feed/__tests__/useMarkPipesDataStale.test.tsx +243 -0
  101. package/reactHooks/feed/useFeedLoader.tsx +28 -1
  102. package/reactHooks/feed/useLoadPipesDataDispatch.ts +12 -11
  103. package/reactHooks/feed/useMarkPipesDataStale.ts +68 -23
  104. package/reactHooks/navigation/__tests__/index.test.tsx +176 -1
  105. package/reactHooks/navigation/__tests__/usePresentScreen.test.ts +154 -0
  106. package/reactHooks/navigation/index.ts +2 -0
  107. package/reactHooks/navigation/usePresentScreen.ts +157 -0
  108. package/reactHooks/navigation/useRoute.ts +22 -5
  109. package/reactHooks/usePluginConfiguration.ts +84 -46
  110. package/riverComponetsMeasurementProvider/index.tsx +3 -1
  111. package/uiActionsRegistrator/__tests__/subscribe.test.ts +26 -0
  112. package/uiActionsRegistrator/registry.ts +16 -0
  113. package/appUtils/contextKeysManager/__tests__/getKey/success/byReference.test.ts +0 -56
  114. package/appUtils/contextKeysManager/__tests__/getKeyByReference/failure.test.ts +0 -265
  115. package/appUtils/contextKeysManager/__tests__/getKeyByReference/success.test.ts +0 -303
  116. package/appUtils/contextKeysManager/__tests__/removeReferenceForKey/failure.test.ts +0 -82
  117. package/appUtils/contextKeysManager/__tests__/removeReferenceForKey/success.test.ts +0 -41
  118. package/appUtils/contextKeysManager/__tests__/setKey/success/saveItemButNotReference.test.ts +0 -208
  119. package/appUtils/contextKeysManager/__tests__/setReferenceForKey/failure.test.ts +0 -93
  120. package/appUtils/contextKeysManager/__tests__/setReferenceForKey/success.test.ts +0 -45
@@ -0,0 +1,82 @@
1
+ import { renderHook } from "@testing-library/react-native";
2
+
3
+ const plugin = {
4
+ identifier: "cast",
5
+ configuration: {
6
+ title: "Configured",
7
+ localizations: { fr: { close: "Fermer" } },
8
+ },
9
+ };
10
+
11
+ jest.mock("@applicaster/zapp-react-native-redux/hooks", () => ({
12
+ usePlugins: () => [plugin],
13
+ }));
14
+
15
+ jest.mock(
16
+ "@applicaster/zapp-react-native-utils/appUtils/localizationsHelper",
17
+ () => ({ getUILanguage: () => "fr" })
18
+ );
19
+
20
+ import {
21
+ getPluginConfiguration,
22
+ mergeLocalizations,
23
+ usePluginConfiguration,
24
+ } from "../usePluginConfiguration";
25
+
26
+ const manifest = {
27
+ custom_configuration_fields: [
28
+ { key: "title", initial_value: "Default" },
29
+ { key: "color", initial_value: "red" },
30
+ ],
31
+ localizations: {
32
+ fields: [
33
+ { key: "close", initial_value: "Close" },
34
+ { key: "cancel", initial_value: "Cancel" },
35
+ ],
36
+ },
37
+ };
38
+
39
+ it("matches usePluginConfiguration outside React", () => {
40
+ const { result } = renderHook(() => usePluginConfiguration("cast", manifest));
41
+
42
+ expect(getPluginConfiguration(plugin, manifest)).toEqual(result.current);
43
+ });
44
+
45
+ // Expected values are what R.mergeDeepWith((l, r) => (isNil(l) ? r : l)) returned before ramda was removed
46
+ describe("mergeLocalizations", () => {
47
+ const defaults = { en: { close: "Close", cancel: "Cancel" } };
48
+
49
+ it("returns the defaults when nothing is configured", () => {
50
+ expect(mergeLocalizations(undefined, defaults)).toEqual(defaults);
51
+ });
52
+
53
+ it("keeps configured values, fills nil ones and missing keys from defaults", () => {
54
+ expect(
55
+ mergeLocalizations(
56
+ { en: { close: null, extra: "X" }, fr: { close: "Fermer" } },
57
+ defaults
58
+ )
59
+ ).toEqual({
60
+ en: { close: "Close", extra: "X", cancel: "Cancel" },
61
+ fr: { close: "Fermer" },
62
+ });
63
+ });
64
+
65
+ it("does not merge arrays", () => {
66
+ expect(
67
+ mergeLocalizations(
68
+ { en: { close: ["a"] } },
69
+ { en: { close: ["b"], cancel: "C" } }
70
+ )
71
+ ).toEqual({ en: { close: ["a"], cancel: "C" } });
72
+ });
73
+ });
74
+
75
+ it("keeps configured languages first, so the fallback language stays the configured one", () => {
76
+ const merged = mergeLocalizations(
77
+ { he: { close: "סגור" }, en: { close: "Close it" } },
78
+ { en: { close: "Close" } }
79
+ );
80
+
81
+ expect(Object.keys(merged)).toEqual(["he", "en"]);
82
+ });
@@ -21,17 +21,45 @@ type ActionContexts<T = unknown> = {
21
21
  };
22
22
 
23
23
  /**
24
- * React Hook to subscribe to the custom action context
24
+ * A value that changes whenever a provider is added to or removed from
25
+ * `uiActionsRegistry`.
26
+ *
27
+ * Providers can register after the UI that wants them has rendered - the audio
28
+ * player registers playback speed only once its controller has state, and
29
+ * plugin-backed actions are bridged in from an effect. Put this in the
30
+ * dependency list of anything that resolves actions, so the list is re-read
31
+ * instead of being frozen at first paint.
32
+ */
33
+ export function useRegistryRevision(): number {
34
+ const [revision, setRevision] = useState(0);
35
+
36
+ useEffect(
37
+ () =>
38
+ uiActionsRegistry.subscribe(() => setRevision((current) => current + 1)),
39
+ []
40
+ );
41
+
42
+ return revision;
43
+ }
44
+
45
+ /**
46
+ * Resolves a legacy action context or falls back to the UI action registry.
25
47
  * @param {*} plugId - subscribes to the context of that action plugin
26
48
  * @return {*} - global action provider context or context for specific action plugin
27
49
  */
28
50
  export function useActions<T = unknown>(plugId: string): any {
29
51
  const [logged, setLogged] = useState(false);
30
52
  const context = useContext<ActionContexts<T>>(ActionsContext);
53
+ useRegistryRevision();
54
+
31
55
  const actionContext = context?.actions?.[plugId]?.module?.context;
32
56
 
33
57
  if (plugId) {
34
58
  if (!actionContext) {
59
+ const registeredAction = uiActionsRegistry.getAction(plugId);
60
+
61
+ if (registeredAction) return registeredAction;
62
+
35
63
  if (!logged) {
36
64
  logger.warning({
37
65
  message: `useActions: Couldn't find an action for ${plugId} plugin`,
@@ -139,25 +167,3 @@ export function useEntryActionState(
139
167
 
140
168
  return { state, invokeAction };
141
169
  }
142
-
143
- /**
144
- * A value that changes whenever a provider is added to or removed from
145
- * `uiActionsRegistry`.
146
- *
147
- * Providers can register after the UI that wants them has rendered - the audio
148
- * player registers playback speed only once its controller has state, and
149
- * plugin-backed actions are bridged in from an effect. Put this in the
150
- * dependency list of anything that resolves actions, so the list is re-read
151
- * instead of being frozen at first paint.
152
- */
153
- export function useRegistryRevision(): number {
154
- const [revision, setRevision] = useState(0);
155
-
156
- useEffect(
157
- () =>
158
- uiActionsRegistry.subscribe(() => setRevision((current) => current + 1)),
159
- []
160
- );
161
-
162
- return revision;
163
- }
@@ -5,6 +5,7 @@ import { ActionExecutorContext } from "@applicaster/zapp-react-native-utils/acti
5
5
 
6
6
  const mockNavigator = {
7
7
  getPathname: () => "pathnameMock",
8
+ currentRoute: "pathnameMock",
8
9
  push: jest.fn(),
9
10
  data: {},
10
11
  };
@@ -29,14 +30,17 @@ jest.mock("@applicaster/zapp-react-native-utils/reactHooks/screen", () => ({
29
30
  ),
30
31
  useTargetScreenData: jest.fn(() => ({})),
31
32
  useCurrentScreenData: jest.fn(() => ({})),
33
+ useScreenContext: jest.fn(() => ({})),
32
34
  }));
33
35
 
36
+ const mockSetEntryContext = jest.fn();
37
+
34
38
  jest.mock("@applicaster/zapp-react-native-ui-components/Contexts", () => ({
35
39
  ...jest.requireActual(
36
40
  "@applicaster/zapp-react-native-ui-components/Contexts"
37
41
  ),
38
42
  ZappPipesEntryContext: {
39
- useZappPipesContext: jest.fn(() => [undefined, jest.fn()]),
43
+ useZappPipesContext: jest.fn(() => [undefined, mockSetEntryContext]),
40
44
  },
41
45
  }));
42
46
 
@@ -66,6 +70,12 @@ const wrapper = ({ children }) => (
66
70
  </CellTapContext.Provider>
67
71
  );
68
72
 
73
+ const actionExecutorWrapper = ({ children }) => (
74
+ <ActionExecutorContext.Provider value={actionExecutor}>
75
+ {children}
76
+ </ActionExecutorContext.Provider>
77
+ );
78
+
69
79
  describe("useCellClick", () => {
70
80
  it("returns a function", () => {
71
81
  const { result } = renderHook(() => useCellClick(mockProps));
@@ -95,4 +105,124 @@ describe("useCellClick", () => {
95
105
 
96
106
  cleanup();
97
107
  });
108
+
109
+ it("does not push when the cell finishes a hook", async () => {
110
+ mockNavigator.push.mockClear();
111
+
112
+ const item = {
113
+ id: "profile-1",
114
+ type: { value: "feed" },
115
+ extensions: {
116
+ tap_actions: {
117
+ actions: [
118
+ { type: "sessionStorageSet" },
119
+ { type: "finishHook", options: { success: true } },
120
+ ],
121
+ },
122
+ },
123
+ };
124
+
125
+ const { result } = renderHook(() => useCellClick({ item }), {
126
+ wrapper: actionExecutorWrapper,
127
+ });
128
+
129
+ await result.current();
130
+
131
+ await waitFor(() => {
132
+ expect(actionExecutor.handleEntryActions).toHaveBeenCalled();
133
+ });
134
+
135
+ expect(mockNavigator.push).not.toHaveBeenCalled();
136
+ cleanup();
137
+ });
138
+
139
+ it("pushes after tap actions that do not finish a hook", async () => {
140
+ mockNavigator.push.mockClear();
141
+
142
+ const item = {
143
+ id: "episode-1",
144
+ type: { value: "feed" },
145
+ extensions: {
146
+ tap_actions: {
147
+ actions: [{ type: "sessionStorageSet" }],
148
+ },
149
+ },
150
+ };
151
+
152
+ const { result } = renderHook(() => useCellClick({ item }), {
153
+ wrapper: actionExecutorWrapper,
154
+ });
155
+
156
+ await result.current();
157
+
158
+ await waitFor(() => {
159
+ expect(mockNavigator.push).toHaveBeenCalled();
160
+ });
161
+
162
+ cleanup();
163
+ });
164
+
165
+ describe("entry context", () => {
166
+ const tapWith = async (item) => {
167
+ mockSetEntryContext.mockClear();
168
+ actionExecutor.handleEntryActions.mockClear();
169
+
170
+ const { result } = renderHook(() => useCellClick({ item }), {
171
+ wrapper: actionExecutorWrapper,
172
+ });
173
+
174
+ await result.current();
175
+ cleanup();
176
+ };
177
+
178
+ it("is not set on a tap of an action cell", async () => {
179
+ await tapWith({
180
+ id: "team-1",
181
+ type: { value: "action" },
182
+ extensions: {
183
+ tap_actions: {
184
+ actions: [
185
+ { type: "localStorageToggleFlag" },
186
+ { type: "sendCloudEvent" },
187
+ ],
188
+ },
189
+ },
190
+ });
191
+
192
+ expect(mockSetEntryContext).not.toHaveBeenCalled();
193
+ });
194
+
195
+ it("is handed to the actions so an action can set it", async () => {
196
+ await tapWith({
197
+ id: "link-1",
198
+ type: { value: "action" },
199
+ extensions: {
200
+ tap_actions: { actions: [{ type: "navigateToScreen" }] },
201
+ },
202
+ });
203
+
204
+ expect(actionExecutor.handleEntryActions).toHaveBeenCalledWith(
205
+ expect.objectContaining({ id: "link-1" }),
206
+ expect.objectContaining({ setEntryContext: mockSetEntryContext })
207
+ );
208
+ });
209
+
210
+ it("is set after the actions for any other cell", async () => {
211
+ await tapWith({
212
+ id: "episode-2",
213
+ type: { value: "feed" },
214
+ extensions: {
215
+ tap_actions: { actions: [{ type: "localStorageToggleFlag" }] },
216
+ },
217
+ });
218
+
219
+ expect(mockSetEntryContext).toHaveBeenCalledWith(
220
+ expect.objectContaining({ id: "episode-2" })
221
+ );
222
+
223
+ expect(
224
+ actionExecutor.handleEntryActions.mock.invocationCallOrder[0]
225
+ ).toBeLessThan(mockSetEntryContext.mock.invocationCallOrder[0]);
226
+ });
227
+ });
98
228
  });
@@ -71,7 +71,6 @@ export const useCellClick = ({
71
71
  // Making sure we are not getting GestureResponderEvent in here.
72
72
  const isZappEntry = _item?.id && _item?.type;
73
73
  const selectedItem = isZappEntry ? _item : item;
74
- setEntryContext?.(selectedItem);
75
74
 
76
75
  if (!selectedItem?.type?.value) {
77
76
  warnEmptyContentType(selectedItem);
@@ -83,8 +82,15 @@ export const useCellClick = ({
83
82
 
84
83
  logOnPress(selectedItem, pathname, component, onCellTap);
85
84
 
85
+ const tapActions = selectedItem?.extensions?.tap_actions?.actions;
86
+
87
+ const finishesHook =
88
+ Array.isArray(tapActions) &&
89
+ tapActions.some((action) => action?.type === "finishHook");
90
+
86
91
  if (selectedItem) {
87
92
  await actionExecutor?.handleEntryActions(selectedItem, {
93
+ setEntryContext,
88
94
  component,
89
95
  screenData,
90
96
  screenState,
@@ -101,20 +107,29 @@ export const useCellClick = ({
101
107
  url: selectedItem.link.href,
102
108
  });
103
109
  }
104
- } else {
105
- if (isFunction(onCellTap)) {
106
- onCellTap?.(selectedItem, _index);
107
- } else {
108
- if (currentRoute === pathname || pathname.includes("video-modal")) {
109
- const targetScreen = component?.data?.target;
110
-
111
- push(
112
- R.when(
113
- () => targetScreen,
114
- R.mergeLeft({ screen_type: targetScreen })
115
- )(selectedItem)
116
- );
117
- }
110
+
111
+ // An action cell does not open a screen by itself: the actions that do
112
+ // (navigateToScreen) set the entry context for it.
113
+ return;
114
+ }
115
+
116
+ setEntryContext?.(selectedItem);
117
+
118
+ if (isFunction(onCellTap)) {
119
+ onCellTap?.(selectedItem, _index);
120
+ } else if (!finishesHook) {
121
+ // finishHook already completes the hook and navigates to the original
122
+ // target. Pushing the cell as well stacks a second copy of that screen
123
+ // (e.g. home/home after a profile selector hook).
124
+ if (currentRoute === pathname || pathname.includes("video-modal")) {
125
+ const targetScreen = component?.data?.target;
126
+
127
+ push(
128
+ R.when(
129
+ () => targetScreen,
130
+ R.mergeLeft({ screen_type: targetScreen })
131
+ )(selectedItem)
132
+ );
118
133
  }
119
134
  }
120
135
  },
@@ -4,6 +4,11 @@ import { NetInfoState } from "@react-native-community/netinfo";
4
4
  import { NetworkStatusContext } from "@applicaster/zapp-react-native-ui-components/Contexts/NetworkStatusContext";
5
5
  import { isOnline } from "@applicaster/quick-brick-core/App/NetworkStatusProvider/utils";
6
6
 
7
+ type ConnectionInfo = NetInfoState & {
8
+ deviceStatus: NetStatus;
9
+ stillOfflineAfterResumeCount?: number;
10
+ };
11
+
7
12
  /**
8
13
  * This hook returns connection type from RN NetInfo component or boolean for iConnected if justOnlineStatus flag is set
9
14
  * @param {boolean} justOnlineStatus - flag if to return boolean for isConnected
@@ -12,16 +17,14 @@ import { isOnline } from "@applicaster/quick-brick-core/App/NetworkStatusProvide
12
17
 
13
18
  export function useConnectionInfo(justOnlineStatus: true): boolean;
14
19
 
15
- export function useConnectionInfo(
16
- justOnlineStatus: false
17
- ): NetInfoState & { deviceStatus: NetStatus };
20
+ export function useConnectionInfo(justOnlineStatus: false): ConnectionInfo;
18
21
 
19
22
  export function useConnectionInfo(
20
23
  justOnlineStatus: boolean
21
- ): boolean | (NetInfoState & { deviceStatus: NetStatus }) {
24
+ ): boolean | ConnectionInfo {
22
25
  const connectionInfo = React.useContext(
23
26
  NetworkStatusContext
24
- ) as NetInfoState & { deviceStatus: NetStatus };
27
+ ) as ConnectionInfo;
25
28
 
26
29
  return justOnlineStatus ? isOnline(connectionInfo) === true : connectionInfo;
27
30
  }