@chatu-ai/builder-sdk-vue 0.7.2 → 0.7.3
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/dist/useSandboxStatus.js +20 -4
- package/package.json +3 -3
package/dist/useSandboxStatus.js
CHANGED
|
@@ -14,17 +14,33 @@ export function useSandboxStatus(client, conversationId, opts = {}) {
|
|
|
14
14
|
const clearI = opts.clearInterval ?? globalThis.clearInterval.bind(globalThis);
|
|
15
15
|
const pollMs = opts.pollMs ?? 3_000;
|
|
16
16
|
const idlePollMs = opts.idlePollMs ?? 60_000;
|
|
17
|
-
const hibernatedPollMs = opts.hibernatedPollMs ??
|
|
17
|
+
const hibernatedPollMs = opts.hibernatedPollMs ?? 30_000;
|
|
18
18
|
let lastPoll = 0;
|
|
19
|
+
// 过渡态/编译中持续过久时逐级退避(避免异常卡住时每 3s 打一次接口):<2min 按 pollMs,<5min 4×,之后 10×
|
|
20
|
+
let fastSince = 0;
|
|
21
|
+
function backoff(base) {
|
|
22
|
+
const now = Date.now();
|
|
23
|
+
if (!fastSince)
|
|
24
|
+
fastSince = now;
|
|
25
|
+
const elapsed = now - fastSince;
|
|
26
|
+
if (elapsed > 5 * 60_000)
|
|
27
|
+
return base * 10;
|
|
28
|
+
if (elapsed > 2 * 60_000)
|
|
29
|
+
return base * 4;
|
|
30
|
+
return base;
|
|
31
|
+
}
|
|
19
32
|
function currentInterval() {
|
|
20
33
|
const s = status.value?.state;
|
|
21
34
|
if (!s || TRANSITIONAL.has(s))
|
|
22
|
-
return pollMs;
|
|
23
|
-
if (s === 'hibernated')
|
|
35
|
+
return backoff(pollMs);
|
|
36
|
+
if (s === 'hibernated') {
|
|
37
|
+
fastSince = 0;
|
|
24
38
|
return hibernatedPollMs;
|
|
39
|
+
}
|
|
25
40
|
// dev server 仍在编译:按过渡态频率轮询,就绪后自动放慢
|
|
26
41
|
if (status.value?.devServer && status.value.devServer.running && status.value.devServer.ready === false)
|
|
27
|
-
return pollMs;
|
|
42
|
+
return backoff(pollMs);
|
|
43
|
+
fastSince = 0;
|
|
28
44
|
return idlePollMs;
|
|
29
45
|
}
|
|
30
46
|
async function refresh() {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@chatu-ai/builder-sdk-vue",
|
|
3
|
-
"version": "0.7.
|
|
3
|
+
"version": "0.7.3",
|
|
4
4
|
"description": "Vue 3 bindings for @chatu-ai/builder-sdk: useBuilderChat / useSandboxStatus / usePreviewUrl",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -41,7 +41,7 @@
|
|
|
41
41
|
"node": ">=18"
|
|
42
42
|
},
|
|
43
43
|
"dependencies": {
|
|
44
|
-
"@chatu-ai/builder-sdk": "0.7.
|
|
44
|
+
"@chatu-ai/builder-sdk": "0.7.3"
|
|
45
45
|
},
|
|
46
46
|
"peerDependencies": {
|
|
47
47
|
"vue": "^3.4.0"
|
|
@@ -50,7 +50,7 @@
|
|
|
50
50
|
"typescript": "^5.7.0",
|
|
51
51
|
"vue": "^3.5.0",
|
|
52
52
|
"vitest": "^3.0.0",
|
|
53
|
-
"@chatu-ai/builder-sdk-mock": "0.7.
|
|
53
|
+
"@chatu-ai/builder-sdk-mock": "0.7.3"
|
|
54
54
|
},
|
|
55
55
|
"scripts": {
|
|
56
56
|
"build": "tsc -p tsconfig.json",
|