@applicaster/zapp-react-native-utils 13.0.0-alpha.1632352572 → 13.0.0-alpha.1673005505

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 (123) hide show
  1. package/README.md +0 -10
  2. package/actionsExecutor/ActionExecutor.ts +16 -9
  3. package/actionsExecutor/ActionExecutorContext.tsx +74 -9
  4. package/alertUtils/alert.ts +148 -0
  5. package/alertUtils/index.ts +1 -148
  6. package/analyticsUtils/AnalyticPlayerListener.ts +18 -1
  7. package/analyticsUtils/__tests__/__snapshots__/analyticsManagerNoModule.test.js.snap +9 -9
  8. package/analyticsUtils/helpers/hooks.ts +1 -1
  9. package/appUtils/HooksManager/{Hook.js → Hook.ts} +35 -23
  10. package/appUtils/HooksManager/__tests__/__snapshots__/hook.test.js.snap +10 -8
  11. package/appUtils/HooksManager/__tests__/__snapshots__/hooksManager.test.js.snap +693 -0
  12. package/appUtils/HooksManager/__tests__/hook.test.js +196 -184
  13. package/appUtils/HooksManager/__tests__/hooksManager.test.js +96 -99
  14. package/appUtils/HooksManager/{constants.js → constants.ts} +1 -1
  15. package/appUtils/HooksManager/{index.js → index.ts} +121 -112
  16. package/appUtils/HooksManager/types.ts +119 -0
  17. package/appUtils/RiverFocusManager/index.js +17 -12
  18. package/appUtils/accessibilityManager/index.ts +42 -1
  19. package/appUtils/contextKeysManager/contextResolver.ts +77 -0
  20. package/appUtils/contextKeysManager/index.ts +2 -2
  21. package/appUtils/contextKeysManager/utils/index.ts +2 -1
  22. package/appUtils/focusManager/__tests__/__snapshots__/focusManager.test.js.snap +7 -6
  23. package/appUtils/focusManager/index.ts +100 -65
  24. package/appUtils/focusManager/treeDataStructure/Tree/index.js +25 -3
  25. package/appUtils/focusManager/treeDataStructure/Utils/index.js +1 -3
  26. package/appUtils/focusManager/utils/enums.ts +4 -0
  27. package/appUtils/focusManagerAux/utils/index.ts +4 -3
  28. package/appUtils/{index.js → index.ts} +1 -1
  29. package/appUtils/keyCodes/__tests__/__snapshots__/keyCodes.test.js.snap +2 -2
  30. package/appUtils/keyCodes/__tests__/keyCodes.test.js +4 -4
  31. package/appUtils/keyCodes/{index.js → index.ts} +2 -0
  32. package/appUtils/keyCodes/keys/index.ts +3 -0
  33. package/appUtils/keyCodes/{keys.android.js → keys/keyEventMapper.ts} +0 -19
  34. package/appUtils/keyCodes/keys/keys.android.ts +18 -0
  35. package/appUtils/keyCodes/keys/keys.ios.ts +25 -0
  36. package/appUtils/keyCodes/keys/keys.ts +15 -0
  37. package/appUtils/keyCodes/{keysByPlatform.js → keys/keysByPlatform.ts} +3 -3
  38. package/appUtils/keyCodes/keysByPlatform.ts +8 -0
  39. package/appUtils/orientationHelper.ts +1 -1
  40. package/appUtils/platform/const.ts +14 -0
  41. package/appUtils/platform/platformUtils.ts +47 -18
  42. package/appUtils/playerManager/player.ts +5 -4
  43. package/appUtils/playerManager/playerNative.ts +1 -1
  44. package/arrayUtils/__tests__/__snapshots__/arrayUtils.test.ts.snap +4 -4
  45. package/domUtils/{cookieManager.js → cookieManager.ts} +1 -2
  46. package/equalUtils/index.ts +10 -3
  47. package/focusManager/FocusManager.ts +11 -1
  48. package/functionUtils/__tests__/__snapshots__/functionUtils.test.js.snap +4 -4
  49. package/functionUtils/index.ts +15 -11
  50. package/idleUtils/__tests__/withTimeout$.test.ts +37 -0
  51. package/idleUtils/index.ts +1 -1
  52. package/idleUtils/withTimeout.ts +15 -2
  53. package/logger/const.ts +9 -67
  54. package/manifestUtils/__tests__/createConfig.test.js +16 -16
  55. package/modalState/index.ts +1 -5
  56. package/navigationUtils/__tests__/__snapshots__/navigationUtils.test.js.snap +6 -6
  57. package/navigationUtils/__tests__/itemTypes.test.js +2 -2
  58. package/navigationUtils/__tests__/navigationUtils.test.js +2 -2
  59. package/navigationUtils/index.ts +17 -8
  60. package/package.json +3 -2
  61. package/reactHooks/autoscrolling/__tests__/useTrackCurrentAutoScrollingElement.test.ts +1 -1
  62. package/reactHooks/autoscrolling/__tests__/useTrackedView.test.tsx +1 -1
  63. package/reactHooks/cell-click/__tests__/index.test.js +10 -2
  64. package/reactHooks/cell-click/index.ts +7 -1
  65. package/reactHooks/feed/__tests__/useBuildPipesUrl.test.tsx +4 -4
  66. package/reactHooks/feed/__tests__/useFeedLoader.test.tsx +10 -11
  67. package/reactHooks/feed/useFeedLoader.tsx +1 -1
  68. package/reactHooks/feed/usePipesCacheReset.ts +5 -5
  69. package/reactHooks/flatList/__tests__/index.test.tsx +30 -21
  70. package/reactHooks/layout/__tests__/index.test.tsx +10 -10
  71. package/reactHooks/layout/useDimensions/helpers/__tests__/getInitialDimensions.native.test.js +14 -28
  72. package/reactHooks/layout/useDimensions/helpers/__tests__/getInitialDimensions.test.js +1 -1
  73. package/reactHooks/layout/useDimensions/useDimensions.ts +8 -0
  74. package/reactHooks/navigation/__tests__/index.test.tsx +0 -4
  75. package/reactHooks/navigation/index.ts +35 -236
  76. package/reactHooks/navigation/useGetBottomTabBarHeight.ts +12 -0
  77. package/reactHooks/navigation/useGetNavBarTopBorderWidth.ts +14 -0
  78. package/reactHooks/navigation/useGetTabBarHeight.ts +10 -0
  79. package/reactHooks/navigation/useIsScreenActive.ts +17 -0
  80. package/reactHooks/navigation/useNavigationPluginData.ts +15 -0
  81. package/reactHooks/navigation/useNavigationType.ts +15 -0
  82. package/reactHooks/navigation/usePathname.ts +4 -0
  83. package/reactHooks/navigation/useProfilerLogging.ts +15 -0
  84. package/reactHooks/navigation/useRoute.ts +100 -0
  85. package/reactHooks/navigation/useUniqueRouteSuffix.ts +41 -0
  86. package/reactHooks/player/TVSeekControlller/ISeekController.ts +27 -2
  87. package/reactHooks/player/TVSeekControlller/LongPressSeekController.ts +23 -61
  88. package/reactHooks/player/TVSeekControlller/TVSeekController.ts +143 -48
  89. package/reactHooks/player/TVSeekControlller/TapSeekController.ts +29 -51
  90. package/reactHooks/player/__tests__/useAutoSeek._test.tsx +115 -0
  91. package/reactHooks/player/__tests__/useTapSeek._test.ts +94 -0
  92. package/reactHooks/player/const.ts +1 -5
  93. package/reactHooks/state/useRefWithInitialValue.ts +14 -0
  94. package/reactHooks/state/useStateFromSubscribe.ts +23 -0
  95. package/reactHooks/usePluginConfiguration.ts +1 -1
  96. package/reactHooks/useSubscriberFor.ts +4 -3
  97. package/reactUtils/__tests__/__snapshots__/reactUtilsHelpers.test.js.snap +16 -4
  98. package/reactUtils/__tests__/reactUtils.test.js +10 -28
  99. package/reactUtils/__tests__/reactUtilsHelpers.test.js +72 -71
  100. package/reactUtils/createContext/__tests__/__snapshots__/helpers.test.js.snap +13 -79
  101. package/reactUtils/createContext/__tests__/__snapshots__/index.test.js.snap +2 -2
  102. package/reactUtils/createContext/__tests__/__snapshots__/provider.test.js.snap +3 -28
  103. package/reactUtils/createContext/__tests__/__snapshots__/withConsumer.test.js.snap +3 -4
  104. package/reactUtils/createContext/__tests__/__snapshots__/withProvider.test.js.snap +7 -3
  105. package/reactUtils/createContext/__tests__/helpers.test.js +107 -121
  106. package/reactUtils/createContext/__tests__/provider.test.js +4 -6
  107. package/reactUtils/createContext/__tests__/withConsumer.test.js +12 -12
  108. package/reactUtils/createContext/__tests__/withProvider.test.js +4 -4
  109. package/reactUtils/index.ts +0 -14
  110. package/screenState/index.ts +24 -10
  111. package/testUtils/index.tsx +0 -10
  112. package/theme/__mocks__/index.ts +4 -0
  113. package/theme/index.ts +1 -1
  114. package/time/Timer.ts +5 -2
  115. package/types.ts +1 -0
  116. package/zappFrameworkUtils/presentPluginOneTime.ts +2 -3
  117. package/appUtils/keyCodes/keys.ios.js +0 -46
  118. /package/appUtils/HooksManager/{logger.js → logger.ts} +0 -0
  119. /package/appUtils/{directionHelper.js → directionHelper.ts} +0 -0
  120. /package/appUtils/keyCodes/{androidTVKeys.js → androidTVKeys.ts} +0 -0
  121. /package/appUtils/keyCodes/{keys.web.js → keys/keys.web.ts} +0 -0
  122. /package/appUtils/{localizationsHelper.js → localizationsHelper.ts} +0 -0
  123. /package/domUtils/{logger.js → logger.ts} +0 -0
