@applicaster/zapp-react-native-utils 13.0.0-alpha.3592913150 → 13.0.0-alpha.3637360334
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/README.md +0 -10
- package/actionsExecutor/ActionExecutorContext.tsx +93 -6
- package/analyticsUtils/currentScreenProperities.ts +6 -4
- package/appUtils/HooksManager/Hook.ts +2 -2
- package/appUtils/HooksManager/index.ts +1 -1
- package/appUtils/HooksManager/types.ts +2 -2
- package/appUtils/contextKeysManager/contextResolver.ts +7 -14
- 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 +11 -12
- package/appUtils/keyCodes/index.ts +11 -7
- package/appUtils/orientationHelper.ts +11 -13
- package/appUtils/platform/platformUtils.ts +30 -3
- package/appUtils/playerManager/index.ts +1 -1
- package/appUtils/playerManager/player.ts +26 -14
- package/appUtils/playerManager/playerNative.ts +18 -3
- package/equalUtils/__tests__/isEqual/combination.test.ts +263 -0
- package/equalUtils/index.ts +49 -30
- package/focusManager/FocusManager.ts +11 -1
- package/focusManager/index.ts +49 -4
- package/functionUtils/index.ts +21 -8
- package/idleUtils/__tests__/withTimeout$.test.ts +37 -0
- package/idleUtils/index.ts +1 -1
- package/idleUtils/withTimeout.ts +15 -2
- package/manifestUtils/__tests__/createConfig.test.js +0 -2
- package/manifestUtils/defaultManifestConfigurations/player.js +8 -0
- package/manifestUtils/fonts/index.js +5 -6
- package/manifestUtils/sharedConfiguration/screenPicker/stylesFields.js +1 -1
- package/navigationUtils/index.ts +3 -3
- package/numberUtils/index.ts +7 -5
- package/package.json +4 -10
- package/playerUtils/configurationGenerator.ts +8 -0
- package/reactHooks/autoscrolling/__tests__/useTrackedView.test.tsx +5 -7
- package/reactHooks/autoscrolling/useTrackedView.ts +12 -1
- package/reactHooks/feed/useFeedLoader.tsx +4 -2
- package/reactHooks/hookModal/hooks/useHookModalScreenData.ts +39 -0
- package/reactHooks/layout/useDimensions/helpers/__tests__/getInitialDimensions.test.js +1 -1
- package/reactHooks/layout/useDimensions/useDimensions.ts +8 -0
- package/reactHooks/navigation/__mocks__/useNavigation.ts +3 -0
- package/reactHooks/navigation/__tests__/index.test.tsx +6 -17
- package/reactHooks/navigation/index.ts +13 -23
- package/reactHooks/navigation/useGetTabBarHeight.ts +1 -3
- package/reactHooks/navigation/useProfilerLogging.ts +15 -0
- package/reactHooks/navigation/useRoute.ts +2 -4
- package/reactHooks/state/useRefWithInitialValue.ts +14 -0
- package/reactHooks/state/useStateFromSubscribe.ts +23 -0
- package/reactHooks/usePluginConfiguration.ts +1 -1
- package/reactHooks/useSubscriberFor.ts +4 -3
- package/reactUtils/__tests__/__snapshots__/reactUtilsHelpers.test.js.snap +16 -4
- package/reactUtils/__tests__/reactUtils.test.js +1 -19
- package/reactUtils/__tests__/reactUtilsHelpers.test.js +72 -71
- package/reactUtils/createContext/__tests__/__snapshots__/helpers.test.js.snap +6 -72
- package/reactUtils/createContext/__tests__/__snapshots__/provider.test.js.snap +3 -28
- package/reactUtils/createContext/__tests__/__snapshots__/withConsumer.test.js.snap +3 -4
- package/reactUtils/createContext/__tests__/__snapshots__/withProvider.test.js.snap +7 -3
- package/reactUtils/createContext/__tests__/helpers.test.js +107 -121
- package/reactUtils/createContext/__tests__/{index.test.js → index.test.ts} +2 -2
- package/reactUtils/createContext/__tests__/provider.test.js +4 -6
- package/reactUtils/createContext/__tests__/withConsumer.test.js +12 -12
- package/reactUtils/createContext/__tests__/withProvider.test.js +4 -4
- package/reactUtils/createContext/helpers.ts +6 -1
- package/reactUtils/createContext/index.ts +11 -25
- package/reactUtils/index.ts +0 -11
- package/screenState/index.ts +24 -10
- package/services/js2native.ts +673 -0
- package/testUtils/index.tsx +0 -10
- package/theme/index.ts +1 -1
- package/time/BackgroundTimer.ts +55 -0
- package/time/Timer.ts +9 -6
- package/types.ts +1 -0
- package/zappFrameworkUtils/loginPluginUtils.ts +6 -2
- package/zappFrameworkUtils/presentPluginOneTime.ts +2 -3
- package/reactUtils/createContext/__tests__/index-no-react.test.js +0 -27
- /package/reactUtils/createContext/__tests__/__snapshots__/{index.test.js.snap → index.test.ts.snap} +0 -0
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { DeviceEventEmitter, NativeModules } from "react-native";
|
|
2
|
+
import { platformSelect } from "../reactUtils";
|
|
3
|
+
|
|
4
|
+
const { BackgroundTimer: RNBackgroundTimer } = NativeModules;
|
|
5
|
+
|
|
6
|
+
class BackgroundTimer {
|
|
7
|
+
private uniqueId: number;
|
|
8
|
+
private readonly callbacks: Record<number, () => void>;
|
|
9
|
+
|
|
10
|
+
constructor() {
|
|
11
|
+
this.uniqueId = 0;
|
|
12
|
+
this.callbacks = {};
|
|
13
|
+
|
|
14
|
+
const EventEmitter = platformSelect({
|
|
15
|
+
android: DeviceEventEmitter,
|
|
16
|
+
ios: undefined,
|
|
17
|
+
default: undefined,
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
EventEmitter?.addListener("BackgroundTimer.timer.fired", (id: number) => {
|
|
21
|
+
if (this.callbacks[id]) {
|
|
22
|
+
const callback = this.callbacks[id];
|
|
23
|
+
delete this.callbacks[id];
|
|
24
|
+
callback();
|
|
25
|
+
}
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
setTimeout(callback, timeout): number | NodeJS.Timeout {
|
|
30
|
+
if (!RNBackgroundTimer) {
|
|
31
|
+
return global.setTimeout(callback, timeout);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
this.uniqueId += 1;
|
|
35
|
+
const timeoutId = this.uniqueId;
|
|
36
|
+
|
|
37
|
+
this.callbacks[timeoutId] = callback;
|
|
38
|
+
RNBackgroundTimer.setTimeout(timeoutId, timeout);
|
|
39
|
+
|
|
40
|
+
return timeoutId;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
clearTimeout(timeoutId: number | NodeJS.Timeout): void {
|
|
44
|
+
if (!RNBackgroundTimer) {
|
|
45
|
+
return global.clearTimeout(timeoutId as NodeJS.Timeout);
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
if (this.callbacks[timeoutId as number]) {
|
|
49
|
+
delete this.callbacks[timeoutId as number];
|
|
50
|
+
RNBackgroundTimer.clearTimeout(timeoutId);
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
export default new BackgroundTimer();
|
package/time/Timer.ts
CHANGED
|
@@ -1,16 +1,19 @@
|
|
|
1
|
+
import BackgroundTimer from "./BackgroundTimer";
|
|
2
|
+
|
|
1
3
|
export class Timer {
|
|
2
4
|
private startTime: number;
|
|
3
|
-
private
|
|
4
|
-
private timeoutId: NodeJS.Timeout | null;
|
|
5
|
+
private timeoutId: number | NodeJS.Timeout | null;
|
|
5
6
|
|
|
6
|
-
constructor(
|
|
7
|
-
|
|
7
|
+
constructor(
|
|
8
|
+
private callback: () => void,
|
|
9
|
+
private remaining: number = null
|
|
10
|
+
) {
|
|
8
11
|
this.timeoutId = null;
|
|
9
12
|
}
|
|
10
13
|
|
|
11
14
|
start(): void {
|
|
12
15
|
this.startTime = Date.now();
|
|
13
|
-
this.timeoutId = setTimeout(this.callback, this.remaining);
|
|
16
|
+
this.timeoutId = BackgroundTimer.setTimeout(this.callback, this.remaining);
|
|
14
17
|
|
|
15
18
|
this.remaining = 0;
|
|
16
19
|
}
|
|
@@ -26,6 +29,6 @@ export class Timer {
|
|
|
26
29
|
}
|
|
27
30
|
|
|
28
31
|
clear(): void {
|
|
29
|
-
clearTimeout(this.timeoutId);
|
|
32
|
+
BackgroundTimer.clearTimeout(this.timeoutId);
|
|
30
33
|
}
|
|
31
34
|
}
|
package/types.ts
CHANGED
|
@@ -89,11 +89,15 @@ const runInBackground = async ({
|
|
|
89
89
|
const shouldPresent = await hookPresentPolicy.shouldPresentScreen();
|
|
90
90
|
|
|
91
91
|
if (!shouldPresent) {
|
|
92
|
+
const isRefreshed = await checkUserAuthenticated();
|
|
93
|
+
|
|
92
94
|
log_info(
|
|
93
|
-
|
|
95
|
+
`runInBackground: Background mode finished, ${isRefreshed ? "finish hook with completion true" : "refresh failed will presentUI"}`
|
|
94
96
|
);
|
|
95
97
|
|
|
96
|
-
|
|
98
|
+
isRefreshed
|
|
99
|
+
? callback({ success: isRefreshed, payload: item })
|
|
100
|
+
: presentUI();
|
|
97
101
|
|
|
98
102
|
return;
|
|
99
103
|
}
|
|
@@ -92,9 +92,8 @@ export const PresentHookPluginOneTime = (
|
|
|
92
92
|
const presentOneTimeVersionName =
|
|
93
93
|
await getLatestWatchedVersionNumberFromStorage(storageKey, namespace);
|
|
94
94
|
|
|
95
|
-
const applicationVersionName =
|
|
96
|
-
versionNameKey
|
|
97
|
-
);
|
|
95
|
+
const applicationVersionName =
|
|
96
|
+
await sessionStorage.getItem(versionNameKey);
|
|
98
97
|
|
|
99
98
|
if (!presentOneTimeVersionName || !applicationVersionName) {
|
|
100
99
|
log_info(
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
jest.mock("create-react-context", () =>
|
|
2
|
-
jest.fn(() => ({
|
|
3
|
-
Consumer: jest.fn(),
|
|
4
|
-
Provider: jest.fn(),
|
|
5
|
-
}))
|
|
6
|
-
);
|
|
7
|
-
|
|
8
|
-
jest.mock("react", () => ({
|
|
9
|
-
...jest.requireActual("react"),
|
|
10
|
-
createContext: undefined,
|
|
11
|
-
}));
|
|
12
|
-
|
|
13
|
-
const { createContext } = require("../index");
|
|
14
|
-
const createReactContext = require("create-react-context");
|
|
15
|
-
|
|
16
|
-
describe("when react context api is not defined", () => {
|
|
17
|
-
it("uses the polyfill", () => {
|
|
18
|
-
createContext({ foo: "bar" });
|
|
19
|
-
|
|
20
|
-
expect(createReactContext).toHaveBeenCalledWith(
|
|
21
|
-
expect.objectContaining({
|
|
22
|
-
foo: "bar",
|
|
23
|
-
setFoo: expect.any(Function),
|
|
24
|
-
})
|
|
25
|
-
);
|
|
26
|
-
});
|
|
27
|
-
});
|
/package/reactUtils/createContext/__tests__/__snapshots__/{index.test.js.snap → index.test.ts.snap}
RENAMED
|
File without changes
|