miaoda-expo-devkit 0.1.1-dev.development-build.8 → 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 +6 -4
- package/package.json +19 -19
- package/pnpm-patches/expo@55.0.6.patch +291 -51
- package/pnpm-patches/react-native@0.83.2.patch +291 -205
- package/pnpmfile.cjs +4 -0
|
@@ -21,18 +21,24 @@ index e2b8941..355deae 100644
|
|
|
21
21
|
"jest-expo": "~55.0.9",
|
|
22
22
|
"lottie-react-native": "~7.3.4",
|
|
23
23
|
diff --git a/src/async-require/hmr.ts b/src/async-require/hmr.ts
|
|
24
|
-
index c0ea71e..
|
|
24
|
+
index c0ea71e..bf5dc6c 100644
|
|
25
25
|
--- a/src/async-require/hmr.ts
|
|
26
26
|
+++ b/src/async-require/hmr.ts
|
|
27
|
-
@@ -11,12 +11,
|
|
27
|
+
@@ -11,12 +11,25 @@
|
|
28
28
|
import MetroHMRClient from '@expo/metro/metro-runtime/modules/HMRClient';
|
|
29
29
|
import prettyFormat, { plugins } from 'pretty-format';
|
|
30
30
|
|
|
31
31
|
+import {
|
|
32
32
|
+ checkMiaodaHmrCompatibility,
|
|
33
|
+
+ getMiaodaHmrCompatibilityState,
|
|
33
34
|
+ isMiaodaHmrCompatibilityEnabled,
|
|
34
35
|
+ setMiaodaHmrCompatibilityRetry,
|
|
35
36
|
+} from './miaodaHmrCompatibilityCheck';
|
|
37
|
+
+
|
|
38
|
+
+import {
|
|
39
|
+
+ getMiaodaNativeBlockingStatus,
|
|
40
|
+
+ onMiaodaNativeBlockingStatusAction,
|
|
41
|
+
+} from './miaodaNativeBlockingStatus';
|
|
36
42
|
+
|
|
37
43
|
import {
|
|
38
44
|
getConnectionError,
|
|
@@ -44,7 +50,7 @@ index c0ea71e..98fddec 100644
|
|
|
44
50
|
showLoading,
|
|
45
51
|
} from './hmrUtils';
|
|
46
52
|
|
|
47
|
-
@@ -29,8 +
|
|
53
|
+
@@ -29,8 +42,183 @@ let hmrClient: MetroHMRClient | null = null;
|
|
48
54
|
let hmrUnavailableReason: string | null = null;
|
|
49
55
|
const buildErrorQueue = new Set<unknown>();
|
|
50
56
|
let didConnect: boolean = false;
|
|
@@ -82,9 +88,8 @@ index c0ea71e..98fddec 100644
|
|
|
82
88
|
+}
|
|
83
89
|
+
|
|
84
90
|
+let miaodaServerDisconnected = false;
|
|
85
|
-
+// 开发服务器断线状态订阅者:launch/
|
|
86
|
-
+// Metro
|
|
87
|
-
+// 不阻断交互(pointerEvents: 'none'),服务恢复后自动消失。
|
|
91
|
+
+// 开发服务器断线状态订阅者:launch/ 里的回退横幅(旧客户端)据此提示用户
|
|
92
|
+
+// Metro 已不可达。新客户端上阻断 UI 由原生阻断页渲染,JS 只上报状态。
|
|
88
93
|
+const miaodaServerDisconnectedListeners = new Set<(disconnected: boolean) => void>();
|
|
89
94
|
+
|
|
90
95
|
+// miaodaServerDisconnected 的唯一写入入口:值真正变化时才广播,
|
|
@@ -92,6 +97,17 @@ index c0ea71e..98fddec 100644
|
|
|
92
97
|
+function setMiaodaServerDisconnected(disconnected: boolean) {
|
|
93
98
|
+ if (miaodaServerDisconnected === disconnected) return;
|
|
94
99
|
+ miaodaServerDisconnected = disconnected;
|
|
100
|
+
+ // 新客户端:断线挂原生阻断页(重新尝试 / 退出),恢复时收起。
|
|
101
|
+
+ // 同一时刻只保留一个阻断页且连接优先:热更新确认页已在展示时不再切换
|
|
102
|
+
+ //(该页本身已阻断交互,确认或退出后断线状态仍由轮询驱动重新挂出)。
|
|
103
|
+
+ const native = getMiaodaNativeBlockingStatus();
|
|
104
|
+
+ if (native != null && getMiaodaHmrCompatibilityState().status !== 'blocked') {
|
|
105
|
+
+ if (disconnected) {
|
|
106
|
+
+ void native.showBlockingStatus('disconnected');
|
|
107
|
+
+ } else {
|
|
108
|
+
+ void native.dismissBlockingStatus();
|
|
109
|
+
+ }
|
|
110
|
+
+ }
|
|
95
111
|
+ for (const listener of miaodaServerDisconnectedListeners) {
|
|
96
112
|
+ try {
|
|
97
113
|
+ listener(disconnected);
|
|
@@ -99,6 +115,24 @@ index c0ea71e..98fddec 100644
|
|
|
99
115
|
+ }
|
|
100
116
|
+}
|
|
101
117
|
+
|
|
118
|
+
+// 原生阻断页「重新尝试」:立即探测一轮而不是等下一个 2 秒周期,
|
|
119
|
+
+// 探测结果仍由统一的轮询路径处理(成功即收起页面)。
|
|
120
|
+
+function probeMiaodaStatusNow() {
|
|
121
|
+
+ if (miaodaPollTimer != null) {
|
|
122
|
+
+ clearTimeout(miaodaPollTimer);
|
|
123
|
+
+ miaodaPollTimer = null;
|
|
124
|
+
+ }
|
|
125
|
+
+ void pollMiaodaStatus();
|
|
126
|
+
+}
|
|
127
|
+
+
|
|
128
|
+
+// 原生阻断页按钮事件入口:断线页的「重新尝试」由 JS 触发立即探测
|
|
129
|
+
+//(「退出」在原生侧直接结束进程,不经过 JS)。
|
|
130
|
+
+onMiaodaNativeBlockingStatusAction((event) => {
|
|
131
|
+
+ if (event.kind === 'disconnected' && event.action === 'retry') {
|
|
132
|
+
+ probeMiaodaStatusNow();
|
|
133
|
+
+ }
|
|
134
|
+
+});
|
|
135
|
+
+
|
|
102
136
|
+// 订阅断线状态变化,返回取消订阅函数(供 React useEffect 使用)。
|
|
103
137
|
+export function subscribeMiaodaServerDisconnected(
|
|
104
138
|
+ listener: (disconnected: boolean) => void
|
|
@@ -174,6 +208,8 @@ index c0ea71e..98fddec 100644
|
|
|
174
208
|
+async function attemptMiaodaReload() {
|
|
175
209
|
+ const intent = miaodaReloadIntent;
|
|
176
210
|
+ if (!intent || intent.attempted || miaodaReloadChecking || miaodaReloadCommitted || miaodaPaused) return;
|
|
211
|
+
+ // 连接优先于能力:断线期间检查只会得到 unknown,等恢复后由轮询重新驱动。
|
|
212
|
+
+ if (miaodaServerDisconnected) return;
|
|
177
213
|
+ intent.attempted = true;
|
|
178
214
|
+ miaodaReloadChecking = true;
|
|
179
215
|
+ const epoch = miaodaReloadEpoch;
|
|
@@ -198,7 +234,7 @@ index c0ea71e..98fddec 100644
|
|
|
198
234
|
type LogLevel =
|
|
199
235
|
| 'trace'
|
|
200
236
|
| 'info'
|
|
201
|
-
@@ -42,6 +
|
|
237
|
+
@@ -42,6 +230,127 @@ type LogLevel =
|
|
202
238
|
| 'groupEnd'
|
|
203
239
|
| 'debug';
|
|
204
240
|
|
|
@@ -326,7 +362,7 @@ index c0ea71e..98fddec 100644
|
|
|
326
362
|
function assert(foo: any, msg: string): asserts foo {
|
|
327
363
|
if (!foo) throw new Error(msg);
|
|
328
364
|
}
|
|
329
|
-
@@ -52,6 +
|
|
365
|
+
@@ -52,6 +361,9 @@ function assert(foo: any, msg: string): asserts foo {
|
|
330
366
|
*/
|
|
331
367
|
const HMRClient = {
|
|
332
368
|
enable() {
|
|
@@ -336,7 +372,7 @@ index c0ea71e..98fddec 100644
|
|
|
336
372
|
if (hmrUnavailableReason !== null) {
|
|
337
373
|
// If HMR became unavailable while you weren't using it,
|
|
338
374
|
// explain why when you try to turn it on.
|
|
339
|
-
@@ -87,6 +
|
|
375
|
+
@@ -87,6 +399,7 @@ const HMRClient = {
|
|
340
376
|
},
|
|
341
377
|
|
|
342
378
|
disable() {
|
|
@@ -344,7 +380,7 @@ index c0ea71e..98fddec 100644
|
|
|
344
380
|
assert(hmrClient, 'Expected HMRClient.setup() call at startup.');
|
|
345
381
|
hmrClient.disable();
|
|
346
382
|
},
|
|
347
|
-
@@ -180,6 +
|
|
383
|
+
@@ -180,6 +493,42 @@ const HMRClient = {
|
|
348
384
|
const origin = `${serverScheme}://${serverHost}`;
|
|
349
385
|
const client = new MetroHMRClient(`${origin}/hot`);
|
|
350
386
|
hmrClient = client;
|
|
@@ -387,7 +423,7 @@ index c0ea71e..98fddec 100644
|
|
|
387
423
|
|
|
388
424
|
pendingEntryPoints.push(
|
|
389
425
|
// HMRServer understands regular bundle URLs, so prefer that in case
|
|
390
|
-
@@ -193,6 +
|
|
426
|
+
@@ -193,6 +542,61 @@ const HMRClient = {
|
|
391
427
|
})
|
|
392
428
|
);
|
|
393
429
|
|
|
@@ -449,7 +485,7 @@ index c0ea71e..98fddec 100644
|
|
|
449
485
|
client.on('connection-error', (e: Error) => {
|
|
450
486
|
setHMRUnavailableReason(getConnectionError(serverHost, e));
|
|
451
487
|
});
|
|
452
|
-
@@ -221,7 +
|
|
488
|
+
@@ -221,7 +625,13 @@ const HMRClient = {
|
|
453
489
|
}) => {
|
|
454
490
|
// NOTE(@krystofwoldrich): I don't know why sometimes empty updates are sent. But they should not reset the overlay.
|
|
455
491
|
const isEmpty = added.length === 0 && modified.length === 0 && deleted.length === 0;
|
|
@@ -464,7 +500,7 @@ index c0ea71e..98fddec 100644
|
|
|
464
500
|
resetErrorOverlay();
|
|
465
501
|
}
|
|
466
502
|
}
|
|
467
|
-
@@ -234,6 +
|
|
503
|
+
@@ -234,6 +644,10 @@ const HMRClient = {
|
|
468
504
|
client.on('error', (data) => this._onMetroError(data));
|
|
469
505
|
|
|
470
506
|
client.on('close', (closeEvent?: { code: number; reason: string }) => {
|
|
@@ -475,7 +511,7 @@ index c0ea71e..98fddec 100644
|
|
|
475
511
|
hideLoading();
|
|
476
512
|
const reason = closeEvent?.reason;
|
|
477
513
|
const code = closeEvent?.code || 1000;
|
|
478
|
-
@@ -318,7 +
|
|
514
|
+
@@ -318,7 +732,8 @@ function setHMRUnavailableReason(reason: string) {
|
|
479
515
|
function registerBundleEntryPoints(client: MetroHMRClient | null) {
|
|
480
516
|
if (hmrUnavailableReason != null) {
|
|
481
517
|
// "Bundle Splitting – Metro disconnected"
|
|
@@ -485,7 +521,7 @@ index c0ea71e..98fddec 100644
|
|
|
485
521
|
return;
|
|
486
522
|
}
|
|
487
523
|
|
|
488
|
-
@@ -326,6 +
|
|
524
|
+
@@ -326,6 +741,9 @@ function registerBundleEntryPoints(client: MetroHMRClient | null) {
|
|
489
525
|
client?.send(
|
|
490
526
|
JSON.stringify({
|
|
491
527
|
type: 'register-entrypoints',
|
|
@@ -497,21 +533,28 @@ index c0ea71e..98fddec 100644
|
|
|
497
533
|
);
|
|
498
534
|
diff --git a/src/async-require/miaodaHmrCompatibility.ts b/src/async-require/miaodaHmrCompatibility.ts
|
|
499
535
|
new file mode 100644
|
|
500
|
-
index 0000000..
|
|
536
|
+
index 0000000..3b44065
|
|
501
537
|
--- /dev/null
|
|
502
538
|
+++ b/src/async-require/miaodaHmrCompatibility.ts
|
|
503
|
-
@@ -0,0 +1,
|
|
539
|
+
@@ -0,0 +1,149 @@
|
|
504
540
|
+export type HmrCompatibilityState = {
|
|
505
541
|
+ status: 'idle' | 'checking' | 'blocked';
|
|
506
542
|
+ reason?: string;
|
|
543
|
+
+ reasons?: string[];
|
|
507
544
|
+};
|
|
508
545
|
+
|
|
509
546
|
+export type HmrCompatibilityDecision = 'hold' | 'retry' | 'update';
|
|
510
547
|
+
|
|
548
|
+
+type HmrCompatibilityStatus = 'compatible' | 'incompatible' | 'unknown';
|
|
549
|
+
+
|
|
511
550
|
+type Dependencies = {
|
|
512
551
|
+ isEnabled: () => boolean;
|
|
513
552
|
+ check: () => Promise<unknown>;
|
|
514
|
-
+ confirm: (
|
|
553
|
+
+ confirm: (
|
|
554
|
+
+ status: 'incompatible' | 'unknown',
|
|
555
|
+
+ reason: string,
|
|
556
|
+
+ reasons: string[]
|
|
557
|
+
+ ) => Promise<HmrCompatibilityDecision>;
|
|
515
558
|
+ timeoutMs?: number;
|
|
516
559
|
+};
|
|
517
560
|
+
|
|
@@ -535,7 +578,11 @@ index 0000000..2201769
|
|
|
535
578
|
+ }
|
|
536
579
|
+ }
|
|
537
580
|
+
|
|
538
|
-
+ async function inspect(): Promise<{
|
|
581
|
+
+ async function inspect(): Promise<{
|
|
582
|
+
+ status: HmrCompatibilityStatus;
|
|
583
|
+
+ reason: string;
|
|
584
|
+
+ reasons: string[];
|
|
585
|
+
+ }> {
|
|
539
586
|
+ let timer: ReturnType<typeof setTimeout> | undefined;
|
|
540
587
|
+ try {
|
|
541
588
|
+ const result = await Promise.race([
|
|
@@ -547,19 +594,32 @@ index 0000000..2201769
|
|
|
547
594
|
+ );
|
|
548
595
|
+ }),
|
|
549
596
|
+ ]);
|
|
550
|
-
+ const value = result as { status?: unknown; reason?: unknown } | null;
|
|
597
|
+
+ const value = result as { status?: unknown; reason?: unknown; reasons?: unknown } | null;
|
|
551
598
|
+ const reason = typeof value?.reason === 'string' ? value.reason.trim() : '';
|
|
599
|
+
+ // 结构化原因列表优先(新客户端);旧客户端回退用 reason 按行拆分。
|
|
600
|
+
+ const reasons = Array.isArray(value?.reasons)
|
|
601
|
+
+ ? (value.reasons as unknown[]).filter((item): item is string => typeof item === 'string' && item !== '')
|
|
602
|
+
+ : reason.split('\n').map((line) => line.trim()).filter((line) => line !== '');
|
|
552
603
|
+ if (value?.status === 'compatible') {
|
|
553
|
-
+ return { status: 'compatible', reason };
|
|
604
|
+
+ return { status: 'compatible', reason, reasons };
|
|
554
605
|
+ }
|
|
555
606
|
+ if (value?.status === 'incompatible') {
|
|
556
|
-
+ return {
|
|
607
|
+
+ return {
|
|
608
|
+
+ status: 'incompatible',
|
|
609
|
+
+ reason: reason || '当前开发构建缺少项目所需的原生能力。',
|
|
610
|
+
+ reasons,
|
|
611
|
+
+ };
|
|
557
612
|
+ }
|
|
558
|
-
+ return {
|
|
613
|
+
+ return {
|
|
614
|
+
+ status: 'unknown',
|
|
615
|
+
+ reason: reason || '兼容性检查未返回明确结果,请更新开发客户端后重试。',
|
|
616
|
+
+ reasons,
|
|
617
|
+
+ };
|
|
559
618
|
+ } catch (error) {
|
|
560
619
|
+ return {
|
|
561
620
|
+ status: 'unknown',
|
|
562
621
|
+ reason: error instanceof Error ? error.message : '兼容性检查失败,请检查网络后重试。',
|
|
622
|
+
+ reasons: [],
|
|
563
623
|
+ };
|
|
564
624
|
+ } finally {
|
|
565
625
|
+ clearTimeout(timer);
|
|
@@ -583,10 +643,10 @@ index 0000000..2201769
|
|
|
583
643
|
+ publish(idle);
|
|
584
644
|
+ return true;
|
|
585
645
|
+ }
|
|
586
|
-
+ publish({ status: 'blocked', reason: result.reason });
|
|
646
|
+
+ publish({ status: 'blocked', reason: result.reason, reasons: result.reasons });
|
|
587
647
|
+ let decision: HmrCompatibilityDecision;
|
|
588
648
|
+ try {
|
|
589
|
-
+ decision = await deps.confirm(result.status, result.reason);
|
|
649
|
+
+ decision = await deps.confirm(result.status, result.reason, result.reasons);
|
|
590
650
|
+ } catch {
|
|
591
651
|
+ // 弹框异常也保留暂停状态,横幅仍可触发重试。
|
|
592
652
|
+ return false;
|
|
@@ -628,13 +688,18 @@ index 0000000..2201769
|
|
|
628
688
|
+}
|
|
629
689
|
diff --git a/src/async-require/miaodaHmrCompatibilityCheck.native.ts b/src/async-require/miaodaHmrCompatibilityCheck.native.ts
|
|
630
690
|
new file mode 100644
|
|
631
|
-
index 0000000..
|
|
691
|
+
index 0000000..de12dc6
|
|
632
692
|
--- /dev/null
|
|
633
693
|
+++ b/src/async-require/miaodaHmrCompatibilityCheck.native.ts
|
|
634
|
-
@@ -0,0 +1,
|
|
694
|
+
@@ -0,0 +1,85 @@
|
|
635
695
|
+import { Alert } from 'react-native';
|
|
636
696
|
+
|
|
637
697
|
+import { createHmrCompatibilityController } from './miaodaHmrCompatibility';
|
|
698
|
+
+import {
|
|
699
|
+
+ getMiaodaNativeBlockingStatus,
|
|
700
|
+
+ onMiaodaNativeBlockingStatusAction,
|
|
701
|
+
+} from './miaodaNativeBlockingStatus';
|
|
702
|
+
+import { MIAODA_PROMPT_COPY } from '../launch/miaodaPromptCopy';
|
|
638
703
|
+import { isRunningInExpoGo } from '../environment/ExpoGo';
|
|
639
704
|
+
|
|
640
705
|
+export type { HmrCompatibilityState } from './miaodaHmrCompatibility';
|
|
@@ -657,20 +722,53 @@ index 0000000..721fd81
|
|
|
657
722
|
+ // 只读取兼容性结果,不触发任何剪贴板写入。
|
|
658
723
|
+ return module.checkCopyCompatibility();
|
|
659
724
|
+ },
|
|
660
|
-
+
|
|
661
|
-
+
|
|
662
|
-
+
|
|
663
|
-
+
|
|
664
|
-
+
|
|
665
|
-
+
|
|
666
|
-
+
|
|
667
|
-
+
|
|
668
|
-
+
|
|
669
|
-
+
|
|
670
|
-
+
|
|
671
|
-
+
|
|
725
|
+
+ // 热更新执行前的确认:新客户端交给原生阻断页(仍要使用 / 退出),文案与
|
|
726
|
+
+ // 连接问题、加载前确认共用一套;旧客户端回退三按钮 Alert(JS 无法退出进程,
|
|
727
|
+
+ // 保留「保留当前应用 / 重新检查」两个安全选项)。
|
|
728
|
+
+ confirm: (status, reason, reasons) =>
|
|
729
|
+
+ new Promise((resolve) => {
|
|
730
|
+
+ const native = getMiaodaNativeBlockingStatus();
|
|
731
|
+
+ if (native != null) {
|
|
732
|
+
+ void (async () => {
|
|
733
|
+
+ const shown = await native.showBlockingStatus('hmrCapability', { status, reasons });
|
|
734
|
+
+ if (!shown) {
|
|
735
|
+
+ showLegacyAlert(status, reason, resolve);
|
|
736
|
+
+ return;
|
|
737
|
+
+ }
|
|
738
|
+
+ let remove: () => void = () => {};
|
|
739
|
+
+ remove = onMiaodaNativeBlockingStatusAction((event) => {
|
|
740
|
+
+ if (event.kind === 'hmrCapability' && event.action === 'continue') {
|
|
741
|
+
+ remove();
|
|
742
|
+
+ resolve('update');
|
|
743
|
+
+ }
|
|
744
|
+
+ });
|
|
745
|
+
+ })();
|
|
746
|
+
+ return;
|
|
747
|
+
+ }
|
|
748
|
+
+ showLegacyAlert(status, reason, resolve);
|
|
749
|
+
+ }),
|
|
672
750
|
+});
|
|
673
751
|
+
|
|
752
|
+
+// 旧客户端回退弹窗:标题已与统一文案表对齐,正文保留三按钮语义的完整说明。
|
|
753
|
+
+function showLegacyAlert(
|
|
754
|
+
+ status: 'incompatible' | 'unknown',
|
|
755
|
+
+ reason: string,
|
|
756
|
+
+ resolve: (decision: 'hold' | 'retry' | 'update') => void
|
|
757
|
+
+) {
|
|
758
|
+
+ Alert.alert(
|
|
759
|
+
+ status === 'incompatible'
|
|
760
|
+
+ ? MIAODA_PROMPT_COPY.incompatibleTitle
|
|
761
|
+
+ : MIAODA_PROMPT_COPY.unknownTitle,
|
|
762
|
+
+ `${reason}\n\n更新已暂停,当前应用仍可继续使用。建议根据项目最新原生依赖重新构建并安装开发客户端后再更新。仍要更新可能导致应用无法运行。`,
|
|
763
|
+
+ [
|
|
764
|
+
+ { text: '保留当前应用', style: 'cancel', onPress: () => resolve('hold') },
|
|
765
|
+
+ { text: '重新检查', onPress: () => resolve('retry') },
|
|
766
|
+
+ { text: '仍要更新', style: 'destructive', onPress: () => resolve('update') },
|
|
767
|
+
+ ],
|
|
768
|
+
+ { cancelable: false }
|
|
769
|
+
+ );
|
|
770
|
+
+}
|
|
771
|
+
+
|
|
674
772
|
+export const {
|
|
675
773
|
+ checkMiaodaHmrCompatibility,
|
|
676
774
|
+ isMiaodaHmrCompatibilityEnabled,
|
|
@@ -703,28 +801,115 @@ index 0000000..1487079
|
|
|
703
801
|
+ setMiaodaHmrCompatibilityRetry,
|
|
704
802
|
+ retryMiaodaHmrCompatibility,
|
|
705
803
|
+} = controller;
|
|
804
|
+
diff --git a/src/async-require/miaodaNativeBlockingStatus.ts b/src/async-require/miaodaNativeBlockingStatus.ts
|
|
805
|
+
new file mode 100644
|
|
806
|
+
index 0000000..ea5ddd5
|
|
807
|
+
--- /dev/null
|
|
808
|
+
+++ b/src/async-require/miaodaNativeBlockingStatus.ts
|
|
809
|
+
@@ -0,0 +1,78 @@
|
|
810
|
+
+// dev-launcher 原生阻断页桥接:新客户端上运行中阻断 UI(断线页 / 热更新能力
|
|
811
|
+
+// 确认页)由原生渲染(复用吉祥物资产与统一文案),JS 只负责检测与状态上报。
|
|
812
|
+
+// 旧开发客户端没有这组接口,调用方据此回退自有 UI(断线横幅 / 确认弹窗)。
|
|
813
|
+
+
|
|
814
|
+
+type MiaodaBlockingStatusActionEvent = {
|
|
815
|
+
+ kind: string;
|
|
816
|
+
+ action: string;
|
|
817
|
+
+};
|
|
818
|
+
+
|
|
819
|
+
+type NativeBlockingStatusModule = {
|
|
820
|
+
+ showBlockingStatus: (
|
|
821
|
+
+ kind: string,
|
|
822
|
+
+ payload?: Record<string, unknown>
|
|
823
|
+
+ ) => Promise<boolean> | boolean;
|
|
824
|
+
+ dismissBlockingStatus: () => void | Promise<void>;
|
|
825
|
+
+ addListener: (
|
|
826
|
+
+ eventName: string,
|
|
827
|
+
+ listener: (event: MiaodaBlockingStatusActionEvent) => void
|
|
828
|
+
+ ) => { remove: () => void };
|
|
829
|
+
+};
|
|
830
|
+
+
|
|
831
|
+
+type NativeModuleRegistry = {
|
|
832
|
+
+ expo?: {
|
|
833
|
+
+ modules?: {
|
|
834
|
+
+ ExpoDevLauncher?: Record<string, unknown>;
|
|
835
|
+
+ };
|
|
836
|
+
+ };
|
|
837
|
+
+};
|
|
838
|
+
+
|
|
839
|
+
+function getRuntime(): NativeModuleRegistry {
|
|
840
|
+
+ return globalThis as typeof globalThis & NativeModuleRegistry;
|
|
841
|
+
+}
|
|
842
|
+
+
|
|
843
|
+
+// 按需安装 Expo 模块:初始化阶段桥接模块可能尚未就绪(与 LogBox 的延迟注册
|
|
844
|
+
+// 方式一致)。安装失败不抛错,由调用方按旧客户端回退。
|
|
845
|
+
+function ensureNativeModulesInstalled() {
|
|
846
|
+
+ const runtime = getRuntime();
|
|
847
|
+
+ if (runtime.expo == null) {
|
|
848
|
+
+ const registry = require('react-native/Libraries/TurboModule/TurboModuleRegistry');
|
|
849
|
+
+ registry.get('ExpoModulesCore')?.installModules?.();
|
|
850
|
+
+ }
|
|
851
|
+
+}
|
|
852
|
+
+
|
|
853
|
+
+/**
|
|
854
|
+
+ * 取原生阻断页接口;三接口齐全才算新客户端,否则返回 null。
|
|
855
|
+
+ * 任何一步异常都按「不支持」处理,让调用方回退旧 UI。
|
|
856
|
+
+ */
|
|
857
|
+
+export function getMiaodaNativeBlockingStatus(): NativeBlockingStatusModule | null {
|
|
858
|
+
+ try {
|
|
859
|
+
+ ensureNativeModulesInstalled();
|
|
860
|
+
+ const module = getRuntime().expo?.modules?.ExpoDevLauncher;
|
|
861
|
+
+ if (module == null) return null;
|
|
862
|
+
+ const candidate = module as Partial<NativeBlockingStatusModule>;
|
|
863
|
+
+ if (
|
|
864
|
+
+ typeof candidate.showBlockingStatus !== 'function' ||
|
|
865
|
+
+ typeof candidate.dismissBlockingStatus !== 'function' ||
|
|
866
|
+
+ typeof candidate.addListener !== 'function'
|
|
867
|
+
+ ) {
|
|
868
|
+
+ return null;
|
|
869
|
+
+ }
|
|
870
|
+
+ return candidate as NativeBlockingStatusModule;
|
|
871
|
+
+ } catch {
|
|
872
|
+
+ return null;
|
|
873
|
+
+ }
|
|
874
|
+
+}
|
|
875
|
+
+
|
|
876
|
+
+/**
|
|
877
|
+
+ * 订阅原生阻断页按钮事件;原生不可用时为 no-op。
|
|
878
|
+
+ * 返回取消订阅函数(供一次性等待的调用方清理)。
|
|
879
|
+
+ */
|
|
880
|
+
+export function onMiaodaNativeBlockingStatusAction(
|
|
881
|
+
+ listener: (event: MiaodaBlockingStatusActionEvent) => void
|
|
882
|
+
+): () => void {
|
|
883
|
+
+ const module = getMiaodaNativeBlockingStatus();
|
|
884
|
+
+ if (module == null) return () => {};
|
|
885
|
+
+ const subscription = module.addListener('onBlockingStatusAction', listener);
|
|
886
|
+
+ return () => subscription.remove();
|
|
887
|
+
+}
|
|
706
888
|
diff --git a/src/launch/MiaodaDevServerBanner.tsx b/src/launch/MiaodaDevServerBanner.tsx
|
|
707
889
|
new file mode 100644
|
|
708
|
-
index 0000000..
|
|
890
|
+
index 0000000..13037b7
|
|
709
891
|
--- /dev/null
|
|
710
892
|
+++ b/src/launch/MiaodaDevServerBanner.tsx
|
|
711
|
-
@@ -0,0 +1,
|
|
893
|
+
@@ -0,0 +1,50 @@
|
|
712
894
|
+import * as React from 'react';
|
|
713
895
|
+import { StyleSheet, Text, View } from 'react-native';
|
|
714
896
|
+
|
|
715
897
|
+import { isMiaodaServerDisconnected, subscribeMiaodaServerDisconnected } from '../async-require/hmr';
|
|
898
|
+
+import { getMiaodaNativeBlockingStatus } from '../async-require/miaodaNativeBlockingStatus';
|
|
899
|
+
+import { MIAODA_PROMPT_COPY } from './miaodaPromptCopy';
|
|
716
900
|
+import { getInitialSafeArea } from '../environment/getInitialSafeArea';
|
|
717
901
|
+
|
|
718
|
-
+//
|
|
719
|
-
+//
|
|
902
|
+
+// 开发服务器断线提示横幅(旧客户端回退):/_hmr/status 轮询连续失败达到阈值后
|
|
903
|
+
+// 显示,服务恢复或 WebSocket 重连后自动消失。非阻断(pointerEvents: 'none'),
|
|
720
904
|
+// 不影响应用交互;已加载的 JS 继续运行,只有代码更新会中断。
|
|
905
|
+
+// 新客户端上阻断 UI 由原生阻断页渲染(重新尝试 / 退出),本横幅不再出现。
|
|
721
906
|
+export default function MiaodaDevServerBanner(): React.ReactElement | null {
|
|
722
907
|
+ const [disconnected, setDisconnected] = React.useState(isMiaodaServerDisconnected);
|
|
723
908
|
+ React.useEffect(() => subscribeMiaodaServerDisconnected(setDisconnected), []);
|
|
724
|
-
+ if (!disconnected) return null;
|
|
909
|
+
+ if (!disconnected || getMiaodaNativeBlockingStatus() != null) return null;
|
|
725
910
|
+ return (
|
|
726
911
|
+ <View style={styles.container}>
|
|
727
|
-
+ <Text style={styles.title}
|
|
912
|
+
+ <Text style={styles.title}>{MIAODA_PROMPT_COPY.disconnectedTitle}</Text>
|
|
728
913
|
+ <Text style={styles.subtitle}>应用仍可继续使用,服务恢复后将自动重连</Text>
|
|
729
914
|
+ </View>
|
|
730
915
|
+ );
|
|
@@ -758,10 +943,10 @@ index 0000000..6313570
|
|
|
758
943
|
+});
|
|
759
944
|
diff --git a/src/launch/MiaodaHmrCompatibilityBanner.tsx b/src/launch/MiaodaHmrCompatibilityBanner.tsx
|
|
760
945
|
new file mode 100644
|
|
761
|
-
index 0000000..
|
|
946
|
+
index 0000000..4aecd61
|
|
762
947
|
--- /dev/null
|
|
763
948
|
+++ b/src/launch/MiaodaHmrCompatibilityBanner.tsx
|
|
764
|
-
@@ -0,0 +1,
|
|
949
|
+
@@ -0,0 +1,71 @@
|
|
765
950
|
+import * as React from 'react';
|
|
766
951
|
+import { Pressable, StyleSheet, Text, View } from 'react-native';
|
|
767
952
|
+
|
|
@@ -771,8 +956,12 @@ index 0000000..4d17e1c
|
|
|
771
956
|
+ retryMiaodaHmrCompatibility,
|
|
772
957
|
+ subscribeMiaodaHmrCompatibility,
|
|
773
958
|
+} from '../async-require/miaodaHmrCompatibilityCheck';
|
|
959
|
+
+import { getMiaodaNativeBlockingStatus } from '../async-require/miaodaNativeBlockingStatus';
|
|
774
960
|
+import { getInitialSafeArea } from '../environment/getInitialSafeArea';
|
|
775
961
|
+
|
|
962
|
+
+// 热更新能力确认横幅(旧客户端回退):确认弹窗关闭但检查仍未通过时提示
|
|
963
|
+
+// 用户更新处于暂停。新客户端上确认由原生阻断页(仍要使用 / 退出)承担,
|
|
964
|
+
+// 本横幅不再出现。
|
|
776
965
|
+export default function MiaodaHmrCompatibilityBanner(): React.ReactElement | null {
|
|
777
966
|
+ const [state, setState] = React.useState(getMiaodaHmrCompatibilityState);
|
|
778
967
|
+ React.useEffect(() => {
|
|
@@ -780,14 +969,18 @@ index 0000000..4d17e1c
|
|
|
780
969
|
+ setState(getMiaodaHmrCompatibilityState());
|
|
781
970
|
+ return unsubscribe;
|
|
782
971
|
+ }, []);
|
|
783
|
-
+ if (
|
|
972
|
+
+ if (
|
|
973
|
+
+ !isMiaodaHmrCompatibilityEnabled() ||
|
|
974
|
+
+ state.status !== 'blocked' ||
|
|
975
|
+
+ getMiaodaNativeBlockingStatus() != null
|
|
976
|
+
+ ) {
|
|
784
977
|
+ return null;
|
|
785
978
|
+ }
|
|
786
979
|
+ return (
|
|
787
980
|
+ <View pointerEvents="box-none" style={styles.container}>
|
|
788
981
|
+ <View style={styles.banner}>
|
|
789
982
|
+ <Text style={styles.title}>更新已暂停</Text>
|
|
790
|
-
+ <Text style={styles.subtitle}
|
|
983
|
+
+ <Text style={styles.subtitle}>当前应用仍可使用,建议重新构建开发客户端</Text>
|
|
791
984
|
+ <Pressable
|
|
792
985
|
+ accessibilityRole="button"
|
|
793
986
|
+ accessibilityLabel="重试检查开发构建兼容性"
|
|
@@ -827,7 +1020,7 @@ index 0000000..4d17e1c
|
|
|
827
1020
|
+});
|
|
828
1021
|
diff --git a/src/launch/MiaodaHmrOverlay.tsx b/src/launch/MiaodaHmrOverlay.tsx
|
|
829
1022
|
new file mode 100644
|
|
830
|
-
index 0000000..
|
|
1023
|
+
index 0000000..8b8cef4
|
|
831
1024
|
--- /dev/null
|
|
832
1025
|
+++ b/src/launch/MiaodaHmrOverlay.tsx
|
|
833
1026
|
@@ -0,0 +1,58 @@
|
|
@@ -859,7 +1052,7 @@ index 0000000..2db61b9
|
|
|
859
1052
|
+ return (
|
|
860
1053
|
+ <View style={styles.container}>
|
|
861
1054
|
+ <ActivityIndicator color="#ffffff" size="large" />
|
|
862
|
-
+ <Text style={styles.title}
|
|
1055
|
+
+ <Text style={styles.title}>应用正在修改中</Text>
|
|
863
1056
|
+ <Text style={styles.subtitle}>暂时无法使用,更新完成后将自动恢复</Text>
|
|
864
1057
|
+ </View>
|
|
865
1058
|
+ );
|
|
@@ -889,6 +1082,53 @@ index 0000000..2db61b9
|
|
|
889
1082
|
+ marginTop: 8,
|
|
890
1083
|
+ },
|
|
891
1084
|
+});
|
|
1085
|
+
diff --git a/src/launch/miaodaPromptCopy.ts b/src/launch/miaodaPromptCopy.ts
|
|
1086
|
+
new file mode 100644
|
|
1087
|
+
index 0000000..d2556eb
|
|
1088
|
+
--- /dev/null
|
|
1089
|
+
+++ b/src/launch/miaodaPromptCopy.ts
|
|
1090
|
+
@@ -0,0 +1,41 @@
|
|
1091
|
+
+// Development Build 提示文案的唯一事实源(devkit 补丁 JS 侧)。
|
|
1092
|
+
+//
|
|
1093
|
+
+// 连接问题与能力问题各只有一套文案,所有时机(热更新前、复制错误前、运行中
|
|
1094
|
+
+// 断线)共用。与 iOS 的 DevLauncherPromptCopy.swift、Android 的
|
|
1095
|
+
+// DevLauncherPromptCopy.kt、react-native 补丁的 LogBoxPromptCopy.js 逐字对应,
|
|
1096
|
+
+// 由 devkit 的文案一致性测试(promptCopyConsistency.test.ts)锁定;修改任何
|
|
1097
|
+
+// 一端必须同步其余三端。
|
|
1098
|
+
+
|
|
1099
|
+
+export const MIAODA_PROMPT_COPY = {
|
|
1100
|
+
+ // 连接问题(运行中断线阻断页;加载前由原生吉祥物状态页承担)。
|
|
1101
|
+
+ connectingTitle: '正在连接开发服务器',
|
|
1102
|
+
+ connectFailedTitle: '无法连接开发服务器',
|
|
1103
|
+
+ connectFailedBody: '请确认开发服务器正在运行,或访问秒哒重新打开此应用。',
|
|
1104
|
+
+ retryButtonTitle: '重新尝试',
|
|
1105
|
+
+ retryingButtonTitle: '正在重新尝试',
|
|
1106
|
+
+ disconnectedTitle: '已断开开发服务器',
|
|
1107
|
+
+ disconnectedBody: '当前应用已暂停使用,恢复连接后将自动返回。也可以重新尝试,或退出开发客户端。',
|
|
1108
|
+
+
|
|
1109
|
+
+ // 能力问题(热更新前确认)。
|
|
1110
|
+
+ incompatibleTitle: '当前开发构建能力不完整',
|
|
1111
|
+
+ incompatibleBody:
|
|
1112
|
+
+ '当前开发构建的原生能力与项目不匹配,继续使用可能导致应用无法运行。建议重新构建开发客户端。',
|
|
1113
|
+
+ unknownTitle: '无法确认当前开发构建是否适用',
|
|
1114
|
+
+ unknownBody:
|
|
1115
|
+
+ '暂时无法完成原生能力检查,继续使用可能导致应用无法运行。建议检查网络后重新进入,或重新构建开发客户端。',
|
|
1116
|
+
+ continueButtonTitle: '仍要使用',
|
|
1117
|
+
+
|
|
1118
|
+
+ // 通用按钮。
|
|
1119
|
+
+ exitButtonTitle: '退出',
|
|
1120
|
+
+ cancelButtonTitle: '取消',
|
|
1121
|
+
+ copyRetryButtonTitle: '重试',
|
|
1122
|
+
+
|
|
1123
|
+
+ // 能力问题(复制错误前,仅旧客户端回退弹窗使用)。
|
|
1124
|
+
+ copyConfirmQuestion: '仍要复制错误给智能体修复吗?',
|
|
1125
|
+
+ copyConfirmButtonTitle: '仍要复制错误',
|
|
1126
|
+
+} as const;
|
|
1127
|
+
+
|
|
1128
|
+
+export const MIAODA_PROMPT_COPY_INCOMPATIBLE_MESSAGE =
|
|
1129
|
+
+ MIAODA_PROMPT_COPY.incompatibleBody + MIAODA_PROMPT_COPY.copyConfirmQuestion;
|
|
1130
|
+
+export const MIAODA_PROMPT_COPY_UNKNOWN_MESSAGE =
|
|
1131
|
+
+ MIAODA_PROMPT_COPY.unknownBody + MIAODA_PROMPT_COPY.copyConfirmQuestion;
|
|
892
1132
|
diff --git a/src/launch/withDevTools.ios.tsx b/src/launch/withDevTools.ios.tsx
|
|
893
1133
|
index f1f686c..c64b1ca 100644
|
|
894
1134
|
--- a/src/launch/withDevTools.ios.tsx
|