@applicaster/quick-brick-core 12.0.0-alpha.6236157458 → 12.0.0-alpha.7539319320

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.
@@ -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
  }
@@ -3,7 +3,7 @@ import * as React from "react";
3
3
 
4
4
  import { isEqual } from "@applicaster/zapp-react-native-utils/equalUtils";
5
5
  import { ThemeContext } from "@applicaster/zapp-react-native-utils/theme";
6
- import { useDimensions } from "@applicaster/zapp-react-native-utils/reactHooks";
6
+ import { useIsTablet } from "@applicaster/zapp-react-native-utils/reactHooks";
7
7
  import {
8
8
  mapKeys,
9
9
  partitionByKeys,
@@ -36,7 +36,7 @@ function populateTheme(plugin) {
36
36
 
37
37
  const TABLET_PREFIX = "tablet_";
38
38
 
39
- const prepareForTablet = (dimensions) => (themeProps) => {
39
+ const prepareForTablet = (isTablet) => (themeProps) => {
40
40
  const [tabletThemeProps, mobileTheme] = partitionByKeys(
41
41
  R.compose(R.startsWith(TABLET_PREFIX), R.head),
42
42
  themeProps
@@ -63,12 +63,12 @@ const prepareForTablet = (dimensions) => (themeProps) => {
63
63
  R.omit(["tablet_theme"])
64
64
  )(tabletThemeProps);
65
65
 
66
- return dimensions.deviceInfo.isTablet ? tabletTheme : mobileTheme;
66
+ return isTablet ? tabletTheme : mobileTheme;
67
67
  };
68
68
 
69
- const selectThemes = (dimensions, plugins) =>
69
+ const selectThemes = (isTablet, plugins) =>
70
70
  R.compose(
71
- R.map(prepareForTablet(dimensions)),
71
+ R.map(prepareForTablet(isTablet)),
72
72
  R.fromPairs,
73
73
  R.reject(R.isNil),
74
74
  R.map(populateTheme),
@@ -97,20 +97,13 @@ const MemoizedThemeContextProvider = React.memo(
97
97
  );
98
98
 
99
99
  function ThemeManagerComponent({ children, plugins }: Props) {
100
- const dimensions = useDimensions("screen", { deviceInfo: true });
101
- const [themes, setThemes] = React.useState(selectThemes(dimensions, plugins));
100
+ const isTablet = useIsTablet();
101
+
102
+ const themes = selectThemes(isTablet, plugins);
102
103
 
103
104
  const [selectedThemeId, setSelectedThemeId] =
104
105
  React.useState(DEFAULT_THEME_ID);
105
106
 
106
- React.useEffect(() => {
107
- setThemes((oldThemes) => {
108
- const newThemes = selectThemes(dimensions, plugins);
109
-
110
- return R.equals(oldThemes, newThemes) ? oldThemes : newThemes;
111
- });
112
- }, [plugins, dimensions]);
113
-
114
107
  return (
115
108
  <MemoizedThemeContextProvider
116
109
  themes={themes}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@applicaster/quick-brick-core",
3
- "version": "12.0.0-alpha.6236157458",
3
+ "version": "12.0.0-alpha.7539319320",
4
4
  "description": "Core package for Applicaster's Quick Brick App",
5
5
  "main": "index.js",
6
6
  "types": "index.d.ts",
@@ -30,13 +30,13 @@
30
30
  },
31
31
  "homepage": "https://github.com/applicaster/quickbrick#readme",
32
32
  "dependencies": {
33
- "@applicaster/applicaster-types": "12.0.0-alpha.6236157458",
34
- "@applicaster/quick-brick-core-plugins": "12.0.0-alpha.6236157458",
35
- "@applicaster/zapp-pipes-v2-client": "12.0.0-alpha.6236157458",
36
- "@applicaster/zapp-react-native-bridge": "12.0.0-alpha.6236157458",
37
- "@applicaster/zapp-react-native-redux": "12.0.0-alpha.6236157458",
38
- "@applicaster/zapp-react-native-ui-components": "12.0.0-alpha.6236157458",
39
- "@applicaster/zapp-react-native-utils": "12.0.0-alpha.6236157458",
33
+ "@applicaster/applicaster-types": "12.0.0-alpha.7539319320",
34
+ "@applicaster/quick-brick-core-plugins": "12.0.0-alpha.7539319320",
35
+ "@applicaster/zapp-pipes-v2-client": "12.0.0-alpha.7539319320",
36
+ "@applicaster/zapp-react-native-bridge": "12.0.0-alpha.7539319320",
37
+ "@applicaster/zapp-react-native-redux": "12.0.0-alpha.7539319320",
38
+ "@applicaster/zapp-react-native-ui-components": "12.0.0-alpha.7539319320",
39
+ "@applicaster/zapp-react-native-utils": "12.0.0-alpha.7539319320",
40
40
  "atob": "^2.1.2",
41
41
  "axios": "^0.21.2",
42
42
  "btoa": "^1.2.1",