@office-iss/react-native-win32 0.75.2 → 0.76.0-preview.1
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/.eslintrc.js +11 -0
- package/.flowconfig +5 -4
- package/CHANGELOG.json +164 -47
- package/CHANGELOG.md +53 -28
- package/Libraries/Alert/Alert.js +3 -0
- package/Libraries/Animated/AnimatedEvent.js +1 -1
- package/Libraries/Animated/AnimatedImplementation.js +7 -7
- package/Libraries/Animated/NativeAnimatedAllowlist.js +111 -0
- package/Libraries/Animated/animations/Animation.js +11 -1
- package/Libraries/Animated/animations/DecayAnimation.js +1 -1
- package/Libraries/Animated/animations/SpringAnimation.js +1 -1
- package/Libraries/Animated/animations/TimingAnimation.js +2 -1
- package/Libraries/Animated/components/AnimatedScrollView.js +3 -2
- package/Libraries/Animated/createAnimatedComponent.js +10 -9
- package/Libraries/Animated/nodes/AnimatedColor.js +1 -1
- package/Libraries/Animated/nodes/AnimatedInterpolation.js +3 -2
- package/Libraries/Animated/nodes/AnimatedNode.js +42 -33
- package/Libraries/Animated/nodes/AnimatedObject.js +56 -50
- package/Libraries/Animated/nodes/AnimatedProps.js +77 -40
- package/Libraries/Animated/nodes/AnimatedStyle.js +103 -59
- package/Libraries/Animated/nodes/AnimatedTracking.js +1 -1
- package/Libraries/Animated/nodes/AnimatedTransform.js +102 -67
- package/Libraries/Animated/nodes/AnimatedValue.js +2 -1
- package/Libraries/Animated/nodes/AnimatedWithChildren.js +21 -22
- package/Libraries/Animated/useAnimatedProps.js +142 -7
- package/Libraries/BatchedBridge/NativeModules.js +2 -0
- package/Libraries/Blob/FileReader.js +1 -1
- package/Libraries/Blob/URL.js +2 -62
- package/Libraries/Blob/URLSearchParams.js +71 -0
- package/Libraries/Components/DrawerAndroid/DrawerLayoutAndroid.android.js +1 -1
- package/Libraries/Components/RefreshControl/__mocks__/RefreshControlMock.js +1 -1
- package/Libraries/Components/ScrollView/ScrollView.js +131 -169
- package/Libraries/Components/ScrollView/ScrollViewStickyHeader.js +1 -1
- package/Libraries/Components/StatusBar/StatusBar.js +3 -1
- package/Libraries/Components/TextInput/TextInput.d.ts +32 -2
- package/Libraries/Components/TextInput/TextInput.js +230 -94
- package/Libraries/Components/TextInput/TextInput.win32.js +230 -100
- package/Libraries/Components/View/ReactNativeStyleAttributes.js +22 -0
- package/Libraries/Components/View/ReactNativeViewAttributes.js +2 -0
- package/Libraries/Components/View/ReactNativeViewAttributes.win32.js +2 -0
- package/Libraries/Components/View/ViewAccessibility.d.ts +15 -0
- package/Libraries/Components/View/ViewNativeComponent.js +0 -1
- package/Libraries/Components/View/ViewPropTypes.js +14 -0
- package/Libraries/Components/View/ViewPropTypes.win32.js +14 -0
- package/Libraries/Core/ExceptionsManager.js +2 -0
- package/Libraries/Core/InitializeCore.js +3 -1
- package/Libraries/Core/ReactFiberErrorDialog.js +3 -0
- package/Libraries/Core/ReactNativeVersion.js +4 -4
- package/Libraries/Core/ReactNativeVersionCheck.win32.js +1 -1
- package/Libraries/Core/setUpErrorHandling.js +7 -1
- package/Libraries/Core/setUpGlobals.js +1 -0
- package/Libraries/Core/setUpReactRefresh.js +0 -4
- package/Libraries/Image/AssetSourceResolver.js +28 -1
- package/Libraries/Image/Image.android.js +9 -14
- package/Libraries/Image/Image.ios.js +11 -22
- package/Libraries/Image/Image.win32.js +11 -24
- package/Libraries/Image/ImageBackground.js +1 -8
- package/Libraries/Image/ImageUtils.js +9 -9
- package/Libraries/Image/ImageViewNativeComponent.js +1 -0
- package/Libraries/Inspector/Inspector.js +3 -2
- package/Libraries/Inspector/Inspector.win32.js +3 -2
- package/Libraries/Inspector/InspectorPanel.js +16 -10
- package/Libraries/Inspector/NetworkOverlay.js +1 -1
- package/Libraries/Interaction/TaskQueue.js +1 -0
- package/Libraries/Lists/FlatList.js +1 -1
- package/Libraries/Lists/SectionList.js +2 -2
- package/Libraries/Lists/SectionListModern.js +3 -3
- package/Libraries/LogBox/Data/LogBoxData.js +24 -3
- package/Libraries/LogBox/LogBoxNotificationContainer.js +3 -2
- package/Libraries/LogBox/UI/LogBoxInspectorHeader.js +9 -8
- package/Libraries/LogBox/UI/LogBoxInspectorHeader.win32.js +9 -29
- package/Libraries/Modal/Modal.js +0 -1
- package/Libraries/NativeComponent/BaseViewConfig.android.js +8 -0
- package/Libraries/NativeComponent/BaseViewConfig.ios.js +7 -0
- package/Libraries/NativeComponent/BaseViewConfig.win32.js +7 -0
- package/Libraries/NativeComponent/NativeComponentRegistry.js +22 -22
- package/Libraries/NativeComponent/StaticViewConfigValidator.js +0 -21
- package/Libraries/Network/XMLHttpRequest.js +4 -2
- package/Libraries/ReactNative/AppContainer-dev.js +1 -5
- package/Libraries/ReactNative/AppContainer-prod.js +1 -5
- package/Libraries/ReactNative/AppContainer.js +0 -1
- package/Libraries/ReactNative/AppRegistry.js +0 -6
- package/Libraries/ReactNative/BridgelessUIManager.js +1 -0
- package/Libraries/ReactNative/ReactFabricPublicInstance/ReactFabricHostComponent.js +1 -1
- package/Libraries/ReactNative/ReactFabricPublicInstance/ReactFabricPublicInstance.js +5 -5
- package/Libraries/ReactNative/RendererImplementation.js +26 -4
- package/Libraries/ReactNative/getNativeComponentAttributes.js +8 -0
- package/Libraries/ReactNative/renderApplication.js +0 -2
- package/Libraries/Renderer/shims/ReactNativeTypes.js +11 -4
- package/Libraries/StyleSheet/StyleSheet.js +1 -1
- package/Libraries/StyleSheet/StyleSheet.win32.js +1 -1
- package/Libraries/StyleSheet/StyleSheetTypes.d.ts +57 -0
- package/Libraries/StyleSheet/StyleSheetTypes.js +60 -5
- package/Libraries/StyleSheet/processBackgroundImage.js +384 -0
- package/Libraries/StyleSheet/processBoxShadow.js +211 -0
- package/Libraries/StyleSheet/processFilter.js +231 -42
- package/Libraries/Text/Text.js +394 -196
- package/Libraries/Text/Text.win32.js +442 -229
- package/Libraries/Text/TextNativeComponent.js +2 -1
- package/Libraries/Text/TextNativeComponent.win32.js +1 -1
- package/Libraries/TurboModule/TurboModuleRegistry.js +13 -50
- package/Libraries/Types/CodegenTypes.js +3 -1
- package/Libraries/Utilities/Appearance.js +108 -84
- package/Libraries/Utilities/DevLoadingView.js +2 -4
- package/Libraries/Utilities/HMRClient.js +2 -1
- package/Libraries/Utilities/ReactNativeTestTools.js +1 -1
- package/Libraries/Utilities/createPerformanceLogger.js +0 -9
- package/Libraries/Utilities/stringifyViewConfig.js +22 -0
- package/Libraries/Utilities/useColorScheme.js +3 -3
- package/Libraries/WebSocket/WebSocket.js +1 -1
- package/Libraries/promiseRejectionTrackingOptions.js +1 -1
- package/Libraries/vendor/emitter/EventEmitter.js +6 -5
- package/flow/jest.js +2 -2
- package/index.js +3 -1
- package/index.win32.js +3 -1
- package/jest/mockComponent.js +4 -1
- package/jest/mockModal.js +1 -3
- package/jest/mockScrollView.js +1 -1
- package/jest/renderer.js +2 -2
- package/jest/setup.js +16 -13
- package/jest.config.js +1 -2
- package/overrides.json +22 -22
- package/package.json +30 -30
- package/src/private/animated/NativeAnimatedHelper.js +438 -0
- package/src/private/animated/NativeAnimatedHelper.win32.js +440 -0
- package/src/private/animated/NativeAnimatedValidation.js +64 -0
- package/src/private/components/HScrollViewNativeComponents.js +56 -0
- package/src/private/components/SafeAreaView_INTERNAL_DO_NOT_USE.js +27 -0
- package/src/private/components/VScrollViewNativeComponents.js +48 -0
- package/src/private/components/useSyncOnScroll.js +48 -0
- package/src/private/featureflags/ReactNativeFeatureFlags.js +166 -16
- package/src/private/featureflags/specs/NativeReactNativeFeatureFlags.js +29 -5
- package/src/private/fusebox/FuseboxSessionObserver.js +42 -0
- package/{Libraries/Core → src/private/renderer/errorhandling}/ErrorHandlers.js +14 -4
- package/src/private/setup/setUpDOM.js +28 -0
- package/src/private/setup/setUpIntersectionObserver.js +27 -0
- package/src/private/setup/setUpMutationObserver.js +26 -0
- package/src/private/setup/setUpPerformanceObserver.js +64 -0
- package/src/private/specs/modules/NativeAppearance.js +3 -3
- package/src/private/specs/modules/NativeLinkingManager.js +1 -1
- package/src/private/specs/modules/NativePlatformConstantsWin.js +7 -0
- package/src/private/specs/modules/NativeSampleTurboModule.js +14 -1
- package/src/private/webapis/dom/nodes/ReadOnlyNode.js +6 -4
- package/{Libraries/IntersectionObserver → src/private/webapis/intersectionobserver}/IntersectionObserver.js +5 -3
- package/{Libraries/IntersectionObserver → src/private/webapis/intersectionobserver}/IntersectionObserverEntry.js +3 -3
- package/{Libraries/IntersectionObserver → src/private/webapis/intersectionobserver}/IntersectionObserverManager.js +14 -17
- package/src/private/{specs/modules → webapis/intersectionobserver/specs}/NativeIntersectionObserver.js +2 -2
- package/{Libraries/IntersectionObserver → src/private/webapis/intersectionobserver/specs}/__mocks__/NativeIntersectionObserver.js +4 -4
- package/{Libraries/MutationObserver → src/private/webapis/mutationobserver}/MutationObserver.js +5 -3
- package/{Libraries/MutationObserver → src/private/webapis/mutationobserver}/MutationObserverManager.js +24 -15
- package/{Libraries/MutationObserver → src/private/webapis/mutationobserver}/MutationRecord.js +4 -6
- package/src/private/{specs/modules → webapis/mutationobserver/specs}/NativeMutationObserver.js +2 -2
- package/{Libraries/MutationObserver → src/private/webapis/mutationobserver/specs}/__mocks__/NativeMutationObserver.js +5 -5
- package/src/private/webapis/performance/{EventCounts.js → EventTiming.js} +65 -3
- package/src/private/webapis/performance/LongTasks.js +39 -0
- package/src/private/webapis/performance/Performance.js +22 -9
- package/src/private/webapis/performance/PerformanceEntry.js +36 -18
- package/src/private/webapis/performance/PerformanceObserver.js +29 -43
- package/src/private/webapis/performance/RawPerformanceEntry.js +24 -1
- package/src/private/webapis/performance/UserTiming.js +17 -12
- package/src/private/webapis/performance/specs/NativePerformanceObserver.js +1 -1
- package/src-win/Libraries/Components/View/ViewAccessibility.d.ts +15 -0
- package/types/experimental.d.ts +20 -1
- package/Libraries/Animated/NativeAnimatedHelper.js +0 -615
- package/Libraries/Animated/NativeAnimatedHelper.win32.js +0 -617
- package/Libraries/Core/setUpIntersectionObserver.js +0 -16
- package/Libraries/Core/setUpMutationObserver.js +0 -16
- package/Libraries/Core/setUpPerformanceObserver.js +0 -18
- package/Libraries/IntersectionObserver/NativeIntersectionObserver.js +0 -13
- package/Libraries/MutationObserver/NativeMutationObserver.js +0 -13
- package/Libraries/Utilities/verifyComponentAttributeEquivalence.js +0 -135
- package/src/private/core/setUpDOM.js +0 -18
- package/src/private/webapis/performance/PerformanceEventTiming.js +0 -55
- /package/src/private/{core → styles}/composeStyles.js +0 -0
|
@@ -14,7 +14,7 @@ import * as TurboModuleRegistry from '../../../../Libraries/TurboModule/TurboMod
|
|
|
14
14
|
|
|
15
15
|
export interface Spec extends TurboModule {
|
|
16
16
|
// Common interface
|
|
17
|
-
+getInitialURL: () => Promise
|
|
17
|
+
+getInitialURL: () => Promise<?string>;
|
|
18
18
|
+canOpenURL: (url: string) => Promise<boolean>;
|
|
19
19
|
+openURL: (url: string) => Promise<void>;
|
|
20
20
|
+openSettings: () => Promise<void>;
|
|
@@ -12,6 +12,13 @@ import type {TurboModule} from '../../../../Libraries/TurboModule/RCTExport';
|
|
|
12
12
|
|
|
13
13
|
import * as TurboModuleRegistry from '../../../../Libraries/TurboModule/TurboModuleRegistry';
|
|
14
14
|
|
|
15
|
+
export type ReactNativeVersionAndroid = {|
|
|
16
|
+
major: number,
|
|
17
|
+
minor: number,
|
|
18
|
+
patch: number,
|
|
19
|
+
prerelease: ?string,
|
|
20
|
+
|};
|
|
21
|
+
|
|
15
22
|
export type PlatformConstantsWin32 = {|
|
|
16
23
|
isTesting: boolean,
|
|
17
24
|
isDisableAnimations?: boolean,
|
|
@@ -12,7 +12,10 @@ import type {
|
|
|
12
12
|
RootTag,
|
|
13
13
|
TurboModule,
|
|
14
14
|
} from '../../../../Libraries/TurboModule/RCTExport';
|
|
15
|
-
import type {
|
|
15
|
+
import type {
|
|
16
|
+
EventEmitter,
|
|
17
|
+
UnsafeObject,
|
|
18
|
+
} from '../../../../Libraries/Types/CodegenTypes';
|
|
16
19
|
|
|
17
20
|
import * as TurboModuleRegistry from '../../../../Libraries/TurboModule/TurboModuleRegistry';
|
|
18
21
|
|
|
@@ -21,7 +24,17 @@ export enum EnumInt {
|
|
|
21
24
|
B = 42,
|
|
22
25
|
}
|
|
23
26
|
|
|
27
|
+
export type ObjectStruct = {
|
|
28
|
+
a: number,
|
|
29
|
+
b: string,
|
|
30
|
+
c?: ?string,
|
|
31
|
+
};
|
|
32
|
+
|
|
24
33
|
export interface Spec extends TurboModule {
|
|
34
|
+
+onPress: EventEmitter<void>;
|
|
35
|
+
+onClick: EventEmitter<string>;
|
|
36
|
+
+onChange: EventEmitter<ObjectStruct>;
|
|
37
|
+
+onSubmit: EventEmitter<ObjectStruct[]>;
|
|
25
38
|
// Exported methods.
|
|
26
39
|
+getConstants: () => {|
|
|
27
40
|
const1: boolean,
|
|
@@ -304,8 +304,10 @@ function setInstanceHandle(
|
|
|
304
304
|
export function getShadowNode(node: ReadOnlyNode): ?ShadowNode {
|
|
305
305
|
// Lazy import Fabric here to avoid DOM Node APIs classes from having side-effects.
|
|
306
306
|
// With a static import we can't use these classes for Paper-only variants.
|
|
307
|
-
const
|
|
308
|
-
return
|
|
307
|
+
const RendererProxy = require('../../../../../Libraries/ReactNative/RendererProxy');
|
|
308
|
+
return RendererProxy.getNodeFromInternalInstanceHandle(
|
|
309
|
+
getInstanceHandle(node),
|
|
310
|
+
);
|
|
309
311
|
}
|
|
310
312
|
|
|
311
313
|
export function getChildNodes(
|
|
@@ -349,9 +351,9 @@ export function getPublicInstanceFromInternalInstanceHandle(
|
|
|
349
351
|
): ?ReadOnlyNode {
|
|
350
352
|
// Lazy import Fabric here to avoid DOM Node APIs classes from having side-effects.
|
|
351
353
|
// With a static import we can't use these classes for Paper-only variants.
|
|
352
|
-
const
|
|
354
|
+
const RendererProxy = require('../../../../../Libraries/ReactNative/RendererProxy');
|
|
353
355
|
const mixedPublicInstance =
|
|
354
|
-
|
|
356
|
+
RendererProxy.getPublicInstanceFromInternalInstanceHandle(instanceHandle);
|
|
355
357
|
// $FlowExpectedError[incompatible-return] React defines public instances as "mixed" because it can't access the definition from React Native.
|
|
356
358
|
return mixedPublicInstance;
|
|
357
359
|
}
|
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
import type IntersectionObserverEntry from './IntersectionObserverEntry';
|
|
14
14
|
import type {IntersectionObserverId} from './IntersectionObserverManager';
|
|
15
15
|
|
|
16
|
-
import ReactNativeElement from '
|
|
16
|
+
import ReactNativeElement from '../dom/nodes/ReactNativeElement';
|
|
17
17
|
import * as IntersectionObserverManager from './IntersectionObserverManager';
|
|
18
18
|
|
|
19
19
|
export type IntersectionObserverCallback = (
|
|
@@ -141,12 +141,14 @@ export default class IntersectionObserver {
|
|
|
141
141
|
return;
|
|
142
142
|
}
|
|
143
143
|
|
|
144
|
-
IntersectionObserverManager.observe({
|
|
144
|
+
const didStartObserving = IntersectionObserverManager.observe({
|
|
145
145
|
intersectionObserverId: this._getOrCreateIntersectionObserverId(),
|
|
146
146
|
target,
|
|
147
147
|
});
|
|
148
148
|
|
|
149
|
-
|
|
149
|
+
if (didStartObserving) {
|
|
150
|
+
this._observationTargets.add(target);
|
|
151
|
+
}
|
|
150
152
|
}
|
|
151
153
|
|
|
152
154
|
/**
|
|
@@ -10,10 +10,10 @@
|
|
|
10
10
|
|
|
11
11
|
// flowlint unsafe-getters-setters:off
|
|
12
12
|
|
|
13
|
-
import type ReactNativeElement from '
|
|
14
|
-
import type {NativeIntersectionObserverEntry} from './NativeIntersectionObserver';
|
|
13
|
+
import type ReactNativeElement from '../dom/nodes/ReactNativeElement';
|
|
14
|
+
import type {NativeIntersectionObserverEntry} from './specs/NativeIntersectionObserver';
|
|
15
15
|
|
|
16
|
-
import DOMRectReadOnly from '
|
|
16
|
+
import DOMRectReadOnly from '../dom/geometry/DOMRectReadOnly';
|
|
17
17
|
|
|
18
18
|
/**
|
|
19
19
|
* The [`IntersectionObserverEntry`](https://developer.mozilla.org/en-US/docs/Web/API/IntersectionObserverEntry)
|
|
@@ -18,20 +18,17 @@
|
|
|
18
18
|
* the notifications together.
|
|
19
19
|
*/
|
|
20
20
|
|
|
21
|
-
import type ReactNativeElement from '
|
|
21
|
+
import type ReactNativeElement from '../dom/nodes/ReactNativeElement';
|
|
22
22
|
import type IntersectionObserver, {
|
|
23
23
|
IntersectionObserverCallback,
|
|
24
24
|
} from './IntersectionObserver';
|
|
25
25
|
import type IntersectionObserverEntry from './IntersectionObserverEntry';
|
|
26
26
|
|
|
27
|
-
import
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
} from '../../src/private/webapis/dom/nodes/ReadOnlyNode';
|
|
31
|
-
import * as Systrace from '../Performance/Systrace';
|
|
32
|
-
import warnOnce from '../Utilities/warnOnce';
|
|
27
|
+
import * as Systrace from '../../../../Libraries/Performance/Systrace';
|
|
28
|
+
import warnOnce from '../../../../Libraries/Utilities/warnOnce';
|
|
29
|
+
import {getInstanceHandle, getShadowNode} from '../dom/nodes/ReadOnlyNode';
|
|
33
30
|
import {createIntersectionObserverEntry} from './IntersectionObserverEntry';
|
|
34
|
-
import NativeIntersectionObserver from './NativeIntersectionObserver';
|
|
31
|
+
import NativeIntersectionObserver from './specs/NativeIntersectionObserver';
|
|
35
32
|
|
|
36
33
|
export type IntersectionObserverId = number;
|
|
37
34
|
|
|
@@ -119,10 +116,10 @@ export function observe({
|
|
|
119
116
|
}: {
|
|
120
117
|
intersectionObserverId: IntersectionObserverId,
|
|
121
118
|
target: ReactNativeElement,
|
|
122
|
-
}):
|
|
119
|
+
}): boolean {
|
|
123
120
|
if (NativeIntersectionObserver == null) {
|
|
124
121
|
warnNoNativeIntersectionObserver();
|
|
125
|
-
return;
|
|
122
|
+
return false;
|
|
126
123
|
}
|
|
127
124
|
|
|
128
125
|
const registeredObserver = registeredIntersectionObservers.get(
|
|
@@ -132,15 +129,13 @@ export function observe({
|
|
|
132
129
|
console.error(
|
|
133
130
|
`IntersectionObserverManager: could not start observing target because IntersectionObserver with ID ${intersectionObserverId} was not registered.`,
|
|
134
131
|
);
|
|
135
|
-
return;
|
|
132
|
+
return false;
|
|
136
133
|
}
|
|
137
134
|
|
|
138
135
|
const targetShadowNode = getShadowNode(target);
|
|
139
136
|
if (targetShadowNode == null) {
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
);
|
|
143
|
-
return;
|
|
137
|
+
// The target is disconnected. We can't observe it anymore.
|
|
138
|
+
return false;
|
|
144
139
|
}
|
|
145
140
|
|
|
146
141
|
const instanceHandle = getInstanceHandle(target);
|
|
@@ -148,7 +143,7 @@ export function observe({
|
|
|
148
143
|
console.error(
|
|
149
144
|
'IntersectionObserverManager: could not find reference to instance handle from target',
|
|
150
145
|
);
|
|
151
|
-
return;
|
|
146
|
+
return false;
|
|
152
147
|
}
|
|
153
148
|
|
|
154
149
|
// Store the mapping between the instance handle and the target so we can
|
|
@@ -163,11 +158,13 @@ export function observe({
|
|
|
163
158
|
isConnected = true;
|
|
164
159
|
}
|
|
165
160
|
|
|
166
|
-
|
|
161
|
+
NativeIntersectionObserver.observe({
|
|
167
162
|
intersectionObserverId,
|
|
168
163
|
targetShadowNode,
|
|
169
164
|
thresholds: registeredObserver.observer.thresholds,
|
|
170
165
|
});
|
|
166
|
+
|
|
167
|
+
return true;
|
|
171
168
|
}
|
|
172
169
|
|
|
173
170
|
export function unobserve(
|
|
@@ -8,9 +8,9 @@
|
|
|
8
8
|
* @format
|
|
9
9
|
*/
|
|
10
10
|
|
|
11
|
-
import type {TurboModule} from '
|
|
11
|
+
import type {TurboModule} from '../../../../../Libraries/TurboModule/RCTExport';
|
|
12
12
|
|
|
13
|
-
import * as TurboModuleRegistry from '
|
|
13
|
+
import * as TurboModuleRegistry from '../../../../../Libraries/TurboModule/TurboModuleRegistry';
|
|
14
14
|
|
|
15
15
|
export type NativeIntersectionObserverEntry = {
|
|
16
16
|
intersectionObserverId: number,
|
|
@@ -8,16 +8,16 @@
|
|
|
8
8
|
* @format
|
|
9
9
|
*/
|
|
10
10
|
|
|
11
|
-
import type ReactNativeElement from '../../../
|
|
12
|
-
import type IntersectionObserver from '
|
|
11
|
+
import type ReactNativeElement from '../../../dom/nodes/ReactNativeElement';
|
|
12
|
+
import type IntersectionObserver from '../../IntersectionObserver';
|
|
13
13
|
import type {
|
|
14
14
|
NativeIntersectionObserverEntry,
|
|
15
15
|
NativeIntersectionObserverObserveOptions,
|
|
16
16
|
Spec,
|
|
17
17
|
} from '../NativeIntersectionObserver';
|
|
18
18
|
|
|
19
|
-
import {
|
|
20
|
-
import {
|
|
19
|
+
import {getFabricUIManager} from '../../../../../../Libraries/ReactNative/__mocks__/FabricUIManager';
|
|
20
|
+
import {getShadowNode} from '../../../dom/nodes/ReadOnlyNode';
|
|
21
21
|
import invariant from 'invariant';
|
|
22
22
|
import nullthrows from 'nullthrows';
|
|
23
23
|
|
package/{Libraries/MutationObserver → src/private/webapis/mutationobserver}/MutationObserver.js
RENAMED
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
import type {MutationObserverId} from './MutationObserverManager';
|
|
14
14
|
import type MutationRecord from './MutationRecord';
|
|
15
15
|
|
|
16
|
-
import ReactNativeElement from '
|
|
16
|
+
import ReactNativeElement from '../dom/nodes/ReactNativeElement';
|
|
17
17
|
import * as MutationObserverManager from './MutationObserverManager';
|
|
18
18
|
|
|
19
19
|
export type MutationObserverCallback = (
|
|
@@ -121,13 +121,15 @@ export default class MutationObserver {
|
|
|
121
121
|
MutationObserverManager.unobserve(mutationObserverId, target);
|
|
122
122
|
}
|
|
123
123
|
|
|
124
|
-
MutationObserverManager.observe({
|
|
124
|
+
const didStartObserving = MutationObserverManager.observe({
|
|
125
125
|
mutationObserverId,
|
|
126
126
|
target,
|
|
127
127
|
subtree: Boolean(options?.subtree),
|
|
128
128
|
});
|
|
129
129
|
|
|
130
|
-
|
|
130
|
+
if (didStartObserving) {
|
|
131
|
+
this._observationTargets.add(target);
|
|
132
|
+
}
|
|
131
133
|
}
|
|
132
134
|
|
|
133
135
|
_unobserve(target: ReactNativeElement): void {
|
|
@@ -18,20 +18,20 @@
|
|
|
18
18
|
* the notifications together.
|
|
19
19
|
*/
|
|
20
20
|
|
|
21
|
-
import type ReactNativeElement from '
|
|
21
|
+
import type ReactNativeElement from '../dom/nodes/ReactNativeElement';
|
|
22
22
|
import type MutationObserver, {
|
|
23
23
|
MutationObserverCallback,
|
|
24
24
|
} from './MutationObserver';
|
|
25
25
|
import type MutationRecord from './MutationRecord';
|
|
26
26
|
|
|
27
|
+
import * as Systrace from '../../../../Libraries/Performance/Systrace';
|
|
28
|
+
import warnOnce from '../../../../Libraries/Utilities/warnOnce';
|
|
27
29
|
import {
|
|
28
30
|
getPublicInstanceFromInternalInstanceHandle,
|
|
29
31
|
getShadowNode,
|
|
30
|
-
} from '
|
|
31
|
-
import * as Systrace from '../Performance/Systrace';
|
|
32
|
-
import warnOnce from '../Utilities/warnOnce';
|
|
32
|
+
} from '../dom/nodes/ReadOnlyNode';
|
|
33
33
|
import {createMutationRecord} from './MutationRecord';
|
|
34
|
-
import NativeMutationObserver from './NativeMutationObserver';
|
|
34
|
+
import NativeMutationObserver from './specs/NativeMutationObserver';
|
|
35
35
|
|
|
36
36
|
export type MutationObserverId = number;
|
|
37
37
|
|
|
@@ -43,6 +43,13 @@ const registeredMutationObservers: Map<
|
|
|
43
43
|
$ReadOnly<{observer: MutationObserver, callback: MutationObserverCallback}>,
|
|
44
44
|
> = new Map();
|
|
45
45
|
|
|
46
|
+
// The mapping between ReactNativeElement and their corresponding shadow node
|
|
47
|
+
// needs to be kept here because React removes the link when unmounting.
|
|
48
|
+
const targetToShadowNodeMap: WeakMap<
|
|
49
|
+
ReactNativeElement,
|
|
50
|
+
ReturnType<typeof getShadowNode>,
|
|
51
|
+
> = new WeakMap();
|
|
52
|
+
|
|
46
53
|
/**
|
|
47
54
|
* Registers the given mutation observer and returns a unique ID for it,
|
|
48
55
|
* which is required to start observing targets.
|
|
@@ -85,10 +92,10 @@ export function observe({
|
|
|
85
92
|
mutationObserverId: MutationObserverId,
|
|
86
93
|
target: ReactNativeElement,
|
|
87
94
|
subtree: boolean,
|
|
88
|
-
}):
|
|
95
|
+
}): boolean {
|
|
89
96
|
if (NativeMutationObserver == null) {
|
|
90
97
|
warnNoNativeMutationObserver();
|
|
91
|
-
return;
|
|
98
|
+
return false;
|
|
92
99
|
}
|
|
93
100
|
|
|
94
101
|
const registeredObserver =
|
|
@@ -97,17 +104,17 @@ export function observe({
|
|
|
97
104
|
console.error(
|
|
98
105
|
`MutationObserverManager: could not start observing target because MutationObserver with ID ${mutationObserverId} was not registered.`,
|
|
99
106
|
);
|
|
100
|
-
return;
|
|
107
|
+
return false;
|
|
101
108
|
}
|
|
102
109
|
|
|
103
110
|
const targetShadowNode = getShadowNode(target);
|
|
104
111
|
if (targetShadowNode == null) {
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
);
|
|
108
|
-
return;
|
|
112
|
+
// The target is disconnected. We can't observe it anymore.
|
|
113
|
+
return false;
|
|
109
114
|
}
|
|
110
115
|
|
|
116
|
+
targetToShadowNodeMap.set(target, targetShadowNode);
|
|
117
|
+
|
|
111
118
|
if (!isConnected) {
|
|
112
119
|
NativeMutationObserver.connect(
|
|
113
120
|
notifyMutationObservers,
|
|
@@ -121,11 +128,13 @@ export function observe({
|
|
|
121
128
|
isConnected = true;
|
|
122
129
|
}
|
|
123
130
|
|
|
124
|
-
|
|
131
|
+
NativeMutationObserver.observe({
|
|
125
132
|
mutationObserverId,
|
|
126
133
|
targetShadowNode,
|
|
127
134
|
subtree,
|
|
128
135
|
});
|
|
136
|
+
|
|
137
|
+
return true;
|
|
129
138
|
}
|
|
130
139
|
|
|
131
140
|
export function unobserve(
|
|
@@ -146,10 +155,10 @@ export function unobserve(
|
|
|
146
155
|
return;
|
|
147
156
|
}
|
|
148
157
|
|
|
149
|
-
const targetShadowNode =
|
|
158
|
+
const targetShadowNode = targetToShadowNodeMap.get(target);
|
|
150
159
|
if (targetShadowNode == null) {
|
|
151
160
|
console.error(
|
|
152
|
-
'MutationObserverManager: could not find
|
|
161
|
+
'MutationObserverManager: could not find registration data for target',
|
|
153
162
|
);
|
|
154
163
|
return;
|
|
155
164
|
}
|
package/{Libraries/MutationObserver → src/private/webapis/mutationobserver}/MutationRecord.js
RENAMED
|
@@ -10,13 +10,11 @@
|
|
|
10
10
|
|
|
11
11
|
// flowlint unsafe-getters-setters:off
|
|
12
12
|
|
|
13
|
-
import type ReactNativeElement from '
|
|
14
|
-
import type ReadOnlyNode from '
|
|
15
|
-
import type {NativeMutationRecord} from './NativeMutationObserver';
|
|
13
|
+
import type ReactNativeElement from '../dom/nodes/ReactNativeElement';
|
|
14
|
+
import type ReadOnlyNode from '../dom/nodes/ReadOnlyNode';
|
|
15
|
+
import type {NativeMutationRecord} from './specs/NativeMutationObserver';
|
|
16
16
|
|
|
17
|
-
import NodeList, {
|
|
18
|
-
createNodeList,
|
|
19
|
-
} from '../../src/private/webapis/dom/oldstylecollections/NodeList';
|
|
17
|
+
import NodeList, {createNodeList} from '../dom/oldstylecollections/NodeList';
|
|
20
18
|
|
|
21
19
|
export type MutationType = 'attributes' | 'characterData' | 'childList';
|
|
22
20
|
|
package/src/private/{specs/modules → webapis/mutationobserver/specs}/NativeMutationObserver.js
RENAMED
|
@@ -8,9 +8,9 @@
|
|
|
8
8
|
* @format
|
|
9
9
|
*/
|
|
10
10
|
|
|
11
|
-
import type {TurboModule} from '
|
|
11
|
+
import type {TurboModule} from '../../../../../Libraries/TurboModule/RCTExport';
|
|
12
12
|
|
|
13
|
-
import * as TurboModuleRegistry from '
|
|
13
|
+
import * as TurboModuleRegistry from '../../../../../Libraries/TurboModule/TurboModuleRegistry';
|
|
14
14
|
|
|
15
15
|
export type MutationObserverId = number;
|
|
16
16
|
|
|
@@ -15,12 +15,12 @@
|
|
|
15
15
|
* JavaScript as an integration test using only public APIs.
|
|
16
16
|
*/
|
|
17
17
|
|
|
18
|
-
import type {NodeSet} from '
|
|
19
|
-
import type {RootTag} from '
|
|
18
|
+
import type {NodeSet} from '../../../../../../Libraries/ReactNative/FabricUIManager';
|
|
19
|
+
import type {RootTag} from '../../../../../../Libraries/ReactNative/RootTag';
|
|
20
20
|
import type {
|
|
21
21
|
InternalInstanceHandle,
|
|
22
22
|
Node,
|
|
23
|
-
} from '
|
|
23
|
+
} from '../../../../../../Libraries/Renderer/shims/ReactNativeTypes';
|
|
24
24
|
import type {
|
|
25
25
|
MutationObserverId,
|
|
26
26
|
NativeMutationObserverObserveOptions,
|
|
@@ -28,14 +28,14 @@ import type {
|
|
|
28
28
|
Spec,
|
|
29
29
|
} from '../NativeMutationObserver';
|
|
30
30
|
|
|
31
|
-
import ReadOnlyNode from '../../../src/private/webapis/dom/nodes/ReadOnlyNode';
|
|
32
31
|
import {
|
|
33
32
|
type NodeMock,
|
|
34
33
|
type UIManagerCommitHook,
|
|
35
34
|
fromNode,
|
|
36
35
|
getFabricUIManager,
|
|
37
36
|
getNodeInChildSet,
|
|
38
|
-
} from '
|
|
37
|
+
} from '../../../../../../Libraries/ReactNative/__mocks__/FabricUIManager';
|
|
38
|
+
import ReadOnlyNode from '../../../dom/nodes/ReadOnlyNode';
|
|
39
39
|
import invariant from 'invariant';
|
|
40
40
|
import nullthrows from 'nullthrows';
|
|
41
41
|
|
|
@@ -4,13 +4,75 @@
|
|
|
4
4
|
* This source code is licensed under the MIT license found in the
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
6
|
*
|
|
7
|
-
* @flow strict
|
|
8
7
|
* @format
|
|
8
|
+
* @flow strict
|
|
9
9
|
*/
|
|
10
10
|
|
|
11
|
+
// flowlint unsafe-getters-setters:off
|
|
12
|
+
|
|
13
|
+
import type {
|
|
14
|
+
DOMHighResTimeStamp,
|
|
15
|
+
PerformanceEntryJSON,
|
|
16
|
+
} from './PerformanceEntry';
|
|
17
|
+
|
|
18
|
+
import {PerformanceEntry} from './PerformanceEntry';
|
|
11
19
|
import {warnNoNativePerformanceObserver} from './PerformanceObserver';
|
|
12
20
|
import NativePerformanceObserver from './specs/NativePerformanceObserver';
|
|
13
21
|
|
|
22
|
+
export type PerformanceEventTimingJSON = {
|
|
23
|
+
...PerformanceEntryJSON,
|
|
24
|
+
processingStart: DOMHighResTimeStamp,
|
|
25
|
+
processingEnd: DOMHighResTimeStamp,
|
|
26
|
+
interactionId: number,
|
|
27
|
+
...
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
export class PerformanceEventTiming extends PerformanceEntry {
|
|
31
|
+
#processingStart: DOMHighResTimeStamp;
|
|
32
|
+
#processingEnd: DOMHighResTimeStamp;
|
|
33
|
+
#interactionId: number;
|
|
34
|
+
|
|
35
|
+
constructor(init: {
|
|
36
|
+
name: string,
|
|
37
|
+
startTime?: DOMHighResTimeStamp,
|
|
38
|
+
duration?: DOMHighResTimeStamp,
|
|
39
|
+
processingStart?: DOMHighResTimeStamp,
|
|
40
|
+
processingEnd?: DOMHighResTimeStamp,
|
|
41
|
+
interactionId?: number,
|
|
42
|
+
}) {
|
|
43
|
+
super({
|
|
44
|
+
name: init.name,
|
|
45
|
+
entryType: 'event',
|
|
46
|
+
startTime: init.startTime ?? 0,
|
|
47
|
+
duration: init.duration ?? 0,
|
|
48
|
+
});
|
|
49
|
+
this.#processingStart = init.processingStart ?? 0;
|
|
50
|
+
this.#processingEnd = init.processingEnd ?? 0;
|
|
51
|
+
this.#interactionId = init.interactionId ?? 0;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
get processingStart(): DOMHighResTimeStamp {
|
|
55
|
+
return this.#processingStart;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
get processingEnd(): DOMHighResTimeStamp {
|
|
59
|
+
return this.#processingEnd;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
get interactionId(): number {
|
|
63
|
+
return this.#interactionId;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
toJSON(): PerformanceEventTimingJSON {
|
|
67
|
+
return {
|
|
68
|
+
...super.toJSON(),
|
|
69
|
+
processingStart: this.#processingStart,
|
|
70
|
+
processingEnd: this.#processingEnd,
|
|
71
|
+
interactionId: this.#interactionId,
|
|
72
|
+
};
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
|
|
14
76
|
type EventCountsForEachCallbackType =
|
|
15
77
|
| (() => void)
|
|
16
78
|
| ((value: number) => void)
|
|
@@ -41,13 +103,13 @@ function getCachedEventCounts(): Map<string, number> {
|
|
|
41
103
|
});
|
|
42
104
|
return cachedEventCounts ?? new Map();
|
|
43
105
|
}
|
|
106
|
+
|
|
44
107
|
/**
|
|
45
108
|
* Implementation of the EventCounts Web Performance API
|
|
46
109
|
* corresponding to the standard in
|
|
47
110
|
* https://www.w3.org/TR/event-timing/#eventcounts
|
|
48
111
|
*/
|
|
49
|
-
export
|
|
50
|
-
// flowlint unsafe-getters-setters:off
|
|
112
|
+
export class EventCounts {
|
|
51
113
|
get size(): number {
|
|
52
114
|
return getCachedEventCounts().size;
|
|
53
115
|
}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the MIT license found in the
|
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
*
|
|
7
|
+
* @format
|
|
8
|
+
* @flow strict
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
// flowlint unsafe-getters-setters:off
|
|
12
|
+
|
|
13
|
+
import type {PerformanceEntryJSON} from './PerformanceEntry';
|
|
14
|
+
|
|
15
|
+
import {PerformanceEntry} from './PerformanceEntry';
|
|
16
|
+
|
|
17
|
+
export type PerformanceLongTaskTimingJSON = {
|
|
18
|
+
...PerformanceEntryJSON,
|
|
19
|
+
attribution: $ReadOnlyArray<TaskAttributionTiming>,
|
|
20
|
+
...
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
export class TaskAttributionTiming extends PerformanceEntry {}
|
|
24
|
+
|
|
25
|
+
const EMPTY_ATTRIBUTION: $ReadOnlyArray<TaskAttributionTiming> =
|
|
26
|
+
Object.preventExtensions([]);
|
|
27
|
+
|
|
28
|
+
export class PerformanceLongTaskTiming extends PerformanceEntry {
|
|
29
|
+
get attribution(): $ReadOnlyArray<TaskAttributionTiming> {
|
|
30
|
+
return EMPTY_ATTRIBUTION;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
toJSON(): PerformanceLongTaskTimingJSON {
|
|
34
|
+
return {
|
|
35
|
+
...super.toJSON(),
|
|
36
|
+
attribution: this.attribution,
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
}
|
|
@@ -10,15 +10,15 @@
|
|
|
10
10
|
|
|
11
11
|
// flowlint unsafe-getters-setters:off
|
|
12
12
|
|
|
13
|
-
import type {HighResTimeStamp, PerformanceEntryType} from './PerformanceEntry';
|
|
14
|
-
import type {PerformanceEntryList} from './PerformanceObserver';
|
|
15
13
|
import type {
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
} from './
|
|
14
|
+
DOMHighResTimeStamp,
|
|
15
|
+
PerformanceEntryType,
|
|
16
|
+
} from './PerformanceEntry';
|
|
17
|
+
import type {PerformanceEntryList} from './PerformanceObserver';
|
|
18
|
+
import type {DetailType, PerformanceMarkOptions} from './UserTiming';
|
|
19
19
|
|
|
20
20
|
import warnOnce from '../../../../Libraries/Utilities/warnOnce';
|
|
21
|
-
import EventCounts from './
|
|
21
|
+
import {EventCounts} from './EventTiming';
|
|
22
22
|
import MemoryInfo from './MemoryInfo';
|
|
23
23
|
import {ALWAYS_LOGGED_ENTRY_TYPES} from './PerformanceEntry';
|
|
24
24
|
import {warnNoNativePerformanceObserver} from './PerformanceObserver';
|
|
@@ -37,7 +37,7 @@ declare var global: {
|
|
|
37
37
|
+nativePerformanceNow?: ?() => number,
|
|
38
38
|
};
|
|
39
39
|
|
|
40
|
-
const getCurrentTimeStamp: () =>
|
|
40
|
+
const getCurrentTimeStamp: () => DOMHighResTimeStamp =
|
|
41
41
|
NativePerformance?.now ?? global.nativePerformanceNow ?? (() => Date.now());
|
|
42
42
|
|
|
43
43
|
// We want some of the performance entry types to be always logged,
|
|
@@ -58,6 +58,13 @@ function warnNoNativePerformance() {
|
|
|
58
58
|
);
|
|
59
59
|
}
|
|
60
60
|
|
|
61
|
+
export type PerformanceMeasureOptions = {
|
|
62
|
+
detail?: DetailType,
|
|
63
|
+
start?: DOMHighResTimeStamp,
|
|
64
|
+
duration?: DOMHighResTimeStamp,
|
|
65
|
+
end?: DOMHighResTimeStamp,
|
|
66
|
+
};
|
|
67
|
+
|
|
61
68
|
/**
|
|
62
69
|
* Partial implementation of the Performance interface for RN,
|
|
63
70
|
* corresponding to the standard in
|
|
@@ -195,7 +202,13 @@ export default class Performance {
|
|
|
195
202
|
duration = options.duration ?? duration;
|
|
196
203
|
}
|
|
197
204
|
|
|
198
|
-
const measure = new PerformanceMeasure(measureName,
|
|
205
|
+
const measure = new PerformanceMeasure(measureName, {
|
|
206
|
+
// FIXME(T196011255): this is incorrect, as we're only assigning the
|
|
207
|
+
// start/end if they're specified as a number, but not if they're
|
|
208
|
+
// specified as previous mark names.
|
|
209
|
+
startTime,
|
|
210
|
+
duration,
|
|
211
|
+
});
|
|
199
212
|
|
|
200
213
|
if (NativePerformance?.measure) {
|
|
201
214
|
NativePerformance.measure(
|
|
@@ -229,7 +242,7 @@ export default class Performance {
|
|
|
229
242
|
* Returns a double, measured in milliseconds.
|
|
230
243
|
* https://developer.mozilla.org/en-US/docs/Web/API/Performance/now
|
|
231
244
|
*/
|
|
232
|
-
now():
|
|
245
|
+
now(): DOMHighResTimeStamp {
|
|
233
246
|
return getCurrentTimeStamp();
|
|
234
247
|
}
|
|
235
248
|
|