@spzxg/cli-ui 0.6.20 → 0.6.21
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/CHANGELOG.md +10 -0
- package/README.md +14 -2
- package/dist/{cli-ui-embed-BIeQkXIU.js → cli-ui-embed-C2J-ctmG.js} +7113 -7112
- package/dist/{cli-ui-index-BOCFJA87.js → cli-ui-index-BmRUqDoS.js} +2 -2
- package/dist/{cli-ui-jszip.min-DeMMXc2T.js → cli-ui-jszip.min-BcH53SWX.js} +2 -2
- package/dist/{cli-ui-jszip.min-cpxytNM4.js → cli-ui-jszip.min-jWoEWxG3.js} +1 -1
- package/dist/{cli-ui-xlsx-BLe37Dql.js → cli-ui-xlsx-VDRLGRnM.js} +1 -1
- package/dist/cli-ui.js +1 -1
- package/package.json +1 -1
- package/src/board/fileSyncTransport.ts +2 -1
- package/src/board/frameQuote.ts +3 -1
- package/src/core/client.ts +9 -5
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { g as ms, a as vs } from "./cli-ui-embed-
|
|
2
|
-
import { r as ys } from "./cli-ui-jszip.min-
|
|
1
|
+
import { g as ms, a as vs } from "./cli-ui-embed-C2J-ctmG.js";
|
|
2
|
+
import { r as ys } from "./cli-ui-jszip.min-jWoEWxG3.js";
|
|
3
3
|
function gs(e, t) {
|
|
4
4
|
for (var n = 0; n < t.length; n++) {
|
|
5
5
|
const r = t[n];
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { a } from "./cli-ui-embed-
|
|
2
|
-
import { r as p } from "./cli-ui-jszip.min-
|
|
1
|
+
import { a } from "./cli-ui-embed-C2J-ctmG.js";
|
|
2
|
+
import { r as p } from "./cli-ui-jszip.min-jWoEWxG3.js";
|
|
3
3
|
function f(t, n) {
|
|
4
4
|
for (var o = 0; o < n.length; o++) {
|
|
5
5
|
const e = n[o];
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { c as bt } from "./cli-ui-embed-
|
|
1
|
+
import { c as bt } from "./cli-ui-embed-C2J-ctmG.js";
|
|
2
2
|
function vt(yt) {
|
|
3
3
|
throw new Error('Could not dynamically require "' + yt + '". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.');
|
|
4
4
|
}
|
|
@@ -28,7 +28,7 @@ function v(e) {
|
|
|
28
28
|
}
|
|
29
29
|
async function R(e) {
|
|
30
30
|
var E;
|
|
31
|
-
const t = await import("./cli-ui-jszip.min-
|
|
31
|
+
const t = await import("./cli-ui-jszip.min-BcH53SWX.js").then((s) => s.j), o = await (t.default ?? t).loadAsync(e), m = async (s) => {
|
|
32
32
|
const a = o.file(s);
|
|
33
33
|
return a ? a.async("string") : null;
|
|
34
34
|
}, S = await m("xl/workbook.xml");
|
package/dist/cli-ui.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { C as a, b as i, d as r, e as t, f as o, h as C, i as l, j as n, k as m, m as d, l as u, n as w, o as B, p as f } from "./cli-ui-embed-
|
|
1
|
+
import { C as a, b as i, d as r, e as t, f as o, h as C, i as l, j as n, k as m, m as d, l as u, n as w, o as B, p as f } from "./cli-ui-embed-C2J-ctmG.js";
|
|
2
2
|
export {
|
|
3
3
|
a as CliBoard,
|
|
4
4
|
i as CliBrowserView,
|
package/package.json
CHANGED
|
@@ -2,6 +2,7 @@ import { FileSyncError, validateFileSyncManifest, type FileSyncManifest, type Fi
|
|
|
2
2
|
|
|
3
3
|
const MANIFEST_MAX = 2 * 1024 * 1024;
|
|
4
4
|
const BATCH_MAX = 1024 * 1024;
|
|
5
|
+
const FILE_SYNC_READ_TIMEOUT_MS = 180_000;
|
|
5
6
|
const abortError = () => new DOMException("文件同步已取消", "AbortError");
|
|
6
7
|
|
|
7
8
|
/** Short, bounded requests only; a 304 is reusable only in the same authenticated namespace. */
|
|
@@ -12,7 +13,7 @@ export function createFileSyncTransport(fetcher: typeof fetch, pathBuilder: (job
|
|
|
12
13
|
if (signal?.aborted) throw abortError();
|
|
13
14
|
const controller = new AbortController(); let timedOut = false;
|
|
14
15
|
const cancel = () => controller.abort(); signal?.addEventListener("abort", cancel, { once: true });
|
|
15
|
-
const timer = setTimeout(() => { timedOut = true; controller.abort(); }, options.requestTimeoutMs ??
|
|
16
|
+
const timer = setTimeout(() => { timedOut = true; controller.abort(); }, options.requestTimeoutMs ?? FILE_SYNC_READ_TIMEOUT_MS);
|
|
16
17
|
let reader: ReadableStreamDefaultReader<Uint8Array> | undefined;
|
|
17
18
|
const stopped = new Promise<never>((_resolve, reject) => controller.signal.addEventListener("abort", () => reject(signal?.aborted ? abortError() : new FileSyncError("文件同步请求超时", 0, "timeout")), { once: true }));
|
|
18
19
|
try {
|
package/src/board/frameQuote.ts
CHANGED
|
@@ -24,12 +24,14 @@ const randomId = () => Math.random().toString(36).slice(2, 12) + Math.random().t
|
|
|
24
24
|
/** 每个预览一个口令 / nonce。 */
|
|
25
25
|
export const frameToken = randomId;
|
|
26
26
|
|
|
27
|
+
const ASSET_RESPONSE_TIMEOUT_MS = 180_000;
|
|
28
|
+
|
|
27
29
|
function runtimeAssetBridge() {
|
|
28
30
|
return `if(typeof History!=="undefined"&&History.prototype){["replaceState","pushState"].forEach(function(fn){var orig=History.prototype[fn];if(typeof orig==="function")History.prototype[fn]=function(){try{return orig.apply(this,arguments)}catch(e){}}})}
|
|
29
31
|
(function(){function memStore(){var d=Object.create(null);return{get length(){return Object.keys(d).length},key:function(i){return Object.keys(d)[i]||null},getItem:function(k){return Object.prototype.hasOwnProperty.call(d,String(k))?d[String(k)]:null},setItem:function(k,v){d[String(k)]=String(v)},removeItem:function(k){delete d[String(k)]},clear:function(){d=Object.create(null)}}}["localStorage","sessionStorage"].forEach(function(k){try{var st=window[k];if(!st)throw 1;st.getItem("__cli_ui_probe__")}catch(e){try{Object.defineProperty(window,k,{configurable:true,value:memStore()})}catch(e2){}}})})();
|
|
30
32
|
var pending=new Map(),blobs=new Map(),seq=0,ext=/^(?:[a-z][a-z0-9+.-]*:|\\/\\/|#)/i;
|
|
31
33
|
function isRel(u){return typeof u==="string"&&!!u.trim()&&!ext.test(u.trim())}
|
|
32
|
-
function askAsset(u){var k=u.trim();if(blobs.has(k))return blobs.get(k);var p=new Promise(function(res,rej){var id="r"+(++seq);var tm=setTimeout(function(){pending.delete(id);rej(new Error("资源加载超时"))}
|
|
34
|
+
function askAsset(u){var k=u.trim();if(blobs.has(k))return blobs.get(k);var p=new Promise(function(res,rej){var id="r"+(++seq);var tm=setTimeout(function(){pending.delete(id);rej(new Error("资源加载超时"))},${ASSET_RESPONSE_TIMEOUT_MS});pending.set(id,{res:res,rej:rej,tm:tm});post({assetReq:id,relUrl:k})});blobs.set(k,p);return p}
|
|
33
35
|
addEventListener("message",function(e){if(e.source!==parent||!e.data||e.data.cliUiAsset!==t)return;var w=pending.get(e.data.assetReq);if(!w)return;pending.delete(e.data.assetReq);clearTimeout(w.tm);if(e.data.ok&&e.data.bytes){var b=new Blob([e.data.bytes],{type:e.data.mime||"application/octet-stream"});w.res({url:URL.createObjectURL(b),bytes:e.data.bytes,mime:e.data.mime||"application/octet-stream"})}else{blobs.delete(e.data.relUrl);w.rej(new Error(e.data.error||"资源不存在"))}});
|
|
34
36
|
function patchNode(n){if(!n||n.nodeType!==1)return false;var tag=n.tagName;
|
|
35
37
|
if(tag==="SCRIPT"){var s=n.getAttribute("src");if(isRel(s)&&!n.dataset.cliBridged){n.dataset.cliBridged="1";n.removeAttribute("src");askAsset(s).then(function(r){var sc=document.createElement("script");sc.dataset.cliBridged="1";if(n.type)sc.type=n.type;sc.src=r.url;sc.onload=function(){n.dispatchEvent(new Event("load"))};sc.onerror=function(){n.dispatchEvent(new Event("error"))};(n.parentNode||document.head).appendChild(sc)},function(){n.dispatchEvent(new Event("error"))});return true}}
|
package/src/core/client.ts
CHANGED
|
@@ -41,17 +41,19 @@ export interface CenterClientOptions {
|
|
|
41
41
|
directFileLinks?: boolean;
|
|
42
42
|
/**
|
|
43
43
|
* 普通请求(不含实时流、文件下载)多久没有响应就放弃,缺省 30 秒。代理或网络挂住时组件不会一直「读取中」,
|
|
44
|
-
*
|
|
44
|
+
* 而是报「请求超时」并按各自的规则重试。看板概况至少等 3 分钟,打开任务浏览器另给 150 秒。
|
|
45
45
|
*/
|
|
46
46
|
requestTimeoutMs?: number;
|
|
47
47
|
}
|
|
48
48
|
|
|
49
49
|
/** 实时流超过这么久没有任何数据(center 每 20 秒一次心跳)就当连接已断。 */
|
|
50
50
|
export const STREAM_SILENCE_MS = 45_000;
|
|
51
|
+
/** 读取看板概况的最短等待时限,允许宿主配置更长的时限。 */
|
|
52
|
+
const BOARD_INFO_TIMEOUT_MS = 180_000;
|
|
51
53
|
/** 读文件:这么久没回响应头(节点卡住、代理挂住)就放弃。 */
|
|
52
|
-
export const FILE_HEADER_TIMEOUT_MS =
|
|
54
|
+
export const FILE_HEADER_TIMEOUT_MS = 180_000;
|
|
53
55
|
/** 读文件:传输中这么久一个字节都没收到就当断了(大文件慢慢传不算,只要还在动)。 */
|
|
54
|
-
export const FILE_STALL_MS =
|
|
56
|
+
export const FILE_STALL_MS = 180_000;
|
|
55
57
|
|
|
56
58
|
export class CenterError extends Error {
|
|
57
59
|
constructor(message: string, readonly code: string, readonly status: number, readonly detail?: unknown) {
|
|
@@ -438,6 +440,7 @@ export function createCenterClient(options: CenterClientOptions = {}): Conversat
|
|
|
438
440
|
* 不自动重连:重连策略(退避、结束后不再连)由调用方决定。
|
|
439
441
|
*/
|
|
440
442
|
board: createBoardClient(base, headers, doFetch, request, options.directFileLinks ?? (!options.token && !options.headers && !options.line),
|
|
443
|
+
Math.max(options.requestTimeoutMs ?? 0, BOARD_INFO_TIMEOUT_MS),
|
|
441
444
|
// 改动:节点限时 40 秒、中枢等 50 秒;这里等得更久,让它们的答复(超时也有明确原因)先到。
|
|
442
445
|
Math.max(options.requestTimeoutMs ?? 30_000, DIFF_TIMEOUT_MS)),
|
|
443
446
|
stream(jobId: string, handlers: StreamHandlers, intervalMs = 300, taskId?: string | null): () => void {
|
|
@@ -607,7 +610,8 @@ function createBoardClient(
|
|
|
607
610
|
doFetch: typeof fetch,
|
|
608
611
|
request: <T>(path: string, init?: RequestInit, timeoutMs?: number, fresh?: boolean) => Promise<T>,
|
|
609
612
|
directLinks: boolean,
|
|
610
|
-
|
|
613
|
+
boardInfoTimeoutMs: number,
|
|
614
|
+
diffTimeoutMs: number,
|
|
611
615
|
): BoardBackend {
|
|
612
616
|
/**
|
|
613
617
|
* 取文件:响应头限时 FILE_HEADER_TIMEOUT_MS;body() 边读边看门(FILE_STALL_MS 没数据就断),
|
|
@@ -801,7 +805,7 @@ function createBoardClient(
|
|
|
801
805
|
},
|
|
802
806
|
fileSync,
|
|
803
807
|
listFiles: (jobId, dir, options = {}) => documentRequest<DirListing>(doFetch, `${base}${boardPath(jobId, "file-sync/list", new URLSearchParams({ dir: dir || ".", limit: String(options.limit ?? 200), ...(options.cursor ? { cursor: options.cursor } : {}) }).toString())}`, { signal: options.signal }, headers),
|
|
804
|
-
info: (jobId) => request<BoardInfo>(boardPath(jobId, "board")),
|
|
808
|
+
info: (jobId) => request<BoardInfo>(boardPath(jobId, "board"), {}, boardInfoTimeoutMs),
|
|
805
809
|
pollFiles: (jobId, scope, signal) => documentRequest(doFetch, `${base}${boardPath(jobId, "file-sync/changes")}`, { method: "POST", signal, headers: { "Content-Type": "application/json" }, body: JSON.stringify(scope) }, headers),
|
|
806
810
|
stat: (jobId, path = ".") => documentRequest<DirListing | FileInfo>(doFetch, `${base}${boardPath(jobId, "file-sync/stat", `path=${encodeURIComponent(path)}`)}`, {}, headers),
|
|
807
811
|
fileUrl: (jobId, path, opts = {}) => boardFileUrl(base, jobId, path, opts.download),
|