@chatbi-v/core 1.0.3 → 1.0.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.
- package/README.md +1 -1
- package/dist/api/engine.d.ts +26 -1
- package/dist/chunk-G3OU7D3Y.mjs +47 -0
- package/dist/components/PluginSlot.d.ts +2 -0
- package/dist/components/SlotSkeletons.d.ts +3 -1
- package/dist/config-manager-ZARQENTB.mjs +8 -0
- package/dist/domain/models.d.ts +25 -0
- package/dist/domain/plugin-manager.d.ts +10 -0
- package/dist/hooks/use-plugin-loader.d.ts +2 -0
- package/dist/index.cjs +326 -473
- package/dist/index.mjs +284 -513
- package/dist/ports/api-port.d.ts +32 -0
- package/dist/ports/plugin-port.d.ts +11 -0
- package/dist/utils/index.d.ts +1 -1
- package/dist/utils/url.d.ts +16 -0
- package/package.json +4 -3
- package/dist/testing/plugin-contract.d.ts +0 -6
- package/dist/utils/stream-parser.d.ts +0 -26
package/dist/index.mjs
CHANGED
|
@@ -1,378 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
6
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
-
var __commonJS = (cb, mod) => function __require() {
|
|
8
|
-
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
|
|
9
|
-
};
|
|
10
|
-
var __copyProps = (to, from, except, desc) => {
|
|
11
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
-
for (let key of __getOwnPropNames(from))
|
|
13
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
-
}
|
|
16
|
-
return to;
|
|
17
|
-
};
|
|
18
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
19
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
|
20
|
-
// file that has been converted to a CommonJS file using a Babel-
|
|
21
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
22
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
23
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
24
|
-
mod
|
|
25
|
-
));
|
|
26
|
-
|
|
27
|
-
// ../../node_modules/.pnpm/dayjs@1.11.19/node_modules/dayjs/dayjs.min.js
|
|
28
|
-
var require_dayjs_min = __commonJS({
|
|
29
|
-
"../../node_modules/.pnpm/dayjs@1.11.19/node_modules/dayjs/dayjs.min.js"(exports, module) {
|
|
30
|
-
"use strict";
|
|
31
|
-
!(function(t, e) {
|
|
32
|
-
"object" == typeof exports && "undefined" != typeof module ? module.exports = e() : "function" == typeof define && define.amd ? define(e) : (t = "undefined" != typeof globalThis ? globalThis : t || self).dayjs = e();
|
|
33
|
-
})(exports, (function() {
|
|
34
|
-
"use strict";
|
|
35
|
-
var t = 1e3, e = 6e4, n = 36e5, r = "millisecond", i = "second", s = "minute", u = "hour", a = "day", o = "week", c = "month", f = "quarter", h = "year", d = "date", l = "Invalid Date", $ = /^(\d{4})[-/]?(\d{1,2})?[-/]?(\d{0,2})[Tt\s]*(\d{1,2})?:?(\d{1,2})?:?(\d{1,2})?[.:]?(\d+)?$/, y = /\[([^\]]+)]|Y{1,4}|M{1,4}|D{1,2}|d{1,4}|H{1,2}|h{1,2}|a|A|m{1,2}|s{1,2}|Z{1,2}|SSS/g, M = { name: "en", weekdays: "Sunday_Monday_Tuesday_Wednesday_Thursday_Friday_Saturday".split("_"), months: "January_February_March_April_May_June_July_August_September_October_November_December".split("_"), ordinal: function(t2) {
|
|
36
|
-
var e2 = ["th", "st", "nd", "rd"], n2 = t2 % 100;
|
|
37
|
-
return "[" + t2 + (e2[(n2 - 20) % 10] || e2[n2] || e2[0]) + "]";
|
|
38
|
-
} }, m = function(t2, e2, n2) {
|
|
39
|
-
var r2 = String(t2);
|
|
40
|
-
return !r2 || r2.length >= e2 ? t2 : "" + Array(e2 + 1 - r2.length).join(n2) + t2;
|
|
41
|
-
}, v = { s: m, z: function(t2) {
|
|
42
|
-
var e2 = -t2.utcOffset(), n2 = Math.abs(e2), r2 = Math.floor(n2 / 60), i2 = n2 % 60;
|
|
43
|
-
return (e2 <= 0 ? "+" : "-") + m(r2, 2, "0") + ":" + m(i2, 2, "0");
|
|
44
|
-
}, m: function t2(e2, n2) {
|
|
45
|
-
if (e2.date() < n2.date()) return -t2(n2, e2);
|
|
46
|
-
var r2 = 12 * (n2.year() - e2.year()) + (n2.month() - e2.month()), i2 = e2.clone().add(r2, c), s2 = n2 - i2 < 0, u2 = e2.clone().add(r2 + (s2 ? -1 : 1), c);
|
|
47
|
-
return +(-(r2 + (n2 - i2) / (s2 ? i2 - u2 : u2 - i2)) || 0);
|
|
48
|
-
}, a: function(t2) {
|
|
49
|
-
return t2 < 0 ? Math.ceil(t2) || 0 : Math.floor(t2);
|
|
50
|
-
}, p: function(t2) {
|
|
51
|
-
return { M: c, y: h, w: o, d: a, D: d, h: u, m: s, s: i, ms: r, Q: f }[t2] || String(t2 || "").toLowerCase().replace(/s$/, "");
|
|
52
|
-
}, u: function(t2) {
|
|
53
|
-
return void 0 === t2;
|
|
54
|
-
} }, g = "en", D = {};
|
|
55
|
-
D[g] = M;
|
|
56
|
-
var p = "$isDayjsObject", S = function(t2) {
|
|
57
|
-
return t2 instanceof _ || !(!t2 || !t2[p]);
|
|
58
|
-
}, w = function t2(e2, n2, r2) {
|
|
59
|
-
var i2;
|
|
60
|
-
if (!e2) return g;
|
|
61
|
-
if ("string" == typeof e2) {
|
|
62
|
-
var s2 = e2.toLowerCase();
|
|
63
|
-
D[s2] && (i2 = s2), n2 && (D[s2] = n2, i2 = s2);
|
|
64
|
-
var u2 = e2.split("-");
|
|
65
|
-
if (!i2 && u2.length > 1) return t2(u2[0]);
|
|
66
|
-
} else {
|
|
67
|
-
var a2 = e2.name;
|
|
68
|
-
D[a2] = e2, i2 = a2;
|
|
69
|
-
}
|
|
70
|
-
return !r2 && i2 && (g = i2), i2 || !r2 && g;
|
|
71
|
-
}, O = function(t2, e2) {
|
|
72
|
-
if (S(t2)) return t2.clone();
|
|
73
|
-
var n2 = "object" == typeof e2 ? e2 : {};
|
|
74
|
-
return n2.date = t2, n2.args = arguments, new _(n2);
|
|
75
|
-
}, b = v;
|
|
76
|
-
b.l = w, b.i = S, b.w = function(t2, e2) {
|
|
77
|
-
return O(t2, { locale: e2.$L, utc: e2.$u, x: e2.$x, $offset: e2.$offset });
|
|
78
|
-
};
|
|
79
|
-
var _ = (function() {
|
|
80
|
-
function M2(t2) {
|
|
81
|
-
this.$L = w(t2.locale, null, true), this.parse(t2), this.$x = this.$x || t2.x || {}, this[p] = true;
|
|
82
|
-
}
|
|
83
|
-
var m2 = M2.prototype;
|
|
84
|
-
return m2.parse = function(t2) {
|
|
85
|
-
this.$d = (function(t3) {
|
|
86
|
-
var e2 = t3.date, n2 = t3.utc;
|
|
87
|
-
if (null === e2) return /* @__PURE__ */ new Date(NaN);
|
|
88
|
-
if (b.u(e2)) return /* @__PURE__ */ new Date();
|
|
89
|
-
if (e2 instanceof Date) return new Date(e2);
|
|
90
|
-
if ("string" == typeof e2 && !/Z$/i.test(e2)) {
|
|
91
|
-
var r2 = e2.match($);
|
|
92
|
-
if (r2) {
|
|
93
|
-
var i2 = r2[2] - 1 || 0, s2 = (r2[7] || "0").substring(0, 3);
|
|
94
|
-
return n2 ? new Date(Date.UTC(r2[1], i2, r2[3] || 1, r2[4] || 0, r2[5] || 0, r2[6] || 0, s2)) : new Date(r2[1], i2, r2[3] || 1, r2[4] || 0, r2[5] || 0, r2[6] || 0, s2);
|
|
95
|
-
}
|
|
96
|
-
}
|
|
97
|
-
return new Date(e2);
|
|
98
|
-
})(t2), this.init();
|
|
99
|
-
}, m2.init = function() {
|
|
100
|
-
var t2 = this.$d;
|
|
101
|
-
this.$y = t2.getFullYear(), this.$M = t2.getMonth(), this.$D = t2.getDate(), this.$W = t2.getDay(), this.$H = t2.getHours(), this.$m = t2.getMinutes(), this.$s = t2.getSeconds(), this.$ms = t2.getMilliseconds();
|
|
102
|
-
}, m2.$utils = function() {
|
|
103
|
-
return b;
|
|
104
|
-
}, m2.isValid = function() {
|
|
105
|
-
return !(this.$d.toString() === l);
|
|
106
|
-
}, m2.isSame = function(t2, e2) {
|
|
107
|
-
var n2 = O(t2);
|
|
108
|
-
return this.startOf(e2) <= n2 && n2 <= this.endOf(e2);
|
|
109
|
-
}, m2.isAfter = function(t2, e2) {
|
|
110
|
-
return O(t2) < this.startOf(e2);
|
|
111
|
-
}, m2.isBefore = function(t2, e2) {
|
|
112
|
-
return this.endOf(e2) < O(t2);
|
|
113
|
-
}, m2.$g = function(t2, e2, n2) {
|
|
114
|
-
return b.u(t2) ? this[e2] : this.set(n2, t2);
|
|
115
|
-
}, m2.unix = function() {
|
|
116
|
-
return Math.floor(this.valueOf() / 1e3);
|
|
117
|
-
}, m2.valueOf = function() {
|
|
118
|
-
return this.$d.getTime();
|
|
119
|
-
}, m2.startOf = function(t2, e2) {
|
|
120
|
-
var n2 = this, r2 = !!b.u(e2) || e2, f2 = b.p(t2), l2 = function(t3, e3) {
|
|
121
|
-
var i2 = b.w(n2.$u ? Date.UTC(n2.$y, e3, t3) : new Date(n2.$y, e3, t3), n2);
|
|
122
|
-
return r2 ? i2 : i2.endOf(a);
|
|
123
|
-
}, $2 = function(t3, e3) {
|
|
124
|
-
return b.w(n2.toDate()[t3].apply(n2.toDate("s"), (r2 ? [0, 0, 0, 0] : [23, 59, 59, 999]).slice(e3)), n2);
|
|
125
|
-
}, y2 = this.$W, M3 = this.$M, m3 = this.$D, v2 = "set" + (this.$u ? "UTC" : "");
|
|
126
|
-
switch (f2) {
|
|
127
|
-
case h:
|
|
128
|
-
return r2 ? l2(1, 0) : l2(31, 11);
|
|
129
|
-
case c:
|
|
130
|
-
return r2 ? l2(1, M3) : l2(0, M3 + 1);
|
|
131
|
-
case o:
|
|
132
|
-
var g2 = this.$locale().weekStart || 0, D2 = (y2 < g2 ? y2 + 7 : y2) - g2;
|
|
133
|
-
return l2(r2 ? m3 - D2 : m3 + (6 - D2), M3);
|
|
134
|
-
case a:
|
|
135
|
-
case d:
|
|
136
|
-
return $2(v2 + "Hours", 0);
|
|
137
|
-
case u:
|
|
138
|
-
return $2(v2 + "Minutes", 1);
|
|
139
|
-
case s:
|
|
140
|
-
return $2(v2 + "Seconds", 2);
|
|
141
|
-
case i:
|
|
142
|
-
return $2(v2 + "Milliseconds", 3);
|
|
143
|
-
default:
|
|
144
|
-
return this.clone();
|
|
145
|
-
}
|
|
146
|
-
}, m2.endOf = function(t2) {
|
|
147
|
-
return this.startOf(t2, false);
|
|
148
|
-
}, m2.$set = function(t2, e2) {
|
|
149
|
-
var n2, o2 = b.p(t2), f2 = "set" + (this.$u ? "UTC" : ""), l2 = (n2 = {}, n2[a] = f2 + "Date", n2[d] = f2 + "Date", n2[c] = f2 + "Month", n2[h] = f2 + "FullYear", n2[u] = f2 + "Hours", n2[s] = f2 + "Minutes", n2[i] = f2 + "Seconds", n2[r] = f2 + "Milliseconds", n2)[o2], $2 = o2 === a ? this.$D + (e2 - this.$W) : e2;
|
|
150
|
-
if (o2 === c || o2 === h) {
|
|
151
|
-
var y2 = this.clone().set(d, 1);
|
|
152
|
-
y2.$d[l2]($2), y2.init(), this.$d = y2.set(d, Math.min(this.$D, y2.daysInMonth())).$d;
|
|
153
|
-
} else l2 && this.$d[l2]($2);
|
|
154
|
-
return this.init(), this;
|
|
155
|
-
}, m2.set = function(t2, e2) {
|
|
156
|
-
return this.clone().$set(t2, e2);
|
|
157
|
-
}, m2.get = function(t2) {
|
|
158
|
-
return this[b.p(t2)]();
|
|
159
|
-
}, m2.add = function(r2, f2) {
|
|
160
|
-
var d2, l2 = this;
|
|
161
|
-
r2 = Number(r2);
|
|
162
|
-
var $2 = b.p(f2), y2 = function(t2) {
|
|
163
|
-
var e2 = O(l2);
|
|
164
|
-
return b.w(e2.date(e2.date() + Math.round(t2 * r2)), l2);
|
|
165
|
-
};
|
|
166
|
-
if ($2 === c) return this.set(c, this.$M + r2);
|
|
167
|
-
if ($2 === h) return this.set(h, this.$y + r2);
|
|
168
|
-
if ($2 === a) return y2(1);
|
|
169
|
-
if ($2 === o) return y2(7);
|
|
170
|
-
var M3 = (d2 = {}, d2[s] = e, d2[u] = n, d2[i] = t, d2)[$2] || 1, m3 = this.$d.getTime() + r2 * M3;
|
|
171
|
-
return b.w(m3, this);
|
|
172
|
-
}, m2.subtract = function(t2, e2) {
|
|
173
|
-
return this.add(-1 * t2, e2);
|
|
174
|
-
}, m2.format = function(t2) {
|
|
175
|
-
var e2 = this, n2 = this.$locale();
|
|
176
|
-
if (!this.isValid()) return n2.invalidDate || l;
|
|
177
|
-
var r2 = t2 || "YYYY-MM-DDTHH:mm:ssZ", i2 = b.z(this), s2 = this.$H, u2 = this.$m, a2 = this.$M, o2 = n2.weekdays, c2 = n2.months, f2 = n2.meridiem, h2 = function(t3, n3, i3, s3) {
|
|
178
|
-
return t3 && (t3[n3] || t3(e2, r2)) || i3[n3].slice(0, s3);
|
|
179
|
-
}, d2 = function(t3) {
|
|
180
|
-
return b.s(s2 % 12 || 12, t3, "0");
|
|
181
|
-
}, $2 = f2 || function(t3, e3, n3) {
|
|
182
|
-
var r3 = t3 < 12 ? "AM" : "PM";
|
|
183
|
-
return n3 ? r3.toLowerCase() : r3;
|
|
184
|
-
};
|
|
185
|
-
return r2.replace(y, (function(t3, r3) {
|
|
186
|
-
return r3 || (function(t4) {
|
|
187
|
-
switch (t4) {
|
|
188
|
-
case "YY":
|
|
189
|
-
return String(e2.$y).slice(-2);
|
|
190
|
-
case "YYYY":
|
|
191
|
-
return b.s(e2.$y, 4, "0");
|
|
192
|
-
case "M":
|
|
193
|
-
return a2 + 1;
|
|
194
|
-
case "MM":
|
|
195
|
-
return b.s(a2 + 1, 2, "0");
|
|
196
|
-
case "MMM":
|
|
197
|
-
return h2(n2.monthsShort, a2, c2, 3);
|
|
198
|
-
case "MMMM":
|
|
199
|
-
return h2(c2, a2);
|
|
200
|
-
case "D":
|
|
201
|
-
return e2.$D;
|
|
202
|
-
case "DD":
|
|
203
|
-
return b.s(e2.$D, 2, "0");
|
|
204
|
-
case "d":
|
|
205
|
-
return String(e2.$W);
|
|
206
|
-
case "dd":
|
|
207
|
-
return h2(n2.weekdaysMin, e2.$W, o2, 2);
|
|
208
|
-
case "ddd":
|
|
209
|
-
return h2(n2.weekdaysShort, e2.$W, o2, 3);
|
|
210
|
-
case "dddd":
|
|
211
|
-
return o2[e2.$W];
|
|
212
|
-
case "H":
|
|
213
|
-
return String(s2);
|
|
214
|
-
case "HH":
|
|
215
|
-
return b.s(s2, 2, "0");
|
|
216
|
-
case "h":
|
|
217
|
-
return d2(1);
|
|
218
|
-
case "hh":
|
|
219
|
-
return d2(2);
|
|
220
|
-
case "a":
|
|
221
|
-
return $2(s2, u2, true);
|
|
222
|
-
case "A":
|
|
223
|
-
return $2(s2, u2, false);
|
|
224
|
-
case "m":
|
|
225
|
-
return String(u2);
|
|
226
|
-
case "mm":
|
|
227
|
-
return b.s(u2, 2, "0");
|
|
228
|
-
case "s":
|
|
229
|
-
return String(e2.$s);
|
|
230
|
-
case "ss":
|
|
231
|
-
return b.s(e2.$s, 2, "0");
|
|
232
|
-
case "SSS":
|
|
233
|
-
return b.s(e2.$ms, 3, "0");
|
|
234
|
-
case "Z":
|
|
235
|
-
return i2;
|
|
236
|
-
}
|
|
237
|
-
return null;
|
|
238
|
-
})(t3) || i2.replace(":", "");
|
|
239
|
-
}));
|
|
240
|
-
}, m2.utcOffset = function() {
|
|
241
|
-
return 15 * -Math.round(this.$d.getTimezoneOffset() / 15);
|
|
242
|
-
}, m2.diff = function(r2, d2, l2) {
|
|
243
|
-
var $2, y2 = this, M3 = b.p(d2), m3 = O(r2), v2 = (m3.utcOffset() - this.utcOffset()) * e, g2 = this - m3, D2 = function() {
|
|
244
|
-
return b.m(y2, m3);
|
|
245
|
-
};
|
|
246
|
-
switch (M3) {
|
|
247
|
-
case h:
|
|
248
|
-
$2 = D2() / 12;
|
|
249
|
-
break;
|
|
250
|
-
case c:
|
|
251
|
-
$2 = D2();
|
|
252
|
-
break;
|
|
253
|
-
case f:
|
|
254
|
-
$2 = D2() / 3;
|
|
255
|
-
break;
|
|
256
|
-
case o:
|
|
257
|
-
$2 = (g2 - v2) / 6048e5;
|
|
258
|
-
break;
|
|
259
|
-
case a:
|
|
260
|
-
$2 = (g2 - v2) / 864e5;
|
|
261
|
-
break;
|
|
262
|
-
case u:
|
|
263
|
-
$2 = g2 / n;
|
|
264
|
-
break;
|
|
265
|
-
case s:
|
|
266
|
-
$2 = g2 / e;
|
|
267
|
-
break;
|
|
268
|
-
case i:
|
|
269
|
-
$2 = g2 / t;
|
|
270
|
-
break;
|
|
271
|
-
default:
|
|
272
|
-
$2 = g2;
|
|
273
|
-
}
|
|
274
|
-
return l2 ? $2 : b.a($2);
|
|
275
|
-
}, m2.daysInMonth = function() {
|
|
276
|
-
return this.endOf(c).$D;
|
|
277
|
-
}, m2.$locale = function() {
|
|
278
|
-
return D[this.$L];
|
|
279
|
-
}, m2.locale = function(t2, e2) {
|
|
280
|
-
if (!t2) return this.$L;
|
|
281
|
-
var n2 = this.clone(), r2 = w(t2, e2, true);
|
|
282
|
-
return r2 && (n2.$L = r2), n2;
|
|
283
|
-
}, m2.clone = function() {
|
|
284
|
-
return b.w(this.$d, this);
|
|
285
|
-
}, m2.toDate = function() {
|
|
286
|
-
return new Date(this.valueOf());
|
|
287
|
-
}, m2.toJSON = function() {
|
|
288
|
-
return this.isValid() ? this.toISOString() : null;
|
|
289
|
-
}, m2.toISOString = function() {
|
|
290
|
-
return this.$d.toISOString();
|
|
291
|
-
}, m2.toString = function() {
|
|
292
|
-
return this.$d.toUTCString();
|
|
293
|
-
}, M2;
|
|
294
|
-
})(), k = _.prototype;
|
|
295
|
-
return O.prototype = k, [["$ms", r], ["$s", i], ["$m", s], ["$H", u], ["$W", a], ["$M", c], ["$y", h], ["$D", d]].forEach((function(t2) {
|
|
296
|
-
k[t2[1]] = function(e2) {
|
|
297
|
-
return this.$g(e2, t2[0], t2[1]);
|
|
298
|
-
};
|
|
299
|
-
})), O.extend = function(t2, e2) {
|
|
300
|
-
return t2.$i || (t2(e2, _, O), t2.$i = true), O;
|
|
301
|
-
}, O.locale = w, O.isDayjs = S, O.unix = function(t2) {
|
|
302
|
-
return O(1e3 * t2);
|
|
303
|
-
}, O.en = D[g], O.Ls = D, O.p = {}, O;
|
|
304
|
-
}));
|
|
305
|
-
}
|
|
306
|
-
});
|
|
307
|
-
|
|
308
|
-
// ../../node_modules/.pnpm/dayjs@1.11.19/node_modules/dayjs/plugin/relativeTime.js
|
|
309
|
-
var require_relativeTime = __commonJS({
|
|
310
|
-
"../../node_modules/.pnpm/dayjs@1.11.19/node_modules/dayjs/plugin/relativeTime.js"(exports, module) {
|
|
311
|
-
"use strict";
|
|
312
|
-
!(function(r, e) {
|
|
313
|
-
"object" == typeof exports && "undefined" != typeof module ? module.exports = e() : "function" == typeof define && define.amd ? define(e) : (r = "undefined" != typeof globalThis ? globalThis : r || self).dayjs_plugin_relativeTime = e();
|
|
314
|
-
})(exports, (function() {
|
|
315
|
-
"use strict";
|
|
316
|
-
return function(r, e, t) {
|
|
317
|
-
r = r || {};
|
|
318
|
-
var n = e.prototype, o = { future: "in %s", past: "%s ago", s: "a few seconds", m: "a minute", mm: "%d minutes", h: "an hour", hh: "%d hours", d: "a day", dd: "%d days", M: "a month", MM: "%d months", y: "a year", yy: "%d years" };
|
|
319
|
-
function i(r2, e2, t2, o2) {
|
|
320
|
-
return n.fromToBase(r2, e2, t2, o2);
|
|
321
|
-
}
|
|
322
|
-
t.en.relativeTime = o, n.fromToBase = function(e2, n2, i2, d2, u) {
|
|
323
|
-
for (var f, a, s, l = i2.$locale().relativeTime || o, h = r.thresholds || [{ l: "s", r: 44, d: "second" }, { l: "m", r: 89 }, { l: "mm", r: 44, d: "minute" }, { l: "h", r: 89 }, { l: "hh", r: 21, d: "hour" }, { l: "d", r: 35 }, { l: "dd", r: 25, d: "day" }, { l: "M", r: 45 }, { l: "MM", r: 10, d: "month" }, { l: "y", r: 17 }, { l: "yy", d: "year" }], m = h.length, c = 0; c < m; c += 1) {
|
|
324
|
-
var y = h[c];
|
|
325
|
-
y.d && (f = d2 ? t(e2).diff(i2, y.d, true) : i2.diff(e2, y.d, true));
|
|
326
|
-
var p = (r.rounding || Math.round)(Math.abs(f));
|
|
327
|
-
if (s = f > 0, p <= y.r || !y.r) {
|
|
328
|
-
p <= 1 && c > 0 && (y = h[c - 1]);
|
|
329
|
-
var v = l[y.l];
|
|
330
|
-
u && (p = u("" + p)), a = "string" == typeof v ? v.replace("%d", p) : v(p, n2, y.l, s);
|
|
331
|
-
break;
|
|
332
|
-
}
|
|
333
|
-
}
|
|
334
|
-
if (n2) return a;
|
|
335
|
-
var M = s ? l.future : l.past;
|
|
336
|
-
return "function" == typeof M ? M(a) : M.replace("%s", a);
|
|
337
|
-
}, n.to = function(r2, e2) {
|
|
338
|
-
return i(r2, e2, this, true);
|
|
339
|
-
}, n.from = function(r2, e2) {
|
|
340
|
-
return i(r2, e2, this);
|
|
341
|
-
};
|
|
342
|
-
var d = function(r2) {
|
|
343
|
-
return r2.$u ? t.utc() : t();
|
|
344
|
-
};
|
|
345
|
-
n.toNow = function(r2) {
|
|
346
|
-
return this.to(d(this), r2);
|
|
347
|
-
}, n.fromNow = function(r2) {
|
|
348
|
-
return this.from(d(this), r2);
|
|
349
|
-
};
|
|
350
|
-
};
|
|
351
|
-
}));
|
|
352
|
-
}
|
|
353
|
-
});
|
|
354
|
-
|
|
355
|
-
// ../../node_modules/.pnpm/dayjs@1.11.19/node_modules/dayjs/locale/zh-cn.js
|
|
356
|
-
var require_zh_cn = __commonJS({
|
|
357
|
-
"../../node_modules/.pnpm/dayjs@1.11.19/node_modules/dayjs/locale/zh-cn.js"(exports, module) {
|
|
358
|
-
"use strict";
|
|
359
|
-
!(function(e, _) {
|
|
360
|
-
"object" == typeof exports && "undefined" != typeof module ? module.exports = _(require_dayjs_min()) : "function" == typeof define && define.amd ? define(["dayjs"], _) : (e = "undefined" != typeof globalThis ? globalThis : e || self).dayjs_locale_zh_cn = _(e.dayjs);
|
|
361
|
-
})(exports, (function(e) {
|
|
362
|
-
"use strict";
|
|
363
|
-
function _(e2) {
|
|
364
|
-
return e2 && "object" == typeof e2 && "default" in e2 ? e2 : { default: e2 };
|
|
365
|
-
}
|
|
366
|
-
var t = _(e), d = { name: "zh-cn", weekdays: "\u661F\u671F\u65E5_\u661F\u671F\u4E00_\u661F\u671F\u4E8C_\u661F\u671F\u4E09_\u661F\u671F\u56DB_\u661F\u671F\u4E94_\u661F\u671F\u516D".split("_"), weekdaysShort: "\u5468\u65E5_\u5468\u4E00_\u5468\u4E8C_\u5468\u4E09_\u5468\u56DB_\u5468\u4E94_\u5468\u516D".split("_"), weekdaysMin: "\u65E5_\u4E00_\u4E8C_\u4E09_\u56DB_\u4E94_\u516D".split("_"), months: "\u4E00\u6708_\u4E8C\u6708_\u4E09\u6708_\u56DB\u6708_\u4E94\u6708_\u516D\u6708_\u4E03\u6708_\u516B\u6708_\u4E5D\u6708_\u5341\u6708_\u5341\u4E00\u6708_\u5341\u4E8C\u6708".split("_"), monthsShort: "1\u6708_2\u6708_3\u6708_4\u6708_5\u6708_6\u6708_7\u6708_8\u6708_9\u6708_10\u6708_11\u6708_12\u6708".split("_"), ordinal: function(e2, _2) {
|
|
367
|
-
return "W" === _2 ? e2 + "\u5468" : e2 + "\u65E5";
|
|
368
|
-
}, weekStart: 1, yearStart: 4, formats: { LT: "HH:mm", LTS: "HH:mm:ss", L: "YYYY/MM/DD", LL: "YYYY\u5E74M\u6708D\u65E5", LLL: "YYYY\u5E74M\u6708D\u65E5Ah\u70B9mm\u5206", LLLL: "YYYY\u5E74M\u6708D\u65E5ddddAh\u70B9mm\u5206", l: "YYYY/M/D", ll: "YYYY\u5E74M\u6708D\u65E5", lll: "YYYY\u5E74M\u6708D\u65E5 HH:mm", llll: "YYYY\u5E74M\u6708D\u65E5dddd HH:mm" }, relativeTime: { future: "%s\u5185", past: "%s\u524D", s: "\u51E0\u79D2", m: "1 \u5206\u949F", mm: "%d \u5206\u949F", h: "1 \u5C0F\u65F6", hh: "%d \u5C0F\u65F6", d: "1 \u5929", dd: "%d \u5929", M: "1 \u4E2A\u6708", MM: "%d \u4E2A\u6708", y: "1 \u5E74", yy: "%d \u5E74" }, meridiem: function(e2, _2) {
|
|
369
|
-
var t2 = 100 * e2 + _2;
|
|
370
|
-
return t2 < 600 ? "\u51CC\u6668" : t2 < 900 ? "\u65E9\u4E0A" : t2 < 1100 ? "\u4E0A\u5348" : t2 < 1300 ? "\u4E2D\u5348" : t2 < 1800 ? "\u4E0B\u5348" : "\u665A\u4E0A";
|
|
371
|
-
} };
|
|
372
|
-
return t.default.locale(d, null, true), d;
|
|
373
|
-
}));
|
|
374
|
-
}
|
|
375
|
-
});
|
|
1
|
+
import {
|
|
2
|
+
ConfigManager,
|
|
3
|
+
configManager
|
|
4
|
+
} from "./chunk-G3OU7D3Y.mjs";
|
|
376
5
|
|
|
377
6
|
// src/ports/plugin-port.ts
|
|
378
7
|
var PLUGIN_TYPES = ["business", "functional", "view", "theme", "renderer", "system"];
|
|
@@ -386,6 +15,7 @@ var Slot = {
|
|
|
386
15
|
MessageContentRenderer: "message-content-renderer",
|
|
387
16
|
SidebarSystem: "sidebar-system",
|
|
388
17
|
SidebarBottom: "sidebar-bottom",
|
|
18
|
+
RootLayout: "root-layout",
|
|
389
19
|
Custom: "custom"
|
|
390
20
|
};
|
|
391
21
|
|
|
@@ -551,49 +181,6 @@ var useApi = () => {
|
|
|
551
181
|
return context;
|
|
552
182
|
};
|
|
553
183
|
|
|
554
|
-
// src/config-manager.ts
|
|
555
|
-
var ConfigManager = class {
|
|
556
|
-
/** 存储配置的 Map */
|
|
557
|
-
config = /* @__PURE__ */ new Map();
|
|
558
|
-
/**
|
|
559
|
-
* 设置配置项
|
|
560
|
-
* @param key 配置键
|
|
561
|
-
* @param value 配置值
|
|
562
|
-
*/
|
|
563
|
-
set(key, value) {
|
|
564
|
-
this.config.set(key, value);
|
|
565
|
-
}
|
|
566
|
-
/**
|
|
567
|
-
* 获取配置项
|
|
568
|
-
* @param key 配置键
|
|
569
|
-
*/
|
|
570
|
-
get(key) {
|
|
571
|
-
return this.config.get(key);
|
|
572
|
-
}
|
|
573
|
-
/**
|
|
574
|
-
* 合并配置
|
|
575
|
-
* @param config 配置对象
|
|
576
|
-
*/
|
|
577
|
-
merge(config) {
|
|
578
|
-
Object.keys(config).forEach((key) => {
|
|
579
|
-
const existing = this.config.get(key);
|
|
580
|
-
const incoming = config[key];
|
|
581
|
-
if (existing && typeof existing === "object" && incoming && typeof incoming === "object") {
|
|
582
|
-
this.config.set(key, { ...existing, ...incoming });
|
|
583
|
-
} else {
|
|
584
|
-
this.config.set(key, incoming);
|
|
585
|
-
}
|
|
586
|
-
});
|
|
587
|
-
}
|
|
588
|
-
/**
|
|
589
|
-
* 获取所有配置
|
|
590
|
-
*/
|
|
591
|
-
getAll() {
|
|
592
|
-
return Object.fromEntries(this.config);
|
|
593
|
-
}
|
|
594
|
-
};
|
|
595
|
-
var configManager = new ConfigManager();
|
|
596
|
-
|
|
597
184
|
// src/components/PluginErrorBoundary.tsx
|
|
598
185
|
import { Component } from "react";
|
|
599
186
|
import { jsx as jsx2, jsxs } from "react/jsx-runtime";
|
|
@@ -1288,7 +875,20 @@ var PluginManager = class {
|
|
|
1288
875
|
* 获取所有已注册的插件
|
|
1289
876
|
*/
|
|
1290
877
|
getPlugins() {
|
|
878
|
+
const typePriority = {
|
|
879
|
+
system: 0,
|
|
880
|
+
theme: 1,
|
|
881
|
+
renderer: 2,
|
|
882
|
+
functional: 3,
|
|
883
|
+
business: 4,
|
|
884
|
+
view: 5
|
|
885
|
+
};
|
|
1291
886
|
return Array.from(this.plugins.values()).sort((a, b) => {
|
|
887
|
+
const priorityA = typePriority[a.metadata.type] ?? 99;
|
|
888
|
+
const priorityB = typePriority[b.metadata.type] ?? 99;
|
|
889
|
+
if (priorityA !== priorityB) {
|
|
890
|
+
return priorityA - priorityB;
|
|
891
|
+
}
|
|
1292
892
|
const stateA = this.pluginStates[a.id] || { order: 0 };
|
|
1293
893
|
const stateB = this.pluginStates[b.id] || { order: 0 };
|
|
1294
894
|
return stateA.order - stateB.order;
|
|
@@ -1384,6 +984,21 @@ var PluginManager = class {
|
|
|
1384
984
|
const config = configManager.get(pluginId);
|
|
1385
985
|
return config ? config[key] : void 0;
|
|
1386
986
|
}
|
|
987
|
+
/**
|
|
988
|
+
* 获取系统全局配置 (非插件特定配置)
|
|
989
|
+
* @param key 配置键 (如 title, version)
|
|
990
|
+
*/
|
|
991
|
+
getSystemConfig(key) {
|
|
992
|
+
const systemConfig = configManager.get("system");
|
|
993
|
+
return systemConfig ? systemConfig[key] : void 0;
|
|
994
|
+
}
|
|
995
|
+
/**
|
|
996
|
+
* 获取注册的服务
|
|
997
|
+
* @param name 服务名称
|
|
998
|
+
*/
|
|
999
|
+
getService(name) {
|
|
1000
|
+
return serviceRegistry.get(name);
|
|
1001
|
+
}
|
|
1387
1002
|
/**
|
|
1388
1003
|
* 获取指定插槽的扩展
|
|
1389
1004
|
* @param slot 插槽位置
|
|
@@ -1428,10 +1043,35 @@ var PluginManager = class {
|
|
|
1428
1043
|
if (!this.pluginStates[plugin.id]) {
|
|
1429
1044
|
this.pluginStates[plugin.id] = { enabled: true, order: 0 };
|
|
1430
1045
|
}
|
|
1431
|
-
|
|
1432
|
-
|
|
1433
|
-
|
|
1434
|
-
|
|
1046
|
+
const configFromStorage = {};
|
|
1047
|
+
const pluginStorage = this.storageManager.getPluginStorage(plugin.id);
|
|
1048
|
+
if (plugin.metadata.configuration) {
|
|
1049
|
+
plugin.metadata.configuration.forEach((item) => {
|
|
1050
|
+
if (item.default !== void 0) {
|
|
1051
|
+
configFromStorage[item.key] = item.default;
|
|
1052
|
+
}
|
|
1053
|
+
try {
|
|
1054
|
+
const saved = pluginStorage.getItem(item.key);
|
|
1055
|
+
if (saved !== null) {
|
|
1056
|
+
configFromStorage[item.key] = JSON.parse(saved);
|
|
1057
|
+
}
|
|
1058
|
+
} catch (e) {
|
|
1059
|
+
}
|
|
1060
|
+
});
|
|
1061
|
+
}
|
|
1062
|
+
const mergedConfig = {
|
|
1063
|
+
...plugin.defaultConfig,
|
|
1064
|
+
...configFromStorage,
|
|
1065
|
+
...configManager.get(plugin.id) || {}
|
|
1066
|
+
};
|
|
1067
|
+
configManager.set(plugin.id, mergedConfig);
|
|
1068
|
+
if (mergedConfig) {
|
|
1069
|
+
Object.entries(mergedConfig).forEach(([key, value]) => {
|
|
1070
|
+
try {
|
|
1071
|
+
pluginStorage.setItem(key, JSON.stringify(value));
|
|
1072
|
+
} catch (e) {
|
|
1073
|
+
}
|
|
1074
|
+
});
|
|
1435
1075
|
}
|
|
1436
1076
|
switch (plugin.metadata.type) {
|
|
1437
1077
|
case "business":
|
|
@@ -1557,24 +1197,33 @@ var PluginManager = class {
|
|
|
1557
1197
|
*/
|
|
1558
1198
|
async loadPlugins(configs, registry) {
|
|
1559
1199
|
logger7.info("\u5F00\u59CB\u52A0\u8F7D\u63D2\u4EF6...");
|
|
1560
|
-
const
|
|
1200
|
+
const localLoadPromises = Object.entries(registry).map(async ([registryId, importFn]) => {
|
|
1561
1201
|
try {
|
|
1562
1202
|
const module = await importFn();
|
|
1563
|
-
|
|
1203
|
+
const config = configs[registryId];
|
|
1204
|
+
const plugin = this.instantiatePlugin(registryId, module, config);
|
|
1205
|
+
if (plugin && config) {
|
|
1206
|
+
configManager.set(plugin.id, config);
|
|
1207
|
+
}
|
|
1208
|
+
return plugin;
|
|
1564
1209
|
} catch (e) {
|
|
1565
|
-
logger7.error(`\u52A0\u8F7D\
|
|
1210
|
+
logger7.error(`\u52A0\u8F7D\u672C\u5730\u63D2\u4EF6\u6A21\u5757 ${registryId} \u5931\u8D25:`, e);
|
|
1566
1211
|
return null;
|
|
1567
1212
|
}
|
|
1568
1213
|
});
|
|
1569
1214
|
const onlineLoadPromises = Object.entries(configs).filter(([id, config]) => config.url && !registry[id]).map(async ([pluginId, config]) => {
|
|
1570
1215
|
try {
|
|
1571
|
-
|
|
1216
|
+
const plugin = await this.loadRemotePlugin(pluginId, config.url, config);
|
|
1217
|
+
if (plugin && config) {
|
|
1218
|
+
configManager.set(plugin.id, config);
|
|
1219
|
+
}
|
|
1220
|
+
return plugin;
|
|
1572
1221
|
} catch (e) {
|
|
1573
1222
|
logger7.error(`\u52A0\u8F7D\u5728\u7EBF\u63D2\u4EF6 ${pluginId} \u5931\u8D25:`, e);
|
|
1574
1223
|
return null;
|
|
1575
1224
|
}
|
|
1576
1225
|
});
|
|
1577
|
-
const loadedPlugins = await Promise.all([...
|
|
1226
|
+
const loadedPlugins = await Promise.all([...localLoadPromises, ...onlineLoadPromises]);
|
|
1578
1227
|
loadedPlugins.forEach((plugin) => {
|
|
1579
1228
|
if (plugin) {
|
|
1580
1229
|
this.register(plugin, false);
|
|
@@ -1665,16 +1314,26 @@ var PluginManager = class {
|
|
|
1665
1314
|
var pluginManager = new PluginManager(new LocalStorageAdapter());
|
|
1666
1315
|
|
|
1667
1316
|
// src/components/PluginSlot.tsx
|
|
1668
|
-
import { jsx as jsx3 } from "react/jsx-runtime";
|
|
1317
|
+
import { Fragment, jsx as jsx3 } from "react/jsx-runtime";
|
|
1669
1318
|
var PluginSlot = ({
|
|
1670
1319
|
slot,
|
|
1671
1320
|
props = {},
|
|
1672
1321
|
className,
|
|
1673
1322
|
style,
|
|
1674
1323
|
renderItem,
|
|
1675
|
-
skeleton
|
|
1324
|
+
skeleton,
|
|
1325
|
+
fallback
|
|
1676
1326
|
}) => {
|
|
1677
1327
|
const extensions = pluginManager.getExtensions(slot);
|
|
1328
|
+
const systemConfig = pluginManager.getSystemConfig("title") ? {
|
|
1329
|
+
title: pluginManager.getSystemConfig("title"),
|
|
1330
|
+
logo: pluginManager.getSystemConfig("logo"),
|
|
1331
|
+
version: pluginManager.getSystemConfig("version")
|
|
1332
|
+
} : void 0;
|
|
1333
|
+
const mergedProps = useMemo(() => ({
|
|
1334
|
+
...props,
|
|
1335
|
+
systemConfig
|
|
1336
|
+
}), [props, systemConfig]);
|
|
1678
1337
|
const items = useMemo(() => {
|
|
1679
1338
|
return extensions.map((ext, index) => {
|
|
1680
1339
|
const Component2 = ext.component;
|
|
@@ -1682,22 +1341,32 @@ var PluginSlot = ({
|
|
|
1682
1341
|
return {
|
|
1683
1342
|
key,
|
|
1684
1343
|
extension: ext,
|
|
1685
|
-
component: /* @__PURE__ */ jsx3(PluginErrorBoundary, { pluginId: `extension-${key}`, children: /* @__PURE__ */ jsx3(Component2, { ...
|
|
1344
|
+
component: /* @__PURE__ */ jsx3(PluginErrorBoundary, { pluginId: `extension-${key}`, children: /* @__PURE__ */ jsx3(Component2, { ...mergedProps }) }, key)
|
|
1686
1345
|
};
|
|
1687
1346
|
});
|
|
1688
|
-
}, [extensions,
|
|
1347
|
+
}, [extensions, mergedProps]);
|
|
1689
1348
|
if (items.length === 0) {
|
|
1349
|
+
if (fallback) {
|
|
1350
|
+
return /* @__PURE__ */ jsx3(Fragment, { children: fallback });
|
|
1351
|
+
}
|
|
1690
1352
|
if (skeleton) {
|
|
1691
1353
|
return /* @__PURE__ */ jsx3("div", { className: `plugin-slot plugin-slot-${slot} plugin-slot-skeleton ${className || ""}`, style, children: skeleton });
|
|
1692
1354
|
}
|
|
1693
1355
|
return null;
|
|
1694
1356
|
}
|
|
1357
|
+
if (items.length === 1 && slot === "root-layout" && !className && !style && !renderItem) {
|
|
1358
|
+
return /* @__PURE__ */ jsx3(Fragment, { children: items[0].component });
|
|
1359
|
+
}
|
|
1695
1360
|
return /* @__PURE__ */ jsx3("div", { className: `plugin-slot plugin-slot-${slot} ${className || ""}`, style, children: renderItem ? items.map((item, index) => renderItem(item, index)) : items.map((item) => item.component) });
|
|
1696
1361
|
};
|
|
1697
1362
|
|
|
1698
1363
|
// src/components/SlotSkeletons.tsx
|
|
1699
|
-
import { jsx as jsx4 } from "react/jsx-runtime";
|
|
1700
|
-
var SidebarIconSkeleton = () => /* @__PURE__ */
|
|
1364
|
+
import { jsx as jsx4, jsxs as jsxs2 } from "react/jsx-runtime";
|
|
1365
|
+
var SidebarIconSkeleton = ({ expanded = false }) => /* @__PURE__ */ jsxs2("div", { className: `flex items-center transition-all duration-300 relative
|
|
1366
|
+
${expanded ? "w-full" : "w-12 justify-center"} px-3 h-11 rounded-xl`, children: [
|
|
1367
|
+
/* @__PURE__ */ jsx4("div", { className: "w-6 h-6 bg-slate-200 dark:bg-white/10 rounded-lg shrink-0 animate-pulse" }),
|
|
1368
|
+
expanded && /* @__PURE__ */ jsx4("div", { className: "ml-3 flex-1 h-4 bg-slate-200 dark:bg-white/10 rounded animate-pulse" })
|
|
1369
|
+
] });
|
|
1701
1370
|
var StatusBarItemSkeleton = () => /* @__PURE__ */ jsx4("div", { className: "h-4 w-16 bg-slate-200 dark:bg-white/10 rounded animate-pulse" });
|
|
1702
1371
|
var AvatarSkeleton = () => /* @__PURE__ */ jsx4("div", { className: "w-10 h-10 rounded-full bg-slate-200 dark:bg-white/10 animate-pulse" });
|
|
1703
1372
|
var BlockSkeleton = ({ className }) => /* @__PURE__ */ jsx4("div", { className: `bg-slate-200 dark:bg-white/10 rounded animate-pulse ${className || "w-full h-full"}` });
|
|
@@ -1773,7 +1442,7 @@ var AxiosAdapter = class {
|
|
|
1773
1442
|
timeout
|
|
1774
1443
|
});
|
|
1775
1444
|
this.client.interceptors.response.use(
|
|
1776
|
-
(response) => response
|
|
1445
|
+
(response) => response,
|
|
1777
1446
|
(error) => Promise.reject(error)
|
|
1778
1447
|
);
|
|
1779
1448
|
}
|
|
@@ -1809,10 +1478,12 @@ var AxiosAdapter = class {
|
|
|
1809
1478
|
if (defaultHeaders["x-token"]) {
|
|
1810
1479
|
headers["x-token"] = defaultHeaders["x-token"];
|
|
1811
1480
|
}
|
|
1481
|
+
const { signal, ...otherConfig } = config;
|
|
1812
1482
|
const response = await fetch(url, {
|
|
1813
1483
|
method: config.method,
|
|
1814
1484
|
headers,
|
|
1815
|
-
body: config.data ? JSON.stringify(config.data) : void 0
|
|
1485
|
+
body: config.data ? JSON.stringify(config.data) : void 0,
|
|
1486
|
+
signal
|
|
1816
1487
|
});
|
|
1817
1488
|
if (!response.ok) {
|
|
1818
1489
|
throw new Error(`HTTP error! status: ${response.status}`);
|
|
@@ -1822,14 +1493,22 @@ var AxiosAdapter = class {
|
|
|
1822
1493
|
}
|
|
1823
1494
|
const reader = response.body.getReader();
|
|
1824
1495
|
const decoder = new TextDecoder();
|
|
1496
|
+
let buffer = "";
|
|
1825
1497
|
while (true) {
|
|
1826
1498
|
const { done, value } = await reader.read();
|
|
1827
1499
|
if (done) break;
|
|
1828
|
-
|
|
1829
|
-
|
|
1830
|
-
|
|
1500
|
+
buffer += decoder.decode(value, { stream: true });
|
|
1501
|
+
const parts = buffer.split("\n\n");
|
|
1502
|
+
buffer = parts.pop() || "";
|
|
1503
|
+
for (const part of parts) {
|
|
1504
|
+
if (onMessage) {
|
|
1505
|
+
onMessage(part + "\n\n");
|
|
1506
|
+
}
|
|
1831
1507
|
}
|
|
1832
1508
|
}
|
|
1509
|
+
if (buffer && onMessage) {
|
|
1510
|
+
onMessage(buffer);
|
|
1511
|
+
}
|
|
1833
1512
|
if (onFinish) onFinish();
|
|
1834
1513
|
} catch (error) {
|
|
1835
1514
|
if (onError) onError(error);
|
|
@@ -1842,9 +1521,22 @@ var logger9 = createLogger("ApiEngine");
|
|
|
1842
1521
|
var ApiEngine = class {
|
|
1843
1522
|
adapter;
|
|
1844
1523
|
config = {};
|
|
1524
|
+
interceptors = [];
|
|
1845
1525
|
constructor(adapter) {
|
|
1846
1526
|
this.adapter = adapter || new AxiosAdapter();
|
|
1847
1527
|
}
|
|
1528
|
+
/**
|
|
1529
|
+
* 注册拦截器
|
|
1530
|
+
*/
|
|
1531
|
+
registerInterceptor(interceptor) {
|
|
1532
|
+
this.interceptors.push(interceptor);
|
|
1533
|
+
}
|
|
1534
|
+
/**
|
|
1535
|
+
* 移除拦截器
|
|
1536
|
+
*/
|
|
1537
|
+
unregisterInterceptor(interceptor) {
|
|
1538
|
+
this.interceptors = this.interceptors.filter((i) => i !== interceptor);
|
|
1539
|
+
}
|
|
1848
1540
|
/**
|
|
1849
1541
|
* 切换请求适配器
|
|
1850
1542
|
* @param adapter 新的适配器实例
|
|
@@ -1879,34 +1571,42 @@ var ApiEngine = class {
|
|
|
1879
1571
|
logger9.warn(`\u672A\u627E\u5230 API \u5B9A\u4E49: ${module}.${action} (\u5F53\u524D\u5DF2\u6CE8\u518C\u6A21\u5757: ${Object.keys(this.config).join(", ")})`);
|
|
1880
1572
|
return Promise.resolve(void 0);
|
|
1881
1573
|
}
|
|
1882
|
-
let
|
|
1883
|
-
|
|
1884
|
-
|
|
1885
|
-
|
|
1886
|
-
|
|
1574
|
+
let requestConfig = await this.prepareRequestConfig(endpoint, data, options);
|
|
1575
|
+
let response;
|
|
1576
|
+
try {
|
|
1577
|
+
response = await this.adapter.request(requestConfig, endpoint);
|
|
1578
|
+
} catch (error) {
|
|
1579
|
+
if (error.response) {
|
|
1580
|
+
response = error.response;
|
|
1581
|
+
} else {
|
|
1582
|
+
throw error;
|
|
1887
1583
|
}
|
|
1888
|
-
|
|
1889
|
-
|
|
1584
|
+
}
|
|
1585
|
+
if (this.interceptors.length > 0) {
|
|
1586
|
+
const context = this.createInterceptorContext(response, requestConfig);
|
|
1587
|
+
for (const interceptor of this.interceptors) {
|
|
1588
|
+
if (interceptor.interceptResponse) {
|
|
1589
|
+
const hijacked = await interceptor.interceptResponse(context);
|
|
1590
|
+
if (hijacked) {
|
|
1591
|
+
logger9.info("\u8BF7\u6C42\u88AB\u62E6\u622A\u5668\u52AB\u6301:", module, action);
|
|
1592
|
+
return void 0;
|
|
1593
|
+
}
|
|
1594
|
+
}
|
|
1890
1595
|
}
|
|
1891
|
-
return `:${key}`;
|
|
1892
|
-
});
|
|
1893
|
-
const method = endpoint.method;
|
|
1894
|
-
const requestConfig = {
|
|
1895
|
-
...options,
|
|
1896
|
-
url,
|
|
1897
|
-
method
|
|
1898
|
-
};
|
|
1899
|
-
if (method === "GET" || method === "DELETE") {
|
|
1900
|
-
requestConfig.params = data;
|
|
1901
|
-
} else {
|
|
1902
|
-
requestConfig.data = data;
|
|
1903
1596
|
}
|
|
1904
|
-
|
|
1905
|
-
|
|
1906
|
-
|
|
1907
|
-
|
|
1597
|
+
if (response && response.status && (response.status < 200 || response.status >= 300)) {
|
|
1598
|
+
const responseData2 = this.isAxiosResponse(response) ? response.data : response;
|
|
1599
|
+
const isBaseResponse = this.isBaseResponse(responseData2);
|
|
1600
|
+
if (!isBaseResponse) {
|
|
1601
|
+
throw new Error(`Request failed with status ${response.status}`);
|
|
1602
|
+
}
|
|
1603
|
+
}
|
|
1604
|
+
const responseData = this.isAxiosResponse(response) ? response.data : response;
|
|
1605
|
+
if (this.isBaseResponse(responseData)) {
|
|
1606
|
+
const res = responseData;
|
|
1908
1607
|
const code = String(res.code);
|
|
1909
|
-
|
|
1608
|
+
const isSuccess = code === SUCCESS_CODE || code === "200" || code === "0";
|
|
1609
|
+
if (!isSuccess) {
|
|
1910
1610
|
const strategy = endpoint.errorStrategy || "reject";
|
|
1911
1611
|
if (strategy === "reject") {
|
|
1912
1612
|
logger9.error(`API \u8BF7\u6C42\u4E1A\u52A1\u9519\u8BEF (${module}.${action}):`, res.message);
|
|
@@ -1914,7 +1614,7 @@ var ApiEngine = class {
|
|
|
1914
1614
|
}
|
|
1915
1615
|
}
|
|
1916
1616
|
}
|
|
1917
|
-
return
|
|
1617
|
+
return responseData;
|
|
1918
1618
|
}
|
|
1919
1619
|
/**
|
|
1920
1620
|
* 发起流式请求
|
|
@@ -1933,6 +1633,18 @@ var ApiEngine = class {
|
|
|
1933
1633
|
logger9.warn("\u5F53\u524D API \u9002\u914D\u5668\u4E0D\u652F\u6301\u6D41\u5F0F\u4F20\u8F93\u3002");
|
|
1934
1634
|
return;
|
|
1935
1635
|
}
|
|
1636
|
+
const requestConfig = await this.prepareRequestConfig(endpoint, data, options);
|
|
1637
|
+
const callbacks = {
|
|
1638
|
+
onMessage: options.onMessage,
|
|
1639
|
+
onError: options.onError,
|
|
1640
|
+
onFinish: options.onFinish
|
|
1641
|
+
};
|
|
1642
|
+
await this.adapter.stream(requestConfig, callbacks, endpoint);
|
|
1643
|
+
}
|
|
1644
|
+
/**
|
|
1645
|
+
* 准备请求配置,应用 URL 参数替换和拦截器
|
|
1646
|
+
*/
|
|
1647
|
+
async prepareRequestConfig(endpoint, data, options) {
|
|
1936
1648
|
let url = endpoint.url;
|
|
1937
1649
|
const pathParams = options.params || {};
|
|
1938
1650
|
url = url.replace(/:([a-zA-Z0-9_]+)/g, (_, key) => {
|
|
@@ -1941,7 +1653,7 @@ var ApiEngine = class {
|
|
|
1941
1653
|
return `:${key}`;
|
|
1942
1654
|
});
|
|
1943
1655
|
const method = endpoint.method;
|
|
1944
|
-
|
|
1656
|
+
let requestConfig = {
|
|
1945
1657
|
...options,
|
|
1946
1658
|
url,
|
|
1947
1659
|
method
|
|
@@ -1951,16 +1663,100 @@ var ApiEngine = class {
|
|
|
1951
1663
|
} else {
|
|
1952
1664
|
requestConfig.data = data;
|
|
1953
1665
|
}
|
|
1954
|
-
|
|
1955
|
-
|
|
1956
|
-
|
|
1957
|
-
|
|
1666
|
+
if (this.interceptors.length > 0) {
|
|
1667
|
+
for (const interceptor of this.interceptors) {
|
|
1668
|
+
if (interceptor.interceptRequest) {
|
|
1669
|
+
requestConfig = await interceptor.interceptRequest(requestConfig);
|
|
1670
|
+
}
|
|
1671
|
+
}
|
|
1672
|
+
}
|
|
1673
|
+
return requestConfig;
|
|
1674
|
+
}
|
|
1675
|
+
/**
|
|
1676
|
+
* 判断是否为 BaseResponse
|
|
1677
|
+
*/
|
|
1678
|
+
isBaseResponse(data) {
|
|
1679
|
+
return data && typeof data === "object" && "code" in data && ("message" in data || "data" in data);
|
|
1680
|
+
}
|
|
1681
|
+
/**
|
|
1682
|
+
* 严格判断是否为 AxiosResponse
|
|
1683
|
+
*/
|
|
1684
|
+
isAxiosResponse(res) {
|
|
1685
|
+
return res && typeof res === "object" && "data" in res && "status" in res && "headers" in res;
|
|
1686
|
+
}
|
|
1687
|
+
/**
|
|
1688
|
+
* 创建拦截上下文
|
|
1689
|
+
*/
|
|
1690
|
+
createInterceptorContext(response, config) {
|
|
1691
|
+
if (response && typeof response === "object" && "status" in response && "headers" in response) {
|
|
1692
|
+
return {
|
|
1693
|
+
response,
|
|
1694
|
+
status: response.status,
|
|
1695
|
+
headers: response.headers,
|
|
1696
|
+
data: response.data,
|
|
1697
|
+
config
|
|
1698
|
+
};
|
|
1699
|
+
}
|
|
1700
|
+
return {
|
|
1701
|
+
response,
|
|
1702
|
+
status: 200,
|
|
1703
|
+
headers: {},
|
|
1704
|
+
data: response,
|
|
1705
|
+
config
|
|
1958
1706
|
};
|
|
1959
|
-
await this.adapter.stream(requestConfig, callbacks, endpoint);
|
|
1960
1707
|
}
|
|
1961
1708
|
};
|
|
1962
1709
|
var apiEngine = new ApiEngine();
|
|
1963
1710
|
|
|
1711
|
+
// src/utils/url.ts
|
|
1712
|
+
function normalizeParams(strategy = "last") {
|
|
1713
|
+
if (typeof window === "undefined") return new URLSearchParams();
|
|
1714
|
+
const { search, hash } = window.location;
|
|
1715
|
+
const searchParams = new URLSearchParams(search);
|
|
1716
|
+
const hashParams = new URLSearchParams(hash.split("?")[1] || "");
|
|
1717
|
+
const entries = [];
|
|
1718
|
+
searchParams.forEach((v, k) => entries.push([k, v, "search"]));
|
|
1719
|
+
hashParams.forEach((v, k) => entries.push([k, v, "hash"]));
|
|
1720
|
+
const keeper = /* @__PURE__ */ new Map();
|
|
1721
|
+
if (strategy === "first") {
|
|
1722
|
+
entries.forEach(([k, v]) => {
|
|
1723
|
+
if (!keeper.has(k)) keeper.set(k, v);
|
|
1724
|
+
});
|
|
1725
|
+
} else if (strategy === "last") {
|
|
1726
|
+
entries.forEach(([k, v]) => keeper.set(k, v));
|
|
1727
|
+
} else if (strategy === "search") {
|
|
1728
|
+
entries.forEach(([k, v, src]) => {
|
|
1729
|
+
if (src === "search") keeper.set(k, v);
|
|
1730
|
+
});
|
|
1731
|
+
hashParams.forEach((v, k) => {
|
|
1732
|
+
if (!keeper.has(k)) keeper.set(k, v);
|
|
1733
|
+
});
|
|
1734
|
+
} else if (strategy === "hash") {
|
|
1735
|
+
entries.forEach(([k, v, src]) => {
|
|
1736
|
+
if (src === "hash") keeper.set(k, v);
|
|
1737
|
+
});
|
|
1738
|
+
searchParams.forEach((v, k) => {
|
|
1739
|
+
if (!keeper.has(k)) keeper.set(k, v);
|
|
1740
|
+
});
|
|
1741
|
+
}
|
|
1742
|
+
return new URLSearchParams(Array.from(keeper.entries()));
|
|
1743
|
+
}
|
|
1744
|
+
function cleanUrlParams(keysToRemove) {
|
|
1745
|
+
if (typeof window === "undefined") return "";
|
|
1746
|
+
const { pathname, search, hash } = window.location;
|
|
1747
|
+
const searchParams = new URLSearchParams(search);
|
|
1748
|
+
keysToRemove.forEach((key) => searchParams.delete(key));
|
|
1749
|
+
const newSearch = searchParams.toString();
|
|
1750
|
+
const hashParts = hash.split("?");
|
|
1751
|
+
const hashPath = hashParts[0];
|
|
1752
|
+
const hashQuery = hashParts[1] || "";
|
|
1753
|
+
const hashParams = new URLSearchParams(hashQuery);
|
|
1754
|
+
keysToRemove.forEach((key) => hashParams.delete(key));
|
|
1755
|
+
const newHashQuery = hashParams.toString();
|
|
1756
|
+
const newHash = hashPath + (newHashQuery ? "?" + newHashQuery : "");
|
|
1757
|
+
return pathname + (newSearch ? "?" + newSearch : "") + newHash;
|
|
1758
|
+
}
|
|
1759
|
+
|
|
1964
1760
|
// src/api/utils.ts
|
|
1965
1761
|
var mergeMockData = (def, mock) => {
|
|
1966
1762
|
const merged = JSON.parse(JSON.stringify(def));
|
|
@@ -1977,10 +1773,8 @@ var mergeMockData = (def, mock) => {
|
|
|
1977
1773
|
function isMockMode() {
|
|
1978
1774
|
const envMock = typeof process !== "undefined" && process.env.VITE_USE_MOCK === "true" || typeof window !== "undefined" && window.VITE_USE_MOCK === "true";
|
|
1979
1775
|
if (typeof window !== "undefined") {
|
|
1980
|
-
const
|
|
1981
|
-
const
|
|
1982
|
-
const hash = new URLSearchParams(hashSearch);
|
|
1983
|
-
const mockParam = search.get("mock") || hash.get("mock");
|
|
1776
|
+
const params = normalizeParams();
|
|
1777
|
+
const mockParam = params.get("mock");
|
|
1984
1778
|
if (mockParam === "true") return true;
|
|
1985
1779
|
if (mockParam === "false") return false;
|
|
1986
1780
|
}
|
|
@@ -2012,75 +1806,47 @@ function resolveApiModules(definitionsMap, mocksMap = {}) {
|
|
|
2012
1806
|
return config;
|
|
2013
1807
|
}
|
|
2014
1808
|
|
|
2015
|
-
// src/utils/stream-parser.ts
|
|
2016
|
-
function parseStreamChunk(chunk) {
|
|
2017
|
-
const lines = chunk.split("\n").filter((line) => line.trim() !== "");
|
|
2018
|
-
const events = [];
|
|
2019
|
-
let currentEvent = null;
|
|
2020
|
-
for (let i = 0; i < lines.length; i++) {
|
|
2021
|
-
const line = lines[i];
|
|
2022
|
-
if (line.startsWith("event:")) {
|
|
2023
|
-
currentEvent = line.substring(6).trim();
|
|
2024
|
-
} else if (line.startsWith("data:")) {
|
|
2025
|
-
const dataStr = line.substring(5).trim();
|
|
2026
|
-
let data;
|
|
2027
|
-
try {
|
|
2028
|
-
data = JSON.parse(dataStr);
|
|
2029
|
-
} catch {
|
|
2030
|
-
data = dataStr;
|
|
2031
|
-
}
|
|
2032
|
-
const eventType = currentEvent || "data";
|
|
2033
|
-
events.push({
|
|
2034
|
-
event: eventType,
|
|
2035
|
-
data
|
|
2036
|
-
});
|
|
2037
|
-
currentEvent = null;
|
|
2038
|
-
}
|
|
2039
|
-
}
|
|
2040
|
-
return events;
|
|
2041
|
-
}
|
|
2042
|
-
|
|
2043
1809
|
// src/utils/date.ts
|
|
2044
|
-
|
|
2045
|
-
|
|
2046
|
-
|
|
2047
|
-
|
|
2048
|
-
|
|
1810
|
+
import dayjs from "dayjs";
|
|
1811
|
+
import relativeTime from "dayjs/plugin/relativeTime";
|
|
1812
|
+
import "dayjs/locale/zh-cn";
|
|
1813
|
+
dayjs.extend(relativeTime);
|
|
1814
|
+
dayjs.locale("zh-cn");
|
|
2049
1815
|
var dateUtils = {
|
|
2050
1816
|
/**
|
|
2051
1817
|
* 格式化日期为 YYYY-MM-DD
|
|
2052
1818
|
*/
|
|
2053
1819
|
formatDate(date) {
|
|
2054
|
-
return (
|
|
1820
|
+
return dayjs(date).format("YYYY-MM-DD");
|
|
2055
1821
|
},
|
|
2056
1822
|
/**
|
|
2057
1823
|
* 格式化时间为 HH:mm:ss
|
|
2058
1824
|
*/
|
|
2059
1825
|
formatTime(date) {
|
|
2060
|
-
return (
|
|
1826
|
+
return dayjs(date).format("HH:mm:ss");
|
|
2061
1827
|
},
|
|
2062
1828
|
/**
|
|
2063
1829
|
* 格式化日期时间为 YYYY-MM-DD HH:mm:ss
|
|
2064
1830
|
*/
|
|
2065
1831
|
formatDateTime(date) {
|
|
2066
|
-
return (
|
|
1832
|
+
return dayjs(date).format("YYYY-MM-DD HH:mm:ss");
|
|
2067
1833
|
},
|
|
2068
1834
|
/**
|
|
2069
1835
|
* 获取当前时间戳(毫秒)
|
|
2070
1836
|
*/
|
|
2071
1837
|
now() {
|
|
2072
|
-
return (
|
|
1838
|
+
return dayjs().valueOf();
|
|
2073
1839
|
},
|
|
2074
1840
|
/**
|
|
2075
1841
|
* 获取相对时间(例如:几分钟前)
|
|
2076
1842
|
*/
|
|
2077
1843
|
fromNow(date) {
|
|
2078
|
-
return (
|
|
1844
|
+
return dayjs(date).fromNow();
|
|
2079
1845
|
},
|
|
2080
1846
|
/**
|
|
2081
1847
|
* 原始 dayjs 对象,用于更复杂的场景
|
|
2082
1848
|
*/
|
|
2083
|
-
dayjs
|
|
1849
|
+
dayjs
|
|
2084
1850
|
};
|
|
2085
1851
|
|
|
2086
1852
|
// src/utils/index.ts
|
|
@@ -2145,6 +1911,10 @@ var usePluginLoader = (options) => {
|
|
|
2145
1911
|
logger10.info("Starting to load plugins...");
|
|
2146
1912
|
const discoveredRegistry = discoveryRules.length > 0 ? discoverPlugins(discoveryRules, baseUrl) : {};
|
|
2147
1913
|
const finalRegistry = { ...discoveredRegistry, ...manualRegistry };
|
|
1914
|
+
if (options.systemConfig) {
|
|
1915
|
+
const { configManager: configManager2 } = await import("./config-manager-ZARQENTB.mjs");
|
|
1916
|
+
configManager2.set("system", options.systemConfig);
|
|
1917
|
+
}
|
|
2148
1918
|
await pluginManager.loadPlugins(pluginConfigs, finalRegistry);
|
|
2149
1919
|
await pluginManager.initPlugins(sharedContext);
|
|
2150
1920
|
setPluginsLoaded(true);
|
|
@@ -2191,13 +1961,14 @@ export {
|
|
|
2191
1961
|
StatusBarItemSkeleton,
|
|
2192
1962
|
StorageManager,
|
|
2193
1963
|
apiEngine,
|
|
1964
|
+
cleanUrlParams,
|
|
2194
1965
|
configManager,
|
|
2195
1966
|
createLogger,
|
|
2196
1967
|
dateUtils,
|
|
2197
1968
|
discoverPlugins,
|
|
2198
1969
|
isMockMode,
|
|
2199
1970
|
logger,
|
|
2200
|
-
|
|
1971
|
+
normalizeParams,
|
|
2201
1972
|
pluginManager,
|
|
2202
1973
|
resolveApiModules,
|
|
2203
1974
|
resolvePluginRegistry,
|