@office-iss/react-native-win32 0.0.0-canary.301 → 0.0.0-canary.303
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.
- package/.flowconfig +2 -2
- package/CHANGELOG.json +49 -1
- package/CHANGELOG.md +24 -5
- package/IntegrationTests/IntegrationTestsApp.js +1 -1
- package/IntegrationTests/LayoutEventsTest.js +3 -3
- package/Libraries/ActionSheetIOS/ActionSheetIOS.js +3 -3
- package/Libraries/Alert/RCTAlertManager.android.js +2 -2
- package/Libraries/Animated/AnimatedEvent.js +1 -1
- package/Libraries/Animated/AnimatedImplementation.js +2 -2
- package/Libraries/Animated/AnimatedMock.js +1 -1
- package/Libraries/Animated/NativeAnimatedAllowlist.js +1 -0
- package/Libraries/Animated/animations/Animation.js +5 -6
- package/Libraries/Animated/components/AnimatedScrollView.js +1 -1
- package/Libraries/Animated/nodes/AnimatedColor.js +9 -9
- package/Libraries/Animated/nodes/AnimatedInterpolation.js +4 -4
- package/Libraries/Animated/nodes/AnimatedProps.js +2 -2
- package/Libraries/Animated/nodes/AnimatedStyle.js +6 -4
- package/Libraries/Animated/nodes/AnimatedTransform.js +1 -1
- package/Libraries/AppState/AppState.js +5 -1
- package/Libraries/BatchedBridge/NativeModules.js +1 -1
- package/Libraries/Blob/BlobManager.js +1 -1
- package/Libraries/Components/AccessibilityInfo/AccessibilityInfo.js +1 -1
- package/Libraries/Components/AccessibilityInfo/AccessibilityInfo.win32.js +1 -1
- package/Libraries/Components/Button.js +1 -1
- package/Libraries/Components/Button.win32.js +1 -1
- package/Libraries/Components/Pressable/useAndroidRippleForView.js +2 -2
- package/Libraries/Components/ScrollView/ScrollView.js +3 -2
- package/Libraries/Components/ScrollView/ScrollViewStickyHeader.js +1 -1
- package/Libraries/Components/TextInput/TextInput.flow.js +12 -5
- package/Libraries/Components/TextInput/TextInput.flow.win32.js +12 -5
- package/Libraries/Components/TextInput/TextInput.js +9 -4
- package/Libraries/Components/TextInput/TextInput.win32.js +9 -6
- package/Libraries/Components/TextInput/Win32TextInputNativeComponent.js +2 -3
- package/Libraries/Components/Touchable/TouchableWithoutFeedback.js +1 -1
- package/Libraries/Components/View/View.win32.js +3 -1
- package/Libraries/Core/Devtools/loadBundleFromServer.js +1 -1
- package/Libraries/Core/Devtools/loadBundleFromServer.win32.js +1 -1
- package/Libraries/Core/ExceptionsManager.js +2 -2
- package/Libraries/Core/ReactFiberErrorDialog.js +3 -3
- package/Libraries/Core/ReactNativeVersion.js +1 -1
- package/Libraries/Core/Timers/JSTimers.js +1 -1
- package/Libraries/Core/Timers/immediateShim.js +1 -1
- package/Libraries/Debugging/DebuggingOverlayRegistry.js +5 -3
- package/Libraries/Image/Image.android.js +318 -111
- package/Libraries/Image/ImageSourceUtils.js +8 -2
- package/Libraries/Image/resolveAssetSource.js +1 -1
- package/Libraries/Interaction/InteractionManager.js +1 -1
- package/Libraries/Interaction/PanResponder.js +1 -1
- package/Libraries/Lists/FlatList.js +5 -6
- package/Libraries/LogBox/Data/LogBoxData.js +1 -1
- package/Libraries/LogBox/Data/parseLogBoxLog.js +1 -1
- package/Libraries/LogBox/UI/LogBoxInspectorSourceMapStatus.js +1 -1
- package/Libraries/LogBox/UI/LogBoxInspectorSourceMapStatus.win32.js +1 -1
- package/Libraries/Modal/Modal.js +2 -2
- package/Libraries/NativeComponent/NativeComponentRegistry.js +1 -1
- package/Libraries/NativeComponent/ViewConfig.js +1 -1
- package/Libraries/Network/RCTNetworking.android.js +1 -1
- package/Libraries/Network/RCTNetworking.ios.js +1 -1
- package/Libraries/Network/RCTNetworking.win32.js +1 -1
- package/Libraries/Network/convertRequestBody.js +1 -1
- package/Libraries/PermissionsAndroid/PermissionsAndroid.js +10 -9
- package/Libraries/Pressability/HoverState.js +2 -0
- package/Libraries/Pressability/HoverState.win32.js +2 -0
- package/Libraries/PushNotificationIOS/PushNotificationIOS.js +2 -2
- package/Libraries/ReactNative/ReactFabricPublicInstance/ReactFabricHostComponent.js +2 -0
- package/Libraries/ReactNative/ReactFabricPublicInstance/ReactFabricPublicInstance.js +3 -3
- package/Libraries/ReactNative/RendererImplementation.js +116 -116
- package/Libraries/ReactNative/UIManager.js +3 -3
- package/Libraries/ReactPrivate/ReactNativePrivateInterface.js +1 -1
- package/Libraries/Renderer/shims/ReactFabric.js +1 -3
- package/Libraries/Renderer/shims/ReactFeatureFlags.js +1 -3
- package/Libraries/Renderer/shims/ReactNative.js +1 -3
- package/Libraries/Renderer/shims/ReactNativeViewConfigRegistry.js +1 -3
- package/Libraries/Renderer/shims/createReactNativeComponentClass.js +1 -3
- package/Libraries/StyleSheet/PlatformColorValueTypes.android.js +2 -2
- package/Libraries/StyleSheet/PlatformColorValueTypes.ios.js +2 -2
- package/Libraries/StyleSheet/PlatformColorValueTypes.win32.js +4 -0
- package/Libraries/StyleSheet/flattenStyle.js +2 -2
- package/Libraries/StyleSheet/splitLayoutProps.js +2 -2
- package/Libraries/Text/Text.js +509 -235
- package/Libraries/Text/Text.win32.js +622 -275
- package/Libraries/Text/TextNativeComponent.js +2 -2
- package/Libraries/Text/TextNativeComponent.win32.js +2 -2
- package/Libraries/Utilities/HMRClient.js +0 -1
- package/Libraries/Utilities/Platform.android.js +3 -3
- package/Libraries/Utilities/Platform.d.ts +1 -0
- package/Libraries/Utilities/Platform.ios.js +1 -1
- package/Libraries/Utilities/Platform.win32.js +3 -3
- package/Libraries/Utilities/PlatformTypes.js +1 -1
- package/Libraries/Utilities/ReactNativeTestTools.js +12 -0
- package/Libraries/Utilities/codegenNativeCommands.js +1 -1
- package/Libraries/Utilities/codegenNativeComponent.js +1 -1
- package/Libraries/Utilities/differ/pointsDiffer.js +1 -1
- package/Libraries/vendor/emitter/EventEmitter.js +1 -1
- package/index.js +3 -0
- package/index.win32.js +4 -0
- package/jest/local-setup.js +2 -2
- package/jest/mock.js +1 -1
- package/jest/mockComponent.js +8 -8
- package/jest/mockNativeComponent.js +3 -2
- package/jest/mocks/Modal.js +1 -1
- package/jest/mocks/ScrollView.js +1 -1
- package/jest/mocks/ViewNativeComponent.js +1 -1
- package/jest/setup.js +12 -12
- package/overrides.json +16 -16
- package/package.json +12 -12
- package/src/private/animated/NativeAnimatedHelper.js +3 -3
- package/src/private/animated/NativeAnimatedHelper.win32.js +3 -3
- package/src/private/animated/createAnimatedPropsHook.js +9 -11
- package/src/private/animated/createAnimatedPropsMemoHook.js +6 -6
- package/src/private/components/virtualview/VirtualView.js +7 -4
- package/src/private/components/virtualview/VirtualViewNativeComponent.js +6 -0
- package/src/private/devsupport/devmenu/elementinspector/Inspector.js +2 -2
- package/src/private/featureflags/ReactNativeFeatureFlags.js +9 -8
- package/src/private/featureflags/specs/NativeReactNativeFeatureFlags.js +1 -2
- package/src/private/renderer/errorhandling/ErrorHandlers.js +3 -3
- package/src/private/types/HostInstance.js +4 -1
- package/src/private/webapis/dom/nodes/ReactNativeDocument.js +22 -2
- package/src/private/webapis/dom/nodes/ReactNativeElement.js +1 -1
- package/src/private/webapis/dom/nodes/ReadOnlyElement.js +5 -3
- package/src/private/webapis/dom/nodes/ReadOnlyNode.js +16 -13
- package/src/private/webapis/dom/nodes/internals/NodeInternals.js +45 -22
- package/src/private/webapis/dom/nodes/internals/ReactNativeDocumentInstanceHandle.js +1 -1
- package/src/private/webapis/dom/nodes/specs/NativeDOM.js +26 -192
- package/src/private/webapis/dom/oldstylecollections/HTMLCollection.js +14 -11
- package/src/private/webapis/dom/oldstylecollections/NodeList.js +13 -10
- package/src/private/webapis/geometry/DOMRectList.js +1 -1
- package/src/private/webapis/mutationobserver/internals/MutationObserverManager.js +1 -1
- package/src/private/webapis/performance/EventTiming.js +1 -1
- package/src/private/webapis/performance/Performance.js +12 -30
- package/src/private/webapis/performance/specs/NativePerformance.js +4 -4
- package/src/private/webapis/structuredClone/structuredClone.js +9 -9
|
@@ -13,9 +13,7 @@ import type {Node as ShadowNode} from '../../../../../../Libraries/Renderer/shim
|
|
|
13
13
|
import type {TurboModule} from '../../../../../../Libraries/TurboModule/RCTExport';
|
|
14
14
|
import type {InstanceHandle} from '../internals/NodeInternals';
|
|
15
15
|
|
|
16
|
-
import {getFabricUIManager} from '../../../../../../Libraries/ReactNative/FabricUIManager';
|
|
17
16
|
import * as TurboModuleRegistry from '../../../../../../Libraries/TurboModule/TurboModuleRegistry';
|
|
18
|
-
import nullthrows from 'nullthrows';
|
|
19
17
|
|
|
20
18
|
export opaque type NativeElementReference = ShadowNode;
|
|
21
19
|
export opaque type NativeTextReference = ShadowNode;
|
|
@@ -62,6 +60,11 @@ export interface Spec extends TurboModule {
|
|
|
62
60
|
nativeNodeReference: mixed /* NativeNodeReference */,
|
|
63
61
|
) => $ReadOnlyArray<mixed> /* $ReadOnlyArray<InstanceHandle> */;
|
|
64
62
|
|
|
63
|
+
+getElementById?: (
|
|
64
|
+
nativeNodeReference: mixed /* NativeNodeReference */,
|
|
65
|
+
id: string,
|
|
66
|
+
) => mixed /* ?InstanceHandle */;
|
|
67
|
+
|
|
65
68
|
+getParentNode: (
|
|
66
69
|
nativeNodeReference: mixed /* NativeNodeReference */,
|
|
67
70
|
) => mixed /* ?InstanceHandle */;
|
|
@@ -160,18 +163,12 @@ export interface Spec extends TurboModule {
|
|
|
160
163
|
* Legacy direct manipulation APIs (for `ReactNativeElement`).
|
|
161
164
|
*/
|
|
162
165
|
|
|
163
|
-
+setNativeProps
|
|
166
|
+
+setNativeProps: (
|
|
164
167
|
nativeElementReference: mixed,
|
|
165
168
|
updatePayload: mixed,
|
|
166
169
|
) => void;
|
|
167
170
|
}
|
|
168
171
|
|
|
169
|
-
const RawNativeDOM = (TurboModuleRegistry.get<Spec>('NativeDOMCxx'): ?Spec);
|
|
170
|
-
|
|
171
|
-
export function getRawNativeDOMForTests(): ?Spec {
|
|
172
|
-
return RawNativeDOM;
|
|
173
|
-
}
|
|
174
|
-
|
|
175
172
|
// This is the actual interface of this module, but the native module codegen
|
|
176
173
|
// isn't expressive enough yet.
|
|
177
174
|
export interface RefinedSpec {
|
|
@@ -204,6 +201,15 @@ export interface RefinedSpec {
|
|
|
204
201
|
nativeNodeReference: NativeNodeReference,
|
|
205
202
|
) => $ReadOnlyArray<InstanceHandle>;
|
|
206
203
|
|
|
204
|
+
/**
|
|
205
|
+
* This is a React Native implementation of `Document.prototype.getElementById`
|
|
206
|
+
* (see https://developer.mozilla.org/en-US/docs/Web/API/Document/getElementById).
|
|
207
|
+
*
|
|
208
|
+
* If the document is active and contains an element with the given ID, it
|
|
209
|
+
* returns the instance handle of that element. Otherwise, it returns `null`.
|
|
210
|
+
*/
|
|
211
|
+
+getElementById: (rootTag: RootTag, id: string) => ?InstanceHandle;
|
|
212
|
+
|
|
207
213
|
/**
|
|
208
214
|
* This is a React Native implementation of `Node.prototype.parentNode`
|
|
209
215
|
* (see https://developer.mozilla.org/en-US/docs/Web/API/Node/parentNode).
|
|
@@ -432,186 +438,14 @@ export interface RefinedSpec {
|
|
|
432
438
|
) => void;
|
|
433
439
|
}
|
|
434
440
|
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
getChildNodes(nativeNodeReference) {
|
|
448
|
-
// $FlowExpectedError[incompatible-cast]
|
|
449
|
-
return (nullthrows(RawNativeDOM).getChildNodes(
|
|
450
|
-
nativeNodeReference,
|
|
451
|
-
): $ReadOnlyArray<InstanceHandle>);
|
|
452
|
-
},
|
|
453
|
-
|
|
454
|
-
getParentNode(nativeNodeReference) {
|
|
455
|
-
// $FlowExpectedError[incompatible-cast]
|
|
456
|
-
return (nullthrows(RawNativeDOM).getParentNode(
|
|
457
|
-
nativeNodeReference,
|
|
458
|
-
): ?InstanceHandle);
|
|
459
|
-
},
|
|
460
|
-
|
|
461
|
-
isConnected(nativeNodeReference) {
|
|
462
|
-
return nullthrows(RawNativeDOM).isConnected(nativeNodeReference);
|
|
463
|
-
},
|
|
464
|
-
|
|
465
|
-
/*
|
|
466
|
-
* Methods from the `Element` interface (for `ReactNativeElement`).
|
|
467
|
-
*/
|
|
468
|
-
|
|
469
|
-
getBorderWidth(nativeNodeReference) {
|
|
470
|
-
// $FlowExpectedError[incompatible-cast]
|
|
471
|
-
return (nullthrows(RawNativeDOM).getBorderWidth(
|
|
472
|
-
nativeNodeReference,
|
|
473
|
-
): $ReadOnly<
|
|
474
|
-
[
|
|
475
|
-
/* topWidth: */ number,
|
|
476
|
-
/* rightWidth: */ number,
|
|
477
|
-
/* bottomWidth: */ number,
|
|
478
|
-
/* leftWidth: */ number,
|
|
479
|
-
],
|
|
480
|
-
>);
|
|
481
|
-
},
|
|
482
|
-
|
|
483
|
-
getBoundingClientRect(nativeNodeReference, includeTransform: boolean) {
|
|
484
|
-
// $FlowExpectedError[incompatible-cast]
|
|
485
|
-
return (nullthrows(RawNativeDOM).getBoundingClientRect(
|
|
486
|
-
nativeNodeReference,
|
|
487
|
-
includeTransform,
|
|
488
|
-
): $ReadOnly<
|
|
489
|
-
[
|
|
490
|
-
/* x: */ number,
|
|
491
|
-
/* y: */ number,
|
|
492
|
-
/* width: */ number,
|
|
493
|
-
/* height: */ number,
|
|
494
|
-
],
|
|
495
|
-
>);
|
|
496
|
-
},
|
|
497
|
-
|
|
498
|
-
getInnerSize(nativeNodeReference) {
|
|
499
|
-
// $FlowExpectedError[incompatible-cast]
|
|
500
|
-
return (nullthrows(RawNativeDOM).getInnerSize(
|
|
501
|
-
nativeNodeReference,
|
|
502
|
-
): $ReadOnly<[/* width: */ number, /* height: */ number]>);
|
|
503
|
-
},
|
|
504
|
-
|
|
505
|
-
getScrollPosition(nativeNodeReference) {
|
|
506
|
-
// $FlowExpectedError[incompatible-cast]
|
|
507
|
-
return (nullthrows(RawNativeDOM).getScrollPosition(
|
|
508
|
-
nativeNodeReference,
|
|
509
|
-
): $ReadOnly<[/* scrollLeft: */ number, /* scrollTop: */ number]>);
|
|
510
|
-
},
|
|
511
|
-
|
|
512
|
-
getScrollSize(nativeNodeReference) {
|
|
513
|
-
// $FlowExpectedError[incompatible-cast]
|
|
514
|
-
return (nullthrows(RawNativeDOM).getScrollSize(
|
|
515
|
-
nativeNodeReference,
|
|
516
|
-
): $ReadOnly<[/* scrollWidth: */ number, /* scrollHeight: */ number]>);
|
|
517
|
-
},
|
|
518
|
-
|
|
519
|
-
getTagName(nativeNodeReference) {
|
|
520
|
-
return nullthrows(RawNativeDOM).getTagName(nativeNodeReference);
|
|
521
|
-
},
|
|
522
|
-
|
|
523
|
-
getTextContent(nativeNodeReference) {
|
|
524
|
-
return nullthrows(RawNativeDOM).getTextContent(nativeNodeReference);
|
|
525
|
-
},
|
|
526
|
-
|
|
527
|
-
hasPointerCapture(nativeNodeReference, pointerId) {
|
|
528
|
-
return nullthrows(RawNativeDOM).hasPointerCapture(
|
|
529
|
-
nativeNodeReference,
|
|
530
|
-
pointerId,
|
|
531
|
-
);
|
|
532
|
-
},
|
|
533
|
-
|
|
534
|
-
releasePointerCapture(nativeNodeReference, pointerId) {
|
|
535
|
-
return nullthrows(RawNativeDOM).releasePointerCapture(
|
|
536
|
-
nativeNodeReference,
|
|
537
|
-
pointerId,
|
|
538
|
-
);
|
|
539
|
-
},
|
|
540
|
-
|
|
541
|
-
setPointerCapture(nativeNodeReference, pointerId) {
|
|
542
|
-
return nullthrows(RawNativeDOM).setPointerCapture(
|
|
543
|
-
nativeNodeReference,
|
|
544
|
-
pointerId,
|
|
545
|
-
);
|
|
546
|
-
},
|
|
547
|
-
|
|
548
|
-
/*
|
|
549
|
-
* Methods from the `HTMLElement` interface (for `ReactNativeElement`).
|
|
550
|
-
*/
|
|
551
|
-
|
|
552
|
-
getOffset(nativeNodeReference) {
|
|
553
|
-
// $FlowExpectedError[incompatible-cast]
|
|
554
|
-
return (nullthrows(RawNativeDOM).getOffset(nativeNodeReference): $ReadOnly<
|
|
555
|
-
[
|
|
556
|
-
/* offsetParent: */ ?InstanceHandle,
|
|
557
|
-
/* top: */ number,
|
|
558
|
-
/* left: */ number,
|
|
559
|
-
],
|
|
560
|
-
>);
|
|
561
|
-
},
|
|
562
|
-
|
|
563
|
-
/*
|
|
564
|
-
* Special methods to handle the root node.
|
|
565
|
-
*/
|
|
566
|
-
|
|
567
|
-
linkRootNode(rootTag, instanceHandle) {
|
|
568
|
-
// $FlowExpectedError[incompatible-cast]
|
|
569
|
-
return (nullthrows(RawNativeDOM?.linkRootNode)(
|
|
570
|
-
// $FlowExpectedError[incompatible-call]
|
|
571
|
-
rootTag,
|
|
572
|
-
instanceHandle,
|
|
573
|
-
): ?NativeElementReference);
|
|
574
|
-
},
|
|
575
|
-
|
|
576
|
-
/**
|
|
577
|
-
* Legacy layout APIs
|
|
578
|
-
*/
|
|
579
|
-
|
|
580
|
-
measure(nativeNodeReference, callback) {
|
|
581
|
-
return nullthrows(RawNativeDOM).measure(nativeNodeReference, callback);
|
|
582
|
-
},
|
|
583
|
-
|
|
584
|
-
measureInWindow(nativeNodeReference, callback) {
|
|
585
|
-
return nullthrows(RawNativeDOM).measureInWindow(
|
|
586
|
-
nativeNodeReference,
|
|
587
|
-
callback,
|
|
588
|
-
);
|
|
589
|
-
},
|
|
590
|
-
|
|
591
|
-
measureLayout(nativeNodeReference, relativeNode, onFail, onSuccess) {
|
|
592
|
-
return nullthrows(RawNativeDOM).measureLayout(
|
|
593
|
-
nativeNodeReference,
|
|
594
|
-
relativeNode,
|
|
595
|
-
onFail,
|
|
596
|
-
onSuccess,
|
|
597
|
-
);
|
|
598
|
-
},
|
|
599
|
-
|
|
600
|
-
/**
|
|
601
|
-
* Legacy direct manipulation APIs
|
|
602
|
-
*/
|
|
603
|
-
setNativeProps(nativeNodeReference, updatePayload) {
|
|
604
|
-
// TODO: remove when RawNativeDOM.setNativeProps is NOT nullable.
|
|
605
|
-
if (RawNativeDOM?.setNativeProps == null) {
|
|
606
|
-
nullthrows(getFabricUIManager()).setNativeProps(
|
|
607
|
-
nativeNodeReference,
|
|
608
|
-
updatePayload,
|
|
609
|
-
);
|
|
610
|
-
return;
|
|
611
|
-
}
|
|
612
|
-
|
|
613
|
-
return RawNativeDOM.setNativeProps(nativeNodeReference, updatePayload);
|
|
614
|
-
},
|
|
615
|
-
};
|
|
616
|
-
|
|
617
|
-
export default NativeDOM;
|
|
441
|
+
// We used to implement all methods in RefineSpec, manually refining the types
|
|
442
|
+
// for all methods. However, this is slower as every call to the native module
|
|
443
|
+
// requires an additional call only to handle types. Instead, we do an unsafe
|
|
444
|
+
// casting here. Keep in mind that:
|
|
445
|
+
// 1. We use `get` and not `getEnforcing` because we don't want to fail when
|
|
446
|
+
// the module is evaluated, only when used. This is necessary because we
|
|
447
|
+
// don't use inline requires within the `react-native` package and some code
|
|
448
|
+
// might end up loading this but not using it.
|
|
449
|
+
// 2. We lose automatic backwards compatibility checks because of this.
|
|
450
|
+
// $FlowExpectedError[incompatible-type]
|
|
451
|
+
export default (TurboModuleRegistry.get<Spec>('NativeDOMCxx'): RefinedSpec);
|
|
@@ -18,9 +18,16 @@ import {setPlatformObject} from '../../webidl/PlatformObjects';
|
|
|
18
18
|
// IMPORTANT: The type definition for this module is defined in `HTMLCollection.js.flow`
|
|
19
19
|
// because Flow only supports indexers in classes in declaration files.
|
|
20
20
|
|
|
21
|
-
|
|
21
|
+
const REUSABLE_PROPERTY_DESCRIPTOR: {...PropertyDescriptor<mixed>, ...} = {
|
|
22
|
+
value: {},
|
|
23
|
+
enumerable: true,
|
|
24
|
+
configurable: false,
|
|
25
|
+
writable: false,
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
// $FlowFixMe[incompatible-type] Flow doesn't understand [Symbol.iterator]() {} and thinks this class doesn't implement the Iterable<T> interface.
|
|
22
29
|
export default class HTMLCollection<T> implements Iterable<T>, ArrayLike<T> {
|
|
23
|
-
|
|
30
|
+
_length: number;
|
|
24
31
|
|
|
25
32
|
/**
|
|
26
33
|
* Use `createHTMLCollection` to create instances of this class.
|
|
@@ -30,23 +37,19 @@ export default class HTMLCollection<T> implements Iterable<T>, ArrayLike<T> {
|
|
|
30
37
|
*/
|
|
31
38
|
constructor(elements: $ReadOnlyArray<T>) {
|
|
32
39
|
for (let i = 0; i < elements.length; i++) {
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
enumerable: true,
|
|
36
|
-
configurable: false,
|
|
37
|
-
writable: false,
|
|
38
|
-
});
|
|
40
|
+
REUSABLE_PROPERTY_DESCRIPTOR.value = elements[i];
|
|
41
|
+
Object.defineProperty(this, i, REUSABLE_PROPERTY_DESCRIPTOR);
|
|
39
42
|
}
|
|
40
43
|
|
|
41
|
-
this
|
|
44
|
+
this._length = elements.length;
|
|
42
45
|
}
|
|
43
46
|
|
|
44
47
|
get length(): number {
|
|
45
|
-
return this
|
|
48
|
+
return this._length;
|
|
46
49
|
}
|
|
47
50
|
|
|
48
51
|
item(index: number): T | null {
|
|
49
|
-
if (index < 0 || index >= this
|
|
52
|
+
if (index < 0 || index >= this._length) {
|
|
50
53
|
return null;
|
|
51
54
|
}
|
|
52
55
|
|
|
@@ -22,9 +22,14 @@ import {setPlatformObject} from '../../webidl/PlatformObjects';
|
|
|
22
22
|
// IMPORTANT: The Flow type definition for this module is defined in `NodeList.js.flow`
|
|
23
23
|
// because Flow only supports indexers in classes in declaration files.
|
|
24
24
|
|
|
25
|
-
|
|
25
|
+
const REUSABLE_PROPERTY_DESCRIPTOR: {...PropertyDescriptor<mixed>, ...} = {
|
|
26
|
+
value: {},
|
|
27
|
+
writable: false,
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
// $FlowFixMe[incompatible-type] Flow doesn't understand [Symbol.iterator]() {} and thinks this class doesn't implement the Iterable<T> interface.
|
|
26
31
|
export default class NodeList<T> implements Iterable<T>, ArrayLike<T> {
|
|
27
|
-
|
|
32
|
+
_length: number;
|
|
28
33
|
|
|
29
34
|
/**
|
|
30
35
|
* Use `createNodeList` to create instances of this class.
|
|
@@ -34,20 +39,18 @@ export default class NodeList<T> implements Iterable<T>, ArrayLike<T> {
|
|
|
34
39
|
*/
|
|
35
40
|
constructor(elements: $ReadOnlyArray<T>) {
|
|
36
41
|
for (let i = 0; i < elements.length; i++) {
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
writable: false,
|
|
40
|
-
});
|
|
42
|
+
REUSABLE_PROPERTY_DESCRIPTOR.value = elements[i];
|
|
43
|
+
Object.defineProperty(this, i, REUSABLE_PROPERTY_DESCRIPTOR);
|
|
41
44
|
}
|
|
42
|
-
this
|
|
45
|
+
this._length = elements.length;
|
|
43
46
|
}
|
|
44
47
|
|
|
45
48
|
get length(): number {
|
|
46
|
-
return this
|
|
49
|
+
return this._length;
|
|
47
50
|
}
|
|
48
51
|
|
|
49
52
|
item(index: number): T | null {
|
|
50
|
-
if (index < 0 || index >= this
|
|
53
|
+
if (index < 0 || index >= this._length) {
|
|
51
54
|
return null;
|
|
52
55
|
}
|
|
53
56
|
|
|
@@ -71,7 +74,7 @@ export default class NodeList<T> implements Iterable<T>, ArrayLike<T> {
|
|
|
71
74
|
// eslint-disable-next-line consistent-this
|
|
72
75
|
const arrayLike: ArrayLike<T> = this;
|
|
73
76
|
|
|
74
|
-
for (let index = 0; index < this
|
|
77
|
+
for (let index = 0; index < this._length; index++) {
|
|
75
78
|
if (thisArg == null) {
|
|
76
79
|
callbackFn(arrayLike[index], index, this);
|
|
77
80
|
} else {
|
|
@@ -19,7 +19,7 @@ import {setPlatformObject} from '../webidl/PlatformObjects';
|
|
|
19
19
|
// IMPORTANT: The Flow type definition for this module is defined in `DOMRectList.js.flow`
|
|
20
20
|
// because Flow only supports indexers in classes in declaration files.
|
|
21
21
|
|
|
22
|
-
// $FlowFixMe[
|
|
22
|
+
// $FlowFixMe[incompatible-type] Flow doesn't understand [Symbol.iterator]() {} and thinks this class doesn't implement the Iterable interface.
|
|
23
23
|
export default class DOMRectList implements Iterable<DOMRectReadOnly> {
|
|
24
24
|
#length: number;
|
|
25
25
|
|
|
@@ -111,7 +111,7 @@ export function observe({
|
|
|
111
111
|
// the public instance immediately when mutations occur. Otherwise React
|
|
112
112
|
// could dereference it in the instance handle and we wouldn't be able to
|
|
113
113
|
// access it.
|
|
114
|
-
// $FlowExpectedError[incompatible-
|
|
114
|
+
// $FlowExpectedError[incompatible-type] This is typed as (mixed) => mixed in the native module because the codegen doesn't support the actual types.
|
|
115
115
|
getPublicInstanceFromInternalInstanceHandle,
|
|
116
116
|
);
|
|
117
117
|
isConnected = true;
|
|
@@ -93,7 +93,7 @@ function getCachedEventCounts(): Map<string, number> {
|
|
|
93
93
|
);
|
|
94
94
|
cachedEventCounts = eventCounts;
|
|
95
95
|
|
|
96
|
-
// $FlowFixMe[incompatible-
|
|
96
|
+
// $FlowFixMe[incompatible-type]
|
|
97
97
|
global.queueMicrotask(() => {
|
|
98
98
|
// To be consistent with the calls to the API from the same task,
|
|
99
99
|
// but also not to refetch the data from native too often,
|
|
@@ -29,10 +29,7 @@ import {
|
|
|
29
29
|
performanceEntryTypeToRaw,
|
|
30
30
|
rawToPerformanceEntry,
|
|
31
31
|
} from './internals/RawPerformanceEntry';
|
|
32
|
-
import {
|
|
33
|
-
getCurrentTimeStamp,
|
|
34
|
-
warnNoNativePerformance,
|
|
35
|
-
} from './internals/Utilities';
|
|
32
|
+
import {getCurrentTimeStamp} from './internals/Utilities';
|
|
36
33
|
import MemoryInfo from './MemoryInfo';
|
|
37
34
|
import ReactNativeStartupTiming from './ReactNativeStartupTiming';
|
|
38
35
|
import MaybeNativePerformance from './specs/NativePerformance';
|
|
@@ -78,18 +75,16 @@ const MEASURE_OPTIONS_REUSABLE_OBJECT: {...PerformanceMeasureInit} = {
|
|
|
78
75
|
detail: undefined,
|
|
79
76
|
};
|
|
80
77
|
|
|
81
|
-
const getMarkTimeForMeasure =
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
}
|
|
92
|
-
: undefined;
|
|
78
|
+
const getMarkTimeForMeasure = (markName: string): number => {
|
|
79
|
+
const markTime = cachedGetMarkTime(markName);
|
|
80
|
+
if (markTime == null) {
|
|
81
|
+
throw new DOMException(
|
|
82
|
+
`Failed to execute 'measure' on 'Performance': The mark '${markName}' does not exist.`,
|
|
83
|
+
'SyntaxError',
|
|
84
|
+
);
|
|
85
|
+
}
|
|
86
|
+
return markTime;
|
|
87
|
+
};
|
|
93
88
|
|
|
94
89
|
/**
|
|
95
90
|
* Partial implementation of the Performance interface for RN,
|
|
@@ -151,11 +146,6 @@ export default class Performance {
|
|
|
151
146
|
// Please run the benchmarks in `Performance-benchmarks-itest` to ensure
|
|
152
147
|
// changes do not regress performance.
|
|
153
148
|
|
|
154
|
-
if (cachedReportMark === undefined) {
|
|
155
|
-
warnNoNativePerformance();
|
|
156
|
-
return new PerformanceMark(markName, {startTime: 0});
|
|
157
|
-
}
|
|
158
|
-
|
|
159
149
|
if (markName === undefined) {
|
|
160
150
|
throw new TypeError(
|
|
161
151
|
`Failed to execute 'mark' on 'Performance': 1 argument required, but only 0 present.`,
|
|
@@ -225,14 +215,6 @@ export default class Performance {
|
|
|
225
215
|
// Please run the benchmarks in `Performance-benchmarks-itest` to ensure
|
|
226
216
|
// changes do not regress performance.
|
|
227
217
|
|
|
228
|
-
if (
|
|
229
|
-
getMarkTimeForMeasure === undefined ||
|
|
230
|
-
cachedReportMeasure === undefined
|
|
231
|
-
) {
|
|
232
|
-
warnNoNativePerformance();
|
|
233
|
-
return new PerformanceMeasure(measureName, {startTime: 0, duration: 0});
|
|
234
|
-
}
|
|
235
|
-
|
|
236
218
|
let resolvedMeasureName: string;
|
|
237
219
|
let resolvedStartTime: number;
|
|
238
220
|
let resolvedDuration: number;
|
|
@@ -245,7 +227,7 @@ export default class Performance {
|
|
|
245
227
|
}
|
|
246
228
|
|
|
247
229
|
resolvedMeasureName =
|
|
248
|
-
measureName === 'string' ? measureName : String(measureName);
|
|
230
|
+
typeof measureName === 'string' ? measureName : String(measureName);
|
|
249
231
|
|
|
250
232
|
if (startMarkOrOptions != null) {
|
|
251
233
|
switch (typeof startMarkOrOptions) {
|
|
@@ -54,14 +54,14 @@ export type PerformanceObserverInit = {
|
|
|
54
54
|
|
|
55
55
|
export interface Spec extends TurboModule {
|
|
56
56
|
+now: () => number;
|
|
57
|
-
+reportMark
|
|
58
|
-
+reportMeasure
|
|
57
|
+
+reportMark: (name: string, startTime: number, entry: mixed) => void;
|
|
58
|
+
+reportMeasure: (
|
|
59
59
|
name: string,
|
|
60
60
|
startTime: number,
|
|
61
61
|
duration: number,
|
|
62
62
|
entry: mixed,
|
|
63
63
|
) => void;
|
|
64
|
-
+getMarkTime
|
|
64
|
+
+getMarkTime: (name: string) => ?number;
|
|
65
65
|
+clearMarks: (entryName?: string) => void;
|
|
66
66
|
+clearMeasures: (entryName?: string) => void;
|
|
67
67
|
+getEntries: () => $ReadOnlyArray<RawPerformanceEntry>;
|
|
@@ -93,7 +93,7 @@ export interface Spec extends TurboModule {
|
|
|
93
93
|
|
|
94
94
|
+getSupportedPerformanceEntryTypes: () => $ReadOnlyArray<RawPerformanceEntryType>;
|
|
95
95
|
|
|
96
|
-
+clearEventCountsForTesting
|
|
96
|
+
+clearEventCountsForTesting: () => void;
|
|
97
97
|
}
|
|
98
98
|
|
|
99
99
|
export default (TurboModuleRegistry.get<Spec>('NativePerformanceCxx'): ?Spec);
|
|
@@ -61,7 +61,7 @@ function structuredCloneInternal<T>(value: T): T {
|
|
|
61
61
|
|
|
62
62
|
// Handles circular references.
|
|
63
63
|
if (memory.has(value)) {
|
|
64
|
-
// $FlowExpectedError[incompatible-
|
|
64
|
+
// $FlowExpectedError[incompatible-type] we know memory.get(value) is T
|
|
65
65
|
return memory.get(value);
|
|
66
66
|
}
|
|
67
67
|
|
|
@@ -74,7 +74,7 @@ function structuredCloneInternal<T>(value: T): T {
|
|
|
74
74
|
result[key] = structuredCloneInternal(value[key]);
|
|
75
75
|
}
|
|
76
76
|
|
|
77
|
-
// $FlowExpectedError[incompatible-
|
|
77
|
+
// $FlowExpectedError[incompatible-type] we know result is T
|
|
78
78
|
return result;
|
|
79
79
|
}
|
|
80
80
|
|
|
@@ -89,7 +89,7 @@ function structuredCloneInternal<T>(value: T): T {
|
|
|
89
89
|
result[key] = structuredCloneInternal(value[key]);
|
|
90
90
|
}
|
|
91
91
|
|
|
92
|
-
// $FlowExpectedError[incompatible-
|
|
92
|
+
// $FlowExpectedError[incompatible-type] we know result is T
|
|
93
93
|
return result;
|
|
94
94
|
}
|
|
95
95
|
|
|
@@ -99,7 +99,7 @@ function structuredCloneInternal<T>(value: T): T {
|
|
|
99
99
|
if (value instanceof Cls) {
|
|
100
100
|
const result = new Cls(value);
|
|
101
101
|
memory.set(value, result);
|
|
102
|
-
// $FlowExpectedError[incompatible-
|
|
102
|
+
// $FlowExpectedError[incompatible-type] we know result is T
|
|
103
103
|
return result;
|
|
104
104
|
}
|
|
105
105
|
}
|
|
@@ -115,7 +115,7 @@ function structuredCloneInternal<T>(value: T): T {
|
|
|
115
115
|
);
|
|
116
116
|
}
|
|
117
117
|
|
|
118
|
-
// $FlowExpectedError[incompatible-
|
|
118
|
+
// $FlowExpectedError[incompatible-type] we know result is T
|
|
119
119
|
return result;
|
|
120
120
|
}
|
|
121
121
|
|
|
@@ -127,7 +127,7 @@ function structuredCloneInternal<T>(value: T): T {
|
|
|
127
127
|
result.add(structuredCloneInternal(innerValue));
|
|
128
128
|
}
|
|
129
129
|
|
|
130
|
-
// $FlowExpectedError[incompatible-
|
|
130
|
+
// $FlowExpectedError[incompatible-type] we know result is T
|
|
131
131
|
return result;
|
|
132
132
|
}
|
|
133
133
|
|
|
@@ -135,7 +135,7 @@ function structuredCloneInternal<T>(value: T): T {
|
|
|
135
135
|
const result = new RegExp(value.source, value.flags);
|
|
136
136
|
memory.set(value, result);
|
|
137
137
|
|
|
138
|
-
// $FlowExpectedError[incompatible-
|
|
138
|
+
// $FlowExpectedError[incompatible-type] we know result is T
|
|
139
139
|
return result;
|
|
140
140
|
}
|
|
141
141
|
|
|
@@ -162,7 +162,7 @@ function structuredCloneInternal<T>(value: T): T {
|
|
|
162
162
|
|
|
163
163
|
result.stack = value.stack;
|
|
164
164
|
|
|
165
|
-
// $FlowExpectedError[incompatible-
|
|
165
|
+
// $FlowExpectedError[incompatible-type] we know result is T
|
|
166
166
|
return result;
|
|
167
167
|
}
|
|
168
168
|
|
|
@@ -185,7 +185,7 @@ function structuredCloneInternal<T>(value: T): T {
|
|
|
185
185
|
result[key] = structuredCloneInternal(value[key]);
|
|
186
186
|
}
|
|
187
187
|
|
|
188
|
-
// $FlowExpectedError[incompatible-
|
|
188
|
+
// $FlowExpectedError[incompatible-type] we know result is T
|
|
189
189
|
return result;
|
|
190
190
|
}
|
|
191
191
|
|