@applicaster/quick-brick-core 12.0.0-alpha.9151207838 → 12.0.0-alpha.9262886003

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.
@@ -88,10 +88,12 @@ const getActionInitialStateSetters = (key) => {
88
88
  return R.compose(
89
89
  R.map((subscription: { [x: string]: any; pluginId: any }) => {
90
90
  return async () => {
91
+ const now = performance.now();
92
+
91
93
  logger.info({
92
94
  message: `Invocation Started - action plugin ${key}, pluginId: ${
93
95
  subscription.pluginId
94
- }: ${performance.now()}`,
96
+ }`,
95
97
  });
96
98
 
97
99
  const promiseFunc = subscription[key];
@@ -101,7 +103,7 @@ const getActionInitialStateSetters = (key) => {
101
103
  logger.info({
102
104
  message: `Invocation Completed - action plugin ${key}, pluginId: ${
103
105
  subscription.pluginId
104
- }: ${performance.now()}`,
106
+ }: ${performance.now() - now} ms`,
105
107
  });
106
108
 
107
109
  return result;
@@ -1,6 +1,6 @@
1
1
  /// <reference types="../../" />
2
2
  import * as R from "ramda";
3
- import { log_debug, log_warning } from "./logger";
3
+ import { log_debug, log_verbose, log_warning } from "./logger";
4
4
  import { CacheManager } from "./CacheManager";
5
5
 
6
6
  import {
@@ -84,6 +84,8 @@ export async function cacheAssets({
84
84
  };
85
85
  }
86
86
 
87
+ const time = performance.now();
88
+
87
89
  try {
88
90
  const { assetFiles, cellAssets, pluginAssets, layoutAssets } =
89
91
  await getLayoutAssets({
@@ -141,18 +143,20 @@ export async function cacheAssets({
141
143
 
142
144
  newCacheState.forEach(({ file, url }) => (urlFileMap[url] = file));
143
145
 
144
- const updatedLayout = remapAssetPath(layoutAssets, layout, urlFileMap);
146
+ const updatedLayout = remapAssetPath(layoutAssets, layout, urlFileMap, "layoutAssets");
145
147
 
146
148
  const updatedPluginConfigurations = remapAssetPath(
147
149
  pluginAssets,
148
150
  pluginConfigurations,
149
- urlFileMap
151
+ urlFileMap,
152
+ "pluginAssets"
150
153
  );
151
154
 
152
155
  const updatedCellStyles = remapAssetPath(
153
156
  cellAssets,
154
157
  cellStyles,
155
- urlFileMap
158
+ urlFileMap,
159
+ "cellStyles"
156
160
  );
157
161
 
158
162
  return {
@@ -164,5 +168,7 @@ export async function cacheAssets({
164
168
  log_warning(`cacheAssets: Error caching assets, message: ${error.message}`);
165
169
 
166
170
  return { layout, pluginConfigurations, cellStyles };
171
+ } finally {
172
+ log_verbose(`cacheAssets: caching assets took ${performance.now() - time} ms`);
167
173
  }
168
174
  }
@@ -1,7 +1,4 @@
1
- import {
2
- useActions,
3
- usePickFromState,
4
- } from "@applicaster/zapp-react-native-redux/hooks";
1
+ import { useActions } from "@applicaster/zapp-react-native-redux/hooks";
5
2
  import * as R from "ramda";
6
3
  import * as React from "react";
7
4
  import axios from "axios";
@@ -28,6 +25,7 @@ import {
28
25
  } from "../../helpers";
29
26
 
30
27
  import { log_error, log_info } from "../../logger";
28
+ import { useRivers } from "@applicaster/zapp-react-native-utils/reactHooks/state";
31
29
 
32
30
  const getFeed = (query) => ({
33
31
  content: { src: query.data_source },
@@ -60,7 +58,7 @@ export function usePresentSchemeHandler({
60
58
  feedUrl: data_source,
61
59
  });
62
60
 
63
- const { rivers } = usePickFromState(["rivers"]);
61
+ const rivers = useRivers();
64
62
  const screenRiver = findRiver({ screen_id, rivers });
65
63
  const dispatch = useDispatch();
66
64
 
@@ -1,8 +1,6 @@
1
1
  import React from "react";
2
2
  import { render, waitFor, cleanup } from "@testing-library/react-native";
3
3
 
4
- jest.mock("react-native");
5
-
6
4
  const theme = {
7
5
  screen_margin_top: 0,
8
6
  app_background_color: "white",
@@ -7,8 +7,6 @@ import { URLSchemeListener } from "../index";
7
7
 
8
8
  const URL = "url";
9
9
 
10
- jest.mock("react-native");
11
-
12
10
  const TestComponent = () => (
13
11
  <View>
14
12
  <Text>I'm a test component</Text>
@@ -1,16 +1,16 @@
1
1
  import * as React from "react";
2
2
 
3
- import { useNavigation } from "@applicaster/zapp-react-native-utils/reactHooks/navigation";
4
-
5
3
  import { ModalPresenter } from "./ModalPresenter";
6
4
  import { ModalContent } from "./ModalContent";
7
5
  import { ModalChildrenWrapper } from "./ModalChildrenWrapper";
8
6
  import { PathnameContext } from "@applicaster/zapp-react-native-ui-components/Contexts/PathnameContext";
9
7
  import { ScreenContextProvider } from "@applicaster/zapp-react-native-ui-components/Contexts/ScreenContext";
10
8
  import { ROUTE_TYPES } from "@applicaster/zapp-react-native-utils/navigationUtils/routeTypes";
9
+ import { useModalStore } from "@applicaster/zapp-react-native-utils/modalState";
11
10
 
12
11
  export function ModalProvider() {
13
- const { modalState } = useNavigation();
12
+ const { modalState } = useModalStore();
13
+
14
14
  const [modalVisible, setModalVisible] = React.useState(false);
15
15
  const [modalShown, setModalShown] = React.useState(false);
16
16
 
@@ -93,13 +93,6 @@ const navigationActions = {
93
93
 
94
94
  const platform = getPlatform();
95
95
 
96
- const initialModalState = {
97
- visible: false,
98
- screen: null,
99
- options: {},
100
- props: {},
101
- };
102
-
103
96
  export function NavigationProvider({ children }: Props) {
104
97
  const {
105
98
  appData: { layoutVersion },
@@ -131,7 +124,7 @@ export function NavigationProvider({ children }: Props) {
131
124
  ZappPipesEntryContext.Context
132
125
  );
133
126
 
134
- const { openModal, dismissModal, modalState } = useModalStore();
127
+ const { openModal, dismissModal } = useModalStore();
135
128
 
136
129
  const playNextOverlayState = React.useRef();
137
130
 
@@ -153,6 +146,12 @@ export function NavigationProvider({ children }: Props) {
153
146
  [pathname, rivers]
154
147
  );
155
148
 
149
+ const getModalState: () => ModalState = () => {
150
+ const { modalState } = useModalStore.getState();
151
+
152
+ return modalState;
153
+ };
154
+
156
155
  const homeRiver = React.useMemo(
157
156
  () => homeRiverSelector({ rivers }),
158
157
  [rivers]
@@ -701,7 +700,7 @@ export function NavigationProvider({ children }: Props) {
701
700
  modalData: state.stack.modal?.state ?? null,
702
701
  openModal,
703
702
  dismissModal,
704
- modalState,
703
+ getModalState,
705
704
  openModalBottomSheet,
706
705
  closeModalBottomSheet,
707
706
  videoModalState: state.options.videoModal,
@@ -719,14 +718,7 @@ export function NavigationProvider({ children }: Props) {
719
718
  getStack,
720
719
  getStackForPathname,
721
720
  }),
722
- [
723
- rivers,
724
- plugins,
725
- JSON.stringify(state),
726
- modalState,
727
- appLaunched,
728
- startUpHooks,
729
- ]
721
+ [rivers, plugins, JSON.stringify(state), appLaunched, startUpHooks]
730
722
  );
731
723
 
732
724
  // when running the tests, we pass the dispatch function
@@ -32,28 +32,7 @@ Object {
32
32
  }
33
33
  `;
34
34
 
35
- exports[`<NavigationProvider /> modal feature sets the modalState when opening a modal 1`] = `
36
- Object {
37
- "options": Object {
38
- "animated": true,
39
- "animationType": "slide",
40
- "onDismiss": [Function],
41
- "onRequestClose": [Function],
42
- "onShow": [Function],
43
- "presentationStyle": "overFullScreen",
44
- "transparent": true,
45
- },
46
- "props": Object {
47
- "screenData": Object {},
48
- },
49
- "screen": Object {
50
- "id": "A1234",
51
- "navigations": Array [],
52
- "ui_components": Array [],
53
- },
54
- "visible": true,
55
- }
56
- `;
35
+ exports[`<NavigationProvider /> modal feature sets the modalState when opening a modal 1`] = `undefined`;
57
36
 
58
37
  exports[`<NavigationProvider /> modal feature should reset state to initial when dismissing a modal ( closeModalBottomSheet ) opened by openModalBottomSheet 1`] = `
59
38
  Object {
@@ -552,7 +552,7 @@ describe("<NavigationProvider />", () => {
552
552
 
553
553
  const view = wrapper.root.findByType(View);
554
554
  act(() => view.props.navigator.openModal({ item: rivers.A1234 }));
555
- expect(view.props.navigator.modalState).toMatchSnapshot();
555
+ expect(view.props.navigator.get).toMatchSnapshot();
556
556
  });
557
557
 
558
558
  it("removes the visible flag when dismissing a modal", () => {
@@ -568,10 +568,10 @@ describe("<NavigationProvider />", () => {
568
568
 
569
569
  const view = wrapper.root.findByType(View);
570
570
  act(() => view.props.navigator.openModal({ item: rivers.A1234 }));
571
- expect(view.props.navigator.modalState).toMatchSnapshot();
571
+ expect(view.props.navigator.getModalState()).toMatchSnapshot();
572
572
  act(() => view.props.navigator.dismissModal());
573
- expect(view.props.navigator.modalState.visible).toBeFalsy();
574
- expect(view.props.navigator.modalState).toMatchSnapshot();
573
+ expect(view.props.navigator.getModalState().visible).toBeFalsy();
574
+ expect(view.props.navigator.getModalState()).toMatchSnapshot();
575
575
  });
576
576
 
577
577
  it("should reset state to initial when dismissing a modal ( closeModalBottomSheet ) opened by openModalBottomSheet", () => {
@@ -594,9 +594,9 @@ describe("<NavigationProvider />", () => {
594
594
  })
595
595
  );
596
596
 
597
- expect(view.props.navigator.modalState).toMatchSnapshot();
597
+ expect(view.props.navigator.getModalState()).toMatchSnapshot();
598
598
  act(() => view.props.navigator.closeModalBottomSheet());
599
- expect(view.props.navigator.modalState).toMatchSnapshot();
599
+ expect(view.props.navigator.getModalState()).toMatchSnapshot();
600
600
  });
601
601
  });
602
602
  });
@@ -1,8 +1,9 @@
1
1
  import * as R from "ramda";
2
2
  import * as React from "react";
3
3
 
4
+ import { isEqual } from "@applicaster/zapp-react-native-utils/equalUtils";
4
5
  import { ThemeContext } from "@applicaster/zapp-react-native-utils/theme";
5
- import { useDimensions } from "@applicaster/zapp-react-native-utils/reactHooks";
6
+ import { useIsTablet } from "@applicaster/zapp-react-native-utils/reactHooks";
6
7
  import {
7
8
  mapKeys,
8
9
  partitionByKeys,
@@ -35,7 +36,7 @@ function populateTheme(plugin) {
35
36
 
36
37
  const TABLET_PREFIX = "tablet_";
37
38
 
38
- const prepareForTablet = (dimensions) => (themeProps) => {
39
+ const prepareForTablet = (isTablet) => (themeProps) => {
39
40
  const [tabletThemeProps, mobileTheme] = partitionByKeys(
40
41
  R.compose(R.startsWith(TABLET_PREFIX), R.head),
41
42
  themeProps
@@ -62,12 +63,12 @@ const prepareForTablet = (dimensions) => (themeProps) => {
62
63
  R.omit(["tablet_theme"])
63
64
  )(tabletThemeProps);
64
65
 
65
- return dimensions.deviceInfo.isTablet ? tabletTheme : mobileTheme;
66
+ return isTablet ? tabletTheme : mobileTheme;
66
67
  };
67
68
 
68
- const selectThemes = (dimensions, plugins) =>
69
+ const selectThemes = (isTablet, plugins) =>
69
70
  R.compose(
70
- R.map(prepareForTablet(dimensions)),
71
+ R.map(prepareForTablet(isTablet)),
71
72
  R.fromPairs,
72
73
  R.reject(R.isNil),
73
74
  R.map(populateTheme),
@@ -80,36 +81,38 @@ const ThemeContextProvider = ({
80
81
  setSelectedThemeId,
81
82
  children,
82
83
  }: any) => {
83
- const value = React.useMemo(
84
- () => ({ themes, selectedThemeId, setSelectedThemeId }),
85
- [themes, selectedThemeId, setSelectedThemeId]
86
- );
84
+ const value = { themes, selectedThemeId, setSelectedThemeId };
87
85
 
88
86
  return (
89
87
  <ThemeContext.Provider value={value}>{children}</ThemeContext.Provider>
90
88
  );
91
89
  };
92
90
 
91
+ const MemoizedThemeContextProvider = React.memo(
92
+ ThemeContextProvider,
93
+ isEqual({
94
+ byValue: ["selectedThemeId", "setSelectedThemeId"],
95
+ byReference: ["children", "themes"],
96
+ })
97
+ );
98
+
93
99
  function ThemeManagerComponent({ children, plugins }: Props) {
94
- const dimensions = useDimensions("screen", { deviceInfo: true });
95
- const [themes, setThemes] = React.useState(selectThemes(dimensions, plugins));
100
+ const isTablet = useIsTablet();
101
+
102
+ const themes = selectThemes(isTablet, plugins);
96
103
 
97
104
  const [selectedThemeId, setSelectedThemeId] =
98
105
  React.useState(DEFAULT_THEME_ID);
99
106
 
100
- React.useEffect(() => {
101
- setThemes(selectThemes(dimensions, plugins));
102
- }, [plugins, dimensions]);
103
-
104
107
  return (
105
- <ThemeContextProvider
108
+ <MemoizedThemeContextProvider
106
109
  themes={themes}
107
110
  selectedThemeId={selectedThemeId}
108
111
  setSelectedThemeId={setSelectedThemeId}
109
112
  >
110
113
  {children}
111
- </ThemeContextProvider>
114
+ </MemoizedThemeContextProvider>
112
115
  );
113
116
  }
114
117
 
115
- export const ThemeManager = React.memo<Props>(ThemeManagerComponent);
118
+ export const ThemeManager = ThemeManagerComponent;
package/App/index.tsx CHANGED
@@ -5,11 +5,6 @@ import {
5
5
  initialWindowMetrics,
6
6
  } from "react-native-safe-area-context";
7
7
 
8
- import type {
9
- AppComponentProps,
10
- ZappApp,
11
- } from "@applicaster/zapp-react-native-flow-types";
12
-
13
8
  import { ErrorBoundary } from "./ErrorBoundary";
14
9
  import { RouteManager } from "./RouteManager";
15
10
  import { withNavigationProvider } from "./NavigationProvider";
@@ -8,11 +8,6 @@ import * as React from "react";
8
8
  import * as R from "ramda";
9
9
  import { Dimensions } from "react-native";
10
10
 
11
- import type {
12
- AppComponentProps,
13
- ZappAppConfig,
14
- } from "@applicaster/zapp-react-native-flow-types";
15
-
16
11
  import {
17
12
  createZappReduxStore,
18
13
  loadAppContextData,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@applicaster/quick-brick-core",
3
- "version": "12.0.0-alpha.9151207838",
3
+ "version": "12.0.0-alpha.9262886003",
4
4
  "description": "Core package for Applicaster's Quick Brick App",
5
5
  "main": "index.js",
6
6
  "types": "index.d.ts",
@@ -30,15 +30,15 @@
30
30
  },
31
31
  "homepage": "https://github.com/applicaster/quickbrick#readme",
32
32
  "dependencies": {
33
- "@applicaster/applicaster-types": "12.0.0-alpha.9151207838",
34
- "@applicaster/quick-brick-core-plugins": "12.0.0-alpha.9151207838",
35
- "@applicaster/zapp-pipes-v2-client": "12.0.0-alpha.9151207838",
36
- "@applicaster/zapp-react-native-bridge": "12.0.0-alpha.9151207838",
37
- "@applicaster/zapp-react-native-redux": "12.0.0-alpha.9151207838",
38
- "@applicaster/zapp-react-native-ui-components": "12.0.0-alpha.9151207838",
39
- "@applicaster/zapp-react-native-utils": "12.0.0-alpha.9151207838",
33
+ "@applicaster/applicaster-types": "12.0.0-alpha.9262886003",
34
+ "@applicaster/quick-brick-core-plugins": "12.0.0-alpha.9262886003",
35
+ "@applicaster/zapp-pipes-v2-client": "12.0.0-alpha.9262886003",
36
+ "@applicaster/zapp-react-native-bridge": "12.0.0-alpha.9262886003",
37
+ "@applicaster/zapp-react-native-redux": "12.0.0-alpha.9262886003",
38
+ "@applicaster/zapp-react-native-ui-components": "12.0.0-alpha.9262886003",
39
+ "@applicaster/zapp-react-native-utils": "12.0.0-alpha.9262886003",
40
40
  "atob": "^2.1.2",
41
- "axios": "^0.21.2",
41
+ "axios": "^0.28.0",
42
42
  "btoa": "^1.2.1",
43
43
  "camelize": "^1.0.0",
44
44
  "md5": "^2.3.0",
@@ -58,7 +58,6 @@
58
58
  "react-native-safe-area-context": "*"
59
59
  },
60
60
  "devDependencies": {
61
- "@applicaster/zapp-react-native-flow-types": "1.5.0",
62
61
  "@types/react-native": "0.69.6",
63
62
  "@types/tizen-tv-webapis": "^2.0.1",
64
63
  "nock": "^10.0.0",