@applicaster/quick-brick-core 11.0.0-rc.99 → 12.0.0-rc.1
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.
- package/App/ActionsProvider/{ActionsProvider.js → ActionsProvider.tsx} +18 -22
- package/App/AssetCache/CacheManager.ts +33 -36
- package/App/AssetCache/__tests__/__snapshots__/assetCache.test.ts.snap +32 -26
- package/App/AssetCache/__tests__/assetCache.test.ts +12 -15
- package/App/AssetCache/__tests__/cacheManager.test.ts +2 -1
- package/App/AssetCache/index.ts +71 -31
- package/App/AssetCache/logger.ts +8 -1
- package/App/DeepLinking/URLSchemeHandler/SchemeHandlerHooks/__tests__/useOpenSchemeHandler.test.tsx +2 -2
- package/App/DeepLinking/URLSchemeHandler/SchemeHandlerHooks/__tests__/usePresentSchemeHandler.test.tsx +2 -2
- package/App/DeepLinking/helpers/index.ts +4 -7
- package/App/ErrorBoundary/__tests__/errorBoundary.test.js +0 -1
- package/App/ModalProvider/index.tsx +14 -11
- package/App/NavigationProvider/NavigationProvider.tsx +49 -28
- package/App/NavigationProvider/navigator/__tests__/__snapshots__/reducer.test.ts.snap +0 -33
- package/App/NavigationProvider/navigator/__tests__/reducer.test.ts +0 -175
- package/App/NavigationProvider/navigator/reducer.ts +7 -54
- package/App/StoreConnector/{index.js → index.ts} +0 -2
- package/App/ThemeManager/{index.js → index.tsx} +9 -13
- package/App/{index.js → index.tsx} +0 -2
- package/createZappApp/index.js +9 -5
- package/helpers/index.js +0 -2
- package/index.js +0 -2
- package/package.json +8 -8
- package/renderZappApp/index.js +0 -2
- package/tsconfig.json +1 -1
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
// @flow
|
|
2
1
|
import * as React from "react";
|
|
3
2
|
import * as R from "ramda";
|
|
4
3
|
|
|
@@ -6,21 +5,18 @@ import { ActionsContext } from "@applicaster/zapp-react-native-ui-components/Con
|
|
|
6
5
|
import { isNilOrEmpty } from "@applicaster/zapp-react-native-utils/reactUtils/helpers";
|
|
7
6
|
|
|
8
7
|
type Props = {
|
|
9
|
-
children: React.
|
|
10
|
-
rivers:
|
|
11
|
-
plugins:
|
|
12
|
-
useLocation: () => {}
|
|
13
|
-
useHistory: () => {}
|
|
8
|
+
children: React.ReactNode;
|
|
9
|
+
rivers: Record<string, any>;
|
|
10
|
+
plugins: {}[];
|
|
11
|
+
useLocation: () => {};
|
|
12
|
+
useHistory: () => {};
|
|
14
13
|
};
|
|
15
14
|
|
|
16
|
-
type Plugin = {
|
|
17
|
-
|
|
18
|
-
identifier: string,
|
|
15
|
+
type Plugin = Record<string, any> & {
|
|
16
|
+
identifier: string;
|
|
19
17
|
};
|
|
20
18
|
|
|
21
|
-
type PluginsIdMap =
|
|
22
|
-
[any]: Plugin,
|
|
23
|
-
};
|
|
19
|
+
type PluginsIdMap = Record<string, Plugin>;
|
|
24
20
|
|
|
25
21
|
const getActionPlugins = (plugins) =>
|
|
26
22
|
R.filter(R.path(["module", "actionName"]))(plugins);
|
|
@@ -28,10 +24,9 @@ const getActionPlugins = (plugins) =>
|
|
|
28
24
|
/**
|
|
29
25
|
* this functions translates array of objects,
|
|
30
26
|
* to object of keys create from original object.identifier
|
|
31
|
-
* @param {Array} actionPlugins
|
|
32
27
|
*/
|
|
33
28
|
|
|
34
|
-
const abstractIdentifier = (actionPlugins: [
|
|
29
|
+
const abstractIdentifier = (actionPlugins: Plugin[]): PluginsIdMap =>
|
|
35
30
|
R.compose(
|
|
36
31
|
R.mergeAll,
|
|
37
32
|
R.map((plugin) => ({ [plugin.identifier]: plugin }))
|
|
@@ -40,25 +35,26 @@ const abstractIdentifier = (actionPlugins: [Plugin]): PluginsIdMap =>
|
|
|
40
35
|
/**
|
|
41
36
|
* Component returning children.
|
|
42
37
|
* Can be used to create Component from children
|
|
43
|
-
* @param {React.Children} props.children
|
|
44
38
|
*/
|
|
45
|
-
const ChildrenWrapper = ({
|
|
39
|
+
const ChildrenWrapper = ({
|
|
40
|
+
children,
|
|
41
|
+
}: {
|
|
42
|
+
children: React.ReactElement<any>;
|
|
43
|
+
}) => {
|
|
46
44
|
return children;
|
|
47
45
|
};
|
|
48
46
|
|
|
49
47
|
/**
|
|
50
48
|
* It wraps children in multiple context providers
|
|
51
|
-
* @param
|
|
49
|
+
* @param contexts - Array of React Context Providers
|
|
52
50
|
*/
|
|
53
|
-
const contextComposer = (contexts:
|
|
51
|
+
const contextComposer = (contexts: Plugin[]): React.ExoticComponent =>
|
|
54
52
|
R.compose(...contexts)(ChildrenWrapper);
|
|
55
53
|
|
|
56
54
|
/**
|
|
57
55
|
* ActionsProvider is a React Context Provider for a ActionPlugins
|
|
58
|
-
* @param
|
|
59
|
-
* @
|
|
60
|
-
* @param {Array} props.plugins - list of app plugins
|
|
61
|
-
* @return {React.Node} - Returns Children wrapped in the Action providers
|
|
56
|
+
* @param props.plugins - list of app plugins
|
|
57
|
+
* @return Returns Children wrapped in the Action providers
|
|
62
58
|
*/
|
|
63
59
|
export function ActionsProvider(props: Props) {
|
|
64
60
|
const { children, plugins } = props;
|
|
@@ -8,7 +8,7 @@ import {
|
|
|
8
8
|
getNativeRootPath,
|
|
9
9
|
} from "@applicaster/zapp-react-native-bridge/OfflineAssets";
|
|
10
10
|
|
|
11
|
-
import {
|
|
11
|
+
import { log_verbose } from "./logger";
|
|
12
12
|
|
|
13
13
|
type LayoutCacheStorageData = { id: string; files: FilesList };
|
|
14
14
|
|
|
@@ -17,6 +17,7 @@ type AssetCacheDataStorageData = {
|
|
|
17
17
|
};
|
|
18
18
|
|
|
19
19
|
const CACHE_DATA_KEY = "APP_ASSETS_CACHE_DATA_KEY";
|
|
20
|
+
const CACHE_NAMESPACE = "offline_mode";
|
|
20
21
|
const ASSET_FOLDERS = ["rivers", "plugins", "cellStyles"];
|
|
21
22
|
|
|
22
23
|
const getAssetsProps = (assets) => {
|
|
@@ -49,24 +50,25 @@ export class CacheManager {
|
|
|
49
50
|
async getFilesToCache(
|
|
50
51
|
layoutId: string,
|
|
51
52
|
assetFiles: FilesList
|
|
52
|
-
): Promise<{
|
|
53
|
-
|
|
54
|
-
|
|
53
|
+
): Promise<{
|
|
54
|
+
removedFiles: FilesList;
|
|
55
|
+
newFiles: FilesList;
|
|
56
|
+
unchangedFiles: FilesList;
|
|
57
|
+
}> {
|
|
58
|
+
if (isTV()) return { removedFiles: [], newFiles: [], unchangedFiles: [] };
|
|
55
59
|
await this.getCacheData(layoutId);
|
|
56
60
|
|
|
57
61
|
if (layoutId !== this._layoutId) {
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
requestedLayout: layoutId,
|
|
63
|
-
numberOfAssets: assetFiles?.length,
|
|
64
|
-
},
|
|
62
|
+
log_verbose("getFilesToCache: caching new layout id", {
|
|
63
|
+
previousLayout: this._layoutId,
|
|
64
|
+
requestedLayout: layoutId,
|
|
65
|
+
numberOfAssets: assetFiles?.length,
|
|
65
66
|
});
|
|
66
67
|
|
|
67
68
|
return {
|
|
68
69
|
removedFiles: this._files || [],
|
|
69
70
|
newFiles: assetFiles,
|
|
71
|
+
unchangedFiles: [],
|
|
70
72
|
};
|
|
71
73
|
}
|
|
72
74
|
|
|
@@ -75,57 +77,52 @@ export class CacheManager {
|
|
|
75
77
|
const files = getAssetsProps(assetFiles);
|
|
76
78
|
const removedFiles = diff(this._files, files);
|
|
77
79
|
const newFiles = diff(files, this._files);
|
|
78
|
-
|
|
80
|
+
const unchangedFiles = diff(diff(files, removedFiles), newFiles);
|
|
79
81
|
const time = performance.now() - start;
|
|
80
82
|
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
83
|
+
log_verbose(
|
|
84
|
+
`getFilesToCache: getting cache diff for current layout, took ${time} ms`,
|
|
85
|
+
{
|
|
84
86
|
layoutId,
|
|
85
87
|
removedFiles,
|
|
86
88
|
newFiles,
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
+
}
|
|
90
|
+
);
|
|
89
91
|
|
|
90
|
-
return { removedFiles, newFiles };
|
|
92
|
+
return { removedFiles, newFiles, unchangedFiles };
|
|
91
93
|
}
|
|
92
94
|
|
|
93
95
|
async clearCache(removedFiles: FilesList) {
|
|
94
96
|
const folders = removedFiles.map((fileObj) => fileObj.file);
|
|
95
97
|
|
|
96
98
|
if (folders && folders?.length > 0) {
|
|
97
|
-
|
|
98
|
-
message: "clearing asset cache folders",
|
|
99
|
-
data: { folders },
|
|
100
|
-
});
|
|
99
|
+
log_verbose("getFilesToCache: clearing asset cache folders", { folders });
|
|
101
100
|
|
|
102
101
|
await deleteFolders(folders);
|
|
103
102
|
|
|
104
103
|
return;
|
|
105
104
|
}
|
|
106
105
|
|
|
107
|
-
|
|
106
|
+
log_verbose("getFilesToCache: no assets to remove from cache");
|
|
108
107
|
}
|
|
109
108
|
|
|
110
109
|
async saveCacheData(layoutId: string, assetFiles: FilesList) {
|
|
111
110
|
const files = getAssetsProps(assetFiles);
|
|
112
111
|
|
|
113
|
-
|
|
114
|
-
message: "saving cache data",
|
|
115
|
-
data: {
|
|
116
|
-
layoutId,
|
|
117
|
-
files,
|
|
118
|
-
},
|
|
119
|
-
});
|
|
112
|
+
log_verbose("getFilesToCache: saving cache data", { layoutId, files });
|
|
120
113
|
|
|
121
|
-
await localStorage.setItem(
|
|
122
|
-
|
|
123
|
-
|
|
114
|
+
await localStorage.setItem(
|
|
115
|
+
CACHE_DATA_KEY,
|
|
116
|
+
{
|
|
117
|
+
[layoutId]: { id: layoutId, files },
|
|
118
|
+
},
|
|
119
|
+
CACHE_NAMESPACE
|
|
120
|
+
);
|
|
124
121
|
}
|
|
125
122
|
|
|
126
|
-
|
|
123
|
+
async getCacheData(layoutId: string) {
|
|
127
124
|
const cacheData: Maybe<AssetCacheDataStorageData> =
|
|
128
|
-
await localStorage.getItem(CACHE_DATA_KEY);
|
|
125
|
+
await localStorage.getItem(CACHE_DATA_KEY, CACHE_NAMESPACE);
|
|
129
126
|
|
|
130
127
|
const layoutCacheData: Maybe<LayoutCacheStorageData> =
|
|
131
128
|
cacheData?.[layoutId] || {};
|
|
@@ -141,7 +138,7 @@ export class CacheManager {
|
|
|
141
138
|
ASSET_FOLDERS
|
|
142
139
|
);
|
|
143
140
|
|
|
144
|
-
await localStorage.removeItem(CACHE_DATA_KEY);
|
|
141
|
+
await localStorage.removeItem(CACHE_DATA_KEY, CACHE_NAMESPACE);
|
|
145
142
|
|
|
146
143
|
return deleteFolders(assetfolders);
|
|
147
144
|
}
|
|
@@ -270,7 +270,8 @@ Object {
|
|
|
270
270
|
Object {
|
|
271
271
|
"file": "/path/rivers/bcfa75eacd166d575dee8da3c1d7b2f1.png",
|
|
272
272
|
"path": Array [
|
|
273
|
-
"
|
|
273
|
+
"screens",
|
|
274
|
+
2,
|
|
274
275
|
"styles",
|
|
275
276
|
"failing_asset",
|
|
276
277
|
],
|
|
@@ -280,7 +281,8 @@ Object {
|
|
|
280
281
|
Object {
|
|
281
282
|
"file": "/path/rivers/f717cc29f30fb8376953a5cdb4666501.png",
|
|
282
283
|
"path": Array [
|
|
283
|
-
"
|
|
284
|
+
"screens",
|
|
285
|
+
1,
|
|
284
286
|
"navigations",
|
|
285
287
|
0,
|
|
286
288
|
"nav_items",
|
|
@@ -293,7 +295,8 @@ Object {
|
|
|
293
295
|
Object {
|
|
294
296
|
"file": "/path/rivers/fca006fff4ecd7d607e11be81e5d681c.png",
|
|
295
297
|
"path": Array [
|
|
296
|
-
"
|
|
298
|
+
"screens",
|
|
299
|
+
0,
|
|
297
300
|
"general",
|
|
298
301
|
"icon",
|
|
299
302
|
],
|
|
@@ -314,33 +317,23 @@ Object {
|
|
|
314
317
|
"url": "http://img.com/cell_asset.png",
|
|
315
318
|
},
|
|
316
319
|
],
|
|
317
|
-
"
|
|
320
|
+
"layoutAssets": Array [
|
|
318
321
|
Object {
|
|
319
|
-
"file": "/path/
|
|
322
|
+
"file": "/path/rivers/fca006fff4ecd7d607e11be81e5d681c.png",
|
|
320
323
|
"path": Array [
|
|
324
|
+
"screens",
|
|
321
325
|
0,
|
|
322
|
-
"
|
|
323
|
-
"
|
|
324
|
-
],
|
|
325
|
-
"source": "plugins",
|
|
326
|
-
"url": "http://img.com/plugin_asset.png",
|
|
327
|
-
},
|
|
328
|
-
],
|
|
329
|
-
"screenAssets": Array [
|
|
330
|
-
Object {
|
|
331
|
-
"file": "/path/rivers/bcfa75eacd166d575dee8da3c1d7b2f1.png",
|
|
332
|
-
"path": Array [
|
|
333
|
-
"screen3",
|
|
334
|
-
"styles",
|
|
335
|
-
"failing_asset",
|
|
326
|
+
"general",
|
|
327
|
+
"icon",
|
|
336
328
|
],
|
|
337
329
|
"source": "rivers",
|
|
338
|
-
"url": "http://img.com/
|
|
330
|
+
"url": "http://img.com/icon.png",
|
|
339
331
|
},
|
|
340
332
|
Object {
|
|
341
333
|
"file": "/path/rivers/f717cc29f30fb8376953a5cdb4666501.png",
|
|
342
334
|
"path": Array [
|
|
343
|
-
"
|
|
335
|
+
"screens",
|
|
336
|
+
1,
|
|
344
337
|
"navigations",
|
|
345
338
|
0,
|
|
346
339
|
"nav_items",
|
|
@@ -351,14 +344,27 @@ Object {
|
|
|
351
344
|
"url": "http://img.com/tab_asset.png",
|
|
352
345
|
},
|
|
353
346
|
Object {
|
|
354
|
-
"file": "/path/rivers/
|
|
347
|
+
"file": "/path/rivers/bcfa75eacd166d575dee8da3c1d7b2f1.png",
|
|
355
348
|
"path": Array [
|
|
356
|
-
"
|
|
357
|
-
|
|
358
|
-
"
|
|
349
|
+
"screens",
|
|
350
|
+
2,
|
|
351
|
+
"styles",
|
|
352
|
+
"failing_asset",
|
|
359
353
|
],
|
|
360
354
|
"source": "rivers",
|
|
361
|
-
"url": "http://img.com/
|
|
355
|
+
"url": "http://img.com/failing_asset.png",
|
|
356
|
+
},
|
|
357
|
+
],
|
|
358
|
+
"pluginAssets": Array [
|
|
359
|
+
Object {
|
|
360
|
+
"file": "/path/plugins/beeef54b948ce2a8f5b376f8033a720e.png",
|
|
361
|
+
"path": Array [
|
|
362
|
+
0,
|
|
363
|
+
"configuration_json",
|
|
364
|
+
"plugin_asset",
|
|
365
|
+
],
|
|
366
|
+
"source": "plugins",
|
|
367
|
+
"url": "http://img.com/plugin_asset.png",
|
|
362
368
|
},
|
|
363
369
|
],
|
|
364
370
|
}
|
|
@@ -131,10 +131,8 @@ function clearMocks() {
|
|
|
131
131
|
|
|
132
132
|
describe("getLayoutAssets", () => {
|
|
133
133
|
it("returns the list of assets in the layout", async () => {
|
|
134
|
-
const { screens } = layout;
|
|
135
|
-
|
|
136
134
|
await expect(
|
|
137
|
-
getLayoutAssets({
|
|
135
|
+
getLayoutAssets({ layout, pluginConfigurations, cellStyles })
|
|
138
136
|
).resolves.toMatchSnapshot();
|
|
139
137
|
});
|
|
140
138
|
});
|
|
@@ -210,7 +208,7 @@ describe("asset cache", () => {
|
|
|
210
208
|
clearMocks();
|
|
211
209
|
|
|
212
210
|
const { assetFiles: newFiles } = await getLayoutAssets({
|
|
213
|
-
|
|
211
|
+
layout,
|
|
214
212
|
pluginConfigurations,
|
|
215
213
|
cellStyles,
|
|
216
214
|
});
|
|
@@ -219,6 +217,7 @@ describe("asset cache", () => {
|
|
|
219
217
|
Promise.resolve({
|
|
220
218
|
removedFiles,
|
|
221
219
|
newFiles,
|
|
220
|
+
unchangedFiles: [],
|
|
222
221
|
})
|
|
223
222
|
);
|
|
224
223
|
});
|
|
@@ -230,15 +229,13 @@ describe("asset cache", () => {
|
|
|
230
229
|
cellStyles,
|
|
231
230
|
});
|
|
232
231
|
|
|
233
|
-
const { screens } = layout;
|
|
234
|
-
|
|
235
232
|
const { assetFiles } = await getLayoutAssets({
|
|
236
|
-
|
|
233
|
+
layout,
|
|
237
234
|
pluginConfigurations,
|
|
238
235
|
cellStyles,
|
|
239
236
|
});
|
|
240
237
|
|
|
241
|
-
expect(clearCache).
|
|
238
|
+
expect(clearCache).not.toHaveBeenCalled();
|
|
242
239
|
expect(storeFiles).toHaveBeenCalledWith(assetFiles);
|
|
243
240
|
|
|
244
241
|
expect(saveCacheData).toHaveBeenCalledWith(
|
|
@@ -266,6 +263,7 @@ describe("asset cache", () => {
|
|
|
266
263
|
Promise.resolve({
|
|
267
264
|
removedFiles: [],
|
|
268
265
|
newFiles: [],
|
|
266
|
+
unchangedFiles: [],
|
|
269
267
|
})
|
|
270
268
|
);
|
|
271
269
|
});
|
|
@@ -288,7 +286,7 @@ describe("asset cache", () => {
|
|
|
288
286
|
clearMocks();
|
|
289
287
|
|
|
290
288
|
const { assetFiles } = await getLayoutAssets({
|
|
291
|
-
|
|
289
|
+
layout,
|
|
292
290
|
pluginConfigurations,
|
|
293
291
|
cellStyles,
|
|
294
292
|
});
|
|
@@ -297,8 +295,9 @@ describe("asset cache", () => {
|
|
|
297
295
|
|
|
298
296
|
getFilesToCache.mockImplementation(() =>
|
|
299
297
|
Promise.resolve({
|
|
300
|
-
removedFiles,
|
|
298
|
+
removedFiles: [removedFiles],
|
|
301
299
|
newFiles,
|
|
300
|
+
unchangedFiles: [],
|
|
302
301
|
})
|
|
303
302
|
);
|
|
304
303
|
});
|
|
@@ -310,23 +309,21 @@ describe("asset cache", () => {
|
|
|
310
309
|
cellStyles,
|
|
311
310
|
});
|
|
312
311
|
|
|
313
|
-
const { screens } = layout;
|
|
314
|
-
|
|
315
312
|
const { assetFiles } = await getLayoutAssets({
|
|
316
|
-
|
|
313
|
+
layout,
|
|
317
314
|
pluginConfigurations,
|
|
318
315
|
cellStyles,
|
|
319
316
|
});
|
|
320
317
|
|
|
321
318
|
const [removedFiles, ...newFiles] = assetFiles;
|
|
322
319
|
|
|
323
|
-
expect(clearCache).toHaveBeenCalledWith(removedFiles);
|
|
320
|
+
expect(clearCache).toHaveBeenCalledWith([removedFiles]);
|
|
324
321
|
|
|
325
322
|
expect(storeFiles).toHaveBeenCalledWith(newFiles);
|
|
326
323
|
|
|
327
324
|
expect(saveCacheData).toHaveBeenCalledWith(
|
|
328
325
|
layoutId,
|
|
329
|
-
newFiles.filter(({ url }) => !url.includes("fail"))
|
|
326
|
+
newFiles.filter(({ url }) => !url.includes("fail")),
|
|
330
327
|
);
|
|
331
328
|
});
|
|
332
329
|
|
package/App/AssetCache/index.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/// <reference types="../../" />
|
|
2
2
|
import * as R from "ramda";
|
|
3
|
-
import {
|
|
3
|
+
import { log_debug, log_warning } from "./logger";
|
|
4
4
|
import { CacheManager } from "./CacheManager";
|
|
5
5
|
|
|
6
6
|
import {
|
|
@@ -14,20 +14,17 @@ import {
|
|
|
14
14
|
import { isTV } from "@applicaster/zapp-react-native-utils/reactUtils";
|
|
15
15
|
|
|
16
16
|
export async function getLayoutAssets({
|
|
17
|
-
|
|
17
|
+
layout,
|
|
18
18
|
pluginConfigurations,
|
|
19
19
|
cellStyles,
|
|
20
20
|
}) {
|
|
21
21
|
const nativeRootPath = await getNativeRootPath();
|
|
22
22
|
|
|
23
|
-
const
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
),
|
|
29
|
-
[],
|
|
30
|
-
screens
|
|
23
|
+
const layoutAssets: FilesList = collectAssets(
|
|
24
|
+
layout,
|
|
25
|
+
nativeRootPath,
|
|
26
|
+
"rivers",
|
|
27
|
+
[]
|
|
31
28
|
);
|
|
32
29
|
|
|
33
30
|
const pluginAssets: FilesList = collectAssets(
|
|
@@ -51,9 +48,9 @@ export async function getLayoutAssets({
|
|
|
51
48
|
// @ts-ignore
|
|
52
49
|
R.flatten
|
|
53
50
|
// @ts-ignore
|
|
54
|
-
)([
|
|
51
|
+
)([layoutAssets, pluginAssets, cellAssets]);
|
|
55
52
|
|
|
56
|
-
return { assetFiles,
|
|
53
|
+
return { assetFiles, layoutAssets, pluginAssets, cellAssets };
|
|
57
54
|
}
|
|
58
55
|
|
|
59
56
|
export async function cacheAssets({
|
|
@@ -62,6 +59,12 @@ export async function cacheAssets({
|
|
|
62
59
|
cellStyles,
|
|
63
60
|
}: CacheAssetsArgs) {
|
|
64
61
|
if (!isAssetCacheEnabled() || isTV()) {
|
|
62
|
+
log_debug(
|
|
63
|
+
"cacheAssets:" + !isAssetCacheEnabled()
|
|
64
|
+
? "Asset caching is disabled"
|
|
65
|
+
: "Running on TV platform" + "skipping asset caching"
|
|
66
|
+
);
|
|
67
|
+
|
|
65
68
|
return {
|
|
66
69
|
layout,
|
|
67
70
|
pluginConfigurations,
|
|
@@ -69,10 +72,10 @@ export async function cacheAssets({
|
|
|
69
72
|
};
|
|
70
73
|
}
|
|
71
74
|
|
|
72
|
-
const
|
|
75
|
+
const layoutId = layout?.id;
|
|
73
76
|
|
|
74
77
|
if (!layoutId) {
|
|
75
|
-
|
|
78
|
+
log_warning("cacheAssets: layout id is undefined, cannot cache assets");
|
|
76
79
|
|
|
77
80
|
return {
|
|
78
81
|
layout,
|
|
@@ -82,46 +85,83 @@ export async function cacheAssets({
|
|
|
82
85
|
}
|
|
83
86
|
|
|
84
87
|
try {
|
|
85
|
-
const { assetFiles,
|
|
88
|
+
const { assetFiles, cellAssets, pluginAssets, layoutAssets } =
|
|
86
89
|
await getLayoutAssets({
|
|
87
|
-
|
|
90
|
+
layout,
|
|
88
91
|
pluginConfigurations,
|
|
89
92
|
cellStyles,
|
|
90
93
|
});
|
|
91
94
|
|
|
92
|
-
|
|
95
|
+
log_debug(`cacheAssets: getting layout assets:
|
|
96
|
+
assetFilesCount: ${assetFiles.length},
|
|
97
|
+
cellAssets: ${cellAssets.length},
|
|
98
|
+
pluginAssets: ${pluginAssets.length},
|
|
99
|
+
layoutAssets: ${layoutAssets?.length}`);
|
|
100
|
+
|
|
101
|
+
const { removedFiles, newFiles, unchangedFiles } =
|
|
93
102
|
await CacheManager.instance.getFilesToCache(layoutId, assetFiles);
|
|
94
103
|
|
|
95
|
-
|
|
104
|
+
log_debug(`cacheAssets: getting files to cache for layoutId: ${layoutId},
|
|
105
|
+
removedFiles: ${removedFiles?.length},
|
|
106
|
+
newFiles: ${newFiles.length},
|
|
107
|
+
unchangedFiles: ${unchangedFiles.length}`);
|
|
96
108
|
|
|
97
|
-
|
|
109
|
+
const needsCacheUpdate = removedFiles?.length > 0 || newFiles?.length > 0;
|
|
110
|
+
let newCacheState = unchangedFiles;
|
|
111
|
+
|
|
112
|
+
if (removedFiles?.length > 0) {
|
|
98
113
|
await CacheManager.instance.clearCache(removedFiles);
|
|
99
|
-
|
|
114
|
+
|
|
115
|
+
log_debug(`cacheAssets: removed files: ${removedFiles.length}`);
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
if (newFiles?.length > 0) {
|
|
119
|
+
// TODO: Check that we are online
|
|
120
|
+
|
|
121
|
+
const result: StoredFilesResult = await storeFiles(newFiles);
|
|
122
|
+
|
|
100
123
|
const cachedFiles = R.filter(fileIsSaved(result), assetFiles);
|
|
101
|
-
|
|
124
|
+
|
|
125
|
+
newCacheState = cachedFiles.concat(unchangedFiles);
|
|
126
|
+
|
|
127
|
+
log_debug(
|
|
128
|
+
`cacheAssets: saved new files, cashedFiles: ${cachedFiles.length}`
|
|
129
|
+
);
|
|
102
130
|
}
|
|
103
131
|
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
132
|
+
if (needsCacheUpdate && newCacheState) {
|
|
133
|
+
await CacheManager.instance.saveCacheData(layoutId, newCacheState);
|
|
134
|
+
|
|
135
|
+
log_debug(
|
|
136
|
+
`cacheAssets: saving caching data for layoutId: ${layoutId}, cashedFiles: ${newCacheState.length}`
|
|
137
|
+
);
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
const urlFileMap: { [key: string]: string } = {};
|
|
141
|
+
|
|
142
|
+
newCacheState.forEach(({ file, url }) => (urlFileMap[url] = file));
|
|
143
|
+
|
|
144
|
+
const updatedLayout = remapAssetPath(layoutAssets, layout, urlFileMap);
|
|
109
145
|
|
|
110
146
|
const updatedPluginConfigurations = remapAssetPath(
|
|
111
147
|
pluginAssets,
|
|
112
148
|
pluginConfigurations,
|
|
113
|
-
|
|
149
|
+
urlFileMap
|
|
114
150
|
);
|
|
115
151
|
|
|
116
|
-
const updatedCellStyles = remapAssetPath(
|
|
152
|
+
const updatedCellStyles = remapAssetPath(
|
|
153
|
+
cellAssets,
|
|
154
|
+
cellStyles,
|
|
155
|
+
urlFileMap
|
|
156
|
+
);
|
|
117
157
|
|
|
118
158
|
return {
|
|
119
|
-
layout:
|
|
159
|
+
layout: updatedLayout,
|
|
120
160
|
pluginConfigurations: updatedPluginConfigurations,
|
|
121
161
|
cellStyles: updatedCellStyles,
|
|
122
162
|
};
|
|
123
|
-
} catch (
|
|
124
|
-
|
|
163
|
+
} catch (error) {
|
|
164
|
+
log_warning(`cacheAssets: Error caching assets, message: ${error.message}`);
|
|
125
165
|
|
|
126
166
|
return { layout, pluginConfigurations, cellStyles };
|
|
127
167
|
}
|
package/App/AssetCache/logger.ts
CHANGED
|
@@ -1,3 +1,10 @@
|
|
|
1
|
+
import { createLogger } from "@applicaster/zapp-react-native-utils/logger";
|
|
2
|
+
|
|
1
3
|
import { coreAppLogger } from "../logger";
|
|
2
4
|
|
|
3
|
-
export const
|
|
5
|
+
export const { log_verbose, log_debug, log_warning, log_info, log_error } =
|
|
6
|
+
createLogger({
|
|
7
|
+
category: "AssetCache",
|
|
8
|
+
subsystem: "quick-brick-core",
|
|
9
|
+
parent: coreAppLogger,
|
|
10
|
+
});
|
package/App/DeepLinking/URLSchemeHandler/SchemeHandlerHooks/__tests__/useOpenSchemeHandler.test.tsx
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/* eslint-disable max-len */
|
|
2
2
|
import { appStore } from "@applicaster/zapp-react-native-redux/AppStore";
|
|
3
3
|
import * as feedLoader from "@applicaster/zapp-react-native-utils/reactHooks/feed/useFeedLoader";
|
|
4
|
-
import * as
|
|
4
|
+
import * as useNavigationHooks from "@applicaster/zapp-react-native-utils/reactHooks/navigation/useNavigation";
|
|
5
5
|
import { cleanup, renderHook } from "@testing-library/react-hooks";
|
|
6
6
|
import nock from "nock";
|
|
7
7
|
import * as R from "ramda";
|
|
@@ -58,7 +58,7 @@ const navigator = {
|
|
|
58
58
|
const mockStore = configureStore();
|
|
59
59
|
|
|
60
60
|
jest
|
|
61
|
-
.spyOn(
|
|
61
|
+
.spyOn(useNavigationHooks, "useNavigation")
|
|
62
62
|
.mockImplementation(() => navigator);
|
|
63
63
|
|
|
64
64
|
const helperSpy = jest.spyOn(helpers, "handlePresentNavigation");
|
|
@@ -6,7 +6,7 @@ import { sessionStorage } from "@applicaster/zapp-react-native-bridge/ZappStorag
|
|
|
6
6
|
import * as zappRedux from "@applicaster/zapp-react-native-redux";
|
|
7
7
|
import * as helpers from "../../../helpers";
|
|
8
8
|
import * as feedLoader from "@applicaster/zapp-react-native-utils/reactHooks/feed/useFeedLoader";
|
|
9
|
-
import * as
|
|
9
|
+
import * as useNavigationHooks from "@applicaster/zapp-react-native-utils/reactHooks/navigation/useNavigation";
|
|
10
10
|
|
|
11
11
|
import { Provider } from "react-redux";
|
|
12
12
|
import configureStore from "redux-mock-store";
|
|
@@ -25,7 +25,7 @@ const navigator = {
|
|
|
25
25
|
const mockStore = configureStore();
|
|
26
26
|
|
|
27
27
|
jest
|
|
28
|
-
.spyOn(
|
|
28
|
+
.spyOn(useNavigationHooks, "useNavigation")
|
|
29
29
|
.mockImplementation(() => navigator);
|
|
30
30
|
|
|
31
31
|
const helperSpy = jest.spyOn(helpers, "handlePresentNavigation");
|