@@ -1,10 +1,10 @@
1
1
  // Jest Snapshot v1, https://goo.gl/fbAQLP
2
2
 
3
3
  exports[`createContext - when React has the new context API returns the components and the decorators 1`] = `
4
- Object {
4
+ {
5
5
  "Consumer": [MockFunction],
6
6
  "Provider": [MockFunction],
7
- "ReactContext": Object {
7
+ "ReactContext": {
8
8
  "Consumer": [MockFunction],
9
9
  "Provider": [MockFunction],
10
10
  },
@@ -1,32 +1,7 @@
1
1
  // Jest Snapshot v1, https://goo.gl/fbAQLP
2
2
 
3
3
  exports[`createProvider creates a context Provider component 1`] = `
4
- <mockConstructor
5
- value={
6
- Object {
7
- "context": "initialValue",
8
- "otherContext": "otherValue",
9
- "setContext": [Function],
10
- "setOtherContext": [Function],
11
- }
12
- }
13
- >
14
- <MockChild
15
- context="context"
16
- />
17
- </mockConstructor>
18
- `;
19
-
20
- exports[`createProvider creates a context Provider component 2`] = `
21
- Object {
22
- "children": <MockChild
23
- context="context"
24
- />,
25
- "value": Object {
26
- "context": "initialValue",
27
- "otherContext": "otherValue",
28
- "setContext": [Function],
29
- "setOtherContext": [Function],
30
- },
31
- }
4
+ <View>
5
+ context
6
+ </View>
32
7
  `;
@@ -1,8 +1,7 @@
1
1
  // Jest Snapshot v1, https://goo.gl/fbAQLP
2
2
 
3
3
  exports[`createConsumer creates a context consumer function 1`] = `
