@office-iss/react-native-win32 0.72.8 → 0.73.0-preview.2
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 +15 -5
- package/CHANGELOG.json +530 -101
- package/CHANGELOG.md +213 -56
- package/IntegrationTests/PromiseTest.js +1 -0
- package/IntegrationTests/websocket_integration_test_server.js +1 -1
- package/Libraries/Animated/Animated.js +1 -1
- package/Libraries/Animated/AnimatedImplementation.js +1 -1
- package/Libraries/Animated/NativeAnimatedHelper.js +14 -10
- package/Libraries/Animated/NativeAnimatedHelper.win32.js +16 -12
- package/Libraries/Animated/NativeAnimatedModule.js +6 -2
- package/Libraries/Animated/NativeAnimatedTurboModule.js +7 -4
- package/Libraries/Animated/animations/Animation.js +57 -3
- package/Libraries/Animated/animations/DecayAnimation.js +9 -0
- package/Libraries/Animated/animations/SpringAnimation.js +8 -0
- package/Libraries/Animated/animations/TimingAnimation.js +8 -0
- package/Libraries/Animated/components/AnimatedFlatList.js +2 -1
- package/Libraries/Animated/components/AnimatedScrollView.js +2 -0
- package/Libraries/Animated/components/AnimatedSectionList.js +2 -1
- package/Libraries/Animated/createAnimatedComponent.js +1 -0
- package/Libraries/Animated/nodes/AnimatedColor.js +1 -1
- package/Libraries/Animated/nodes/AnimatedObject.js +146 -0
- package/Libraries/Animated/nodes/AnimatedProps.js +19 -7
- package/Libraries/Animated/nodes/AnimatedStyle.js +29 -55
- package/Libraries/Animated/nodes/AnimatedValueXY.js +3 -17
- package/Libraries/Animated/shouldUseTurboAnimatedModule.js +17 -0
- package/Libraries/Animated/useAnimatedProps.js +9 -10
- package/Libraries/AppState/AppState.d.ts +1 -1
- package/Libraries/AppState/NativeAppState.js +8 -4
- package/Libraries/BatchedBridge/MessageQueue.js +45 -36
- package/Libraries/Blob/Blob.js +6 -2
- package/Libraries/Blob/BlobManager.js +9 -10
- package/Libraries/Blob/BlobRegistry.js +14 -9
- package/Libraries/Blob/File.js +1 -1
- package/Libraries/Blob/FileReader.js +1 -2
- package/Libraries/Components/AccessibilityInfo/AccessibilityInfo.d.ts +1 -5
- package/Libraries/Components/AccessibilityInfo/AccessibilityInfo.win32.js +7 -48
- package/Libraries/Components/Button/ButtonWin32.Props.d.ts +1 -1
- package/Libraries/Components/Button/ButtonWin32.Props.js.map +1 -1
- package/Libraries/Components/Button/ButtonWin32.d.ts +1 -1
- package/Libraries/Components/Button/ButtonWin32.js +1 -4
- package/Libraries/Components/Button/ButtonWin32.js.map +1 -1
- package/Libraries/Components/Clipboard/Clipboard.d.ts +4 -4
- package/Libraries/Components/DrawerAndroid/DrawerLayoutAndroid.android.js +3 -1
- package/Libraries/Components/EnterString.win32.d.ts +1 -1
- package/Libraries/Components/Keyboard/KeyboardAvoidingView.js +26 -6
- package/Libraries/Components/Pressable/Pressable.js +3 -2
- package/Libraries/Components/Pressable/Pressable.win32.js +4 -3
- package/Libraries/Components/Pressable/useAndroidRippleForView.js +1 -1
- package/Libraries/Components/SafeAreaView/SafeAreaView.js +7 -7
- package/Libraries/Components/SafeAreaView/SafeAreaView.win32.js +7 -8
- package/Libraries/Components/ScrollView/ScrollView.js +3 -1
- package/Libraries/Components/ScrollView/ScrollView.win32.js +3 -1
- package/Libraries/Components/ScrollView/ScrollViewStickyHeader.js +39 -46
- package/Libraries/Components/Switch/Switch.js +1 -0
- package/Libraries/Components/Text/TextWin32.d.ts +1 -1
- package/Libraries/Components/TextInput/RCTTextInputViewConfig.js +1 -0
- package/Libraries/Components/TextInput/TextInput.d.ts +49 -7
- package/Libraries/Components/TextInput/TextInput.flow.js +43 -10
- package/Libraries/Components/TextInput/TextInput.js +62 -10
- package/Libraries/Components/TextInput/TextInput.win32.js +953 -206
- package/Libraries/Components/TextInput/Win32TextInputNativeComponent.js +23 -0
- package/Libraries/Components/ToastAndroid/{ToastAndroid.ios.js → ToastAndroid.js} +9 -1
- package/Libraries/Components/ToastAndroid/ToastAndroid.win32.js +9 -1
- package/Libraries/Components/Touchable/Tests/TouchableWin32Test.js +2 -2
- package/Libraries/Components/Touchable/Tests/TouchableWin32Test.js.map +1 -1
- package/Libraries/Components/Touchable/TouchableBounce.js +1 -1
- package/Libraries/Components/Touchable/TouchableHighlight.js +1 -1
- package/Libraries/Components/Touchable/TouchableNativeFeedback.js +1 -1
- package/Libraries/Components/Touchable/TouchableOpacity.js +4 -1
- package/Libraries/Components/Touchable/TouchableWin32.d.ts +1 -1
- package/Libraries/Components/Touchable/TouchableWin32.js.map +1 -1
- package/Libraries/Components/Touchable/TouchableWithoutFeedback.js +1 -0
- package/Libraries/Components/TraceUpdateOverlay/TraceUpdateOverlay.js +16 -6
- package/Libraries/Components/View/ReactNativeStyleAttributes.js +9 -0
- package/Libraries/Components/View/ReactNativeViewAttributes.js +1 -0
- package/Libraries/Components/View/ReactNativeViewAttributes.win32.js +1 -0
- package/Libraries/Components/View/View.js +46 -32
- package/Libraries/Components/View/View.win32.js +37 -6
- package/Libraries/Components/View/ViewAccessibility.d.ts +8 -2
- package/Libraries/Components/View/ViewNativeComponent.js +1 -0
- package/Libraries/Components/View/ViewPropTypes.js +18 -3
- package/Libraries/Components/View/ViewPropTypes.win32.js +30 -4
- package/Libraries/Components/View/ViewWin32.js +3 -2
- package/Libraries/Core/Devtools/loadBundleFromServer.js +152 -0
- package/Libraries/Core/Devtools/symbolicateStackTrace.js +2 -1
- package/Libraries/Core/ExceptionsManager.js +16 -7
- package/Libraries/Core/ExtendedError.js +12 -0
- package/Libraries/Core/ReactNativeVersion.js +3 -3
- package/Libraries/Core/ReactNativeVersionCheck.js +0 -2
- package/Libraries/Core/ReactNativeVersionCheck.win32.js +0 -2
- package/Libraries/Core/__mocks__/NativeExceptionsManager.js +20 -0
- package/Libraries/Core/setUpDeveloperTools.js +5 -1
- package/Libraries/Core/setUpIntersectionObserver.js +16 -0
- package/Libraries/{Components/ProgressBarAndroid/ProgressBarAndroid.ios.js → Core/setUpMutationObserver.js} +6 -2
- package/Libraries/Core/setUpPerformance.js +6 -13
- package/Libraries/Core/setUpPerformanceObserver.js +16 -0
- package/Libraries/Core/setUpRegeneratorRuntime.js +4 -2
- package/Libraries/DOM/Nodes/ReactNativeElement.js +135 -18
- package/Libraries/DOM/Nodes/ReadOnlyCharacterData.js +72 -0
- package/Libraries/DOM/Nodes/ReadOnlyElement.js +209 -21
- package/Libraries/DOM/Nodes/ReadOnlyNode.js +206 -17
- package/Libraries/DOM/Nodes/ReadOnlyText.js +30 -0
- package/Libraries/DOM/Nodes/Utilities/Traversal.js +54 -0
- package/Libraries/EventEmitter/NativeEventEmitter.d.ts +0 -6
- package/Libraries/EventEmitter/RCTDeviceEventEmitter.js +15 -4
- package/Libraries/Image/Image.android.js +8 -2
- package/Libraries/Image/Image.d.ts +1 -1
- package/Libraries/Image/Image.ios.js +4 -1
- package/Libraries/Image/Image.win32.js +6 -3
- package/Libraries/Image/ImageBackground.js +3 -0
- package/Libraries/Image/resolveAssetSource.win32.js +1 -1
- package/Libraries/Inspector/DevtoolsOverlay.js +6 -3
- package/Libraries/Inspector/NetworkOverlay.js +2 -2
- package/Libraries/Interaction/JSEventLoopWatchdog.js +1 -5
- package/Libraries/Interaction/PanResponder.js +1 -4
- package/Libraries/IntersectionObserver/IntersectionObserver.js +252 -0
- package/Libraries/IntersectionObserver/IntersectionObserverEntry.js +140 -0
- package/Libraries/IntersectionObserver/IntersectionObserverManager.js +221 -0
- package/Libraries/IntersectionObserver/NativeIntersectionObserver.js +41 -0
- package/Libraries/IntersectionObserver/__mocks__/NativeIntersectionObserver.js +162 -0
- package/Libraries/LayoutAnimation/LayoutAnimation.js +1 -1
- package/Libraries/Lists/FlatList.d.ts +2 -1
- package/Libraries/Lists/FlatList.js +15 -5
- package/Libraries/Lists/SectionList.js +4 -0
- package/Libraries/LogBox/Data/LogBoxData.js +2 -1
- package/Libraries/LogBox/Data/LogBoxLog.js +4 -1
- package/Libraries/LogBox/Data/LogBoxSymbolication.js +5 -2
- package/Libraries/LogBox/Data/parseLogBoxLog.js +57 -20
- package/Libraries/LogBox/UI/AnsiHighlight.js +1 -1
- package/Libraries/LogBox/UI/LogBoxInspectorFooter.js +24 -31
- package/Libraries/LogBox/UI/LogBoxInspectorHeader.js +1 -1
- package/Libraries/LogBox/UI/LogBoxMessage.js +4 -7
- package/Libraries/MutationObserver/MutationObserver.js +184 -0
- package/Libraries/MutationObserver/MutationObserverManager.js +218 -0
- package/Libraries/MutationObserver/MutationRecord.js +82 -0
- package/Libraries/MutationObserver/NativeMutationObserver.js +58 -0
- package/Libraries/MutationObserver/__mocks__/NativeMutationObserver.js +327 -0
- package/Libraries/NativeComponent/BaseViewConfig.android.js +18 -3
- package/Libraries/NativeComponent/BaseViewConfig.ios.js +33 -0
- package/Libraries/NativeComponent/BaseViewConfig.win32.js +33 -0
- package/Libraries/NativeComponent/NativeComponentRegistry.js +13 -9
- package/Libraries/NativeModules/specs/NativeSourceCode.js +6 -6
- package/Libraries/Network/RCTNetworking.android.js +2 -1
- package/Libraries/Network/XMLHttpRequest.js +1 -1
- package/Libraries/NewAppScreen/components/DebugInstructions.js +4 -4
- package/Libraries/NewAppScreen/components/LearnMoreLinks.js +9 -2
- package/Libraries/Performance/QuickPerformanceLogger.js +1 -1
- package/Libraries/PermissionsAndroid/NativePermissionsAndroid.js +1 -0
- package/Libraries/PermissionsAndroid/PermissionsAndroid.d.ts +1 -0
- package/Libraries/PermissionsAndroid/PermissionsAndroid.js +3 -1
- package/Libraries/Pressability/Pressability.js +28 -3
- package/Libraries/Pressability/Pressability.win32.js +30 -5
- package/Libraries/ReactNative/AppContainer.js +2 -3
- package/Libraries/ReactNative/AppRegistry.d.ts +0 -5
- package/Libraries/ReactNative/AppRegistry.js +66 -53
- package/Libraries/ReactNative/BridgelessUIManager.js +38 -9
- package/Libraries/ReactNative/FabricUIManager.js +143 -34
- package/Libraries/ReactNative/I18nManager.js +5 -11
- package/Libraries/ReactNative/NativeI18nManager.js +7 -5
- package/Libraries/ReactNative/PaperUIManager.win32.js +2 -2
- package/Libraries/ReactNative/ReactFabricPublicInstance/ReactFabricHostComponent.js +151 -0
- package/Libraries/ReactNative/ReactFabricPublicInstance/ReactFabricPublicInstance.js +81 -0
- package/Libraries/ReactNative/ReactFabricPublicInstance/ReactNativeAttributePayload.js +492 -0
- package/Libraries/ReactNative/ReactFabricPublicInstance/warnForStyleProps.js +32 -0
- package/Libraries/ReactNative/ReactNativeFeatureFlags.js +19 -3
- package/Libraries/ReactNative/UIManager.js +8 -0
- package/Libraries/ReactNative/__mocks__/FabricUIManager.js +648 -0
- package/Libraries/ReactPrivate/ReactNativePrivateInterface.js +38 -2
- package/Libraries/Renderer/implementations/ReactFabric-dev.js +27 -27
- package/Libraries/Renderer/implementations/ReactFabric-prod.js +3 -3
- package/Libraries/Renderer/implementations/ReactFabric-profiling.js +3 -3
- package/Libraries/Renderer/implementations/ReactNativeRenderer-dev.js +27 -27
- package/Libraries/Renderer/implementations/ReactNativeRenderer-prod.js +3 -3
- package/Libraries/Renderer/implementations/ReactNativeRenderer-profiling.js +3 -3
- package/Libraries/Renderer/shims/ReactFabric.js +5 -6
- package/Libraries/Renderer/shims/ReactFeatureFlags.js +2 -3
- package/Libraries/Renderer/shims/ReactNative.js +2 -3
- package/Libraries/Renderer/shims/ReactNativeTypes.js +35 -17
- package/Libraries/Renderer/shims/ReactNativeViewConfigRegistry.js +3 -3
- package/Libraries/Renderer/shims/createReactNativeComponentClass.js +2 -3
- package/Libraries/Settings/{Settings.android.js → Settings.js} +4 -4
- package/Libraries/Share/Share.d.ts +3 -9
- package/Libraries/StyleSheet/PlatformColorValueTypes.android.js +9 -4
- package/Libraries/StyleSheet/PlatformColorValueTypes.ios.js +28 -13
- package/Libraries/StyleSheet/PlatformColorValueTypes.win32.js +14 -4
- package/Libraries/StyleSheet/PlatformColorValueTypesIOS.ios.js +1 -1
- package/Libraries/StyleSheet/PlatformColorValueTypesWin32.d.ts +1 -1
- package/Libraries/StyleSheet/StyleSheet.d.ts +10 -1
- package/Libraries/StyleSheet/StyleSheet.js +3 -0
- package/Libraries/StyleSheet/StyleSheet.win32.js +3 -0
- package/Libraries/StyleSheet/StyleSheetTypes.d.ts +31 -17
- package/Libraries/StyleSheet/StyleSheetTypes.js +90 -6
- package/Libraries/StyleSheet/flattenStyle.js +4 -0
- package/Libraries/StyleSheet/private/_TransformStyle.js +16 -2
- package/Libraries/StyleSheet/processColor.js +1 -2
- package/Libraries/StyleSheet/processTransformOrigin.js +136 -0
- package/Libraries/StyleSheet/splitLayoutProps.js +1 -0
- package/Libraries/Text/Text.d.ts +5 -5
- package/Libraries/Text/Text.js +17 -10
- package/Libraries/Text/Text.win32.js +354 -0
- package/Libraries/Text/TextProps.win32.js +281 -0
- package/Libraries/TurboModule/TurboModuleRegistry.js +47 -7
- package/Libraries/TurboModule/samples/NativeSampleTurboModule.js +6 -0
- package/Libraries/Types/CoreEventTypes.d.ts +5 -2
- package/Libraries/Utilities/GlobalPerformanceLogger.js +2 -12
- package/Libraries/Utilities/NativeDeviceInfo.js +8 -9
- package/Libraries/Utilities/NativePlatformConstantsAndroid.js +23 -18
- package/Libraries/Utilities/NativePlatformConstantsIOS.js +16 -13
- package/Libraries/Utilities/NativePlatformConstantsWin.js +13 -10
- package/Libraries/Utilities/PerformanceLoggerContext.js +1 -1
- package/Libraries/Utilities/Platform.android.js +12 -8
- package/Libraries/Utilities/Platform.d.ts +1 -0
- package/Libraries/Utilities/Platform.flow.js +84 -0
- package/Libraries/Utilities/Platform.flow.win32.js +111 -0
- package/Libraries/Utilities/Platform.ios.js +12 -8
- package/Libraries/Utilities/Platform.win32.js +12 -8
- package/Libraries/Utilities/PolyfillFunctions.js +1 -1
- package/Libraries/Utilities/ReactNativeTestTools.js +1 -2
- package/Libraries/Utilities/SceneTracker.js +1 -1
- package/Libraries/Utilities/createPerformanceLogger.js +63 -32
- package/Libraries/Utilities/useColorScheme.js +7 -8
- package/Libraries/WebPerformance/MemoryInfo.js +1 -1
- package/Libraries/WebPerformance/NativePerformance.js +3 -8
- package/Libraries/WebPerformance/NativePerformanceObserver.js +4 -0
- package/Libraries/WebPerformance/Performance.js +42 -15
- package/Libraries/WebPerformance/PerformanceEntry.js +14 -6
- package/Libraries/WebPerformance/PerformanceEventTiming.js +18 -1
- package/Libraries/WebPerformance/ReactNativeStartupTiming.js +40 -14
- package/Libraries/WebPerformance/__mocks__/NativePerformance.js +4 -2
- package/Libraries/WebPerformance/__mocks__/NativePerformanceObserver.js +21 -3
- package/Libraries/promiseRejectionTrackingOptions.js +21 -9
- package/Libraries/vendor/emitter/EventEmitter.js +17 -17
- package/flow/global.js +1 -3
- package/flow/jest.js +5 -1
- package/{Libraries/Components/DrawerAndroid/DrawerLayoutAndroid.ios.js → jest/ReactNativeInternalFeatureFlagsMock.js} +2 -1
- package/jest/__tests__/setup-test.js +18 -0
- package/jest/mockModal.js +6 -4
- package/jest/setup.js +61 -30
- package/jest.config.js +1 -1
- package/just-task.js +1 -0
- package/overrides.json +54 -60
- package/package.json +35 -33
- package/src/Libraries/Components/Button/ButtonWin32.Props.ts +1 -1
- package/src/Libraries/Components/Button/ButtonWin32.tsx +0 -2
- package/src/Libraries/Components/Touchable/Tests/TouchableWin32Test.tsx +2 -2
- package/src/Libraries/Components/Touchable/TouchableWin32.tsx +1 -1
- package/src/Libraries/Components/View/ViewAccessibility.d.ts +8 -2
- package/src/Libraries/StyleSheet/PlatformColorValueTypesWin32.d.ts +1 -1
- package/types/experimental.d.ts +44 -0
- package/types/index.d.ts +2 -1
- package/types/modules/Devtools.d.ts +1 -0
- package/types/modules/globals.d.ts +16 -1
- package/IntegrationTests/BUCK +0 -32
- package/IntegrationTests/PropertiesUpdateTest.js +0 -29
- package/IntegrationTests/RCTRootViewIntegrationTestApp.js +0 -86
- package/IntegrationTests/ReactContentSizeUpdateTest.js +0 -89
- package/IntegrationTests/SizeFlexibilityUpdateTest.js +0 -106
- package/Libraries/Components/AccessibilityInfo/NativeAccessibilityInfoWin32.js +0 -37
- package/Libraries/Components/TextInput/TextInput.Types.win32.d.ts +0 -51
- package/Libraries/Components/TextInput/TextInput.Types.win32.js +0 -3
- package/Libraries/Components/TextInput/TextInput.Types.win32.js.map +0 -1
- package/Libraries/Utilities/AcessibilityMapping.js +0 -154
- package/Libraries/Utilities/AcessibilityMapping.win32.js +0 -156
- package/Libraries/Utilities/NativeDevSplitBundleLoader.js +0 -19
- package/Libraries/Utilities/useColorScheme.win32.js +0 -26
- package/flow/use-sync-external-store.js +0 -20
- package/flow-typed/npm/base64-js_v1.x.x.js +0 -12
- package/flow-typed/npm/glob_v7.x.x.js +0 -79
- package/flow-typed/npm/pretty-format_v26.x.x.js +0 -49
- package/flow-typed/npm/promise_v8.x.x.js +0 -30
- package/flow-typed/npm/react-dom_v17.x.x.js +0 -139
- package/flow-typed/npm/react-test-renderer_v16.x.x.js +0 -79
- package/flow-typed/npm/stacktrace-parser_v0.1.x.js +0 -17
- package/flow-typed/npm/yargs_v17.x.x.js +0 -341
- package/src/Libraries/Components/AccessibilityInfo/AccessibilityInfo.d.ts +0 -161
- package/src/Libraries/Components/TextInput/TextInput.Types.win32.ts +0 -68
- /package/Libraries/{Renderer/public → ReactNative/ReactFabricPublicInstance}/ReactFabricPublicInstanceUtils.js +0 -0
|
@@ -14,12 +14,38 @@ import type {LogBoxLogData} from './LogBoxLog';
|
|
|
14
14
|
import parseErrorStack from '../../Core/Devtools/parseErrorStack';
|
|
15
15
|
import UTFSequence from '../../UTFSequence';
|
|
16
16
|
import stringifySafe from '../../Utilities/stringifySafe';
|
|
17
|
+
import ansiRegex from 'ansi-regex';
|
|
18
|
+
|
|
19
|
+
const ANSI_REGEX = ansiRegex().source;
|
|
17
20
|
|
|
18
21
|
const BABEL_TRANSFORM_ERROR_FORMAT =
|
|
19
22
|
/^(?:TransformError )?(?:SyntaxError: |ReferenceError: )(.*): (.*) \((\d+):(\d+)\)\n\n([\s\S]+)/;
|
|
23
|
+
|
|
24
|
+
// https://github.com/babel/babel/blob/33dbb85e9e9fe36915273080ecc42aee62ed0ade/packages/babel-code-frame/src/index.ts#L183-L184
|
|
25
|
+
const BABEL_CODE_FRAME_MARKER_PATTERN = new RegExp(
|
|
26
|
+
[
|
|
27
|
+
// Beginning of a line (per 'm' flag)
|
|
28
|
+
'^',
|
|
29
|
+
// Optional ANSI escapes for colors
|
|
30
|
+
`(?:${ANSI_REGEX})*`,
|
|
31
|
+
// Marker
|
|
32
|
+
'>',
|
|
33
|
+
// Optional ANSI escapes for colors
|
|
34
|
+
`(?:${ANSI_REGEX})*`,
|
|
35
|
+
// Left padding for line number
|
|
36
|
+
' +',
|
|
37
|
+
// Line number
|
|
38
|
+
'[0-9]+',
|
|
39
|
+
// Gutter
|
|
40
|
+
' \\|',
|
|
41
|
+
].join(''),
|
|
42
|
+
'm',
|
|
43
|
+
);
|
|
44
|
+
|
|
20
45
|
const BABEL_CODE_FRAME_ERROR_FORMAT =
|
|
21
46
|
// eslint-disable-next-line no-control-regex
|
|
22
47
|
/^(?:TransformError )?(?:.*):? (?:.*?)(\/.*): ([\s\S]+?)\n([ >]{2}[\d\s]+ \|[\s\S]+|\u{001b}[\s\S]+)/u;
|
|
48
|
+
|
|
23
49
|
const METRO_ERROR_FORMAT =
|
|
24
50
|
/^(?:InternalError Metro has encountered an error:) (.*): (.*) \((\d+):(\d+)\)\n\n([\s\S]+)/u;
|
|
25
51
|
|
|
@@ -211,6 +237,7 @@ export function parseLogBoxException(
|
|
|
211
237
|
substitutions: [],
|
|
212
238
|
},
|
|
213
239
|
category: `${fileName}-${row}-${column}`,
|
|
240
|
+
extraData: error.extraData,
|
|
214
241
|
};
|
|
215
242
|
}
|
|
216
243
|
|
|
@@ -238,30 +265,36 @@ export function parseLogBoxException(
|
|
|
238
265
|
substitutions: [],
|
|
239
266
|
},
|
|
240
267
|
category: `${fileName}-${row}-${column}`,
|
|
268
|
+
extraData: error.extraData,
|
|
241
269
|
};
|
|
242
270
|
}
|
|
243
271
|
|
|
244
|
-
|
|
272
|
+
// Perform a cheap match first before trying to parse the full message, which
|
|
273
|
+
// can get expensive for arbitrary input.
|
|
274
|
+
if (BABEL_CODE_FRAME_MARKER_PATTERN.test(message)) {
|
|
275
|
+
const babelCodeFrameError = message.match(BABEL_CODE_FRAME_ERROR_FORMAT);
|
|
245
276
|
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
277
|
+
if (babelCodeFrameError) {
|
|
278
|
+
// Codeframe errors are thrown from any use of buildCodeFrameError.
|
|
279
|
+
const [fileName, content, codeFrame] = babelCodeFrameError.slice(1);
|
|
280
|
+
return {
|
|
281
|
+
level: 'syntax',
|
|
282
|
+
stack: [],
|
|
283
|
+
isComponentError: false,
|
|
284
|
+
componentStack: [],
|
|
285
|
+
codeFrame: {
|
|
286
|
+
fileName,
|
|
287
|
+
location: null, // We are not given the location.
|
|
288
|
+
content: codeFrame,
|
|
289
|
+
},
|
|
290
|
+
message: {
|
|
291
|
+
content,
|
|
292
|
+
substitutions: [],
|
|
293
|
+
},
|
|
294
|
+
category: `${fileName}-${1}-${1}`,
|
|
295
|
+
extraData: error.extraData,
|
|
296
|
+
};
|
|
297
|
+
}
|
|
265
298
|
}
|
|
266
299
|
|
|
267
300
|
if (message.match(/^TransformError /)) {
|
|
@@ -275,6 +308,7 @@ export function parseLogBoxException(
|
|
|
275
308
|
substitutions: [],
|
|
276
309
|
},
|
|
277
310
|
category: message,
|
|
311
|
+
extraData: error.extraData,
|
|
278
312
|
};
|
|
279
313
|
}
|
|
280
314
|
|
|
@@ -286,6 +320,7 @@ export function parseLogBoxException(
|
|
|
286
320
|
isComponentError: error.isComponentError,
|
|
287
321
|
componentStack:
|
|
288
322
|
componentStack != null ? parseComponentStack(componentStack) : [],
|
|
323
|
+
extraData: error.extraData,
|
|
289
324
|
...parseInterpolation([message]),
|
|
290
325
|
};
|
|
291
326
|
}
|
|
@@ -297,6 +332,7 @@ export function parseLogBoxException(
|
|
|
297
332
|
stack: error.stack,
|
|
298
333
|
isComponentError: error.isComponentError,
|
|
299
334
|
componentStack: parseComponentStack(componentStack),
|
|
335
|
+
extraData: error.extraData,
|
|
300
336
|
...parseInterpolation([message]),
|
|
301
337
|
};
|
|
302
338
|
}
|
|
@@ -307,6 +343,7 @@ export function parseLogBoxException(
|
|
|
307
343
|
level: 'error',
|
|
308
344
|
stack: error.stack,
|
|
309
345
|
isComponentError: error.isComponentError,
|
|
346
|
+
extraData: error.extraData,
|
|
310
347
|
...parseLogBoxLog([message]),
|
|
311
348
|
};
|
|
312
349
|
}
|
|
@@ -73,7 +73,7 @@ export default function Ansi({
|
|
|
73
73
|
return content.replace(/\| $/, ' ');
|
|
74
74
|
} else if (key === 2 && commonWhitespaceLength < Infinity) {
|
|
75
75
|
// Remove common whitespace at the beginning of the line
|
|
76
|
-
return content.
|
|
76
|
+
return content.slice(commonWhitespaceLength);
|
|
77
77
|
} else {
|
|
78
78
|
return content;
|
|
79
79
|
}
|
|
@@ -10,10 +10,10 @@
|
|
|
10
10
|
|
|
11
11
|
import type {LogLevel} from '../Data/LogBoxLog';
|
|
12
12
|
|
|
13
|
+
import SafeAreaView from '../../Components/SafeAreaView/SafeAreaView';
|
|
13
14
|
import View from '../../Components/View/View';
|
|
14
15
|
import StyleSheet from '../../StyleSheet/StyleSheet';
|
|
15
16
|
import Text from '../../Text/Text';
|
|
16
|
-
import DeviceInfo from '../../Utilities/DeviceInfo';
|
|
17
17
|
import LogBoxButton from './LogBoxButton';
|
|
18
18
|
import * as LogBoxStyle from './LogBoxStyle';
|
|
19
19
|
import * as React from 'react';
|
|
@@ -52,39 +52,21 @@ type ButtonProps = $ReadOnly<{|
|
|
|
52
52
|
|
|
53
53
|
function FooterButton(props: ButtonProps): React.Node {
|
|
54
54
|
return (
|
|
55
|
-
<
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
55
|
+
<SafeAreaView style={styles.button}>
|
|
56
|
+
<LogBoxButton
|
|
57
|
+
backgroundColor={{
|
|
58
|
+
default: 'transparent',
|
|
59
|
+
pressed: LogBoxStyle.getBackgroundDarkColor(),
|
|
60
|
+
}}
|
|
61
|
+
onPress={props.onPress}>
|
|
62
|
+
<View style={styles.buttonContent}>
|
|
63
|
+
<Text style={styles.buttonLabel}>{props.text}</Text>
|
|
64
|
+
</View>
|
|
65
|
+
</LogBoxButton>
|
|
66
|
+
</SafeAreaView>
|
|
66
67
|
);
|
|
67
68
|
}
|
|
68
69
|
|
|
69
|
-
const buttonStyles = StyleSheet.create({
|
|
70
|
-
safeArea: {
|
|
71
|
-
flex: 1,
|
|
72
|
-
// $FlowFixMe[sketchy-null-bool]
|
|
73
|
-
paddingBottom: DeviceInfo.getConstants().isIPhoneX_deprecated ? 30 : 0,
|
|
74
|
-
},
|
|
75
|
-
content: {
|
|
76
|
-
alignItems: 'center',
|
|
77
|
-
height: 48,
|
|
78
|
-
justifyContent: 'center',
|
|
79
|
-
},
|
|
80
|
-
label: {
|
|
81
|
-
color: LogBoxStyle.getTextColor(1),
|
|
82
|
-
fontSize: 14,
|
|
83
|
-
includeFontPadding: false,
|
|
84
|
-
lineHeight: 20,
|
|
85
|
-
},
|
|
86
|
-
});
|
|
87
|
-
|
|
88
70
|
const styles = StyleSheet.create({
|
|
89
71
|
root: {
|
|
90
72
|
backgroundColor: LogBoxStyle.getBackgroundColor(1),
|
|
@@ -97,6 +79,17 @@ const styles = StyleSheet.create({
|
|
|
97
79
|
button: {
|
|
98
80
|
flex: 1,
|
|
99
81
|
},
|
|
82
|
+
buttonContent: {
|
|
83
|
+
alignItems: 'center',
|
|
84
|
+
height: 48,
|
|
85
|
+
justifyContent: 'center',
|
|
86
|
+
},
|
|
87
|
+
buttonLabel: {
|
|
88
|
+
color: LogBoxStyle.getTextColor(1),
|
|
89
|
+
fontSize: 14,
|
|
90
|
+
includeFontPadding: false,
|
|
91
|
+
lineHeight: 20,
|
|
92
|
+
},
|
|
100
93
|
syntaxErrorText: {
|
|
101
94
|
textAlign: 'center',
|
|
102
95
|
width: '100%',
|
|
@@ -138,17 +138,14 @@ function LogBoxMessage(props: Props): React.Node {
|
|
|
138
138
|
const key = String(index);
|
|
139
139
|
|
|
140
140
|
if (substitution.offset > prevOffset) {
|
|
141
|
-
const prevPart = content.
|
|
142
|
-
prevOffset,
|
|
143
|
-
substitution.offset - prevOffset,
|
|
144
|
-
);
|
|
141
|
+
const prevPart = content.slice(prevOffset, substitution.offset);
|
|
145
142
|
|
|
146
143
|
createUnderLength(key, prevPart);
|
|
147
144
|
}
|
|
148
145
|
|
|
149
|
-
const substitutionPart = content.
|
|
146
|
+
const substitutionPart = content.slice(
|
|
150
147
|
substitution.offset,
|
|
151
|
-
substitution.length,
|
|
148
|
+
substitution.offset + substitution.length,
|
|
152
149
|
);
|
|
153
150
|
|
|
154
151
|
createUnderLength(key + '.5', substitutionPart, substitutionStyle);
|
|
@@ -156,7 +153,7 @@ function LogBoxMessage(props: Props): React.Node {
|
|
|
156
153
|
}, 0);
|
|
157
154
|
|
|
158
155
|
if (lastOffset < content.length) {
|
|
159
|
-
const lastPart = content.
|
|
156
|
+
const lastPart = content.slice(lastOffset);
|
|
160
157
|
createUnderLength('-1', lastPart);
|
|
161
158
|
}
|
|
162
159
|
|
|
@@ -0,0 +1,184 @@
|
|
|
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-local
|
|
8
|
+
* @format
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
// flowlint unsafe-getters-setters:off
|
|
12
|
+
|
|
13
|
+
import type {MutationObserverId} from './MutationObserverManager';
|
|
14
|
+
import type MutationRecord from './MutationRecord';
|
|
15
|
+
|
|
16
|
+
import ReactNativeElement from '../DOM/Nodes/ReactNativeElement';
|
|
17
|
+
import * as MutationObserverManager from './MutationObserverManager';
|
|
18
|
+
|
|
19
|
+
export type MutationObserverCallback = (
|
|
20
|
+
mutationRecords: $ReadOnlyArray<MutationRecord>,
|
|
21
|
+
observer: MutationObserver,
|
|
22
|
+
) => mixed;
|
|
23
|
+
|
|
24
|
+
type MutationObserverInit = $ReadOnly<{
|
|
25
|
+
subtree?: boolean,
|
|
26
|
+
// This is the only supported option so it's required to be `true`.
|
|
27
|
+
childList: true,
|
|
28
|
+
|
|
29
|
+
// Unsupported:
|
|
30
|
+
attributes?: boolean,
|
|
31
|
+
attributeFilter?: $ReadOnlyArray<string>,
|
|
32
|
+
attributeOldValue?: boolean,
|
|
33
|
+
characterData?: boolean,
|
|
34
|
+
characterDataOldValue?: boolean,
|
|
35
|
+
}>;
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* This is a React Native implementation for the `MutationObserver` API
|
|
39
|
+
* (https://developer.mozilla.org/en-US/docs/Web/API/MutationObserver).
|
|
40
|
+
*
|
|
41
|
+
* It only supports the `subtree` and `childList` options at the moment.
|
|
42
|
+
*/
|
|
43
|
+
export default class MutationObserver {
|
|
44
|
+
_callback: MutationObserverCallback;
|
|
45
|
+
_observationTargets: Set<ReactNativeElement> = new Set();
|
|
46
|
+
_mutationObserverId: ?MutationObserverId;
|
|
47
|
+
|
|
48
|
+
constructor(callback: MutationObserverCallback): void {
|
|
49
|
+
if (callback == null) {
|
|
50
|
+
throw new TypeError(
|
|
51
|
+
"Failed to construct 'MutationObserver': 1 argument required, but only 0 present.",
|
|
52
|
+
);
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
if (typeof callback !== 'function') {
|
|
56
|
+
throw new TypeError(
|
|
57
|
+
"Failed to construct 'MutationObserver': parameter 1 is not of type 'Function'.",
|
|
58
|
+
);
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
this._callback = callback;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* Configures the `MutationObserver` callback to begin receiving notifications
|
|
66
|
+
* of changes to the UI tree that match the given options.
|
|
67
|
+
* Depending on the configuration, the observer may watch a single node in the
|
|
68
|
+
* UI tree, or that node and some or all of its descendant nodes.
|
|
69
|
+
* To stop the `MutationObserver` (so that none of its callbacks will be
|
|
70
|
+
* triggered any longer), call `MutationObserver.disconnect()`.
|
|
71
|
+
*/
|
|
72
|
+
observe(target: ReactNativeElement, options?: MutationObserverInit): void {
|
|
73
|
+
if (!(target instanceof ReactNativeElement)) {
|
|
74
|
+
throw new TypeError(
|
|
75
|
+
"Failed to execute 'observe' on 'MutationObserver': parameter 1 is not of type 'ReactNativeElement'.",
|
|
76
|
+
);
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
// Browsers force a cast of this value to boolean
|
|
80
|
+
if (Boolean(options?.childList) !== true) {
|
|
81
|
+
throw new TypeError(
|
|
82
|
+
"Failed to execute 'observe' on 'MutationObserver': The options object must set 'childList' to true.",
|
|
83
|
+
);
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
if (options?.attributes != null) {
|
|
87
|
+
throw new Error(
|
|
88
|
+
"Failed to execute 'observe' on 'MutationObserver': attributes is not supported",
|
|
89
|
+
);
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
if (options?.attributeFilter != null) {
|
|
93
|
+
throw new Error(
|
|
94
|
+
"Failed to execute 'observe' on 'MutationObserver': attributeFilter is not supported",
|
|
95
|
+
);
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
if (options?.attributeOldValue != null) {
|
|
99
|
+
throw new Error(
|
|
100
|
+
"Failed to execute 'observe' on 'MutationObserver': attributeOldValue is not supported",
|
|
101
|
+
);
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
if (options?.characterData != null) {
|
|
105
|
+
throw new Error(
|
|
106
|
+
"Failed to execute 'observe' on 'MutationObserver': characterData is not supported",
|
|
107
|
+
);
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
if (options?.characterDataOldValue != null) {
|
|
111
|
+
throw new Error(
|
|
112
|
+
"Failed to execute 'observe' on 'MutationObserver': characterDataOldValue is not supported",
|
|
113
|
+
);
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
const mutationObserverId = this._getOrCreateMutationObserverId();
|
|
117
|
+
|
|
118
|
+
// As per the spec, if the target is already being observed, we "reset"
|
|
119
|
+
// the observation and only use the last options used.
|
|
120
|
+
if (this._observationTargets.has(target)) {
|
|
121
|
+
MutationObserverManager.unobserve(mutationObserverId, target);
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
MutationObserverManager.observe({
|
|
125
|
+
mutationObserverId,
|
|
126
|
+
target,
|
|
127
|
+
subtree: Boolean(options?.subtree),
|
|
128
|
+
});
|
|
129
|
+
|
|
130
|
+
this._observationTargets.add(target);
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
_unobserve(target: ReactNativeElement): void {
|
|
134
|
+
if (!(target instanceof ReactNativeElement)) {
|
|
135
|
+
throw new TypeError(
|
|
136
|
+
"Failed to execute 'observe' on 'MutationObserver': parameter 1 is not of type 'ReactNativeElement'.",
|
|
137
|
+
);
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
if (!this._observationTargets.has(target)) {
|
|
141
|
+
return;
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
const mutationObserverId = this._mutationObserverId;
|
|
145
|
+
if (mutationObserverId == null) {
|
|
146
|
+
return;
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
MutationObserverManager.unobserve(mutationObserverId, target);
|
|
150
|
+
this._observationTargets.delete(target);
|
|
151
|
+
|
|
152
|
+
if (this._observationTargets.size === 0) {
|
|
153
|
+
MutationObserverManager.unregisterObserver(mutationObserverId);
|
|
154
|
+
this._mutationObserverId = null;
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
/**
|
|
159
|
+
* Tells the observer to stop watching for mutations.
|
|
160
|
+
* The observer can be reused by calling its `observe()` method again.
|
|
161
|
+
*/
|
|
162
|
+
disconnect(): void {
|
|
163
|
+
for (const target of this._observationTargets.keys()) {
|
|
164
|
+
this._unobserve(target);
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
_getOrCreateMutationObserverId(): MutationObserverId {
|
|
169
|
+
let mutationObserverId = this._mutationObserverId;
|
|
170
|
+
if (mutationObserverId == null) {
|
|
171
|
+
mutationObserverId = MutationObserverManager.registerObserver(
|
|
172
|
+
this,
|
|
173
|
+
this._callback,
|
|
174
|
+
);
|
|
175
|
+
this._mutationObserverId = mutationObserverId;
|
|
176
|
+
}
|
|
177
|
+
return mutationObserverId;
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
// Only for tests
|
|
181
|
+
__getObserverID(): ?MutationObserverId {
|
|
182
|
+
return this._mutationObserverId;
|
|
183
|
+
}
|
|
184
|
+
}
|
|
@@ -0,0 +1,218 @@
|
|
|
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-local
|
|
8
|
+
* @format
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* This module handles the communication between the React Native renderer
|
|
13
|
+
* and all the mutation observers that are currently observing any targets.
|
|
14
|
+
*
|
|
15
|
+
* In order to reduce the communication between native and JavaScript,
|
|
16
|
+
* we register a single notication callback in native, and then we handle how
|
|
17
|
+
* to notify each entry to the right mutation observer when we receive all
|
|
18
|
+
* the notifications together.
|
|
19
|
+
*/
|
|
20
|
+
|
|
21
|
+
import type ReactNativeElement from '../DOM/Nodes/ReactNativeElement';
|
|
22
|
+
import type MutationObserver, {
|
|
23
|
+
MutationObserverCallback,
|
|
24
|
+
} from './MutationObserver';
|
|
25
|
+
import type MutationRecord from './MutationRecord';
|
|
26
|
+
|
|
27
|
+
import {
|
|
28
|
+
getPublicInstanceFromInternalInstanceHandle,
|
|
29
|
+
getShadowNode,
|
|
30
|
+
} from '../DOM/Nodes/ReadOnlyNode';
|
|
31
|
+
import * as Systrace from '../Performance/Systrace';
|
|
32
|
+
import warnOnce from '../Utilities/warnOnce';
|
|
33
|
+
import {createMutationRecord} from './MutationRecord';
|
|
34
|
+
import NativeMutationObserver from './NativeMutationObserver';
|
|
35
|
+
|
|
36
|
+
export type MutationObserverId = number;
|
|
37
|
+
|
|
38
|
+
let nextMutationObserverId: MutationObserverId = 1;
|
|
39
|
+
let isConnected: boolean = false;
|
|
40
|
+
|
|
41
|
+
const registeredMutationObservers: Map<
|
|
42
|
+
MutationObserverId,
|
|
43
|
+
$ReadOnly<{observer: MutationObserver, callback: MutationObserverCallback}>,
|
|
44
|
+
> = new Map();
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* Registers the given mutation observer and returns a unique ID for it,
|
|
48
|
+
* which is required to start observing targets.
|
|
49
|
+
*/
|
|
50
|
+
export function registerObserver(
|
|
51
|
+
observer: MutationObserver,
|
|
52
|
+
callback: MutationObserverCallback,
|
|
53
|
+
): MutationObserverId {
|
|
54
|
+
const mutationObserverId = nextMutationObserverId;
|
|
55
|
+
nextMutationObserverId++;
|
|
56
|
+
registeredMutationObservers.set(mutationObserverId, {
|
|
57
|
+
observer,
|
|
58
|
+
callback,
|
|
59
|
+
});
|
|
60
|
+
return mutationObserverId;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* Unregisters the given mutation observer.
|
|
65
|
+
* This should only be called when an observer is no longer observing any
|
|
66
|
+
* targets.
|
|
67
|
+
*/
|
|
68
|
+
export function unregisterObserver(
|
|
69
|
+
mutationObserverId: MutationObserverId,
|
|
70
|
+
): void {
|
|
71
|
+
const deleted = registeredMutationObservers.delete(mutationObserverId);
|
|
72
|
+
if (deleted && registeredMutationObservers.size === 0) {
|
|
73
|
+
// When there are no observers left, we can disconnect the native module
|
|
74
|
+
// so we don't need to check commits for mutations.
|
|
75
|
+
NativeMutationObserver?.disconnect();
|
|
76
|
+
isConnected = false;
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
export function observe({
|
|
81
|
+
mutationObserverId,
|
|
82
|
+
target,
|
|
83
|
+
subtree,
|
|
84
|
+
}: {
|
|
85
|
+
mutationObserverId: MutationObserverId,
|
|
86
|
+
target: ReactNativeElement,
|
|
87
|
+
subtree: boolean,
|
|
88
|
+
}): void {
|
|
89
|
+
if (NativeMutationObserver == null) {
|
|
90
|
+
warnNoNativeMutationObserver();
|
|
91
|
+
return;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
const registeredObserver =
|
|
95
|
+
registeredMutationObservers.get(mutationObserverId);
|
|
96
|
+
if (registeredObserver == null) {
|
|
97
|
+
console.error(
|
|
98
|
+
`MutationObserverManager: could not start observing target because MutationObserver with ID ${mutationObserverId} was not registered.`,
|
|
99
|
+
);
|
|
100
|
+
return;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
const targetShadowNode = getShadowNode(target);
|
|
104
|
+
if (targetShadowNode == null) {
|
|
105
|
+
console.error(
|
|
106
|
+
'MutationObserverManager: could not find reference to host node from target',
|
|
107
|
+
);
|
|
108
|
+
return;
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
if (!isConnected) {
|
|
112
|
+
NativeMutationObserver.connect(
|
|
113
|
+
notifyMutationObservers,
|
|
114
|
+
// We need to do this operation from native to make sure we're retaining
|
|
115
|
+
// the public instance immediately when mutations occur. Otherwise React
|
|
116
|
+
// could dereference it in the instance handle and we wouldn't be able to
|
|
117
|
+
// access it.
|
|
118
|
+
// $FlowExpectedError[incompatible-call] This is typed as (mixed) => mixed in the native module because the codegen doesn't support the actual types.
|
|
119
|
+
getPublicInstanceFromInternalInstanceHandle,
|
|
120
|
+
);
|
|
121
|
+
isConnected = true;
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
return NativeMutationObserver.observe({
|
|
125
|
+
mutationObserverId,
|
|
126
|
+
targetShadowNode,
|
|
127
|
+
subtree,
|
|
128
|
+
});
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
export function unobserve(
|
|
132
|
+
mutationObserverId: number,
|
|
133
|
+
target: ReactNativeElement,
|
|
134
|
+
): void {
|
|
135
|
+
if (NativeMutationObserver == null) {
|
|
136
|
+
warnNoNativeMutationObserver();
|
|
137
|
+
return;
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
const registeredObserver =
|
|
141
|
+
registeredMutationObservers.get(mutationObserverId);
|
|
142
|
+
if (registeredObserver == null) {
|
|
143
|
+
console.error(
|
|
144
|
+
`MutationObserverManager: could not stop observing target because MutationObserver with ID ${mutationObserverId} was not registered.`,
|
|
145
|
+
);
|
|
146
|
+
return;
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
const targetShadowNode = getShadowNode(target);
|
|
150
|
+
if (targetShadowNode == null) {
|
|
151
|
+
console.error(
|
|
152
|
+
'MutationObserverManager: could not find reference to host node from target',
|
|
153
|
+
);
|
|
154
|
+
return;
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
NativeMutationObserver.unobserve(mutationObserverId, targetShadowNode);
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
/**
|
|
161
|
+
* This function is called from native when there are `MutationObserver`
|
|
162
|
+
* entries to dispatch.
|
|
163
|
+
*/
|
|
164
|
+
function notifyMutationObservers(): void {
|
|
165
|
+
Systrace.beginEvent('MutationObserverManager.notifyMutationObservers');
|
|
166
|
+
try {
|
|
167
|
+
doNotifyMutationObservers();
|
|
168
|
+
} finally {
|
|
169
|
+
Systrace.endEvent();
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
function doNotifyMutationObservers(): void {
|
|
174
|
+
if (NativeMutationObserver == null) {
|
|
175
|
+
warnNoNativeMutationObserver();
|
|
176
|
+
return;
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
const nativeRecords = NativeMutationObserver.takeRecords();
|
|
180
|
+
|
|
181
|
+
const entriesByObserver: Map<
|
|
182
|
+
MutationObserverId,
|
|
183
|
+
Array<MutationRecord>,
|
|
184
|
+
> = new Map();
|
|
185
|
+
|
|
186
|
+
for (const nativeRecord of nativeRecords) {
|
|
187
|
+
let list = entriesByObserver.get(nativeRecord.mutationObserverId);
|
|
188
|
+
if (list == null) {
|
|
189
|
+
list = [];
|
|
190
|
+
entriesByObserver.set(nativeRecord.mutationObserverId, list);
|
|
191
|
+
}
|
|
192
|
+
list.push(createMutationRecord(nativeRecord));
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
for (const [mutationObserverId, entriesForObserver] of entriesByObserver) {
|
|
196
|
+
const registeredObserver =
|
|
197
|
+
registeredMutationObservers.get(mutationObserverId);
|
|
198
|
+
if (!registeredObserver) {
|
|
199
|
+
// This could happen if the observer is disconnected between commit
|
|
200
|
+
// and mount. In this case, we can just ignore the entries.
|
|
201
|
+
return;
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
const {observer, callback} = registeredObserver;
|
|
205
|
+
try {
|
|
206
|
+
callback.call(observer, entriesForObserver, observer);
|
|
207
|
+
} catch (error) {
|
|
208
|
+
console.error(error);
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
function warnNoNativeMutationObserver() {
|
|
214
|
+
warnOnce(
|
|
215
|
+
'missing-native-mutation-observer',
|
|
216
|
+
'Missing native implementation of MutationObserver',
|
|
217
|
+
);
|
|
218
|
+
}
|