@applicaster/zapp-react-native-utils 15.0.0-alpha.8680244503 → 15.0.0-alpha.9300744523

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,7 +1,9 @@
1
- import { ReplaySubject } from "rxjs";
2
- import { filter } from "rxjs/operators";
1
+ import { ReplaySubject, Subject } from "rxjs";
2
+ import { filter, switchMap, take, withLatestFrom, map } from "rxjs/operators";
3
+
3
4
  import { BUTTON_PREFIX } from "@applicaster/zapp-react-native-ui-components/Components/MasterCell/DefaultComponents/tv/TvActionButtons/const";
4
5
  import { focusManager } from "@applicaster/zapp-react-native-utils/appUtils/focusManager/index.ios";
6
+ import { isPartOfMenu, isPartOfContent } from "./index.ios";
5
7
 
6
8
  type FocusableID = string;
7
9
  type RegistrationEvent = {
@@ -9,6 +11,25 @@ type RegistrationEvent = {
9
11
  registered: boolean;
10
12
  };
11
13
 
14
+ let focusableViewRegistrationSubject$ = new Subject<{
15
+ id: FocusableID;
16
+ groupId: FocusableID;
17
+ }>();
18
+
19
+ let focusableGroupRegistrationSubject$ = new ReplaySubject<{
20
+ id: FocusableID;
21
+ }>();
22
+
23
+ let focusableNativeViewRegistrationSubject$ = new Subject<{
24
+ id: FocusableID;
25
+ groupId: FocusableID;
26
+ }>();
27
+
28
+ let focusableNativeGroupRegistrationSubject$ = new ReplaySubject<{
29
+ id: FocusableID;
30
+ groupId: FocusableID;
31
+ }>();
32
+
12
33
  const isFocusableButton = (id: Option<FocusableID>): boolean =>
13
34
  id && id.includes?.(BUTTON_PREFIX);
14
35
 
@@ -22,14 +43,189 @@ export const focusableButtonsRegistration$ = (focusableGroupId: string) =>
22
43
  )
23
44
  );
24
45
 
