@chatbi-v/mocks 2.0.0 → 2.0.2
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 +48 -1
- package/dist/index.d.ts +5 -0
- package/dist/index.js +5 -0
- package/dist/index.mjs +3 -310
- package/dist/index.plugin.js +8508 -0
- package/package.json +5 -6
- package/dist/index.cjs +0 -1095
package/README.md
CHANGED
|
@@ -1,7 +1,54 @@
|
|
|
1
|
-
# @chatbi/mocks
|
|
1
|
+
# @chatbi-v/mocks
|
|
2
2
|
|
|
3
3
|
ChatBI Mock 数据模块,提供灵活的 JSON 和 SSE (Server-Sent Events) 数据模拟功能。
|
|
4
4
|
|
|
5
|
+
## 模块功能说明
|
|
6
|
+
|
|
7
|
+
- **响应策略管理**: 支持 JSON、SSE (流式) 和 SSE-Page (分页流) 等多种响应模式。
|
|
8
|
+
- **数据生成器**: 集成 Mock.js,支持丰富的模板语法和动态数据生成。
|
|
9
|
+
- **拦截器适配**: 轻松接入 Axios 或其他请求库,实现无缝的本地模拟开发。
|
|
10
|
+
- **参数动态插值**: 支持在模板中引用请求 Query 或 Body 参数。
|
|
11
|
+
|
|
12
|
+
## 安装和使用方法
|
|
13
|
+
|
|
14
|
+
### 安装
|
|
15
|
+
|
|
16
|
+
```bash
|
|
17
|
+
pnpm add @chatbi-v/mocks
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
### 使用示例
|
|
21
|
+
|
|
22
|
+
```typescript
|
|
23
|
+
import { MockInterceptor } from '@chatbi-v/mocks';
|
|
24
|
+
|
|
25
|
+
const interceptor = new MockInterceptor();
|
|
26
|
+
|
|
27
|
+
// 注册 mock 规则
|
|
28
|
+
interceptor.register('GET /api/user', {
|
|
29
|
+
type: 'json',
|
|
30
|
+
responseSchema: {
|
|
31
|
+
code: 200,
|
|
32
|
+
data: { id: 1, name: '@cname' }
|
|
33
|
+
}
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
// 在请求库中使用拦截器
|
|
37
|
+
// axios.interceptors.request.use(interceptor.getRequestInterceptor());
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
## API 文档链接
|
|
41
|
+
|
|
42
|
+
请参考 [Mock 模块详细文档](https://github.com/your-repo/docs/mocks/index.md)。
|
|
43
|
+
|
|
44
|
+
## 开发注意事项
|
|
45
|
+
|
|
46
|
+
- **命名规范**: 建议 Mock 文件以 `.mock.ts` 结尾。
|
|
47
|
+
- **数据一致性**: 确保 Mock 返回的数据结构与后端 API 定义一致。
|
|
48
|
+
- **性能**: SSE 模式下的 `delay` 参数不宜设置过大,以免影响开发体验。
|
|
49
|
+
|
|
50
|
+
---
|
|
51
|
+
|
|
5
52
|
## 特性
|
|
6
53
|
|
|
7
54
|
- **多种响应策略**:支持 `json` (普通接口)、`sse` (流式接口)、`sse-page` (带分页的流式接口)。
|
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
package/dist/index.mjs
CHANGED
|
@@ -1,310 +1,3 @@
|
|
|
1
|
-
var __create = Object.create;
|
|
2
|
-
var __defProp = Object.defineProperty;
|
|
3
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
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
1
|
// src/index.ts
|
|
309
2
|
import { dateUtils as dateUtils3 } from "@chatbi-v/core";
|
|
310
3
|
|
|
@@ -466,7 +159,7 @@ data: ${JSON.stringify(data)}
|
|
|
466
159
|
};
|
|
467
160
|
|
|
468
161
|
// src/utils.ts
|
|
469
|
-
|
|
162
|
+
import dayjs from "dayjs";
|
|
470
163
|
import Mock from "mockjs";
|
|
471
164
|
var sleep = (ms) => new Promise((r) => setTimeout(r, ms));
|
|
472
165
|
function processTemplate(data, context) {
|
|
@@ -526,10 +219,10 @@ function eventsToStream(events) {
|
|
|
526
219
|
}
|
|
527
220
|
(async () => {
|
|
528
221
|
try {
|
|
529
|
-
const startTime = (
|
|
222
|
+
const startTime = dayjs().valueOf();
|
|
530
223
|
for (const eventItem of events) {
|
|
531
224
|
const delay = typeof eventItem.delay === "number" ? eventItem.delay : parseInt(String(eventItem.delay || 0));
|
|
532
|
-
const elapsed = (
|
|
225
|
+
const elapsed = dayjs().valueOf() - startTime;
|
|
533
226
|
const remaining = Math.max(0, delay - elapsed);
|
|
534
227
|
if (remaining > 0) {
|
|
535
228
|
await sleep(remaining);
|