@office-iss/react-native-win32 0.0.0-canary.256 → 0.0.0-canary.257
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 +40 -1
- package/CHANGELOG.md +20 -8
- package/Libraries/Core/ReactNativeVersion.js +1 -1
- package/Libraries/Core/setUpTimers.js +19 -0
- package/Libraries/LogBox/Data/LogBoxData.js +39 -4
- package/Libraries/LogBox/Data/LogBoxLog.js +5 -2
- package/Libraries/LogBox/Data/parseLogBoxLog.js +22 -1
- package/Libraries/LogBox/LogBox.js +29 -12
- package/Libraries/LogBox/LogBoxNotificationContainer.js +4 -0
- package/Libraries/LogBox/UI/LogBoxInspector.js +8 -70
- package/Libraries/LogBox/UI/LogBoxInspectorBody.js +87 -0
- package/Libraries/LogBox/UI/LogBoxInspectorFooter.js +6 -42
- package/Libraries/LogBox/UI/LogBoxInspectorFooterButton.js +58 -0
- package/Libraries/LogBox/UI/LogBoxInspectorHeader.js +5 -66
- package/Libraries/LogBox/UI/LogBoxInspectorHeader.win32.js +7 -72
- package/Libraries/LogBox/UI/LogBoxInspectorHeaderButton.js +76 -0
- package/Libraries/LogBox/UI/LogBoxNotification.js +13 -152
- package/Libraries/LogBox/UI/LogBoxNotificationCountBadge.js +63 -0
- package/Libraries/LogBox/UI/LogBoxNotificationDismissButton.js +67 -0
- package/Libraries/LogBox/UI/LogBoxNotificationMessage.js +57 -0
- package/Libraries/Renderer/implementations/ReactFabric-dev.js +15690 -26405
- package/Libraries/Renderer/implementations/ReactFabric-prod.js +2675 -1630
- package/Libraries/Renderer/implementations/ReactFabric-profiling.js +2945 -1682
- package/Libraries/Renderer/implementations/ReactNativeRenderer-dev.js +16141 -27018
- package/Libraries/Renderer/implementations/ReactNativeRenderer-prod.js +2723 -1666
- package/Libraries/Renderer/implementations/ReactNativeRenderer-profiling.js +2984 -1737
- package/Libraries/Share/Share.d.ts +16 -10
- package/Libraries/Share/Share.js +14 -15
- package/Libraries/Text/Text.js +25 -20
- package/Libraries/Text/Text.win32.js +25 -20
- package/Libraries/Text/TextNativeComponent.js +1 -1
- package/Libraries/Text/TextNativeComponent.win32.js +1 -1
- package/Libraries/Text/TextOptimized.js +538 -0
- package/Libraries/Utilities/ReactNativeTestTools.js +7 -24
- package/Libraries/__tests__/ButtonWin32-test.js +7 -6
- package/Libraries/promiseRejectionTrackingOptions.js +1 -0
- package/jest/renderer.js +25 -14
- package/jest/setup.js +5 -0
- package/overrides.json +5 -5
- package/package.json +19 -19
- package/src/private/specs/modules/NativeDevSettings.js +1 -0
- package/src/private/webapis/idlecallbacks/specs/NativeIdleCallbacks.js +34 -0
package/.flowconfig
CHANGED
package/CHANGELOG.json
CHANGED
|
@@ -2,7 +2,46 @@
|
|
|
2
2
|
"name": "@office-iss/react-native-win32",
|
|
3
3
|
"entries": [
|
|
4
4
|
{
|
|
5
|
-
"date": "Wed,
|
|
5
|
+
"date": "Wed, 24 Jul 2024 05:20:13 GMT",
|
|
6
|
+
"version": "0.0.0-canary.257",
|
|
7
|
+
"tag": "@office-iss/react-native-win32_v0.0.0-canary.257",
|
|
8
|
+
"comments": {
|
|
9
|
+
"prerelease": [
|
|
10
|
+
{
|
|
11
|
+
"author": "yajurgrover24@gmail.com",
|
|
12
|
+
"package": "@office-iss/react-native-win32",
|
|
13
|
+
"commit": "7b187af8b17b433ac02a8aff0051684924da4217",
|
|
14
|
+
"comment": "integrate 6/14"
|
|
15
|
+
},
|
|
16
|
+
{
|
|
17
|
+
"author": "beachball",
|
|
18
|
+
"package": "@office-iss/react-native-win32",
|
|
19
|
+
"comment": "Bump @rnw-scripts/eslint-config to v1.2.25",
|
|
20
|
+
"commit": "not available"
|
|
21
|
+
},
|
|
22
|
+
{
|
|
23
|
+
"author": "beachball",
|
|
24
|
+
"package": "@office-iss/react-native-win32",
|
|
25
|
+
"comment": "Bump @rnw-scripts/jest-out-of-tree-snapshot-resolver to v1.1.29",
|
|
26
|
+
"commit": "not available"
|
|
27
|
+
},
|
|
28
|
+
{
|
|
29
|
+
"author": "beachball",
|
|
30
|
+
"package": "@office-iss/react-native-win32",
|
|
31
|
+
"comment": "Bump @rnw-scripts/just-task to v2.3.42",
|
|
32
|
+
"commit": "not available"
|
|
33
|
+
},
|
|
34
|
+
{
|
|
35
|
+
"author": "beachball",
|
|
36
|
+
"package": "@office-iss/react-native-win32",
|
|
37
|
+
"comment": "Bump react-native-platform-override to v1.9.44",
|
|
38
|
+
"commit": "not available"
|
|
39
|
+
}
|
|
40
|
+
]
|
|
41
|
+
}
|
|
42
|
+
},
|
|
43
|
+
{
|
|
44
|
+
"date": "Wed, 10 Jul 2024 05:15:28 GMT",
|
|
6
45
|
"version": "0.0.0-canary.256",
|
|
7
46
|
"tag": "@office-iss/react-native-win32_v0.0.0-canary.256",
|
|
8
47
|
"comments": {
|
package/CHANGELOG.md
CHANGED
|
@@ -1,21 +1,33 @@
|
|
|
1
1
|
# Change Log - @office-iss/react-native-win32
|
|
2
2
|
|
|
3
|
-
This log was last generated on Wed,
|
|
3
|
+
This log was last generated on Wed, 24 Jul 2024 05:20:13 GMT and should not be manually modified.
|
|
4
4
|
|
|
5
5
|
<!-- Start content -->
|
|
6
6
|
|
|
7
|
-
## 0.0.0-canary.
|
|
7
|
+
## 0.0.0-canary.257
|
|
8
8
|
|
|
9
|
-
Wed,
|
|
9
|
+
Wed, 24 Jul 2024 05:20:13 GMT
|
|
10
10
|
|
|
11
11
|
### Changes
|
|
12
12
|
|
|
13
|
-
-
|
|
14
|
-
- Bump @rnw-scripts/eslint-config to v1.2.
|
|
15
|
-
- Bump @rnw-scripts/jest-out-of-tree-snapshot-resolver to v1.1.
|
|
16
|
-
- Bump @rnw-scripts/just-task to v2.3.
|
|
17
|
-
- Bump react-native-platform-override to v1.9.
|
|
13
|
+
- integrate 6/14 (yajurgrover24@gmail.com)
|
|
14
|
+
- Bump @rnw-scripts/eslint-config to v1.2.25
|
|
15
|
+
- Bump @rnw-scripts/jest-out-of-tree-snapshot-resolver to v1.1.29
|
|
16
|
+
- Bump @rnw-scripts/just-task to v2.3.42
|
|
17
|
+
- Bump react-native-platform-override to v1.9.44
|
|
18
18
|
|
|
19
|
+
## 0.0.0-canary.256
|
|
20
|
+
|
|
21
|
+
Wed, 10 Jul 2024 05:15:28 GMT
|
|
22
|
+
|
|
23
|
+
### Changes
|
|
24
|
+
|
|
25
|
+
- Integrate 6/13 (yajurgrover24@gmail.com)
|
|
26
|
+
- Bump @rnw-scripts/eslint-config to v1.2.24
|
|
27
|
+
- Bump @rnw-scripts/jest-out-of-tree-snapshot-resolver to v1.1.28
|
|
28
|
+
- Bump @rnw-scripts/just-task to v2.3.41
|
|
29
|
+
- Bump react-native-platform-override to v1.9.43
|
|
30
|
+
|
|
19
31
|
## 0.0.0-canary.255
|
|
20
32
|
|
|
21
33
|
Fri, 21 Jun 2024 05:17:50 GMT
|
|
@@ -48,6 +48,25 @@ if (global.RN$Bridgeless !== true) {
|
|
|
48
48
|
defineLazyTimer('cancelAnimationFrame');
|
|
49
49
|
defineLazyTimer('requestIdleCallback');
|
|
50
50
|
defineLazyTimer('cancelIdleCallback');
|
|
51
|
+
} else if (
|
|
52
|
+
// TODO remove this condition when bridgeless == modern scheduler everywhere.
|
|
53
|
+
NativeReactNativeFeatureFlags != null &&
|
|
54
|
+
// eslint-disable-next-line react-hooks/rules-of-hooks -- false positive due to `use` prefix
|
|
55
|
+
ReactNativeFeatureFlags.useModernRuntimeScheduler()
|
|
56
|
+
) {
|
|
57
|
+
polyfillGlobal(
|
|
58
|
+
'requestIdleCallback',
|
|
59
|
+
() =>
|
|
60
|
+
require('../../src/private/webapis/idlecallbacks/specs/NativeIdleCallbacks')
|
|
61
|
+
.default.requestIdleCallback,
|
|
62
|
+
);
|
|
63
|
+
|
|
64
|
+
polyfillGlobal(
|
|
65
|
+
'cancelIdleCallback',
|
|
66
|
+
() =>
|
|
67
|
+
require('../../src/private/webapis/idlecallbacks/specs/NativeIdleCallbacks')
|
|
68
|
+
.default.cancelIdleCallback,
|
|
69
|
+
);
|
|
51
70
|
}
|
|
52
71
|
|
|
53
72
|
// We need to check if the native module is available before accessing the
|
|
@@ -8,30 +8,32 @@
|
|
|
8
8
|
* @format
|
|
9
9
|
*/
|
|
10
10
|
|
|
11
|
-
('use strict');
|
|
12
|
-
|
|
13
11
|
import type {ExtendedError} from '../../Core/ExtendedError';
|
|
14
12
|
import type {LogLevel} from './LogBoxLog';
|
|
15
13
|
import type {
|
|
16
14
|
Category,
|
|
17
15
|
ComponentStack,
|
|
16
|
+
ComponentStackType,
|
|
18
17
|
ExtendedExceptionData,
|
|
19
18
|
Message,
|
|
20
19
|
} from './parseLogBoxLog';
|
|
21
20
|
|
|
22
21
|
import parseErrorStack from '../../Core/Devtools/parseErrorStack';
|
|
22
|
+
import NativeDevSettings from '../../NativeModules/specs/NativeDevSettings';
|
|
23
23
|
import NativeLogBox from '../../NativeModules/specs/NativeLogBox';
|
|
24
24
|
import LogBoxLog from './LogBoxLog';
|
|
25
25
|
import {parseLogBoxException} from './parseLogBoxLog';
|
|
26
26
|
import * as React from 'react';
|
|
27
|
+
|
|
27
28
|
export type LogBoxLogs = Set<LogBoxLog>;
|
|
28
|
-
export type LogData = $ReadOnly<{
|
|
29
|
+
export type LogData = $ReadOnly<{
|
|
29
30
|
level: LogLevel,
|
|
30
31
|
message: Message,
|
|
31
32
|
category: Category,
|
|
32
33
|
componentStack: ComponentStack,
|
|
34
|
+
componentStackType: ComponentStackType | null,
|
|
33
35
|
stack?: string,
|
|
34
|
-
|
|
36
|
+
}>;
|
|
35
37
|
|
|
36
38
|
export type Observer = (
|
|
37
39
|
$ReadOnly<{|
|
|
@@ -72,6 +74,7 @@ let logs: LogBoxLogs = new Set();
|
|
|
72
74
|
let updateTimeout: $FlowFixMe | null = null;
|
|
73
75
|
let _isDisabled = false;
|
|
74
76
|
let _selectedIndex = -1;
|
|
77
|
+
let hasShownFuseboxWarningsMigrationMessage = false;
|
|
75
78
|
|
|
76
79
|
let warningFilter: WarningFilter = function (format) {
|
|
77
80
|
return {
|
|
@@ -193,6 +196,11 @@ function appendNewLog(newLog: LogBoxLog) {
|
|
|
193
196
|
}
|
|
194
197
|
|
|
195
198
|
export function addLog(log: LogData): void {
|
|
199
|
+
if (log.level === 'warn' && global.__FUSEBOX_HAS_FULL_CONSOLE_SUPPORT__) {
|
|
200
|
+
// Under Fusebox, don't report warnings to LogBox.
|
|
201
|
+
showFuseboxWarningsMigrationMessageOnce();
|
|
202
|
+
return;
|
|
203
|
+
}
|
|
196
204
|
const errorForStackTrace = new Error();
|
|
197
205
|
|
|
198
206
|
// Parsing logs are expensive so we schedule this
|
|
@@ -209,6 +217,7 @@ export function addLog(log: LogData): void {
|
|
|
209
217
|
stack,
|
|
210
218
|
category: log.category,
|
|
211
219
|
componentStack: log.componentStack,
|
|
220
|
+
componentStackType: log.componentStackType || 'legacy',
|
|
212
221
|
}),
|
|
213
222
|
);
|
|
214
223
|
} catch (error) {
|
|
@@ -453,3 +462,29 @@ export function withSubscription(
|
|
|
453
462
|
|
|
454
463
|
return LogBoxStateSubscription;
|
|
455
464
|
}
|
|
465
|
+
|
|
466
|
+
function showFuseboxWarningsMigrationMessageOnce() {
|
|
467
|
+
if (hasShownFuseboxWarningsMigrationMessage) {
|
|
468
|
+
return;
|
|
469
|
+
}
|
|
470
|
+
hasShownFuseboxWarningsMigrationMessage = true;
|
|
471
|
+
appendNewLog(
|
|
472
|
+
new LogBoxLog({
|
|
473
|
+
level: 'warn',
|
|
474
|
+
message: {
|
|
475
|
+
content: 'Open debugger to view warnings.',
|
|
476
|
+
substitutions: [],
|
|
477
|
+
},
|
|
478
|
+
isComponentError: false,
|
|
479
|
+
stack: [],
|
|
480
|
+
category: 'fusebox-warnings-migration',
|
|
481
|
+
componentStack: [],
|
|
482
|
+
onNotificationPress: () => {
|
|
483
|
+
if (NativeDevSettings.openDebugger) {
|
|
484
|
+
NativeDevSettings.openDebugger();
|
|
485
|
+
}
|
|
486
|
+
clearWarnings();
|
|
487
|
+
},
|
|
488
|
+
}),
|
|
489
|
+
);
|
|
490
|
+
}
|
|
@@ -55,7 +55,7 @@ function convertStackToComponentStack(stack: Stack): ComponentStack {
|
|
|
55
55
|
return componentStack;
|
|
56
56
|
}
|
|
57
57
|
|
|
58
|
-
export type LogBoxLogData = $ReadOnly<{
|
|
58
|
+
export type LogBoxLogData = $ReadOnly<{
|
|
59
59
|
level: LogLevel,
|
|
60
60
|
type?: ?string,
|
|
61
61
|
message: Message,
|
|
@@ -66,7 +66,8 @@ export type LogBoxLogData = $ReadOnly<{|
|
|
|
66
66
|
codeFrame?: ?CodeFrame,
|
|
67
67
|
isComponentError: boolean,
|
|
68
68
|
extraData?: mixed,
|
|
69
|
-
|
|
69
|
+
onNotificationPress?: ?() => void,
|
|
70
|
+
}>;
|
|
70
71
|
|
|
71
72
|
class LogBoxLog {
|
|
72
73
|
message: Message;
|
|
@@ -102,6 +103,7 @@ class LogBoxLog {
|
|
|
102
103
|
componentStack: null,
|
|
103
104
|
status: 'NONE',
|
|
104
105
|
};
|
|
106
|
+
onNotificationPress: ?() => void;
|
|
105
107
|
|
|
106
108
|
constructor(data: LogBoxLogData) {
|
|
107
109
|
this.level = data.level;
|
|
@@ -115,6 +117,7 @@ class LogBoxLog {
|
|
|
115
117
|
this.isComponentError = data.isComponentError;
|
|
116
118
|
this.extraData = data.extraData;
|
|
117
119
|
this.count = 1;
|
|
120
|
+
this.onNotificationPress = data.onNotificationPress;
|
|
118
121
|
}
|
|
119
122
|
|
|
120
123
|
incrementCount(): void {
|
|
@@ -93,6 +93,15 @@ const RE_BABEL_CODE_FRAME_MARKER_PATTERN = new RegExp(
|
|
|
93
93
|
'm',
|
|
94
94
|
);
|
|
95
95
|
|
|
96
|
+
export function hasComponentStack(args: $ReadOnlyArray<mixed>): boolean {
|
|
97
|
+
for (const arg of args) {
|
|
98
|
+
if (typeof arg === 'string' && isComponentStack(arg)) {
|
|
99
|
+
return true;
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
return false;
|
|
103
|
+
}
|
|
104
|
+
|
|
96
105
|
export type ExtendedExceptionData = ExceptionData & {
|
|
97
106
|
isComponentError: boolean,
|
|
98
107
|
...
|
|
@@ -435,13 +444,25 @@ export function parseLogBoxException(
|
|
|
435
444
|
};
|
|
436
445
|
}
|
|
437
446
|
|
|
447
|
+
export function withoutANSIColorStyles(message: mixed): mixed {
|
|
448
|
+
if (typeof message !== 'string') {
|
|
449
|
+
return message;
|
|
450
|
+
}
|
|
451
|
+
|
|
452
|
+
return message.replace(
|
|
453
|
+
// eslint-disable-next-line no-control-regex
|
|
454
|
+
/[\u001b\u009b][[()#;?]*(?:[0-9]{1,4}(?:;[0-9]{0,4})*)?[0-9A-ORZcf-nqry=><]/g,
|
|
455
|
+
'',
|
|
456
|
+
);
|
|
457
|
+
}
|
|
458
|
+
|
|
438
459
|
export function parseLogBoxLog(args: $ReadOnlyArray<mixed>): {|
|
|
439
460
|
componentStack: ComponentStack,
|
|
440
461
|
componentStackType: ComponentStackType,
|
|
441
462
|
category: Category,
|
|
442
463
|
message: Message,
|
|
443
464
|
|} {
|
|
444
|
-
const message = args[0];
|
|
465
|
+
const message = withoutANSIColorStyles(args[0]);
|
|
445
466
|
let argsWithoutComponentStack: Array<mixed> = [];
|
|
446
467
|
let componentStack: ComponentStack = [];
|
|
447
468
|
let componentStackType = 'legacy';
|
|
@@ -13,6 +13,7 @@ import type {ExtendedExceptionData} from './Data/parseLogBoxLog';
|
|
|
13
13
|
|
|
14
14
|
import Platform from '../Utilities/Platform';
|
|
15
15
|
import RCTLog from '../Utilities/RCTLog';
|
|
16
|
+
import {hasComponentStack} from './Data/parseLogBoxLog';
|
|
16
17
|
|
|
17
18
|
export type {LogData, ExtendedExceptionData, IgnorePattern};
|
|
18
19
|
|
|
@@ -150,7 +151,8 @@ if (__DEV__) {
|
|
|
150
151
|
|
|
151
152
|
try {
|
|
152
153
|
if (!isRCTLogAdviceWarning(...args)) {
|
|
153
|
-
const {category, message, componentStack} =
|
|
154
|
+
const {category, message, componentStack, componentStackType} =
|
|
155
|
+
parseLogBoxLog(args);
|
|
154
156
|
|
|
155
157
|
if (!LogBoxData.isMessageIgnored(message.content)) {
|
|
156
158
|
LogBoxData.addLog({
|
|
@@ -158,6 +160,7 @@ if (__DEV__) {
|
|
|
158
160
|
category,
|
|
159
161
|
message,
|
|
160
162
|
componentStack,
|
|
163
|
+
componentStackType,
|
|
161
164
|
});
|
|
162
165
|
}
|
|
163
166
|
}
|
|
@@ -176,12 +179,20 @@ if (__DEV__) {
|
|
|
176
179
|
}
|
|
177
180
|
|
|
178
181
|
try {
|
|
179
|
-
if (!isWarningModuleWarning(...args)) {
|
|
180
|
-
// Only show LogBox for the 'warning' module,
|
|
182
|
+
if (!isWarningModuleWarning(...args) && !hasComponentStack(args)) {
|
|
183
|
+
// Only show LogBox for the 'warning' module, or React errors with
|
|
184
|
+
// component stacks, otherwise pass the error through.u
|
|
185
|
+
//
|
|
181
186
|
// By passing through, this will get picked up by the React console override,
|
|
182
187
|
// potentially adding the component stack. React then passes it back to the
|
|
183
188
|
// React Native ExceptionsManager, which reports it to LogBox as an error.
|
|
184
189
|
//
|
|
190
|
+
// Ideally, we refactor all RN error handling so that LogBox patching
|
|
191
|
+
// errors is not necessary, and they are reported the same as a framework.
|
|
192
|
+
// The blocker to this is that the ExceptionManager console.error override
|
|
193
|
+
// strigifys all of the args before passing it through to LogBox, which
|
|
194
|
+
// would lose all of the interpolation information.
|
|
195
|
+
//
|
|
185
196
|
// The 'warning' module needs to be handled here because React internally calls
|
|
186
197
|
// `console.error('Warning: ')` with the component stack already included.
|
|
187
198
|
originalConsoleError(...args);
|
|
@@ -190,20 +201,25 @@ if (__DEV__) {
|
|
|
190
201
|
|
|
191
202
|
const format = args[0].replace('Warning: ', '');
|
|
192
203
|
const filterResult = LogBoxData.checkWarningFilter(format);
|
|
193
|
-
if (filterResult.suppressCompletely) {
|
|
194
|
-
return;
|
|
195
|
-
}
|
|
196
|
-
|
|
197
204
|
let level = 'error';
|
|
198
|
-
if (filterResult.
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
205
|
+
if (filterResult.monitorEvent !== 'warning_unhandled') {
|
|
206
|
+
if (filterResult.suppressCompletely) {
|
|
207
|
+
return;
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
if (filterResult.suppressDialog_LEGACY === true) {
|
|
211
|
+
level = 'warn';
|
|
212
|
+
} else if (filterResult.forceDialogImmediately === true) {
|
|
213
|
+
level = 'fatal'; // Do not downgrade. These are real bugs with same severity as throws.
|
|
214
|
+
}
|
|
202
215
|
}
|
|
203
216
|
|
|
204
217
|
// Unfortunately, we need to add the Warning: prefix back for downstream dependencies.
|
|
218
|
+
// Downstream, we check for this prefix to know that LogBox already handled it, so
|
|
219
|
+
// it doesn't get reported back to LogBox. It's an absolute mess.
|
|
205
220
|
args[0] = `Warning: ${filterResult.finalFormat}`;
|
|
206
|
-
const {category, message, componentStack} =
|
|
221
|
+
const {category, message, componentStack, componentStackType} =
|
|
222
|
+
parseLogBoxLog(args);
|
|
207
223
|
|
|
208
224
|
// Interpolate the message so they are formatted for adb and other CLIs.
|
|
209
225
|
// This is different than the message.content above because it includes component stacks.
|
|
@@ -216,6 +232,7 @@ if (__DEV__) {
|
|
|
216
232
|
category,
|
|
217
233
|
message,
|
|
218
234
|
componentStack,
|
|
235
|
+
componentStackType,
|
|
219
236
|
});
|
|
220
237
|
}
|
|
221
238
|
} catch (err) {
|
|
@@ -36,6 +36,10 @@ export function _LogBoxNotificationContainer(props: Props): React.Node {
|
|
|
36
36
|
};
|
|
37
37
|
|
|
38
38
|
function openLog(log: LogBoxLog) {
|
|
39
|
+
if (log.onNotificationPress) {
|
|
40
|
+
log.onNotificationPress();
|
|
41
|
+
return;
|
|
42
|
+
}
|
|
39
43
|
let index = logs.length - 1;
|
|
40
44
|
|
|
41
45
|
// Stop at zero because if we don't find any log, we'll open the first log.
|
|
@@ -9,40 +9,37 @@
|
|
|
9
9
|
*/
|
|
10
10
|
|
|
11
11
|
import Keyboard from '../../Components/Keyboard/Keyboard';
|
|
12
|
-
import ScrollView from '../../Components/ScrollView/ScrollView';
|
|
13
12
|
import View from '../../Components/View/View';
|
|
14
13
|
import StyleSheet from '../../StyleSheet/StyleSheet';
|
|
15
14
|
import * as LogBoxData from '../Data/LogBoxData';
|
|
16
15
|
import LogBoxLog, {type LogLevel} from '../Data/LogBoxLog';
|
|
17
|
-
import
|
|
16
|
+
import LogBoxInspectorBody from './LogBoxInspectorBody';
|
|
18
17
|
import LogBoxInspectorFooter from './LogBoxInspectorFooter';
|
|
19
18
|
import LogBoxInspectorHeader from './LogBoxInspectorHeader';
|
|
20
|
-
import LogBoxInspectorMessageHeader from './LogBoxInspectorMessageHeader';
|
|
21
|
-
import LogBoxInspectorReactFrames from './LogBoxInspectorReactFrames';
|
|
22
|
-
import LogBoxInspectorStackFrames from './LogBoxInspectorStackFrames';
|
|
23
19
|
import * as LogBoxStyle from './LogBoxStyle';
|
|
24
20
|
import * as React from 'react';
|
|
21
|
+
import {useEffect} from 'react';
|
|
25
22
|
|
|
26
|
-
type Props = $ReadOnly<{
|
|
23
|
+
type Props = $ReadOnly<{
|
|
27
24
|
onDismiss: () => void,
|
|
28
25
|
onChangeSelectedIndex: (index: number) => void,
|
|
29
26
|
onMinimize: () => void,
|
|
30
27
|
logs: $ReadOnlyArray<LogBoxLog>,
|
|
31
28
|
selectedIndex: number,
|
|
32
29
|
fatalType?: ?LogLevel,
|
|
33
|
-
|
|
30
|
+
}>;
|
|
34
31
|
|
|
35
|
-
function LogBoxInspector(props: Props): React.Node {
|
|
32
|
+
export default function LogBoxInspector(props: Props): React.Node {
|
|
36
33
|
const {logs, selectedIndex} = props;
|
|
37
34
|
let log = logs[selectedIndex];
|
|
38
35
|
|
|
39
|
-
|
|
36
|
+
useEffect(() => {
|
|
40
37
|
if (log) {
|
|
41
38
|
LogBoxData.symbolicateLogNow(log);
|
|
42
39
|
}
|
|
43
40
|
}, [log]);
|
|
44
41
|
|
|
45
|
-
|
|
42
|
+
useEffect(() => {
|
|
46
43
|
// Optimistically symbolicate the last and next logs.
|
|
47
44
|
if (logs.length > 1) {
|
|
48
45
|
const selected = selectedIndex;
|
|
@@ -54,7 +51,7 @@ function LogBoxInspector(props: Props): React.Node {
|
|
|
54
51
|
}
|
|
55
52
|
}, [logs, selectedIndex]);
|
|
56
53
|
|
|
57
|
-
|
|
54
|
+
useEffect(() => {
|
|
58
55
|
Keyboard.dismiss();
|
|
59
56
|
}, []);
|
|
60
57
|
|
|
@@ -84,68 +81,9 @@ function LogBoxInspector(props: Props): React.Node {
|
|
|
84
81
|
);
|
|
85
82
|
}
|
|
86
83
|
|
|
87
|
-
const headerTitleMap = {
|
|
88
|
-
warn: 'Console Warning',
|
|
89
|
-
error: 'Console Error',
|
|
90
|
-
fatal: 'Uncaught Error',
|
|
91
|
-
syntax: 'Syntax Error',
|
|
92
|
-
component: 'Render Error',
|
|
93
|
-
};
|
|
94
|
-
|
|
95
|
-
function LogBoxInspectorBody(props: {log: LogBoxLog, onRetry: () => void}) {
|
|
96
|
-
const [collapsed, setCollapsed] = React.useState(true);
|
|
97
|
-
|
|
98
|
-
React.useEffect(() => {
|
|
99
|
-
setCollapsed(true);
|
|
100
|
-
}, [props.log]);
|
|
101
|
-
|
|
102
|
-
const headerTitle =
|
|
103
|
-
props.log.type ??
|
|
104
|
-
headerTitleMap[props.log.isComponentError ? 'component' : props.log.level];
|
|
105
|
-
|
|
106
|
-
if (collapsed) {
|
|
107
|
-
return (
|
|
108
|
-
<>
|
|
109
|
-
<LogBoxInspectorMessageHeader
|
|
110
|
-
collapsed={collapsed}
|
|
111
|
-
onPress={() => setCollapsed(!collapsed)}
|
|
112
|
-
message={props.log.message}
|
|
113
|
-
level={props.log.level}
|
|
114
|
-
title={headerTitle}
|
|
115
|
-
/>
|
|
116
|
-
<ScrollView style={styles.scrollBody}>
|
|
117
|
-
<LogBoxInspectorCodeFrame codeFrame={props.log.codeFrame} />
|
|
118
|
-
<LogBoxInspectorReactFrames log={props.log} />
|
|
119
|
-
<LogBoxInspectorStackFrames log={props.log} onRetry={props.onRetry} />
|
|
120
|
-
</ScrollView>
|
|
121
|
-
</>
|
|
122
|
-
);
|
|
123
|
-
}
|
|
124
|
-
return (
|
|
125
|
-
<ScrollView style={styles.scrollBody}>
|
|
126
|
-
<LogBoxInspectorMessageHeader
|
|
127
|
-
collapsed={collapsed}
|
|
128
|
-
onPress={() => setCollapsed(!collapsed)}
|
|
129
|
-
message={props.log.message}
|
|
130
|
-
level={props.log.level}
|
|
131
|
-
title={headerTitle}
|
|
132
|
-
/>
|
|
133
|
-
<LogBoxInspectorCodeFrame codeFrame={props.log.codeFrame} />
|
|
134
|
-
<LogBoxInspectorReactFrames log={props.log} />
|
|
135
|
-
<LogBoxInspectorStackFrames log={props.log} onRetry={props.onRetry} />
|
|
136
|
-
</ScrollView>
|
|
137
|
-
);
|
|
138
|
-
}
|
|
139
|
-
|
|
140
84
|
const styles = StyleSheet.create({
|
|
141
85
|
root: {
|
|
142
86
|
flex: 1,
|
|
143
87
|
backgroundColor: LogBoxStyle.getTextColor(),
|
|
144
88
|
},
|
|
145
|
-
scrollBody: {
|
|
146
|
-
backgroundColor: LogBoxStyle.getBackgroundColor(0.9),
|
|
147
|
-
flex: 1,
|
|
148
|
-
},
|
|
149
89
|
});
|
|
150
|
-
|
|
151
|
-
export default LogBoxInspector;
|
|
@@ -0,0 +1,87 @@
|
|
|
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
|
+
import ScrollView from '../../Components/ScrollView/ScrollView';
|
|
12
|
+
import StyleSheet from '../../StyleSheet/StyleSheet';
|
|
13
|
+
import LogBoxLog from '../Data/LogBoxLog';
|
|
14
|
+
import LogBoxInspectorCodeFrame from './LogBoxInspectorCodeFrame';
|
|
15
|
+
import LogBoxInspectorMessageHeader from './LogBoxInspectorMessageHeader';
|
|
16
|
+
import LogBoxInspectorReactFrames from './LogBoxInspectorReactFrames';
|
|
17
|
+
import LogBoxInspectorStackFrames from './LogBoxInspectorStackFrames';
|
|
18
|
+
import * as LogBoxStyle from './LogBoxStyle';
|
|
19
|
+
import * as React from 'react';
|
|
20
|
+
import {useEffect, useState} from 'react';
|
|
21
|
+
|
|
22
|
+
const headerTitleMap = {
|
|
23
|
+
warn: 'Console Warning',
|
|
24
|
+
error: 'Console Error',
|
|
25
|
+
fatal: 'Uncaught Error',
|
|
26
|
+
syntax: 'Syntax Error',
|
|
27
|
+
component: 'Render Error',
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
export default function LogBoxInspectorBody(props: {
|
|
31
|
+
log: LogBoxLog,
|
|
32
|
+
onRetry: () => void,
|
|
33
|
+
}): React.Node {
|
|
34
|
+
const [collapsed, setCollapsed] = useState(true);
|
|
35
|
+
|
|
36
|
+
useEffect(() => {
|
|
37
|
+
setCollapsed(true);
|
|
38
|
+
}, [props.log]);
|
|
39
|
+
|
|
40
|
+
const headerTitle =
|
|
41
|
+
props.log.type ??
|
|
42
|
+
headerTitleMap[props.log.isComponentError ? 'component' : props.log.level];
|
|
43
|
+
|
|
44
|
+
if (collapsed) {
|
|
45
|
+
return (
|
|
46
|
+
<>
|
|
47
|
+
<LogBoxInspectorMessageHeader
|
|
48
|
+
collapsed={collapsed}
|
|
49
|
+
onPress={() => setCollapsed(!collapsed)}
|
|
50
|
+
message={props.log.message}
|
|
51
|
+
level={props.log.level}
|
|
52
|
+
title={headerTitle}
|
|
53
|
+
/>
|
|
54
|
+
<ScrollView style={styles.scrollBody}>
|
|
55
|
+
<LogBoxInspectorCodeFrame codeFrame={props.log.codeFrame} />
|
|
56
|
+
<LogBoxInspectorReactFrames log={props.log} />
|
|
57
|
+
<LogBoxInspectorStackFrames log={props.log} onRetry={props.onRetry} />
|
|
58
|
+
</ScrollView>
|
|
59
|
+
</>
|
|
60
|
+
);
|
|
61
|
+
}
|
|
62
|
+
return (
|
|
63
|
+
<ScrollView style={styles.scrollBody}>
|
|
64
|
+
<LogBoxInspectorMessageHeader
|
|
65
|
+
collapsed={collapsed}
|
|
66
|
+
onPress={() => setCollapsed(!collapsed)}
|
|
67
|
+
message={props.log.message}
|
|
68
|
+
level={props.log.level}
|
|
69
|
+
title={headerTitle}
|
|
70
|
+
/>
|
|
71
|
+
<LogBoxInspectorCodeFrame codeFrame={props.log.codeFrame} />
|
|
72
|
+
<LogBoxInspectorReactFrames log={props.log} />
|
|
73
|
+
<LogBoxInspectorStackFrames log={props.log} onRetry={props.onRetry} />
|
|
74
|
+
</ScrollView>
|
|
75
|
+
);
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
const styles = StyleSheet.create({
|
|
79
|
+
root: {
|
|
80
|
+
flex: 1,
|
|
81
|
+
backgroundColor: LogBoxStyle.getTextColor(),
|
|
82
|
+
},
|
|
83
|
+
scrollBody: {
|
|
84
|
+
backgroundColor: LogBoxStyle.getBackgroundColor(0.9),
|
|
85
|
+
flex: 1,
|
|
86
|
+
},
|
|
87
|
+
});
|