25
- export const emitRegistered = (id: Option<FocusableID>): void => {
46
+ export const resetFocusableRegistration = () => {
47
+ // complete the old subject so subscribers are notified and resources are freed
48
+ if (!focusableViewRegistrationSubject$.closed) {
49
+ focusableViewRegistrationSubject$.complete();
50
+ }
51
+
52
+ if (!focusableGroupRegistrationSubject$.closed) {
53
+ focusableGroupRegistrationSubject$.complete();
54
+ }
55
+
56
+ if (!focusableNativeViewRegistrationSubject$.closed) {
57
+ focusableNativeViewRegistrationSubject$.complete();
58
+ }
59
+
60
+ if (!focusableNativeGroupRegistrationSubject$.closed) {
61
+ focusableNativeGroupRegistrationSubject$.complete();
62
+ }
63
+
64
+ focusableViewRegistrationSubject$ = new Subject<{
65
+ id: FocusableID;
66
+ groupId: FocusableID;
67
+ }>();
68
+
69
+ focusableGroupRegistrationSubject$ = new ReplaySubject<{
70
+ id: FocusableID;
71
+ }>();
72
+
73
+ focusableNativeViewRegistrationSubject$ = new Subject<{
74
+ id: FocusableID;
75
+ groupId: FocusableID;
76
+ }>();
77
+
78
+ focusableNativeGroupRegistrationSubject$ = new ReplaySubject<{
79
+ id: FocusableID;
80
+ groupId: FocusableID;
81
+ }>();
82
+ };
83
+
84
+ const focusableNativeViewRegistration = ({ focusableView, focusableGroup }) => {
85
+ return focusableNativeViewRegistrationSubject$.pipe(
86
+ filter(
87
+ (focusableNativeView) => focusableNativeView.id === focusableView.id
88
+ ),
89
+ take(1),
90
+ switchMap((focusableNativeView) =>
91
+ // start waiting registration of its parent FocusableNativeGroup
92
+ focusableNativeGroupRegistrationSubject$.pipe(
93
+ filter(
94
+ (focusableNativeGroup) =>
95
+ focusableNativeGroup.id === focusableNativeView.groupId
96
+ ),
97
+ take(1),
98
+ map((focusableNativeGroup) => ({
99
+ focusableNativeGroup,
100
+ focusableNativeView,
101
+ focusableView,
102
+ focusableGroup,
103
+ }))
104
+ )
105
+ )
106
+ );
107
+ };
108
+
109
+ export const firstFocusableViewRegistrationFactory = () =>
110
+ focusableViewRegistrationSubject$.pipe(
111
+ take(1), // we care about only first FocusableView registration
112
+ switchMap((focusableView) =>
113
+ // start waiting registration of its parent FocusableGroup
114
+ focusableGroupRegistrationSubject$.pipe(
115
+ filter((focusableGroup) => focusableGroup.id === focusableView.groupId),
116
+ take(1),
117
+ map((focusableGroup) => ({
118
+ focusableView,
119
+ focusableGroup,
120
+ }))
121
+ )
122
+ ),
123
+ // start waiting registration for FocusableNativeView and its parent FocusableNativeGroup
124
+ switchMap(({ focusableView, focusableGroup }) =>
125
+ focusableNativeViewRegistration({
126
+ focusableView,
127
+ focusableGroup,
128
+ })
129
+ )
130
+ );
131
+
132
+ // registration on RN level(into RN focusManager)
133
+ export const emitRegistered = ({
134
+ id,
135
+ groupId,
136
+ isGroup,
137
+ }: {
138
+ id: Option<FocusableID>;
139
+ groupId: Option<FocusableID>;
140
+ isGroup: boolean;
141
+ }): void => {
26
142
  if (isFocusableButton(id)) {
27
143
  registeredSubject$.next({ id, registered: true });
28
144
  }
145
+
146
+ if (isGroup && id) {
147
+ focusableGroupRegistrationSubject$.next({ id });
148
+ }
149
+
150
+ if (!isGroup && id && groupId) {
151
+ focusableViewRegistrationSubject$.next({ id, groupId });
152
+ }
29
153
  };
30
154
 
155
+ // unregistration on RN level(into RN focusManager)
31
156
  export const emitUnregistered = (id: Option<FocusableID>): void => {
32
157
  if (isFocusableButton(id)) {
33
158
  registeredSubject$.next({ id, registered: false });
34
159
  }
35
160
  };
161
+
162
+ // registration focusableNativeView and focusableNativeGroup
163
+ export const emitNativeRegistered = ({
164
+ id,
165
+ groupId,
166
+ isGroup,
167
+ }: {
168
+ id: Option<FocusableID>;
169
+ groupId: Option<FocusableID>;
170
+ isGroup: boolean;
171
+ }): void => {
172
+ if (!isGroup && id && groupId) {
173
+ focusableNativeViewRegistrationSubject$.next({ id, groupId });
174
+ }
175
+
176
+ if (isGroup && id && groupId) {
177
+ focusableNativeGroupRegistrationSubject$.next({ id, groupId });
178
+ }
179
+ };
180
+
181
+ // /////
182
+
183
+ const focusedSubject$ = new Subject<FocusableID>();
184
+
185
+ const focused$ = focusedSubject$.asObservable();
186
+
187
+ export const emitFocused = (id: FocusableID): void => {
188
+ focusedSubject$.next(id);
189
+ };
190
+
191
+ export const topMenuItemFocused$ = focused$.pipe(
192
+ filter((id) => id && isPartOfMenu(focusManager.focusableTree, id))
193
+ );
194
+
195
+ export const contentFocused$ = focused$.pipe(
196
+ filter((id) => {
197
+ const isContent = isPartOfContent(focusManager.focusableTree, id);
198
+
199
+ return id && isContent;
200
+ })
201
+ );
202
+
203
+ const createFocusableRegistry = () => {
204
+ const subject$ = new ReplaySubject<FocusableID | undefined>(1);
205
+
206
+ return {
207
+ observable$: subject$.asObservable(),
208
+ register: (id: FocusableID) => {
209
+ // save focusable_id on registration
210
+ subject$.next(id);
211
+ },
212
+ unregister: () => {
213
+ // reset focusable_id on unregistration
214
+ subject$.next(undefined);
215
+ },
216
+ };
217
+ };
218
+
219
+ /// HOME_TOP_MENU_ITEM
220
+ export const HomeTopMenuItemRegistry = createFocusableRegistry();
221
+
222
+ export const homeTopMenuItemFocused$ = topMenuItemFocused$.pipe(
223
+ withLatestFrom(HomeTopMenuItemRegistry.observable$),
224
+ filter(([id, homeId]) => id === homeId)
225
+ );
226
+
227
+ /// SCREEN_PICKER
228
+ export const ScreenPickerContentContainerRegistry = createFocusableRegistry();
229
+
230
+ /// SEARCH_INPUT
231
+ export const SearchInputRegistry = createFocusableRegistry();
@@ -49,7 +49,7 @@ export const findSelectedMenuId = (
49
49
  ) => {
50
50
  const sectionName = QUICK_BRICK_NAVBAR_SECTIONS[sectionKey];
51
51
 
52
- return pathOr(
52
+ return pathOr<string | undefined>(
53
53
  undefined,
54
54
  ["children", index, "id"],
55
55
  focusableTree.find(sectionName)
@@ -678,6 +678,22 @@ function getPlayerConfiguration({ platform, version }) {
678
678
  }
679
679
 
680
680
  if (isMobile(platform)) {
681
+ localizations.fields.push(
682
+ {
683
+ type: "text_input",
684
+ label: "Restrict playback on mobile networks alert title",
685
+ key: "mobile_connection_restricted_alert_title",
686
+ initial_value: "Restricted Connection Type",
687
+ },
688
+ {
689
+ type: "text_input",
690
+ label: "Restrict playback on mobile networks alert message",
691
+ key: "mobile_connection_restricted_alert_message",
692
+ initial_value:
693
+ "This content can only be viewed over a Wi-Fi or LAN network.",
694
+ }
695
+ );
696
+
681
697
  general.fields.push(
682
698
  {
683
699
  section: "Default Timestamp Type",
@@ -1200,40 +1216,35 @@ function getPlayerConfiguration({ platform, version }) {
1200
1216
  label: "Playback Speed 0.8x",
1201
1217
  type: "uploader",
1202
1218
  label_tooltip: "Playback Speed 0.8x",
1203
- initial_value:
1204
- "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAHgAAAB4CAYAAAA5ZDbSAAAACXBIWXMAACE4AAAhOAFFljFgAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAeMSURBVHgB7Z3/Vds6FMcvnPc/yQRVJyhM8MIEhQkaJihM8MIEwAQNE0AnwJ2g6QR1J4Au0D5dfHNqUuvqShbUcb+fc3R8Elm2oq9+3msrRAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAMjx0qyP39/cQfZj44H175wJ8ffPjuw4rDdDqtaSAE8st8oya/tc/viraYIgL7gpr5w3/UFFaMyodrX3BL+gOIqHMf3pItvzU1eT4fUuW00ktgX1jOHz6QraA2qX04fMlCk4rI+XWUx8Ln95y2iGyBpbBu6Fe3lgN33ye+0G7pmfH55R5mQf3hLvt4W1pzlsC+sPb94TOVg1tyRc9EQXHX1D4c+Dw/0MDZpUSkW76hstzIdYvjrzunuLgsVOXDUo515HxHzZxj8CQL7LkgfQyrfDj2wVfwKfcQUx9OSC807uY/0POgCfE4RPjw2ueVe5ETOb723x2SnudTGaYGTVIXLa1BE4JnmgslPcdpBV60q/b3O6Jwb1OTYZLnr3FHgUnk7u7ucm9v74QGTGoLfh+8kP+xmriMxF8pp5Tu9mZKnHXZw71R51j748ePIxo4ZoFlYrUfiK79j7UuHxYUKDDPrHC39ybw/YN1HS4TqY+B6ImsqwdLSgueK3HX1mWDFJjWil+iVdSURq3EjUbgf5W4JaVxqcS9pXKEeopiogx9PWwSWLqhUPdcpf5IacVVINoV7Pa+BL5P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DORNFp3vPThatrxDrCk56XWaeQaJ5ZHcC3irieX4tDosngxNSX4k3MEdtRYXHrN7jbgH3YQynTuGxGRNxva1BLaDn9nSHdlMfqniNtKU0TkZFOlXNRkf03gJJJZRzqd8WKgsBg1HDW9y5EEZ0hTGcVlgZaB6E5xmZhZ0682TENMli1auqRS7+RY3g9e5caLSZIrpDazToVb7qHx3Gzzoyay9amXbGeDiKw9BhOjpqZbXhrO5XNCBXE7jeyjIU9hcF77LsEqakSJttzWvWv6vYyi4rbSh0T+RAaSx+AuZMmiLX/acIbZaHKZYrGSMelm4x4Vxbv3zes4aiZOvK7dNyThPHIPcz3NfPOxtdUFH7mSJf32rmtYnSVFBG5lggtsRk93ramp8e/ysZr23LVGJk6P1532fNW0NcN39LTiPEhIfmsDAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAArCn66soQkXd6+EXu9muhKwlb+Z/AKYxaYNkl/TJy2mLb/hM4hdHuNtvaJT3GwrpfxzYyyhZs+BPNLo6nL/BH1S/NWAXmzVccpRHcBGabGV0XLdv7OkrH3W/B/wGnMsYx2PLW/nOkHSRjFLjP9k590g6SMQrcZzedkjvxDIIxCtxnD5Be+4cMEcyif4FZ9BaRsxPfKK1ZoxQ4YQvDNefGDdm2jrHbohcU3xv6bJr+f4Rbw9/iTVpQ8/8I63VuTb9226tpxPwPlwURv/dAZk0AAAAASUVORK5CYII=",
1219
+ initial_value: null,
1205
1220
  },
1206
1221
  {
1207
1222
  key: "speed_1",
1208
1223
  label: "Playback Speed 1x",
1209
1224
  type: "uploader",
1210
1225
  label_tooltip: "Playback Speed 1x",
1211
- initial_value:
1212
- "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAHgAAAB4CAYAAAA5ZDbSAAAACXBIWXMAACE4AAAhOAFFljFgAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAI4SURBVHgB7dzhcRJBGIDhT8cCkg6SDmIHsQNLiBUYKwAqUCtIC5ZACVqBdIAdxN3JMSLecXcE8Tt5npkdJlxyf97ZcLcLRAAAAAAAAAAAAAAAAAAAAAAAAADAMb2IiViv17fl4aGMq45fub68vFwFv3kVyZWwF+VhVsZ9MFrqwANmLT1SBm5mbQ37NniWl5FMifu+PHwPcY8izQwuYa/iadbeBkeTaQbfxf64P8r4GoyS7l90h89lXJfxLRgl+23Sqox35f52WX8o/8aDcTLP4EUZrzdxOUzGGbws40MJ6/X2CDIFrhdRNeyn4GjSBBb275jKVTQHEvg/d/aB69Lo+sljGR/jADvnmEUiZx242a2qr/0XzVP35bmHkeeY7Zxj3pw3hXOfwTctz90NjdzEnbccuo0kzj1w1712b+Q9cfed9+TOOnCzSrboONwZuSfuopz3SyRx9hdZJcY8RkQeELfr2D/hNimGR55a3Cr9m+5OpcZpdqvabnNq5HpBdtPx5ynjVmbwlp6ZPLm4lcA7eiLvSh23ErjFwMjp41YCd3t85vEUBG7Rc7W8Mc+27txG4B0D426kjyzwlp64y47nU0cWuDFgEeNNdF94pY0scAxfoeq5uk4Z2Yb/yOXHqUW24X/A2vKAyGk+OGfDv13vIsaBy5onZ8P/T4NXqPZEtuGfwdaG/yp+vfF+HiNsRV5tnSPNhv9kvoSlaj75f9F2zBewAAAAAAAAAAAAAAAAAAAAAAAAwHT8BNhH51wNSx95AAAAAElFTkSuQmCC",
1226
+ initial_value: null,
1213
1227
  },
1214
1228
  {
1215
1229
  key: "speed_1_2",
1216
1230
  label: "Playback Speed 1.2x",
1217
1231
  type: "uploader",
1218
1232
  label_tooltip: "Playback Speed 1.2x",
1219
- initial_value:
1220
- "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAHgAAAB4CAYAAAA5ZDbSAAAACXBIWXMAACE4AAAhOAFFljFgAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAUjSURBVHgB7d3bUeNIFAbgA7Xv2EUCmgiWjWBNBAwRYCKYdQQrIliIYEUEw0awymDIYDQBUFC8g+eccWsulPomteTu1v9VdZlSGyP0W1KrWxci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wGy6Vuo6qF9dTg1w6MR4eHireN3cNBwYLOcY1+MxQt5Khs661WF0/VJJZQbtrqPpquLyzvcm1h0pa1xwyjRlyjI0s29jnief0Sfl2P/r2XfuKMWDbeczRnvimdi9rTbX2ONch5N5f3hgDrgx1N8u4r/BbaaZbOzEsIRfUU3QBq0aMXEvUvKmS1m/s1+nWHdOce6gMIffeao3dyJJj10ZTp5v+beCcN0s17farsk9uHFqvFenPqAjFuPVQ813wjx/UJO+TBiRk/gz5Oxfq7w0a8AcAAAAAAAAAAAAAAAAAAAAAAAAAAAAAANif7B8Q/dOlJHI7iEJNvlcl+8tCsg5Y3R/Ldm1QuUz46aI2ud9lx+XCr1HubhOLLNdgh6eQdjn3uZNPKnIN+DP5XzQtl6ha77+Rmuw20eoOOgX5K4bcfSdWOe6Dh9yMJYobuYSUY8BDnj2Y1XMLRY4BD7lJS3LPJrTJMeAht1lK7tmENmhF/4BWdEI25C/L3qwsA1YdFj6BXcX0LOSQcu+LLvnF1g258b2XVUrmMppUcvmdfhznNlz+43Kd+2jSV0z9PFgMpokeAAAAAElFTkSuQmCC",
1233
+ initial_value: null,
1221
1234
  },
1222
1235
  {
1223
1236
  key: "speed_1_5",
1224
1237
  label: "Playback Speed 1.5x",
1225
1238
  type: "uploader",
1226
1239
  label_tooltip: "Playback Speed 1.5x",
1227
- initial_value:
1228
- "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAHgAAAB4CAYAAAA5ZDbSAAAACXBIWXMAACE4AAAhOAFFljFgAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAVySURBVHgB7Z2NVeQ2EMcHXgrYrSCmghwVxFdBuApuqSBQAaaCgwrgKoBUgFPBkQrOqQDSAGTmeZbbt2d9WmZl7f/3nvAi2bLX/5U8Gn2YCAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAID8OKDCeHp6WvBmQYlZLpcdzZBfaCL0Rv/JoR5K5xv2k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rkPIsYquItPkRyPV3jn54bsSgOTZkCch4gqhvutQchS4s6Q5rVgdLCddhqFt3yHEqPro245WC7wx5WVq53qIvKJIchT4OjLtDb5h0hd8fHBwcE9xiKDSNbgKdJLUhninEyPSrekkO4G1v3Xoi56HDGUVj9NisZCSLKM4pCT6CNXquY+WcTM1uoE4bw+VReRoB8vURlZNhuemSyyt7uSXK8/J+wh341CeH/R6NkuE5NtxaBOd44T6UZxy3VFdfmp4fdY8cpkWBAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEEiW60WmRKfAyBvaZEpJpdGPGi5Le0fDNkULrG9Edc3rkZeLBM3enxPFLoS2sbC2i2bsquo5U2QJ1gnToTPjP+m84qIoVWDbOh8mrOt/zJXiqmjbnGQHled6XLOixGdw9HIHI4/NkhIF9l7uN/GxWVKiwGOWYUixMk9WlCjwmBVhxxybJbCifwArekb4rna3SZHerCIFVodFiGCXy0JeJ7tN6b7ohtyvpDsveR2qfelNajj8Rj/auR2Hvzhcld6b9D8EYh6U+B0kAAAAAABJRU5ErkJggg==",
1240
+ initial_value: null,
1229
1241
  },
1230
1242
  {
1231
1243
  key: "speed_2",
1232
1244
  label: "Playback Speed 2x",
1233
1245
  type: "uploader",
1234
1246
  label_tooltip: "Playback Speed 2x",
1235
- initial_value:
1236
- "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAHgAAAB4CAYAAAA5ZDbSAAAACXBIWXMAACE4AAAhOAFFljFgAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAQnSURBVHgB7d2PUdRAFMfxh2MBUIGxArECjwqECjwqUCowV4FYgdABVCAdSAekg7ME35pFgnOb3ZDAvmy+n5lMGJLL3dzvkuyfZCMCAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA2LMnM7Hdbvd11p2ag4ODRtDLdMAa6kpnH3U61qkKrHbrp0sN/EbwiMmAfbBfdVrJMI1OZxr0leAvcwFruC7YWsY515DPBLYC1nC/6eyLTONC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tNKjHgMcMcPvfItS+uxIDHDHySfdCUqVGKfkApekZSn3jWVWRrVpEB+waLIYFtSh1mqfS26FriD9U4G/KUtLlZSm9SrdM7eajnNjpd63Reem/SH2FDq35f8ateAAAAAElFTkSuQmCC",
1247
+ initial_value: null,
1237
1248
  },
1238
1249
  {
1239
1250
  key: "sleep_timer",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@applicaster/zapp-react-native-utils",
3
- "version": "15.0.0-alpha.8680244503",
3
+ "version": "15.0.0-alpha.9300744523",
4
4
  "description": "Applicaster Zapp React Native utilities package",
5
5
  "main": "index.js",
6
6
  "types": "index.d.ts",
@@ -27,13 +27,13 @@
27
27
  },
28
28
  "homepage": "https://github.com/applicaster/quickbrick#readme",
29
29
  "dependencies": {
30
- "@applicaster/applicaster-types": "15.0.0-alpha.8680244503",
30
+ "@applicaster/applicaster-types": "15.0.0-alpha.9300744523",
31
31
  "buffer": "^5.2.1",
32
32
  "camelize": "^1.0.0",
33
33
  "dayjs": "^1.11.10",
34
+ "handlebars": "4.7.8",
34
35
  "memoizee": "0.4.15",
35
- "prop-types": "^15.0.0",
36
- "react-native-handlebars": "^5.0.0-alpha.1"
36
+ "prop-types": "^15.0.0"
37
37
  },
38
38
  "peerDependencies": {
39
39
  "@applicaster/zapp-pipes-v2-client": "*",
@@ -1,3 +1,34 @@
1
+ import React from "react";
2
+
3
+ import { WrappedWithProviders } from "@applicaster/zapp-react-native-utils/testUtils";
4
+
5
+ import {
6
+ getInflatedDataSourceUrl,
7
+ getSearchContext,
8
+ useGetUrlInflater,
9
+ } from "../useInflatedUrl";
10
+
11
+ import { reactHooksLogger } from "../../logger";
12
+
13
+ jest.mock("../../navigation", () => ({
14
+ useRoute: () => ({ pathname: "/mock/path" }),
15
+ }));
16
+
17
+ // mock contexts hooks
18
+ jest.mock("@applicaster/zapp-react-native-ui-components/Contexts", () => ({
19
+ ZappPipesEntryContext: {
20
+ useZappPipesContext: () => [
21
+ { id: "entry-1", extensions: { showId: "A123" } },
22
+ ],
23
+ },
24
+ ZappPipesSearchContext: {
25
+ useZappPipesContext: () => ["user%20query"],
26
+ },
27
+ ZappPipesScreenContext: {
28
+ useZappPipesContext: () => [{ id: "screen-1" }],
29
+ },
30
+ }));
31
+
1
32
  jest.mock("../../logger", () => ({
2
33
  reactHooksLogger: {
3
34
  warning: jest.fn(),
@@ -5,13 +36,6 @@ jest.mock("../../logger", () => ({
5
36
  },
6
37
  }));
7
38
 
8
- const {
9
- getInflatedDataSourceUrl,
10
- getSearchContext,
11
- } = require("../useInflatedUrl");
12
-
13
- const { reactHooksLogger } = require("../../logger");
14
-
15
39
  let mockStore;
16
40
 
17
41
  describe("getInflatedDataSourceUrl", () => {
@@ -188,3 +212,34 @@ describe("getSearchContext", () => {
188
212
  expect(result).toHaveProperty(mapping.queryParam.property, searchContext);
189
213
  });
190
214
  });
215
+
216
+ describe("useGetUrlInflater", () => {
217
+ const { renderHook } = require("@testing-library/react-hooks");
218
+
219
+ it("returns original url when mapping is not provided", () => {
220
+ const { result } = renderHook(() => useGetUrlInflater(), {
221
+ wrapper: WrappedWithProviders,
222
+ });
223
+
224
+ const src = "https://foo.com/feed";
225
+ expect(result.current(src)).toBe(src);
226
+ });
227
+
228
+ it("inflates url using entry/search/screen contexts when mapping provided", () => {
229
+ const { result } = renderHook(() => useGetUrlInflater(), {
230
+ wrapper: ({ children }) => (
231
+ <WrappedWithProviders>{children}</WrappedWithProviders>
232
+ ),
233
+ });
234
+
235
+ const source = "https://foo.com/shows/{{showId}}?q={{q}}";
236
+
237
+ const mapping = {
238
+ showId: { source: "entry", property: "extensions.showId" },
239
+ q: { source: "search", property: "q" },
240
+ };
241
+
242
+ const url = result.current(source, mapping);
243
+ expect(url).toBe("https://foo.com/shows/A123?q=user%20query");
244
+ });
245
+ });
@@ -1,4 +1,4 @@
1
- import { useMemo } from "react";
1
+ import { useCallback, useMemo, useRef } from "react";
2
2
  import * as R from "ramda";
3
3
 
4
4
  import {
@@ -169,7 +169,7 @@ const encodeIfNeeded: (string) => string = R.tryCatch(
169
169
 
170
170
  export function getSearchContext(
171
171
  searchContext: string,
172
- mapping: ZappTypeMapping
172
+ mapping: Nullable<ZappTypeMapping>
173
173
  ) {
174
174
  if (!mapping) {
175
175
  return {};
@@ -183,31 +183,57 @@ export function getSearchContext(
183
183
  return { [property]: encodeIfNeeded(searchContext) };
184
184
  }
185
185
 
186
- export function useInflatedUrl({
187
- feedUrl,
188
- mapping,
189
- }: {
190
- feedUrl?: string;
191
- mapping?: ZappTypeMapping;
192
- }) {
186
+ /**
187
+ * Hook returns a function that replace placeholders with context values
188
+ * @returns function that inflates urls based on contexts
189
+ */
190
+ export const useGetUrlInflater = () => {
193
191
  const { pathname } = useRoute();
194
192
 
195
193
  const [entryContext] = ZappPipesEntryContext.useZappPipesContext(pathname);
196
194
  const [searchContext] = ZappPipesSearchContext.useZappPipesContext();
197
195
  const [screenContext] = ZappPipesScreenContext.useZappPipesContext();
198
196
 
199
- const url = useMemo(
200
- () =>
201
- getInflatedDataSourceUrl({
197
+ const entryContextRef = useRef(entryContext);
198
+ entryContextRef.current = entryContext;
199
+
200
+ const screenContextRef = useRef(screenContext);
201
+ screenContextRef.current = screenContext;
202
+
203
+ const searchContextRef = useRef(searchContext);
204
+ searchContextRef.current = searchContext;
205
+
206
+ return useCallback(
207
+ (
208
+ feedUrl: Nullable<string>,
209
+ mapping?: Nullable<ZappTypeMapping>
210
+ ): Nullable<string> => {
211
+ return getInflatedDataSourceUrl({
202
212
  source: feedUrl,
203
213
  contexts: {
204
- entry: entryContext,
205
- screen: screenContext,
206
- search: getSearchContext(searchContext, mapping),
214
+ entry: entryContextRef.current,
215
+ screen: screenContextRef.current,
216
+ search: getSearchContext(searchContextRef.current, mapping),
207
217
  },
208
218
  mapping,
209
- }),
210
- [entryContext, feedUrl, mapping, screenContext, searchContext]
219
+ });
220
+ },
221
+ []
222
+ );
223
+ };
224
+
225
+ export function useInflatedUrl({
226
+ feedUrl,
227
+ mapping,
228
+ }: {
229
+ feedUrl?: string;
230
+ mapping?: ZappTypeMapping;
231
+ }) {
232
+ const urlInflater = useGetUrlInflater();
233
+
234
+ const url = useMemo(
235
+ () => urlInflater(feedUrl, mapping),
236
+ [urlInflater, feedUrl, mapping]
211
237
  );
212
238
 
213
239
  return url;
@@ -88,6 +88,10 @@ export function isNavBarVisible(
88
88
  if (route.startsWith("/hooks/")) {
89
89
  const module = screenData?.module;
90
90
 
91
+ if (module === undefined) {
92
+ return showNavBar;
93
+ }
94
+
91
95
  if (module?.presentFullScreen) {
92
96
  return false;
93
97
  }
@@ -2,7 +2,7 @@ import * as React from "react";
2
2
  import { Provider } from "react-redux";
3
3
  import { renderHook } from "@testing-library/react-hooks";
4
4
  import configureStore from "redux-mock-store";
5
- import thunk from "redux-thunk";
5
+ import { thunk } from "redux-thunk";
6
6
 
7
7
  const mockStore = configureStore([thunk]);
8
8
 
@@ -2,7 +2,7 @@ import * as React from "react";
2
2
  import { Provider } from "react-redux";
3
3
  import { renderHook } from "@testing-library/react-hooks";
4
4
  import configureStore from "redux-mock-store";
5
- import thunk from "redux-thunk";
5
+ import { thunk } from "redux-thunk";
6
6
 
7
7
  const mockStore = configureStore([thunk]);
8
8
 
@@ -0,0 +1,7 @@
1
+ export const FOCUSABLE_GROUP_ID = "search-screen";
2
+
3
+ export const FOCUSABLE_RESULTS_ID = "search-screen-results";
4
+
5
+ export const SEARCH_BOX_GROUP_ID = "search_box_group_id";
6
+
7
+ export const SEARCH_INPUT_FOCUSABLE_ID = "search_input_group_id";
@@ -0,0 +1,3 @@
1
+ import { SEARCH_INPUT_FOCUSABLE_ID } from "./const";
2
+
3
+ export const isSearchInputId = (id) => id === SEARCH_INPUT_FOCUSABLE_ID;
@@ -4,7 +4,7 @@ declare const global;
4
4
  import * as R from "ramda";
5
5
  import camelize from "camelize";
6
6
  // @ts-ignore
7
- import Handlebars from "react-native-handlebars";
7
+ import Handlebars from "handlebars";
8
8
 
9
9
  global.Buffer = global.Buffer || require("buffer").Buffer;
10
10
 
@@ -4,7 +4,7 @@ import React, { PropsWithChildren } from "react";
4
4
  import configureStore from "redux-mock-store";
5
5
  import { Provider } from "react-redux";
6
6
  import { View } from "react-native";
7
- import thunk from "redux-thunk";
7
+ import { thunk } from "redux-thunk";
8
8
  import * as R from "ramda";
9
9
 
10
10
  import { appStore } from "@applicaster/zapp-react-native-redux/AppStore";
@@ -0,0 +1,48 @@
1
+ import { mergeRight } from "../mergeRight";
2
+
3
+ describe("mergeRight", () => {
4
+ test("merges two objects with no overlapping keys", () => {
5
+ const a = { x: 1, y: 2 };
6
+ const b = { z: 3 };
7
+
8
+ const result = mergeRight(a, b);
9
+
10
+ expect(result).toEqual({ x: 1, y: 2, z: 3 });
11
+ });
12
+
13
+ test("overwrites keys from the second object", () => {
14
+ const a = { x: 1, y: 2 };
15
+ const b = { y: 10, z: 3 };
16
+
17
+ const result = mergeRight(a, b);
18
+
19
+ expect(result).toEqual({ x: 1, y: 10, z: 3 });
20
+ });
21
+
22
+ test("does not mutate the original objects", () => {
23
+ const a = { x: 1 };
24
+ const b = { y: 2 };
25
+
26
+ const result = mergeRight(a, b);
27
+
28
+ expect(result).not.toBe(a);
29
+ expect(result).not.toBe(b);
30
+ expect(a).toEqual({ x: 1 });
31
+ expect(b).toEqual({ y: 2 });
32
+ });
33
+
34
+ test("works with empty objects", () => {
35
+ expect(mergeRight({}, { a: 1 })).toEqual({ a: 1 });
36
+ expect(mergeRight({ a: 1 }, {})).toEqual({ a: 1 });
37
+ expect(mergeRight({}, {})).toEqual({});
38
+ });
39
+
40
+ test("works with nested objects (shallow merge only)", () => {
41
+ const a = { x: { nested: 1 }, y: 2 };
42
+ const b = { x: { nested: 10 }, z: 3 };
43
+
44
+ const result = mergeRight(a, b);
45
+
46
+ expect(result).toEqual({ x: { nested: 10 }, y: 2, z: 3 });
47
+ });
48
+ });
package/utils/index.ts CHANGED
@@ -18,6 +18,8 @@ export { take } from "./take";
18
18
 
19
19
  export { mapAccum } from "./mapAccum";
20
20
 
21
+ export { mergeRight } from "./mergeRight";
22
+
21
23
  export {
22
24
  cloneDeep as clone,
23
25
  flatten,
@@ -42,6 +44,14 @@ export {
42
44
  partial,
43
45
  clamp,
44
46
  reverse,
47
+ takeRight,
48
+ fromPairs,
49
+ sortBy,
50
+ merge,
51
+ values,
52
+ head,
53
+ findIndex,
45
54
  set,
46
55
  compact,
56
+ identity,
47
57
  } from "lodash";
@@ -0,0 +1,5 @@
1
+ import { assign } from "lodash";
2
+
3
+ export const mergeRight = (a, b) => {
4
+ return assign({}, a, b);
5
+ };
package/utils/path.ts CHANGED
@@ -1,5 +1,8 @@
1
- import { get } from "lodash";
1
+ import { pathOr } from "./pathOr";
2
2
 
3
- export const path = (route, record) => {
4
- return get(record, route, undefined);
3
+ export const path = <T = any>(
4
+ route: (string | number) | (string | number)[],
5
+ record: any
6
+ ) => {
7
+ return pathOr<T>(undefined, route, record);
5
8
  };