@applicaster/zapp-react-native-utils 12.0.3-rc.2 → 13.0.0-alpha.1338463240

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.
Files changed (44) hide show
  1. package/actionsExecutor/ActionExecutorContext.tsx +15 -1
  2. package/appUtils/HooksManager/{Hook.js → Hook.ts} +35 -23
  3. package/appUtils/HooksManager/__tests__/__snapshots__/hook.test.js.snap +4 -2
  4. package/appUtils/HooksManager/__tests__/__snapshots__/hooksManager.test.js.snap +693 -0
  5. package/appUtils/HooksManager/__tests__/hook.test.js +196 -184
  6. package/appUtils/HooksManager/__tests__/hooksManager.test.js +96 -99
  7. package/appUtils/HooksManager/{constants.js → constants.ts} +1 -1
  8. package/appUtils/HooksManager/{index.js → index.ts} +121 -112
  9. package/appUtils/HooksManager/types.ts +116 -0
  10. package/appUtils/RiverFocusManager/index.js +17 -12
  11. package/appUtils/accessibilityManager/index.ts +1 -42
  12. package/appUtils/focusManager/index.ts +63 -90
  13. package/appUtils/focusManager/treeDataStructure/Tree/index.js +2 -26
  14. package/appUtils/focusManager/treeDataStructure/Utils/index.js +1 -3
  15. package/appUtils/{index.js → index.ts} +1 -1
  16. package/appUtils/keyCodes/__tests__/keyCodes.test.js +3 -3
  17. package/appUtils/keyCodes/{index.js → index.ts} +2 -0
  18. package/appUtils/keyCodes/keys/index.ts +3 -0
  19. package/appUtils/keyCodes/{keys.android.js → keys/keyEventMapper.ts} +0 -19
  20. package/appUtils/keyCodes/keys/keys.android.ts +18 -0
  21. package/appUtils/keyCodes/keys/keys.ios.ts +25 -0
  22. package/appUtils/keyCodes/keys/keys.ts +15 -0
  23. package/appUtils/keyCodes/keysByPlatform.ts +8 -0
  24. package/appUtils/platform/platformUtils.ts +0 -14
  25. package/appUtils/playerManager/index.ts +6 -2
  26. package/domUtils/{cookieManager.js → cookieManager.ts} +1 -2
  27. package/functionUtils/index.ts +15 -11
  28. package/manifestUtils/sharedConfiguration/screenPicker/__tests__/utils.test.js +304 -0
  29. package/manifestUtils/sharedConfiguration/screenPicker/stylesFields.js +875 -0
  30. package/manifestUtils/sharedConfiguration/screenPicker/utils.js +130 -0
  31. package/modalState/index.ts +1 -5
  32. package/navigationUtils/index.ts +14 -5
  33. package/package.json +2 -2
  34. package/reactHooks/navigation/index.ts +7 -4
  35. package/reactUtils/index.ts +0 -14
  36. package/appUtils/focusManager/utils/enums.ts +0 -4
  37. package/appUtils/keyCodes/keys.ios.js +0 -46
  38. /package/appUtils/HooksManager/{logger.js → logger.ts} +0 -0
  39. /package/appUtils/{directionHelper.js → directionHelper.ts} +0 -0
  40. /package/appUtils/keyCodes/{androidTVKeys.js → androidTVKeys.ts} +0 -0
  41. /package/appUtils/keyCodes/{keys.web.js → keys/keys.web.ts} +0 -0
  42. /package/appUtils/keyCodes/{keysByPlatform.js → keys/keysByPlatform.ts} +0 -0
  43. /package/appUtils/{localizationsHelper.js → localizationsHelper.ts} +0 -0
  44. /package/domUtils/{logger.js → logger.ts} +0 -0
