@glodon-aiot/agent-cli-ui 3.7.0-alpha.2 → 3.8.0-alpha.4

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.
@@ -1,4 +1,4 @@
1
- var I = (L, P, g) => new Promise((d, N) => {
1
+ var I = (L, P, g) => new Promise((c, N) => {
2
2
  var R = (h) => {
3
3
  try {
4
4
  C(g.next(h));
@@ -11,7 +11,7 @@ var I = (L, P, g) => new Promise((d, N) => {
11
11
  } catch (S) {
12
12
  N(S);
13
13
  }
14
- }, C = (h) => h.done ? d(h.value) : Promise.resolve(h.value).then(R, A);
14
+ }, C = (h) => h.done ? c(h.value) : Promise.resolve(h.value).then(R, A);
15
15
  C((g = g.apply(L, P)).next());
16
16
  });
17
17
  import { jsx as r, Fragment as le, jsxs as b } from "react/jsx-runtime";
@@ -20,16 +20,16 @@ import { forwardRef as he, useState as E, useRef as G, useContext as pe, useEffe
20
20
  import { LoadingOutlined as ye, CloseCircleFilled as Ce, CloudUploadOutlined as be } from "@ant-design/icons";
21
21
  /* empty css */import Se from "lodash/debounce";
22
22
  import Ne from "./FileCard/index.mjs";
23
- import { IFileOrigin as Fe } from "@glodon-aiot/apis";
24
- import we from "./ClearModal/index.mjs";
23
+ import { IFileOrigin as we } from "@glodon-aiot/apis";
24
+ import Fe from "./ClearModal/index.mjs";
25
25
  import j from "../../../../components/Iconfont/index.mjs";
26
26
  import ve from "../../../../context.mjs";
27
- import { isValidImageUrlWithAnyExtension as Ie, extractFileName as Ee, FILE_NAME_MAX_LENGTH as X, fileTypes as ze } from "../../../../utils/index.mjs";
28
- import { MB as Ae } from "../../../../constant.mjs";
29
- const Ue = he((L, P) => {
27
+ import { isValidImageUrlWithAnyExtension as Ie, FILE_NAME_MAX_LENGTH as X, fileTypes as Ee } from "../../../../utils/index.mjs";
28
+ import { MB as ze } from "../../../../constant.mjs";
29
+ const Ae = he((L, P) => {
30
30
  const {
31
31
  appId: g,
32
- sid: d,
32
+ sid: c,
33
33
  onStatusChange: N,
34
34
  createSession: R,
35
35
  disabled: A = !1,
@@ -40,22 +40,22 @@ const Ue = he((L, P) => {
40
40
  afterFilesClear: K,
41
41
  docViewerUrl: q,
42
42
  isFirstSession: J
43
- } = L, [c, m] = E([]), f = G(c), [Q, U] = E([]), [Y, T] = E(!1), [F, k] = E(""), w = G(D), [$, B] = E(!1), {
43
+ } = L, [d, m] = E([]), f = G(d), [Q, U] = E([]), [Y, T] = E(!1), [w, k] = E(""), F = G(D), [$, B] = E(!1), {
44
44
  Dragger: Z
45
45
  } = W, {
46
46
  service: a,
47
47
  popupContainer: t
48
48
  } = pe(ve);
49
49
  z(() => {
50
- w.current = D;
50
+ F.current = D;
51
51
  }, [D]), xe(P, () => ({
52
52
  update: H,
53
53
  clear: _
54
54
  })), z(() => {
55
55
  J || (U([]), m([]), H());
56
- }, [d]);
57
- const H = () => d ? new Promise((e, i) => {
58
- a == null || a.getApplicationIdSessionKnowledgeFiles(g, d, {
56
+ }, [c]);
57
+ const H = () => c ? new Promise((e, i) => {
58
+ a == null || a.getApplicationIdSessionKnowledgeFiles(g, c, {
59
59
  //1是未开启
60
60
  enabled: 1
61
61
  }).then((s) => {
@@ -64,12 +64,12 @@ const Ue = he((L, P) => {
64
64
  e();
65
65
  });
66
66
  }) : Promise.resolve(), ee = (e) => I(void 0, null, function* () {
67
- d && (e == null || e.map((i) => I(void 0, null, function* () {
67
+ c && (e == null || e.map((i) => I(void 0, null, function* () {
68
68
  var s;
69
69
  try {
70
- if (yield a == null ? void 0 : a.checkFileReady(g, d, i.id)) {
70
+ if (yield a == null ? void 0 : a.checkFileReady(g, c, i.id)) {
71
71
  const l = [...f.current], p = e.findIndex((u) => u.id === i.id);
72
- p !== -1 && (l[p].status = 2), m(l), C && C(i, d);
72
+ p !== -1 && (l[p].status = 2), m(l), C && C(i, c);
73
73
  }
74
74
  } catch (n) {
75
75
  if (((s = n.cause) == null ? void 0 : s.code) === -101) {
@@ -81,8 +81,8 @@ const Ue = he((L, P) => {
81
81
  })));
82
82
  });
83
83
  z(() => {
84
- N && N(F);
85
- }, [F]);
84
+ N && N(w);
85
+ }, [w]);
86
86
  const O = (e) => I(void 0, null, function* () {
87
87
  if (e.size <= 0)
88
88
  return o.config({
@@ -92,7 +92,7 @@ const Ue = he((L, P) => {
92
92
  getContainer: void 0,
93
93
  prefixCls: "gbot-message"
94
94
  }), !1;
95
- if (Ee(e.name).length > X)
95
+ if (e.name.length > X)
96
96
  return o.config({
97
97
  getContainer: () => (t == null ? void 0 : t.current) || document.body,
98
98
  prefixCls: "gbot-message"
@@ -100,7 +100,7 @@ const Ue = he((L, P) => {
100
100
  getContainer: void 0,
101
101
  prefixCls: "gbot-message"
102
102
  }), !1;
103
- if (e.size > 50 * Ae)
103
+ if (e.size > 50 * ze)
104
104
  return o.config({
105
105
  getContainer: () => (t == null ? void 0 : t.current) || document.body,
106
106
  prefixCls: "gbot-message"
@@ -108,7 +108,7 @@ const Ue = he((L, P) => {
108
108
  getContainer: void 0,
109
109
  prefixCls: "gbot-message"
110
110
  }), !1;
111
- if (ze.some((n) => n === e.type)) {
111
+ if (Ee.some((n) => n === e.type)) {
112
112
  const n = e;
113
113
  n.status = 1, m((l) => l.length >= 10 ? l : [...l, n]);
114
114
  } else
@@ -116,24 +116,24 @@ const Ue = he((L, P) => {
116
116
  return !1;
117
117
  });
118
118
  z(() => {
119
- if (c.length < 10 ? T(!1) : T(!0), !c.length) {
119
+ if (d.length < 10 ? T(!1) : T(!0), !d.length) {
120
120
  k("");
121
121
  return;
122
122
  }
123
- const e = c.find((n) => n.status === 1), i = c.find((n) => n.status === 3);
124
- c.every((n) => n.status === 2) ? k("successed") : e ? k("process") : i && k("failed"), S && S(c);
125
- }, [c]), z(() => {
126
- f.current = c;
127
- const e = c.filter((i) => !Q.includes(i));
128
- se(e), U(c);
129
- }, [c]);
123
+ const e = d.find((n) => n.status === 1), i = d.find((n) => n.status === 3);
124
+ d.every((n) => n.status === 2) ? k("successed") : e ? k("process") : i && k("failed"), S && S(d);
125
+ }, [d]), z(() => {
126
+ f.current = d;
127
+ const e = d.filter((i) => !Q.includes(i));
128
+ se(e), U(d);
129
+ }, [d]);
130
130
  const te = (e, i, s) => I(void 0, null, function* () {
131
131
  var p;
132
132
  const n = [...f.current], l = f.current.findIndex((u) => u === s);
133
133
  l !== -1 && (n[l].id = i), m(n);
134
134
  try {
135
- const u = yield a == null ? void 0 : a.checkFileReady(g, e, i, () => w.current, void 0, (x) => {
136
- const y = [...f.current], v = f.current.findIndex((de) => de === s);
135
+ const u = yield a == null ? void 0 : a.checkFileReady(g, e, i, () => F.current, void 0, (x) => {
136
+ const y = [...f.current], v = f.current.findIndex((ce) => ce === s);
137
137
  y[v].url = x.url, m(y);
138
138
  });
139
139
  if (u) {
@@ -147,11 +147,11 @@ const Ue = he((L, P) => {
147
147
  return;
148
148
  }
149
149
  }
150
- }), ne = () => d ? Promise.resolve(d) : R(), se = (e) => {
150
+ }), ne = () => c ? Promise.resolve(c) : R(), se = (e) => {
151
151
  e.length && ne().then((i) => {
152
152
  e == null || e.forEach((s) => {
153
153
  var n;
154
- w.current = !0, (n = ce(i, s)) == null || n.then((l) => {
154
+ F.current = !0, (n = de(i, s)) == null || n.then((l) => {
155
155
  var u;
156
156
  if (!l)
157
157
  return;
@@ -160,9 +160,9 @@ const Ue = he((L, P) => {
160
160
  name: s.name,
161
161
  size: s.size,
162
162
  type: 1,
163
- origin: Fe.AECPILOT
163
+ origin: we.AECPILOT
164
164
  };
165
- w.current && ((u = re(i, p)) == null || u.then((x) => te(i, x, s)));
165
+ F.current && ((u = re(i, p)) == null || u.then((x) => te(i, x, s)));
166
166
  });
167
167
  });
168
168
  });
@@ -175,8 +175,8 @@ const Ue = he((L, P) => {
175
175
  prefixCls: "gbot-message"
176
176
  });
177
177
  }, 300), ie = (e) => {
178
- d && e != null && e.id && (a == null || a.delApplicationIdSessionKnowledgeFileId(g, d, e.id).then((i) => {
179
- const s = c.filter((n) => n.id !== e.id);
178
+ c && e != null && e.id && (a == null || a.delApplicationIdSessionKnowledgeFileId(g, c, e.id).then((i) => {
179
+ const s = d.filter((n) => n.id !== e.id);
180
180
  m(s), o.config({
181
181
  getContainer: () => (t == null ? void 0 : t.current) || document.body,
182
182
  prefixCls: "gbot-message"
@@ -220,7 +220,7 @@ const Ue = he((L, P) => {
220
220
  }), /* @__PURE__ */ r(M, {
221
221
  className: "action",
222
222
  type: "link",
223
- disabled: !c.length,
223
+ disabled: !d.length,
224
224
  onClick: () => {
225
225
  B(!0);
226
226
  },
@@ -238,7 +238,7 @@ const Ue = he((L, P) => {
238
238
  })]
239
239
  })]
240
240
  })
241
- }), ce = (e, i) => {
241
+ }), de = (e, i) => {
242
242
  if (!e)
243
243
  throw Error("session is not exist.");
244
244
  return a == null ? void 0 : a.uploadFile(e, i).catch(() => (o.config({
@@ -253,7 +253,7 @@ const Ue = he((L, P) => {
253
253
  children: /* @__PURE__ */ r(ue, {
254
254
  size: "small",
255
255
  color: "#9C24F2",
256
- count: F === "successed" ? c.length : F === "process" ? /* @__PURE__ */ r(fe, {
256
+ count: w === "successed" ? d.length : w === "process" ? /* @__PURE__ */ r(fe, {
257
257
  className: "file-action file-process",
258
258
  indicator: /* @__PURE__ */ r(ye, {
259
259
  style: {
@@ -261,7 +261,7 @@ const Ue = he((L, P) => {
261
261
  },
262
262
  spin: !0
263
263
  })
264
- }) : F === "failed" ? /* @__PURE__ */ r(Ce, {
264
+ }) : w === "failed" ? /* @__PURE__ */ r(Ce, {
265
265
  style: {
266
266
  color: "#dc4446",
267
267
  fontSize: 14
@@ -276,16 +276,16 @@ const Ue = he((L, P) => {
276
276
  })
277
277
  }), _ = () => new Promise((e) => {
278
278
  const i = f.current;
279
- if (!d)
279
+ if (!c)
280
280
  return e();
281
281
  const s = [];
282
282
  i.filter((n) => n.id).forEach((n) => s.push({
283
283
  id: n.id,
284
284
  status: n.status
285
- })), a == null || a.delApplicationIdSessionKnowledgeFile(g, d, {
285
+ })), a == null || a.delApplicationIdSessionKnowledgeFile(g, c, {
286
286
  files: s
287
287
  }).then(() => {
288
- U([]), m([]), f.current = [], K && K(), w.current = !1, e();
288
+ U([]), m([]), f.current = [], K && K(), F.current = !1, e();
289
289
  });
290
290
  });
291
291
  return /* @__PURE__ */ b("div", {
@@ -303,7 +303,7 @@ const Ue = he((L, P) => {
303
303
  getPopupContainer: () => (t == null ? void 0 : t.current) || document.body,
304
304
  content: /* @__PURE__ */ r("div", {
305
305
  className: "file-upload",
306
- children: c.length > 0 ? /* @__PURE__ */ r("div", {
306
+ children: d.length > 0 ? /* @__PURE__ */ r("div", {
307
307
  className: "upload-wrapper",
308
308
  children: /* @__PURE__ */ r("div", {
309
309
  className: "input-files",
@@ -311,7 +311,7 @@ const Ue = he((L, P) => {
311
311
  display: "flex",
312
312
  flexDirection: "column"
313
313
  },
314
- children: c == null ? void 0 : c.map((e, i) => /* @__PURE__ */ r(Ne, {
314
+ children: d == null ? void 0 : d.map((e, i) => /* @__PURE__ */ r(Ne, {
315
315
  file: e,
316
316
  actions: {
317
317
  preview: () => {
@@ -341,7 +341,7 @@ const Ue = he((L, P) => {
341
341
  ie(e);
342
342
  },
343
343
  download: () => {
344
- d && (a == null || a.getApplicationIdSessionKnowledgeFileId(g, d, e.id).then((s) => {
344
+ c && (a == null || a.getApplicationIdSessionKnowledgeFileId(g, c, e.id).then((s) => {
345
345
  if (!(s != null && s.url)) {
346
346
  o.config({
347
347
  getContainer: () => (t == null ? void 0 : t.current) || document.body,
@@ -399,7 +399,7 @@ const Ue = he((L, P) => {
399
399
  title: ae,
400
400
  trigger: "click",
401
401
  children: V
402
- }), $ && /* @__PURE__ */ r(we, {
402
+ }), $ && /* @__PURE__ */ r(Fe, {
403
403
  isvisible: $,
404
404
  onClose: (e) => {
405
405
  e === "clear" && _(), B(!1);
@@ -407,7 +407,7 @@ const Ue = he((L, P) => {
407
407
  })]
408
408
  });
409
409
  });
410
- Ue.displayName = "UploadFiles";
410
+ Ae.displayName = "UploadFiles";
411
411
  export {
412
- Ue as default
412
+ Ae as default
413
413
  };