@office-iss/react-native-win32 0.0.0-canary.291 → 0.0.0-canary.293
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 +1 -1
- package/CHANGELOG.json +43 -1
- package/CHANGELOG.md +22 -4
- package/Libraries/Alert/RCTAlertManager.js +17 -0
- package/Libraries/Animated/AnimatedEvent.js +4 -3
- package/Libraries/Animated/AnimatedExports.js.flow +2 -0
- package/Libraries/Animated/AnimatedImplementation.js +2 -2
- package/Libraries/Animated/components/AnimatedScrollView.js +48 -43
- package/Libraries/Animated/nodes/AnimatedValue.js +2 -1
- package/Libraries/BatchedBridge/MessageQueue.js +2 -2
- package/Libraries/Blob/FileReader.js +219 -8
- package/Libraries/Blob/URL.js +13 -1
- package/Libraries/Components/AccessibilityInfo/legacySendAccessibilityEvent.js +17 -0
- package/Libraries/Components/Button.js +1 -1
- package/Libraries/Components/Button.win32.js +1 -1
- package/Libraries/Components/DrawerAndroid/DrawerLayoutAndroid.android.js +1 -3
- package/Libraries/{Utilities/__mocks__/GlobalPerformanceLogger.js → Components/DrawerAndroid/DrawerLayoutAndroid.ios.js} +3 -4
- package/Libraries/Components/DrawerAndroid/DrawerLayoutAndroid.js +6 -66
- package/Libraries/Components/DrawerAndroid/DrawerLayoutAndroid.js.flow +18 -0
- package/Libraries/Components/DrawerAndroid/DrawerLayoutAndroidFallback.js +71 -0
- package/Libraries/Components/Keyboard/Keyboard.js +4 -2
- package/Libraries/Components/Keyboard/KeyboardAvoidingView.js +6 -3
- package/Libraries/Components/Pressable/Pressable.js +6 -1
- package/Libraries/Components/Pressable/Pressable.win32.js +6 -1
- package/Libraries/Components/ProgressBarAndroid/ProgressBarAndroid.js +12 -2
- package/Libraries/Components/RefreshControl/RefreshControl.js +1 -1
- package/Libraries/Components/ScrollView/ScrollView.d.ts +1 -1
- package/Libraries/Components/ScrollView/ScrollView.js +128 -116
- package/Libraries/Components/StaticRenderer.js +1 -1
- package/Libraries/Components/Switch/Switch.js +7 -3
- package/Libraries/Components/TextInput/AndroidTextInputNativeComponent.js +2 -1
- package/Libraries/Components/TextInput/RCTTextInputViewConfig.js +2 -4
- package/Libraries/Components/TextInput/TextInput.flow.js +59 -42
- package/Libraries/Components/TextInput/TextInput.flow.win32.js +1208 -0
- package/Libraries/Components/TextInput/TextInput.js +67 -1005
- package/Libraries/Components/TextInput/TextInput.win32.js +69 -1037
- package/Libraries/{Blob/__mocks__/BlobModule.js → Components/ToastAndroid/ToastAndroid.ios.js} +3 -6
- package/Libraries/Components/ToastAndroid/ToastAndroid.js +4 -32
- package/Libraries/Components/ToastAndroid/ToastAndroid.js.flow +109 -0
- package/Libraries/Components/ToastAndroid/ToastAndroid.win32.js +4 -32
- package/Libraries/Components/ToastAndroid/ToastAndroidFallback.js +45 -0
- package/Libraries/Components/Touchable/Touchable.js +5 -5
- package/Libraries/Components/Touchable/Touchable.win32.js +5 -5
- package/Libraries/Components/Touchable/TouchableBounce.js +12 -6
- package/Libraries/Components/Touchable/TouchableHighlight.js +9 -6
- package/Libraries/Components/Touchable/TouchableNativeFeedback.js +4 -4
- package/Libraries/Components/Touchable/TouchableNativeFeedback.win32.js +4 -4
- package/Libraries/Components/Touchable/TouchableOpacity.js +11 -5
- package/Libraries/Components/View/View.js +18 -21
- package/Libraries/Components/View/View.win32.js +21 -24
- package/Libraries/Components/View/ViewAccessibility.js +7 -0
- package/Libraries/Components/View/ViewAccessibility.win32.js +7 -0
- package/Libraries/Components/View/ViewPropTypes.js +1 -1
- package/Libraries/Components/View/ViewPropTypes.win32.js +1 -1
- package/Libraries/Core/ReactNativeVersion.js +1 -1
- package/Libraries/Core/setUpReactDevTools.js +5 -5
- package/Libraries/EventEmitter/NativeEventEmitter.js +4 -1
- package/Libraries/Image/Image.js +17 -0
- package/Libraries/Image/Image.js.flow +2 -2
- package/Libraries/Image/ImageInjection.js +1 -1
- package/Libraries/Image/ImageProps.js +5 -5
- package/Libraries/Image/ImageSource.js +3 -1
- package/Libraries/Image/ImageSourceUtils.js +4 -2
- package/Libraries/Image/ImageTypes.flow.js +1 -1
- package/Libraries/Lists/FlatList.d.ts +2 -2
- package/Libraries/Lists/FlatList.js +1 -1
- package/Libraries/Lists/SectionList.js +1 -1
- package/Libraries/Lists/SectionListModern.js +3 -3
- package/Libraries/LogBox/Data/LogBoxData.js +1 -1
- package/Libraries/LogBox/LogBoxNotificationContainer.js +1 -1
- package/Libraries/Modal/Modal.js +3 -3
- package/Libraries/NativeComponent/BaseViewConfig.js +17 -0
- package/Libraries/NativeComponent/PlatformBaseViewConfig.js +2 -2
- package/Libraries/NativeModules/specs/NativeDevMenu.js +2 -2
- package/Libraries/Network/RCTNetworking.js +17 -0
- package/Libraries/Network/XMLHttpRequest.js +781 -10
- package/Libraries/NewAppScreen/components/DebugInstructions.js +1 -1
- package/Libraries/NewAppScreen/components/Header.js +1 -1
- package/Libraries/NewAppScreen/components/HermesBadge.js +1 -1
- package/Libraries/NewAppScreen/components/LearnMoreLinks.js +3 -3
- package/Libraries/NewAppScreen/components/ReloadInstructions.js +1 -1
- package/Libraries/Performance/Systrace.js +7 -7
- package/Libraries/ReactNative/AppContainer-dev.js +3 -2
- package/Libraries/ReactNative/RendererImplementation.js +6 -5
- package/Libraries/ReactNative/renderApplication.js +9 -0
- package/Libraries/ReactPrivate/ReactNativePrivateInterface.js +2 -2
- package/Libraries/Renderer/implementations/ReactFabric-dev.js +4840 -4748
- package/Libraries/Renderer/implementations/ReactFabric-prod.js +4947 -4829
- package/Libraries/Renderer/implementations/ReactFabric-profiling.js +3998 -3888
- package/Libraries/Renderer/implementations/ReactNativeRenderer-dev.js +5005 -4948
- package/Libraries/Renderer/implementations/ReactNativeRenderer-prod.js +2744 -2652
- package/Libraries/Renderer/implementations/ReactNativeRenderer-profiling.js +5020 -4933
- package/Libraries/Renderer/shims/ReactFabric.js +3 -1
- package/Libraries/Renderer/shims/ReactFeatureFlags.js +3 -1
- package/Libraries/Renderer/shims/ReactNative.js +3 -1
- package/Libraries/Renderer/shims/ReactNativeViewConfigRegistry.js +3 -1
- package/Libraries/Renderer/shims/createReactNativeComponentClass.js +3 -1
- package/Libraries/Settings/Settings.js +13 -19
- package/Libraries/Settings/Settings.win32.js +19 -20
- package/Libraries/Settings/SettingsFallback.js +33 -0
- package/Libraries/StyleSheet/PlatformColorValueTypes.js +15 -0
- package/Libraries/StyleSheet/Rect.js +1 -0
- package/Libraries/StyleSheet/StyleSheet.js.flow +3 -3
- package/Libraries/StyleSheet/StyleSheetTypes.d.ts +1 -1
- package/Libraries/StyleSheet/StyleSheetTypes.js +75 -33
- package/Libraries/StyleSheet/flattenStyle.js +7 -1
- package/Libraries/StyleSheet/processBackgroundImage.js +670 -214
- package/Libraries/Text/Text.js +3 -3
- package/Libraries/Text/Text.win32.js +3 -3
- package/Libraries/Text/TextNativeComponent.js +0 -4
- package/Libraries/Text/TextNativeComponent.win32.js +0 -4
- package/Libraries/Text/TextProps.js +1 -1
- package/Libraries/Text/TextProps.win32.js +1 -1
- package/Libraries/Utilities/Appearance.js +2 -0
- package/Libraries/Utilities/BackHandler.js +17 -0
- package/Libraries/Utilities/Platform.js +17 -0
- package/Libraries/Utilities/PlatformTypes.js +2 -0
- package/Libraries/Utilities/ReactNativeTestTools.js +1 -1
- package/Libraries/WebSocket/WebSocket.js +313 -8
- package/flow/global.js +0 -2
- package/index.js +1 -288
- package/index.win32.js +8 -297
- package/overrides.json +29 -23
- package/package.json +16 -16
- package/src/private/animated/NativeAnimatedHelper.js +1 -1
- package/src/private/animated/NativeAnimatedHelper.win32.js +1 -1
- package/src/private/animated/createAnimatedPropsHook.js +2 -27
- package/src/private/components/{SafeAreaView_INTERNAL_DO_NOT_USE.js → safeareaview/SafeAreaView_INTERNAL_DO_NOT_USE.js} +6 -6
- package/src/private/components/{HScrollViewNativeComponents.js → scrollview/HScrollViewNativeComponents.js} +8 -8
- package/src/private/components/scrollview/VScrollViewNativeComponents.js +25 -0
- package/src/private/{devmenu → devsupport/devmenu}/DevMenu.js +1 -1
- package/src/private/{inspector → devsupport/devmenu/elementinspector}/BorderBox.js +3 -3
- package/src/private/{inspector → devsupport/devmenu/elementinspector}/BoxInspector.js +6 -5
- package/src/private/{inspector → devsupport/devmenu/elementinspector}/ElementBox.js +8 -6
- package/src/private/{inspector → devsupport/devmenu/elementinspector}/ElementProperties.js +11 -10
- package/src/private/{inspector → devsupport/devmenu/elementinspector}/Inspector.js +14 -12
- package/src/private/{inspector → devsupport/devmenu/elementinspector}/InspectorOverlay.js +5 -4
- package/src/private/{inspector → devsupport/devmenu/elementinspector}/InspectorPanel.js +9 -8
- package/src/private/{inspector → devsupport/devmenu/elementinspector}/NetworkOverlay.js +10 -9
- package/src/private/{inspector → devsupport/devmenu/elementinspector}/ReactDevToolsOverlay.js +7 -7
- package/src/private/{inspector → devsupport/devmenu/elementinspector}/StyleInspector.js +7 -6
- package/src/private/{inspector → devsupport/devmenu/elementinspector}/XHRInterceptor.js +2 -2
- package/src/private/{inspector → devsupport/devmenu/elementinspector}/getInspectorDataForViewAtPoint.js +2 -2
- package/src/private/{inspector → devsupport/devmenu/elementinspector}/resolveBoxStyle.js +1 -1
- package/src/private/{inspector → devsupport/devmenu/perfmonitor}/PerformanceOverlay.js +6 -5
- package/src/private/{specs_DEPRECATED/modules → devsupport/devmenu/specs}/NativeDevMenu.js +2 -2
- package/src/private/{debugging → devsupport/rndevtools}/ReactDevToolsSettingsManager.android.js +1 -1
- package/src/private/{debugging → devsupport/rndevtools}/ReactDevToolsSettingsManager.ios.js +1 -1
- package/src/private/{debugging → devsupport/rndevtools}/ReactDevToolsSettingsManager.win32.js +1 -1
- package/src/private/{debugging → devsupport/rndevtools}/setUpFuseboxReactDevToolsDispatcher.js +1 -1
- package/src/private/{fusebox → devsupport/rndevtools}/specs/NativeReactDevToolsRuntimeSettingsModule.js +2 -2
- package/src/private/{specs_DEPRECATED/modules → devsupport/rndevtools/specs}/NativeReactDevToolsSettingsManager.js +2 -2
- package/src/private/featureflags/ReactNativeFeatureFlags.js +37 -43
- package/src/private/featureflags/specs/NativeReactNativeFeatureFlags.js +8 -8
- package/src/private/renderer/errorhandling/ErrorHandlers.js +2 -2
- package/src/private/specs_DEPRECATED/modules/NativeSampleTurboModule.js +3 -0
- package/src/private/types/HostComponent.js +1 -1
- package/src/private/types/HostInstance.js +12 -4
- package/src/private/webapis/performance/Performance.js +1 -3
- package/types/index.d.ts +1 -1
- package/types/public/ReactNativeTypes.d.ts +2 -2
- package/Libraries/BatchedBridge/__mocks__/MessageQueueTestConfig.js +0 -38
- package/Libraries/BatchedBridge/__mocks__/MessageQueueTestModule.js +0 -22
- package/Libraries/Blob/FileReader_new.js +0 -231
- package/Libraries/Blob/FileReader_old.js +0 -186
- package/Libraries/Blob/__mocks__/FileReaderModule.js +0 -20
- package/Libraries/Components/RefreshControl/__mocks__/RefreshControlMock.js +0 -32
- package/Libraries/Core/__mocks__/ErrorUtils.js +0 -33
- package/Libraries/Core/__mocks__/NativeExceptionsManager.js +0 -19
- package/Libraries/EventEmitter/__mocks__/NativeEventEmitter.js +0 -49
- package/Libraries/Events/CustomEvent.js +0 -32
- package/Libraries/Events/EventPolyfill.js +0 -239
- package/Libraries/Lists/__flowtests__/FlatList-flowtest.js +0 -118
- package/Libraries/Lists/__flowtests__/SectionList-flowtest.js +0 -134
- package/Libraries/Network/XMLHttpRequest_new.js +0 -794
- package/Libraries/Network/XMLHttpRequest_old.js +0 -701
- package/Libraries/StyleSheet/__flowtests__/StyleSheet-flowtest.js +0 -58
- package/Libraries/Utilities/__mocks__/BackHandler.js +0 -45
- package/Libraries/Utilities/__mocks__/PixelRatio.js +0 -25
- package/Libraries/WebSocket/WebSocketEvent.js +0 -30
- package/Libraries/WebSocket/WebSocket_new.js +0 -325
- package/Libraries/WebSocket/WebSocket_old.js +0 -297
- package/Libraries/WebSocket/__mocks__/event-target-shim.js +0 -27
- package/Libraries/__flowtests__/ReactNativeTypes-flowtest.js +0 -30
- package/Libraries/vendor/emitter/__flowtests__/EventEmitter-flowtest.js +0 -81
- package/jest/__tests__/setup-test.js +0 -18
- package/src/private/components/VScrollViewNativeComponents.js +0 -25
- package/src/private/webapis/performance/specs/__mocks__/NativePerformanceMock.js +0 -267
- package/src/types/third_party/event-target-shim.d.ts +0 -392
- /package/src/private/{devmenu → devsupport/devmenu}/DevMenu.d.ts +0 -0
- /package/src/private/{debugging → devsupport/rndevtools}/FuseboxSessionObserver.js +0 -0
|
@@ -1,267 +0,0 @@
|
|
|
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
|
-
* @flow strict
|
|
8
|
-
* @format
|
|
9
|
-
*/
|
|
10
|
-
|
|
11
|
-
import type {
|
|
12
|
-
NativeBatchedObserverCallback,
|
|
13
|
-
NativeMemoryInfo,
|
|
14
|
-
NativePerformanceMarkResult,
|
|
15
|
-
NativePerformanceMeasureResult,
|
|
16
|
-
OpaqueNativeObserverHandle,
|
|
17
|
-
PerformanceObserverInit,
|
|
18
|
-
RawPerformanceEntry,
|
|
19
|
-
RawPerformanceEntryType,
|
|
20
|
-
ReactNativeStartupTiming,
|
|
21
|
-
} from '../NativePerformance';
|
|
22
|
-
import typeof NativePerformance from '../NativePerformance';
|
|
23
|
-
|
|
24
|
-
import {RawPerformanceEntryTypeValues} from '../../internals/RawPerformanceEntry';
|
|
25
|
-
|
|
26
|
-
type MockObserver = {
|
|
27
|
-
handleEntry: (entry: RawPerformanceEntry) => void,
|
|
28
|
-
callback: NativeBatchedObserverCallback,
|
|
29
|
-
didScheduleFlushBuffer: boolean,
|
|
30
|
-
entries: Array<RawPerformanceEntry>,
|
|
31
|
-
options: PerformanceObserverInit,
|
|
32
|
-
droppedEntriesCount: number,
|
|
33
|
-
};
|
|
34
|
-
|
|
35
|
-
const eventCounts: Map<string, number> = new Map();
|
|
36
|
-
const observers: Set<MockObserver> = new Set();
|
|
37
|
-
const marks: Map<string, number> = new Map();
|
|
38
|
-
let entries: Array<RawPerformanceEntry> = [];
|
|
39
|
-
|
|
40
|
-
function getMockObserver(
|
|
41
|
-
opaqueNativeObserverHandle: OpaqueNativeObserverHandle,
|
|
42
|
-
): MockObserver {
|
|
43
|
-
return opaqueNativeObserverHandle as $FlowFixMe as MockObserver;
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
function createMockObserver(callback: NativeBatchedObserverCallback) {
|
|
47
|
-
const observer: MockObserver = {
|
|
48
|
-
callback,
|
|
49
|
-
didScheduleFlushBuffer: false,
|
|
50
|
-
entries: [],
|
|
51
|
-
options: {},
|
|
52
|
-
droppedEntriesCount: 0,
|
|
53
|
-
handleEntry: (entry: RawPerformanceEntry) => {
|
|
54
|
-
if (
|
|
55
|
-
observer.options.type !== entry.entryType &&
|
|
56
|
-
!observer.options.entryTypes?.includes(entry.entryType)
|
|
57
|
-
) {
|
|
58
|
-
return;
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
if (
|
|
62
|
-
entry.entryType === RawPerformanceEntryTypeValues.EVENT &&
|
|
63
|
-
entry.duration < (observer.options?.durationThreshold ?? 0)
|
|
64
|
-
) {
|
|
65
|
-
return;
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
observer.entries.push(entry);
|
|
69
|
-
|
|
70
|
-
if (!observer.didScheduleFlushBuffer) {
|
|
71
|
-
observer.didScheduleFlushBuffer = true;
|
|
72
|
-
// $FlowFixMe[incompatible-call]
|
|
73
|
-
global.queueMicrotask(() => {
|
|
74
|
-
observer.didScheduleFlushBuffer = false;
|
|
75
|
-
// We want to emulate the way it's done in native (i.e. async/batched)
|
|
76
|
-
observer.callback();
|
|
77
|
-
});
|
|
78
|
-
}
|
|
79
|
-
},
|
|
80
|
-
};
|
|
81
|
-
|
|
82
|
-
return observer;
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
export function reportEntry(entry: RawPerformanceEntry) {
|
|
86
|
-
entries.push(entry);
|
|
87
|
-
|
|
88
|
-
switch (entry.entryType) {
|
|
89
|
-
case RawPerformanceEntryTypeValues.MARK:
|
|
90
|
-
marks.set(entry.name, entry.startTime);
|
|
91
|
-
break;
|
|
92
|
-
case RawPerformanceEntryTypeValues.MEASURE:
|
|
93
|
-
break;
|
|
94
|
-
case RawPerformanceEntryTypeValues.EVENT:
|
|
95
|
-
eventCounts.set(entry.name, (eventCounts.get(entry.name) ?? 0) + 1);
|
|
96
|
-
break;
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
for (const observer of observers) {
|
|
100
|
-
observer.handleEntry(entry);
|
|
101
|
-
}
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
let currentTime: number = 12;
|
|
105
|
-
|
|
106
|
-
const NativePerformanceMock = {
|
|
107
|
-
setCurrentTime: (time: number): void => {
|
|
108
|
-
currentTime = time;
|
|
109
|
-
},
|
|
110
|
-
|
|
111
|
-
now: (): number => currentTime,
|
|
112
|
-
|
|
113
|
-
markWithResult: (
|
|
114
|
-
name: string,
|
|
115
|
-
startTime?: number,
|
|
116
|
-
): NativePerformanceMarkResult => {
|
|
117
|
-
const computedStartTime = startTime ?? performance.now();
|
|
118
|
-
|
|
119
|
-
marks.set(name, computedStartTime);
|
|
120
|
-
reportEntry({
|
|
121
|
-
entryType: RawPerformanceEntryTypeValues.MARK,
|
|
122
|
-
name,
|
|
123
|
-
startTime: computedStartTime,
|
|
124
|
-
duration: 0,
|
|
125
|
-
});
|
|
126
|
-
|
|
127
|
-
return computedStartTime;
|
|
128
|
-
},
|
|
129
|
-
|
|
130
|
-
measureWithResult: (
|
|
131
|
-
name: string,
|
|
132
|
-
startTime: number,
|
|
133
|
-
endTime: number,
|
|
134
|
-
duration?: number,
|
|
135
|
-
startMark?: string,
|
|
136
|
-
endMark?: string,
|
|
137
|
-
): NativePerformanceMeasureResult => {
|
|
138
|
-
const start = startMark != null ? marks.get(startMark) : startTime;
|
|
139
|
-
const end = endMark != null ? marks.get(endMark) : endTime;
|
|
140
|
-
|
|
141
|
-
if (start === undefined) {
|
|
142
|
-
throw new Error('startMark does not exist');
|
|
143
|
-
}
|
|
144
|
-
|
|
145
|
-
if (end === undefined) {
|
|
146
|
-
throw new Error('endMark does not exist');
|
|
147
|
-
}
|
|
148
|
-
|
|
149
|
-
const computedDuration = duration ?? end - start;
|
|
150
|
-
reportEntry({
|
|
151
|
-
entryType: RawPerformanceEntryTypeValues.MEASURE,
|
|
152
|
-
name,
|
|
153
|
-
startTime: start,
|
|
154
|
-
duration: computedDuration,
|
|
155
|
-
});
|
|
156
|
-
|
|
157
|
-
return [start, computedDuration];
|
|
158
|
-
},
|
|
159
|
-
|
|
160
|
-
getSimpleMemoryInfo: (): NativeMemoryInfo => {
|
|
161
|
-
return {};
|
|
162
|
-
},
|
|
163
|
-
|
|
164
|
-
getReactNativeStartupTiming: (): ReactNativeStartupTiming => {
|
|
165
|
-
return {
|
|
166
|
-
startTime: 0,
|
|
167
|
-
endTime: 0,
|
|
168
|
-
executeJavaScriptBundleEntryPointStart: 0,
|
|
169
|
-
executeJavaScriptBundleEntryPointEnd: 0,
|
|
170
|
-
initializeRuntimeStart: 0,
|
|
171
|
-
initializeRuntimeEnd: 0,
|
|
172
|
-
};
|
|
173
|
-
},
|
|
174
|
-
|
|
175
|
-
getEventCounts: (): $ReadOnlyArray<[string, number]> => {
|
|
176
|
-
return Array.from(eventCounts.entries());
|
|
177
|
-
},
|
|
178
|
-
|
|
179
|
-
createObserver: (
|
|
180
|
-
callback: NativeBatchedObserverCallback,
|
|
181
|
-
): OpaqueNativeObserverHandle => {
|
|
182
|
-
return createMockObserver(callback);
|
|
183
|
-
},
|
|
184
|
-
|
|
185
|
-
getDroppedEntriesCount: (observer: OpaqueNativeObserverHandle): number => {
|
|
186
|
-
return getMockObserver(observer).droppedEntriesCount;
|
|
187
|
-
},
|
|
188
|
-
|
|
189
|
-
observe: (
|
|
190
|
-
observer: OpaqueNativeObserverHandle,
|
|
191
|
-
options: PerformanceObserverInit,
|
|
192
|
-
): void => {
|
|
193
|
-
const mockObserver = getMockObserver(observer);
|
|
194
|
-
mockObserver.options = options;
|
|
195
|
-
observers.add(mockObserver);
|
|
196
|
-
},
|
|
197
|
-
|
|
198
|
-
disconnect: (observer: OpaqueNativeObserverHandle): void => {
|
|
199
|
-
const mockObserver = getMockObserver(observer);
|
|
200
|
-
observers.delete(mockObserver);
|
|
201
|
-
},
|
|
202
|
-
|
|
203
|
-
takeRecords: (
|
|
204
|
-
observer: OpaqueNativeObserverHandle,
|
|
205
|
-
): $ReadOnlyArray<RawPerformanceEntry> => {
|
|
206
|
-
const mockObserver = getMockObserver(observer);
|
|
207
|
-
const observerEntries = mockObserver.entries;
|
|
208
|
-
mockObserver.entries = [];
|
|
209
|
-
return observerEntries.sort((a, b) => a.startTime - b.startTime);
|
|
210
|
-
},
|
|
211
|
-
|
|
212
|
-
clearMarks: (entryName?: string) => {
|
|
213
|
-
if (entryName != null) {
|
|
214
|
-
marks.delete(entryName);
|
|
215
|
-
} else {
|
|
216
|
-
marks.clear();
|
|
217
|
-
}
|
|
218
|
-
|
|
219
|
-
entries = entries.filter(
|
|
220
|
-
entry =>
|
|
221
|
-
entry.entryType !== RawPerformanceEntryTypeValues.MARK ||
|
|
222
|
-
(entryName != null && entry.name !== entryName),
|
|
223
|
-
);
|
|
224
|
-
},
|
|
225
|
-
|
|
226
|
-
clearMeasures: (entryName?: string) => {
|
|
227
|
-
entries = entries.filter(
|
|
228
|
-
entry =>
|
|
229
|
-
entry.entryType !== RawPerformanceEntryTypeValues.MEASURE ||
|
|
230
|
-
(entryName != null && entry.name !== entryName),
|
|
231
|
-
);
|
|
232
|
-
},
|
|
233
|
-
|
|
234
|
-
getEntries: (): $ReadOnlyArray<RawPerformanceEntry> => {
|
|
235
|
-
return [...entries].sort((a, b) => a.startTime - b.startTime);
|
|
236
|
-
},
|
|
237
|
-
|
|
238
|
-
getEntriesByName: (
|
|
239
|
-
entryName: string,
|
|
240
|
-
entryType?: ?RawPerformanceEntryType,
|
|
241
|
-
): $ReadOnlyArray<RawPerformanceEntry> => {
|
|
242
|
-
return NativePerformanceMock.getEntries().filter(
|
|
243
|
-
entry =>
|
|
244
|
-
(entryType == null || entry.entryType === entryType) &&
|
|
245
|
-
entry.name === entryName,
|
|
246
|
-
);
|
|
247
|
-
},
|
|
248
|
-
|
|
249
|
-
getEntriesByType: (
|
|
250
|
-
entryType: RawPerformanceEntryType,
|
|
251
|
-
): $ReadOnlyArray<RawPerformanceEntry> => {
|
|
252
|
-
return entries.filter(entry => entry.entryType === entryType);
|
|
253
|
-
},
|
|
254
|
-
|
|
255
|
-
getSupportedPerformanceEntryTypes:
|
|
256
|
-
(): $ReadOnlyArray<RawPerformanceEntryType> => {
|
|
257
|
-
return [
|
|
258
|
-
RawPerformanceEntryTypeValues.MARK,
|
|
259
|
-
RawPerformanceEntryTypeValues.MEASURE,
|
|
260
|
-
RawPerformanceEntryTypeValues.EVENT,
|
|
261
|
-
];
|
|
262
|
-
},
|
|
263
|
-
};
|
|
264
|
-
|
|
265
|
-
(NativePerformanceMock: NativePerformance);
|
|
266
|
-
|
|
267
|
-
export default NativePerformanceMock;
|
|
@@ -1,392 +0,0 @@
|
|
|
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
|
-
*/
|
|
9
|
-
|
|
10
|
-
export as namespace EventTargetShim;
|
|
11
|
-
|
|
12
|
-
/**
|
|
13
|
-
* `Event` interface.
|
|
14
|
-
* @see https://dom.spec.whatwg.org/#event
|
|
15
|
-
*/
|
|
16
|
-
export interface Event {
|
|
17
|
-
/**
|
|
18
|
-
* The type of this event.
|
|
19
|
-
*/
|
|
20
|
-
readonly type: string;
|
|
21
|
-
|
|
22
|
-
/**
|
|
23
|
-
* The target of this event.
|
|
24
|
-
*/
|
|
25
|
-
readonly target: EventTarget<{}, {}, 'standard'> | null;
|
|
26
|
-
|
|
27
|
-
/**
|
|
28
|
-
* The current target of this event.
|
|
29
|
-
*/
|
|
30
|
-
readonly currentTarget: EventTarget<{}, {}, 'standard'> | null;
|
|
31
|
-
|
|
32
|
-
/**
|
|
33
|
-
* The target of this event.
|
|
34
|
-
* @deprecated
|
|
35
|
-
*/
|
|
36
|
-
readonly srcElement: any | null;
|
|
37
|
-
|
|
38
|
-
/**
|
|
39
|
-
* The composed path of this event.
|
|
40
|
-
*/
|
|
41
|
-
composedPath(): EventTarget<{}, {}, 'standard'>[];
|
|
42
|
-
|
|
43
|
-
/**
|
|
44
|
-
* Constant of NONE.
|
|
45
|
-
*/
|
|
46
|
-
readonly NONE: number;
|
|
47
|
-
|
|
48
|
-
/**
|
|
49
|
-
* Constant of CAPTURING_PHASE.
|
|
50
|
-
*/
|
|
51
|
-
readonly CAPTURING_PHASE: number;
|
|
52
|
-
|
|
53
|
-
/**
|
|
54
|
-
* Constant of BUBBLING_PHASE.
|
|
55
|
-
*/
|
|
56
|
-
readonly BUBBLING_PHASE: number;
|
|
57
|
-
|
|
58
|
-
/**
|
|
59
|
-
* Constant of AT_TARGET.
|
|
60
|
-
*/
|
|
61
|
-
readonly AT_TARGET: number;
|
|
62
|
-
|
|
63
|
-
/**
|
|
64
|
-
* Indicates which phase of the event flow is currently being evaluated.
|
|
65
|
-
*/
|
|
66
|
-
readonly eventPhase: number;
|
|
67
|
-
|
|
68
|
-
/**
|
|
69
|
-
* Stop event bubbling.
|
|
70
|
-
*/
|
|
71
|
-
stopPropagation(): void;
|
|
72
|
-
|
|
73
|
-
/**
|
|
74
|
-
* Stop event bubbling.
|
|
75
|
-
*/
|
|
76
|
-
stopImmediatePropagation(): void;
|
|
77
|
-
|
|
78
|
-
/**
|
|
79
|
-
* Initialize event.
|
|
80
|
-
* @deprecated
|
|
81
|
-
*/
|
|
82
|
-
initEvent(type: string, bubbles?: boolean, cancelable?: boolean): void;
|
|
83
|
-
|
|
84
|
-
/**
|
|
85
|
-
* The flag indicating bubbling.
|
|
86
|
-
*/
|
|
87
|
-
readonly bubbles: boolean;
|
|
88
|
-
|
|
89
|
-
/**
|
|
90
|
-
* Stop event bubbling.
|
|
91
|
-
* @deprecated
|
|
92
|
-
*/
|
|
93
|
-
cancelBubble: boolean;
|
|
94
|
-
|
|
95
|
-
/**
|
|
96
|
-
* Set or get cancellation flag.
|
|
97
|
-
* @deprecated
|
|
98
|
-
*/
|
|
99
|
-
returnValue: boolean;
|
|
100
|
-
|
|
101
|
-
/**
|
|
102
|
-
* The flag indicating whether the event can be canceled.
|
|
103
|
-
*/
|
|
104
|
-
readonly cancelable: boolean;
|
|
105
|
-
|
|
106
|
-
/**
|
|
107
|
-
* Cancel this event.
|
|
108
|
-
*/
|
|
109
|
-
preventDefault(): void;
|
|
110
|
-
|
|
111
|
-
/**
|
|
112
|
-
* The flag to indicating whether the event was canceled.
|
|
113
|
-
*/
|
|
114
|
-
readonly defaultPrevented: boolean;
|
|
115
|
-
|
|
116
|
-
/**
|
|
117
|
-
* The flag to indicating if event is composed.
|
|
118
|
-
*/
|
|
119
|
-
readonly composed: boolean;
|
|
120
|
-
|
|
121
|
-
/**
|
|
122
|
-
* Indicates whether the event was dispatched by the user agent.
|
|
123
|
-
*/
|
|
124
|
-
readonly isTrusted: boolean;
|
|
125
|
-
|
|
126
|
-
/**
|
|
127
|
-
* The unix time of this event.
|
|
128
|
-
*/
|
|
129
|
-
readonly timeStamp: number;
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
/**
|
|
133
|
-
* The constructor of `EventTarget` interface.
|
|
134
|
-
*/
|
|
135
|
-
export type EventTargetConstructor<
|
|
136
|
-
TEvents extends EventTarget.EventDefinition = {},
|
|
137
|
-
TEventAttributes extends EventTarget.EventDefinition = {},
|
|
138
|
-
TMode extends EventTarget.Mode = 'loose',
|
|
139
|
-
> = {
|
|
140
|
-
prototype: EventTarget<TEvents, TEventAttributes, TMode>;
|
|
141
|
-
new (): EventTarget<TEvents, TEventAttributes, TMode>;
|
|
142
|
-
};
|
|
143
|
-
|
|
144
|
-
/**
|
|
145
|
-
* `EventTarget` interface.
|
|
146
|
-
* @see https://dom.spec.whatwg.org/#interface-eventtarget
|
|
147
|
-
*/
|
|
148
|
-
export type EventTarget<
|
|
149
|
-
TEvents extends EventTarget.EventDefinition = {},
|
|
150
|
-
TEventAttributes extends EventTarget.EventDefinition = {},
|
|
151
|
-
TMode extends EventTarget.Mode = 'loose',
|
|
152
|
-
> = EventTarget.EventAttributes<TEventAttributes> & {
|
|
153
|
-
/**
|
|
154
|
-
* Add a given listener to this event target.
|
|
155
|
-
* @param eventName The event name to add.
|
|
156
|
-
* @param listener The listener to add.
|
|
157
|
-
* @param options The options for this listener.
|
|
158
|
-
*/
|
|
159
|
-
addEventListener<TEventType extends EventTarget.EventType<TEvents, TMode>>(
|
|
160
|
-
type: TEventType,
|
|
161
|
-
listener: EventTarget.Listener<
|
|
162
|
-
EventTarget.PickEvent<TEvents, TEventType>
|
|
163
|
-
> | null,
|
|
164
|
-
options?: boolean | EventTarget.AddOptions,
|
|
165
|
-
): void;
|
|
166
|
-
|
|
167
|
-
/**
|
|
168
|
-
* Remove a given listener from this event target.
|
|
169
|
-
* @param eventName The event name to remove.
|
|
170
|
-
* @param listener The listener to remove.
|
|
171
|
-
* @param options The options for this listener.
|
|
172
|
-
*/
|
|
173
|
-
removeEventListener<TEventType extends EventTarget.EventType<TEvents, TMode>>(
|
|
174
|
-
type: TEventType,
|
|
175
|
-
listener: EventTarget.Listener<
|
|
176
|
-
EventTarget.PickEvent<TEvents, TEventType>
|
|
177
|
-
> | null,
|
|
178
|
-
options?: boolean | EventTarget.RemoveOptions,
|
|
179
|
-
): void;
|
|
180
|
-
|
|
181
|
-
/**
|
|
182
|
-
* Dispatch a given event.
|
|
183
|
-
* @param event The event to dispatch.
|
|
184
|
-
* @returns `false` if canceled.
|
|
185
|
-
*/
|
|
186
|
-
dispatchEvent<TEventType extends EventTarget.EventType<TEvents, TMode>>(
|
|
187
|
-
event: EventTarget.EventData<TEvents, TEventType, TMode>,
|
|
188
|
-
): boolean;
|
|
189
|
-
};
|
|
190
|
-
|
|
191
|
-
export const EventTarget: EventTargetConstructor & {
|
|
192
|
-
/**
|
|
193
|
-
* Create an `EventTarget` instance with detailed event definition.
|
|
194
|
-
*
|
|
195
|
-
* The detailed event definition requires to use `defineEventAttribute()`
|
|
196
|
-
* function later.
|
|
197
|
-
*
|
|
198
|
-
* Unfortunately, the second type parameter `TEventAttributes` was needed
|
|
199
|
-
* because we cannot compute string literal types.
|
|
200
|
-
*
|
|
201
|
-
* @example
|
|
202
|
-
* const signal = new EventTarget<{ abort: Event }, { onabort: Event }>()
|
|
203
|
-
* defineEventAttribute(signal, "abort")
|
|
204
|
-
*/
|
|
205
|
-
new <
|
|
206
|
-
TEvents extends EventTarget.EventDefinition,
|
|
207
|
-
TEventAttributes extends EventTarget.EventDefinition,
|
|
208
|
-
TMode extends EventTarget.Mode = 'loose',
|
|
209
|
-
>(): EventTarget<TEvents, TEventAttributes, TMode>;
|
|
210
|
-
|
|
211
|
-
/**
|
|
212
|
-
* Define an `EventTarget` constructor with attribute events and detailed event definition.
|
|
213
|
-
*
|
|
214
|
-
* Unfortunately, the second type parameter `TEventAttributes` was needed
|
|
215
|
-
* because we cannot compute string literal types.
|
|
216
|
-
*
|
|
217
|
-
* @example
|
|
218
|
-
* class AbortSignal extends EventTarget<{ abort: Event }, { onabort: Event }>("abort") {
|
|
219
|
-
* abort(): void {}
|
|
220
|
-
* }
|
|
221
|
-
*
|
|
222
|
-
* @param events Optional event attributes (e.g. passing in `"click"` adds `onclick` to prototype).
|
|
223
|
-
*/
|
|
224
|
-
<
|
|
225
|
-
TEvents extends EventTarget.EventDefinition = {},
|
|
226
|
-
TEventAttributes extends EventTarget.EventDefinition = {},
|
|
227
|
-
TMode extends EventTarget.Mode = 'loose',
|
|
228
|
-
>(
|
|
229
|
-
events: string[],
|
|
230
|
-
): EventTargetConstructor<TEvents, TEventAttributes, TMode>;
|
|
231
|
-
|
|
232
|
-
/**
|
|
233
|
-
* Define an `EventTarget` constructor with attribute events and detailed event definition.
|
|
234
|
-
*
|
|
235
|
-
* Unfortunately, the second type parameter `TEventAttributes` was needed
|
|
236
|
-
* because we cannot compute string literal types.
|
|
237
|
-
*
|
|
238
|
-
* @example
|
|
239
|
-
* class AbortSignal extends EventTarget<{ abort: Event }, { onabort: Event }>("abort") {
|
|
240
|
-
* abort(): void {}
|
|
241
|
-
* }
|
|
242
|
-
*
|
|
243
|
-
* @param events Optional event attributes (e.g. passing in `"click"` adds `onclick` to prototype).
|
|
244
|
-
*/
|
|
245
|
-
<
|
|
246
|
-
TEvents extends EventTarget.EventDefinition = {},
|
|
247
|
-
TEventAttributes extends EventTarget.EventDefinition = {},
|
|
248
|
-
TMode extends EventTarget.Mode = 'loose',
|
|
249
|
-
>(
|
|
250
|
-
event0: string,
|
|
251
|
-
...events: string[]
|
|
252
|
-
): EventTargetConstructor<TEvents, TEventAttributes, TMode>;
|
|
253
|
-
};
|
|
254
|
-
|
|
255
|
-
export namespace EventTarget {
|
|
256
|
-
/**
|
|
257
|
-
* Options of `removeEventListener()` method.
|
|
258
|
-
*/
|
|
259
|
-
export interface RemoveOptions {
|
|
260
|
-
/**
|
|
261
|
-
* The flag to indicate that the listener is for the capturing phase.
|
|
262
|
-
*/
|
|
263
|
-
capture?: boolean | undefined;
|
|
264
|
-
}
|
|
265
|
-
|
|
266
|
-
/**
|
|
267
|
-
* Options of `addEventListener()` method.
|
|
268
|
-
*/
|
|
269
|
-
export interface AddOptions extends RemoveOptions {
|
|
270
|
-
/**
|
|
271
|
-
* The flag to indicate that the listener doesn't support
|
|
272
|
-
* `event.preventDefault()` operation.
|
|
273
|
-
*/
|
|
274
|
-
passive?: boolean | undefined;
|
|
275
|
-
/**
|
|
276
|
-
* The flag to indicate that the listener will be removed on the first
|
|
277
|
-
* event.
|
|
278
|
-
*/
|
|
279
|
-
once?: boolean | undefined;
|
|
280
|
-
}
|
|
281
|
-
|
|
282
|
-
/**
|
|
283
|
-
* The type of regular listeners.
|
|
284
|
-
*/
|
|
285
|
-
export interface FunctionListener<TEvent> {
|
|
286
|
-
(event: TEvent): void;
|
|
287
|
-
}
|
|
288
|
-
|
|
289
|
-
/**
|
|
290
|
-
* The type of object listeners.
|
|
291
|
-
*/
|
|
292
|
-
export interface ObjectListener<TEvent> {
|
|
293
|
-
handleEvent(event: TEvent): void;
|
|
294
|
-
}
|
|
295
|
-
|
|
296
|
-
/**
|
|
297
|
-
* The type of listeners.
|
|
298
|
-
*/
|
|
299
|
-
export type Listener<TEvent> =
|
|
300
|
-
| FunctionListener<TEvent>
|
|
301
|
-
| ObjectListener<TEvent>;
|
|
302
|
-
|
|
303
|
-
/**
|
|
304
|
-
* Event definition.
|
|
305
|
-
*/
|
|
306
|
-
export type EventDefinition = {
|
|
307
|
-
readonly [key: string]: Event;
|
|
308
|
-
};
|
|
309
|
-
|
|
310
|
-
/**
|
|
311
|
-
* Mapped type for event attributes.
|
|
312
|
-
*/
|
|
313
|
-
export type EventAttributes<TEventAttributes extends EventDefinition> = {
|
|
314
|
-
[P in keyof TEventAttributes]: FunctionListener<TEventAttributes[P]> | null;
|
|
315
|
-
};
|
|
316
|
-
|
|
317
|
-
/**
|
|
318
|
-
* The type of event data for `dispatchEvent()` method.
|
|
319
|
-
*/
|
|
320
|
-
export type EventData<
|
|
321
|
-
TEvents extends EventDefinition,
|
|
322
|
-
TEventType extends keyof TEvents | string,
|
|
323
|
-
TMode extends Mode,
|
|
324
|
-
> = TEventType extends keyof TEvents
|
|
325
|
-
? // Require properties which are not generated automatically.
|
|
326
|
-
Pick<
|
|
327
|
-
TEvents[TEventType],
|
|
328
|
-
Exclude<keyof TEvents[TEventType], OmittableEventKeys>
|
|
329
|
-
> &
|
|
330
|
-
// Properties which are generated automatically are optional.
|
|
331
|
-
Partial<Pick<Event, OmittableEventKeys>>
|
|
332
|
-
: TMode extends 'standard'
|
|
333
|
-
? Event
|
|
334
|
-
: Event | NonStandardEvent;
|
|
335
|
-
|
|
336
|
-
/**
|
|
337
|
-
* The string literal types of the properties which are generated
|
|
338
|
-
* automatically in `dispatchEvent()` method.
|
|
339
|
-
*/
|
|
340
|
-
export type OmittableEventKeys = Exclude<keyof Event, 'type'>;
|
|
341
|
-
|
|
342
|
-
/**
|
|
343
|
-
* The type of event data.
|
|
344
|
-
*/
|
|
345
|
-
export type NonStandardEvent = {
|
|
346
|
-
[key: string]: any;
|
|
347
|
-
type: string;
|
|
348
|
-
};
|
|
349
|
-
|
|
350
|
-
/**
|
|
351
|
-
* The type of listeners.
|
|
352
|
-
*/
|
|
353
|
-
export type PickEvent<
|
|
354
|
-
TEvents extends EventDefinition,
|
|
355
|
-
TEventType extends keyof TEvents | string,
|
|
356
|
-
> = TEventType extends keyof TEvents ? TEvents[TEventType] : Event;
|
|
357
|
-
|
|
358
|
-
/**
|
|
359
|
-
* Event type candidates.
|
|
360
|
-
*/
|
|
361
|
-
export type EventType<
|
|
362
|
-
TEvents extends EventDefinition,
|
|
363
|
-
TMode extends Mode,
|
|
364
|
-
> = TMode extends 'strict' ? keyof TEvents : keyof TEvents | string;
|
|
365
|
-
|
|
366
|
-
/**
|
|
367
|
-
* - `"strict"` ..... Methods don't accept unknown events.
|
|
368
|
-
* `dispatchEvent()` accepts partial objects.
|
|
369
|
-
* - `"loose"` ...... Methods accept unknown events.
|
|
370
|
-
* `dispatchEvent()` accepts partial objects.
|
|
371
|
-
* - `"standard"` ... Methods accept unknown events.
|
|
372
|
-
* `dispatchEvent()` doesn't accept partial objects.
|
|
373
|
-
*/
|
|
374
|
-
export type Mode = 'strict' | 'standard' | 'loose';
|
|
375
|
-
}
|
|
376
|
-
|
|
377
|
-
/**
|
|
378
|
-
* Specialized `type` property.
|
|
379
|
-
*/
|
|
380
|
-
export type Type<T extends string> = {type: T};
|
|
381
|
-
|
|
382
|
-
/**
|
|
383
|
-
* Define an event attribute (e.g. `eventTarget.onclick`).
|
|
384
|
-
* @param prototype The event target prototype to define an event attribute.
|
|
385
|
-
* @param eventName The event name to define.
|
|
386
|
-
*/
|
|
387
|
-
export function defineEventAttribute(
|
|
388
|
-
prototype: EventTarget,
|
|
389
|
-
eventName: string,
|
|
390
|
-
): void;
|
|
391
|
-
|
|
392
|
-
export default EventTarget;
|
|
File without changes
|
|
File without changes
|