react-native-tvos 0.71.7-0rc0 → 0.71.8-0rc0

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.
@@ -29,13 +29,18 @@ type TVTouchableConfig = $ReadOnly<{|
29
29
  |}>;
30
30
 
31
31
  export default class TVTouchable {
32
- _tvEventHandler: TVEventHandler;
32
+ _tvEventHandler: TVEventHandler = null;
33
+ _enabled: boolean = false;
33
34
 
34
35
  constructor(component: any, config: TVTouchableConfig) {
35
36
  invariant(Platform.isTV, 'TVTouchable: Requires `Platform.isTV`.');
36
37
  this._tvEventHandler = new TVEventHandler();
38
+ const _tvtouchable = this;
37
39
  this._tvEventHandler.enable(component, (_, tvData) => {
38
40
  tvData.dispatchConfig = {};
41
+ if (!_tvtouchable._enabled) {
42
+ return;
43
+ }
39
44
  if (ReactNative.findNodeHandle(component) === tvData.tag) {
40
45
  if (tvData.eventType === 'focus') {
41
46
  config.onFocus(tvData);
@@ -52,9 +57,12 @@ export default class TVTouchable {
52
57
  }
53
58
  }
54
59
  });
60
+ this._enabled = true;
55
61
  }
56
62
 
57
63
  destroy(): void {
64
+ this._enabled = false;
58
65
  this._tvEventHandler.disable();
66
+ this._tvEventHandler = null;
59
67
  }
60
68
  }
@@ -13,6 +13,7 @@ import type {ColorValue} from '../../StyleSheet/StyleSheet';
13
13
  import type {PressEvent} from '../../Types/CoreEventTypes';
14
14
  import type {TouchableType} from './Touchable.flow';
15
15
 
16
+ import ReactNative from '../../Renderer/shims/ReactNative';
16
17
  import {PressabilityDebugView} from '../../Pressability/PressabilityDebug';
17
18
  import UIManager from '../../ReactNative/UIManager';
18
19
  import Platform from '../../Utilities/Platform';
@@ -12,6 +12,6 @@
12
12
  exports.version = {
13
13
  major: 0,
14
14
  minor: 71,
15
- patch: 7,
15
+ patch: 8,
16
16
  prerelease: '0rc0',
17
17
  };
@@ -256,21 +256,21 @@ static void *TextFieldSelectionObservingContext = &TextFieldSelectionObservingCo
256
256
 
257
257
  - (void)textViewDidChange:(__unused UITextView *)textView
258
258
  {
259
- if (_ignoreNextTextInputCall && [_lastStringStateWasUpdatedWith isEqual:_backedTextInputView.attributedText]) {
259
+ if (_ignoreNextTextInputCall) {
260
260
  _ignoreNextTextInputCall = NO;
261
261
  return;
262
262
  }
263
- _lastStringStateWasUpdatedWith = _backedTextInputView.attributedText;
264
263
  _textDidChangeIsComing = NO;
265
264
  [_backedTextInputView.textInputDelegate textInputDidChange];
266
265
  }
267
266
 
268
267
  - (void)textViewDidChangeSelection:(__unused UITextView *)textView
269
268
  {
270
- if (![_lastStringStateWasUpdatedWith isEqual:_backedTextInputView.attributedText]) {
269
+ if (_lastStringStateWasUpdatedWith && ![_lastStringStateWasUpdatedWith isEqual:_backedTextInputView.attributedText]) {
271
270
  [self textViewDidChange:_backedTextInputView];
272
271
  _ignoreNextTextInputCall = YES;
273
272
  }
273
+ _lastStringStateWasUpdatedWith = _backedTextInputView.attributedText;
274
274
  [self textViewProbablyDidChangeSelection];
275
275
  }
276
276
 
@@ -58,6 +58,11 @@ const Platform = {
58
58
  return this.constants.interfaceIdiom === 'tv';
59
59
  },
60
60
  // $FlowFixMe[unsafe-getters-setters]
61
+ get isTVOS(): boolean {
62
+ // $FlowFixMe[object-this-reference]
63
+ return this.constants.interfaceIdiom === 'tv';
64
+ },
65
+ // $FlowFixMe[unsafe-getters-setters]
61
66
  get isTesting(): boolean {
62
67
  if (__DEV__) {
63
68
  // $FlowFixMe[object-this-reference]
@@ -23,7 +23,7 @@ NSDictionary* RCTGetReactNativeVersion(void)
23
23
  __rnVersion = @{
24
24
  RCTVersionMajor: @(0),
25
25
  RCTVersionMinor: @(71),
26
- RCTVersionPatch: @(7),
26
+ RCTVersionPatch: @(8),
27
27
  RCTVersionPrerelease: @"0rc0",
28
28
  };
29
29
  });
@@ -1,4 +1,4 @@
1
- VERSION_NAME=0.71.7-0rc0
1
+ VERSION_NAME=0.71.8-0rc0
2
2
 
3
3
  # GROUP=com.facebook.react
4
4
  # Group for the TV repo
@@ -17,6 +17,6 @@ public class ReactNativeVersion {
17
17
  public static final Map<String, Object> VERSION = MapBuilder.<String, Object>of(
18
18
  "major", 0,
19
19
  "minor", 71,
20
- "patch", 7,
20
+ "patch", 8,
21
21
  "prerelease", "0rc0");
22
22
  }
@@ -17,7 +17,7 @@ namespace facebook::react {
17
17
  constexpr struct {
18
18
  int32_t Major = 0;
19
19
  int32_t Minor = 71;
20
- int32_t Patch = 7;
20
+ int32_t Patch = 8;
21
21
  std::string_view Prerelease = "0rc0";
22
22
  } ReactNativeVersion;
23
23
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-native-tvos",
3
- "version": "0.71.7-0rc0",
3
+ "version": "0.71.8-0rc0",
4
4
  "bin": "./cli.js",
5
5
  "description": "A framework for building native apps using React",
6
6
  "license": "MIT",
@@ -73,6 +73,7 @@
73
73
  "!template/package-lock.json",
74
74
  "!template/yarn.lock",
75
75
  "third-party-podspecs",
76
+ "tvos-types.d.ts",
76
77
  "types"
77
78
  ],
78
79
  "scripts": {
@@ -140,7 +141,7 @@
140
141
  "pretty-format": "^26.5.2",
141
142
  "promise": "^8.3.0",
142
143
  "react-devtools-core": "^4.26.1",
143
- "react-native-gradle-plugin": "^0.71.17",
144
+ "react-native-gradle-plugin": "^0.71.18",
144
145
  "react-refresh": "^0.4.0",
145
146
  "react-shallow-renderer": "^16.15.0",
146
147
  "regenerator-runtime": "^0.13.2",
@@ -195,7 +196,7 @@
195
196
  "mkdirp": "^0.5.1",
196
197
  "mock-fs": "^5.1.4",
197
198
  "prettier": "^2.4.1",
198
- "react-native-core": "npm:react-native@0.71.7",
199
+ "react-native-core": "npm:react-native@0.71.8",
199
200
  "shelljs": "^0.8.5",
200
201
  "signedsource": "^1.0.0",
201
202
  "typescript": "4.1.3",
Binary file
Binary file
Binary file
@@ -156,7 +156,7 @@ dependencies {
156
156
  // in gradle.properties for now
157
157
  // We also use the io.github.react-native-tvos group for the react-android and hermes-android dependencies
158
158
 
159
- implementation("io.github.react-native-tvos:react-android:${REACT_NATIVE_TV_VERSION_STRING}")
159
+ implementation("io.github.react-native-tvos:react-android")
160
160
 
161
161
  implementation("androidx.swiperefreshlayout:swiperefreshlayout:1.0.0")
162
162
 
@@ -167,7 +167,7 @@ dependencies {
167
167
 
168
168
  debugImplementation("com.facebook.flipper:flipper-fresco-plugin:${FLIPPER_VERSION}")
169
169
  if (hermesEnabled.toBoolean()) {
170
- implementation("io.github.react-native-tvos:hermes-android:${REACT_NATIVE_TV_VERSION_STRING}")
170
+ implementation("io.github.react-native-tvos:hermes-android")
171
171
  } else {
172
172
  implementation jscFlavor
173
173
  }
@@ -42,7 +42,3 @@ newArchEnabled=false
42
42
  # Use this property to enable or disable the Hermes JS engine.
43
43
  # If set to false, you will be using JSC instead.
44
44
  hermesEnabled=true
45
-
46
- # react-native-gradle-plugin does not yet set the version automatically
47
- # for the TV repo, so we set the version here
48
- REACT_NATIVE_TV_VERSION_STRING=0.71.7-0rc0
@@ -11,7 +11,7 @@
11
11
  },
12
12
  "dependencies": {
13
13
  "react": "18.2.0",
14
- "react-native": "npm:react-native-tvos@0.71.7-0rc0"
14
+ "react-native": "npm:react-native-tvos@0.71.8-0rc0"
15
15
  },
16
16
  "devDependencies": {
17
17
  "@babel/core": "^7.20.0",
@@ -0,0 +1,6 @@
1
+ /**
2
+ * Beginning in 0.71, it is no longer necessary to import this file
3
+ * in React Native TV apps using Typescript.
4
+ *
5
+ * TV types are now found in `./types/public/ReactNativeTVTypes.d.ts`
6
+ */
package/types/index.d.ts CHANGED
@@ -157,6 +157,8 @@ export * from './public/Insets';
157
157
  export * from './public/ReactNativeRenderer';
158
158
  export * from './public/ReactNativeTypes';
159
159
 
160
+ export * from './public/ReactNativeTVTypes';
161
+
160
162
  import type {ErrorUtils} from '../Libraries/vendor/core/ErrorUtils';
161
163
 
162
164
  declare global {
@@ -0,0 +1,192 @@
1
+ import React from 'react';
2
+ import { ViewProps, ScrollViewProps } from 'react-native';
3
+
4
+ declare module 'react-native' {
5
+ interface ViewProps {
6
+ /**
7
+ * TV next focus down (see documentation for the View component).
8
+ */
9
+ nextFocusDown?: number,
10
+
11
+ /**
12
+ * TV next focus forward (see documentation for the View component).
13
+ *
14
+ * @platform android
15
+ */
16
+ nextFocusForward?: number,
17
+
18
+ /**
19
+ * TV next focus left (see documentation for the View component).
20
+ */
21
+ nextFocusLeft?: number,
22
+
23
+ /**
24
+ * TV next focus right (see documentation for the View component).
25
+ */
26
+ nextFocusRight?: number,
27
+
28
+ /**
29
+ * TV next focus up (see documentation for the View component).
30
+ */
31
+ nextFocusUp?: number,
32
+ }
33
+
34
+ interface View {
35
+ requestTVFocus(): void;
36
+ }
37
+
38
+ export const useTVEventHandler: (handleEvent: (event: HWEvent) => void) => void;
39
+
40
+ export const TVEventControl: {
41
+ enableTVMenuKey(): void;
42
+ disableTVMenuKey(): void;
43
+ enableTVPanGesture(): void;
44
+ disableTVPanGesture(): void;
45
+ enableGestureHandlersCancelTouches(): void;
46
+ disableGestureHandlersCancelTouches(): void;
47
+ };
48
+
49
+ export type HWEvent = {
50
+ eventType: 'up' | 'down' | 'right' | 'left' | 'longUp' | 'longDown' | 'longRight' | 'longLeft' | 'blur' | 'focus' | 'pan' | string;
51
+ eventKeyAction?: -1 | 1 | 0 | number;
52
+ tag?: number;
53
+ body?: {
54
+ state: "Began" | "Changed" | "Ended",
55
+ x: number,
56
+ y: number,
57
+ velocityx: number,
58
+ velocityy: number
59
+ }
60
+ };
61
+
62
+ export class TVEventHandler {
63
+ enable<T extends React.Component<unknown>>(
64
+ component?: T,
65
+ callback?: (component: T, data: HWEvent) => void
66
+ ): void;
67
+ disable(): void;
68
+ }
69
+
70
+ export interface FocusGuideProps extends ViewProps {
71
+ /**
72
+ * If the view should be "visible". display "flex" if visible, otherwise "none".
73
+ * Defaults to true
74
+ */
75
+ enabled?: boolean;
76
+ /**
77
+ * Array of `Component`s to register as destinations with `UIFocusGuide`
78
+ */
79
+ destinations?: (null | number | React.Component<any, any> | React.ComponentClass<any>)[];
80
+ /**
81
+ * If true, `TVFocusGuide` will automatically manage focus for you.
82
+ * It will redirect the focus to the first focusable child on the first visit.
83
+ * It also remembers the last focused child and redirects the focus
84
+ * to it on the subsequent visits.
85
+ *
86
+ * `destinations` prop takes precedence over this prop when used together.
87
+ *
88
+ * @default false
89
+ */
90
+ autoFocus?: boolean;
91
+ /**
92
+ * Enables focus trapping for the focus guide (see README).
93
+ */
94
+ trapFocusUp?: boolean;
95
+ /**
96
+ * Enables focus trapping for the focus guide (see README).
97
+ */
98
+ trapFocusDown?: boolean;
99
+ /**
100
+ * Enables focus trapping for the focus guide (see README).
101
+ */
102
+ trapFocusLeft?: boolean;
103
+ /**
104
+ * Enables focus trapping for the focus guide (see README).
105
+ */
106
+ trapFocusRight?: boolean;
107
+ /**
108
+ * @deprecated Don't use it, no longer necessary.
109
+ */
110
+ safePadding?: 'both' | 'vertical' | 'horizontal' | null;
111
+ }
112
+
113
+ export type FocusGuideMethods = {
114
+ setDestinations: (
115
+ destinations: (React.ElementRef<HostComponent<unknown>> | null | undefined)[],
116
+ ) => void;
117
+ }
118
+
119
+ /**
120
+ * This component provides support for Apple's `UIFocusGuide` API,
121
+ * to help ensure that focusable controls can be navigated to,
122
+ * even if they are not directly in line with other controls on both tvOS and Android.
123
+ * An example is provided in `RNTester` that shows different ways of using this component.
124
+ * https://github.com/react-native-tvos/react-native-tvos/blob/tvos-v0.69.8/packages/rn-tester/js/examples/TVFocusGuide/TVFocusGuideAutoFocusExample.js
125
+ */
126
+ export const TVFocusGuideView: React.ForwardRefExoticComponent<FocusGuideProps & React.RefAttributes<View & FocusGuideMethods>>;
127
+ export interface TVTextScrollViewProps extends ScrollViewProps {
128
+ /**
129
+ * The duration of the scroll animation when a swipe is detected.
130
+ * Default value is 0.3 s
131
+ */
132
+ scrollDuration?: number;
133
+ /**
134
+ * Scrolling distance when a swipe is detected
135
+ * Default value is half the visible height (vertical scroller)
136
+ * or width (horizontal scroller)
137
+ */
138
+ pageSize?: number;
139
+ /**
140
+ * If true, will scroll to start when focus moves out past the beginning
141
+ * of the scroller
142
+ * Defaults to true
143
+ */
144
+ snapToStart?: boolean;
145
+ /**
146
+ * If true, will scroll to end when focus moves out past the end of the
147
+ * scroller
148
+ * Defaults to true
149
+ */
150
+ snapToEnd?: boolean;
151
+ /**
152
+ * Called when the scroller comes into focus (e.g. for highlighting)
153
+ */
154
+ onFocus?(evt: HWEvent): void;
155
+ /**
156
+ * Called when the scroller goes out of focus
157
+ */
158
+ onBlur?(evt: HWEvent): void;
159
+ }
160
+
161
+ export class TVTextScrollView extends React.Component<TVTextScrollViewProps> {}
162
+
163
+ export interface PressableStateCallbackType {
164
+ readonly focused: boolean;
165
+ }
166
+
167
+ export interface TouchableWithoutFeedbackPropsIOS {
168
+ /**
169
+ * *(Apple TV only)* TV preferred focus (see documentation for the View component).
170
+ *
171
+ * @platform ios
172
+ */
173
+ hasTVPreferredFocus?: boolean;
174
+
175
+ /**
176
+ * *(Apple TV only)* Object with properties to control Apple TV parallax effects.
177
+ *
178
+ * enabled: If true, parallax effects are enabled. Defaults to true.
179
+ * shiftDistanceX: Defaults to 2.0.
180
+ * shiftDistanceY: Defaults to 2.0.
181
+ * tiltAngle: Defaults to 0.05.
182
+ * magnification: Defaults to 1.0.
183
+ * pressMagnification: Defaults to 1.0.
184
+ * pressDuration: Defaults to 0.3.
185
+ * pressDelay: Defaults to 0.0.
186
+ *
187
+ * @platform ios
188
+ */
189
+ tvParallaxProperties?: TVParallaxProperties;
190
+ }
191
+
192
+ }