@glodon-aiot/react-components 3.11.1-shapshot.1765331458 → 3.13.0-alpha.27
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/es/ImageMap/index.mjs +2 -3
- package/dist/es/index.mjs +38 -41
- package/dist/lib/index.js +2 -10
- package/dist/src/index.d.ts +0 -1
- package/package.json +11 -18
- package/dist/aiot-react-components.js +0 -20191
- package/dist/aiot-react-components.umd.cjs +0 -183
- package/dist/es/components/DocumentViewer/components/DownloadButton.mjs +0 -18
- package/dist/es/components/DocumentViewer/components/ErrorAlert.mjs +0 -28
- package/dist/es/components/DocumentViewer/components/FileRenderers.mjs +0 -486
- package/dist/es/components/DocumentViewer/components/MediaRenderers.mjs +0 -46
- package/dist/es/components/DocumentViewer/components/PDFViewer/index.mjs +0 -62
- package/dist/es/components/DocumentViewer/components/PDFViewer/style.less.mjs +0 -4
- package/dist/es/components/DocumentViewer/components/ZipRenderer.mjs +0 -154
- package/dist/es/components/DocumentViewer/constants.mjs +0 -21
- package/dist/es/components/DocumentViewer/hooks/useZipViewer.mjs +0 -153
- package/dist/es/components/DocumentViewer/index.mjs +0 -380
- package/dist/es/components/DocumentViewer/style.less.mjs +0 -4
- package/dist/es/components/DocumentViewer/utils.mjs +0 -96
- package/dist/es/node_modules/@react-pdf-viewer/open/lib/styles/index.css.mjs +0 -4
- package/dist/es/node_modules/@react-pdf-viewer/toolbar/lib/styles/index.css.mjs +0 -4
- package/dist/es/utils/file.mjs +0 -17
- package/dist/src/components/DocumentViewer/components/DownloadButton.d.ts +0 -7
- package/dist/src/components/DocumentViewer/components/ErrorAlert.d.ts +0 -10
- package/dist/src/components/DocumentViewer/components/FileRenderers.d.ts +0 -23
- package/dist/src/components/DocumentViewer/components/MediaRenderers.d.ts +0 -9
- package/dist/src/components/DocumentViewer/components/PDFViewer/index.d.ts +0 -7
- package/dist/src/components/DocumentViewer/components/PdfRenderer.d.ts +0 -11
- package/dist/src/components/DocumentViewer/components/ZipRenderer.d.ts +0 -22
- package/dist/src/components/DocumentViewer/components/index.d.ts +0 -9
- package/dist/src/components/DocumentViewer/constants.d.ts +0 -21
- package/dist/src/components/DocumentViewer/hooks/index.d.ts +0 -5
- package/dist/src/components/DocumentViewer/hooks/usePdfViewer.d.ts +0 -7
- package/dist/src/components/DocumentViewer/hooks/useZipViewer.d.ts +0 -21
- package/dist/src/components/DocumentViewer/index.d.ts +0 -11
- package/dist/src/components/DocumentViewer/utils.d.ts +0 -23
- package/dist/src/utils/file.d.ts +0 -16
- package/dist/style.css +0 -1
|
@@ -1,154 +0,0 @@
|
|
|
1
|
-
import { jsx as e, jsxs as r } from "react/jsx-runtime";
|
|
2
|
-
import { Spin as m, Alert as d, Table as f } from "antd";
|
|
3
|
-
import h from "../index.mjs";
|
|
4
|
-
import { formatFileSize as p } from "../utils.mjs";
|
|
5
|
-
const v = ({
|
|
6
|
-
zipFiles: t,
|
|
7
|
-
zipLoading: a,
|
|
8
|
-
zipError: i,
|
|
9
|
-
selectedZipFile: n,
|
|
10
|
-
zipFileContent: o,
|
|
11
|
-
onFileClick: s,
|
|
12
|
-
url: c
|
|
13
|
-
}) => a ? /* @__PURE__ */ e("div", {
|
|
14
|
-
className: "document-viewer-loading",
|
|
15
|
-
children: /* @__PURE__ */ e(m, {
|
|
16
|
-
size: "large",
|
|
17
|
-
tip: "加载 ZIP 文件..."
|
|
18
|
-
})
|
|
19
|
-
}) : i && t.length === 0 ? /* @__PURE__ */ e(d, {
|
|
20
|
-
className: "document-viewer-alert-full",
|
|
21
|
-
message: "ZIP 加载失败",
|
|
22
|
-
description: i,
|
|
23
|
-
type: "error",
|
|
24
|
-
showIcon: !0,
|
|
25
|
-
action: /* @__PURE__ */ e("a", {
|
|
26
|
-
href: c,
|
|
27
|
-
target: "_blank",
|
|
28
|
-
rel: "noopener noreferrer",
|
|
29
|
-
children: "下载文件"
|
|
30
|
-
})
|
|
31
|
-
}) : /* @__PURE__ */ r("div", {
|
|
32
|
-
className: "document-viewer-zip",
|
|
33
|
-
children: [i && t.length > 0 && /* @__PURE__ */ e(d, {
|
|
34
|
-
className: "document-viewer-alert-full",
|
|
35
|
-
message: "提示",
|
|
36
|
-
description: i,
|
|
37
|
-
type: "warning",
|
|
38
|
-
showIcon: !0,
|
|
39
|
-
style: {
|
|
40
|
-
marginBottom: 16
|
|
41
|
-
}
|
|
42
|
-
}), /* @__PURE__ */ r("div", {
|
|
43
|
-
style: {
|
|
44
|
-
display: "flex",
|
|
45
|
-
height: "100%",
|
|
46
|
-
gap: "16px"
|
|
47
|
-
},
|
|
48
|
-
children: [/* @__PURE__ */ r("div", {
|
|
49
|
-
style: {
|
|
50
|
-
width: "300px",
|
|
51
|
-
borderRight: "1px solid #e8e8e8",
|
|
52
|
-
overflow: "auto",
|
|
53
|
-
display: "flex",
|
|
54
|
-
flexDirection: "column"
|
|
55
|
-
},
|
|
56
|
-
children: [/* @__PURE__ */ r("div", {
|
|
57
|
-
style: {
|
|
58
|
-
padding: "12px",
|
|
59
|
-
fontWeight: "bold",
|
|
60
|
-
borderBottom: "1px solid #e8e8e8",
|
|
61
|
-
flexShrink: 0
|
|
62
|
-
},
|
|
63
|
-
children: ["文件列表 (", t.length, ")"]
|
|
64
|
-
}), /* @__PURE__ */ e("div", {
|
|
65
|
-
style: {
|
|
66
|
-
flex: 1,
|
|
67
|
-
overflow: "auto",
|
|
68
|
-
minHeight: 0
|
|
69
|
-
},
|
|
70
|
-
children: /* @__PURE__ */ e(f, {
|
|
71
|
-
dataSource: t,
|
|
72
|
-
size: "small",
|
|
73
|
-
pagination: !1,
|
|
74
|
-
scroll: {
|
|
75
|
-
y: "100%"
|
|
76
|
-
},
|
|
77
|
-
onRow: (l) => ({
|
|
78
|
-
onClick: () => s(l.name),
|
|
79
|
-
style: {
|
|
80
|
-
cursor: "pointer",
|
|
81
|
-
backgroundColor: n === l.name ? "#e6f7ff" : "transparent"
|
|
82
|
-
}
|
|
83
|
-
}),
|
|
84
|
-
columns: [{
|
|
85
|
-
title: "文件名",
|
|
86
|
-
dataIndex: "name",
|
|
87
|
-
key: "name",
|
|
88
|
-
ellipsis: !0,
|
|
89
|
-
render: (l) => /* @__PURE__ */ e("span", {
|
|
90
|
-
title: l,
|
|
91
|
-
children: l.split("/").pop()
|
|
92
|
-
})
|
|
93
|
-
}, {
|
|
94
|
-
title: "大小",
|
|
95
|
-
dataIndex: "size",
|
|
96
|
-
key: "size",
|
|
97
|
-
width: 80,
|
|
98
|
-
render: (l) => p(l)
|
|
99
|
-
}]
|
|
100
|
-
})
|
|
101
|
-
})]
|
|
102
|
-
}), /* @__PURE__ */ e("div", {
|
|
103
|
-
style: {
|
|
104
|
-
flex: 1,
|
|
105
|
-
overflow: "auto",
|
|
106
|
-
display: "flex",
|
|
107
|
-
flexDirection: "column"
|
|
108
|
-
},
|
|
109
|
-
children: n && o ? /* @__PURE__ */ r("div", {
|
|
110
|
-
style: {
|
|
111
|
-
display: "flex",
|
|
112
|
-
flexDirection: "column",
|
|
113
|
-
height: "100%"
|
|
114
|
-
},
|
|
115
|
-
children: [/* @__PURE__ */ e("div", {
|
|
116
|
-
style: {
|
|
117
|
-
padding: "12px",
|
|
118
|
-
borderBottom: "1px solid #e8e8e8",
|
|
119
|
-
fontWeight: "bold",
|
|
120
|
-
flexShrink: 0
|
|
121
|
-
},
|
|
122
|
-
children: o.name
|
|
123
|
-
}), /* @__PURE__ */ e("div", {
|
|
124
|
-
style: {
|
|
125
|
-
flex: 1,
|
|
126
|
-
overflow: "auto",
|
|
127
|
-
padding: "16px"
|
|
128
|
-
},
|
|
129
|
-
children: /* @__PURE__ */ e(h, {
|
|
130
|
-
url: o.blobUrl,
|
|
131
|
-
fileName: o.name,
|
|
132
|
-
showToolbar: !1,
|
|
133
|
-
style: {
|
|
134
|
-
height: "100%",
|
|
135
|
-
width: "100%"
|
|
136
|
-
}
|
|
137
|
-
})
|
|
138
|
-
})]
|
|
139
|
-
}) : /* @__PURE__ */ e("div", {
|
|
140
|
-
style: {
|
|
141
|
-
display: "flex",
|
|
142
|
-
alignItems: "center",
|
|
143
|
-
justifyContent: "center",
|
|
144
|
-
height: "100%",
|
|
145
|
-
color: "#999"
|
|
146
|
-
},
|
|
147
|
-
children: "请从左侧列表中选择文件进行预览"
|
|
148
|
-
})
|
|
149
|
-
})]
|
|
150
|
-
})]
|
|
151
|
-
});
|
|
152
|
-
export {
|
|
153
|
-
v as ZipRenderer
|
|
154
|
-
};
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
const _ = 5242880, I = 2097152, S = 2097152, o = 5242880, t = 5242880, E = 2097152, s = 2097152, n = 2097152, A = 2097152, c = 104857600, M = 104857600, X = 1e4, Z = 1e4, L = 5e3, e = 1e3, N = 5242880, P = 3e4, F = ["text", "json", "csv", "tsv", "markdown", "html", "xml", "jsonl", "image", "pdf", "code"];
|
|
2
|
-
export {
|
|
3
|
-
Z as MAX_CSV_ROWS,
|
|
4
|
-
o as MAX_CSV_SIZE,
|
|
5
|
-
X as MAX_DISPLAY_LINES,
|
|
6
|
-
I as MAX_DISPLAY_SIZE,
|
|
7
|
-
c as MAX_FALLBACK_SIZE,
|
|
8
|
-
_ as MAX_FILE_SIZE,
|
|
9
|
-
A as MAX_HIGHLIGHT_SIZE,
|
|
10
|
-
L as MAX_JSONL_LINES,
|
|
11
|
-
E as MAX_JSONL_SIZE,
|
|
12
|
-
S as MAX_JSON_SIZE,
|
|
13
|
-
s as MAX_MARKDOWN_SIZE,
|
|
14
|
-
t as MAX_TSV_SIZE,
|
|
15
|
-
n as MAX_XML_SIZE,
|
|
16
|
-
e as MAX_ZIP_FILES,
|
|
17
|
-
M as MAX_ZIP_FILE_SIZE,
|
|
18
|
-
F as SAFE_FILE_TYPES,
|
|
19
|
-
N as ZIP_CHUNK_SIZE,
|
|
20
|
-
P as ZIP_ENTRIES_TIMEOUT
|
|
21
|
-
};
|
|
@@ -1,153 +0,0 @@
|
|
|
1
|
-
var U = (c, Z, f) => new Promise((I, u) => {
|
|
2
|
-
var P = (w) => {
|
|
3
|
-
try {
|
|
4
|
-
E(f.next(w));
|
|
5
|
-
} catch (t) {
|
|
6
|
-
u(t);
|
|
7
|
-
}
|
|
8
|
-
}, p = (w) => {
|
|
9
|
-
try {
|
|
10
|
-
E(f.throw(w));
|
|
11
|
-
} catch (t) {
|
|
12
|
-
u(t);
|
|
13
|
-
}
|
|
14
|
-
}, E = (w) => w.done ? I(w.value) : Promise.resolve(w.value).then(P, p);
|
|
15
|
-
E((f = f.apply(c, Z)).next());
|
|
16
|
-
});
|
|
17
|
-
import { useState as h, useEffect as _, useCallback as M } from "react";
|
|
18
|
-
import { configure as A, BlobReader as L, ZipReader as R, HttpRangeReader as k, BlobWriter as H } from "@zip.js/zip.js";
|
|
19
|
-
import { ZIP_CHUNK_SIZE as O, MAX_FALLBACK_SIZE as y, MAX_ZIP_FILES as m, ZIP_ENTRIES_TIMEOUT as B, MAX_ZIP_FILE_SIZE as C, SAFE_FILE_TYPES as D } from "../constants.mjs";
|
|
20
|
-
import { checkRangeSupport as j, getFileSize as v } from "../utils.mjs";
|
|
21
|
-
import { getFileExtension as x, getFileType as W } from "../../../utils/file.mjs";
|
|
22
|
-
const S = {
|
|
23
|
-
filenameEncoding: "utf-8"
|
|
24
|
-
}, Q = (c) => {
|
|
25
|
-
const [Z, f] = h([]), [I, u] = h(!0), [P, p] = h(null), [E, w] = h(null), [t, T] = h(null);
|
|
26
|
-
_(() => {
|
|
27
|
-
if (!c) {
|
|
28
|
-
p("文件URL不能为空"), u(!1);
|
|
29
|
-
return;
|
|
30
|
-
}
|
|
31
|
-
u(!0), p(null), f([]), w(null), t != null && t.blobUrl && (URL.revokeObjectURL(t.blobUrl), T(null));
|
|
32
|
-
let e = null;
|
|
33
|
-
U(void 0, null, function* () {
|
|
34
|
-
try {
|
|
35
|
-
A({
|
|
36
|
-
chunkSize: O,
|
|
37
|
-
useWebWorkers: !1
|
|
38
|
-
});
|
|
39
|
-
const {
|
|
40
|
-
supportsRange: n,
|
|
41
|
-
fileSize: r
|
|
42
|
-
} = yield j(c);
|
|
43
|
-
if (n) {
|
|
44
|
-
const o = new k(c);
|
|
45
|
-
e = new R(o, S);
|
|
46
|
-
const b = (yield Promise.race([e.getEntries(), new Promise((i, a) => setTimeout(() => a(new Error("读取 ZIP 目录结构超时")), B))])).filter((i) => !i.directory).map((i) => ({
|
|
47
|
-
name: i.filename,
|
|
48
|
-
size: i.uncompressedSize || 0,
|
|
49
|
-
isDirectory: !1
|
|
50
|
-
}));
|
|
51
|
-
b.sort((i, a) => i.name.localeCompare(a.name)), b.length > m ? (p(`ZIP 文件包含 ${b.length} 个文件,仅显示前 ${m} 个`), f(b.slice(0, m))) : f(b);
|
|
52
|
-
} else {
|
|
53
|
-
if (r > y)
|
|
54
|
-
throw new Error(`服务器不支持 HTTP Range 请求,且文件过大(${Math.round(r / 1024 / 1024)}MB),无法预览。请下载后查看。`);
|
|
55
|
-
const o = yield fetch(c);
|
|
56
|
-
if (!o.ok)
|
|
57
|
-
throw new Error(`HTTP error! status: ${o.status}`);
|
|
58
|
-
const g = yield o.blob(), b = new L(g);
|
|
59
|
-
e = new R(b, S);
|
|
60
|
-
const a = (yield e.getEntries()).filter((s) => !s.directory).map((s) => ({
|
|
61
|
-
name: s.filename,
|
|
62
|
-
size: s.uncompressedSize || 0,
|
|
63
|
-
isDirectory: !1
|
|
64
|
-
}));
|
|
65
|
-
a.sort((s, l) => s.name.localeCompare(l.name)), a.length > m ? (p(`ZIP 文件包含 ${a.length} 个文件,仅显示前 ${m} 个`), f(a.slice(0, m))) : f(a);
|
|
66
|
-
}
|
|
67
|
-
e && (yield e.close()), u(!1);
|
|
68
|
-
} catch (n) {
|
|
69
|
-
if (e)
|
|
70
|
-
try {
|
|
71
|
-
yield e.close();
|
|
72
|
-
} catch (o) {
|
|
73
|
-
}
|
|
74
|
-
const r = n.message || n.toString() || "加载 ZIP 文件失败";
|
|
75
|
-
if (r.includes("Range") || r.includes("range") || r.includes("HTTP Range not supported") || r.includes("超时"))
|
|
76
|
-
try {
|
|
77
|
-
const o = yield v(c);
|
|
78
|
-
if (o > y)
|
|
79
|
-
throw new Error(`文件过大(${Math.round(o / 1024 / 1024)}MB),无法通过 Range 请求加载,且文件过大无法下载整个文件预览。请下载后查看。`);
|
|
80
|
-
const g = yield fetch(c);
|
|
81
|
-
if (!g.ok)
|
|
82
|
-
throw new Error(`HTTP error! status: ${g.status}`);
|
|
83
|
-
const b = yield g.blob(), i = new L(b);
|
|
84
|
-
e = new R(i, S);
|
|
85
|
-
const s = (yield e.getEntries()).filter((l) => !l.directory).map((l) => ({
|
|
86
|
-
name: l.filename,
|
|
87
|
-
size: l.uncompressedSize || 0,
|
|
88
|
-
isDirectory: !1
|
|
89
|
-
}));
|
|
90
|
-
s.sort((l, d) => l.name.localeCompare(d.name)), s.length > m ? (p(`ZIP 文件包含 ${s.length} 个文件,仅显示前 ${m} 个`), f(s.slice(0, m))) : f(s), e && (yield e.close()), u(!1);
|
|
91
|
-
return;
|
|
92
|
-
} catch (o) {
|
|
93
|
-
const g = o.message || o.toString();
|
|
94
|
-
p(`ZIP 文件加载失败: ${r}。Fallback 方案也失败: ${g}`);
|
|
95
|
-
}
|
|
96
|
-
else
|
|
97
|
-
p(r);
|
|
98
|
-
u(!1);
|
|
99
|
-
}
|
|
100
|
-
});
|
|
101
|
-
}, [c]);
|
|
102
|
-
const z = M((e) => U(void 0, null, function* () {
|
|
103
|
-
if (E === e && t) {
|
|
104
|
-
w(null), t.blobUrl && URL.revokeObjectURL(t.blobUrl), T(null);
|
|
105
|
-
return;
|
|
106
|
-
}
|
|
107
|
-
w(e);
|
|
108
|
-
try {
|
|
109
|
-
let n = null, r;
|
|
110
|
-
try {
|
|
111
|
-
const s = new k(c);
|
|
112
|
-
n = new R(s, S), r = (yield n.getEntries()).find((d) => d.filename === e);
|
|
113
|
-
} catch (s) {
|
|
114
|
-
const l = yield fetch(c);
|
|
115
|
-
if (!l.ok)
|
|
116
|
-
throw new Error(`HTTP error! status: ${l.status}`);
|
|
117
|
-
const d = yield l.blob(), $ = new L(d);
|
|
118
|
-
n = new R($, S), r = (yield n.getEntries()).find((F) => F.filename === e);
|
|
119
|
-
}
|
|
120
|
-
if (!r)
|
|
121
|
-
throw new Error("文件不存在");
|
|
122
|
-
if (r.directory)
|
|
123
|
-
throw new Error("无法预览目录");
|
|
124
|
-
if ((r.uncompressedSize || 0) > C)
|
|
125
|
-
throw new Error("文件过大(超过 100MB),无法预览");
|
|
126
|
-
const g = yield r.getData(new H()), b = URL.createObjectURL(g), i = x(e), a = W(i);
|
|
127
|
-
if (!D.includes(a))
|
|
128
|
-
throw new Error(`不支持预览 ${i || "未知"} 格式的文件`);
|
|
129
|
-
T({
|
|
130
|
-
name: e,
|
|
131
|
-
blobUrl: b,
|
|
132
|
-
type: a
|
|
133
|
-
}), n && (yield n.close());
|
|
134
|
-
} catch (n) {
|
|
135
|
-
const r = n.message || n.toString() || "预览文件失败";
|
|
136
|
-
p(r);
|
|
137
|
-
}
|
|
138
|
-
}), [c, E, t]);
|
|
139
|
-
return _(() => () => {
|
|
140
|
-
t != null && t.blobUrl && URL.revokeObjectURL(t.blobUrl);
|
|
141
|
-
}, [t]), {
|
|
142
|
-
zipFiles: Z,
|
|
143
|
-
zipLoading: I,
|
|
144
|
-
zipError: P,
|
|
145
|
-
selectedZipFile: E,
|
|
146
|
-
zipFileContent: t,
|
|
147
|
-
handleFileClick: z,
|
|
148
|
-
setSelectedZipFile: w
|
|
149
|
-
};
|
|
150
|
-
};
|
|
151
|
-
export {
|
|
152
|
-
Q as useZipViewer
|
|
153
|
-
};
|