@applicaster/quick-brick-core 16.0.0-alpha.4880104344 → 16.0.0-alpha.4934353272

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 (84) hide show
  1. package/App/ActionSetters/index.ts +2 -2
  2. package/App/ActionsProvider/ActionsProvider.tsx +31 -9
  3. package/App/ActionsProvider/LegacyActionsRegistryAdapter.tsx +123 -0
  4. package/App/ActionsProvider/__tests__/LegacyActionsRegistryAdapter.test.tsx +64 -0
  5. package/App/AssetCache/logger.ts +1 -1
  6. package/App/DeepLinking/URLSchemeHandler/SchemeHandlerHooks/__tests__/useOpenSchemeHandler.test.tsx +25 -15
  7. package/App/DeepLinking/URLSchemeHandler/SchemeHandlerHooks/usePresentSchemeHandler.ts +3 -0
  8. package/App/DeepLinking/URLSchemeListener/URLSchemeContextProvider.tsx +4 -1
  9. package/App/DeepLinking/logger.ts +1 -1
  10. package/App/ErrorBoundary/index.tsx +5 -2
  11. package/App/ModalProvider/ModalBottomSheet/DraggableBottomSheet/__tests__/index.test.tsx +88 -0
  12. package/App/ModalProvider/ModalBottomSheet/DraggableBottomSheet/index.tsx +30 -56
  13. package/App/ModalProvider/ModalBottomSheet/ModalBottomSheetFrame.tsx +9 -2
  14. package/App/ModalProvider/ModalBottomSheet/hooks/__tests__/useKeyboardHeight.android.test.ts +105 -0
  15. package/App/ModalProvider/ModalBottomSheet/hooks/__tests__/useKeyboardHeight.test.ts +102 -0
  16. package/App/ModalProvider/ModalBottomSheet/hooks/index.ts +1 -0
  17. package/App/ModalProvider/ModalBottomSheet/hooks/useKeyboardHeight.ts +30 -0
  18. package/App/ModalProvider/ModalBottomSheet/index.tsx +5 -2
  19. package/App/ModalProvider/ModalContent.tsx +3 -0
  20. package/App/ModalProvider/__tests__/ModalContent.test.tsx +39 -0
  21. package/App/ModalProvider/__tests__/index.test.tsx +99 -0
  22. package/App/ModalProvider/index.tsx +39 -14
  23. package/App/NavigationProvider/NavigationProvider.tsx +73 -12
  24. package/App/NavigationProvider/__tests__/navToolbox.test.ts +227 -0
  25. package/App/NavigationProvider/__tests__/navigationProvider.test.tsx +56 -0
  26. package/App/NavigationProvider/__tests__/utils.test.ts +31 -1
  27. package/App/NavigationProvider/navToolbox.ts +224 -0
  28. package/App/NavigationProvider/utils.ts +37 -2
  29. package/App/NetworkStatusProvider/NetworkStatusProvider.tsx +40 -4
  30. package/App/NetworkStatusProvider/ResumeVerificationController.ts +282 -0
  31. package/App/NetworkStatusProvider/__tests__/NetworkStatusProvider.test.tsx +167 -1
  32. package/App/NetworkStatusProvider/__tests__/ResumeVerificationController.test.ts +486 -0
  33. package/App/NetworkStatusProvider/__tests__/resumeVerification.test.ts +126 -0
  34. package/App/NetworkStatusProvider/__tests__/useResumeVerifiedNetInfo.test.ts +204 -0
  35. package/App/NetworkStatusProvider/resumeVerification.ts +54 -0
  36. package/App/NetworkStatusProvider/useResumeVerifiedNetInfo.ts +33 -0
  37. package/App/NotificationToastRenderer/NotificationToastManager.ts +214 -0
  38. package/App/NotificationToastRenderer/NotificationToastRenderer.tsx +134 -0
  39. package/App/NotificationToastRenderer/NotificationToastRenderer.tv.tsx +10 -0
  40. package/App/NotificationToastRenderer/NotificationToastRenderer.web.tsx +61 -0
  41. package/App/NotificationToastRenderer/__tests__/NotificationToastManager.test.ts +237 -0
  42. package/App/NotificationToastRenderer/__tests__/NotificationToastRenderer.test.tsx +233 -0
  43. package/App/NotificationToastRenderer/__tests__/NotificationToastRenderer.web.test.tsx +90 -0
  44. package/App/NotificationToastRenderer/__tests__/resolveConfirmationToastStyle.test.ts +118 -0
  45. package/App/NotificationToastRenderer/__tests__/useNotificationHeight.test.tsx +58 -0
  46. package/App/NotificationToastRenderer/__tests__/useNotificationToastState.test.ts +112 -0
  47. package/App/NotificationToastRenderer/index.tsx +9 -0
  48. package/App/NotificationToastRenderer/resolveConfirmationToastStyle.ts +33 -0
  49. package/App/NotificationToastRenderer/useNotificationHeight.tsx +14 -0
  50. package/App/NotificationToastRenderer/useNotificationToastState.tsx +12 -0
  51. package/App/ThemeManager/index.tsx +6 -1
  52. package/App/appLifeCycleManager/index.tsx +2 -2
  53. package/App/appRemoteDataLoader/index.tsx +2 -2
  54. package/App/appRemoteDataLoader/remoteDataLoader.ts +2 -2
  55. package/App/index.tsx +16 -7
  56. package/App/layoutPreview/LayoutPreviewReminder.tsx +136 -0
  57. package/App/layoutPreview/__tests__/persistence.test.ts +63 -0
  58. package/App/layoutPreview/persistence.ts +228 -0
  59. package/App/logger.js +2 -2
  60. package/App/remoteContextReloader/__tests__/getNativeRemoteContextData.test.ts +148 -0
  61. package/App/remoteContextReloader/__tests__/getPromiseForType.test.js +31 -0
  62. package/App/remoteContextReloader/getRemoteContextData/getNativeRemoteContextData.ts +107 -29
  63. package/App/remoteContextReloader/helpers.ts +2 -1
  64. package/App/uiActions/index.ts +13 -0
  65. package/App/uiActions/muteUnmute/__tests__/assetResolver.test.ts +226 -0
  66. package/App/uiActions/muteUnmute/__tests__/binding.test.ts +51 -0
  67. package/App/uiActions/muteUnmute/__tests__/defaultAssets.test.ts +73 -0
  68. package/App/uiActions/muteUnmute/__tests__/entryState.test.ts +57 -0
  69. package/App/uiActions/muteUnmute/__tests__/labelResolver.test.ts +35 -0
  70. package/App/uiActions/muteUnmute/assetResolver.ts +87 -0
  71. package/App/uiActions/muteUnmute/assets/action/flavour_1/mute.png +0 -0
  72. package/App/uiActions/muteUnmute/assets/action/flavour_1/unmute.png +0 -0
  73. package/App/uiActions/muteUnmute/assets/action/flavour_2/mute.png +0 -0
  74. package/App/uiActions/muteUnmute/assets/action/flavour_2/unmute.png +0 -0
  75. package/App/uiActions/muteUnmute/assets/button/flavour_1/mute.png +0 -0
  76. package/App/uiActions/muteUnmute/assets/button/flavour_1/unmute.png +0 -0
  77. package/App/uiActions/muteUnmute/assets/button/flavour_2/mute.png +0 -0
  78. package/App/uiActions/muteUnmute/assets/button/flavour_2/unmute.png +0 -0
  79. package/App/uiActions/muteUnmute/defaultAssets.ts +33 -0
  80. package/App/uiActions/muteUnmute/entryState.ts +28 -0
  81. package/App/uiActions/muteUnmute/index.ts +79 -0
  82. package/App/uiActions/muteUnmute/labelResolver.ts +15 -0
  83. package/App/uiActions/muteUnmute/types.ts +18 -0
  84. package/package.json +8 -8
