react-native-windows 0.74.38 → 0.74.40

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.
@@ -1,5 +1,5 @@
1
1
  /*
2
- * Copyright (c) Facebook, Inc. and its affiliates.
2
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
3
3
  *
4
4
  * Licensed under the Apache License, Version 2.0 (the "License");
5
5
  * you may not use this file except in compliance with the License.
@@ -37,7 +37,6 @@ struct to_ascii_array {
37
37
  return data.data[index];
38
38
  }
39
39
  };
40
-
41
40
  template <uint64_t Base, typename Alphabet>
42
41
  alignas(kIsMobile ? sizeof(size_t) : hardware_constructive_interference_size)
43
42
  typename to_ascii_array<Base, Alphabet>::data_type_ const
@@ -92,13 +91,13 @@ extern template to_ascii_table<10, to_ascii_alphabet_upper>::data_type_ const
92
91
  extern template to_ascii_table<16, to_ascii_alphabet_upper>::data_type_ const
93
92
  to_ascii_table<16, to_ascii_alphabet_upper>::data;
94
93
 
95
- template <uint64_t Base, typename I>
94
+ template <uint64_t Base, typename Int>
96
95
  struct to_ascii_powers {
97
- static constexpr size_t size_(I v) {
96
+ static constexpr size_t size_(Int v) {
98
97
  return 1 + (v < Base ? 0 : size_(v / Base));
99
98
  }
100
- static constexpr size_t const size = size_(~I(0));
101
- using data_type_ = c_array<I, size>;
99
+ static constexpr size_t const size = size_(~Int(0));
100
+ using data_type_ = c_array<Int, size>;
102
101
  static constexpr data_type_ data_() {
103
102
  data_type_ result{};
104
103
  for (size_t i = 0; i < size; ++i) {
@@ -109,12 +108,14 @@ struct to_ascii_powers {
109
108
  // @lint-ignore CLANGTIDY
110
109
  static data_type_ const data;
111
110
  };
112
- template <uint64_t Base, typename I>
113
- constexpr size_t const to_ascii_powers<Base, I>::size;
114
- template <uint64_t Base, typename I>
111
+ #if FOLLY_CPLUSPLUS < 201703L
112
+ template <uint64_t Base, typename Int>
113
+ constexpr size_t const to_ascii_powers<Base, Int>::size;
114
+ #endif
115
+ template <uint64_t Base, typename Int>
115
116
  alignas(hardware_constructive_interference_size)
116
- typename to_ascii_powers<Base, I>::data_type_ const
117
- to_ascii_powers<Base, I>::data = to_ascii_powers<Base, I>::data_();
117
+ typename to_ascii_powers<Base, Int>::data_type_ const
118
+ to_ascii_powers<Base, Int>::data = to_ascii_powers<Base, Int>::data_();
118
119
 
119
120
  extern template to_ascii_powers<8, uint64_t>::data_type_ const
120
121
  to_ascii_powers<8, uint64_t>::data;
@@ -149,7 +150,7 @@ template <uint64_t Base>
149
150
  FOLLY_ALWAYS_INLINE size_t to_ascii_size_array(uint64_t v) {
150
151
  using powers = to_ascii_powers<Base, uint64_t>;
151
152
  for (size_t i = 0u; i < powers::size; ++i) {
152
- if (FOLLY_LIKELY(v < powers::data.data[i])) {
153
+ if (FOLLY_UNLIKELY(v < powers::data.data[i])) {
153
154
  return i + size_t(i == 0);
154
155
  }
155
156
  }
@@ -270,6 +271,15 @@ FOLLY_ALWAYS_INLINE size_t to_ascii_with_table(char* out, uint64_t v) {
270
271
  return size;
271
272
  }
272
273
 
274
+ // Assumes that size >= number of digits in v. If >, the result is left-padded
275
+ // with 0s.
276
+ template <uint64_t Base, typename Alphabet>
277
+ FOLLY_ALWAYS_INLINE void to_ascii_with_route(
278
+ char* outb, size_t size, uint64_t v) {
279
+ kIsMobile //
280
+ ? to_ascii_with_array<Base, Alphabet>(outb, size, v)
281
+ : to_ascii_with_table<Base, Alphabet>(outb, size, v);
282
+ }
273
283
  template <uint64_t Base, typename Alphabet>
274
284
  FOLLY_ALWAYS_INLINE size_t
275
285
  to_ascii_with_route(char* outb, char const* oute, uint64_t v) {
@@ -277,9 +287,7 @@ to_ascii_with_route(char* outb, char const* oute, uint64_t v) {
277
287
  if (FOLLY_UNLIKELY(oute < outb || size_t(oute - outb) < size)) {
278
288
  return 0;
279
289
  }
280
- kIsMobile //
281
- ? to_ascii_with_array<Base, Alphabet>(outb, size, v)
282
- : to_ascii_with_table<Base, Alphabet>(outb, size, v);
290
+ to_ascii_with_route<Base, Alphabet>(outb, size, v);
283
291
  return size;
284
292
  }
285
293
  template <uint64_t Base, typename Alphabet, size_t N>
@@ -1,5 +1,5 @@
1
1
  /*
2
- * Copyright (c) Facebook, Inc. and its affiliates.
2
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
3
3
  *
4
4
  * Licensed under the Apache License, Version 2.0 (the "License");
5
5
  * you may not use this file except in compliance with the License.
@@ -61,14 +61,14 @@ using to_ascii_alphabet_upper = to_ascii_alphabet<true>;
61
61
  // In base 10, u64 requires at most 20 bytes, u32 at most 10, u16 at most 5,
62
62
  // and u8 at most 3.
63
63
  /*
64
- template <uint64_t Base, typename I>
64
+ template <uint64_t Base, typename Int>
65
65
  FOLLY_INLINE_VARIABLE constexpr size_t to_ascii_size_max =
66
- detail::to_ascii_powers<Base, I>::size;
66
+ detail::to_ascii_powers<Base, Int>::size;
67
67
  */
