@applicaster/quick-brick-core 12.0.0-alpha.4342066143 → 12.0.0-alpha.4354608902
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.
|
@@ -66,6 +66,7 @@ import { inflateUrl } from "@applicaster/zapp-react-native-ui-components/Compone
|
|
|
66
66
|
import { useModalStore } from "@applicaster/zapp-react-native-utils/modalState";
|
|
67
67
|
import { useSubscriberFor } from "@applicaster/zapp-react-native-utils/reactHooks/useSubscriberFor";
|
|
68
68
|
import { QBUIComponentEvents } from "@applicaster/zapp-react-native-ui-components/events";
|
|
69
|
+
import { Hook } from "@applicaster/zapp-react-native-utils/appUtils/HooksManager/Hook";
|
|
69
70
|
|
|
70
71
|
const logger = coreAppLogger.addSubsystem("Navigator");
|
|
71
72
|
|
|
@@ -75,17 +76,6 @@ type Props = {
|
|
|
75
76
|
plugins?: QuickBrickPlugin[];
|
|
76
77
|
};
|
|
77
78
|
|
|
78
|
-
type EntryWithParent = ZappEntry & { parent?: EntryWithParent };
|
|
79
|
-
|
|
80
|
-
type SingleEntry = {
|
|
81
|
-
data: EntryWithParent;
|
|
82
|
-
route: string;
|
|
83
|
-
id: string;
|
|
84
|
-
parentId?: string;
|
|
85
|
-
};
|
|
86
|
-
|
|
87
|
-
type EntryContextType = { [K in string]: SingleEntry };
|
|
88
|
-
|
|
89
79
|
const navigationActions = {
|
|
90
80
|
[ACTIONS.PUSH]: push,
|
|
91
81
|
[ACTIONS.REPLACE]: replace,
|
|
@@ -122,9 +112,7 @@ export function NavigationProvider({ children }: Props) {
|
|
|
122
112
|
const pathname = state?.location?.pathname;
|
|
123
113
|
const pathnameRef = React.useRef(pathname);
|
|
124
114
|
|
|
125
|
-
const { context }
|
|
126
|
-
ZappPipesEntryContext.Context
|
|
127
|
-
);
|
|
115
|
+
const { context } = React.useContext(ZappPipesEntryContext.Context);
|
|
128
116
|
|
|
129
117
|
const { openModal, dismissModal } = useModalStore();
|
|
130
118
|
|
|
@@ -380,7 +368,18 @@ export function NavigationProvider({ children }: Props) {
|
|
|
380
368
|
}
|
|
381
369
|
};
|
|
382
370
|
|
|
383
|
-
const handleHookPresent = (
|
|
371
|
+
const handleHookPresent = (
|
|
372
|
+
{
|
|
373
|
+
hookPlugin,
|
|
374
|
+
route,
|
|
375
|
+
payload,
|
|
376
|
+
}: {
|
|
377
|
+
hookPlugin: Hook;
|
|
378
|
+
route: string;
|
|
379
|
+
payload: object;
|
|
380
|
+
},
|
|
381
|
+
dispose
|
|
382
|
+
) => {
|
|
384
383
|
if (hookPlugin?.lastHook) {
|
|
385
384
|
dispose();
|
|
386
385
|
}
|
|
@@ -414,9 +413,12 @@ export function NavigationProvider({ children }: Props) {
|
|
|
414
413
|
}
|
|
415
414
|
};
|
|
416
415
|
|
|
417
|
-
const handleHookCancel = ({ hookPlugin }, dispose) => {
|
|
418
|
-
|
|
419
|
-
|
|
416
|
+
const handleHookCancel = ({ hookPlugin, callback }, dispose) => {
|
|
417
|
+
dispose();
|
|
418
|
+
setStartUpHooks(false);
|
|
419
|
+
|
|
420
|
+
if (callback && typeof callback === "function") {
|
|
421
|
+
callback();
|
|
420
422
|
}
|
|
421
423
|
|
|
422
424
|
if (hookPlugin.isModalHook()) {
|
|
@@ -482,7 +484,13 @@ export function NavigationProvider({ children }: Props) {
|
|
|
482
484
|
return false;
|
|
483
485
|
}, [pluginConfigurations, plugins, rivers]);
|
|
484
486
|
|
|
485
|
-
const [startUpHooks,
|
|
487
|
+
const [startUpHooks, _setStartUpHooks] = React.useState(checkStartUpHooks);
|
|
488
|
+
const currentStartUpHooks = React.useRef(checkStartUpHooks);
|
|
489
|
+
|
|
490
|
+
const setStartUpHooks = (value) => {
|
|
491
|
+
_setStartUpHooks(value);
|
|
492
|
+
currentStartUpHooks.current = value;
|
|
493
|
+
};
|
|
486
494
|
|
|
487
495
|
const handleHookComplete =
|
|
488
496
|
(navigationAction, targetRoute, { screen, options }) =>
|
|
@@ -490,7 +498,7 @@ export function NavigationProvider({ children }: Props) {
|
|
|
490
498
|
if (hookPlugin?.lastHook) {
|
|
491
499
|
dispose({ disposeAll: true });
|
|
492
500
|
|
|
493
|
-
startUpHooks && setStartUpHooks(false);
|
|
501
|
+
startUpHooks.current && setStartUpHooks(false);
|
|
494
502
|
}
|
|
495
503
|
|
|
496
504
|
dispatch(
|
|
@@ -599,10 +607,15 @@ export function NavigationProvider({ children }: Props) {
|
|
|
599
607
|
targetScreen: screen,
|
|
600
608
|
rivers,
|
|
601
609
|
plugins,
|
|
602
|
-
startUpHooksData: {
|
|
610
|
+
startUpHooksData: {
|
|
611
|
+
startUpHooks: currentStartUpHooks.current,
|
|
612
|
+
setStartUpHooks,
|
|
613
|
+
},
|
|
603
614
|
};
|
|
604
615
|
|
|
605
|
-
HooksManager(hooksOptions)
|
|
616
|
+
const hooksManager = HooksManager(hooksOptions);
|
|
617
|
+
|
|
618
|
+
hooksManager.subscriber
|
|
606
619
|
.on(HOOKS_EVENTS.PRESENT_SCREEN_HOOK, handleHookPresent)
|
|
607
620
|
.on(HOOKS_EVENTS.ERROR, handleHookError)
|
|
608
621
|
.on(HOOKS_EVENTS.CANCEL, handleHookCancel)
|
|
@@ -613,8 +626,9 @@ export function NavigationProvider({ children }: Props) {
|
|
|
613
626
|
screen,
|
|
614
627
|
options,
|
|
615
628
|
})
|
|
616
|
-
)
|
|
617
|
-
|
|
629
|
+
);
|
|
630
|
+
|
|
631
|
+
hooksManager.handleHooks(legacyScreenData({ entry, screen }));
|
|
618
632
|
} else {
|
|
619
633
|
dispatch(navigationAction(targetRoute, { screen, entry, options }));
|
|
620
634
|
}
|
|
@@ -672,15 +686,15 @@ export function NavigationProvider({ children }: Props) {
|
|
|
672
686
|
|
|
673
687
|
// It will only work for the regular stack and pathname, It won't work for modals
|
|
674
688
|
// TODO: integrate video/hook and regular modal into stack.
|
|
675
|
-
const getStackForPathname =
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
const stack = [...
|
|
689
|
+
const getStackForPathname = (
|
|
690
|
+
pathname: string
|
|
691
|
+
): NavigationScreenState | undefined => {
|
|
692
|
+
const stack = [...state?.stack?.mainStack];
|
|
679
693
|
|
|
680
694
|
const currentStack = stack.find(({ route }) => route === pathname);
|
|
681
695
|
|
|
682
696
|
return currentStack;
|
|
683
|
-
}
|
|
697
|
+
};
|
|
684
698
|
|
|
685
699
|
const navigator: QuickBrickAppNavigator = React.useMemo(
|
|
686
700
|
() => ({
|
|
@@ -724,7 +738,7 @@ export function NavigationProvider({ children }: Props) {
|
|
|
724
738
|
replaceTop,
|
|
725
739
|
getStack,
|
|
726
740
|
getStackForPathname,
|
|
727
|
-
mainStack: state
|
|
741
|
+
mainStack: state.stack.mainStack,
|
|
728
742
|
}),
|
|
729
743
|
[rivers, plugins, JSON.stringify(state), appLaunched, startUpHooks]
|
|
730
744
|
);
|
|
@@ -3,7 +3,10 @@ import * as R from "ramda";
|
|
|
3
3
|
|
|
4
4
|
import { NetInfoState } from "@react-native-community/netinfo";
|
|
5
5
|
import { NETWORK_HOOKS_KEYS } from "./const";
|
|
6
|
-
import {
|
|
6
|
+
import {
|
|
7
|
+
isVizioPlatform,
|
|
8
|
+
platformSelect,
|
|
9
|
+
} from "@applicaster/zapp-react-native-utils/reactUtils";
|
|
7
10
|
import { Platform } from "react-native";
|
|
8
11
|
|
|
9
12
|
type ConnectionStatus = boolean;
|
|
@@ -203,6 +206,18 @@ export const subscribeToDeviceNetworkChanges = (callback: NetCb) => {
|
|
|
203
206
|
registeredListener = webapis.network.addNetworkStateChangeListener(
|
|
204
207
|
samsungNetworkChangeHandler(callback)
|
|
205
208
|
);
|
|
209
|
+
|
|
210
|
+
return;
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
if (isVizioPlatform()) {
|
|
214
|
+
window.addEventListener("online", function () {
|
|
215
|
+
callback({ online: true });
|
|
216
|
+
});
|
|
217
|
+
|
|
218
|
+
window.addEventListener("offline", function () {
|
|
219
|
+
callback({ online: false });
|
|
220
|
+
});
|
|
206
221
|
}
|
|
207
222
|
};
|
|
208
223
|
|
|
@@ -214,5 +229,12 @@ export const subscribeToDeviceNetworkChanges = (callback: NetCb) => {
|
|
|
214
229
|
export const unsubscribeToDeviceNetworkChanges = (id = registeredListener) => {
|
|
215
230
|
if (hasTizenAPIs()) {
|
|
216
231
|
webapis.network.removeNetworkStateChangeListener(id);
|
|
232
|
+
|
|
233
|
+
return;
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
if (isVizioPlatform()) {
|
|
237
|
+
window.removeEventListener("online", function () {});
|
|
238
|
+
window.removeEventListener("offline", function () {});
|
|
217
239
|
}
|
|
218
240
|
};
|
package/App/index.tsx
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
2
|
import * as R from "ramda";
|
|
3
3
|
import {
|
|
4
|
-
SafeAreaProvider,
|
|
5
4
|
initialWindowMetrics,
|
|
5
|
+
SafeAreaProvider,
|
|
6
6
|
} from "react-native-safe-area-context";
|
|
7
7
|
|
|
8
8
|
import { ErrorBoundary } from "./ErrorBoundary";
|
|
@@ -27,6 +27,7 @@ import {
|
|
|
27
27
|
import { withURLSchemeContextProvider } from "./DeepLinking/URLSchemeListener/URLSchemeContextProvider";
|
|
28
28
|
import { appRemoteDataLoader } from "./appRemoteDataLoader";
|
|
29
29
|
import { withActionExecutor } from "@applicaster/zapp-react-native-utils/actionsExecutor/ActionExecutorContext";
|
|
30
|
+
import { withScreenDataContextProvider } from "@applicaster/zapp-react-native-ui-components/Contexts/ScreenDataContext";
|
|
30
31
|
|
|
31
32
|
/**
|
|
32
33
|
* @typedef {Object} AppOptions
|
|
@@ -99,6 +100,7 @@ export function createQuickBrickApp(options): ZappApp {
|
|
|
99
100
|
withURLSchemeContextProvider,
|
|
100
101
|
withNetworkStatusProvider,
|
|
101
102
|
withNavigationProvider,
|
|
103
|
+
withScreenDataContextProvider,
|
|
102
104
|
ZappPipesSearchContext.withProvider,
|
|
103
105
|
InteractionManager,
|
|
104
106
|
withActionExecutor,
|
package/const/index.ts
CHANGED
package/createZappApp/index.tsx
CHANGED
|
@@ -7,6 +7,10 @@
|
|
|
7
7
|
import * as React from "react";
|
|
8
8
|
import * as R from "ramda";
|
|
9
9
|
import { Dimensions } from "react-native";
|
|
10
|
+
import {
|
|
11
|
+
isNotEmpty,
|
|
12
|
+
isNotNil,
|
|
13
|
+
} from "@applicaster/zapp-react-native-utils/reactUtils/helpers";
|
|
10
14
|
|
|
11
15
|
import {
|
|
12
16
|
createZappReduxStore,
|
|
@@ -27,6 +31,9 @@ import { remoteDataLoader } from "../App/appRemoteDataLoader/remoteDataLoader";
|
|
|
27
31
|
import * as QuickBrickManager from "@applicaster/zapp-react-native-bridge/QuickBrick";
|
|
28
32
|
import { isAndroidPlatform } from "@applicaster/zapp-react-native-utils/reactUtils";
|
|
29
33
|
|
|
34
|
+
const isNotEmptyObject = (value: unknown) =>
|
|
35
|
+
isNotNil(value) && R.is(Object, value) && isNotEmpty(value);
|
|
36
|
+
|
|
30
37
|
/**
|
|
31
38
|
* Creates a Zapp App with the provided options
|
|
32
39
|
* @export
|
|
@@ -55,8 +62,8 @@ export function createZappApp(zappAppConfig: ZappAppConfig) {
|
|
|
55
62
|
|
|
56
63
|
const useTabletLayout =
|
|
57
64
|
isTablet({ width, height }, width > height ? "landscape" : "portrait") &&
|
|
58
|
-
tabletLayout &&
|
|
59
|
-
tabletCellStyles;
|
|
65
|
+
isNotEmptyObject(tabletLayout) &&
|
|
66
|
+
isNotEmptyObject(tabletCellStyles);
|
|
60
67
|
|
|
61
68
|
function fetchPluginConfiguration(plugin) {
|
|
62
69
|
const configuration = R.compose(
|
package/defaults/index.js
CHANGED
package/package.json
CHANGED
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@applicaster/quick-brick-core",
|
|
3
|
-
"version": "12.0.0-alpha.
|
|
3
|
+
"version": "12.0.0-alpha.4354608902",
|
|
4
4
|
"description": "Core package for Applicaster's Quick Brick App",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"types": "index.d.ts",
|
|
7
7
|
"scripts": {
|
|
8
8
|
"test": "jest -w=2",
|
|
9
|
-
"flow-types": "node_modules/.bin/flow-copy-source -v -i '**/__tests__**' . .",
|
|
10
9
|
"build": "echo 'skipping ts build for core packages'"
|
|
11
10
|
},
|
|
12
11
|
"repository": {
|
|
@@ -30,13 +29,13 @@
|
|
|
30
29
|
},
|
|
31
30
|
"homepage": "https://github.com/applicaster/quickbrick#readme",
|
|
32
31
|
"dependencies": {
|
|
33
|
-
"@applicaster/applicaster-types": "12.0.0-alpha.
|
|
34
|
-
"@applicaster/quick-brick-core-plugins": "12.0.0-alpha.
|
|
35
|
-
"@applicaster/zapp-pipes-v2-client": "12.0.0-alpha.
|
|
36
|
-
"@applicaster/zapp-react-native-bridge": "12.0.0-alpha.
|
|
37
|
-
"@applicaster/zapp-react-native-redux": "12.0.0-alpha.
|
|
38
|
-
"@applicaster/zapp-react-native-ui-components": "12.0.0-alpha.
|
|
39
|
-
"@applicaster/zapp-react-native-utils": "12.0.0-alpha.
|
|
32
|
+
"@applicaster/applicaster-types": "12.0.0-alpha.4354608902",
|
|
33
|
+
"@applicaster/quick-brick-core-plugins": "12.0.0-alpha.4354608902",
|
|
34
|
+
"@applicaster/zapp-pipes-v2-client": "12.0.0-alpha.4354608902",
|
|
35
|
+
"@applicaster/zapp-react-native-bridge": "12.0.0-alpha.4354608902",
|
|
36
|
+
"@applicaster/zapp-react-native-redux": "12.0.0-alpha.4354608902",
|
|
37
|
+
"@applicaster/zapp-react-native-ui-components": "12.0.0-alpha.4354608902",
|
|
38
|
+
"@applicaster/zapp-react-native-utils": "12.0.0-alpha.4354608902",
|
|
40
39
|
"atob": "^2.1.2",
|
|
41
40
|
"axios": "^0.28.0",
|
|
42
41
|
"btoa": "^1.2.1",
|