@@ -4,8 +4,8 @@ import { allSettled } from "promise";
4
4
  import { useActions } from "@applicaster/zapp-react-native-utils/reactHooks/actions";
5
5
 
6
6
  import * as React from "react";
7
- import { coreAppLogger } from "../logger";
8
- const logger = coreAppLogger.addSubsystem("AppLifeCycleManager");
7
+ import { subsystemLogger } from "@applicaster/zapp-react-native-utils/logger";
8
+ const logger = subsystemLogger("app/lifecycle", "AppLifeCycleManager");
9
9
 
10
10
  const debugActions = (actions) =>
11
11
  logger.debug({
@@ -3,6 +3,14 @@ import * as R from "ramda";
3
3
 
4
4
  import { ActionsContext } from "@applicaster/zapp-react-native-ui-components/Contexts/ActionsContext";
5
5
  import { isNilOrEmpty } from "@applicaster/zapp-react-native-utils/reactUtils/helpers";
6
+ import { createLogger } from "@applicaster/zapp-react-native-utils/logger";
7
+
8
+ import { LegacyActionsRegistryAdapter } from "./LegacyActionsRegistryAdapter";
9
+
10
+ const { log_debug } = createLogger({
11
+ subsystem: "core/actions",
12
+ category: "ActionRegistration",
13
+ });
6
14
 
7
15
  type Props = {
8
16
  children: React.ReactNode;
@@ -36,19 +44,17 @@ const abstractIdentifier = (actionPlugins: Plugin[]): PluginsIdMap =>
36
44
  * Component returning children.
37
45
  * Can be used to create Component from children
38
46
  */
39
- const ChildrenWrapper = ({
40
- children,
41
- }: {
42
- children: React.ReactElement<any>;
43
- }) => {
44
- return children;
47
+ const ChildrenWrapper = ({ children }: { children: React.ReactNode }) => {
48
+ return <>{children}</>;
45
49
  };
46
50
 
47
51
  /**
48
52
  * It wraps children in multiple context providers
49
53
  * @param contexts - Array of React Context Providers
50
54
  */
51
- const contextComposer = (contexts: Plugin[]): React.ExoticComponent =>
55
+ const contextComposer = (
56
+ contexts: Plugin[]
57
+ ): React.ComponentType<React.PropsWithChildren> =>
52
58
  R.compose(...contexts)(ChildrenWrapper);
53
59
 
54
60
  /**
@@ -69,6 +75,19 @@ export function ActionsProvider(props: Props) {
69
75
  [plugins]
70
76
  );
71
77
 
78
+ React.useEffect(() => {
79
+ const count = Object.keys(actionPlugins).length;
80
+
81
+ if (count > 0) {
82
+ log_debug(
83
+ `ActionsProvider: composed ${count} action plugin(s) into context`,
84
+ { identifiers: Object.keys(actionPlugins) }
85
+ );
86
+ } else {
87
+ log_debug("ActionsProvider: no action plugins to compose");
88
+ }
89
+ }, [actionPlugins]);
90
+
72
91
  const contextProviders = React.useMemo((): [Plugin] | [] => {
73
92
  try {
74
93
  const providers = R.compose(
@@ -88,7 +107,7 @@ export function ActionsProvider(props: Props) {
88
107
  ? contextComposer(contextProviders)
89
108
  : React.Fragment,
90
109
  []
91
- );
110
+ ) as React.ComponentType<React.PropsWithChildren>;
92
111
 
93
112
  const contextValue = React.useMemo(
94
113
  () => ({ actions: actionPlugins }),
@@ -97,7 +116,10 @@ export function ActionsProvider(props: Props) {
97
116
 
98
117
  return (
99
118
  <ActionsContext.Provider value={contextValue}>
100
- <Context>{children}</Context>
119
+ <Context>
120
+ <LegacyActionsRegistryAdapter actionPlugins={actionPlugins} />
121
+ {children}
122
+ </Context>
101
123
  </ActionsContext.Provider>
102
124
  );
103
125
  }
@@ -0,0 +1,123 @@
1
+ import * as React from "react";
2
+ import * as R from "ramda";
3
+
4
+ import { uiActionsRegistry } from "@applicaster/zapp-react-native-utils/uiActionsRegistrator";
5
+ import { createLogger } from "@applicaster/zapp-react-native-utils/logger";
6
+
7
+ const { log_debug, log_warning } = createLogger({
8
+ subsystem: "core/actions/legacy_registry",
9
+ category: "ActionRegistration",
10
+ });
11
+
12
+ type LegacyActionPlugin = Record<string, any> & {
13
+ identifier: string;
14
+ module: {
15
+ context?: React.Context<any>;
16
+ [key: string]: any;
17
+ };
18
+ };
19
+
20
+ /**
21
+ * Bridges a single legacy action plugin (one that exposes `module.context`)
22
+ * into the `uiActionsRegistry`.
23
+ *
24
+ * Reactivity note: legacy stateful actions rely on React Context re-renders to
25
+ * propagate their latest value to subscribed UI (via `useActions`). We keep
26
+ * that mechanism intact and only *mirror* the current value into the registry
27
+ * through a ref, so registry-based consumers always read the freshest value at
28
+ * call time without changing legacy reactivity.
29
+ */
30
+ function LegacyActionBridge({ plugin }: { plugin: LegacyActionPlugin }) {
31
+ // `plugin.module.context` is stable for the lifetime of the plugin, so this
32
+ // single `useContext` call is safe and rules-of-hooks compliant.
33
+ const value = React.useContext(plugin.module.context as React.Context<any>);
34
+
35
+ const valueRef = React.useRef(value);
36
+ valueRef.current = value;
37
+
38
+ React.useEffect(() => {
39
+ if (value == null) {
40
+ log_warning(
41
+ `LegacyActionBridge: context value for "${plugin.identifier}" is null/undefined – skipping registration`,
42
+ { identifier: plugin.identifier }
43
+ );
44
+ } else {
45
+ log_debug(
46
+ `LegacyActionBridge: context value ready for "${plugin.identifier}", registering in UIActionsRegistry`,
47
+ { identifier: plugin.identifier }
48
+ );
49
+ }
50
+
51
+ const unregister = uiActionsRegistry.registerActionProvider(
52
+ plugin.identifier,
53
+ () =>
54
+ valueRef.current
55
+ ? [{ identifier: plugin.identifier, action: valueRef.current }]
56
+ : []
57
+ );
58
+
59
+ return () => {
60
+ log_debug(
61
+ `LegacyActionBridge: unmounting bridge for "${plugin.identifier}"`,
62
+ { identifier: plugin.identifier }
63
+ );
64
+
65
+ unregister();
66
+ };
67
+ }, [plugin.identifier]);
68
+
69
+ // Consumers resolve a snapshot of `value`; when the plugin publishes a new
70
+ // one (e.g. cast devices found), make them re-resolve so availability
71
+ // predicates are not read from a stale value. Registration already
72
+ // notifies, so the first render is skipped.
73
+ const isFirstValueRef = React.useRef(true);
74
+
75
+ React.useEffect(() => {
76
+ if (isFirstValueRef.current) {
77
+ isFirstValueRef.current = false;
78
+
79
+ return;
80
+ }
81
+
82
+ uiActionsRegistry.notifyProviderChanged(plugin.identifier);
83
+ }, [value, plugin.identifier]);
84
+
85
+ return null;
86
+ }
87
+
88
+ type Props = {
89
+ actionPlugins: Record<string, LegacyActionPlugin>;
90
+ };
91
+
92
+ /**
93
+ * Registers every legacy action plugin's live context value into the
94
+ * `uiActionsRegistry`. It must be rendered *inside* the composed context
95
+ * providers (see `ActionsProvider`) so that each plugin's context is populated.
96
+ *
97
+ * This is the compatibility layer that lets new, registry-based consumers read
98
+ * actions coming from old plugins that still export `contextProvider`/`context`.
99
+ */
100
+ export function LegacyActionsRegistryAdapter({ actionPlugins }: Props) {
101
+ const bridgedPlugins = React.useMemo(
102
+ () =>
103
+ R.values(actionPlugins).filter(
104
+ (plugin) => plugin?.module?.context != null
105
+ ),
106
+ [actionPlugins]
107
+ );
108
+
109
+ log_debug(
110
+ `LegacyActionsRegistryAdapter: bridging ${bridgedPlugins.length} legacy action plugin(s)`,
111
+ { identifiers: bridgedPlugins.map((p) => p.identifier) }
112
+ );
113
+
114
+ return (
115
+ <>
116
+ {bridgedPlugins.map((plugin) => (
117
+ <LegacyActionBridge key={plugin.identifier} plugin={plugin} />
118
+ ))}
119
+ </>
120
+ );
121
+ }
122
+
123
+ LegacyActionsRegistryAdapter.displayName = "LegacyActionsRegistryAdapter";
@@ -0,0 +1,64 @@
1
+ import React from "react";
2
+ import { render } from "@testing-library/react-native";
3
+ import { uiActionsRegistry } from "@applicaster/zapp-react-native-utils/uiActionsRegistrator";
4
+ import { LegacyActionsRegistryAdapter } from "../LegacyActionsRegistryAdapter";
5
+
6
+ const CastContext = React.createContext<any>(null);
7
+
8
+ const plugin = {
9
+ identifier: "cast-action-test",
10
+ module: { context: CastContext },
11
+ };
12
+
13
+ const renderWithValue = (value) => (
14
+ <CastContext.Provider value={value}>
15
+ <LegacyActionsRegistryAdapter actionPlugins={{ cast: plugin } as any} />
16
+ </CastContext.Provider>
17
+ );
18
+
19
+ describe("LegacyActionsRegistryAdapter", () => {
20
+ it("makes consumers re-resolve when the plugin publishes a new value", () => {
21
+ const noDevices = { isActionAvailable: () => false };
22
+ const devicesFound = { isActionAvailable: () => true };
23
+
24
+ const { rerender, unmount } = render(renderWithValue(noDevices));
25
+
26
+ // what a consumer resolved at first paint
27
+ expect(
28
+ uiActionsRegistry
29
+ .getAction("cast-action-test")
30
+ ?.isActionAvailable?.({} as any)
31
+ ).toBe(false);
32
+
33
+ const listener = jest.fn();
34
+ const unsubscribe = uiActionsRegistry.subscribe(listener);
35
+
36
+ rerender(renderWithValue(devicesFound));
37
+
38
+ expect(listener).toHaveBeenCalledTimes(1);
39
+
40
+ expect(
41
+ uiActionsRegistry
42
+ .getAction("cast-action-test")
43
+ ?.isActionAvailable?.({} as any)
44
+ ).toBe(true);
45
+
46
+ unsubscribe();
47
+ unmount();
48
+ });
49
+
50
+ it("does not notify again when the value is unchanged", () => {
51
+ const stable = { isActionAvailable: () => true };
52
+ const { rerender, unmount } = render(renderWithValue(stable));
53
+
54
+ const listener = jest.fn();
55
+ const unsubscribe = uiActionsRegistry.subscribe(listener);
56
+
57
+ rerender(renderWithValue(stable));
58
+
59
+ expect(listener).not.toHaveBeenCalled();
60
+
61
+ unsubscribe();
62
+ unmount();
63
+ });
64
+ });
@@ -5,6 +5,6 @@ import { coreAppLogger } from "../logger";
5
5
  export const { log_verbose, log_debug, log_warning, log_info, log_error } =
6
6
  createLogger({
7
7
  category: "AssetCache",
8
- subsystem: "quick-brick-core",
8
+ subsystem: "storage/asset_cache",
9
9
  parent: coreAppLogger,
10
10
  });
@@ -60,11 +60,21 @@ jest.spyOn(useNavigationHooks, "useNavigation").mockReturnValue(navigator);
60
60
  const helperSpy = jest.spyOn(helpers, "handlePresentNavigation");
61
61
  const feedLoaderSpy = jest.spyOn(feedLoader, "useFeedLoader");
62
62
 
63
- const setEntryContext = jest.fn();
64
-
65
- jest.doMock("@applicaster/zapp-react-native-ui-components/Contexts", () => ({
63
+ const mockSetEntryContext = jest.fn();
64
+
65
+ // `jest.mock` is hoisted above the imports, so the entry context is replaced
66
+ // before anything can pull the real one in. `jest.doMock` is not hoisted, and
67
+ // only worked here for as long as no import above happened to load this module
68
+ // first - which any new import anywhere in the graph could silently undo,
69
+ // leaving the hook writing to the real context while the spy stayed at zero
70
+ // calls. The rest of the module is kept, since other consumers loaded by this
71
+ // graph read other exports from it.
72
+ jest.mock("@applicaster/zapp-react-native-ui-components/Contexts", () => ({
73
+ ...jest.requireActual(
74
+ "@applicaster/zapp-react-native-ui-components/Contexts"
75
+ ),
66
76
  ZappPipesEntryContext: {
67
- useZappPipesContext: () => [{}, setEntryContext],
77
+ useZappPipesContext: () => [{}, mockSetEntryContext],
68
78
  },
69
79
  }));
70
80
 
@@ -76,7 +86,7 @@ jest.mock("../../../logger", () => ({
76
86
  log_debug: jest.fn(),
77
87
  }));
78
88
 
79
- // to use import instead of require it's required to use jest.mock above
89
+ // Required after the mocks above, so the hook binds to them.
80
90
  const { useOpenSchemeHandler } = require("../useOpenSchemeHandler");
81
91
 
82
92
  const mockStoreObj = { rivers, contentTypes, pipesEndpoints, appData };
@@ -101,7 +111,7 @@ function clearMocks() {
101
111
  navigator.replace.mockClear();
102
112
  navigator.push.mockClear();
103
113
  navigator.goHome.mockClear();
104
- setEntryContext.mockClear();
114
+ mockSetEntryContext.mockClear();
105
115
  }
106
116
 
107
117
  describe("useOpenSchemeHandler", () => {
@@ -215,7 +225,7 @@ describe("useOpenSchemeHandler", () => {
215
225
  })
216
226
  );
217
227
 
218
- expect(setEntryContext).toHaveBeenCalledWith(
228
+ expect(mockSetEntryContext).toHaveBeenCalledWith(
219
229
  expect.objectContaining({
220
230
  ...params,
221
231
  extensions: { ...params, initial_player_state: "fullscreen" },
@@ -272,7 +282,7 @@ describe("useOpenSchemeHandler", () => {
272
282
  })
273
283
  );
274
284
 
275
- expect(setEntryContext).toHaveBeenCalledWith(
285
+ expect(mockSetEntryContext).toHaveBeenCalledWith(
276
286
  expect.objectContaining({
277
287
  ...params,
278
288
  extensions: { ...params, initial_player_state: "fullscreen" },
@@ -331,7 +341,7 @@ describe("useOpenSchemeHandler", () => {
331
341
  })
332
342
  );
333
343
 
334
- expect(setEntryContext).toHaveBeenCalledWith(
344
+ expect(mockSetEntryContext).toHaveBeenCalledWith(
335
345
  entryWithInitialPlayerState
336
346
  );
337
347
  };
@@ -361,7 +371,7 @@ describe("useOpenSchemeHandler", () => {
361
371
  })
362
372
  );
363
373
 
364
- expect(setEntryContext).toHaveBeenCalledWith(
374
+ expect(mockSetEntryContext).toHaveBeenCalledWith(
365
375
  entryWithInitialPlayerState
366
376
  );
367
377
  };
@@ -391,7 +401,7 @@ describe("useOpenSchemeHandler", () => {
391
401
  })
392
402
  );
393
403
 
394
- expect(setEntryContext).toHaveBeenCalledWith(
404
+ expect(mockSetEntryContext).toHaveBeenCalledWith(
395
405
  entryWithInitialPlayerState
396
406
  );
397
407
  };
@@ -421,7 +431,7 @@ describe("useOpenSchemeHandler", () => {
421
431
  })
422
432
  );
423
433
 
424
- expect(setEntryContext).toHaveBeenCalledWith(
434
+ expect(mockSetEntryContext).toHaveBeenCalledWith(
425
435
  entryWithInitialPlayerState
426
436
  );
427
437
  };
@@ -451,7 +461,7 @@ describe("useOpenSchemeHandler", () => {
451
461
  })
452
462
  );
453
463
 
454
- expect(setEntryContext).toHaveBeenCalledWith(
464
+ expect(mockSetEntryContext).toHaveBeenCalledWith(
455
465
  entryWithInitialPlayerState
456
466
  );
457
467
  };
@@ -485,7 +495,7 @@ describe("useOpenSchemeHandler", () => {
485
495
  })
486
496
  );
487
497
 
488
- expect(setEntryContext).toHaveBeenCalledWith(
498
+ expect(mockSetEntryContext).toHaveBeenCalledWith(
489
499
  expect.objectContaining(entryWithInitialPlayerState)
490
500
  );
491
501
  };
@@ -514,7 +524,7 @@ describe("useOpenSchemeHandler", () => {
514
524
  );
515
525
 
516
526
  expect(navigator.goHome).toHaveBeenCalled();
517
- expect(setEntryContext).not.toHaveBeenCalled();
527
+ expect(mockSetEntryContext).not.toHaveBeenCalled();
518
528
  };
519
529
 
520
530
  await testHook({
@@ -28,6 +28,7 @@ import {
28
28
 
29
29
  import { log_error, log_info } from "../../logger";
30
30
  import { useRivers } from "@applicaster/zapp-react-native-utils/reactHooks/state";
31
+ import { rememberLayoutPreview } from "../../../layoutPreview/persistence";
31
32
 
32
33
  const getFeed = (query) => ({
33
34
  content: { src: query.data_source },
@@ -155,6 +156,8 @@ export function usePresentSchemeHandler({
155
156
  rivers_configuration_id
156
157
  );
157
158
 
159
+ await rememberLayoutPreview(rivers_configuration_id);
160
+
158
161
  onFinish((done) => {
159
162
  actions?.setAppReady();
160
163
  navigator.replace(homeRiver);
@@ -3,6 +3,7 @@ import React, {
3
3
  createContext,
4
4
  useEffect,
5
5
  useCallback,
6
+ useMemo,
6
7
  ComponentType,
7
8
  ReactChild,
8
9
  } from "react";
@@ -196,9 +197,11 @@ function URLSchemeContextProvider(props: Props) {
196
197
  };
197
198
  }, []);
198
199
 
200
+ const contextValue = useMemo(() => ({ url: state, done }), [state, done]);
201
+
199
202
  return (
200
203
  <View style={fillStyles.container}>
201
- <URLSchemeContext.Provider value={{ url: state, done }}>
204
+ <URLSchemeContext.Provider value={contextValue}>
202
205
  {props.children}
203
206
  </URLSchemeContext.Provider>
204
207
  </View>
@@ -5,6 +5,6 @@ import { coreAppLogger } from "../logger";
5
5
  export const { log_verbose, log_debug, log_warning, log_info, log_error } =
6
6
  createLogger({
7
7
  category: "DeepLinking",
8
- subsystem: "General",
8
+ subsystem: "app/deep_linking",
9
9
  parent: coreAppLogger,
10
10
  });
@@ -1,13 +1,16 @@
1
1
  import * as React from "react";
2
2
  import pick from "lodash/pick";
3
3
 
4
- import { coreLogger } from "@applicaster/zapp-react-native-utils/logger";
4
+ import { subsystemLogger } from "@applicaster/zapp-react-native-utils/logger";
5
5
  import { ErrorScreen } from "@applicaster/zapp-react-native-ui-components/Components/ErrorScreen";
6
6
 
7
7
  import { useErrorStore } from "./store";
8
8
  import * as QuickBrickManager from "@applicaster/zapp-react-native-bridge/QuickBrick";
9
9
 
10
- const errorBoundaryLogger = coreLogger.addSubsystem("react_error-boundary");
10
+ const errorBoundaryLogger = subsystemLogger(
11
+ "crash/error_boundary",
12
+ "ErrorBoundary"
13
+ );
11
14
 
12
15
  type Props = {
13
16
  children: React.ReactNode;
@@ -0,0 +1,88 @@
1
+ import React from "react";
2
+ import { View } from "react-native";
3
+ import { render } from "@testing-library/react-native";
4
+ import { State } from "react-native-gesture-handler";
5
+ import { DraggableBottomSheet } from "../index";
6
+
7
+ // Render the gesture handlers as passthrough Views so we can mount the sheet
8
+ // and drive its release handler directly. State stays real (we need ACTIVE).
9
+ jest.mock("react-native-gesture-handler", () => {
10
+ const RN = require("react-native");
11
+ const ReactActual = require("react");
12
+ const actual = jest.requireActual("react-native-gesture-handler");
13
+
14
+ const Passthrough = ReactActual.forwardRef(({ children }: any, _ref: any) => (
15
+ <RN.View>{children}</RN.View>
16
+ ));
17
+
18
+ return {
19
+ __esModule: true,
20
+ ...actual,
21
+ PanGestureHandler: Passthrough,
22
+ TapGestureHandler: Passthrough,
23
+ };
24
+ });
25
+
26
+ // height 800, sheetHeight 400, no header:
27
+ // SnapPoints.top = 800 - 400 = 400 (lastSnap after mount)
28
+ // SnapPoints.threshold = max(800 - 400 / 2, 100) = 600
29
+ // Release dismisses when lastSnap + translationY + 0.05 * velocityY > 600,
30
+ // i.e. once the drag+toss pushes past 200px.
31
+ const mountSheet = () => {
32
+ const dismiss = jest.fn();
33
+ const ref = React.createRef<DraggableBottomSheet>();
34
+
35
+ render(
36
+ <DraggableBottomSheet
37
+ ref={ref}
38
+ header={() => null}
39
+ dismiss={dismiss}
40
+ visible={true}
41
+ sheetHeight={400}
42
+ width={320}
43
+ height={800}
44
+ hasHeader={false}
45
+ maxWidth={320}
46
+ >
47
+ <View testID="child" />
48
+ </DraggableBottomSheet>
49
+ );
50
+
51
+ return { instance: ref.current as DraggableBottomSheet, dismiss };
52
+ };
53
+
54
+ const release = (
55
+ instance: DraggableBottomSheet,
56
+ translationY: number,
57
+ velocityY = 0
58
+ ) =>
59
+ instance._onHandlerStateChange({
60
+ nativeEvent: { oldState: State.ACTIVE, translationY, velocityY },
61
+ });
62
+
63
+ describe("DraggableBottomSheet release", () => {
64
+ // Mounting an open sheet schedules a deferred animateIn via setTimeout. Keep
65
+ // it on fake timers so it never fires into a torn-down Jest environment.
66
+ beforeEach(() => jest.useFakeTimers());
67
+
68
+ afterEach(() => {
69
+ jest.clearAllTimers();
70
+ jest.useRealTimers();
71
+ });
72
+
73
+ it("dismisses when the release lands past the threshold", () => {
74
+ const { instance, dismiss } = mountSheet();
75
+
76
+ release(instance, 300);
77
+
78
+ expect(dismiss).toHaveBeenCalledTimes(1);
79
+ });
80
+
81
+ it("springs back (does not dismiss) when the release is below the threshold", () => {
82
+ const { instance, dismiss } = mountSheet();
83
+
84
+ release(instance, 50);
85
+
86
+ expect(dismiss).not.toHaveBeenCalled();
87
+ });
88
+ });