@office-iss/react-native-win32 0.0.0-canary.298 → 0.0.0-canary.299
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 +5 -3
- package/CHANGELOG.json +28 -1
- package/CHANGELOG.md +16 -6
- package/IntegrationTests/IntegrationTestsApp.js +1 -0
- package/IntegrationTests/LoggingTestModule.js +16 -20
- package/IntegrationTests/TimersTest.js +1 -0
- package/IntegrationTests/WebSocketTest.js +1 -0
- package/Libraries/ActionSheetIOS/NativeActionSheetManager.js +1 -0
- package/Libraries/Alert/Alert.js +2 -2
- package/Libraries/Alert/NativeAlertManager.js +1 -0
- package/Libraries/Alert/RCTAlertManager.android.js +19 -13
- package/Libraries/Alert/RCTAlertManager.ios.js +9 -11
- package/Libraries/Alert/RCTAlertManager.js +1 -3
- package/Libraries/Alert/RCTAlertManager.js.flow +4 -6
- package/Libraries/Animated/AnimatedEvent.js +4 -3
- package/Libraries/Animated/AnimatedExports.js.flow +5 -0
- package/Libraries/Animated/AnimatedImplementation.js +44 -44
- package/Libraries/Animated/AnimatedMock.js +2 -2
- package/Libraries/Animated/NativeAnimatedModule.js +1 -0
- package/Libraries/Animated/NativeAnimatedTurboModule.js +1 -0
- package/Libraries/Animated/animations/Animation.js +6 -1
- package/Libraries/Animated/components/AnimatedScrollView.js +6 -5
- package/Libraries/Animated/components/AnimatedText.js +2 -5
- package/Libraries/Animated/components/AnimatedView.js +2 -1
- package/Libraries/Animated/createAnimatedComponent.js +2 -4
- package/Libraries/Animated/nodes/AnimatedProps.js +2 -7
- package/Libraries/AppState/NativeAppState.js +1 -0
- package/Libraries/Blob/NativeBlobModule.js +1 -0
- package/Libraries/Blob/NativeFileReaderModule.js +1 -0
- package/Libraries/Components/AccessibilityInfo/NativeAccessibilityInfo.js +1 -2
- package/Libraries/Components/AccessibilityInfo/NativeAccessibilityInfoWin32.js +1 -2
- package/Libraries/Components/AccessibilityInfo/NativeAccessibilityManager.js +1 -2
- package/Libraries/Components/ActivityIndicator/ActivityIndicatorViewNativeComponent.js +1 -2
- package/Libraries/Components/Button.js +7 -4
- package/Libraries/Components/Button.win32.js +7 -4
- package/Libraries/Components/Clipboard/NativeClipboard.js +1 -2
- package/Libraries/Components/DrawerAndroid/AndroidDrawerLayoutNativeComponent.js +1 -2
- package/Libraries/Components/Keyboard/NativeKeyboardObserver.js +1 -2
- package/Libraries/Components/Pressable/Pressable.js +8 -2
- package/Libraries/Components/Pressable/Pressable.win32.js +8 -8
- package/Libraries/Components/ProgressBarAndroid/ProgressBarAndroidNativeComponent.js +1 -2
- package/Libraries/Components/RefreshControl/AndroidSwipeRefreshLayoutNativeComponent.js +1 -2
- package/Libraries/Components/RefreshControl/PullToRefreshViewNativeComponent.js +1 -0
- package/Libraries/Components/SafeAreaView/RCTSafeAreaViewNativeComponent.js +1 -2
- package/Libraries/Components/SafeAreaView/SafeAreaView.d.ts +9 -0
- package/Libraries/Components/SafeAreaView/SafeAreaView.js +3 -2
- package/Libraries/Components/SafeAreaView/SafeAreaView.win32.js +3 -2
- package/Libraries/Components/ScrollView/AndroidHorizontalScrollContentViewNativeComponent.js +1 -2
- package/Libraries/Components/ScrollView/ScrollView.d.ts +10 -1
- package/Libraries/Components/ScrollView/ScrollView.js +3 -1
- package/Libraries/Components/Sound/NativeSoundManager.js +1 -2
- package/Libraries/Components/StatusBar/NativeStatusBarManagerAndroid.js +1 -2
- package/Libraries/Components/StatusBar/NativeStatusBarManagerIOS.js +1 -2
- package/Libraries/Components/StatusBar/StatusBar.d.ts +4 -0
- package/Libraries/Components/StatusBar/StatusBar.js +5 -0
- package/Libraries/Components/Switch/AndroidSwitchNativeComponent.js +1 -2
- package/Libraries/Components/Switch/Switch.js +2 -1
- package/Libraries/Components/Switch/SwitchNativeComponent.js +1 -2
- package/Libraries/Components/TextInput/AndroidTextInputNativeComponent.js +8 -7
- package/Libraries/Components/TextInput/RCTInputAccessoryViewNativeComponent.js +1 -2
- package/Libraries/Components/TextInput/TextInput.flow.js +1 -1
- package/Libraries/Components/TextInput/TextInput.js +2 -4
- package/Libraries/Components/TextInput/TextInput.win32.js +28 -3
- package/Libraries/Components/ToastAndroid/NativeToastAndroid.js +1 -2
- package/Libraries/Components/Touchable/Touchable.js +7 -3
- package/Libraries/Components/Touchable/Touchable.win32.js +7 -3
- package/Libraries/Components/Touchable/TouchableHighlight.js +5 -1
- package/Libraries/Components/Touchable/TouchableNativeFeedback.js +3 -2
- package/Libraries/Components/Touchable/TouchableNativeFeedback.win32.js +3 -2
- package/Libraries/Components/Touchable/TouchableOpacity.d.ts +1 -0
- package/Libraries/Components/Touchable/TouchableOpacity.js +3 -2
- package/Libraries/Components/UnimplementedViews/UnimplementedNativeViewNativeComponent.js +1 -2
- package/Libraries/Components/View/ReactNativeStyleAttributes.js +6 -15
- package/Libraries/Components/View/View.js +17 -18
- package/Libraries/Components/View/View.win32.js +16 -2
- package/Libraries/Components/View/ViewAccessibility.js +0 -7
- package/Libraries/Components/View/ViewAccessibility.win32.js +0 -7
- package/Libraries/Components/View/ViewPropTypes.d.ts +4 -0
- package/Libraries/Components/View/ViewPropTypes.js +8 -0
- package/Libraries/Components/View/ViewPropTypes.win32.js +8 -0
- package/Libraries/Core/ExceptionsManager.js +28 -15
- package/Libraries/Core/NativeExceptionsManager.js +1 -0
- package/Libraries/Core/ReactNativeVersion.js +1 -1
- package/Libraries/Core/SegmentFetcher/NativeSegmentFetcher.js +1 -0
- package/Libraries/Core/Timers/NativeTiming.js +1 -0
- package/Libraries/Core/checkNativeVersion.js +1 -0
- package/Libraries/Core/setUpReactDevTools.js +21 -4
- package/Libraries/Debugging/DebuggingOverlayNativeComponent.js +1 -0
- package/Libraries/EventEmitter/NativeEventEmitter.js +3 -3
- package/Libraries/Image/Image.android.js +3 -3
- package/Libraries/Image/ImageSource.d.ts +5 -0
- package/Libraries/Image/ImageViewNativeComponent.js +3 -3
- package/Libraries/Image/NativeImageEditor.js +1 -0
- package/Libraries/Image/NativeImageLoaderAndroid.js +1 -0
- package/Libraries/Image/NativeImageLoaderIOS.js +1 -0
- package/Libraries/Image/NativeImageLoaderWin32.js +1 -0
- package/Libraries/Image/NativeImageStoreAndroid.js +1 -0
- package/Libraries/Image/NativeImageStoreIOS.js +1 -0
- package/Libraries/Image/RelativeImageStub.js +1 -1
- package/Libraries/Image/TextInlineImageNativeComponent.js +3 -3
- package/Libraries/Interaction/InteractionManager.js +6 -1
- package/Libraries/Interaction/NativeFrameRateLogger.js +1 -0
- package/Libraries/Interaction/TaskQueue.js +14 -0
- package/Libraries/LayoutAnimation/LayoutAnimation.js +12 -8
- package/Libraries/Linking/NativeIntentAndroid.js +1 -0
- package/Libraries/Linking/NativeLinkingManager.js +1 -0
- package/Libraries/Lists/FlatList.js +5 -6
- package/Libraries/Lists/SectionList.js +4 -4
- package/Libraries/Lists/VirtualizedList.js +3 -2
- package/Libraries/LogBox/Data/LogBoxData.js +7 -4
- package/Libraries/LogBox/LogBox.js +72 -101
- package/Libraries/Modal/Modal.d.ts +8 -2
- package/Libraries/Modal/Modal.js +19 -2
- package/Libraries/Modal/NativeModalManager.js +1 -0
- package/Libraries/Modal/RCTModalHostViewNativeComponent.js +1 -0
- package/Libraries/NativeComponent/BaseViewConfig.android.js +6 -15
- package/Libraries/NativeComponent/BaseViewConfig.ios.js +6 -15
- package/Libraries/NativeComponent/BaseViewConfig.win32.js +6 -15
- package/Libraries/NativeModules/specs/NativeDevMenu.js +1 -0
- package/Libraries/NativeModules/specs/NativeDevSettings.js +1 -0
- package/Libraries/NativeModules/specs/NativeDeviceEventManager.js +1 -0
- package/Libraries/NativeModules/specs/NativeDialogManagerAndroid.js +1 -0
- package/Libraries/NativeModules/specs/NativeLogBox.js +1 -0
- package/Libraries/NativeModules/specs/NativeRedBox.js +1 -0
- package/Libraries/NativeModules/specs/NativeSourceCode.js +1 -0
- package/Libraries/Network/NativeNetworkingAndroid.js +1 -0
- package/Libraries/Network/NativeNetworkingIOS.js +1 -0
- package/Libraries/Network/XMLHttpRequest.js +2 -0
- package/Libraries/PermissionsAndroid/NativePermissionsAndroid.js +1 -0
- package/Libraries/PermissionsAndroid/PermissionsAndroid.js +3 -2
- package/Libraries/PushNotificationIOS/NativePushNotificationManagerIOS.js +1 -0
- package/Libraries/ReactNative/AppRegistry.flow.js +2 -2
- package/Libraries/ReactNative/AppRegistryImpl.js +0 -10
- package/Libraries/ReactNative/BridgelessUIManager.js +1 -1
- package/Libraries/ReactNative/NativeHeadlessJsTaskSupport.js +1 -0
- package/Libraries/ReactNative/NativeI18nManager.js +1 -0
- package/Libraries/ReactNative/NativeUIManager.js +1 -0
- package/Libraries/ReactNative/ReactFabricPublicInstance/ReactNativeAttributePayload.js +80 -61
- package/Libraries/ReactPrivate/ReactNativePrivateInterface.js +1 -1
- package/Libraries/ReactPrivate/ReactNativePrivateInterface.js.flow +2 -2
- package/Libraries/Renderer/implementations/ReactFabric-dev.js +3 -1
- package/Libraries/Renderer/implementations/ReactFabric-prod.js +3 -1
- package/Libraries/Renderer/implementations/ReactFabric-profiling.js +3 -1
- package/Libraries/Renderer/shims/ReactNativeTypes.js +3 -12
- package/Libraries/Renderer/shims/ReactNativeTypes.win32.js +3 -12
- package/Libraries/Settings/NativeSettingsManager.js +1 -0
- package/Libraries/Share/NativeShareModule.js +1 -0
- package/Libraries/StyleSheet/StyleSheet.js +1 -0
- package/Libraries/StyleSheet/processAspectRatio.js +2 -0
- package/Libraries/Text/Text.js +4 -6
- package/Libraries/Text/TextAncestor.js +3 -10
- package/Libraries/Text/TextAncestorContext.js +23 -0
- package/Libraries/Text/TextProps.js +2 -2
- package/Libraries/Text/TextProps.win32.js +2 -2
- package/Libraries/TurboModule/samples/NativeSampleTurboModule.js +1 -0
- package/Libraries/Types/CodegenTypesNamespace.js +1 -0
- package/Libraries/Utilities/HMRClient.js +12 -2
- package/Libraries/Utilities/NativeAppearance.js +1 -0
- package/Libraries/Utilities/NativeDevLoadingView.js +1 -0
- package/Libraries/Utilities/NativeDeviceInfo.js +1 -2
- package/Libraries/Utilities/NativePlatformConstantsAndroid.js +1 -0
- package/Libraries/Utilities/NativePlatformConstantsIOS.js +1 -0
- package/Libraries/Utilities/NativePlatformConstantsWin.js +1 -0
- package/Libraries/Utilities/Platform.android.js +1 -4
- package/Libraries/Utilities/Platform.ios.js +1 -4
- package/Libraries/Utilities/Platform.js.flow +2 -2
- package/Libraries/Utilities/Platform.win32.js +1 -4
- package/Libraries/Utilities/PlatformTypes.js +1 -1
- package/Libraries/Utilities/codegenNativeCommands.js +4 -2
- package/Libraries/Utilities/codegenNativeComponent.js +3 -3
- package/Libraries/Utilities/createPerformanceLogger.js +32 -0
- package/Libraries/Vibration/NativeVibration.js +1 -0
- package/Libraries/WebSocket/NativeWebSocketModule.js +1 -0
- package/Libraries/vendor/emitter/EventEmitter.js +6 -6
- package/index.js +21 -0
- package/index.win32.js +12 -1
- package/jest/setup.js +1 -0
- package/overrides.json +25 -25
- package/package.json +11 -11
- package/src/private/animated/createAnimatedPropsHook.js +4 -1
- package/src/private/animated/createAnimatedPropsMemoHook.js +2 -2
- package/src/private/components/virtualview/VirtualView.js +145 -0
- package/src/private/components/virtualview/VirtualViewNativeComponent.js +90 -0
- package/src/private/featureflags/ReactNativeFeatureFlags.js +43 -23
- package/src/private/featureflags/specs/NativeReactNativeFeatureFlags.js +9 -5
- package/src/private/setup/setUpPerformanceObserver.js +7 -0
- package/src/private/specs_DEPRECATED/components/ActivityIndicatorViewNativeComponent.js +7 -4
- package/src/private/specs_DEPRECATED/components/AndroidDrawerLayoutNativeComponent.js +3 -3
- package/src/private/specs_DEPRECATED/components/AndroidHorizontalScrollContentViewNativeComponent.js +3 -3
- package/src/private/specs_DEPRECATED/components/AndroidSwipeRefreshLayoutNativeComponent.js +3 -3
- package/src/private/specs_DEPRECATED/components/AndroidSwitchNativeComponent.js +10 -7
- package/src/private/specs_DEPRECATED/components/DebuggingOverlayNativeComponent.js +5 -4
- package/src/private/specs_DEPRECATED/components/ProgressBarAndroidNativeComponent.js +7 -4
- package/src/private/specs_DEPRECATED/components/PullToRefreshViewNativeComponent.js +9 -6
- package/src/private/specs_DEPRECATED/components/RCTInputAccessoryViewNativeComponent.js +9 -6
- package/src/private/specs_DEPRECATED/components/RCTModalHostViewNativeComponent.js +14 -5
- package/src/private/specs_DEPRECATED/components/RCTSafeAreaViewNativeComponent.js +8 -5
- package/src/private/specs_DEPRECATED/components/SwitchNativeComponent.js +5 -5
- package/src/private/specs_DEPRECATED/components/UnimplementedNativeViewNativeComponent.js +3 -3
- package/src/private/specs_DEPRECATED/modules/NativeDeviceInfo.js +1 -0
- package/src/private/specs_DEPRECATED/modules/NativeUIManager.js +9 -6
- package/src/private/styles/composeStyles.js +5 -12
- package/src/private/webapis/errors/DOMException.js +1 -1
- package/src/private/webapis/idlecallbacks/specs/NativeIdleCallbacks.js +4 -2
- package/src/private/webapis/intersectionobserver/IntersectionObserver.js +12 -7
- package/src/private/webapis/intersectionobserver/internals/IntersectionObserverManager.js +13 -0
- package/src/private/webapis/intersectionobserver/specs/NativeIntersectionObserver.js +2 -1
- package/src/private/webapis/performance/Performance.js +164 -61
- package/src/private/webapis/performance/PerformanceEntry.js +20 -16
- package/src/private/webapis/performance/PerformanceObserver.js +31 -27
- package/src/private/webapis/performance/ResourceTiming.js +108 -0
- package/src/private/webapis/performance/UserTiming.js +60 -8
- package/src/private/webapis/performance/internals/RawPerformanceEntry.js +47 -32
- package/src/private/webapis/performance/specs/NativePerformance.js +13 -1
- package/src-win/Libraries/Components/View/ViewPropTypes.d.ts +4 -0
- package/Libraries/BugReporting/BugReporting.js +0 -140
- package/Libraries/BugReporting/NativeBugReporting.js +0 -13
- package/Libraries/BugReporting/dumpReactTree.js +0 -151
- package/Libraries/BugReporting/getReactData.js +0 -187
- package/src/private/specs_DEPRECATED/modules/NativeBugReporting.js +0 -20
|
@@ -18,6 +18,7 @@ import type {
|
|
|
18
18
|
import type {DetailType, PerformanceMarkOptions} from './UserTiming';
|
|
19
19
|
|
|
20
20
|
import DOMException from '../errors/DOMException';
|
|
21
|
+
import structuredClone from '../structuredClone/structuredClone';
|
|
21
22
|
import {setPlatformObject} from '../webidl/PlatformObjects';
|
|
22
23
|
import {EventCounts} from './EventTiming';
|
|
23
24
|
import {
|
|
@@ -38,12 +39,17 @@ declare var global: {
|
|
|
38
39
|
const getCurrentTimeStamp: () => DOMHighResTimeStamp =
|
|
39
40
|
NativePerformance?.now ?? global.nativePerformanceNow ?? (() => Date.now());
|
|
40
41
|
|
|
41
|
-
export type PerformanceMeasureOptions =
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
}
|
|
42
|
+
export type PerformanceMeasureOptions =
|
|
43
|
+
| {
|
|
44
|
+
detail?: DetailType,
|
|
45
|
+
start?: DOMHighResTimeStamp | string,
|
|
46
|
+
duration?: DOMHighResTimeStamp,
|
|
47
|
+
}
|
|
48
|
+
| {
|
|
49
|
+
detail?: DetailType,
|
|
50
|
+
start?: DOMHighResTimeStamp | string,
|
|
51
|
+
end?: DOMHighResTimeStamp | string,
|
|
52
|
+
};
|
|
47
53
|
|
|
48
54
|
const ENTRY_TYPES_AVAILABLE_FROM_TIMELINE: $ReadOnlyArray<PerformanceEntryType> =
|
|
49
55
|
['mark', 'measure'];
|
|
@@ -111,11 +117,39 @@ export default class Performance {
|
|
|
111
117
|
markName: string,
|
|
112
118
|
markOptions?: PerformanceMarkOptions,
|
|
113
119
|
): PerformanceMark {
|
|
120
|
+
if (markName == null) {
|
|
121
|
+
throw new TypeError(
|
|
122
|
+
`Failed to execute 'mark' on 'Performance': 1 argument required, but only 0 present.`,
|
|
123
|
+
);
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
let resolvedDetail;
|
|
127
|
+
if (markOptions?.detail != null) {
|
|
128
|
+
resolvedDetail = structuredClone(markOptions.detail);
|
|
129
|
+
}
|
|
130
|
+
|
|
114
131
|
let computedStartTime;
|
|
115
132
|
if (NativePerformance?.markWithResult) {
|
|
133
|
+
let resolvedStartTime;
|
|
134
|
+
|
|
135
|
+
const startTime = markOptions?.startTime;
|
|
136
|
+
if (startTime !== undefined) {
|
|
137
|
+
resolvedStartTime = Number(startTime);
|
|
138
|
+
if (resolvedStartTime < 0) {
|
|
139
|
+
throw new TypeError(
|
|
140
|
+
`Failed to execute 'mark' on 'Performance': '${markName}' cannot have a negative start time.`,
|
|
141
|
+
);
|
|
142
|
+
} else if (!Number.isFinite(resolvedStartTime)) {
|
|
143
|
+
throw new TypeError(
|
|
144
|
+
`Failed to execute 'mark' on 'Performance': Failed to read the 'startTime' property from 'PerformanceMarkOptions': The provided double value is non-finite.`,
|
|
145
|
+
);
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
// $FlowExpectedError[not-a-function]
|
|
116
150
|
computedStartTime = NativePerformance.markWithResult(
|
|
117
151
|
markName,
|
|
118
|
-
|
|
152
|
+
resolvedStartTime,
|
|
119
153
|
);
|
|
120
154
|
} else {
|
|
121
155
|
warnNoNativePerformance();
|
|
@@ -124,7 +158,7 @@ export default class Performance {
|
|
|
124
158
|
|
|
125
159
|
return new PerformanceMark(markName, {
|
|
126
160
|
startTime: computedStartTime,
|
|
127
|
-
detail:
|
|
161
|
+
detail: resolvedDetail,
|
|
128
162
|
});
|
|
129
163
|
}
|
|
130
164
|
|
|
@@ -142,66 +176,135 @@ export default class Performance {
|
|
|
142
176
|
startMarkOrOptions?: string | PerformanceMeasureOptions,
|
|
143
177
|
endMark?: string,
|
|
144
178
|
): PerformanceMeasure {
|
|
145
|
-
let
|
|
146
|
-
let
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
if (
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
179
|
+
let resolvedStartTime: number | void;
|
|
180
|
+
let resolvedStartMark: string | void;
|
|
181
|
+
let resolvedEndTime: number | void;
|
|
182
|
+
let resolvedEndMark: string | void;
|
|
183
|
+
let resolvedDuration: number | void;
|
|
184
|
+
let resolvedDetail: mixed;
|
|
185
|
+
|
|
186
|
+
if (startMarkOrOptions != null) {
|
|
187
|
+
switch (typeof startMarkOrOptions) {
|
|
188
|
+
case 'object': {
|
|
189
|
+
if (endMark != null) {
|
|
190
|
+
throw new TypeError(
|
|
191
|
+
`Failed to execute 'measure' on 'Performance': If a non-empty PerformanceMeasureOptions object was passed, |end_mark| must not be passed.`,
|
|
192
|
+
);
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
const start = startMarkOrOptions.start;
|
|
196
|
+
switch (typeof start) {
|
|
197
|
+
case 'number': {
|
|
198
|
+
resolvedStartTime = start;
|
|
199
|
+
break;
|
|
200
|
+
}
|
|
201
|
+
case 'string': {
|
|
202
|
+
resolvedStartMark = start;
|
|
203
|
+
break;
|
|
204
|
+
}
|
|
205
|
+
case 'undefined': {
|
|
206
|
+
break;
|
|
207
|
+
}
|
|
208
|
+
default: {
|
|
209
|
+
resolvedStartMark = String(start);
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
const end = startMarkOrOptions.end;
|
|
214
|
+
switch (typeof end) {
|
|
215
|
+
case 'number': {
|
|
216
|
+
resolvedEndTime = end;
|
|
217
|
+
break;
|
|
218
|
+
}
|
|
219
|
+
case 'string': {
|
|
220
|
+
resolvedEndMark = end;
|
|
221
|
+
break;
|
|
222
|
+
}
|
|
223
|
+
case 'undefined': {
|
|
224
|
+
break;
|
|
225
|
+
}
|
|
226
|
+
default: {
|
|
227
|
+
resolvedEndMark = String(end);
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
const duration = startMarkOrOptions.duration;
|
|
232
|
+
switch (typeof duration) {
|
|
233
|
+
case 'number': {
|
|
234
|
+
resolvedDuration = duration;
|
|
235
|
+
break;
|
|
236
|
+
}
|
|
237
|
+
case 'undefined':
|
|
238
|
+
break;
|
|
239
|
+
default: {
|
|
240
|
+
resolvedDuration = Number(duration);
|
|
241
|
+
if (!Number.isFinite(resolvedDuration)) {
|
|
242
|
+
throw new TypeError(
|
|
243
|
+
`Failed to execute 'measure' on 'Performance': Failed to read the 'duration' property from 'PerformanceMeasureOptions': The provided double value is non-finite.`,
|
|
244
|
+
);
|
|
245
|
+
}
|
|
246
|
+
}
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
if (
|
|
250
|
+
resolvedDuration != null &&
|
|
251
|
+
(resolvedEndMark != null || resolvedEndTime != null)
|
|
252
|
+
) {
|
|
253
|
+
throw new TypeError(
|
|
254
|
+
`Failed to execute 'measure' on 'Performance': If a non-empty PerformanceMeasureOptions object was passed, it must not have all of its 'start', 'duration', and 'end' properties defined`,
|
|
255
|
+
);
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
const detail = startMarkOrOptions.detail;
|
|
259
|
+
if (detail != null) {
|
|
260
|
+
resolvedDetail = structuredClone(detail);
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
break;
|
|
264
|
+
}
|
|
265
|
+
case 'string': {
|
|
266
|
+
resolvedStartMark = startMarkOrOptions;
|
|
267
|
+
|
|
268
|
+
if (endMark !== undefined) {
|
|
269
|
+
resolvedEndMark = String(endMark);
|
|
270
|
+
}
|
|
271
|
+
break;
|
|
272
|
+
}
|
|
273
|
+
default: {
|
|
274
|
+
resolvedStartMark = String(startMarkOrOptions);
|
|
275
|
+
}
|
|
175
276
|
}
|
|
176
|
-
|
|
177
|
-
if (typeof options.start === 'number') {
|
|
178
|
-
startTime = options.start;
|
|
179
|
-
} else {
|
|
180
|
-
startMarkName = options.start;
|
|
181
|
-
}
|
|
182
|
-
|
|
183
|
-
if (typeof options.end === 'number') {
|
|
184
|
-
endTime = options.end;
|
|
185
|
-
} else {
|
|
186
|
-
endMarkName = options.end;
|
|
187
|
-
}
|
|
188
|
-
|
|
189
|
-
duration = options.duration ?? duration;
|
|
190
277
|
}
|
|
191
278
|
|
|
192
|
-
let computedStartTime =
|
|
193
|
-
let computedDuration =
|
|
279
|
+
let computedStartTime = 0;
|
|
280
|
+
let computedDuration = 0;
|
|
194
281
|
|
|
195
|
-
if (NativePerformance?.
|
|
282
|
+
if (NativePerformance?.measure) {
|
|
283
|
+
try {
|
|
284
|
+
[computedStartTime, computedDuration] = NativePerformance.measure(
|
|
285
|
+
measureName,
|
|
286
|
+
resolvedStartTime,
|
|
287
|
+
resolvedEndTime,
|
|
288
|
+
resolvedDuration,
|
|
289
|
+
resolvedStartMark,
|
|
290
|
+
resolvedEndMark,
|
|
291
|
+
);
|
|
292
|
+
} catch (error) {
|
|
293
|
+
throw new DOMException(
|
|
294
|
+
"Failed to execute 'measure' on 'Performance': " + error.message,
|
|
295
|
+
'SyntaxError',
|
|
296
|
+
);
|
|
297
|
+
}
|
|
298
|
+
} else if (NativePerformance?.measureWithResult) {
|
|
196
299
|
try {
|
|
197
300
|
[computedStartTime, computedDuration] =
|
|
198
301
|
NativePerformance.measureWithResult(
|
|
199
302
|
measureName,
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
303
|
+
resolvedStartTime ?? 0,
|
|
304
|
+
resolvedEndTime ?? 0,
|
|
305
|
+
resolvedDuration,
|
|
306
|
+
resolvedStartMark,
|
|
307
|
+
resolvedEndMark,
|
|
205
308
|
);
|
|
206
309
|
} catch (error) {
|
|
207
310
|
throw new DOMException(
|
|
@@ -216,7 +319,7 @@ export default class Performance {
|
|
|
216
319
|
const measure = new PerformanceMeasure(measureName, {
|
|
217
320
|
startTime: computedStartTime,
|
|
218
321
|
duration: computedDuration ?? 0,
|
|
219
|
-
detail:
|
|
322
|
+
detail: resolvedDetail,
|
|
220
323
|
});
|
|
221
324
|
|
|
222
325
|
return measure;
|
|
@@ -29,10 +29,14 @@ export type PerformanceEntryJSON = {
|
|
|
29
29
|
};
|
|
30
30
|
|
|
31
31
|
export class PerformanceEntry {
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
32
|
+
// We don't use private fields because they're significantly slower to
|
|
33
|
+
// initialize on construction and to access.
|
|
34
|
+
// We also need these to be protected so they can be initialized in subclasses
|
|
35
|
+
// where we avoid calling `super()` for performance reasons.
|
|
36
|
+
__name: string;
|
|
37
|
+
__entryType: PerformanceEntryType;
|
|
38
|
+
__startTime: DOMHighResTimeStamp;
|
|
39
|
+
__duration: DOMHighResTimeStamp;
|
|
36
40
|
|
|
37
41
|
constructor(init: {
|
|
38
42
|
name: string,
|
|
@@ -40,34 +44,34 @@ export class PerformanceEntry {
|
|
|
40
44
|
startTime: DOMHighResTimeStamp,
|
|
41
45
|
duration: DOMHighResTimeStamp,
|
|
42
46
|
}) {
|
|
43
|
-
this
|
|
44
|
-
this
|
|
45
|
-
this
|
|
46
|
-
this
|
|
47
|
+
this.__name = init.name;
|
|
48
|
+
this.__entryType = init.entryType;
|
|
49
|
+
this.__startTime = init.startTime;
|
|
50
|
+
this.__duration = init.duration;
|
|
47
51
|
}
|
|
48
52
|
|
|
49
53
|
get name(): string {
|
|
50
|
-
return this
|
|
54
|
+
return this.__name;
|
|
51
55
|
}
|
|
52
56
|
|
|
53
57
|
get entryType(): PerformanceEntryType {
|
|
54
|
-
return this
|
|
58
|
+
return this.__entryType;
|
|
55
59
|
}
|
|
56
60
|
|
|
57
61
|
get startTime(): DOMHighResTimeStamp {
|
|
58
|
-
return this
|
|
62
|
+
return this.__startTime;
|
|
59
63
|
}
|
|
60
64
|
|
|
61
65
|
get duration(): DOMHighResTimeStamp {
|
|
62
|
-
return this
|
|
66
|
+
return this.__duration;
|
|
63
67
|
}
|
|
64
68
|
|
|
65
69
|
toJSON(): PerformanceEntryJSON {
|
|
66
70
|
return {
|
|
67
|
-
name: this
|
|
68
|
-
entryType: this
|
|
69
|
-
startTime: this
|
|
70
|
-
duration: this
|
|
71
|
+
name: this.__name,
|
|
72
|
+
entryType: this.__entryType,
|
|
73
|
+
startTime: this.__startTime,
|
|
74
|
+
duration: this.__duration,
|
|
71
75
|
};
|
|
72
76
|
}
|
|
73
77
|
}
|
|
@@ -23,6 +23,7 @@ import {
|
|
|
23
23
|
} from './internals/RawPerformanceEntry';
|
|
24
24
|
import {warnNoNativePerformance} from './internals/Utilities';
|
|
25
25
|
import NativePerformance from './specs/NativePerformance';
|
|
26
|
+
import nullthrows from 'nullthrows';
|
|
26
27
|
|
|
27
28
|
export {PerformanceEntry} from './PerformanceEntry';
|
|
28
29
|
|
|
@@ -130,14 +131,16 @@ export class PerformanceObserver {
|
|
|
130
131
|
this.#nativeObserverHandle = this.#createNativeObserver();
|
|
131
132
|
}
|
|
132
133
|
|
|
134
|
+
const observerHandle = nullthrows(this.#nativeObserverHandle);
|
|
135
|
+
|
|
133
136
|
if (options.entryTypes) {
|
|
134
137
|
this.#type = 'multiple';
|
|
135
|
-
NativePerformance.observe?.(
|
|
138
|
+
NativePerformance.observe?.(observerHandle, {
|
|
136
139
|
entryTypes: options.entryTypes.map(performanceEntryTypeToRaw),
|
|
137
140
|
});
|
|
138
141
|
} else if (options.type) {
|
|
139
142
|
this.#type = 'single';
|
|
140
|
-
NativePerformance.observe?.(
|
|
143
|
+
NativePerformance.observe?.(observerHandle, {
|
|
141
144
|
type: performanceEntryTypeToRaw(options.type),
|
|
142
145
|
buffered: options.buffered,
|
|
143
146
|
durationThreshold: options.durationThreshold,
|
|
@@ -158,37 +161,38 @@ export class PerformanceObserver {
|
|
|
158
161
|
NativePerformance.disconnect(this.#nativeObserverHandle);
|
|
159
162
|
}
|
|
160
163
|
|
|
161
|
-
#createNativeObserver(): OpaqueNativeObserverHandle {
|
|
164
|
+
#createNativeObserver(): OpaqueNativeObserverHandle | null {
|
|
162
165
|
if (!NativePerformance || !NativePerformance.createObserver) {
|
|
163
166
|
warnNoNativePerformance();
|
|
164
|
-
return;
|
|
167
|
+
return null;
|
|
165
168
|
}
|
|
166
169
|
|
|
167
170
|
this.#calledAtLeastOnce = false;
|
|
168
171
|
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
172
|
+
const observerHandle: OpaqueNativeObserverHandle =
|
|
173
|
+
NativePerformance.createObserver(() => {
|
|
174
|
+
const rawEntries = NativePerformance.takeRecords?.(
|
|
175
|
+
observerHandle,
|
|
176
|
+
true, // sort records
|
|
177
|
+
);
|
|
178
|
+
if (!rawEntries) {
|
|
179
|
+
return;
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
const entries = rawEntries.map(rawToPerformanceEntry);
|
|
183
|
+
const entryList = new PerformanceObserverEntryList(entries);
|
|
184
|
+
|
|
185
|
+
let droppedEntriesCount = 0;
|
|
186
|
+
if (!this.#calledAtLeastOnce) {
|
|
187
|
+
droppedEntriesCount =
|
|
188
|
+
NativePerformance.getDroppedEntriesCount?.(observerHandle) ?? 0;
|
|
189
|
+
this.#calledAtLeastOnce = true;
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
this.#callback(entryList, this, {droppedEntriesCount});
|
|
193
|
+
});
|
|
194
|
+
|
|
195
|
+
return observerHandle;
|
|
192
196
|
}
|
|
193
197
|
|
|
194
198
|
#validateObserveOptions(options: PerformanceObserverInit): void {
|
|
@@ -0,0 +1,108 @@
|
|
|
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 {
|
|
14
|
+
DOMHighResTimeStamp,
|
|
15
|
+
PerformanceEntryJSON,
|
|
16
|
+
} from './PerformanceEntry';
|
|
17
|
+
|
|
18
|
+
import {PerformanceEntry} from './PerformanceEntry';
|
|
19
|
+
|
|
20
|
+
export type PerformanceResourceTimingJSON = {
|
|
21
|
+
...PerformanceEntryJSON,
|
|
22
|
+
fetchStart: DOMHighResTimeStamp,
|
|
23
|
+
requestStart: DOMHighResTimeStamp,
|
|
24
|
+
connectStart: DOMHighResTimeStamp,
|
|
25
|
+
connectEnd: DOMHighResTimeStamp,
|
|
26
|
+
responseStart: DOMHighResTimeStamp,
|
|
27
|
+
responseEnd: DOMHighResTimeStamp,
|
|
28
|
+
responseStatus: ?number,
|
|
29
|
+
...
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
export class PerformanceResourceTiming extends PerformanceEntry {
|
|
33
|
+
#fetchStart: DOMHighResTimeStamp;
|
|
34
|
+
#requestStart: DOMHighResTimeStamp;
|
|
35
|
+
#connectStart: DOMHighResTimeStamp;
|
|
36
|
+
#connectEnd: DOMHighResTimeStamp;
|
|
37
|
+
#responseStart: DOMHighResTimeStamp;
|
|
38
|
+
#responseEnd: DOMHighResTimeStamp;
|
|
39
|
+
#responseStatus: ?number;
|
|
40
|
+
|
|
41
|
+
constructor(init: {
|
|
42
|
+
name: string,
|
|
43
|
+
startTime: DOMHighResTimeStamp,
|
|
44
|
+
duration: DOMHighResTimeStamp,
|
|
45
|
+
fetchStart: DOMHighResTimeStamp,
|
|
46
|
+
requestStart: DOMHighResTimeStamp,
|
|
47
|
+
connectStart: DOMHighResTimeStamp,
|
|
48
|
+
connectEnd: DOMHighResTimeStamp,
|
|
49
|
+
responseStart: DOMHighResTimeStamp,
|
|
50
|
+
responseEnd: DOMHighResTimeStamp,
|
|
51
|
+
responseStatus?: number,
|
|
52
|
+
}) {
|
|
53
|
+
super({
|
|
54
|
+
name: init.name,
|
|
55
|
+
entryType: 'resource',
|
|
56
|
+
startTime: init.startTime,
|
|
57
|
+
duration: init.duration,
|
|
58
|
+
});
|
|
59
|
+
this.#fetchStart = init.fetchStart;
|
|
60
|
+
this.#requestStart = init.requestStart;
|
|
61
|
+
this.#connectStart = init.connectStart;
|
|
62
|
+
this.#connectEnd = init.connectEnd;
|
|
63
|
+
this.#responseStart = init.responseStart;
|
|
64
|
+
this.#responseEnd = init.responseEnd;
|
|
65
|
+
this.#responseStatus = init.responseStatus;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
get fetchStart(): DOMHighResTimeStamp {
|
|
69
|
+
return this.#fetchStart;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
get requestStart(): DOMHighResTimeStamp {
|
|
73
|
+
return this.#requestStart;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
get connectStart(): DOMHighResTimeStamp {
|
|
77
|
+
return this.#connectStart;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
get connectEnd(): DOMHighResTimeStamp {
|
|
81
|
+
return this.#connectEnd;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
get responseStart(): DOMHighResTimeStamp {
|
|
85
|
+
return this.#responseStart;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
get responseEnd(): DOMHighResTimeStamp {
|
|
89
|
+
return this.#responseEnd;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
get responseStatus(): ?number {
|
|
93
|
+
return this.#responseStatus;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
toJSON(): PerformanceResourceTimingJSON {
|
|
97
|
+
return {
|
|
98
|
+
...super.toJSON(),
|
|
99
|
+
fetchStart: this.#fetchStart,
|
|
100
|
+
requestStart: this.#requestStart,
|
|
101
|
+
connectStart: this.#connectStart,
|
|
102
|
+
connectEnd: this.#connectEnd,
|
|
103
|
+
responseStart: this.#responseStart,
|
|
104
|
+
responseEnd: this.#responseEnd,
|
|
105
|
+
responseStatus: this.#responseStatus,
|
|
106
|
+
};
|
|
107
|
+
}
|
|
108
|
+
}
|
|
@@ -29,9 +29,12 @@ export type PerformanceMeasureInit = {
|
|
|
29
29
|
duration: DOMHighResTimeStamp,
|
|
30
30
|
};
|
|
31
31
|
|
|
32
|
-
|
|
33
|
-
|
|
32
|
+
class PerformanceMarkTemplate extends PerformanceEntry {
|
|
33
|
+
// We don't use private fields because they're significantly slower to
|
|
34
|
+
// initialize on construction and to access.
|
|
35
|
+
_detail: DetailType;
|
|
34
36
|
|
|
37
|
+
// This constructor isn't really used. See `PerformanceMark` below.
|
|
35
38
|
constructor(markName: string, markOptions?: PerformanceMarkOptions) {
|
|
36
39
|
super({
|
|
37
40
|
name: markName,
|
|
@@ -41,18 +44,46 @@ export class PerformanceMark extends PerformanceEntry {
|
|
|
41
44
|
});
|
|
42
45
|
|
|
43
46
|
if (markOptions) {
|
|
44
|
-
this
|
|
47
|
+
this._detail = markOptions.detail;
|
|
45
48
|
}
|
|
46
49
|
}
|
|
47
50
|
|
|
48
51
|
get detail(): DetailType {
|
|
49
|
-
return this
|
|
52
|
+
return this._detail;
|
|
50
53
|
}
|
|
51
54
|
}
|
|
52
55
|
|
|
53
|
-
|
|
54
|
-
|
|
56
|
+
// This is the real value we're exporting where we define the class a function
|
|
57
|
+
// so we don't need to call `super()` and we can avoid the performance penalty
|
|
58
|
+
// of the current code transpiled with Babel.
|
|
59
|
+
// We should remove this when we have built-in support for classes in the
|
|
60
|
+
// runtime.
|
|
61
|
+
export const PerformanceMark: typeof PerformanceMarkTemplate =
|
|
62
|
+
// $FlowExpectedError[incompatible-type]
|
|
63
|
+
function PerformanceMark(
|
|
64
|
+
this: PerformanceMarkTemplate,
|
|
65
|
+
markName: string,
|
|
66
|
+
markOptions?: PerformanceMarkOptions,
|
|
67
|
+
) {
|
|
68
|
+
this.__name = markName;
|
|
69
|
+
this.__entryType = 'mark';
|
|
70
|
+
this.__startTime = markOptions?.startTime ?? performance.now();
|
|
71
|
+
this.__duration = 0;
|
|
55
72
|
|
|
73
|
+
if (markOptions) {
|
|
74
|
+
this._detail = markOptions.detail;
|
|
75
|
+
}
|
|
76
|
+
};
|
|
77
|
+
|
|
78
|
+
// $FlowExpectedError[prop-missing]
|
|
79
|
+
PerformanceMark.prototype = PerformanceMarkTemplate.prototype;
|
|
80
|
+
|
|
81
|
+
class PerformanceMeasureTemplate extends PerformanceEntry {
|
|
82
|
+
// We don't use private fields because they're significantly slower to
|
|
83
|
+
// initialize on construction and to access.
|
|
84
|
+
_detail: DetailType;
|
|
85
|
+
|
|
86
|
+
// This constructor isn't really used. See `PerformanceMeasure` below.
|
|
56
87
|
constructor(measureName: string, measureOptions: PerformanceMeasureInit) {
|
|
57
88
|
super({
|
|
58
89
|
name: measureName,
|
|
@@ -62,11 +93,32 @@ export class PerformanceMeasure extends PerformanceEntry {
|
|
|
62
93
|
});
|
|
63
94
|
|
|
64
95
|
if (measureOptions) {
|
|
65
|
-
this
|
|
96
|
+
this._detail = measureOptions.detail;
|
|
66
97
|
}
|
|
67
98
|
}
|
|
68
99
|
|
|
69
100
|
get detail(): DetailType {
|
|
70
|
-
return this
|
|
101
|
+
return this._detail;
|
|
71
102
|
}
|
|
72
103
|
}
|
|
104
|
+
|
|
105
|
+
// We do the same here as we do for `PerformanceMark` for performance reasons.
|
|
106
|
+
export const PerformanceMeasure: typeof PerformanceMeasureTemplate =
|
|
107
|
+
// $FlowExpectedError[incompatible-type]
|
|
108
|
+
function PerformanceMeasure(
|
|
109
|
+
this: PerformanceMeasureTemplate,
|
|
110
|
+
measureName: string,
|
|
111
|
+
measureOptions: PerformanceMeasureInit,
|
|
112
|
+
) {
|
|
113
|
+
this.__name = measureName;
|
|
114
|
+
this.__entryType = 'measure';
|
|
115
|
+
this.__startTime = measureOptions.startTime;
|
|
116
|
+
this.__duration = measureOptions.duration;
|
|
117
|
+
|
|
118
|
+
if (measureOptions) {
|
|
119
|
+
this._detail = measureOptions.detail;
|
|
120
|
+
}
|
|
121
|
+
};
|
|
122
|
+
|
|
123
|
+
// $FlowExpectedError[prop-missing]
|
|
124
|
+
PerformanceMeasure.prototype = PerformanceMeasureTemplate.prototype;
|