miaoda-expo-devkit 0.1.1-dev.development-build.7 → 0.1.1-dev.development-build.9
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/README.md +12 -3
- package/package.json +19 -19
- package/pnpm-patches/expo@55.0.6.patch +789 -25
- package/pnpm-patches/metro-runtime@0.83.3.patch +351 -3
- package/pnpm-patches/react-native@0.83.2.patch +291 -205
- package/pnpmfile.cjs +9 -0
|
@@ -1,8 +1,156 @@
|
|
|
1
|
+
diff --git a/Libraries/LogBox/Data/LogBoxCopy.js b/Libraries/LogBox/Data/LogBoxCopy.js
|
|
2
|
+
new file mode 100644
|
|
3
|
+
index 0000000..9b01194
|
|
4
|
+
--- /dev/null
|
|
5
|
+
+++ b/Libraries/LogBox/Data/LogBoxCopy.js
|
|
6
|
+
@@ -0,0 +1,139 @@
|
|
7
|
+
+/**
|
|
8
|
+
+ * @flow strict-local
|
|
9
|
+
+ * @format
|
|
10
|
+
+ */
|
|
11
|
+
+
|
|
12
|
+
+export type CopyStatus =
|
|
13
|
+
+ | 'idle'
|
|
14
|
+
+ | 'checking'
|
|
15
|
+
+ | 'confirming'
|
|
16
|
+
+ | 'copied'
|
|
17
|
+
+ | 'check-failed'
|
|
18
|
+
+ | 'copy-failed';
|
|
19
|
+
+
|
|
20
|
+
+type CopyModule = {
|
|
21
|
+
+ checkCopyCompatibility: () => Promise<{status: string, reason?: string, reasons?: string[]}>,
|
|
22
|
+
+ copyErrorToClipboard: (text: string) => Promise<void>,
|
|
23
|
+
+};
|
|
24
|
+
+
|
|
25
|
+
+function getCopyModule(): CopyModule {
|
|
26
|
+
+ // 延迟取桥接模块,避免 LogBox 初始化时引入 Expo 包或再次触发日志。
|
|
27
|
+
+ if (globalThis.expo == null) {
|
|
28
|
+
+ const registry = require('../../TurboModule/TurboModuleRegistry');
|
|
29
|
+
+ registry.get('ExpoModulesCore')?.installModules?.();
|
|
30
|
+
+ }
|
|
31
|
+
+ const module = globalThis.expo?.modules?.ExpoDevLauncher;
|
|
32
|
+
+ if (
|
|
33
|
+
+ typeof module?.checkCopyCompatibility !== 'function' ||
|
|
34
|
+
+ typeof module?.copyErrorToClipboard !== 'function'
|
|
35
|
+
+ ) {
|
|
36
|
+
+ throw new Error('请更新开发客户端后重试,当前客户端不支持复制兼容性检查。');
|
|
37
|
+
+ }
|
|
38
|
+
+ return module;
|
|
39
|
+
+}
|
|
40
|
+
+
|
|
41
|
+
+// 失败阶段:'check' 为兼容性检查失败(统一弹窗由 UI 渲染),'write' 为
|
|
42
|
+
+// 剪贴板写入失败(沿用「复制失败」提示)。
|
|
43
|
+
+export type CopyFailurePhase = 'check' | 'write';
|
|
44
|
+
+
|
|
45
|
+
+export function createLogBoxCopyController(
|
|
46
|
+
+ onStatus: (status: CopyStatus) => void,
|
|
47
|
+
+ onFailure: (phase: CopyFailurePhase, message: string) => void,
|
|
48
|
+
+ confirmIncompatible: (reason: string) => Promise<boolean>,
|
|
49
|
+
+ isValid: () => boolean = () => true,
|
|
50
|
+
+): {copy: (text: string) => Promise<void>, cancel: () => void} {
|
|
51
|
+
+ let generation = 0;
|
|
52
|
+
+ let busy = false;
|
|
53
|
+
+ let stopWaiting: ?(() => void);
|
|
54
|
+
+ const stopped = {};
|
|
55
|
+
+
|
|
56
|
+
+ return {
|
|
57
|
+
+ cancel() {
|
|
58
|
+
+ // 页面退出或错误切换后,旧检查、确认框和写入回执均不能更新新页面。
|
|
59
|
+
+ generation += 1;
|
|
60
|
+
+ busy = false;
|
|
61
|
+
+ stopWaiting?.();
|
|
62
|
+
+ stopWaiting = null;
|
|
63
|
+
+ },
|
|
64
|
+
+ async copy(text: string): Promise<void> {
|
|
65
|
+
+ // 同步加锁,覆盖 React 尚未提交 checking 状态时的连续点击。
|
|
66
|
+
+ if (busy) {
|
|
67
|
+
+ return;
|
|
68
|
+
+ }
|
|
69
|
+
+ busy = true;
|
|
70
|
+
+ const request = ++generation;
|
|
71
|
+
+ const current = () => generation === request && isValid();
|
|
72
|
+
+ let timer;
|
|
73
|
+
+ let writing = false;
|
|
74
|
+
+ const cancelled = new Promise(resolve => {
|
|
75
|
+
+ stopWaiting = () => resolve(stopped);
|
|
76
|
+
+ });
|
|
77
|
+
+ onStatus('checking');
|
|
78
|
+
+ try {
|
|
79
|
+
+ const module = getCopyModule();
|
|
80
|
+
+ const timeout = new Promise((_, reject) => {
|
|
81
|
+
+ // 原生负责取消网络;JS 看门狗兼容异常桥接或迟到回调。
|
|
82
|
+
+ timer = setTimeout(
|
|
83
|
+
+ () => reject(new Error('兼容性检查超过 8 秒,请检查网络后重试。')),
|
|
84
|
+
+ 8000,
|
|
85
|
+
+ );
|
|
86
|
+
+ });
|
|
87
|
+
+ const result = await Promise.race([
|
|
88
|
+
+ module.checkCopyCompatibility(),
|
|
89
|
+
+ timeout,
|
|
90
|
+
+ cancelled,
|
|
91
|
+
+ ]);
|
|
92
|
+
+ clearTimeout(timer);
|
|
93
|
+
+ if (!current() || result === stopped) {
|
|
94
|
+
+ return;
|
|
95
|
+
+ }
|
|
96
|
+
+ if (result?.status === 'incompatible') {
|
|
97
|
+
+ onStatus('confirming');
|
|
98
|
+
+ // 结构化原因列表优先(新客户端),旧客户端回退用 reason。
|
|
99
|
+
+ const reason = (Array.isArray(result.reasons)
|
|
100
|
+
+ ? result.reasons.join('\n')
|
|
101
|
+
+ : result.reason) || '当前开发构建与项目原生能力不兼容。';
|
|
102
|
+
+ const approved = await Promise.race([
|
|
103
|
+
+ confirmIncompatible(reason),
|
|
104
|
+
+ cancelled,
|
|
105
|
+
+ ]);
|
|
106
|
+
+ if (!current() || approved !== true) {
|
|
107
|
+
+ if (current()) {
|
|
108
|
+
+ onStatus('idle');
|
|
109
|
+
+ }
|
|
110
|
+
+ return;
|
|
111
|
+
+ }
|
|
112
|
+
+ } else if (result?.status !== 'compatible') {
|
|
113
|
+
+ throw new Error(result?.reason || '无法完成兼容性检查,请检查网络后重试。');
|
|
114
|
+
+ }
|
|
115
|
+
+ if (!current()) {
|
|
116
|
+
+ return;
|
|
117
|
+
+ }
|
|
118
|
+
+ writing = true;
|
|
119
|
+
+ // 点击时传入的文本已固定,且仅在真实原生写入完成后显示成功。
|
|
120
|
+
+ await module.copyErrorToClipboard(text);
|
|
121
|
+
+ if (current()) {
|
|
122
|
+
+ onStatus('copied');
|
|
123
|
+
+ }
|
|
124
|
+
+ } catch (error) {
|
|
125
|
+
+ if (current()) {
|
|
126
|
+
+ onStatus(writing ? 'copy-failed' : 'check-failed');
|
|
127
|
+
+ onFailure(
|
|
128
|
+
+ writing ? 'write' : 'check',
|
|
129
|
+
+ writing
|
|
130
|
+
+ ? '剪贴板写入失败,请重试。'
|
|
131
|
+
+ : error instanceof Error
|
|
132
|
+
+ ? error.message
|
|
133
|
+
+ : '兼容性检查失败,请重试。',
|
|
134
|
+
+ );
|
|
135
|
+
+ }
|
|
136
|
+
+ } finally {
|
|
137
|
+
+ clearTimeout(timer);
|
|
138
|
+
+ if (current()) {
|
|
139
|
+
+ busy = false;
|
|
140
|
+
+ stopWaiting = null;
|
|
141
|
+
+ }
|
|
142
|
+
+ }
|
|
143
|
+
+ },
|
|
144
|
+
+ };
|
|
145
|
+
+}
|
|
1
146
|
diff --git a/Libraries/LogBox/Data/LogBoxData.js b/Libraries/LogBox/Data/LogBoxData.js
|
|
2
147
|
index 2ce92e0..56eb4f8 100644
|
|
3
148
|
--- a/Libraries/LogBox/Data/LogBoxData.js
|
|
4
149
|
+++ b/Libraries/LogBox/Data/LogBoxData.js
|
|
5
|
-
@@ -
|
|
150
|
+
@@ -146,13 +146,21 @@ function appendNewLog(newLog: LogBoxLog) {
|
|
151
|
+
return;
|
|
152
|
+
}
|
|
153
|
+
|
|
6
154
|
- // If the next log has the same category as the previous one
|
|
7
155
|
- // then roll it up into the last log in the list by incrementing
|
|
8
156
|
- // the count (similar to how Chrome does it).
|
|
@@ -25,10 +173,46 @@ index 2ce92e0..56eb4f8 100644
|
|
|
25
173
|
+ }
|
|
26
174
|
return;
|
|
27
175
|
}
|
|
176
|
+
|
|
177
|
+
diff --git a/Libraries/LogBox/Data/LogBoxPromptCopy.js b/Libraries/LogBox/Data/LogBoxPromptCopy.js
|
|
178
|
+
new file mode 100644
|
|
179
|
+
index 0000000..ceab0e7
|
|
180
|
+
--- /dev/null
|
|
181
|
+
+++ b/Libraries/LogBox/Data/LogBoxPromptCopy.js
|
|
182
|
+
@@ -0,0 +1,28 @@
|
|
183
|
+
+/**
|
|
184
|
+
+ * Development Build 提示文案的唯一事实源(react-native 补丁 JS 侧,LogBox 复制链路)。
|
|
185
|
+
+ *
|
|
186
|
+
+ * 与 iOS 的 DevLauncherPromptCopy.swift、Android 的 DevLauncherPromptCopy.kt、
|
|
187
|
+
+ * expo 补丁的 miaodaPromptCopy.ts 逐字对应,由 devkit 的文案一致性测试
|
|
188
|
+
+ * (promptCopyConsistency.test.ts)锁定;修改任何一端必须同步其余三端。
|
|
189
|
+
+ *
|
|
190
|
+
+ * @flow strict-local
|
|
191
|
+
+ * @format
|
|
192
|
+
+ */
|
|
193
|
+
+
|
|
194
|
+
+export const LOGBOX_PROMPT_COPY = {
|
|
195
|
+
+ // 能力问题(复制错误前确认弹窗)。
|
|
196
|
+
+ incompatibleTitle: '当前开发构建能力不完整',
|
|
197
|
+
+ incompatibleBody:
|
|
198
|
+
+ '当前开发构建的原生能力与项目不匹配,继续使用可能导致应用无法运行。建议重新构建开发客户端。',
|
|
199
|
+
+ unknownTitle: '无法确认当前开发构建是否适用',
|
|
200
|
+
+ unknownBody:
|
|
201
|
+
+ '暂时无法完成原生能力检查,继续使用可能导致应用无法运行。建议检查网络后重新进入,或重新构建开发客户端。',
|
|
202
|
+
+
|
|
203
|
+
+ // 通用按钮。
|
|
204
|
+
+ cancelButtonTitle: '取消',
|
|
205
|
+
+ copyRetryButtonTitle: '重试',
|
|
206
|
+
+
|
|
207
|
+
+ // 复制确认。
|
|
208
|
+
+ copyConfirmQuestion: '仍要复制错误给智能体修复吗?',
|
|
209
|
+
+ copyConfirmButtonTitle: '仍要复制错误',
|
|
210
|
+
+};
|
|
28
211
|
diff --git a/Libraries/LogBox/UI/LogBoxInspector.js b/Libraries/LogBox/UI/LogBoxInspector.js
|
|
212
|
+
index be889b0..854c1cf 100644
|
|
29
213
|
--- a/Libraries/LogBox/UI/LogBoxInspector.js
|
|
30
214
|
+++ b/Libraries/LogBox/UI/LogBoxInspector.js
|
|
31
|
-
@@ -8,6 +8,
|
|
215
|
+
@@ -8,6 +8,11 @@
|
|
32
216
|
* @format
|
|
33
217
|
*/
|
|
34
218
|
|
|
@@ -36,10 +220,11 @@ diff --git a/Libraries/LogBox/UI/LogBoxInspector.js b/Libraries/LogBox/UI/LogBox
|
|
|
36
220
|
+
|
|
37
221
|
+import Alert from '../../Alert/Alert';
|
|
38
222
|
+import {createLogBoxCopyController} from '../Data/LogBoxCopy';
|
|
223
|
+
+import {LOGBOX_PROMPT_COPY} from '../Data/LogBoxPromptCopy';
|
|
39
224
|
import Keyboard from '../../Components/Keyboard/Keyboard';
|
|
40
225
|
import View from '../../Components/View/View';
|
|
41
226
|
import StyleSheet from '../../StyleSheet/StyleSheet';
|
|
42
|
-
@@ -18,7 +
|
|
227
|
+
@@ -18,7 +23,97 @@ import LogBoxInspectorFooter from './LogBoxInspectorFooter';
|
|
43
228
|
import LogBoxInspectorHeader from './LogBoxInspectorHeader';
|
|
44
229
|
import * as LogBoxStyle from './LogBoxStyle';
|
|
45
230
|
import * as React from 'react';
|
|
@@ -138,7 +323,7 @@ diff --git a/Libraries/LogBox/UI/LogBoxInspector.js b/Libraries/LogBox/UI/LogBox
|
|
|
138
323
|
|
|
139
324
|
type Props = $ReadOnly<{
|
|
140
325
|
onDismiss: () => void,
|
|
141
|
-
@@ -32,6 +
|
|
326
|
+
@@ -32,6 +127,10 @@ type Props = $ReadOnly<{
|
|
142
327
|
export default function LogBoxInspector(props: Props): React.Node {
|
|
143
328
|
const {logs, selectedIndex} = props;
|
|
144
329
|
let log = logs[selectedIndex];
|
|
@@ -149,35 +334,66 @@ diff --git a/Libraries/LogBox/UI/LogBoxInspector.js b/Libraries/LogBox/UI/LogBox
|
|
|
149
334
|
|
|
150
335
|
useEffect(() => {
|
|
151
336
|
if (log) {
|
|
152
|
-
@@ -55,
|
|
337
|
+
@@ -55,10 +154,85 @@ export default function LogBoxInspector(props: Props): React.Node {
|
|
153
338
|
Keyboard.dismiss();
|
|
154
339
|
}, []);
|
|
155
340
|
|
|
156
341
|
+ useEffect(() => {
|
|
157
342
|
+ setCopyStatus('idle');
|
|
343
|
+
+ // 弹窗「重试」需要重新发起复制;controller 在下方才创建,先用间接引用。
|
|
344
|
+
+ let controllerRef: {copy: (text: string) => Promise<void>, cancel: () => void} | null = null;
|
|
158
345
|
+ const controller = createLogBoxCopyController(
|
|
159
346
|
+ status => {
|
|
160
347
|
+ if (currentLog.current === log) {
|
|
161
348
|
+ setCopyStatus(status);
|
|
162
349
|
+ }
|
|
163
350
|
+ },
|
|
164
|
-
+ message => {
|
|
165
|
-
+ if (currentLog.current
|
|
351
|
+
+ (phase, message) => {
|
|
352
|
+
+ if (currentLog.current !== log) {
|
|
353
|
+
+ return;
|
|
354
|
+
+ }
|
|
355
|
+
+ if (phase === 'write') {
|
|
166
356
|
+ Alert.alert('复制失败', message);
|
|
357
|
+
+ return;
|
|
167
358
|
+ }
|
|
359
|
+
+ // 检查失败(unknown):统一标题/正文 + 重试/取消,不再透传零散 reason。
|
|
360
|
+
+ Alert.alert(
|
|
361
|
+
+ LOGBOX_PROMPT_COPY.unknownTitle,
|
|
362
|
+
+ LOGBOX_PROMPT_COPY.unknownBody,
|
|
363
|
+
+ [
|
|
364
|
+
+ {text: LOGBOX_PROMPT_COPY.cancelButtonTitle, style: 'cancel', onPress: () => {}},
|
|
365
|
+
+ {
|
|
366
|
+
+ text: LOGBOX_PROMPT_COPY.copyRetryButtonTitle,
|
|
367
|
+
+ onPress: () => {
|
|
368
|
+
+ if (currentLog.current === log) {
|
|
369
|
+
+ void controllerRef?.copy(formatLogForClipboard(log));
|
|
370
|
+
+ }
|
|
371
|
+
+ },
|
|
372
|
+
+ },
|
|
373
|
+
+ ],
|
|
374
|
+
+ {cancelable: true}
|
|
375
|
+
+ );
|
|
168
376
|
+ },
|
|
169
377
|
+ reason => new Promise(resolve => {
|
|
170
378
|
+ if (currentLog.current !== log) {
|
|
171
379
|
+ resolve(false);
|
|
172
380
|
+ return;
|
|
173
381
|
+ }
|
|
174
|
-
+ Alert.alert(
|
|
175
|
-
+
|
|
176
|
-
+ {
|
|
177
|
-
+
|
|
382
|
+
+ Alert.alert(
|
|
383
|
+
+ LOGBOX_PROMPT_COPY.incompatibleTitle,
|
|
384
|
+
+ `${LOGBOX_PROMPT_COPY.incompatibleBody}${
|
|
385
|
+
+ reason ? '\n' + reason : ''
|
|
386
|
+
+ }${LOGBOX_PROMPT_COPY.copyConfirmQuestion}`,
|
|
387
|
+
+ [
|
|
388
|
+
+ {text: LOGBOX_PROMPT_COPY.cancelButtonTitle, style: 'cancel', onPress: () => resolve(false)},
|
|
389
|
+
+ {text: LOGBOX_PROMPT_COPY.copyConfirmButtonTitle, onPress: () => resolve(true)},
|
|
390
|
+
+ ],
|
|
391
|
+
+ {cancelable: true, onDismiss: () => resolve(false)}
|
|
392
|
+
+ );
|
|
178
393
|
+ }),
|
|
179
394
|
+ () => currentLog.current === log,
|
|
180
395
|
+ );
|
|
396
|
+
+ controllerRef = controller;
|
|
181
397
|
+ copyController.current = controller;
|
|
182
398
|
+ return () => {
|
|
183
399
|
+ controller.cancel();
|
|
@@ -189,8 +405,8 @@ diff --git a/Libraries/LogBox/UI/LogBoxInspector.js b/Libraries/LogBox/UI/LogBox
|
|
|
189
405
|
+
|
|
190
406
|
function _handleRetry() {
|
|
191
407
|
LogBoxData.retrySymbolicateLogNow(log);
|
|
192
|
-
|
|
193
|
-
|
|
408
|
+
}
|
|
409
|
+
|
|
194
410
|
+ function _handleCopy() {
|
|
195
411
|
+ try {
|
|
196
412
|
+ void copyController.current?.copy(formatLogForClipboard(log));
|
|
@@ -199,10 +415,12 @@ diff --git a/Libraries/LogBox/UI/LogBoxInspector.js b/Libraries/LogBox/UI/LogBox
|
|
|
199
415
|
+ setCopyStatus('copy-failed');
|
|
200
416
|
+ Alert.alert('复制失败', '无法整理错误内容,请重试。');
|
|
201
417
|
+ }
|
|
202
|
-
|
|
203
|
-
|
|
418
|
+
+ }
|
|
419
|
+
+
|
|
204
420
|
if (log == null) {
|
|
205
|
-
|
|
421
|
+
return null;
|
|
422
|
+
}
|
|
423
|
+
@@ -73,6 +247,8 @@ export default function LogBoxInspector(props: Props): React.Node {
|
|
206
424
|
/>
|
|
207
425
|
<LogBoxInspectorBody log={log} onRetry={_handleRetry} />
|
|
208
426
|
<LogBoxInspectorFooter
|
|
@@ -212,9 +430,10 @@ diff --git a/Libraries/LogBox/UI/LogBoxInspector.js b/Libraries/LogBox/UI/LogBox
|
|
|
212
430
|
onMinimize={props.onMinimize}
|
|
213
431
|
level={log.level}
|
|
214
432
|
diff --git a/Libraries/LogBox/UI/LogBoxInspectorBody.js b/Libraries/LogBox/UI/LogBoxInspectorBody.js
|
|
433
|
+
index f9059fa..c1c8f02 100644
|
|
215
434
|
--- a/Libraries/LogBox/UI/LogBoxInspectorBody.js
|
|
216
435
|
+++ b/Libraries/LogBox/UI/LogBoxInspectorBody.js
|
|
217
|
-
@@ -20,11 +20,11 @@
|
|
436
|
+
@@ -20,11 +20,11 @@ import * as React from 'react';
|
|
218
437
|
import {useEffect, useState} from 'react';
|
|
219
438
|
|
|
220
439
|
const headerTitleMap = {
|
|
@@ -231,7 +450,7 @@ diff --git a/Libraries/LogBox/UI/LogBoxInspectorBody.js b/Libraries/LogBox/UI/Lo
|
|
|
231
450
|
};
|
|
232
451
|
|
|
233
452
|
export default function LogBoxInspectorBody(props: {
|
|
234
|
-
@@ -37,9 +37,12 @@
|
|
453
|
+
@@ -37,9 +37,12 @@ export default function LogBoxInspectorBody(props: {
|
|
235
454
|
setCollapsed(true);
|
|
236
455
|
}, [props.log]);
|
|
237
456
|
|
|
@@ -248,9 +467,10 @@ diff --git a/Libraries/LogBox/UI/LogBoxInspectorBody.js b/Libraries/LogBox/UI/Lo
|
|
|
248
467
|
if (collapsed) {
|
|
249
468
|
return (
|
|
250
469
|
diff --git a/Libraries/LogBox/UI/LogBoxInspectorCodeFrame.js b/Libraries/LogBox/UI/LogBoxInspectorCodeFrame.js
|
|
470
|
+
index 0b4606c..d3d72d7 100644
|
|
251
471
|
--- a/Libraries/LogBox/UI/LogBoxInspectorCodeFrame.js
|
|
252
472
|
+++ b/Libraries/LogBox/UI/LogBoxInspectorCodeFrame.js
|
|
253
|
-
@@ -94,7 +94,7 @@
|
|
473
|
+
@@ -94,7 +94,7 @@ function LogBoxInspectorCodeFrame(props: Props): React.Node {
|
|
254
474
|
}
|
|
255
475
|
return (
|
|
256
476
|
<LogBoxInspectorSection
|
|
@@ -260,9 +480,10 @@ diff --git a/Libraries/LogBox/UI/LogBoxInspectorCodeFrame.js b/Libraries/LogBox/
|
|
|
260
480
|
{sources.map((frame, index) => (
|
|
261
481
|
<CodeFrameDisplay key={index} codeFrame={frame} />
|
|
262
482
|
diff --git a/Libraries/LogBox/UI/LogBoxInspectorFooter.js b/Libraries/LogBox/UI/LogBoxInspectorFooter.js
|
|
483
|
+
index c3a7b69..3b27917 100644
|
|
263
484
|
--- a/Libraries/LogBox/UI/LogBoxInspectorFooter.js
|
|
264
485
|
+++ b/Libraries/LogBox/UI/LogBoxInspectorFooter.js
|
|
265
|
-
@@ -18,36 +18,
|
|
486
|
+
@@ -18,36 +18,54 @@ import * as LogBoxStyle from './LogBoxStyle';
|
|
266
487
|
import * as React from 'react';
|
|
267
488
|
|
|
268
489
|
type Props = $ReadOnly<{
|
|
@@ -285,18 +506,14 @@ diff --git a/Libraries/LogBox/UI/LogBoxInspectorFooter.js b/Libraries/LogBox/UI/
|
|
|
285
506
|
- </View>
|
|
286
507
|
- );
|
|
287
508
|
- }
|
|
509
|
+
+ // 过程态只保留「正在检查」与默认文案:确认期间按钮被控制器锁住,
|
|
510
|
+
+ // 失败统一走弹窗(不再在按钮上显示「检查失败,点击重试」)。
|
|
288
511
|
+ const copyButtonText =
|
|
289
512
|
+ props.copyStatus === 'copied'
|
|
290
513
|
+ ? '已复制'
|
|
291
514
|
+ : props.copyStatus === 'checking'
|
|
292
515
|
+ ? '正在检查兼容性(最多 8 秒)'
|
|
293
|
-
+ :
|
|
294
|
-
+ ? '等待确认'
|
|
295
|
-
+ : props.copyStatus === 'check-failed'
|
|
296
|
-
+ ? '检查失败,点击重试'
|
|
297
|
-
+ : props.copyStatus === 'copy-failed'
|
|
298
|
-
+ ? '复制失败,点击重试'
|
|
299
|
-
+ : '复制错误给智能体修复';
|
|
516
|
+
+ : '复制错误给智能体修复';
|
|
300
517
|
|
|
301
518
|
return (
|
|
302
519
|
- <View style={styles.root}>
|
|
@@ -343,10 +560,24 @@ diff --git a/Libraries/LogBox/UI/LogBoxInspectorFooter.js b/Libraries/LogBox/UI/
|
|
|
343
560
|
</View>
|
|
344
561
|
);
|
|
345
562
|
}
|
|
563
|
+
diff --git a/Libraries/LogBox/UI/LogBoxInspectorFooterButton.js b/Libraries/LogBox/UI/LogBoxInspectorFooterButton.js
|
|
564
|
+
index e75d7a2..57d1f47 100644
|
|
565
|
+
--- a/Libraries/LogBox/UI/LogBoxInspectorFooterButton.js
|
|
566
|
+
+++ b/Libraries/LogBox/UI/LogBoxInspectorFooterButton.js
|
|
567
|
+
@@ -18,7 +18,7 @@ import * as React from 'react';
|
|
568
|
+
|
|
569
|
+
type ButtonProps = $ReadOnly<{
|
|
570
|
+
id: string,
|
|
571
|
+
- onPress: () => void,
|
|
572
|
+
+ onPress?: () => void,
|
|
573
|
+
text: string,
|
|
574
|
+
}>;
|
|
575
|
+
|
|
346
576
|
diff --git a/Libraries/LogBox/UI/LogBoxInspectorHeader.js b/Libraries/LogBox/UI/LogBoxInspectorHeader.js
|
|
577
|
+
index c6aa793..975315c 100644
|
|
347
578
|
--- a/Libraries/LogBox/UI/LogBoxInspectorHeader.js
|
|
348
579
|
+++ b/Libraries/LogBox/UI/LogBoxInspectorHeader.js
|
|
349
|
-
@@ -50,7 +50,7 @@
|
|
580
|
+
@@ -50,7 +50,7 @@ export default function LogBoxInspectorHeader(props: Props): React.Node {
|
|
350
581
|
const nextIndex =
|
|
351
582
|
props.selectedIndex + 1 > props.total - 1 ? 0 : props.selectedIndex + 1;
|
|
352
583
|
|
|
@@ -356,9 +587,10 @@ diff --git a/Libraries/LogBox/UI/LogBoxInspectorHeader.js b/Libraries/LogBox/UI/
|
|
|
356
587
|
return (
|
|
357
588
|
<LogBoxInspectorHeaderSafeArea style={styles[props.level]}>
|
|
358
589
|
diff --git a/Libraries/LogBox/UI/LogBoxInspectorMessageHeader.js b/Libraries/LogBox/UI/LogBoxInspectorMessageHeader.js
|
|
590
|
+
index 65259c1..a0edb49 100644
|
|
359
591
|
--- a/Libraries/LogBox/UI/LogBoxInspectorMessageHeader.js
|
|
360
592
|
+++ b/Libraries/LogBox/UI/LogBoxInspectorMessageHeader.js
|
|
361
|
-
@@ -38,7 +38,7 @@
|
|
593
|
+
@@ -38,7 +38,7 @@ function LogBoxInspectorMessageHeader(props: Props): React.Node {
|
|
362
594
|
}
|
|
363
595
|
return (
|
|
364
596
|
<Text style={messageStyles.collapse} onPress={() => props.onPress()}>
|
|
@@ -367,10 +599,33 @@ diff --git a/Libraries/LogBox/UI/LogBoxInspectorMessageHeader.js b/Libraries/Log
|
|
|
367
599
|
</Text>
|
|
368
600
|
);
|
|
369
601
|
}
|
|
602
|
+
diff --git a/Libraries/LogBox/UI/LogBoxInspectorReactFrames.js b/Libraries/LogBox/UI/LogBoxInspectorReactFrames.js
|
|
603
|
+
index d9e0b1a..f5b8482 100644
|
|
604
|
+
--- a/Libraries/LogBox/UI/LogBoxInspectorReactFrames.js
|
|
605
|
+
+++ b/Libraries/LogBox/UI/LogBoxInspectorReactFrames.js
|
|
606
|
+
@@ -73,14 +73,14 @@ function LogBoxInspectorReactFrames(props: Props): React.Node {
|
|
607
|
+
|
|
608
|
+
const count = props.log.getAvailableComponentStack().length - 3;
|
|
609
|
+
if (collapsed) {
|
|
610
|
+
- return `See ${count} more components`;
|
|
611
|
+
+ return `查看更多 ${count} 个组件`;
|
|
612
|
+
} else {
|
|
613
|
+
- return `Collapse ${count} components`;
|
|
614
|
+
+ return `折叠 ${count} 个组件`;
|
|
615
|
+
}
|
|
616
|
+
}
|
|
617
|
+
|
|
618
|
+
return (
|
|
619
|
+
- <LogBoxInspectorSection heading="Component Stack">
|
|
620
|
+
+ <LogBoxInspectorSection heading="组件栈">
|
|
621
|
+
{getStackList().map((frame, index) => (
|
|
622
|
+
<View
|
|
623
|
+
// Unfortunately we don't have a unique identifier for stack traces.
|
|
370
624
|
diff --git a/Libraries/LogBox/UI/LogBoxInspectorStackFrames.js b/Libraries/LogBox/UI/LogBoxInspectorStackFrames.js
|
|
625
|
+
index 48c1b84..41b308d 100644
|
|
371
626
|
--- a/Libraries/LogBox/UI/LogBoxInspectorStackFrames.js
|
|
372
627
|
+++ b/Libraries/LogBox/UI/LogBoxInspectorStackFrames.js
|
|
373
|
-
@@ -34,7 +34,7 @@
|
|
628
|
+
@@ -34,7 +34,7 @@ export function getCollapseMessage(
|
|
374
629
|
collapsed: boolean,
|
|
375
630
|
): string {
|
|
376
631
|
if (stackFrames.length === 0) {
|
|
@@ -379,13 +634,14 @@ diff --git a/Libraries/LogBox/UI/LogBoxInspectorStackFrames.js b/Libraries/LogBo
|
|
|
379
634
|
}
|
|
380
635
|
|
|
381
636
|
const collapsedCount = stackFrames.reduce((count, {collapse}) => {
|
|
382
|
-
@@ -46,23 +46,12 @@
|
|
637
|
+
@@ -46,23 +46,12 @@ export function getCollapseMessage(
|
|
383
638
|
}, 0);
|
|
384
639
|
|
|
385
640
|
if (collapsedCount === 0) {
|
|
386
641
|
- return 'Showing all frames';
|
|
387
|
-
|
|
388
|
-
|
|
642
|
+
+ return '已显示全部调用栈';
|
|
643
|
+
}
|
|
644
|
+
|
|
389
645
|
- const framePlural = `frame${collapsedCount > 1 ? 's' : ''}`;
|
|
390
646
|
- if (collapsedCount === stackFrames.length) {
|
|
391
647
|
- return collapsed
|
|
@@ -400,16 +656,13 @@ diff --git a/Libraries/LogBox/UI/LogBoxInspectorStackFrames.js b/Libraries/LogBo
|
|
|
400
656
|
- ? `See ${collapsedCount} more ${framePlural}`
|
|
401
657
|
- : `Collapse ${collapsedCount} ${framePlural}`;
|
|
402
658
|
- }
|
|
403
|
-
+ return '已显示全部调用栈';
|
|
404
|
-
+ }
|
|
405
|
-
+
|
|
406
659
|
+ return collapsed
|
|
407
660
|
+ ? `展开 ${collapsedCount} 个调用栈帧`
|
|
408
661
|
+ : `折叠 ${collapsedCount} 个调用栈帧`;
|
|
409
662
|
}
|
|
410
663
|
|
|
411
664
|
function LogBoxInspectorStackFrames(props: Props): React.Node {
|
|
412
|
-
@@ -85,7 +74,7 @@
|
|
665
|
+
@@ -85,7 +74,7 @@ function LogBoxInspectorStackFrames(props: Props): React.Node {
|
|
413
666
|
|
|
414
667
|
return (
|
|
415
668
|
<LogBoxInspectorSection
|
|
@@ -418,7 +671,7 @@ diff --git a/Libraries/LogBox/UI/LogBoxInspectorStackFrames.js b/Libraries/LogBo
|
|
|
418
671
|
action={
|
|
419
672
|
<LogBoxInspectorSourceMapStatus
|
|
420
673
|
onPress={
|
|
421
|
-
@@ -97,8 +86,7 @@
|
|
674
|
+
@@ -97,8 +86,7 @@ function LogBoxInspectorStackFrames(props: Props): React.Node {
|
|
422
675
|
{props.log.symbolicated.status !== 'COMPLETE' && (
|
|
423
676
|
<View style={stackStyles.hintBox}>
|
|
424
677
|
<Text style={stackStyles.hintText}>
|
|
@@ -428,170 +681,3 @@ diff --git a/Libraries/LogBox/UI/LogBoxInspectorStackFrames.js b/Libraries/LogBo
|
|
|
428
681
|
</Text>
|
|
429
682
|
</View>
|
|
430
683
|
)}
|
|
431
|
-
diff --git a/Libraries/LogBox/UI/LogBoxInspectorReactFrames.js b/Libraries/LogBox/UI/LogBoxInspectorReactFrames.js
|
|
432
|
-
--- a/Libraries/LogBox/UI/LogBoxInspectorReactFrames.js
|
|
433
|
-
+++ b/Libraries/LogBox/UI/LogBoxInspectorReactFrames.js
|
|
434
|
-
@@ -73,14 +73,14 @@
|
|
435
|
-
|
|
436
|
-
const count = props.log.getAvailableComponentStack().length - 3;
|
|
437
|
-
if (collapsed) {
|
|
438
|
-
- return `See ${count} more components`;
|
|
439
|
-
+ return `查看更多 ${count} 个组件`;
|
|
440
|
-
} else {
|
|
441
|
-
- return `Collapse ${count} components`;
|
|
442
|
-
+ return `折叠 ${count} 个组件`;
|
|
443
|
-
}
|
|
444
|
-
}
|
|
445
|
-
|
|
446
|
-
return (
|
|
447
|
-
- <LogBoxInspectorSection heading="Component Stack">
|
|
448
|
-
+ <LogBoxInspectorSection heading="组件栈">
|
|
449
|
-
{getStackList().map((frame, index) => (
|
|
450
|
-
<View
|
|
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
|
-
}>;
|