68
68
  // to_ascii_size_max_decimal
69
69
  //
70
70
  // An alias to to_ascii_size_max<10>.
71
- template <typename I>
71
+ template <typename Int>
72
72
  FOLLY_INLINE_VARIABLE constexpr size_t to_ascii_size_max_decimal;
73
73
 
74
74
  template <>
@@ -170,7 +170,7 @@ size_t to_ascii_upper(char (&out)[N], uint64_t v) {
170
170
  //
171
171
  // An alias to to_ascii<10, false>.
172
172
  //
173
- // async-signals-afe
173
+ // async-signal-safe
174
174
  inline size_t to_ascii_decimal(char* outb, char const* oute, uint64_t v) {
175
175
  return to_ascii_lower<10>(outb, oute, v);
176
176
  }
@@ -6,7 +6,7 @@
6
6
  "Type": "git",
7
7
  "Git": {
8
8
  "RepositoryUrl": "https://github.com/facebook/folly",
9
- "CommitHash": "d62707bf4dc8c58bcc317260611b8cbe25c7f444"
9
+ "CommitHash": "234d39a36a43106747d10cc19efada72fd810dd3"
10
10
  }
11
11
  },
12
12
  "DevelopmentDependency": false
@@ -152,6 +152,7 @@ type ButtonProps = $ReadOnly<{|
152
152
  accessible?: ?boolean,
153
153
  accessibilityActions?: ?$ReadOnlyArray<AccessibilityActionInfo>,
154
154
  onAccessibilityAction?: ?(event: AccessibilityActionEvent) => mixed,
155
+ onAccessibilityTap?: ?() => void, // Windows
155
156
  accessibilityState?: ?AccessibilityState,
156
157
 
157
158
  /**
@@ -331,6 +332,7 @@ const Button: React.AbstractComponent<
331
332
  accessibilityHint,
332
333
  accessibilityLanguage,
333
334
  onAccessibilityAction,
335
+ onAccessibilityTap, // Windows
334
336
  tabIndex,
335
337
  } = props;
336
338
  const buttonStyles: Array<ViewStyleProp> = [styles.button];
@@ -389,6 +391,7 @@ const Button: React.AbstractComponent<
389
391
  accessibilityLanguage={accessibilityLanguage}
390
392
  accessibilityRole="button"
391
393
  accessibilityState={_accessibilityState}
394
+ onAccessibilityTap={onAccessibilityTap} // Windows
392
395
  importantForAccessibility={_importantForAccessibility}
393
396
  hasTVPreferredFocus={hasTVPreferredFocus}
394
397
  nextFocusDown={nextFocusDown}
@@ -116,25 +116,25 @@ struct CompTextHost : public winrt::implements<CompTextHost, ITextHost> {
116
116
 
117
117
  //@cmember Show the scroll bar
118
118
  BOOL TxShowScrollBar(INT fnBar, BOOL fShow) override {
119
- assert(false);
119
+ // assert(false);
120
120
  return {};
121
121
  }
122
122
 
123
123
  //@cmember Enable the scroll bar
124
124
  BOOL TxEnableScrollBar(INT fuSBFlags, INT fuArrowflags) override {
125
- assert(false);
125
+ // assert(false);
126
126
  return {};
127
127
  }
128
128
 
129
129
  //@cmember Set the scroll range
130
130
  BOOL TxSetScrollRange(INT fnBar, LONG nMinPos, INT nMaxPos, BOOL fRedraw) override {
131
- assert(false);
131
+ // assert(false);
132
132
  return {};
133
133
  }
134
134
 
135
135
  //@cmember Set the scroll position
136
136
  BOOL TxSetScrollPos(INT fnBar, INT nPos, BOOL fRedraw) override {
137
- assert(false);
137
+ // assert(false);
138
138
  return {};
139
139
  }
140
140
 
@@ -377,8 +377,11 @@ struct CompTextHost : public winrt::implements<CompTextHost, ITextHost> {
377
377
 
378
378
  //@cmember Get the bits representing requested scroll bars for the window
379
379
  HRESULT TxGetScrollBars(DWORD *pdwScrollBar) override {
380
- // TODO support scrolling
381
- *pdwScrollBar = 0;
380
+ if (m_outer->m_multiline) {
381
+ *pdwScrollBar = WS_VSCROLL | WS_HSCROLL | ES_AUTOVSCROLL | ES_AUTOHSCROLL;
382
+ } else {
383
+ *pdwScrollBar = WS_HSCROLL | ES_AUTOHSCROLL;
384
+ }
382
385
  return S_OK;
383
386
  }
384
387
 
@@ -1042,6 +1045,12 @@ void WindowsTextInputComponentView::updateProps(
1042
1045
  autoCapitalizeOnUpdateProps(oldTextInputProps.autoCapitalize, newTextInputProps.autoCapitalize);
1043
1046
  }
1044
1047
 
1048
+ if (oldTextInputProps.textAlign != newTextInputProps.textAlign) {
1049
+ // Let UpdateParaFormat() to refresh the text field with the new text alignment.
1050
+ m_propBitsMask |= TXTBIT_PARAFORMATCHANGE;
1051
+ m_propBits |= TXTBIT_PARAFORMATCHANGE;
1052
+ }
1053
+
1045
1054
  UpdatePropertyBits();
1046
1055
  }
1047
1056
 
@@ -1305,7 +1314,15 @@ void WindowsTextInputComponentView::UpdateParaFormat() noexcept {
1305
1314
  m_pf.cbSize = sizeof(PARAFORMAT2);
1306
1315
  m_pf.dwMask = PFM_ALL;
1307
1316
 
1308
- m_pf.wAlignment = PFA_LEFT;
1317
+ auto &textAlign = windowsTextInputProps().textAlign;
1318
+
1319
+ if (textAlign == facebook::react::TextAlignment::Center) {
1320
+ m_pf.wAlignment = PFA_CENTER;
1321
+ } else if (textAlign == facebook::react::TextAlignment::Right) {
1322
+ m_pf.wAlignment = PFA_RIGHT;
1323
+ } else {
1324
+ m_pf.wAlignment = PFA_LEFT;
1325
+ }
1309
1326
 
1310
1327
  m_pf.cTabCount = 1;
1311
1328
  m_pf.rgxTabs[0] = lDefaultTab;
@@ -1475,6 +1492,9 @@ WindowsTextInputComponentView::createVisual() noexcept {
1475
1492
  winrt::check_hresult(g_pfnCreateTextServices(nullptr, m_textHost.get(), spUnk.put()));
1476
1493
  spUnk.as(m_textServices);
1477
1494
 
1495
+ LRESULT res;
1496
+ winrt::check_hresult(m_textServices->TxSendMessage(EM_SETTEXTMODE, TM_PLAINTEXT, 0, &res));
1497
+
1478
1498
  m_caretVisual = m_compContext.CreateCaretVisual();
1479
1499
  visual.InsertAt(m_caretVisual.InnerVisual(), 0);
1480
1500
  m_caretVisual.IsVisible(false);
@@ -5,6 +5,8 @@
5
5
 
6
6
  #include "WindowsTextInputEventEmitter.h"
7
7
 
8
+ #include <react/renderer/core/graphicsConversions.h>
9
+
8
10
  namespace facebook::react {
9
11
 
10
12
  void WindowsTextInputEventEmitter::onChange(OnChange event) const {
@@ -46,4 +48,23 @@ void WindowsTextInputEventEmitter::onKeyPress(OnKeyPress event) const {
46
48
  });
47
49
  }
48
50
 
51
+ static jsi::Value textInputMetricsContentSizePayload(
52
+ jsi::Runtime &runtime,
53
+ const WindowsTextInputEventEmitter::OnContentSizeChange &event) {
54
+ auto payload = jsi::Object(runtime);
55
+ {
56
+ auto contentSize = jsi::Object(runtime);
57
+ contentSize.setProperty(runtime, "width", event.contentSize.width);
58
+ contentSize.setProperty(runtime, "height", event.contentSize.height);
59
+ payload.setProperty(runtime, "contentSize", contentSize);
60
+ }
61
+ return payload;
62
+ };
63
+
64
+ void WindowsTextInputEventEmitter::onContentSizeChange(OnContentSizeChange event) const {
65
+ dispatchEvent("textInputContentSizeChange", [event = std::move(event)](jsi::Runtime &runtime) {
66
+ return textInputMetricsContentSizePayload(runtime, event);
67
+ });
68
+ }
69
+
49
70
  } // namespace facebook::react
@@ -36,10 +36,16 @@ class WindowsTextInputEventEmitter : public ViewEventEmitter {
36
36
  std::string key;
37
37
  };
38
38
 
39
+ struct OnContentSizeChange {
40
+ int target;
41
+ facebook::react::Size contentSize;
42
+ };
43
+
39
44
  void onChange(OnChange value) const;
40
45
  void onSelectionChange(const OnSelectionChange &value) const;
41
46
  void onSubmitEditing(OnSubmitEditing value) const;
42
47
  void onKeyPress(OnKeyPress value) const;
48
+ void onContentSizeChange(OnContentSizeChange value) const;
43
49
  };
44
50
 
45
51
  } // namespace facebook::react
@@ -47,7 +47,10 @@ WindowsTextInputProps::WindowsTextInputProps(
47
47
  autoCapitalize(convertRawProp(context, rawProps, "autoCapitalize", sourceProps.autoCapitalize, {})),
48
48
  clearTextOnSubmit(convertRawProp(context, rawProps, "clearTextOnSubmit", sourceProps.clearTextOnSubmit, {false})),
49
49
  submitKeyEvents(convertRawProp(context, rawProps, "submitKeyEvents", sourceProps.submitKeyEvents, {})),
50
- autoFocus(convertRawProp(context, rawProps, "autoFocus", sourceProps.autoFocus, {false})) {}
50
+ autoFocus(convertRawProp(context, rawProps, "autoFocus", sourceProps.autoFocus, {false})),
51
+ textAlign(
52
+ convertRawProp(context, rawProps, "textAlign", sourceProps.textAlign, facebook::react::TextAlignment::Left)) {
53
+ }
51
54
 
52
55
  void WindowsTextInputProps::setProp(
53
56
  const PropsParserContext &context,
@@ -4,6 +4,7 @@
4
4
  #pragma once
5
5
 
6
6
  #include <react/components/rnwcore/Props.h>
7
+ #include <react/renderer/attributedstring/conversions.h>
7
8
  #include <react/renderer/components/text/BaseTextProps.h>
8
9
  #include <react/renderer/core/propsConversions.h>
9
10
 
@@ -118,6 +119,7 @@ class WindowsTextInputProps final : public ViewProps, public BaseTextProps {
118
119
  bool clearTextOnSubmit{false};
119
120
  std::vector<CompWindowsTextInputSubmitKeyEventsStruct> submitKeyEvents{};
120
121
  bool autoFocus{false};
122
+ facebook::react::TextAlignment textAlign{};
121
123
  };
122
124
 
123
125
  } // namespace facebook::react
@@ -158,11 +158,10 @@ Size WindowsTextInputShadowNode::measureContent(
158
158
  const LayoutContext &layoutContext,
159
159
  const LayoutConstraints &layoutConstraints) const {
160
160
  if (getStateData().cachedAttributedStringId != 0) {
161
+ facebook::react::ParagraphAttributes paragraphAttributes{};
162
+ paragraphAttributes.maximumNumberOfLines = getConcreteProps().multiline ? 0 : 1;
161
163
  return m_textLayoutManager
162
- ->measureCachedSpannableById(
163
- getStateData().cachedAttributedStringId,
164
- {}, // TODO getConcreteProps().paragraphAttributes
165
- layoutConstraints)
164
+ ->measureCachedSpannableById(getStateData().cachedAttributedStringId, paragraphAttributes, layoutConstraints)
166
165
  .size;
167
166
  }
168
167
 
@@ -183,13 +182,11 @@ Size WindowsTextInputShadowNode::measureContent(
183
182
 
184
183
  TextLayoutContext textLayoutContext;
185
184
  textLayoutContext.pointScaleFactor = layoutContext.pointScaleFactor;
185
+ facebook::react::ParagraphAttributes paragraphAttributes{};
186
+ paragraphAttributes.maximumNumberOfLines = getConcreteProps().multiline ? 0 : 1;
186
187
  return m_textLayoutManager
187
188
  ->measure(
188
- AttributedStringBox{attributedString},
189
- {}, // TODO getConcreteProps().paragraphAttributes,
190
- textLayoutContext,
191
- layoutConstraints,
192
- nullptr)
189
+ AttributedStringBox{attributedString}, paragraphAttributes, textLayoutContext, layoutConstraints, nullptr)
193
190
  .size;
194
191
  }
195
192
 
@@ -50,7 +50,6 @@ void AnimationDriver::StartAnimation() {
50
50
  animatedValue->PropertySet().StartAnimation(ValueAnimatedNode::s_valueName, animation);
51
51
  animatedValue->AddActiveAnimation(m_id);
52
52
  }
53
- scopedBatch.End();
54
53
 
55
54
  m_scopedBatchCompletedToken = scopedBatch.Completed(
56
55
  [weakSelf = weak_from_this(), weakManager = m_manager, id = m_id, tag = m_animatedValueTag](auto sender, auto) {
@@ -74,6 +73,8 @@ void AnimationDriver::StartAnimation() {
74
73
  }
75
74
  });
76
75
 
76
+ scopedBatch.End();
77
+
77
78
  m_animation = animation;
78
79
  m_scopedBatch = scopedBatch;
79
80
  }
@@ -10,11 +10,11 @@
10
10
  -->
11
11
  <Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
12
12
  <PropertyGroup>
13
- <ReactNativeWindowsVersion>0.74.38</ReactNativeWindowsVersion>
13
+ <ReactNativeWindowsVersion>0.74.40</ReactNativeWindowsVersion>
14
14
  <ReactNativeWindowsMajor>0</ReactNativeWindowsMajor>
15
15
  <ReactNativeWindowsMinor>74</ReactNativeWindowsMinor>
16
- <ReactNativeWindowsPatch>38</ReactNativeWindowsPatch>
16
+ <ReactNativeWindowsPatch>40</ReactNativeWindowsPatch>
17
17
  <ReactNativeWindowsCanary>false</ReactNativeWindowsCanary>
18
- <ReactNativeWindowsCommitId>0438560b807679d6b74c3410fe2b9502300256ba</ReactNativeWindowsCommitId>
18
+ <ReactNativeWindowsCommitId>bd26f3b61d1f46e15b9f85ef16c46744db8f33e5</ReactNativeWindowsCommitId>
19
19
  </PropertyGroup>
20
20
  </Project>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-native-windows",
3
- "version": "0.74.38",
3
+ "version": "0.74.40",
4
4
  "license": "MIT",
5
5
  "repository": {
6
6
  "type": "git",