@applicaster/zapp-react-native-utils 12.0.5-rc.5 → 13.0.0-alpha.1035032144
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/actionsExecutor/ActionExecutor.ts +16 -9
- package/actionsExecutor/ActionExecutorContext.tsx +74 -9
- package/alertUtils/alert.ts +148 -0
- package/alertUtils/index.ts +1 -148
- package/analyticsUtils/AnalyticPlayerListener.ts +18 -1
- package/analyticsUtils/__tests__/__snapshots__/analyticsManagerNoModule.test.js.snap +9 -9
- package/analyticsUtils/helpers/hooks.ts +1 -1
- package/appUtils/HooksManager/{Hook.js → Hook.ts} +35 -23
- package/appUtils/HooksManager/__tests__/__snapshots__/hook.test.js.snap +10 -8
- package/appUtils/HooksManager/__tests__/__snapshots__/hooksManager.test.js.snap +693 -0
- package/appUtils/HooksManager/__tests__/hook.test.js +196 -184
- package/appUtils/HooksManager/__tests__/hooksManager.test.js +96 -99
- package/appUtils/HooksManager/{constants.js → constants.ts} +1 -1
- package/appUtils/HooksManager/{index.js → index.ts} +121 -112
- package/appUtils/HooksManager/types.ts +119 -0
- package/appUtils/RiverFocusManager/index.js +17 -12
- package/appUtils/accessibilityManager/index.ts +1 -1
- package/appUtils/contextKeysManager/contextResolver.ts +77 -0
- package/appUtils/focusManager/__tests__/__snapshots__/focusManager.test.js.snap +6 -6
- package/appUtils/focusManager/treeDataStructure/Tree/index.js +2 -3
- package/appUtils/focusManager/treeDataStructure/Utils/index.js +1 -3
- package/appUtils/{index.js → index.ts} +1 -1
- package/appUtils/keyCodes/__tests__/__snapshots__/keyCodes.test.js.snap +2 -2
- package/appUtils/keyCodes/__tests__/keyCodes.test.js +4 -4
- package/appUtils/keyCodes/{index.js → index.ts} +2 -0
- package/appUtils/keyCodes/keys/index.ts +3 -0
- package/appUtils/keyCodes/{keys.android.js → keys/keyEventMapper.ts} +0 -19
- package/appUtils/keyCodes/keys/keys.android.ts +18 -0
- package/appUtils/keyCodes/keys/keys.ios.ts +25 -0
- package/appUtils/keyCodes/keys/keys.ts +15 -0
- package/appUtils/keyCodes/{keysByPlatform.js → keys/keysByPlatform.ts} +4 -0
- package/appUtils/keyCodes/keysByPlatform.ts +8 -0
- package/appUtils/keyInputHandler/KeyInputHandler.ts +68 -0
- package/appUtils/orientationHelper.ts +1 -1
- package/appUtils/platform/platformUtils.ts +6 -14
- package/appUtils/playerManager/player.ts +17 -5
- package/appUtils/playerManager/playerNative.ts +3 -2
- package/appUtils/playerManager/usePlayerControllerSetup.tsx +3 -3
- package/arrayUtils/__tests__/__snapshots__/arrayUtils.test.ts.snap +4 -4
- package/domUtils/{cookieManager.js → cookieManager.ts} +1 -2
- package/functionUtils/__tests__/__snapshots__/functionUtils.test.js.snap +4 -4
- package/functionUtils/index.ts +15 -11
- package/logger/const.ts +9 -67
- package/manifestUtils/__tests__/createConfig.test.js +16 -16
- package/modalState/index.ts +1 -5
- package/navigationUtils/__tests__/__snapshots__/navigationUtils.test.js.snap +6 -6
- package/navigationUtils/__tests__/itemTypes.test.js +2 -2
- package/navigationUtils/__tests__/navigationUtils.test.js +2 -2
- package/navigationUtils/index.ts +14 -5
- package/package.json +3 -2
- package/reactHooks/autoscrolling/__tests__/useTrackCurrentAutoScrollingElement.test.ts +1 -1
- package/reactHooks/autoscrolling/__tests__/useTrackedView.test.tsx +1 -1
- package/reactHooks/cell-click/__tests__/index.test.js +10 -2
- package/reactHooks/cell-click/index.ts +7 -1
- package/reactHooks/feed/__tests__/useBuildPipesUrl.test.tsx +4 -4
- package/reactHooks/feed/__tests__/useFeedLoader.test.tsx +10 -11
- package/reactHooks/feed/usePipesCacheReset.ts +5 -5
- package/reactHooks/flatList/__tests__/index.test.tsx +30 -21
- package/reactHooks/layout/__tests__/index.test.tsx +10 -10
- package/reactHooks/layout/useDimensions/helpers/__tests__/getInitialDimensions.native.test.js +14 -28
- package/reactHooks/layout/useDimensions/useDimensions.ts +8 -0
- package/reactHooks/navigation/__tests__/index.test.tsx +0 -4
- package/reactHooks/navigation/index.ts +29 -218
- package/reactHooks/navigation/useGetBottomTabBarHeight.ts +12 -0
- package/reactHooks/navigation/useGetNavBarTopBorderWidth.ts +14 -0
- package/reactHooks/navigation/useGetTabBarHeight.ts +12 -0
- package/reactHooks/navigation/useIsScreenActive.ts +17 -0
- package/reactHooks/navigation/useNavigationPluginData.ts +15 -0
- package/reactHooks/navigation/useNavigationType.ts +15 -0
- package/reactHooks/navigation/usePathname.ts +4 -0
- package/reactHooks/navigation/useRoute.ts +100 -0
- package/reactHooks/navigation/useUniqueRouteSuffix.ts +41 -0
- package/reactHooks/player/TVSeekControlller/ISeekController.ts +32 -0
- package/reactHooks/player/TVSeekControlller/LongPressSeekController.ts +71 -0
- package/reactHooks/player/TVSeekControlller/TVSeekController.ts +258 -0
- package/reactHooks/player/TVSeekControlller/TapSeekController.ts +53 -0
- package/reactHooks/player/__tests__/{useAutoSeek.test.tsx → useAutoSeek._test.tsx} +2 -3
- package/reactHooks/player/const.ts +0 -4
- package/reactHooks/player/index.ts +0 -6
- package/reactHooks/state/useStateFromSubscribe.ts +23 -0
- package/reactUtils/__tests__/reactUtils.test.js +10 -28
- package/reactUtils/createContext/__tests__/__snapshots__/helpers.test.js.snap +19 -19
- package/reactUtils/createContext/__tests__/__snapshots__/index.test.js.snap +2 -2
- package/reactUtils/createContext/__tests__/__snapshots__/provider.test.js.snap +3 -3
- package/reactUtils/createContext/__tests__/helpers.test.js +8 -8
- package/reactUtils/index.ts +0 -14
- package/screenState/index.ts +24 -10
- package/theme/__mocks__/index.ts +4 -0
- package/time/Timer.ts +1 -1
- package/types.ts +1 -0
- package/appUtils/keyCodes/keys.ios.js +0 -46
- package/reactHooks/player/useAutoSeek.tsx +0 -87
- package/reactHooks/player/useSeek.tsx +0 -66
- package/reactHooks/player/useTapSeek.tsx +0 -58
- /package/appUtils/HooksManager/{logger.js → logger.ts} +0 -0
- /package/appUtils/{directionHelper.js → directionHelper.ts} +0 -0
- /package/appUtils/keyCodes/{androidTVKeys.js → androidTVKeys.ts} +0 -0
- /package/appUtils/keyCodes/{keys.web.js → keys/keys.web.ts} +0 -0
- /package/appUtils/{localizationsHelper.js → localizationsHelper.ts} +0 -0
- /package/domUtils/{logger.js → logger.ts} +0 -0
- /package/reactHooks/player/__tests__/{useTapSeek.test.ts → useTapSeek._test.ts} +0 -0
|
@@ -5,6 +5,7 @@ import { createLogger, utilsLogger } from "../../logger";
|
|
|
5
5
|
import { getBoolFromConfigValue } from "../../configurationUtils";
|
|
6
6
|
import { PlayerRole, SharedPlayerCallBacksKeys } from "./conts";
|
|
7
7
|
import { OverlaysObserver } from "./OverlayObserver/OverlaysObserver";
|
|
8
|
+
import { TVSeekController } from "../../reactHooks/player/TVSeekControlller/TVSeekController";
|
|
8
9
|
|
|
9
10
|
const logger = createLogger({
|
|
10
11
|
category: "PlayerController",
|
|
@@ -49,6 +50,8 @@ export class Player {
|
|
|
49
50
|
[key: string]: QuickBrickPlayer.SharedPlayerCallBacks;
|
|
50
51
|
} = {};
|
|
51
52
|
|
|
53
|
+
public seekController?: TVSeekController | null;
|
|
54
|
+
|
|
52
55
|
get entry(): ZappEntry | null {
|
|
53
56
|
return this._entry;
|
|
54
57
|
}
|
|
@@ -59,6 +62,8 @@ export class Player {
|
|
|
59
62
|
}
|
|
60
63
|
|
|
61
64
|
constructor(props) {
|
|
65
|
+
this.seekController = null;
|
|
66
|
+
|
|
62
67
|
this.playerState = {
|
|
63
68
|
// We want isLive null by default to be able not to show controls if we do not know type
|
|
64
69
|
isLive: null,
|
|
@@ -91,6 +96,8 @@ export class Player {
|
|
|
91
96
|
this.onVideoProgress = this.onVideoProgress.bind(this);
|
|
92
97
|
this.onVideoLoad = this.onVideoLoad.bind(this);
|
|
93
98
|
this.isFullScreenSupported = this.isFullScreenSupported.bind(this);
|
|
99
|
+
this.onPlayerSeekComplete = this.onPlayerSeekComplete.bind(this);
|
|
100
|
+
|
|
94
101
|
this.entryObservable = null;
|
|
95
102
|
}
|
|
96
103
|
|
|
@@ -321,7 +328,7 @@ export class Player {
|
|
|
321
328
|
* You should use dispatchPlayerEvent at PlayerContainer or call playerManager.invokeHandler directly
|
|
322
329
|
* This allows you to use one method for everything.
|
|
323
330
|
*/
|
|
324
|
-
|
|
331
|
+
onPlayerSeekStart = (event: QuickBrickPlayer.OnSeekStartEvent) => {
|
|
325
332
|
const { isLive, seekableDuration, currentTime, duration, seekTime } = event;
|
|
326
333
|
|
|
327
334
|
this.setPlaybackState({ currentTime, duration, seekableDuration, isLive });
|
|
@@ -336,10 +343,11 @@ export class Player {
|
|
|
336
343
|
});
|
|
337
344
|
};
|
|
338
345
|
|
|
339
|
-
|
|
346
|
+
onPlayerSeekComplete = (event: QuickBrickPlayer.OnSeekCompleteEvent) => {
|
|
340
347
|
const { isLive, seekableDuration, currentTime, duration } = event;
|
|
341
348
|
|
|
342
349
|
this.setPlaybackState({ currentTime, duration, seekableDuration, isLive });
|
|
350
|
+
|
|
343
351
|
this.playerState.seekPosition = null;
|
|
344
352
|
|
|
345
353
|
if (!isLive) {
|
|
@@ -620,14 +628,18 @@ export class Player {
|
|
|
620
628
|
selectTrack = (_track) => {};
|
|
621
629
|
|
|
622
630
|
protected notifyPlayHeadPositionUpdate = () => {
|
|
631
|
+
const currentTime = this.getPosition();
|
|
632
|
+
|
|
623
633
|
const event = {
|
|
624
|
-
currentTime
|
|
634
|
+
currentTime,
|
|
625
635
|
duration: this.getDuration(),
|
|
626
636
|
item: this.getEntry(),
|
|
627
637
|
seekableDuration: this.playerState.seekableDuration,
|
|
628
638
|
isLive: this.isLive(),
|
|
629
639
|
};
|
|
630
640
|
|
|
641
|
+
this.seekController?.onVideoProgress(currentTime);
|
|
642
|
+
|
|
631
643
|
this.invokeListenersUpdate({
|
|
632
644
|
callbackName: SharedPlayerCallBacksKeys.OnVideoProgress,
|
|
633
645
|
event,
|
|
@@ -653,8 +665,8 @@ export class Player {
|
|
|
653
665
|
};
|
|
654
666
|
|
|
655
667
|
public getListener = (): QuickBrickPlayer.SharedPlayerCallBacks => ({
|
|
656
|
-
onPlayerSeekStart: this.
|
|
657
|
-
onPlayerSeekComplete: this.
|
|
668
|
+
onPlayerSeekStart: this.onPlayerSeekStart,
|
|
669
|
+
onPlayerSeekComplete: this.onPlayerSeekComplete,
|
|
658
670
|
onVideoEnd: this.onVideoEnd,
|
|
659
671
|
onError: this.onError,
|
|
660
672
|
onVideoError: this.onVideoError,
|
|
@@ -58,7 +58,7 @@ export class PlayerNative extends Player {
|
|
|
58
58
|
return this.playerState.contentPosition;
|
|
59
59
|
};
|
|
60
60
|
|
|
61
|
-
currentPlayerComponent = (): ReactComponent<
|
|
61
|
+
currentPlayerComponent = (): ReactComponent<PlayerRefProps> =>
|
|
62
62
|
this.playerComponent?.current;
|
|
63
63
|
|
|
64
64
|
getState = () => this.playerState;
|
|
@@ -222,9 +222,10 @@ export class PlayerNative extends Player {
|
|
|
222
222
|
|
|
223
223
|
onVideoLoad = (event) => {
|
|
224
224
|
if (this.startPosition) {
|
|
225
|
-
super.onVideoLoad({ ...event, ignoreContinueWatching: true });
|
|
226
225
|
this.seekTo(this.startPosition);
|
|
227
226
|
this.startPosition = null;
|
|
227
|
+
|
|
228
|
+
super.onVideoLoad({ ...event, ignoreContinueWatching: true });
|
|
228
229
|
} else {
|
|
229
230
|
super.onVideoLoad(event);
|
|
230
231
|
}
|
|
@@ -39,7 +39,7 @@ export const usePlayerControllerSetup = ({
|
|
|
39
39
|
? { supports_native_controls: true, ...config }
|
|
40
40
|
: config;
|
|
41
41
|
|
|
42
|
-
const
|
|
42
|
+
const combinedProps = {
|
|
43
43
|
player: ref,
|
|
44
44
|
listener: props as any,
|
|
45
45
|
config: newConfig,
|
|
@@ -47,9 +47,9 @@ export const usePlayerControllerSetup = ({
|
|
|
47
47
|
entry,
|
|
48
48
|
playerPluginId: pluginId,
|
|
49
49
|
playerRole: PlayerRole.Primary,
|
|
50
|
-
}
|
|
50
|
+
};
|
|
51
51
|
|
|
52
|
-
setPlayerController(
|
|
52
|
+
setPlayerController(new ControllerType(combinedProps));
|
|
53
53
|
}, [playerId, entry?.id]);
|
|
54
54
|
|
|
55
55
|
React.useEffect(() => {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
|
2
2
|
|
|
3
3
|
exports[`shiftArray shifts the n first items from the head to the tail of the array with a positive offset 1`] = `
|
|
4
|
-
|
|
4
|
+
[
|
|
5
5
|
"bar",
|
|
6
6
|
"baz",
|
|
7
7
|
42,
|
|
@@ -10,7 +10,7 @@ Array [
|
|
|
10
10
|
`;
|
|
11
11
|
|
|
12
12
|
exports[`shiftArray shifts the n first items from the head to the tail of the array with a positive offset 2`] = `
|
|
13
|
-
|
|
13
|
+
[
|
|
14
14
|
"baz",
|
|
15
15
|
42,
|
|
16
16
|
"foo",
|
|
@@ -19,7 +19,7 @@ Array [
|
|
|
19
19
|
`;
|
|
20
20
|
|
|
21
21
|
exports[`shiftArray shifts the n last items from the tail to the head of the array with a negative offset 1`] = `
|
|
22
|
-
|
|
22
|
+
[
|
|
23
23
|
42,
|
|
24
24
|
"foo",
|
|
25
25
|
"bar",
|
|
@@ -28,7 +28,7 @@ Array [
|
|
|
28
28
|
`;
|
|
29
29
|
|
|
30
30
|
exports[`shiftArray shifts the n last items from the tail to the head of the array with a negative offset 2`] = `
|
|
31
|
-
|
|
31
|
+
[
|
|
32
32
|
"baz",
|
|
33
33
|
42,
|
|
34
34
|
"foo",
|
|
@@ -2,7 +2,6 @@ import { domUtilsLogger } from "./logger";
|
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* Gets an object of cookies and sets them on the DOM.
|
|
5
|
-
* @param {Object} cookies selected data key for label.
|
|
6
5
|
*/
|
|
7
6
|
export function setCookies(cookies): void {
|
|
8
7
|
const cookieKeys = Object.keys(cookies);
|
|
@@ -25,7 +24,7 @@ export function setCookies(cookies): void {
|
|
|
25
24
|
/**
|
|
26
25
|
* Gets cookies set on DOM
|
|
27
26
|
*/
|
|
28
|
-
export function getCookies():
|
|
27
|
+
export function getCookies(): typeof document.cookie {
|
|
29
28
|
try {
|
|
30
29
|
if (document) {
|
|
31
30
|
return document.cookie;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
|
2
2
|
|
|
3
3
|
exports[`functionUtils subscriber can be invoked without args 1`] = `
|
|
4
|
-
|
|
5
|
-
"handlers":
|
|
4
|
+
{
|
|
5
|
+
"handlers": {},
|
|
6
6
|
"invokeHandler": [Function],
|
|
7
7
|
"on": [Function],
|
|
8
8
|
"removeHandler": [Function],
|
|
@@ -10,9 +10,9 @@ Object {
|
|
|
10
10
|
`;
|
|
11
11
|
|
|
12
12
|
exports[`functionUtils subscriber returns the original object with additional methods 1`] = `
|
|
13
|
-
|
|
13
|
+
{
|
|
14
14
|
"foo": "bar",
|
|
15
|
-
"handlers":
|
|
15
|
+
"handlers": {},
|
|
16
16
|
"invokeHandler": [Function],
|
|
17
17
|
"method": [Function],
|
|
18
18
|
"on": [Function],
|
package/functionUtils/index.ts
CHANGED
|
@@ -111,12 +111,12 @@ type SubscriberFn<T> = (
|
|
|
111
111
|
|
|
112
112
|
export type EventHandlerFn<T> = (event: string, ...args: unknown[]) => T;
|
|
113
113
|
|
|
114
|
-
type SubscriberObj =
|
|
115
|
-
on
|
|
116
|
-
invokeHandler: EventHandlerFn<SubscriberObj
|
|
117
|
-
removeHandler: EventHandlerFn<SubscriberObj
|
|
118
|
-
handlers: Record<string, SubscriberFn<SubscriberObj
|
|
119
|
-
}
|
|
114
|
+
export type SubscriberObj<T extends {} = {}> = {
|
|
115
|
+
on: SubscriberFn<SubscriberObj<T>>;
|
|
116
|
+
invokeHandler: EventHandlerFn<SubscriberObj<T>>;
|
|
117
|
+
removeHandler: EventHandlerFn<SubscriberObj<T>>;
|
|
118
|
+
handlers: Record<string, SubscriberFn<SubscriberObj<T>>[] | []>;
|
|
119
|
+
} & T;
|
|
120
120
|
|
|
121
121
|
export const clearObject = (object: { [key: string]: unknown }) =>
|
|
122
122
|
Object.keys(object).forEach((key) => delete object[key]);
|
|
@@ -126,7 +126,11 @@ export const clearObject = (object: { [key: string]: unknown }) =>
|
|
|
126
126
|
* @param {Object} obj to add the subscription feature on
|
|
127
127
|
* @returns {Object} subscriber object
|
|
128
128
|
*/
|
|
129
|
-
export function subscriber
|
|
129
|
+
export function subscriber<T extends Partial<SubscriberObj> = {}>(
|
|
130
|
+
_obj: T = {} as T
|
|
131
|
+
): SubscriberObj {
|
|
132
|
+
const obj: T = _obj;
|
|
133
|
+
|
|
130
134
|
if (!obj.handlers) {
|
|
131
135
|
obj.handlers = {};
|
|
132
136
|
}
|
|
@@ -172,7 +176,7 @@ export function subscriber(obj: SubscriberObj = {}): SubscriberObj {
|
|
|
172
176
|
| SubscriberFn<SubscriberObj>[]
|
|
173
177
|
| [];
|
|
174
178
|
|
|
175
|
-
return obj;
|
|
179
|
+
return obj as SubscriberObj;
|
|
176
180
|
};
|
|
177
181
|
|
|
178
182
|
/**
|
|
@@ -188,16 +192,16 @@ export function subscriber(obj: SubscriberObj = {}): SubscriberObj {
|
|
|
188
192
|
|
|
189
193
|
R.compose(R.forEach(callHandlerWithDispose), R.propOr([], event))(handlers);
|
|
190
194
|
|
|
191
|
-
return obj;
|
|
195
|
+
return obj as SubscriberObj;
|
|
192
196
|
};
|
|
193
197
|
|
|
194
198
|
obj.removeHandler = function (event, handler) {
|
|
195
199
|
handlers[event] = R.reject(R.equals(handler), handlers[event]);
|
|
196
200
|
|
|
197
|
-
return obj;
|
|
201
|
+
return obj as SubscriberObj;
|
|
198
202
|
};
|
|
199
203
|
|
|
200
|
-
return obj;
|
|
204
|
+
return obj as SubscriberObj;
|
|
201
205
|
}
|
|
202
206
|
|
|
203
207
|
/**
|
package/logger/const.ts
CHANGED
|
@@ -1,6 +1,3 @@
|
|
|
1
|
-
/* eslint-disable unused-imports/no-unused-vars */
|
|
2
|
-
import * as R from "ramda";
|
|
3
|
-
|
|
4
1
|
enum XRayLogLevel {
|
|
5
2
|
verbose = 0,
|
|
6
3
|
debug = 1,
|
|
@@ -11,51 +8,9 @@ enum XRayLogLevel {
|
|
|
11
8
|
off = 100,
|
|
12
9
|
}
|
|
13
10
|
|
|
14
|
-
|
|
15
|
-
off = "off",
|
|
16
|
-
verbose = "verbose",
|
|
17
|
-
debug = "debug",
|
|
18
|
-
info = "info",
|
|
19
|
-
warning = "warning",
|
|
20
|
-
error = "error",
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
const toastLevelToLogLevel = (toastLogLevel: ToastLogLevel): XRayLogLevel => {
|
|
24
|
-
if (R.isNil(toastLogLevel)) {
|
|
25
|
-
return XRayLogLevel.off;
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
switch (toastLogLevel) {
|
|
29
|
-
case ToastLogLevel.verbose:
|
|
30
|
-
return XRayLogLevel.verbose;
|
|
31
|
-
case ToastLogLevel.debug:
|
|
32
|
-
return XRayLogLevel.debug;
|
|
33
|
-
case ToastLogLevel.info:
|
|
34
|
-
return XRayLogLevel.info;
|
|
35
|
-
case ToastLogLevel.error:
|
|
36
|
-
return XRayLogLevel.error;
|
|
37
|
-
default:
|
|
38
|
-
return XRayLogLevel.off;
|
|
39
|
-
}
|
|
40
|
-
};
|
|
41
|
-
|
|
42
|
-
const PLUGIN_IDENTIFIER = "xray_logging_plugin";
|
|
43
|
-
|
|
44
|
-
const wrapInObject = (obj, name) => {};
|
|
45
|
-
|
|
46
|
-
const applyConditions = (wrappedObj) => {};
|
|
47
|
-
|
|
48
|
-
const sanitizeEventPayload = () => {};
|
|
11
|
+
const wrapInObject = (_ctx: unknown, _key: string) => {};
|
|
49
12
|
|
|
50
|
-
const
|
|
51
|
-
|
|
52
|
-
const isWeb = () => {};
|
|
53
|
-
|
|
54
|
-
const isDOMApp = () => {};
|
|
55
|
-
|
|
56
|
-
const isBrowser = () => {};
|
|
57
|
-
|
|
58
|
-
const eventAllowed = () => {};
|
|
13
|
+
const applyConditions = (_fn: unknown) => {};
|
|
59
14
|
|
|
60
15
|
/**
|
|
61
16
|
* This is the mocked version of XRayLogger
|
|
@@ -90,34 +45,21 @@ export default class XRayLogger {
|
|
|
90
45
|
);
|
|
91
46
|
};
|
|
92
47
|
|
|
93
|
-
log = (
|
|
94
|
-
const logEvent = typeof event === "string" ? { message: event } : event;
|
|
95
|
-
};
|
|
48
|
+
log = (_event) => {};
|
|
96
49
|
|
|
97
|
-
debug = (
|
|
98
|
-
const logEvent = typeof event === "string" ? { message: event } : event;
|
|
99
|
-
};
|
|
50
|
+
debug = (_event) => {};
|
|
100
51
|
|
|
101
|
-
info = (
|
|
102
|
-
const logEvent = typeof event === "string" ? { message: event } : event;
|
|
103
|
-
};
|
|
52
|
+
info = (_event) => {};
|
|
104
53
|
|
|
105
|
-
warning = (
|
|
106
|
-
const logEvent = typeof event === "string" ? { message: event } : event;
|
|
107
|
-
};
|
|
54
|
+
warning = (_event) => {};
|
|
108
55
|
|
|
109
|
-
warn = (
|
|
56
|
+
warn = (_event) => {
|
|
110
57
|
this.warning(event);
|
|
111
58
|
};
|
|
112
59
|
|
|
113
|
-
error = (
|
|
114
|
-
const logEvent: XRayEventData =
|
|
115
|
-
event instanceof Error
|
|
116
|
-
? { exception: event as Error, message: event.message }
|
|
117
|
-
: (event as XRayEventData);
|
|
118
|
-
};
|
|
60
|
+
error = (_event) => {};
|
|
119
61
|
|
|
120
|
-
sendEvent = (
|
|
62
|
+
sendEvent = (_event, _eventData) => {};
|
|
121
63
|
|
|
122
64
|
// To be used by QuickBrick Hook events
|
|
123
65
|
sendAudienceEvent = (event, eventData = null) => {
|
|
@@ -1,11 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
const styles = {
|
|
1
|
+
const mockStyles = {
|
|
4
2
|
fields: [{ key: "field_1", initial_value: 1 }],
|
|
5
3
|
label: "styles",
|
|
6
4
|
};
|
|
7
5
|
|
|
8
|
-
const
|
|
6
|
+
const mockStylesWithGroup = {
|
|
9
7
|
fields: [
|
|
10
8
|
{
|
|
11
9
|
group: true,
|
|
@@ -15,26 +13,28 @@ const stylesWithGroup = {
|
|
|
15
13
|
],
|
|
16
14
|
};
|
|
17
15
|
|
|
18
|
-
const
|
|
19
|
-
styles: jest.fn(() => ({ styles })),
|
|
16
|
+
const mockGenerators = {
|
|
17
|
+
styles: jest.fn(() => ({ styles: mockStyles })),
|
|
20
18
|
stylesGroup: jest.fn(() => ({
|
|
21
|
-
styles:
|
|
19
|
+
styles: mockStylesWithGroup,
|
|
22
20
|
})),
|
|
23
|
-
customConfiguration: jest.fn(() => ({ custom_configuration: [
|
|
21
|
+
customConfiguration: jest.fn(() => ({ custom_configuration: [mockStyles] })),
|
|
24
22
|
customConfigurationGroup: jest.fn(() => ({
|
|
25
|
-
custom_configuration: [
|
|
23
|
+
custom_configuration: [mockStylesWithGroup],
|
|
26
24
|
})),
|
|
27
25
|
};
|
|
28
26
|
|
|
29
|
-
jest.
|
|
27
|
+
jest.doMock("../defaultManifestConfigurations", () => ({
|
|
30
28
|
defaultConfigurations: {
|
|
31
|
-
styles:
|
|
32
|
-
stylesGroup:
|
|
33
|
-
customConfiguration:
|
|
34
|
-
customConfigurationGroup:
|
|
29
|
+
styles: mockGenerators.styles,
|
|
30
|
+
stylesGroup: mockGenerators.stylesGroup,
|
|
31
|
+
customConfiguration: mockGenerators.customConfiguration,
|
|
32
|
+
customConfigurationGroup: mockGenerators.customConfigurationGroup,
|
|
35
33
|
},
|
|
36
34
|
}));
|
|
37
35
|
|
|
36
|
+
const { createConfig } = require("../createConfig");
|
|
37
|
+
|
|
38
38
|
describe("createConfig", () => {
|
|
39
39
|
it("should return a function", () => {
|
|
40
40
|
const currentResult = createConfig(jest.fn());
|
|
@@ -78,7 +78,7 @@ describe("createConfig", () => {
|
|
|
78
78
|
extend: "styles",
|
|
79
79
|
})(props);
|
|
80
80
|
|
|
81
|
-
expect(
|
|
81
|
+
expect(mockGenerators.styles).toBeCalledWith(props);
|
|
82
82
|
});
|
|
83
83
|
|
|
84
84
|
it("should return base configuration if manifest is not provided", () => {
|
|
@@ -88,7 +88,7 @@ describe("createConfig", () => {
|
|
|
88
88
|
extend: "styles",
|
|
89
89
|
})({});
|
|
90
90
|
|
|
91
|
-
expect(currentResult).toEqual({ styles });
|
|
91
|
+
expect(currentResult).toEqual({ styles: mockStyles });
|
|
92
92
|
});
|
|
93
93
|
|
|
94
94
|
describe("Data merging", () => {
|
package/modalState/index.ts
CHANGED
|
@@ -31,11 +31,7 @@ export const useModalStore = create<ModalStore>((set) => ({
|
|
|
31
31
|
set((state) => ({
|
|
32
32
|
modalState: { ...state.modalState, ...newState },
|
|
33
33
|
})),
|
|
34
|
-
openModal: ({
|
|
35
|
-
item,
|
|
36
|
-
options = {},
|
|
37
|
-
props = { screenData: {} },
|
|
38
|
-
}: OpenModalArg) =>
|
|
34
|
+
openModal: ({ item, options = {}, props }: OpenModalArg) =>
|
|
39
35
|
set({
|
|
40
36
|
modalState: {
|
|
41
37
|
visible: true,
|
|
@@ -1,19 +1,19 @@
|
|
|
1
1
|
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
|
2
2
|
|
|
3
3
|
exports[`getNavigationProps returns the props otherwise 1`] = `
|
|
4
|
-
|
|
5
|
-
"assets":
|
|
4
|
+
{
|
|
5
|
+
"assets": {
|
|
6
6
|
"appLogo": "appLogo.png",
|
|
7
7
|
},
|
|
8
8
|
"home": false,
|
|
9
|
-
"nav_items":
|
|
10
|
-
|
|
9
|
+
"nav_items": [
|
|
10
|
+
{
|
|
11
11
|
"type": "label",
|
|
12
12
|
},
|
|
13
13
|
],
|
|
14
|
-
"rules":
|
|
14
|
+
"rules": {},
|
|
15
15
|
"selected": "A1234",
|
|
16
|
-
"styles":
|
|
16
|
+
"styles": {
|
|
17
17
|
"style": "foo",
|
|
18
18
|
},
|
|
19
19
|
"title": "testTitle",
|
|
@@ -61,8 +61,8 @@ describe("getTypeMatcher", () => {
|
|
|
61
61
|
|
|
62
62
|
describe("isItemOfType", () => {
|
|
63
63
|
it("is a curried function", () => {
|
|
64
|
-
expect(itemIsOfType(river, SCREEN_TYPES.RIVER)).
|
|
65
|
-
expect(itemIsOfType(river)).
|
|
64
|
+
expect(itemIsOfType(river, SCREEN_TYPES.RIVER)).toBeTruthy();
|
|
65
|
+
expect(itemIsOfType(river)).toBeInstanceOf(Function);
|
|
66
66
|
});
|
|
67
67
|
|
|
68
68
|
it("returns true if the item is of the given type", () => {
|
|
@@ -243,7 +243,7 @@ describe("getTargetRoute", () => {
|
|
|
243
243
|
it("returns a valid path when initial pathname is /", () => {
|
|
244
244
|
const targetRoute = getTargetRoute(river, "/", { layoutVersion });
|
|
245
245
|
expect(targetRoute).toEqual(`/river/${river.id}`);
|
|
246
|
-
expect(targetRoute).not.
|
|
246
|
+
expect(targetRoute).not.toContainEntry("//");
|
|
247
247
|
});
|
|
248
248
|
});
|
|
249
249
|
|
|
@@ -273,7 +273,7 @@ describe("getTargetRoute", () => {
|
|
|
273
273
|
it("returns a valid path when initial pathname is /", () => {
|
|
274
274
|
const targetRoute = getTargetRoute(river, "/", { layoutVersion });
|
|
275
275
|
expect(targetRoute).toEqual(`/river/${river.id}`);
|
|
276
|
-
expect(targetRoute).not.
|
|
276
|
+
expect(targetRoute).not.toContainEntry("//");
|
|
277
277
|
});
|
|
278
278
|
});
|
|
279
279
|
});
|
package/navigationUtils/index.ts
CHANGED
|
@@ -324,7 +324,13 @@ export function getPathAttributes({
|
|
|
324
324
|
* @param {object} rivers
|
|
325
325
|
* @returns {object}
|
|
326
326
|
*/
|
|
327
|
-
export function getRiverFromRoute({
|
|
327
|
+
export function getRiverFromRoute({
|
|
328
|
+
route,
|
|
329
|
+
rivers,
|
|
330
|
+
}: {
|
|
331
|
+
route: string;
|
|
332
|
+
rivers: Record<string, ZappRiver>;
|
|
333
|
+
}) {
|
|
328
334
|
if (!route) {
|
|
329
335
|
return null;
|
|
330
336
|
}
|
|
@@ -437,7 +443,7 @@ export const runZappHooksForEntry = async (
|
|
|
437
443
|
|
|
438
444
|
let success;
|
|
439
445
|
let payload;
|
|
440
|
-
const rivers = appStore.get("rivers");
|
|
446
|
+
const rivers: Record<string, ZappRiver> = appStore.get("rivers");
|
|
441
447
|
const plugins = appStore.get("plugins");
|
|
442
448
|
const appData = appStore.get("appData");
|
|
443
449
|
|
|
@@ -492,13 +498,16 @@ export const runZappHooksForEntry = async (
|
|
|
492
498
|
payload = _payload;
|
|
493
499
|
};
|
|
494
500
|
|
|
495
|
-
HooksManager(hooksOptions)
|
|
501
|
+
const hooksManager = HooksManager(hooksOptions);
|
|
502
|
+
|
|
503
|
+
hooksManager.subscriber
|
|
496
504
|
.on(HOOKS_EVENTS.PRESENT_SCREEN_HOOK, handleHookPresent)
|
|
497
505
|
.on(HOOKS_EVENTS.START_BACKGROUND_HOOK, handleBackgroundHook)
|
|
498
506
|
.on(HOOKS_EVENTS.ERROR, onFinished(false))
|
|
499
507
|
.on(HOOKS_EVENTS.CANCEL, onFinished(false))
|
|
500
|
-
.on(HOOKS_EVENTS.COMPLETE, onFinished(true))
|
|
501
|
-
|
|
508
|
+
.on(HOOKS_EVENTS.COMPLETE, onFinished(true));
|
|
509
|
+
|
|
510
|
+
hooksManager.handleHooks(entry);
|
|
502
511
|
|
|
503
512
|
// eslint-disable-next-line no-unmodified-loop-condition
|
|
504
513
|
while (success === undefined) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@applicaster/zapp-react-native-utils",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "13.0.0-alpha.1035032144",
|
|
4
4
|
"description": "Applicaster Zapp React Native utilities package",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"types": "index.d.ts",
|
|
@@ -28,7 +28,7 @@
|
|
|
28
28
|
},
|
|
29
29
|
"homepage": "https://github.com/applicaster/quickbrick#readme",
|
|
30
30
|
"dependencies": {
|
|
31
|
-
"@applicaster/applicaster-types": "
|
|
31
|
+
"@applicaster/applicaster-types": "13.0.0-alpha.1035032144",
|
|
32
32
|
"buffer": "^5.2.1",
|
|
33
33
|
"camelize": "^1.0.0",
|
|
34
34
|
"create-react-context": "^0.2.3",
|
|
@@ -44,6 +44,7 @@
|
|
|
44
44
|
"immer": "*",
|
|
45
45
|
"react": "17.0.2",
|
|
46
46
|
"react-native": "0.68.6",
|
|
47
|
+
"uglify-js": "*",
|
|
47
48
|
"validate-color": "*",
|
|
48
49
|
"zustand": "*"
|
|
49
50
|
},
|
|
@@ -5,14 +5,14 @@ import { ActionExecutorContext } from "@applicaster/zapp-react-native-utils/acti
|
|
|
5
5
|
|
|
6
6
|
import { waitFor } from "@testing-library/react-native";
|
|
7
7
|
|
|
8
|
-
const
|
|
8
|
+
const mockNavigator = {
|
|
9
9
|
getPathname: () => "pathnameMock",
|
|
10
10
|
push: jest.fn(),
|
|
11
11
|
data: {},
|
|
12
12
|
};
|
|
13
13
|
|
|
14
14
|
jest.mock("@applicaster/zapp-react-native-utils/reactHooks/navigation", () => ({
|
|
15
|
-
useNavigation: () =>
|
|
15
|
+
useNavigation: () => mockNavigator,
|
|
16
16
|
useRoute: () => ({ pathname: "pathnameMock" }),
|
|
17
17
|
useProfilerLogging: () => {
|
|
18
18
|
return jest.fn();
|
|
@@ -25,7 +25,15 @@ jest.mock("@applicaster/zapp-react-native-utils/analyticsUtils/", () => ({
|
|
|
25
25
|
}),
|
|
26
26
|
}));
|
|
27
27
|
|
|
28
|
+
jest.mock("@applicaster/zapp-react-native-utils/reactHooks/screen", () => ({
|
|
29
|
+
useTargetScreenData: jest.fn(() => ({})),
|
|
30
|
+
useCurrentScreenData: jest.fn(() => ({})),
|
|
31
|
+
}));
|
|
32
|
+
|
|
28
33
|
jest.mock("@applicaster/zapp-react-native-ui-components/Contexts", () => ({
|
|
34
|
+
...jest.requireActual(
|
|
35
|
+
"@applicaster/zapp-react-native-ui-components/Contexts"
|
|
36
|
+
),
|
|
29
37
|
ZappPipesEntryContext: {
|
|
30
38
|
useZappPipesContext: jest.fn(() => [undefined, jest.fn()]),
|
|
31
39
|
},
|
|
@@ -16,6 +16,7 @@ import { ActionExecutorContext } from "@applicaster/zapp-react-native-utils/acti
|
|
|
16
16
|
import { isFunction, noop } from "../../functionUtils";
|
|
17
17
|
import { useSendAnalyticsOnPress } from "../analytics";
|
|
18
18
|
import { logOnPress, warnEmptyContentType } from "./helpers";
|
|
19
|
+
import { useCurrentScreenData } from "../screen";
|
|
19
20
|
|
|
20
21
|
/**
|
|
21
22
|
* If onCellTap is defined execute the function and
|
|
@@ -44,6 +45,7 @@ export const useCellClick = ({
|
|
|
44
45
|
|
|
45
46
|
const onCellTap: Option<Function> = React.useContext(CellTapContext);
|
|
46
47
|
const actionExecutor = React.useContext(ActionExecutorContext);
|
|
48
|
+
const screenData = useCurrentScreenData();
|
|
47
49
|
|
|
48
50
|
const cellSelectable = toBooleanWithDefaultTrue(
|
|
49
51
|
component?.rules?.component_cells_selectable
|
|
@@ -78,7 +80,10 @@ export const useCellClick = ({
|
|
|
78
80
|
logOnPress(selectedItem, pathname, component, onCellTap);
|
|
79
81
|
|
|
80
82
|
if (selectedItem) {
|
|
81
|
-
await actionExecutor?.handleEntryActions(selectedItem
|
|
83
|
+
await actionExecutor?.handleEntryActions(selectedItem, {
|
|
84
|
+
component,
|
|
85
|
+
screenData,
|
|
86
|
+
});
|
|
82
87
|
}
|
|
83
88
|
|
|
84
89
|
if (selectedItem?.type?.value === "action") {
|
|
@@ -111,6 +116,7 @@ export const useCellClick = ({
|
|
|
111
116
|
pathname,
|
|
112
117
|
push,
|
|
113
118
|
sendAnalyticsOnPress,
|
|
119
|
+
screenData,
|
|
114
120
|
]
|
|
115
121
|
);
|
|
116
122
|
|