@applicaster/zapp-react-native-utils 13.0.0-alpha.5004843012 → 13.0.0-alpha.5112402674
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/HooksManager/Hook.ts +2 -2
- package/appUtils/HooksManager/types.ts +2 -2
- package/appUtils/contextKeysManager/contextResolver.ts +2 -6
- package/appUtils/focusManager/index.ts +3 -2
- package/appUtils/playerManager/player.ts +2 -2
- package/idleUtils/index.ts +1 -1
- package/idleUtils/withTimeout.ts +2 -15
- package/manifestUtils/__tests__/createConfig.test.js +2 -0
- package/manifestUtils/sharedConfiguration/screenPicker/__tests__/utils.test.js +304 -0
- package/manifestUtils/sharedConfiguration/screenPicker/stylesFields.js +875 -0
- package/manifestUtils/sharedConfiguration/screenPicker/utils.js +130 -0
- package/navigationUtils/index.ts +3 -3
- package/package.json +2 -2
- package/reactHooks/layout/useDimensions/helpers/__tests__/getInitialDimensions.test.js +1 -1
- package/reactHooks/usePluginConfiguration.ts +1 -1
- package/reactHooks/useSubscriberFor.ts +3 -4
- package/screenState/index.ts +10 -24
- package/theme/index.ts +1 -1
- package/time/Timer.ts +1 -4
- package/types.ts +0 -1
- package/zappFrameworkUtils/presentPluginOneTime.ts +3 -2
- package/idleUtils/__tests__/withTimeout$.test.ts +0 -37
- package/reactHooks/state/useRefWithInitialValue.ts +0 -14
- package/reactHooks/state/useStateFromSubscribe.ts +0 -23
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
const defaultPlatforms = {
|
|
2
|
+
tvos: "tvOS",
|
|
3
|
+
android_tv: "Android TV",
|
|
4
|
+
lg_tv: "LG TV",
|
|
5
|
+
samsung_tv: "Samsung TV",
|
|
6
|
+
};
|
|
7
|
+
|
|
8
|
+
const global_defaults = {
|
|
9
|
+
fontSize: 20,
|
|
10
|
+
lineHeight: 40,
|
|
11
|
+
letterSpacing: 0.4,
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
const generateFontConfiguration = (platforms = defaultPlatforms) => {
|
|
15
|
+
const platformEntries = Object.entries(platforms);
|
|
16
|
+
const defaultsEntries = Object.entries(global_defaults);
|
|
17
|
+
const splitCamelCase = (str) => str.replace(/([a-z](?=[A-Z]))/g, "$1_");
|
|
18
|
+
|
|
19
|
+
return platformEntries.reduce((acc, [platformKey, platformValue]) => {
|
|
20
|
+
acc.push(
|
|
21
|
+
...defaultsEntries.reduce((acc2, [valueKey, defaultValue]) => {
|
|
22
|
+
acc2.push({
|
|
23
|
+
type: "number_input",
|
|
24
|
+
label: `${platformValue} ${splitCamelCase(valueKey).replace(
|
|
25
|
+
"_",
|
|
26
|
+
" "
|
|
27
|
+
)}`,
|
|
28
|
+
key: `${platformKey}_${splitCamelCase(valueKey)}`.toLowerCase(),
|
|
29
|
+
initial_value: defaultValue,
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
return acc2;
|
|
33
|
+
}, [])
|
|
34
|
+
);
|
|
35
|
+
|
|
36
|
+
return acc;
|
|
37
|
+
}, []);
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
const conditional_rule = (key, condition_value) => ({
|
|
41
|
+
key,
|
|
42
|
+
condition_value,
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
const createConditionalConfig = (rules, matchAll = false) => ({
|
|
46
|
+
rules: matchAll ? "all_conditions" : "conditional",
|
|
47
|
+
conditional_fields: rules.map((field) => conditional_rule(...field)),
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
const conditional_horizontal_type = createConditionalConfig([
|
|
51
|
+
["styles/screen_picker_type", "horizontal"],
|
|
52
|
+
]);
|
|
53
|
+
|
|
54
|
+
const conditional_vertical_type = createConditionalConfig([
|
|
55
|
+
["styles/screen_picker_type", "vertical"],
|
|
56
|
+
]);
|
|
57
|
+
|
|
58
|
+
const conditional_horizontal_type_item_fixed = createConditionalConfig(
|
|
59
|
+
[
|
|
60
|
+
["styles/screen_picker_type", "horizontal"],
|
|
61
|
+
["styles/screen_picker_item_size", "fixed"],
|
|
62
|
+
],
|
|
63
|
+
true
|
|
64
|
+
);
|
|
65
|
+
|
|
66
|
+
const conditional_horizontal_type_item_dynamic = createConditionalConfig(
|
|
67
|
+
[
|
|
68
|
+
["styles/screen_picker_type", "horizontal"],
|
|
69
|
+
["screen_picker_horizontal_display_type", "dynamic"],
|
|
70
|
+
],
|
|
71
|
+
true
|
|
72
|
+
);
|
|
73
|
+
|
|
74
|
+
const conditional_horizontal_display_type_fixed = createConditionalConfig(
|
|
75
|
+
[
|
|
76
|
+
["styles/screen_picker_type", "horizontal"],
|
|
77
|
+
["styles/screen_picker_horizontal_display_type", "fixed"],
|
|
78
|
+
],
|
|
79
|
+
true
|
|
80
|
+
);
|
|
81
|
+
|
|
82
|
+
const conditional_horizontal_asset_on = createConditionalConfig(
|
|
83
|
+
[
|
|
84
|
+
["styles/screen_picker_type", "horizontal"],
|
|
85
|
+
["styles/screen_picker_asset_switch", true],
|
|
86
|
+
],
|
|
87
|
+
true
|
|
88
|
+
);
|
|
89
|
+
|
|
90
|
+
const createVariationFields = ({
|
|
91
|
+
prefix = "screen_picker",
|
|
92
|
+
key,
|
|
93
|
+
type = "number_input",
|
|
94
|
+
label = "",
|
|
95
|
+
variants: [a, b],
|
|
96
|
+
}) => {
|
|
97
|
+
return [
|
|
98
|
+
{
|
|
99
|
+
type,
|
|
100
|
+
key: `${prefix}${prefix.length > 0 ? "_" : ""}${
|
|
101
|
+
a?.key ?? "vertical"
|
|
102
|
+
}_${key}`,
|
|
103
|
+
label: a?.label ?? label,
|
|
104
|
+
initial_value: a.initial_value,
|
|
105
|
+
...conditional_vertical_type,
|
|
106
|
+
},
|
|
107
|
+
{
|
|
108
|
+
type,
|
|
109
|
+
key: `${prefix}${prefix.length > 0 ? "_" : ""}${
|
|
110
|
+
b.key ?? "horizontal"
|
|
111
|
+
}_${key}`,
|
|
112
|
+
label: b?.label ?? label,
|
|
113
|
+
initial_value: b.initial_value,
|
|
114
|
+
...conditional_horizontal_type,
|
|
115
|
+
},
|
|
116
|
+
];
|
|
117
|
+
};
|
|
118
|
+
|
|
119
|
+
module.exports = {
|
|
120
|
+
generateFontConfiguration,
|
|
121
|
+
createVariationFields,
|
|
122
|
+
createConditionalConfig,
|
|
123
|
+
conditional_rule,
|
|
124
|
+
conditional_horizontal_type,
|
|
125
|
+
conditional_vertical_type,
|
|
126
|
+
conditional_horizontal_type_item_fixed,
|
|
127
|
+
conditional_horizontal_type_item_dynamic,
|
|
128
|
+
conditional_horizontal_display_type_fixed,
|
|
129
|
+
conditional_horizontal_asset_on,
|
|
130
|
+
};
|
package/navigationUtils/index.ts
CHANGED
|
@@ -644,8 +644,8 @@ export const getScreenId = (
|
|
|
644
644
|
fallbackRiver: ZappRiver
|
|
645
645
|
) => {
|
|
646
646
|
return screenData?.targetScreen
|
|
647
|
-
?
|
|
647
|
+
? screenData?.targetScreen?.id ?? fallbackRiver.id
|
|
648
648
|
: "screen_id" in screenData
|
|
649
|
-
|
|
650
|
-
|
|
649
|
+
? screenData.screen_id
|
|
650
|
+
: fallbackRiver.id;
|
|
651
651
|
};
|
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.5112402674",
|
|
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.5112402674",
|
|
32
32
|
"buffer": "^5.2.1",
|
|
33
33
|
"camelize": "^1.0.0",
|
|
34
34
|
"create-react-context": "^0.2.3",
|
|
@@ -4,10 +4,9 @@ import { subscriber } from "@applicaster/zapp-react-native-utils/functionUtils";
|
|
|
4
4
|
const subscriberObjects = Object.create({});
|
|
5
5
|
|
|
6
6
|
interface UseSubscriberFor {
|
|
7
|
-
(
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
): (...args: unknown[]) => ReturnType<typeof subscriber>;
|
|
7
|
+
(eventName: string, handler?: (...args: unknown[]) => void): (
|
|
8
|
+
...args: unknown[]
|
|
9
|
+
) => ReturnType<typeof subscriber>;
|
|
11
10
|
}
|
|
12
11
|
|
|
13
12
|
/**
|
package/screenState/index.ts
CHANGED
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
import { create } from "zustand";
|
|
2
2
|
import { produce } from "immer";
|
|
3
3
|
import { path } from "ramda";
|
|
4
|
-
import React from "react";
|
|
5
|
-
import { useShallow } from "zustand/react/shallow";
|
|
6
4
|
|
|
7
5
|
type ScreenState = {
|
|
8
6
|
selectedEntry: {
|
|
@@ -20,8 +18,6 @@ type ScreenStore = {
|
|
|
20
18
|
setSelectedEntry: (screenId: string, entryId: string) => void;
|
|
21
19
|
};
|
|
22
20
|
|
|
23
|
-
type SetSelectedEntry = (screenId: string, entryId: string) => void;
|
|
24
|
-
|
|
25
21
|
const useScreenStore = create<ScreenStore>((set) => ({
|
|
26
22
|
screens: screensInitialState,
|
|
27
23
|
setSelectedEntry: (screenId, entryId) =>
|
|
@@ -39,27 +35,17 @@ const useScreenStore = create<ScreenStore>((set) => ({
|
|
|
39
35
|
export function useScreenState(
|
|
40
36
|
screenId: ScreenId
|
|
41
37
|
): null | { screen: ScreenState; setSelectedEntry: (entryId: string) => void } {
|
|
42
|
-
const
|
|
43
|
-
|
|
44
|
-
|
|
38
|
+
// const state = useState(screenState);
|
|
39
|
+
const screenState = useScreenStore(
|
|
40
|
+
path(["screens", screenId])
|
|
41
|
+
) as ScreenState;
|
|
45
42
|
|
|
46
|
-
const setSelectedEntry = useScreenStore
|
|
47
|
-
useShallow(path(["setSelectedEntry"]))
|
|
48
|
-
);
|
|
43
|
+
const setSelectedEntry = useScreenStore((state) => state.setSelectedEntry);
|
|
49
44
|
|
|
50
|
-
|
|
51
|
-
(entryId) => setSelectedEntry(screenId, entryId),
|
|
52
|
-
[screenId, setSelectedEntry]
|
|
53
|
-
);
|
|
45
|
+
if (!screenId) return null;
|
|
54
46
|
|
|
55
|
-
return
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
: {
|
|
60
|
-
screen: screenState,
|
|
61
|
-
setSelectedEntry: memoizedSetSelectedEntry,
|
|
62
|
-
},
|
|
63
|
-
[screenId, screenState]
|
|
64
|
-
);
|
|
47
|
+
return {
|
|
48
|
+
screen: screenState,
|
|
49
|
+
setSelectedEntry: (entryId) => setSelectedEntry(screenId, entryId),
|
|
50
|
+
};
|
|
65
51
|
}
|
package/theme/index.ts
CHANGED
|
@@ -14,7 +14,7 @@ export const ThemeContext = React.createContext({
|
|
|
14
14
|
export function useTheme<
|
|
15
15
|
T extends Record<string, any> =
|
|
16
16
|
| BaseThemePropertiesTV
|
|
17
|
-
| BaseThemePropertiesMobile
|
|
17
|
+
| BaseThemePropertiesMobile
|
|
18
18
|
>(): T {
|
|
19
19
|
const { themes, selectedThemeId } = React.useContext(ThemeContext);
|
|
20
20
|
|
package/time/Timer.ts
CHANGED
|
@@ -3,10 +3,7 @@ export class Timer {
|
|
|
3
3
|
private remaining: number;
|
|
4
4
|
private timeoutId: NodeJS.Timeout | null;
|
|
5
5
|
|
|
6
|
-
constructor(
|
|
7
|
-
private callback: () => void,
|
|
8
|
-
private duration: number
|
|
9
|
-
) {
|
|
6
|
+
constructor(private callback: () => void, private duration: number) {
|
|
10
7
|
this.remaining = this.duration;
|
|
11
8
|
this.timeoutId = null;
|
|
12
9
|
}
|
package/types.ts
CHANGED
|
@@ -92,8 +92,9 @@ export const PresentHookPluginOneTime = (
|
|
|
92
92
|
const presentOneTimeVersionName =
|
|
93
93
|
await getLatestWatchedVersionNumberFromStorage(storageKey, namespace);
|
|
94
94
|
|
|
95
|
-
const applicationVersionName =
|
|
96
|
-
|
|
95
|
+
const applicationVersionName = await sessionStorage.getItem(
|
|
96
|
+
versionNameKey
|
|
97
|
+
);
|
|
97
98
|
|
|
98
99
|
if (!presentOneTimeVersionName || !applicationVersionName) {
|
|
99
100
|
log_info(
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
import { TestScheduler } from "rxjs/testing";
|
|
2
|
-
|
|
3
|
-
import { withTimeout$ } from "..";
|
|
4
|
-
|
|
5
|
-
describe("withTimeout$", () => {
|
|
6
|
-
let testScheduler: TestScheduler;
|
|
7
|
-
|
|
8
|
-
beforeEach(() => {
|
|
9
|
-
testScheduler = new TestScheduler((actual, expected) => {
|
|
10
|
-
expect(actual).toEqual(expected);
|
|
11
|
-
});
|
|
12
|
-
});
|
|
13
|
-
|
|
14
|
-
it("should emit undefined after the specified timeout", () => {
|
|
15
|
-
testScheduler.run(({ expectObservable }) => {
|
|
16
|
-
const timeout = 1000;
|
|
17
|
-
const expectedMarble = "1s (a|)";
|
|
18
|
-
const expectedValues = { a: undefined };
|
|
19
|
-
|
|
20
|
-
const result$ = withTimeout$(timeout);
|
|
21
|
-
|
|
22
|
-
expectObservable(result$).toBe(expectedMarble, expectedValues);
|
|
23
|
-
});
|
|
24
|
-
});
|
|
25
|
-
|
|
26
|
-
it("should complete after emitting undefined", () => {
|
|
27
|
-
testScheduler.run(({ expectObservable }) => {
|
|
28
|
-
const timeout = 500;
|
|
29
|
-
const expectedMarble = "500ms (a|)";
|
|
30
|
-
const expectedValues = { a: undefined };
|
|
31
|
-
|
|
32
|
-
const result$ = withTimeout$(timeout);
|
|
33
|
-
|
|
34
|
-
expectObservable(result$).toBe(expectedMarble, expectedValues);
|
|
35
|
-
});
|
|
36
|
-
});
|
|
37
|
-
});
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import React from "react";
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* returns a ref with an initial value that is lazily evaluated once
|
|
5
|
-
* */
|
|
6
|
-
export const useRefWithInitialValue = <T>(initialValueGetter: () => T) => {
|
|
7
|
-
const ref = React.useRef<T>(null);
|
|
8
|
-
|
|
9
|
-
if (ref.current === null) {
|
|
10
|
-
ref.current = initialValueGetter();
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
return ref;
|
|
14
|
-
};
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import { useEffect, useState } from "react";
|
|
2
|
-
import type { Subject } from "rxjs";
|
|
3
|
-
|
|
4
|
-
export const useStateFromSubscribe = <T, U>(
|
|
5
|
-
subject: Subject<T>,
|
|
6
|
-
onUpdate: (
|
|
7
|
-
observerValue: T,
|
|
8
|
-
next: React.Dispatch<React.SetStateAction<U>>
|
|
9
|
-
) => void,
|
|
10
|
-
initialValue: U
|
|
11
|
-
) => {
|
|
12
|
-
const [state, setState] = useState<U>(initialValue);
|
|
13
|
-
|
|
14
|
-
useEffect(() => {
|
|
15
|
-
const subscription = subject.subscribe((observer) =>
|
|
16
|
-
onUpdate(observer, setState)
|
|
17
|
-
);
|
|
18
|
-
|
|
19
|
-
return () => subscription.unsubscribe();
|
|
20
|
-
}, [subject]);
|
|
21
|
-
|
|
22
|
-
return state;
|
|
23
|
-
};
|