miaoda-expo-devkit 0.1.1-dev.development-build.6 → 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 +205 -19
- package/pnpmfile.cjs +3 -1
package/package.json
CHANGED
|
@@ -28,20 +28,23 @@ index 2ce92e0..56eb4f8 100644
|
|
|
28
28
|
diff --git a/Libraries/LogBox/UI/LogBoxInspector.js b/Libraries/LogBox/UI/LogBoxInspector.js
|
|
29
29
|
--- a/Libraries/LogBox/UI/LogBoxInspector.js
|
|
30
30
|
+++ b/Libraries/LogBox/UI/LogBoxInspector.js
|
|
31
|
-
@@ -8,6 +8,
|
|
31
|
+
@@ -8,6 +8,10 @@
|
|
32
32
|
* @format
|
|
33
33
|
*/
|
|
34
34
|
|
|
35
|
-
+import
|
|
35
|
+
+import type {CopyStatus} from '../Data/LogBoxCopy';
|
|
36
|
+
+
|
|
37
|
+
+import Alert from '../../Alert/Alert';
|
|
38
|
+
+import {createLogBoxCopyController} from '../Data/LogBoxCopy';
|
|
36
39
|
import Keyboard from '../../Components/Keyboard/Keyboard';
|
|
37
40
|
import View from '../../Components/View/View';
|
|
38
41
|
import StyleSheet from '../../StyleSheet/StyleSheet';
|
|
39
|
-
@@ -18,7 +
|
|
42
|
+
@@ -18,7 +22,97 @@
|
|
40
43
|
import LogBoxInspectorHeader from './LogBoxInspectorHeader';
|
|
41
44
|
import * as LogBoxStyle from './LogBoxStyle';
|
|
42
45
|
import * as React from 'react';
|
|
43
46
|
-import {useEffect} from 'react';
|
|
44
|
-
+import {useEffect, useState} from 'react';
|
|
47
|
+
+import {useEffect, useRef, useState} from 'react';
|
|
45
48
|
+
|
|
46
49
|
+const errorTitleMap = {
|
|
47
50
|
+ warn: '控制台警告',
|
|
@@ -135,22 +138,53 @@ diff --git a/Libraries/LogBox/UI/LogBoxInspector.js b/Libraries/LogBox/UI/LogBox
|
|
|
135
138
|
|
|
136
139
|
type Props = $ReadOnly<{
|
|
137
140
|
onDismiss: () => void,
|
|
138
|
-
@@ -32,6 +
|
|
141
|
+
@@ -32,6 +126,10 @@
|
|
139
142
|
export default function LogBoxInspector(props: Props): React.Node {
|
|
140
143
|
const {logs, selectedIndex} = props;
|
|
141
144
|
let log = logs[selectedIndex];
|
|
142
|
-
+ const [copyStatus, setCopyStatus] = useState<'idle'
|
|
143
|
-
+
|
|
144
|
-
+ );
|
|
145
|
+
+ const [copyStatus, setCopyStatus] = useState<CopyStatus>('idle');
|
|
146
|
+
+ const copyController = useRef(null);
|
|
147
|
+
+ const currentLog = useRef(log);
|
|
148
|
+
+ currentLog.current = log;
|
|
145
149
|
|
|
146
150
|
useEffect(() => {
|
|
147
151
|
if (log) {
|
|
148
|
-
@@ -55,8 +
|
|
152
|
+
@@ -55,8 +153,52 @@
|
|
149
153
|
Keyboard.dismiss();
|
|
150
154
|
}, []);
|
|
151
155
|
|
|
152
156
|
+ useEffect(() => {
|
|
153
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
|
+
+ };
|
|
154
188
|
+ }, [log]);
|
|
155
189
|
+
|
|
156
190
|
function _handleRetry() {
|
|
@@ -159,16 +193,16 @@ diff --git a/Libraries/LogBox/UI/LogBoxInspector.js b/Libraries/LogBox/UI/LogBox
|
|
|
159
193
|
+
|
|
160
194
|
+ function _handleCopy() {
|
|
161
195
|
+ try {
|
|
162
|
-
+
|
|
163
|
-
+ setCopyStatus('copied');
|
|
196
|
+
+ void copyController.current?.copy(formatLogForClipboard(log));
|
|
164
197
|
+ } catch {
|
|
165
198
|
+ // 复制失败不能再次触发 LogBox,否则会遮盖原始错误。
|
|
166
|
-
+ setCopyStatus('failed');
|
|
199
|
+
+ setCopyStatus('copy-failed');
|
|
200
|
+
+ Alert.alert('复制失败', '无法整理错误内容,请重试。');
|
|
167
201
|
+ }
|
|
168
202
|
}
|
|
169
203
|
|
|
170
204
|
if (log == null) {
|
|
171
|
-
@@ -73,6 +
|
|
205
|
+
@@ -73,6 +215,8 @@
|
|
172
206
|
/>
|
|
173
207
|
<LogBoxInspectorBody log={log} onRetry={_handleRetry} />
|
|
174
208
|
<LogBoxInspectorFooter
|
|
@@ -228,11 +262,11 @@ diff --git a/Libraries/LogBox/UI/LogBoxInspectorCodeFrame.js b/Libraries/LogBox/
|
|
|
228
262
|
diff --git a/Libraries/LogBox/UI/LogBoxInspectorFooter.js b/Libraries/LogBox/UI/LogBoxInspectorFooter.js
|
|
229
263
|
--- a/Libraries/LogBox/UI/LogBoxInspectorFooter.js
|
|
230
264
|
+++ b/Libraries/LogBox/UI/LogBoxInspectorFooter.js
|
|
231
|
-
@@ -18,36 +18,
|
|
265
|
+
@@ -18,36 +18,58 @@
|
|
232
266
|
import * as React from 'react';
|
|
233
267
|
|
|
234
268
|
type Props = $ReadOnly<{
|
|
235
|
-
+ copyStatus: 'idle' | 'copied' | 'failed',
|
|
269
|
+
+ copyStatus: 'idle' | 'checking' | 'confirming' | 'copied' | 'check-failed' | 'copy-failed',
|
|
236
270
|
+ onCopy: () => void,
|
|
237
271
|
onDismiss: () => void,
|
|
238
272
|
onMinimize: () => void,
|
|
@@ -254,9 +288,15 @@ diff --git a/Libraries/LogBox/UI/LogBoxInspectorFooter.js b/Libraries/LogBox/UI/
|
|
|
254
288
|
+ const copyButtonText =
|
|
255
289
|
+ props.copyStatus === 'copied'
|
|
256
290
|
+ ? '已复制'
|
|
257
|
-
+ : props.copyStatus === '
|
|
258
|
-
+ ? '
|
|
259
|
-
+ : '
|
|
291
|
+
+ : props.copyStatus === 'checking'
|
|
292
|
+
+ ? '正在检查兼容性(最多 8 秒)'
|
|
293
|
+
+ : props.copyStatus === 'confirming'
|
|
294
|
+
+ ? '等待确认'
|
|
295
|
+
+ : props.copyStatus === 'check-failed'
|
|
296
|
+
+ ? '检查失败,点击重试'
|
|
297
|
+
+ : props.copyStatus === 'copy-failed'
|
|
298
|
+
+ ? '复制失败,点击重试'
|
|
299
|
+
+ : '复制错误给智能体修复';
|
|
260
300
|
|
|
261
301
|
return (
|
|
262
302
|
- <View style={styles.root}>
|
|
@@ -275,7 +315,7 @@ diff --git a/Libraries/LogBox/UI/LogBoxInspectorFooter.js b/Libraries/LogBox/UI/
|
|
|
275
315
|
+ <LogBoxInspectorFooterButton
|
|
276
316
|
+ id="logbox_footer_button_copy"
|
|
277
317
|
+ text={copyButtonText}
|
|
278
|
-
+ onPress={props.onCopy}
|
|
318
|
+
+ onPress={props.copyStatus === 'checking' || props.copyStatus === 'confirming' ? undefined : props.onCopy}
|
|
279
319
|
+ />
|
|
280
320
|
+ </View>
|
|
281
321
|
+ <View style={styles.root}>
|
|
@@ -409,3 +449,149 @@ diff --git a/Libraries/LogBox/UI/LogBoxInspectorReactFrames.js b/Libraries/LogBo
|
|
|
409
449
|
{getStackList().map((frame, index) => (
|
|
410
450
|
<View
|
|
411
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',
|