@@ -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
+ };
@@ -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,
@@ -324,7 +324,13 @@ export function getPathAttributes({
324
324
  * @param {object} rivers
325
325
  * @returns {object}
326
326
  */
327
- export function getRiverFromRoute({ route, rivers }) {
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
- .handleHooks(entry);
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": "12.0.3-rc.2",
3
+ "version": "13.0.0-alpha.1338463240",
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": "12.0.3-rc.2",
31
+ "@applicaster/applicaster-types": "13.0.0-alpha.1338463240",
32
32
  "buffer": "^5.2.1",
33
33
  "camelize": "^1.0.0",
34
34
  "create-react-context": "^0.2.3",
@@ -320,16 +320,19 @@ export const useZappHooksForEntry = (
320
320
  callbacks?.handleHookComplete?.(props);
321
321
  };
322
322
 
323
- const hookManager = HooksManager(hooksOptions)
323
+ const hookManager = HooksManager(hooksOptions);
324
+
325
+ hookManager.subscriber
324
326
  .on(HOOKS_EVENTS.PRESENT_SCREEN_HOOK, handleHookPresent)
325
327
  .on(HOOKS_EVENTS.ERROR, handleHookError)
326
328
  .on(HOOKS_EVENTS.CANCEL, handleHookCancel)
327
329
  .on(HOOKS_EVENTS.START_BACKGROUND_HOOK, handleBackgroundHook)
328
- .on(HOOKS_EVENTS.COMPLETE, handleHookComplete)
329
- .handleHooks(entry);
330
+ .on(HOOKS_EVENTS.COMPLETE, handleHookComplete);
331
+
332
+ hookManager.handleHooks(entry);
330
333
 
331
334
  return () => {
332
- hookManager
335
+ hookManager.subscriber
333
336
  .removeHandler(HOOKS_EVENTS.PRESENT_SCREEN_HOOK, handleHookPresent)
334
337
  .removeHandler(HOOKS_EVENTS.ERROR, handleHookError)
335
338
  .removeHandler(HOOKS_EVENTS.CANCEL, handleHookCancel)
@@ -109,20 +109,6 @@ export const isTvOSPlatform = () => getPlatform() === "tvos";
109
109
 
110
110
  export const isAndroidTVPlatform = () => getPlatform() === "android_tv";
111
111
 
112
- declare global {
113
- interface Window {
114
- VIZIO?: {
115
- Chromevox: {
116
- play: (text: string) => void;
117
- };
118
- exitApplication: () => void;
119
- setClosedCaptionHandler: (
120
- callback: (isCCEnabled: boolean) => void
121
- ) => void;
122
- };
123
- }
124
- }
125
-
126
112
  /**
127
113
  * Platforms found in userAgent string, please note that simulators
128
114
  * might not have the same agents that the devices have
@@ -1,4 +0,0 @@
1
- export enum ACTION {
2
- FOCUS = "focus",
3
- BLUR = "blur",
4
- }
@@ -1,46 +0,0 @@
1
- /* global tizen */
2
- const isTizen = typeof tizen !== "undefined";
3
-
4
- export const KEYS = {
5
- Enter: { code: "Enter", keyCode: 13 },
6
- Space: { code: "Space", keyCode: 32 },
7
- m: { code: "m", keyCode: 77 },
8
- ArrowLeft: { code: "ArrowLeft", keyCode: 37 },
9
- ArrowUp: { code: "ArrowUp", keyCode: 38 },
10
- ArrowRight: { code: "ArrowRight", keyCode: 39 },
11
- ArrowDown: { code: "ArrowDown", keyCode: 40 },
12
- Back: isTizen
13
- ? { code: "Back", keyCode: 10009 }
14
- : { code: "Backspace", keyCode: 8 },
15
- Play: isTizen
16
- ? { code: "MediaPlay", keyCode: 10252 }
17
- : { code: "PlayPause", keyCode: 179 },
18
- Pause: isTizen
19
- ? { code: "MediaPause", keyCode: 19 }
20
- : { code: "Pause", keyCode: 179 },
21
- Forward: isTizen
22
- ? { code: "MediaFastForward", keyCode: 417 }
23
- : { code: "Forward", keyCode: 176 },
24
- Rewind: isTizen
25
- ? { code: "MediaRewind", keyCode: 412 }
26
- : { code: "Rewind", keyCode: 177 },
27
- VolumeUp: isTizen
28
- ? { code: "VolumeUp", keyCode: 447 }
29
- : { code: "VolumeUp", keyCode: 175 },
30
- VolumeDown: isTizen
31
- ? { code: "VolumeDown", keyCode: 448 }
32
- : { code: "VolumeDown", keyCode: 174 },
33
- ToggleMute: isTizen
34
- ? { code: "VolumeMute", keyCode: 449 }
35
- : { code: "VolumeMute", keyCode: 173 },
36
- Stop: isTizen
37
- ? { code: "MediaStop", keyCode: 413 }
38
- : { code: "Q", keyCode: 81 },
39
- };
40
-
41
- export const ARROW_KEYS = [
42
- KEYS.ArrowUp,
43
- KEYS.ArrowLeft,
44
- KEYS.ArrowDown,
45
- KEYS.ArrowRight,
46
- ];
File without changes
File without changes