@applicaster/zapp-react-native-utils 13.0.0-alpha.2000015251 → 13.0.0-alpha.2113353282
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/appUtils/contextKeysManager/index.ts +2 -2
- package/appUtils/contextKeysManager/utils/index.ts +2 -1
- package/appUtils/focusManager/__tests__/__snapshots__/focusManager.test.js.snap +1 -0
- package/appUtils/focusManager/index.ts +9 -0
- package/appUtils/platform/platformUtils.ts +6 -0
- package/equalUtils/index.ts +10 -3
- package/focusManager/FocusManager.ts +11 -1
- package/numberUtils/index.ts +5 -7
- package/package.json +2 -2
- package/reactHooks/navigation/index.ts +7 -19
- package/reactHooks/navigation/useProfilerLogging.ts +15 -0
|
@@ -16,12 +16,12 @@ import {
|
|
|
16
16
|
|
|
17
17
|
export { StorageLevel };
|
|
18
18
|
|
|
19
|
-
type KeyNameObj = {
|
|
19
|
+
export type KeyNameObj = {
|
|
20
20
|
namespace: string;
|
|
21
21
|
key: string;
|
|
22
22
|
};
|
|
23
23
|
|
|
24
|
-
type KeyName = string | KeyNameObj;
|
|
24
|
+
export type KeyName = string | KeyNameObj;
|
|
25
25
|
|
|
26
26
|
type ParsedKeyAndNamespace = {
|
|
27
27
|
namespace?: string;
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import * as R from "ramda";
|
|
2
2
|
import { DEFAULT_NAMESPACE } from "../consts";
|
|
3
|
+
import { KeyName, KeyNameObj } from "../index";
|
|
3
4
|
|
|
4
5
|
const lastDotRegex = /\.([^.]+)$/;
|
|
5
6
|
const splitByLastDot = R.compose(R.init, R.split(lastDotRegex));
|
|
6
7
|
|
|
7
|
-
export function getNamespaceAndKey(namespacedKey) {
|
|
8
|
+
export function getNamespaceAndKey(namespacedKey: KeyName): KeyNameObj {
|
|
8
9
|
if (typeof namespacedKey !== "string") return namespacedKey;
|
|
9
10
|
|
|
10
11
|
const namespacedKeyProps = namespacedKey.includes(".")
|
|
@@ -345,6 +345,14 @@ export const focusManager = (function () {
|
|
|
345
345
|
});
|
|
346
346
|
}
|
|
347
347
|
|
|
348
|
+
function pressIn() {
|
|
349
|
+
const currentFocusable = getCurrentFocus();
|
|
350
|
+
|
|
351
|
+
if (currentFocusable) {
|
|
352
|
+
currentFocusable.pressIn(null);
|
|
353
|
+
}
|
|
354
|
+
}
|
|
355
|
+
|
|
348
356
|
/**
|
|
349
357
|
* calls the `press` method on the current focus component
|
|
350
358
|
* @public
|
|
@@ -552,6 +560,7 @@ export const focusManager = (function () {
|
|
|
552
560
|
invokeHandler,
|
|
553
561
|
removeHandler,
|
|
554
562
|
longPress,
|
|
563
|
+
pressIn,
|
|
555
564
|
pressOut,
|
|
556
565
|
enableFocus,
|
|
557
566
|
setInitialFocus,
|
|
@@ -77,6 +77,12 @@ export class ClosedCaptioningManager {
|
|
|
77
77
|
|
|
78
78
|
private constructor() {
|
|
79
79
|
this.initialize();
|
|
80
|
+
|
|
81
|
+
window["vizioDebug"] = {
|
|
82
|
+
setCCEnabled: (isCCEnabled: boolean) => {
|
|
83
|
+
this.ccState$.next(isCCEnabled);
|
|
84
|
+
},
|
|
85
|
+
};
|
|
80
86
|
}
|
|
81
87
|
|
|
82
88
|
static getInstance(): ClosedCaptioningManager {
|
package/equalUtils/index.ts
CHANGED
|
@@ -49,9 +49,16 @@ export const isEqual =
|
|
|
49
49
|
}
|
|
50
50
|
|
|
51
51
|
if (compareRemainingKeysBySameValue) {
|
|
52
|
-
const
|
|
53
|
-
|
|
54
|
-
|
|
52
|
+
const allKeys = new Set([...Object.keys(prev), ...Object.keys(next)]);
|
|
53
|
+
|
|
54
|
+
const declaredKeys = new Set([
|
|
55
|
+
...byValue,
|
|
56
|
+
...byReference,
|
|
57
|
+
...byComparator.keys,
|
|
58
|
+
]);
|
|
59
|
+
|
|
60
|
+
const undeclaredKeys = Array.from(allKeys).filter(
|
|
61
|
+
(key) => !declaredKeys.has(key)
|
|
55
62
|
);
|
|
56
63
|
|
|
57
64
|
const isRestKeysEqualAllBySameValue = undeclaredKeys.every((key) =>
|
|
@@ -250,7 +250,17 @@ class FocusManager {
|
|
|
250
250
|
}
|
|
251
251
|
|
|
252
252
|
onDisableFocusChange = (id) => {
|
|
253
|
-
|
|
253
|
+
const isFocused = FocusManager.instance.isFocused(id);
|
|
254
|
+
|
|
255
|
+
const isDescendantFocused = (() => {
|
|
256
|
+
try {
|
|
257
|
+
return FocusManager.instance.isAnyDescendantFocused(id);
|
|
258
|
+
} catch (_e) {
|
|
259
|
+
return false;
|
|
260
|
+
}
|
|
261
|
+
})();
|
|
262
|
+
|
|
263
|
+
if (isFocused || isDescendantFocused) {
|
|
254
264
|
// Move focus to next one
|
|
255
265
|
const nextFocus = FocusManager.instance.focused?.props
|
|
256
266
|
?.nextFocusDown as string;
|
package/numberUtils/index.ts
CHANGED
|
@@ -3,7 +3,7 @@ import { logger } from "@applicaster/zapp-react-native-utils/logger";
|
|
|
3
3
|
|
|
4
4
|
const numberUtilsLogger = logger?.addSubsystem("NumberUtils");
|
|
5
5
|
|
|
6
|
-
export const toNumber = (value:
|
|
6
|
+
export const toNumber = (value: any): number | undefined => {
|
|
7
7
|
if (R.isNil(value) || R.isEmpty(value)) {
|
|
8
8
|
return undefined;
|
|
9
9
|
}
|
|
@@ -17,12 +17,10 @@ export const toNumber = (value: unknown): number | undefined => {
|
|
|
17
17
|
return undefined;
|
|
18
18
|
};
|
|
19
19
|
|
|
20
|
-
export const toNumberWithDefault = (
|
|
21
|
-
defaultValue
|
|
22
|
-
value: unknown
|
|
23
|
-
): number => toNumber(value) ?? defaultValue;
|
|
20
|
+
export const toNumberWithDefault = (defaultValue: number, value: any): number =>
|
|
21
|
+
toNumber(value) ?? defaultValue;
|
|
24
22
|
|
|
25
|
-
export const toNumberWithDefaultZero = (value:
|
|
23
|
+
export const toNumberWithDefaultZero = (value: any): number =>
|
|
26
24
|
toNumberWithDefault(0, value);
|
|
27
25
|
|
|
28
26
|
export const requireNumber = (obj, key: string) => {
|
|
@@ -41,7 +39,7 @@ export const requireNumber = (obj, key: string) => {
|
|
|
41
39
|
|
|
42
40
|
export const toFiniteNumberWithDefault = (
|
|
43
41
|
defaultValue: number,
|
|
44
|
-
value:
|
|
42
|
+
value: any
|
|
45
43
|
): number => {
|
|
46
44
|
const possibleNumber = toNumberWithDefault(defaultValue, value);
|
|
47
45
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@applicaster/zapp-react-native-utils",
|
|
3
|
-
"version": "13.0.0-alpha.
|
|
3
|
+
"version": "13.0.0-alpha.2113353282",
|
|
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": "13.0.0-alpha.
|
|
31
|
+
"@applicaster/applicaster-types": "13.0.0-alpha.2113353282",
|
|
32
32
|
"buffer": "^5.2.1",
|
|
33
33
|
"camelize": "^1.0.0",
|
|
34
34
|
"create-react-context": "^0.2.3",
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { BackHandler
|
|
1
|
+
import { useContext, useEffect, useMemo, useRef } from "react";
|
|
2
|
+
import { BackHandler } from "react-native";
|
|
3
3
|
|
|
4
4
|
import {
|
|
5
5
|
useContentTypes,
|
|
@@ -31,6 +31,8 @@ export { useGetBottomTabBarHeight } from "./useGetBottomTabBarHeight";
|
|
|
31
31
|
|
|
32
32
|
export { useIsScreenActive } from "./useIsScreenActive";
|
|
33
33
|
|
|
34
|
+
export { useProfilerLogging } from "./useProfilerLogging";
|
|
35
|
+
|
|
34
36
|
export {
|
|
35
37
|
useUniqueRouteSuffix,
|
|
36
38
|
useNavbarId,
|
|
@@ -121,10 +123,8 @@ export function isNavBarVisible(
|
|
|
121
123
|
return true;
|
|
122
124
|
}
|
|
123
125
|
|
|
124
|
-
const { ProfilerBridge } = NativeModules;
|
|
125
|
-
|
|
126
126
|
export const useBackHandler = (cb: () => boolean) => {
|
|
127
|
-
|
|
127
|
+
useEffect(() => {
|
|
128
128
|
BackHandler.addEventListener("hardwareBackPress", cb);
|
|
129
129
|
|
|
130
130
|
return () => {
|
|
@@ -158,7 +158,7 @@ export const useZappHooksForEntry = (
|
|
|
158
158
|
setIsHooksExecutionInProgress,
|
|
159
159
|
setIsPresentingFullScreen,
|
|
160
160
|
setIsRunningInBackground,
|
|
161
|
-
}: HookModalContextT =
|
|
161
|
+
}: HookModalContextT = useContext(ZappHookModalContext.ReactContext);
|
|
162
162
|
|
|
163
163
|
const {
|
|
164
164
|
appData: { layoutVersion },
|
|
@@ -256,22 +256,10 @@ export const useZappHooksForEntry = (
|
|
|
256
256
|
}, [entry.id]);
|
|
257
257
|
};
|
|
258
258
|
|
|
259
|
-
export const useProfilerLogging = () => {
|
|
260
|
-
const logTimestamp = (data: string) =>
|
|
261
|
-
InteractionManager.runAfterInteractions(() => {
|
|
262
|
-
if (ProfilerBridge && data) {
|
|
263
|
-
ProfilerBridge.updateTimer("navigation", data, Date.now());
|
|
264
|
-
}
|
|
265
|
-
});
|
|
266
|
-
|
|
267
|
-
return logTimestamp;
|
|
268
|
-
};
|
|
269
|
-
|
|
270
259
|
export const useRunIfLongPress = (
|
|
271
260
|
options = { timeout: LONG_KEY_PRESS_TIMEOUT }
|
|
272
261
|
) => {
|
|
273
|
-
const pressTimeout =
|
|
274
|
-
React.useRef<Nullable<ReturnType<typeof setTimeout>>>(null);
|
|
262
|
+
const pressTimeout = useRef<Nullable<ReturnType<typeof setTimeout>>>(null);
|
|
275
263
|
|
|
276
264
|
const resetTimeout = () => {
|
|
277
265
|
clearTimeout(pressTimeout.current as ReturnType<typeof setTimeout>);
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { useCallback } from "react";
|
|
2
|
+
import { InteractionManager, NativeModules } from "react-native";
|
|
3
|
+
|
|
4
|
+
const { ProfilerBridge } = NativeModules;
|
|
5
|
+
|
|
6
|
+
export const useProfilerLogging = () =>
|
|
7
|
+
useCallback(
|
|
8
|
+
(data: string) =>
|
|
9
|
+
InteractionManager.runAfterInteractions(() => {
|
|
10
|
+
if (ProfilerBridge && data) {
|
|
11
|
+
ProfilerBridge.updateTimer("navigation", data, Date.now());
|
|
12
|
+
}
|
|
13
|
+
}),
|
|
14
|
+
[]
|
|
15
|
+
);
|