@react-native-oh/react-native-harmony 0.72.27-3 → 0.72.27-5

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.
@@ -40,8 +40,10 @@ let queue: Array<() => void> = [];
40
40
  // $FlowFixMe
41
41
  let singleOpQueue: Array<any> = [];
42
42
 
43
- // RNOH: patch
44
- const useSingleOpBatching = true; // while we do not use operationBatching we want to use logic for listening to events
43
+ const useSingleOpBatching =
44
+ Platform.OS === 'android' &&
45
+ !!NativeAnimatedModule?.queueAndExecuteBatchedOperations &&
46
+ ReactNativeFeatureFlags.animatedShouldUseSingleOp();
45
47
  let flushQueueTimeout = null;
46
48
 
47
49
  const eventListenerGetValueCallbacks: {
@@ -53,8 +55,40 @@ const eventListenerAnimationFinishedCallbacks: {
53
55
  let globalEventEmitterGetValueListener: ?EventSubscription = null;
54
56
  let globalEventEmitterAnimationFinishedListener: ?EventSubscription = null;
55
57
 
56
- // RNOH: patch
57
- const nativeOps = NativeAnimatedModule;
58
+ const nativeOps: ?typeof NativeAnimatedModule = useSingleOpBatching
59
+ ? ((function () {
60
+ const apis = [
61
+ 'createAnimatedNode', // 1
62
+ 'updateAnimatedNodeConfig', // 2
63
+ 'getValue', // 3
64
+ 'startListeningToAnimatedNodeValue', // 4
65
+ 'stopListeningToAnimatedNodeValue', // 5
66
+ 'connectAnimatedNodes', // 6
67
+ 'disconnectAnimatedNodes', // 7
68
+ 'startAnimatingNode', // 8
69
+ 'stopAnimation', // 9
70
+ 'setAnimatedNodeValue', // 10
71
+ 'setAnimatedNodeOffset', // 11
72
+ 'flattenAnimatedNodeOffset', // 12
73
+ 'extractAnimatedNodeOffset', // 13
74
+ 'connectAnimatedNodeToView', // 14
75
+ 'disconnectAnimatedNodeFromView', // 15
76
+ 'restoreDefaultValues', // 16
77
+ 'dropAnimatedNode', // 17
78
+ 'addAnimatedEventToView', // 18
79
+ 'removeAnimatedEventFromView', // 19
80
+ 'addListener', // 20
81
+ 'removeListener', // 21
82
+ ];
83
+ return apis.reduce<{[string]: number}>((acc, functionName, i) => {
84
+ // These indices need to be kept in sync with the indices in native (see NativeAnimatedModule in Java, or the equivalent for any other native platform).
85
+ // $FlowFixMe[prop-missing]
86
+ acc[functionName] = i + 1;
87
+ return acc;
88
+ }, {});
89
+ })(): $FlowFixMe)
90
+ : NativeAnimatedModule;
91
+
58
92
  /**
59
93
  * Wrappers around NativeAnimatedModule to provide flow and autocomplete support for
60
94
  * the native module methods, and automatic queue management on Android
@@ -132,11 +166,7 @@ const API = {
132
166
  // use RCTDeviceEventEmitter. This reduces overhead of sending lots of
133
167
  // JSI functions across to native code; but also, TM infrastructure currently
134
168
  // does not support packing a function into native arrays.
135
-
136
- // RNOH: patch
137
- for (let q = 0, l = singleOpQueue.length; q < l; q++) {
138
- singleOpQueue[q]();
139
- }
169
+ NativeAnimatedModule?.queueAndExecuteBatchedOperations?.(singleOpQueue);
140
170
  singleOpQueue.length = 0;
141
171
  } else {
142
172
  Platform.OS === 'android' &&
@@ -154,13 +184,18 @@ const API = {
154
184
  fn: Fn,
155
185
  ...args: Args
156
186
  ): void => {
187
+ if (useSingleOpBatching) {
188
+ // Get the command ID from the queued function, and push that ID and any arguments needed to execute the operation
189
+ // $FlowFixMe: surprise, fn is actually a number
190
+ singleOpQueue.push(fn, ...args);
191
+ return;
192
+ }
193
+
157
194
  // If queueing is explicitly on, *or* the queue has not yet
158
195
  // been flushed, use the queue. This is to prevent operations
159
196
  // from being executed out of order.
160
- // RNOH: patch
161
- const currentlyUsedQueue = useSingleOpBatching ? singleOpQueue : queue;
162
- if (queueOperations || currentlyUsedQueue.length !== 0) {
163
- currentlyUsedQueue.push(() => fn(...args));
197
+ if (queueOperations || queue.length !== 0) {
198
+ queue.push(() => fn(...args));
164
199
  } else {
165
200
  fn(...args);
166
201
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@react-native-oh/react-native-harmony",
3
- "version": "0.72.27-3",
3
+ "version": "0.72.27-5",
4
4
  "description": "",
5
5
  "publishConfig": {
6
6
  "registry": "https://registry.npmjs.org/",
@@ -49,7 +49,7 @@
49
49
  "./*.har"
50
50
  ],
51
51
  "dependencies": {
52
- "@react-native-oh/react-native-harmony-cli": "^0.0.26-3",
52
+ "@react-native-oh/react-native-harmony-cli": "^0.0.26-5",
53
53
  "colors": "^1.4.0",
54
54
  "fs-extra": "^11.1.1",
55
55
  "metro": "^0.76.3",
Binary file