miaoda-expo-devkit 0.1.1-dev.development-build.5 → 0.1.1-dev.development-build.7
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/package.json +1 -1
- package/pnpm-patches/react-native@0.83.2.patch +232 -19
- package/pnpmfile.cjs +3 -1
package/package.json
CHANGED
|
@@ -1,20 +1,50 @@
|
|
|
1
|
+
diff --git a/Libraries/LogBox/Data/LogBoxData.js b/Libraries/LogBox/Data/LogBoxData.js
|
|
2
|
+
index 2ce92e0..56eb4f8 100644
|
|
3
|
+
--- a/Libraries/LogBox/Data/LogBoxData.js
|
|
4
|
+
+++ b/Libraries/LogBox/Data/LogBoxData.js
|
|
5
|
+
@@ -149,9 +149,17 @@ function appendNewLog(newLog: LogBoxLog) {
|
|
6
|
+
- // If the next log has the same category as the previous one
|
|
7
|
+
- // then roll it up into the last log in the list by incrementing
|
|
8
|
+
- // the count (similar to how Chrome does it).
|
|
9
|
+
+ // Only merge logs with the same severity. A fatal exception must retain
|
|
10
|
+
+ // its own stack and open the inspector even after a matching console error.
|
|
11
|
+
const lastLog = Array.from(logs).pop();
|
|
12
|
+
- if (lastLog && lastLog.category === newLog.category) {
|
|
13
|
+
+ if (
|
|
14
|
+
+ lastLog &&
|
|
15
|
+
+ lastLog.category === newLog.category &&
|
|
16
|
+
+ lastLog.level === newLog.level
|
|
17
|
+
+ ) {
|
|
18
|
+
lastLog.incrementCount();
|
|
19
|
+
- handleUpdate();
|
|
20
|
+
+ // A repeated uncaught exception must also reopen a hidden inspector.
|
|
21
|
+
+ if (newLog.level === 'fatal' && _selectedIndex < 0) {
|
|
22
|
+
+ setSelectedLog(logs.size - 1);
|
|
23
|
+
+ } else {
|
|
24
|
+
+ handleUpdate();
|
|
25
|
+
+ }
|
|
26
|
+
return;
|
|
27
|
+
}
|
|
1
28
|
diff --git a/Libraries/LogBox/UI/LogBoxInspector.js b/Libraries/LogBox/UI/LogBoxInspector.js
|
|
2
29
|
--- a/Libraries/LogBox/UI/LogBoxInspector.js
|
|
3
30
|
+++ b/Libraries/LogBox/UI/LogBoxInspector.js
|
|
4
|
-
@@ -8,6 +8,
|
|
31
|
+
@@ -8,6 +8,10 @@
|
|
5
32
|
* @format
|
|
6
33
|
*/
|
|
7
34
|
|
|
8
|
-
+import
|
|
35
|
+
+import type {CopyStatus} from '../Data/LogBoxCopy';
|
|
36
|
+
+
|
|
37
|
+
+import Alert from '../../Alert/Alert';
|
|
38
|
+
+import {createLogBoxCopyController} from '../Data/LogBoxCopy';
|
|
9
39
|
import Keyboard from '../../Components/Keyboard/Keyboard';
|
|
10
40
|
import View from '../../Components/View/View';
|
|
11
41
|
import StyleSheet from '../../StyleSheet/StyleSheet';
|
|
12
|
-
@@ -18,7 +
|
|
42
|
+
@@ -18,7 +22,97 @@
|
|
13
43
|
import LogBoxInspectorHeader from './LogBoxInspectorHeader';
|
|
14
44
|
import * as LogBoxStyle from './LogBoxStyle';
|
|
15
45
|
import * as React from 'react';
|
|
16
46
|
-import {useEffect} from 'react';
|
|
17
|
-
+import {useEffect, useState} from 'react';
|
|
47
|
+
+import {useEffect, useRef, useState} from 'react';
|
|
18
48
|
+
|
|
19
49
|
+const errorTitleMap = {
|
|
20
50
|
+ warn: '控制台警告',
|
|
@@ -108,22 +138,53 @@ diff --git a/Libraries/LogBox/UI/LogBoxInspector.js b/Libraries/LogBox/UI/LogBox
|
|
|
108
138
|
|
|
109
139
|
type Props = $ReadOnly<{
|
|
110
140
|
onDismiss: () => void,
|
|
111
|
-
@@ -32,6 +
|
|
141
|
+
@@ -32,6 +126,10 @@
|
|
112
142
|
export default function LogBoxInspector(props: Props): React.Node {
|
|
113
143
|
const {logs, selectedIndex} = props;
|
|
114
144
|
let log = logs[selectedIndex];
|
|
115
|
-
+ const [copyStatus, setCopyStatus] = useState<'idle'
|
|
116
|
-
+
|
|
117
|
-
+ );
|
|
145
|
+
+ const [copyStatus, setCopyStatus] = useState<CopyStatus>('idle');
|
|
146
|
+
+ const copyController = useRef(null);
|
|
147
|
+
+ const currentLog = useRef(log);
|
|
148
|
+
+ currentLog.current = log;
|
|
118
149
|
|
|
119
150
|
useEffect(() => {
|
|
120
151
|
if (log) {
|
|
121
|
-
@@ -55,8 +
|
|
152
|
+
@@ -55,8 +153,52 @@
|
|
122
153
|
Keyboard.dismiss();
|
|
123
154
|
}, []);
|
|
124
155
|
|
|
125
156
|
+ useEffect(() => {
|
|
126
157
|
+ setCopyStatus('idle');
|
|
158
|
+
+ const controller = createLogBoxCopyController(
|
|
159
|
+
+ status => {
|
|
160
|
+
+ if (currentLog.current === log) {
|
|
161
|
+
+ setCopyStatus(status);
|
|
162
|
+
+ }
|
|
163
|
+
+ },
|
|
164
|
+
+ message => {
|
|
165
|
+
+ if (currentLog.current === log) {
|
|
166
|
+
+ Alert.alert('复制失败', message);
|
|
167
|
+
+ }
|
|
168
|
+
+ },
|
|
169
|
+
+ reason => new Promise(resolve => {
|
|
170
|
+
+ if (currentLog.current !== log) {
|
|
171
|
+
+ resolve(false);
|
|
172
|
+
+ return;
|
|
173
|
+
+ }
|
|
174
|
+
+ Alert.alert('开发构建不适用', reason, [
|
|
175
|
+
+ {text: '取消', style: 'cancel', onPress: () => resolve(false)},
|
|
176
|
+
+ {text: '仍要复制错误', onPress: () => resolve(true)},
|
|
177
|
+
+ ], {cancelable: true, onDismiss: () => resolve(false)});
|
|
178
|
+
+ }),
|
|
179
|
+
+ () => currentLog.current === log,
|
|
180
|
+
+ );
|
|
181
|
+
+ copyController.current = controller;
|
|
182
|
+
+ return () => {
|
|
183
|
+
+ controller.cancel();
|
|
184
|
+
+ if (copyController.current === controller) {
|
|
185
|
+
+ copyController.current = null;
|
|
186
|
+
+ }
|
|
187
|
+
+ };
|
|
127
188
|
+ }, [log]);
|
|
128
189
|
+
|
|
129
190
|
function _handleRetry() {
|
|
@@ -132,16 +193,16 @@ diff --git a/Libraries/LogBox/UI/LogBoxInspector.js b/Libraries/LogBox/UI/LogBox
|
|
|
132
193
|
+
|
|
133
194
|
+ function _handleCopy() {
|
|
134
195
|
+ try {
|
|
135
|
-
+
|
|
136
|
-
+ setCopyStatus('copied');
|
|
196
|
+
+ void copyController.current?.copy(formatLogForClipboard(log));
|
|
137
197
|
+ } catch {
|
|
138
198
|
+ // 复制失败不能再次触发 LogBox,否则会遮盖原始错误。
|
|
139
|
-
+ setCopyStatus('failed');
|
|
199
|
+
+ setCopyStatus('copy-failed');
|
|
200
|
+
+ Alert.alert('复制失败', '无法整理错误内容,请重试。');
|
|
140
201
|
+ }
|
|
141
202
|
}
|
|
142
203
|
|
|
143
204
|
if (log == null) {
|
|
144
|
-
@@ -73,6 +
|
|
205
|
+
@@ -73,6 +215,8 @@
|
|
145
206
|
/>
|
|
146
207
|
<LogBoxInspectorBody log={log} onRetry={_handleRetry} />
|
|
147
208
|
<LogBoxInspectorFooter
|
|
@@ -201,11 +262,11 @@ diff --git a/Libraries/LogBox/UI/LogBoxInspectorCodeFrame.js b/Libraries/LogBox/
|
|
|
201
262
|
diff --git a/Libraries/LogBox/UI/LogBoxInspectorFooter.js b/Libraries/LogBox/UI/LogBoxInspectorFooter.js
|
|
202
263
|
--- a/Libraries/LogBox/UI/LogBoxInspectorFooter.js
|
|
203
264
|
+++ b/Libraries/LogBox/UI/LogBoxInspectorFooter.js
|
|
204
|
-
@@ -18,36 +18,
|
|
265
|
+
@@ -18,36 +18,58 @@
|
|
205
266
|
import * as React from 'react';
|
|
206
267
|
|
|
207
268
|
type Props = $ReadOnly<{
|
|
208
|
-
+ copyStatus: 'idle' | 'copied' | 'failed',
|
|
269
|
+
+ copyStatus: 'idle' | 'checking' | 'confirming' | 'copied' | 'check-failed' | 'copy-failed',
|
|
209
270
|
+ onCopy: () => void,
|
|
210
271
|
onDismiss: () => void,
|
|
211
272
|
onMinimize: () => void,
|
|
@@ -227,9 +288,15 @@ diff --git a/Libraries/LogBox/UI/LogBoxInspectorFooter.js b/Libraries/LogBox/UI/
|
|
|
227
288
|
+ const copyButtonText =
|
|
228
289
|
+ props.copyStatus === 'copied'
|
|
229
290
|
+ ? '已复制'
|
|
230
|
-
+ : props.copyStatus === '
|
|
231
|
-
+ ? '
|
|
232
|
-
+ : '
|
|
291
|
+
+ : props.copyStatus === 'checking'
|
|
292
|
+
+ ? '正在检查兼容性(最多 8 秒)'
|
|
293
|
+
+ : props.copyStatus === 'confirming'
|
|
294
|
+
+ ? '等待确认'
|
|
295
|
+
+ : props.copyStatus === 'check-failed'
|
|
296
|
+
+ ? '检查失败,点击重试'
|
|
297
|
+
+ : props.copyStatus === 'copy-failed'
|
|
298
|
+
+ ? '复制失败,点击重试'
|
|
299
|
+
+ : '复制错误给智能体修复';
|
|
233
300
|
|
|
234
301
|
return (
|
|
235
302
|
- <View style={styles.root}>
|
|
@@ -248,7 +315,7 @@ diff --git a/Libraries/LogBox/UI/LogBoxInspectorFooter.js b/Libraries/LogBox/UI/
|
|
|
248
315
|
+ <LogBoxInspectorFooterButton
|
|
249
316
|
+ id="logbox_footer_button_copy"
|
|
250
317
|
+ text={copyButtonText}
|
|
251
|
-
+ onPress={props.onCopy}
|
|
318
|
+
+ onPress={props.copyStatus === 'checking' || props.copyStatus === 'confirming' ? undefined : props.onCopy}
|
|
252
319
|
+ />
|
|
253
320
|
+ </View>
|
|
254
321
|
+ <View style={styles.root}>
|
|
@@ -382,3 +449,149 @@ diff --git a/Libraries/LogBox/UI/LogBoxInspectorReactFrames.js b/Libraries/LogBo
|
|
|
382
449
|
{getStackList().map((frame, index) => (
|
|
383
450
|
<View
|
|
384
451
|
// Unfortunately we don't have a unique identifier for stack traces.
|
|
452
|
+
diff --git a/Libraries/LogBox/Data/LogBoxCopy.js b/Libraries/LogBox/Data/LogBoxCopy.js
|
|
453
|
+
new file mode 100644
|
|
454
|
+
--- /dev/null
|
|
455
|
+
+++ b/Libraries/LogBox/Data/LogBoxCopy.js
|
|
456
|
+
@@ -0,0 +1,130 @@
|
|
457
|
+
+/**
|
|
458
|
+
+ * @flow strict-local
|
|
459
|
+
+ * @format
|
|
460
|
+
+ */
|
|
461
|
+
+
|
|
462
|
+
+export type CopyStatus =
|
|
463
|
+
+ | 'idle'
|
|
464
|
+
+ | 'checking'
|
|
465
|
+
+ | 'confirming'
|
|
466
|
+
+ | 'copied'
|
|
467
|
+
+ | 'check-failed'
|
|
468
|
+
+ | 'copy-failed';
|
|
469
|
+
+
|
|
470
|
+
+type CopyModule = {
|
|
471
|
+
+ checkCopyCompatibility: () => Promise<{status: string, reason?: string}>,
|
|
472
|
+
+ copyErrorToClipboard: (text: string) => Promise<void>,
|
|
473
|
+
+};
|
|
474
|
+
+
|
|
475
|
+
+function getCopyModule(): CopyModule {
|
|
476
|
+
+ // 延迟取桥接模块,避免 LogBox 初始化时引入 Expo 包或再次触发日志。
|
|
477
|
+
+ if (globalThis.expo == null) {
|
|
478
|
+
+ const registry = require('../../TurboModule/TurboModuleRegistry');
|
|
479
|
+
+ registry.get('ExpoModulesCore')?.installModules?.();
|
|
480
|
+
+ }
|
|
481
|
+
+ const module = globalThis.expo?.modules?.ExpoDevLauncher;
|
|
482
|
+
+ if (
|
|
483
|
+
+ typeof module?.checkCopyCompatibility !== 'function' ||
|
|
484
|
+
+ typeof module?.copyErrorToClipboard !== 'function'
|
|
485
|
+
+ ) {
|
|
486
|
+
+ throw new Error('请更新开发客户端后重试,当前客户端不支持复制兼容性检查。');
|
|
487
|
+
+ }
|
|
488
|
+
+ return module;
|
|
489
|
+
+}
|
|
490
|
+
+
|
|
491
|
+
+export function createLogBoxCopyController(
|
|
492
|
+
+ onStatus: (status: CopyStatus) => void,
|
|
493
|
+
+ onFailure: (message: string) => void,
|
|
494
|
+
+ confirmIncompatible: (reason: string) => Promise<boolean>,
|
|
495
|
+
+ isValid: () => boolean = () => true,
|
|
496
|
+
+): {copy: (text: string) => Promise<void>, cancel: () => void} {
|
|
497
|
+
+ let generation = 0;
|
|
498
|
+
+ let busy = false;
|
|
499
|
+
+ let stopWaiting: ?(() => void);
|
|
500
|
+
+ const stopped = {};
|
|
501
|
+
+
|
|
502
|
+
+ return {
|
|
503
|
+
+ cancel() {
|
|
504
|
+
+ // 页面退出或错误切换后,旧检查、确认框和写入回执均不能更新新页面。
|
|
505
|
+
+ generation += 1;
|
|
506
|
+
+ busy = false;
|
|
507
|
+
+ stopWaiting?.();
|
|
508
|
+
+ stopWaiting = null;
|
|
509
|
+
+ },
|
|
510
|
+
+ async copy(text: string): Promise<void> {
|
|
511
|
+
+ // 同步加锁,覆盖 React 尚未提交 checking 状态时的连续点击。
|
|
512
|
+
+ if (busy) {
|
|
513
|
+
+ return;
|
|
514
|
+
+ }
|
|
515
|
+
+ busy = true;
|
|
516
|
+
+ const request = ++generation;
|
|
517
|
+
+ const current = () => generation === request && isValid();
|
|
518
|
+
+ let timer;
|
|
519
|
+
+ let writing = false;
|
|
520
|
+
+ const cancelled = new Promise(resolve => {
|
|
521
|
+
+ stopWaiting = () => resolve(stopped);
|
|
522
|
+
+ });
|
|
523
|
+
+ onStatus('checking');
|
|
524
|
+
+ try {
|
|
525
|
+
+ const module = getCopyModule();
|
|
526
|
+
+ const timeout = new Promise((_, reject) => {
|
|
527
|
+
+ // 原生负责取消网络;JS 看门狗兼容异常桥接或迟到回调。
|
|
528
|
+
+ timer = setTimeout(
|
|
529
|
+
+ () => reject(new Error('兼容性检查超过 8 秒,请检查网络后重试。')),
|
|
530
|
+
+ 8000,
|
|
531
|
+
+ );
|
|
532
|
+
+ });
|
|
533
|
+
+ const result = await Promise.race([
|
|
534
|
+
+ module.checkCopyCompatibility(),
|
|
535
|
+
+ timeout,
|
|
536
|
+
+ cancelled,
|
|
537
|
+
+ ]);
|
|
538
|
+
+ clearTimeout(timer);
|
|
539
|
+
+ if (!current() || result === stopped) {
|
|
540
|
+
+ return;
|
|
541
|
+
+ }
|
|
542
|
+
+ if (result?.status === 'incompatible') {
|
|
543
|
+
+ onStatus('confirming');
|
|
544
|
+
+ const approved = await Promise.race([
|
|
545
|
+
+ confirmIncompatible(result.reason || '当前开发构建与项目原生能力不兼容。'),
|
|
546
|
+
+ cancelled,
|
|
547
|
+
+ ]);
|
|
548
|
+
+ if (!current() || approved !== true) {
|
|
549
|
+
+ if (current()) {
|
|
550
|
+
+ onStatus('idle');
|
|
551
|
+
+ }
|
|
552
|
+
+ return;
|
|
553
|
+
+ }
|
|
554
|
+
+ } else if (result?.status !== 'compatible') {
|
|
555
|
+
+ throw new Error(result?.reason || '无法完成兼容性检查,请检查网络后重试。');
|
|
556
|
+
+ }
|
|
557
|
+
+ if (!current()) {
|
|
558
|
+
+ return;
|
|
559
|
+
+ }
|
|
560
|
+
+ writing = true;
|
|
561
|
+
+ // 点击时传入的文本已固定,且仅在真实原生写入完成后显示成功。
|
|
562
|
+
+ await module.copyErrorToClipboard(text);
|
|
563
|
+
+ if (current()) {
|
|
564
|
+
+ onStatus('copied');
|
|
565
|
+
+ }
|
|
566
|
+
+ } catch (error) {
|
|
567
|
+
+ if (current()) {
|
|
568
|
+
+ onStatus(writing ? 'copy-failed' : 'check-failed');
|
|
569
|
+
+ onFailure(
|
|
570
|
+
+ writing
|
|
571
|
+
+ ? '剪贴板写入失败,请重试。'
|
|
572
|
+
+ : error instanceof Error
|
|
573
|
+
+ ? error.message
|
|
574
|
+
+ : '兼容性检查失败,请重试。',
|
|
575
|
+
+ );
|
|
576
|
+
+ }
|
|
577
|
+
+ } finally {
|
|
578
|
+
+ clearTimeout(timer);
|
|
579
|
+
+ if (current()) {
|
|
580
|
+
+ busy = false;
|
|
581
|
+
+ stopWaiting = null;
|
|
582
|
+
+ }
|
|
583
|
+
+ }
|
|
584
|
+
+ },
|
|
585
|
+
+ };
|
|
586
|
+
+}
|
|
587
|
+
diff --git a/Libraries/LogBox/UI/LogBoxInspectorFooterButton.js b/Libraries/LogBox/UI/LogBoxInspectorFooterButton.js
|
|
588
|
+
--- a/Libraries/LogBox/UI/LogBoxInspectorFooterButton.js
|
|
589
|
+
+++ b/Libraries/LogBox/UI/LogBoxInspectorFooterButton.js
|
|
590
|
+
@@ -18,6 +18,6 @@
|
|
591
|
+
|
|
592
|
+
type ButtonProps = $ReadOnly<{
|
|
593
|
+
id: string,
|
|
594
|
+
- onPress: () => void,
|
|
595
|
+
+ onPress?: () => void,
|
|
596
|
+
text: string,
|
|
597
|
+
}>;
|
package/pnpmfile.cjs
CHANGED
|
@@ -73,7 +73,9 @@ const managedPatches = {
|
|
|
73
73
|
},
|
|
74
74
|
'react-native@0.83.2': {
|
|
75
75
|
filename: 'react-native@0.83.2.patch',
|
|
76
|
-
legacyHashes: new Set(
|
|
76
|
+
legacyHashes: new Set([
|
|
77
|
+
'4416d7456eece4b818b0798b04cc71a4f3273a70cf32458749c699d05c779729',
|
|
78
|
+
]),
|
|
77
79
|
},
|
|
78
80
|
'react-native-worklets@0.7.4': {
|
|
79
81
|
filename: 'react-native-worklets@0.7.4.patch',
|