@lark-apaas/coding-html-devserver 0.1.12-beta.1 → 0.1.13-alpha.20261110060758
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.
|
@@ -50,6 +50,19 @@ const PING_INTERVAL_LEAK_PATTERN = /pingIntervalId = setInterval\(\(\) => \{\s*i
|
|
|
50
50
|
* 已实测 Vite 7.3.x / 8.x 文本一致(fullstack 模板 vite ^7.3.1,vite-react 模板 vite ^8)。
|
|
51
51
|
*/
|
|
52
52
|
const CONNECTED_LOG_PATTERN = /console\.debug\((`\[vite\] connected\.`)\)/;
|
|
53
|
+
/**
|
|
54
|
+
* 匹配 @vite/client 断线探活入口的分支判断:
|
|
55
|
+
* function waitForSuccessfulPing(socketUrl) {
|
|
56
|
+
* if (typeof SharedWorker === "undefined") { ...页面内探活... }
|
|
57
|
+
* ...SharedWorker 内探活...
|
|
58
|
+
* Vite 默认在 SharedWorker 里发 `vite-ping`。worker 发出的请求拿不到浏览器侧(PPE 插件)注入的
|
|
59
|
+
* 泳道头(`x-tt-env` / `x-use-ppe`),探活会落到线上网关;线上网关处理不了的沙箱(如尚未上线的
|
|
60
|
+
* TAE)会让探活永远失败、patch 1 的重连永远走不到。改为恒走页面内分支,让探活与首次建链、
|
|
61
|
+
* 重连走同一泳道。代价仅是断线期间页面 DevTools 多出浏览器原生的 WebSocket 失败报错(不经过
|
|
62
|
+
* console 方法,不影响 console 劫持与埋点)。已实测 Vite 7.3.x / 8.0.x ~ 8.3.x 文本一致。
|
|
63
|
+
*/
|
|
64
|
+
const PING_IN_WORKER_PATTERN = /(function waitForSuccessfulPing\(socketUrl\) \{\s*if \()typeof SharedWorker === "undefined"(\))/;
|
|
65
|
+
const PING_IN_PAGE_MARKER = /function waitForSuccessfulPing\(socketUrl\) \{\s*if \(true\)/;
|
|
53
66
|
function viteClientPatchPlugin() {
|
|
54
67
|
return {
|
|
55
68
|
name: 'miaoda-html-vite-client-patch',
|
|
@@ -107,6 +120,14 @@ function viteClientPatchPlugin() {
|
|
|
107
120
|
'devServer-reconnected NOT reportable and disconnect dedup will latch — ' +
|
|
108
121
|
'Vite client.mjs may have changed.');
|
|
109
122
|
}
|
|
123
|
+
// patch 6: 断线探活改在页面内发(不走 SharedWorker),让探活带上浏览器侧注入的泳道头
|
|
124
|
+
if (PING_IN_WORKER_PATTERN.test(patched)) {
|
|
125
|
+
patched = patched.replace(PING_IN_WORKER_PATTERN, '$1true$2');
|
|
126
|
+
}
|
|
127
|
+
else if (!PING_IN_PAGE_MARKER.test(patched)) {
|
|
128
|
+
console.warn('[miaoda-html-vite-client-patch] ping-in-worker pattern not found in @vite/client; ' +
|
|
129
|
+
'vite-ping will NOT carry lane headers — Vite client.mjs may have changed.');
|
|
130
|
+
}
|
|
110
131
|
return patched === code ? undefined : { code: patched };
|
|
111
132
|
},
|
|
112
133
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lark-apaas/coding-html-devserver",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.13-alpha.20261110060758",
|
|
4
4
|
"description": "Dev/build toolchain for the miaoda-coding html (pure HTML) stack. Wraps vite (dev + HMR) behind a bin so the template never sees vite; build is pure-copy + platform-script injection + optional minify.",
|
|
5
5
|
"main": "./lib/index.js",
|
|
6
6
|
"types": "./lib/index.d.ts",
|