4
- <Child
5
- context="foo"
6
- setContext={[MockFunction]}
7
- />
4
+ <View>
5
+ foo
6
+ </View>
8
7
  `;
@@ -1,7 +1,11 @@
1
1
  // Jest Snapshot v1, https://goo.gl/fbAQLP
2
2
 
3
3
  exports[`withProvider decorates a component with the provider 1`] = `
4
- <Provider>
5
- <Component />
6
- </Provider>
4
+ <View>
5
+ <View>
6
+ <Text>
7
+ I am a Component
8
+ </Text>
9
+ </View>
10
+ </View>
7
11
  `;
@@ -1,7 +1,8 @@
1
1
  import * as React from "react";
2
- import { shallow } from "enzyme";
3
2
  import { View, Text } from "react-native";
4
3
 
4
+ import { NOOP, getSetterName, createContextSetters } from "../helpers";
5
+
5
6
  function stateValidator({ property, value }) {
6
7
  return (
7
8
  (property === "foo" && value === "new foo") ||
@@ -9,150 +10,135 @@ function stateValidator({ property, value }) {
9
10
  );
10
11
  }
11
12
 
12
- const logger = {
13
- warning: jest.fn(),
14
- };
15
-
16
- jest.mock("../../logger", () => ({
17
- reactUtilsLogger: {
18
- addSubsystem: jest.fn(() => logger),
19
- },
20
- }));
21
-
22
- const { NOOP, getSetterName, createContextSetters } = require("../helpers");
23
-
24
- describe("NOOP", () => {
25
- it("does nothing", () => {
26
- expect(NOOP()).toBeUndefined();
13
+ describe("helpers", () => {
14
+ describe("NOOP", () => {
15
+ it("does nothing", () => {
16
+ expect(NOOP()).toBeUndefined();
17
+ });
27
18
  });
28
- });
29
19
 
30
- describe("getSetterName", () => {
31
- it("returns a setter name for the given property name", () => {
32
- expect(getSetterName("fooBar")).toBe("setFooBar");
20
+ describe("getSetterName", () => {
21
+ it("returns a setter name for the given property name", () => {
22
+ expect(getSetterName("fooBar")).toBe("setFooBar");
23
+ });
33
24
  });
34
- });
35
-
36
- describe("createContextSetters", () => {
37
- describe("when state validator is provided", () => {
38
- class Component extends React.Component {
39
- constructor(props) {
40
- super(props);
41
- this.state = { foo: "foo", bar: "bar" };
42
- createContextSetters(["foo", "bar"], this, { stateValidator });
43
- }
44
-
45
- resetInitialState() {
46
- this.setState({ foo: "foo", bar: "bar" });
47
- }
48
25
 
49
- render() {
50
- return (
51
- <View>
52
- <Text>I am a component</Text>
53
- </View>
54
- );
26
+ describe("createContextSetters", () => {
27
+ describe("when state validator is provided", () => {
28
+ class ClassComponent {
29
+ constructor() {
30
+ this._state = { foo: "foo", bar: "bar" };
31
+ createContextSetters(["foo", "bar"], this, { stateValidator });
32
+ }
33
+
34
+ setState(newState) {
35
+ if (typeof newState === "function") {
36
+ this.state = newState(this.state);
37
+ } else {
38
+ this.state = { ...this.state, ...newState };
39
+ }
40
+ }
41
+
42
+ set state(val) {
43
+ this._state = val;
44
+ }
45
+
46
+ get state() {
47
+ return this._state;
48
+ }
49
+
50
+ getState() {
51
+ return this._state;
52
+ }
53
+
54
+ resetInitialState() {
55
+ this.setState({ foo: "foo", bar: "bar" });
56
+ }
57
+
58
+ render() {
59
+ return <View testID="test-view">{JSON.stringify(this.state)}</View>;
60
+ }
55
61
  }
56
- }
57
62
 
58
- const wrapper = shallow(<Component />);
59
- const instance = wrapper.instance();
60
- const setStateSpy = jest.spyOn(instance, "setState");
63
+ let instance;
61
64
 
62
- beforeEach(() => {
63
- instance.resetInitialState();
64
- setStateSpy.mockClear();
65
- logger.warning.mockClear();
66
- });
67
-
68
- it("adds all properties and setters to the component", () => {
69
- expect(instance).toHaveProperty("setFoo");
70
- expect(instance.setFoo).toBeFunction();
71
- expect(instance).toHaveProperty("setBar");
72
- expect(instance.setBar).toBeFunction();
73
- });
65
+ beforeEach(() => {
66
+ instance = new ClassComponent();
67
+ });
74
68
 
75
- it("calls setState when the setters are called & the validator passes", () => {
76
- expect(instance.state).toMatchSnapshot();
69
+ it("calls setState when the setters are called & the validator passes", () => {
70
+ expect(instance.state.foo).toEqual("foo");
71
+ expect(instance.state.bar).toEqual("bar");
77
72
 
78
- instance.setFoo("new foo");
79
- expect(instance.state).toMatchSnapshot();
80
-
81
- instance.setBar("new bar");
82
- expect(instance.state).toMatchSnapshot();
83
-
84
- expect(setStateSpy).toHaveBeenCalledTimes(2);
85
- expect(setStateSpy.mock.calls).toMatchSnapshot();
86
- expect(logger.warning).not.toHaveBeenCalled();
87
- });
73
+ instance.setFoo("new foo");
74
+ expect(instance.state.foo).toEqual("new foo");
88
75
 
89
- it("skips the update if the state validator doesn't pass", () => {
90
- expect(instance.state).toMatchSnapshot();
76
+ instance.setBar("new bar");
77
+ expect(instance.state.bar).toEqual("new bar");
78
+ });
91
79
 
92
- instance.setFoo("invalid foo");
93
- expect(instance.state).toMatchSnapshot();
80
+ it("skips the update if the state validator doesn't pass", () => {
81
+ expect(instance.state.foo).toEqual("foo");
82
+ expect(instance.state.bar).toEqual("bar");
94
83
 
95
- instance.setBar("invalid bar");
96
- expect(instance.state).toMatchSnapshot();
84
+ instance.setFoo("invalid foo");
85
+ expect(instance.state.foo).toEqual("foo");
97
86
 
98
- expect(setStateSpy).not.toHaveBeenCalled();
99
- expect(logger.warning).toHaveBeenCalledTimes(2);
100
- expect(logger.warning.mock.calls).toMatchSnapshot();
101
- });
87
+ instance.setBar("invalid bar");
88
+ expect(instance.state.bar).toEqual("bar");
89
+ });
102
90
 
103
- it("skips the update if the new value is the same as the previous one", () => {
104
- instance.setFoo("new foo");
105
- instance.setFoo("new foo");
106
- expect(instance.state).toMatchSnapshot();
107
- expect(setStateSpy).toHaveBeenCalledTimes(1);
91
+ it("skips the update if the new value is the same as the previous one", () => {
92
+ instance.setFoo("new foo");
93
+ instance.setFoo("new foo");
94
+ expect(instance.state).toMatchSnapshot();
95
+ });
108
96
  });
109
- });
110
-
111
- describe("when no state validator is provided", () => {
112
- class Component extends React.Component {
113
- constructor(props) {
114
- super(props);
115
- this.state = { foo: "foo", bar: "bar" };
116
- createContextSetters(["foo", "bar"], this);
117
- }
118
97
 
119
- render() {
120
- return (
121
- <View>
122
- <Text>I am a component </Text>
123
- </View>
124
- );
98
+ describe("when no state validator is provided", () => {
99
+ class Component extends React.Component {
100
+ constructor(props) {
101
+ super(props);
102
+ this.state = { foo: "foo", bar: "bar" };
103
+ createContextSetters(["foo", "bar"], this);
104
+ }
105
+
106
+ render() {
107
+ return (
108
+ <View>
109
+ <Text>I am a component </Text>
110
+ </View>
111
+ );
112
+ }
125
113
  }
126
- }
127
114
 
128
- const wrapper = shallow(<Component />);
129
- const instance = wrapper.instance();
130
- const setStateSpy = jest.spyOn(instance, "setState");
115
+ // const wrapper = new Component();
116
+ const instance = new Component();
117
+ const setStateSpy = jest.spyOn(instance, "setState");
131
118
 
132
- afterEach(() => {
133
- setStateSpy.mockClear();
134
- logger.warning.mockClear();
135
- });
119
+ afterEach(() => {
120
+ setStateSpy.mockClear();
121
+ });
136
122
 
137
- it("adds all properties and setters to the component", () => {
138
- expect(instance).toHaveProperty("setFoo");
139
- expect(instance.setFoo).toBeFunction();
140
- expect(instance).toHaveProperty("setBar");
141
- expect(instance.setBar).toBeFunction();
142
- });
123
+ it("adds all properties and setters to the component", () => {
124
+ expect(instance).toHaveProperty("setFoo");
125
+ expect(instance.setFoo).toBeFunction();
126
+ expect(instance).toHaveProperty("setBar");
127
+ expect(instance.setBar).toBeFunction();
128
+ });
143
129
 
144
- it("calls setState when the setters are called, no matter what the value is", () => {
145
- expect(instance.state).toMatchSnapshot();
130
+ it("calls setState when the setters are called, no matter what the value is", () => {
131
+ expect(instance.state).toMatchSnapshot();
146
132
 
147
- instance.setFoo("invalid foo");
148
- expect(instance.state).toMatchSnapshot();
133
+ instance.setFoo("invalid foo");
134
+ expect(instance.state).toMatchSnapshot();
149
135
 
150
- instance.setBar("invalid bar");
151
- expect(instance.state).toMatchSnapshot();
136
+ instance.setBar("invalid bar");
137
+ expect(instance.state).toMatchSnapshot();
152
138
 
153
- expect(setStateSpy).toHaveBeenCalledTimes(2);
154
- expect(setStateSpy.mock.calls).toMatchSnapshot();
155
- expect(logger.warning).not.toHaveBeenCalled();
139
+ expect(setStateSpy).toHaveBeenCalledTimes(2);
140
+ expect(setStateSpy.mock.calls).toMatchSnapshot();
141
+ });
156
142
  });
157
143
  });
158
144
  });
@@ -1,7 +1,7 @@
1
1
  /* eslint-disable react/prop-types */
2
2
  import * as React from "react";
3
- import { shallow } from "enzyme";
4
- import toJson from "enzyme-to-json";
3
+ import { render } from "@testing-library/react-native";
4
+
5
5
  import { View } from "react-native";
6
6
 
7
7
  import { createProvider } from "../provider";
@@ -29,14 +29,12 @@ describe("createProvider", () => {
29
29
  it("creates a context Provider component", () => {
30
30
  const MockChild = (props) => <View>{props.context}</View>;
31
31
 
32
- const wrapper = shallow(
32
+ const wrapper = render(
33
33
  <Provider>
34
34
  <MockChild context={"context"} />
35
35
  </Provider>
36
36
  );
37
37
 
38
- expect(toJson(wrapper)).toMatchSnapshot();
39
-
40
- expect(wrapper.find(ReactContext.Provider).props()).toMatchSnapshot();
38
+ expect(wrapper.toJSON()).toMatchSnapshot();
41
39
  });
42
40
  });
@@ -1,7 +1,7 @@
1
1
  /* eslint-disable react/prop-types */
2
2
  import * as React from "react";
3
- import { shallow } from "enzyme";
4
- import toJson from "enzyme-to-json";
3
+ import { render } from "@testing-library/react-native";
4
+
5
5
  import { View } from "react-native";
6
6
 
7
7
  import { createWithConsumerDecorator } from "../withConsumer";
@@ -11,21 +11,21 @@ describe("createConsumer", () => {
11
11
  const { Consumer } = ReactContext;
12
12
  const withConsumer = createWithConsumerDecorator(Consumer);
13
13
 
14
- it("returns a function", () => {
15
- expect(withConsumer).toBeFunction();
16
- });
17
-
18
14
  it("creates a context consumer function", () => {
19
- const Child = (props) => <View>{props.context}</View>;
20
- const DecoratedChild = withConsumer(Child);
15
+ expect(withConsumer).toBeFunction();
21
16
  const newContextValue = "newValue";
22
17
 
23
- const wrapper = shallow(<DecoratedChild />);
18
+ const Child = (props) => {
19
+ props.setContext(newContextValue);
20
+
21
+ return <View>{props.context}</View>;
22
+ };
23
+
24
+ const DecoratedChild = withConsumer(Child);
24
25
 
25
- const childWrapper = wrapper.dive();
26
+ const wrapper = render(<DecoratedChild />);
26
27
 
27
- expect(toJson(childWrapper)).toMatchSnapshot();
28
- childWrapper.props().setContext(newContextValue);
28
+ expect(wrapper.toJSON()).toMatchSnapshot();
29
29
 
30
30
  expect(mockContextData.setContext).toHaveBeenCalledWith(newContextValue);
31
31
  });
@@ -1,7 +1,7 @@
1
1
  /* eslint-disable react/prop-types */
2
2
  import * as React from "react";
3
- import { shallow } from "enzyme";
4
- import toJson from "enzyme-to-json";
3
+ import { render } from "@testing-library/react-native";
4
+
5
5
  import { View, Text } from "react-native";
6
6
 
7
7
  import { createWithProviderDecorator } from "../withProvider";
@@ -19,8 +19,8 @@ describe("withProvider", () => {
19
19
 
20
20
  const DecoratedComponent = withProvider(Component);
21
21
 
22
- const wrapper = shallow(<DecoratedComponent />);
22
+ const wrapper = render(<DecoratedComponent />);
23
23
 
24
- expect(toJson(wrapper)).toMatchSnapshot();
24
+ expect(wrapper.toJSON()).toMatchSnapshot();
25
25
  });
26
26
  });
@@ -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,6 +1,8 @@
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";
4
6
 
5
7
  type ScreenState = {
6
8
  selectedEntry: {
@@ -18,6 +20,8 @@ type ScreenStore = {
18
20
  setSelectedEntry: (screenId: string, entryId: string) => void;
19
21
  };
20
22
 
23
+ type SetSelectedEntry = (screenId: string, entryId: string) => void;
24
+
21
25
  const useScreenStore = create<ScreenStore>((set) => ({
22
26
  screens: screensInitialState,
23
27
  setSelectedEntry: (screenId, entryId) =>
@@ -35,17 +39,27 @@ const useScreenStore = create<ScreenStore>((set) => ({
35
39
  export function useScreenState(
36
40
  screenId: ScreenId
37
41
  ): null | { screen: ScreenState; setSelectedEntry: (entryId: string) => void } {
38
- // const state = useState(screenState);
39
- const screenState = useScreenStore(
40
- path(["screens", screenId])
41
- ) as ScreenState;
42
+ const screenState = useScreenStore<ScreenState>(
43
+ useShallow(path(["screens", screenId]))
44
+ );
42
45
 
43
- const setSelectedEntry = useScreenStore((state) => state.setSelectedEntry);
46
+ const setSelectedEntry = useScreenStore<SetSelectedEntry>(
47
+ useShallow(path(["setSelectedEntry"]))
48
+ );
44
49
 
45
- if (!screenId) return null;
50
+ const memoizedSetSelectedEntry = React.useCallback(
51
+ (entryId) => setSelectedEntry(screenId, entryId),
52
+ [screenId, setSelectedEntry]
53
+ );
46
54
 
47
- return {
48
- screen: screenState,
49
- setSelectedEntry: (entryId) => setSelectedEntry(screenId, entryId),
50
- };
55
+ return React.useMemo(
56
+ () =>
57
+ !screenId
58
+ ? null
59
+ : {
60
+ screen: screenState,
61
+ setSelectedEntry: memoizedSetSelectedEntry,
62
+ },
63
+ [screenId, screenState]
64
+ );
51
65
  }
@@ -15,16 +15,6 @@ import { ThemeContext } from "../theme";
15
15
 
16
16
  export { getByTestId } from "./getByTestId";
17
17
 
18
- /**
19
- * Function to be used in tandem with enzyme findWhere(node => node.prop('testID') === 'yourID')
20
- * Example:
21
- * wrapper.findWhere(testIDEquals('yourID'))
22
- * @param {*} testId
23
- * @return boolean
24
- */
25
- export const testIDEquals = (testId: any): boolean =>
26
- R.compose(R.equals(testId), R.invoker(1, "prop")("testID"));
27
-
28
18
  /** Helper function for react-test-renderer, accepts type and renderer
29
19
  * * @param {*} type React Component type instance or name of component
30
20
  * * @param {*} renderer renderer instance
@@ -1,3 +1,5 @@
1
+ import React from "react";
2
+
1
3
  export const themeMock = {
2
4
  screen_padding_top: 20,
3
5
  screen_padding_bottom: 48,
@@ -17,3 +19,5 @@ export const themeMock = {
17
19
  };
18
20
 
19
21
  export const useTheme = jest.fn().mockReturnValue(themeMock);
22
+
23
+ export const ThemeContext = React.createContext(themeMock);
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,8 +3,11 @@ export class Timer {
3
3
  private remaining: number;
4
4
  private timeoutId: NodeJS.Timeout | null;
5
5
 
6
- constructor(private callback: () => void, private duration: number) {
7
- this.remaining = duration;
6
+ constructor(
7
+ private callback: () => void,
8
+ private duration: number
9
+ ) {
10
+ this.remaining = this.duration;
8
11
  this.timeoutId = null;
9
12
  }
10
13
 
package/types.ts CHANGED
@@ -8,4 +8,5 @@ export type ManifestField<T> = {
8
8
 
9
9
  export enum ENDPOINT_TAGS {
10
10
  allow_missing_keys = "allow_missing_keys",
11
+ observe_storage = "observe_storage",
11
12
  }
@@ -92,9 +92,8 @@ export const PresentHookPluginOneTime = (
92
92
  const presentOneTimeVersionName =
93
93
  await getLatestWatchedVersionNumberFromStorage(storageKey, namespace);
94
94
 
95
- const applicationVersionName = await sessionStorage.getItem(
96
- versionNameKey
97
- );
95
+ const applicationVersionName =
96
+ await sessionStorage.getItem(versionNameKey);
98
97
 
99
98
  if (!presentOneTimeVersionName || !applicationVersionName) {
100
99
  log_info(
@@ -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