@vunk/plus 1.3.2 → 1.3.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/components/agent-chat-provider/index.mjs +1 -574
- package/components/broadcasting-markdown/index.mjs +15 -2
- package/components/broadcasting-markdown/src/index.vue.d.ts +14 -0
- package/components/broadcasting-markdown/src/paragraph.vue.d.ts +14 -0
- package/components/browser.mjs +575 -0
- package/components/bubble-list/src/index.vue.d.ts +14 -0
- package/components/bubble-templates/src/index.vue.d.ts +14 -0
- package/components/chat-independent/src/index.vue.d.ts +14 -0
- package/components/tables-v1/src/ctx.d.ts +1 -1
- package/components/tables-v1/src/index.vue.d.ts +1 -1
- package/components/tables-v1-checkbox/src/ctx.d.ts +1 -1
- package/components/tables-v1-checkbox/src/index.vue.d.ts +3 -3
- package/package.json +1 -1
|
@@ -19,6 +19,10 @@ declare const _default: import("vue").DefineComponent<import("vue").ExtractPropT
|
|
|
19
19
|
type: PropType<AnyFunc>;
|
|
20
20
|
default: AnyFunc;
|
|
21
21
|
};
|
|
22
|
+
retryTimes: {
|
|
23
|
+
type: NumberConstructor;
|
|
24
|
+
default: number;
|
|
25
|
+
};
|
|
22
26
|
}>, {
|
|
23
27
|
props: import("@vue/shared").LooseRequired<Readonly<import("vue").ExtractPropTypes<{
|
|
24
28
|
enable: {
|
|
@@ -37,11 +41,16 @@ declare const _default: import("vue").DefineComponent<import("vue").ExtractPropT
|
|
|
37
41
|
type: PropType<AnyFunc>;
|
|
38
42
|
default: AnyFunc;
|
|
39
43
|
};
|
|
44
|
+
retryTimes: {
|
|
45
|
+
type: NumberConstructor;
|
|
46
|
+
default: number;
|
|
47
|
+
};
|
|
40
48
|
}>> & Readonly<{
|
|
41
49
|
"onUpdate:status"?: ((...args: any[]) => any) | undefined;
|
|
42
50
|
}> & {}>;
|
|
43
51
|
emit: (event: "update:status", ...args: any[]) => void;
|
|
44
52
|
theDef: import("vue").ShallowRef<Deferred<any> | undefined, Deferred<any> | undefined>;
|
|
53
|
+
retryTimes: number;
|
|
45
54
|
processingDef: {
|
|
46
55
|
_ref: import("vue").ShallowRef<unknown, unknown>;
|
|
47
56
|
readonly value: unknown;
|
|
@@ -67,6 +76,10 @@ declare const _default: import("vue").DefineComponent<import("vue").ExtractPropT
|
|
|
67
76
|
type: PropType<AnyFunc>;
|
|
68
77
|
default: AnyFunc;
|
|
69
78
|
};
|
|
79
|
+
retryTimes: {
|
|
80
|
+
type: NumberConstructor;
|
|
81
|
+
default: number;
|
|
82
|
+
};
|
|
70
83
|
}>> & Readonly<{
|
|
71
84
|
"onUpdate:status"?: ((...args: any[]) => any) | undefined;
|
|
72
85
|
}>, {
|
|
@@ -74,5 +87,6 @@ declare const _default: import("vue").DefineComponent<import("vue").ExtractPropT
|
|
|
74
87
|
pause: boolean;
|
|
75
88
|
enable: boolean;
|
|
76
89
|
status: ParagraphStatus;
|
|
90
|
+
retryTimes: number;
|
|
77
91
|
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
|
|
78
92
|
export default _default;
|
|
@@ -0,0 +1,575 @@
|
|
|
1
|
+
const LogLevels = {
|
|
2
|
+
fatal: 0,
|
|
3
|
+
error: 0,
|
|
4
|
+
warn: 1,
|
|
5
|
+
log: 2,
|
|
6
|
+
info: 3,
|
|
7
|
+
success: 3,
|
|
8
|
+
fail: 3,
|
|
9
|
+
debug: 4,
|
|
10
|
+
trace: 5,
|
|
11
|
+
verbose: Number.POSITIVE_INFINITY
|
|
12
|
+
};
|
|
13
|
+
const LogTypes = {
|
|
14
|
+
// Silent
|
|
15
|
+
silent: {
|
|
16
|
+
level: -1
|
|
17
|
+
},
|
|
18
|
+
// Level 0
|
|
19
|
+
fatal: {
|
|
20
|
+
level: LogLevels.fatal
|
|
21
|
+
},
|
|
22
|
+
error: {
|
|
23
|
+
level: LogLevels.error
|
|
24
|
+
},
|
|
25
|
+
// Level 1
|
|
26
|
+
warn: {
|
|
27
|
+
level: LogLevels.warn
|
|
28
|
+
},
|
|
29
|
+
// Level 2
|
|
30
|
+
log: {
|
|
31
|
+
level: LogLevels.log
|
|
32
|
+
},
|
|
33
|
+
// Level 3
|
|
34
|
+
info: {
|
|
35
|
+
level: LogLevels.info
|
|
36
|
+
},
|
|
37
|
+
success: {
|
|
38
|
+
level: LogLevels.success
|
|
39
|
+
},
|
|
40
|
+
fail: {
|
|
41
|
+
level: LogLevels.fail
|
|
42
|
+
},
|
|
43
|
+
ready: {
|
|
44
|
+
level: LogLevels.info
|
|
45
|
+
},
|
|
46
|
+
start: {
|
|
47
|
+
level: LogLevels.info
|
|
48
|
+
},
|
|
49
|
+
box: {
|
|
50
|
+
level: LogLevels.info
|
|
51
|
+
},
|
|
52
|
+
// Level 4
|
|
53
|
+
debug: {
|
|
54
|
+
level: LogLevels.debug
|
|
55
|
+
},
|
|
56
|
+
// Level 5
|
|
57
|
+
trace: {
|
|
58
|
+
level: LogLevels.trace
|
|
59
|
+
},
|
|
60
|
+
// Verbose
|
|
61
|
+
verbose: {
|
|
62
|
+
level: LogLevels.verbose
|
|
63
|
+
}
|
|
64
|
+
};
|
|
65
|
+
|
|
66
|
+
function isPlainObject$1(value) {
|
|
67
|
+
if (value === null || typeof value !== "object") {
|
|
68
|
+
return false;
|
|
69
|
+
}
|
|
70
|
+
const prototype = Object.getPrototypeOf(value);
|
|
71
|
+
if (prototype !== null && prototype !== Object.prototype && Object.getPrototypeOf(prototype) !== null) {
|
|
72
|
+
return false;
|
|
73
|
+
}
|
|
74
|
+
if (Symbol.iterator in value) {
|
|
75
|
+
return false;
|
|
76
|
+
}
|
|
77
|
+
if (Symbol.toStringTag in value) {
|
|
78
|
+
return Object.prototype.toString.call(value) === "[object Module]";
|
|
79
|
+
}
|
|
80
|
+
return true;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
function _defu(baseObject, defaults, namespace = ".", merger) {
|
|
84
|
+
if (!isPlainObject$1(defaults)) {
|
|
85
|
+
return _defu(baseObject, {}, namespace);
|
|
86
|
+
}
|
|
87
|
+
const object = Object.assign({}, defaults);
|
|
88
|
+
for (const key in baseObject) {
|
|
89
|
+
if (key === "__proto__" || key === "constructor") {
|
|
90
|
+
continue;
|
|
91
|
+
}
|
|
92
|
+
const value = baseObject[key];
|
|
93
|
+
if (value === null || value === void 0) {
|
|
94
|
+
continue;
|
|
95
|
+
}
|
|
96
|
+
if (Array.isArray(value) && Array.isArray(object[key])) {
|
|
97
|
+
object[key] = [...value, ...object[key]];
|
|
98
|
+
} else if (isPlainObject$1(value) && isPlainObject$1(object[key])) {
|
|
99
|
+
object[key] = _defu(
|
|
100
|
+
value,
|
|
101
|
+
object[key],
|
|
102
|
+
(namespace ? `${namespace}.` : "") + key.toString());
|
|
103
|
+
} else {
|
|
104
|
+
object[key] = value;
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
return object;
|
|
108
|
+
}
|
|
109
|
+
function createDefu(merger) {
|
|
110
|
+
return (...arguments_) => (
|
|
111
|
+
// eslint-disable-next-line unicorn/no-array-reduce
|
|
112
|
+
arguments_.reduce((p, c) => _defu(p, c, ""), {})
|
|
113
|
+
);
|
|
114
|
+
}
|
|
115
|
+
const defu = createDefu();
|
|
116
|
+
|
|
117
|
+
function isPlainObject(obj) {
|
|
118
|
+
return Object.prototype.toString.call(obj) === "[object Object]";
|
|
119
|
+
}
|
|
120
|
+
function isLogObj(arg) {
|
|
121
|
+
if (!isPlainObject(arg)) {
|
|
122
|
+
return false;
|
|
123
|
+
}
|
|
124
|
+
if (!arg.message && !arg.args) {
|
|
125
|
+
return false;
|
|
126
|
+
}
|
|
127
|
+
if (arg.stack) {
|
|
128
|
+
return false;
|
|
129
|
+
}
|
|
130
|
+
return true;
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
let paused = false;
|
|
134
|
+
const queue = [];
|
|
135
|
+
class Consola {
|
|
136
|
+
options;
|
|
137
|
+
_lastLog;
|
|
138
|
+
_mockFn;
|
|
139
|
+
/**
|
|
140
|
+
* Creates an instance of Consola with specified options or defaults.
|
|
141
|
+
*
|
|
142
|
+
* @param {Partial<ConsolaOptions>} [options={}] - Configuration options for the Consola instance.
|
|
143
|
+
*/
|
|
144
|
+
constructor(options = {}) {
|
|
145
|
+
const types = options.types || LogTypes;
|
|
146
|
+
this.options = defu(
|
|
147
|
+
{
|
|
148
|
+
...options,
|
|
149
|
+
defaults: { ...options.defaults },
|
|
150
|
+
level: _normalizeLogLevel(options.level, types),
|
|
151
|
+
reporters: [...options.reporters || []]
|
|
152
|
+
},
|
|
153
|
+
{
|
|
154
|
+
types: LogTypes,
|
|
155
|
+
throttle: 1e3,
|
|
156
|
+
throttleMin: 5,
|
|
157
|
+
formatOptions: {
|
|
158
|
+
date: true,
|
|
159
|
+
colors: false,
|
|
160
|
+
compact: true
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
);
|
|
164
|
+
for (const type in types) {
|
|
165
|
+
const defaults = {
|
|
166
|
+
type,
|
|
167
|
+
...this.options.defaults,
|
|
168
|
+
...types[type]
|
|
169
|
+
};
|
|
170
|
+
this[type] = this._wrapLogFn(defaults);
|
|
171
|
+
this[type].raw = this._wrapLogFn(
|
|
172
|
+
defaults,
|
|
173
|
+
true
|
|
174
|
+
);
|
|
175
|
+
}
|
|
176
|
+
if (this.options.mockFn) {
|
|
177
|
+
this.mockTypes();
|
|
178
|
+
}
|
|
179
|
+
this._lastLog = {};
|
|
180
|
+
}
|
|
181
|
+
/**
|
|
182
|
+
* Gets the current log level of the Consola instance.
|
|
183
|
+
*
|
|
184
|
+
* @returns {number} The current log level.
|
|
185
|
+
*/
|
|
186
|
+
get level() {
|
|
187
|
+
return this.options.level;
|
|
188
|
+
}
|
|
189
|
+
/**
|
|
190
|
+
* Sets the minimum log level that will be output by the instance.
|
|
191
|
+
*
|
|
192
|
+
* @param {number} level - The new log level to set.
|
|
193
|
+
*/
|
|
194
|
+
set level(level) {
|
|
195
|
+
this.options.level = _normalizeLogLevel(
|
|
196
|
+
level,
|
|
197
|
+
this.options.types,
|
|
198
|
+
this.options.level
|
|
199
|
+
);
|
|
200
|
+
}
|
|
201
|
+
/**
|
|
202
|
+
* Displays a prompt to the user and returns the response.
|
|
203
|
+
* Throw an error if `prompt` is not supported by the current configuration.
|
|
204
|
+
*
|
|
205
|
+
* @template T
|
|
206
|
+
* @param {string} message - The message to display in the prompt.
|
|
207
|
+
* @param {T} [opts] - Optional options for the prompt. See {@link PromptOptions}.
|
|
208
|
+
* @returns {promise<T>} A promise that infer with the prompt options. See {@link PromptOptions}.
|
|
209
|
+
*/
|
|
210
|
+
prompt(message, opts) {
|
|
211
|
+
if (!this.options.prompt) {
|
|
212
|
+
throw new Error("prompt is not supported!");
|
|
213
|
+
}
|
|
214
|
+
return this.options.prompt(message, opts);
|
|
215
|
+
}
|
|
216
|
+
/**
|
|
217
|
+
* Creates a new instance of Consola, inheriting options from the current instance, with possible overrides.
|
|
218
|
+
*
|
|
219
|
+
* @param {Partial<ConsolaOptions>} options - Optional overrides for the new instance. See {@link ConsolaOptions}.
|
|
220
|
+
* @returns {ConsolaInstance} A new Consola instance. See {@link ConsolaInstance}.
|
|
221
|
+
*/
|
|
222
|
+
create(options) {
|
|
223
|
+
const instance = new Consola({
|
|
224
|
+
...this.options,
|
|
225
|
+
...options
|
|
226
|
+
});
|
|
227
|
+
if (this._mockFn) {
|
|
228
|
+
instance.mockTypes(this._mockFn);
|
|
229
|
+
}
|
|
230
|
+
return instance;
|
|
231
|
+
}
|
|
232
|
+
/**
|
|
233
|
+
* Creates a new Consola instance with the specified default log object properties.
|
|
234
|
+
*
|
|
235
|
+
* @param {InputLogObject} defaults - Default properties to include in any log from the new instance. See {@link InputLogObject}.
|
|
236
|
+
* @returns {ConsolaInstance} A new Consola instance. See {@link ConsolaInstance}.
|
|
237
|
+
*/
|
|
238
|
+
withDefaults(defaults) {
|
|
239
|
+
return this.create({
|
|
240
|
+
...this.options,
|
|
241
|
+
defaults: {
|
|
242
|
+
...this.options.defaults,
|
|
243
|
+
...defaults
|
|
244
|
+
}
|
|
245
|
+
});
|
|
246
|
+
}
|
|
247
|
+
/**
|
|
248
|
+
* Creates a new Consola instance with a specified tag, which will be included in every log.
|
|
249
|
+
*
|
|
250
|
+
* @param {string} tag - The tag to include in each log of the new instance.
|
|
251
|
+
* @returns {ConsolaInstance} A new Consola instance. See {@link ConsolaInstance}.
|
|
252
|
+
*/
|
|
253
|
+
withTag(tag) {
|
|
254
|
+
return this.withDefaults({
|
|
255
|
+
tag: this.options.defaults.tag ? this.options.defaults.tag + ":" + tag : tag
|
|
256
|
+
});
|
|
257
|
+
}
|
|
258
|
+
/**
|
|
259
|
+
* Adds a custom reporter to the Consola instance.
|
|
260
|
+
* Reporters will be called for each log message, depending on their implementation and log level.
|
|
261
|
+
*
|
|
262
|
+
* @param {ConsolaReporter} reporter - The reporter to add. See {@link ConsolaReporter}.
|
|
263
|
+
* @returns {Consola} The current Consola instance.
|
|
264
|
+
*/
|
|
265
|
+
addReporter(reporter) {
|
|
266
|
+
this.options.reporters.push(reporter);
|
|
267
|
+
return this;
|
|
268
|
+
}
|
|
269
|
+
/**
|
|
270
|
+
* Removes a custom reporter from the Consola instance.
|
|
271
|
+
* If no reporter is specified, all reporters will be removed.
|
|
272
|
+
*
|
|
273
|
+
* @param {ConsolaReporter} reporter - The reporter to remove. See {@link ConsolaReporter}.
|
|
274
|
+
* @returns {Consola} The current Consola instance.
|
|
275
|
+
*/
|
|
276
|
+
removeReporter(reporter) {
|
|
277
|
+
if (reporter) {
|
|
278
|
+
const i = this.options.reporters.indexOf(reporter);
|
|
279
|
+
if (i !== -1) {
|
|
280
|
+
return this.options.reporters.splice(i, 1);
|
|
281
|
+
}
|
|
282
|
+
} else {
|
|
283
|
+
this.options.reporters.splice(0);
|
|
284
|
+
}
|
|
285
|
+
return this;
|
|
286
|
+
}
|
|
287
|
+
/**
|
|
288
|
+
* Replaces all reporters of the Consola instance with the specified array of reporters.
|
|
289
|
+
*
|
|
290
|
+
* @param {ConsolaReporter[]} reporters - The new reporters to set. See {@link ConsolaReporter}.
|
|
291
|
+
* @returns {Consola} The current Consola instance.
|
|
292
|
+
*/
|
|
293
|
+
setReporters(reporters) {
|
|
294
|
+
this.options.reporters = Array.isArray(reporters) ? reporters : [reporters];
|
|
295
|
+
return this;
|
|
296
|
+
}
|
|
297
|
+
wrapAll() {
|
|
298
|
+
this.wrapConsole();
|
|
299
|
+
this.wrapStd();
|
|
300
|
+
}
|
|
301
|
+
restoreAll() {
|
|
302
|
+
this.restoreConsole();
|
|
303
|
+
this.restoreStd();
|
|
304
|
+
}
|
|
305
|
+
/**
|
|
306
|
+
* Overrides console methods with Consola logging methods for consistent logging.
|
|
307
|
+
*/
|
|
308
|
+
wrapConsole() {
|
|
309
|
+
for (const type in this.options.types) {
|
|
310
|
+
if (!console["__" + type]) {
|
|
311
|
+
console["__" + type] = console[type];
|
|
312
|
+
}
|
|
313
|
+
console[type] = this[type].raw;
|
|
314
|
+
}
|
|
315
|
+
}
|
|
316
|
+
/**
|
|
317
|
+
* Restores the original console methods, removing Consola overrides.
|
|
318
|
+
*/
|
|
319
|
+
restoreConsole() {
|
|
320
|
+
for (const type in this.options.types) {
|
|
321
|
+
if (console["__" + type]) {
|
|
322
|
+
console[type] = console["__" + type];
|
|
323
|
+
delete console["__" + type];
|
|
324
|
+
}
|
|
325
|
+
}
|
|
326
|
+
}
|
|
327
|
+
/**
|
|
328
|
+
* Overrides standard output and error streams to redirect them through Consola.
|
|
329
|
+
*/
|
|
330
|
+
wrapStd() {
|
|
331
|
+
this._wrapStream(this.options.stdout, "log");
|
|
332
|
+
this._wrapStream(this.options.stderr, "log");
|
|
333
|
+
}
|
|
334
|
+
_wrapStream(stream, type) {
|
|
335
|
+
if (!stream) {
|
|
336
|
+
return;
|
|
337
|
+
}
|
|
338
|
+
if (!stream.__write) {
|
|
339
|
+
stream.__write = stream.write;
|
|
340
|
+
}
|
|
341
|
+
stream.write = (data) => {
|
|
342
|
+
this[type].raw(String(data).trim());
|
|
343
|
+
};
|
|
344
|
+
}
|
|
345
|
+
/**
|
|
346
|
+
* Restores the original standard output and error streams, removing the Consola redirection.
|
|
347
|
+
*/
|
|
348
|
+
restoreStd() {
|
|
349
|
+
this._restoreStream(this.options.stdout);
|
|
350
|
+
this._restoreStream(this.options.stderr);
|
|
351
|
+
}
|
|
352
|
+
_restoreStream(stream) {
|
|
353
|
+
if (!stream) {
|
|
354
|
+
return;
|
|
355
|
+
}
|
|
356
|
+
if (stream.__write) {
|
|
357
|
+
stream.write = stream.__write;
|
|
358
|
+
delete stream.__write;
|
|
359
|
+
}
|
|
360
|
+
}
|
|
361
|
+
/**
|
|
362
|
+
* Pauses logging, queues incoming logs until resumed.
|
|
363
|
+
*/
|
|
364
|
+
pauseLogs() {
|
|
365
|
+
paused = true;
|
|
366
|
+
}
|
|
367
|
+
/**
|
|
368
|
+
* Resumes logging, processing any queued logs.
|
|
369
|
+
*/
|
|
370
|
+
resumeLogs() {
|
|
371
|
+
paused = false;
|
|
372
|
+
const _queue = queue.splice(0);
|
|
373
|
+
for (const item of _queue) {
|
|
374
|
+
item[0]._logFn(item[1], item[2]);
|
|
375
|
+
}
|
|
376
|
+
}
|
|
377
|
+
/**
|
|
378
|
+
* Replaces logging methods with mocks if a mock function is provided.
|
|
379
|
+
*
|
|
380
|
+
* @param {ConsolaOptions["mockFn"]} mockFn - The function to use for mocking logging methods. See {@link ConsolaOptions["mockFn"]}.
|
|
381
|
+
*/
|
|
382
|
+
mockTypes(mockFn) {
|
|
383
|
+
const _mockFn = mockFn || this.options.mockFn;
|
|
384
|
+
this._mockFn = _mockFn;
|
|
385
|
+
if (typeof _mockFn !== "function") {
|
|
386
|
+
return;
|
|
387
|
+
}
|
|
388
|
+
for (const type in this.options.types) {
|
|
389
|
+
this[type] = _mockFn(type, this.options.types[type]) || this[type];
|
|
390
|
+
this[type].raw = this[type];
|
|
391
|
+
}
|
|
392
|
+
}
|
|
393
|
+
_wrapLogFn(defaults, isRaw) {
|
|
394
|
+
return (...args) => {
|
|
395
|
+
if (paused) {
|
|
396
|
+
queue.push([this, defaults, args, isRaw]);
|
|
397
|
+
return;
|
|
398
|
+
}
|
|
399
|
+
return this._logFn(defaults, args, isRaw);
|
|
400
|
+
};
|
|
401
|
+
}
|
|
402
|
+
_logFn(defaults, args, isRaw) {
|
|
403
|
+
if ((defaults.level || 0) > this.level) {
|
|
404
|
+
return false;
|
|
405
|
+
}
|
|
406
|
+
const logObj = {
|
|
407
|
+
date: /* @__PURE__ */ new Date(),
|
|
408
|
+
args: [],
|
|
409
|
+
...defaults,
|
|
410
|
+
level: _normalizeLogLevel(defaults.level, this.options.types)
|
|
411
|
+
};
|
|
412
|
+
if (!isRaw && args.length === 1 && isLogObj(args[0])) {
|
|
413
|
+
Object.assign(logObj, args[0]);
|
|
414
|
+
} else {
|
|
415
|
+
logObj.args = [...args];
|
|
416
|
+
}
|
|
417
|
+
if (logObj.message) {
|
|
418
|
+
logObj.args.unshift(logObj.message);
|
|
419
|
+
delete logObj.message;
|
|
420
|
+
}
|
|
421
|
+
if (logObj.additional) {
|
|
422
|
+
if (!Array.isArray(logObj.additional)) {
|
|
423
|
+
logObj.additional = logObj.additional.split("\n");
|
|
424
|
+
}
|
|
425
|
+
logObj.args.push("\n" + logObj.additional.join("\n"));
|
|
426
|
+
delete logObj.additional;
|
|
427
|
+
}
|
|
428
|
+
logObj.type = typeof logObj.type === "string" ? logObj.type.toLowerCase() : "log";
|
|
429
|
+
logObj.tag = typeof logObj.tag === "string" ? logObj.tag : "";
|
|
430
|
+
const resolveLog = (newLog = false) => {
|
|
431
|
+
const repeated = (this._lastLog.count || 0) - this.options.throttleMin;
|
|
432
|
+
if (this._lastLog.object && repeated > 0) {
|
|
433
|
+
const args2 = [...this._lastLog.object.args];
|
|
434
|
+
if (repeated > 1) {
|
|
435
|
+
args2.push(`(repeated ${repeated} times)`);
|
|
436
|
+
}
|
|
437
|
+
this._log({ ...this._lastLog.object, args: args2 });
|
|
438
|
+
this._lastLog.count = 1;
|
|
439
|
+
}
|
|
440
|
+
if (newLog) {
|
|
441
|
+
this._lastLog.object = logObj;
|
|
442
|
+
this._log(logObj);
|
|
443
|
+
}
|
|
444
|
+
};
|
|
445
|
+
clearTimeout(this._lastLog.timeout);
|
|
446
|
+
const diffTime = this._lastLog.time && logObj.date ? logObj.date.getTime() - this._lastLog.time.getTime() : 0;
|
|
447
|
+
this._lastLog.time = logObj.date;
|
|
448
|
+
if (diffTime < this.options.throttle) {
|
|
449
|
+
try {
|
|
450
|
+
const serializedLog = JSON.stringify([
|
|
451
|
+
logObj.type,
|
|
452
|
+
logObj.tag,
|
|
453
|
+
logObj.args
|
|
454
|
+
]);
|
|
455
|
+
const isSameLog = this._lastLog.serialized === serializedLog;
|
|
456
|
+
this._lastLog.serialized = serializedLog;
|
|
457
|
+
if (isSameLog) {
|
|
458
|
+
this._lastLog.count = (this._lastLog.count || 0) + 1;
|
|
459
|
+
if (this._lastLog.count > this.options.throttleMin) {
|
|
460
|
+
this._lastLog.timeout = setTimeout(
|
|
461
|
+
resolveLog,
|
|
462
|
+
this.options.throttle
|
|
463
|
+
);
|
|
464
|
+
return;
|
|
465
|
+
}
|
|
466
|
+
}
|
|
467
|
+
} catch {
|
|
468
|
+
}
|
|
469
|
+
}
|
|
470
|
+
resolveLog(true);
|
|
471
|
+
}
|
|
472
|
+
_log(logObj) {
|
|
473
|
+
for (const reporter of this.options.reporters) {
|
|
474
|
+
reporter.log(logObj, {
|
|
475
|
+
options: this.options
|
|
476
|
+
});
|
|
477
|
+
}
|
|
478
|
+
}
|
|
479
|
+
}
|
|
480
|
+
function _normalizeLogLevel(input, types = {}, defaultLevel = 3) {
|
|
481
|
+
if (input === void 0) {
|
|
482
|
+
return defaultLevel;
|
|
483
|
+
}
|
|
484
|
+
if (typeof input === "number") {
|
|
485
|
+
return input;
|
|
486
|
+
}
|
|
487
|
+
if (types[input] && types[input].level !== void 0) {
|
|
488
|
+
return types[input].level;
|
|
489
|
+
}
|
|
490
|
+
return defaultLevel;
|
|
491
|
+
}
|
|
492
|
+
Consola.prototype.add = Consola.prototype.addReporter;
|
|
493
|
+
Consola.prototype.remove = Consola.prototype.removeReporter;
|
|
494
|
+
Consola.prototype.clear = Consola.prototype.removeReporter;
|
|
495
|
+
Consola.prototype.withScope = Consola.prototype.withTag;
|
|
496
|
+
Consola.prototype.mock = Consola.prototype.mockTypes;
|
|
497
|
+
Consola.prototype.pause = Consola.prototype.pauseLogs;
|
|
498
|
+
Consola.prototype.resume = Consola.prototype.resumeLogs;
|
|
499
|
+
function createConsola$1(options = {}) {
|
|
500
|
+
return new Consola(options);
|
|
501
|
+
}
|
|
502
|
+
|
|
503
|
+
class BrowserReporter {
|
|
504
|
+
options;
|
|
505
|
+
defaultColor;
|
|
506
|
+
levelColorMap;
|
|
507
|
+
typeColorMap;
|
|
508
|
+
constructor(options) {
|
|
509
|
+
this.options = { ...options };
|
|
510
|
+
this.defaultColor = "#7f8c8d";
|
|
511
|
+
this.levelColorMap = {
|
|
512
|
+
0: "#c0392b",
|
|
513
|
+
// Red
|
|
514
|
+
1: "#f39c12",
|
|
515
|
+
// Yellow
|
|
516
|
+
3: "#00BCD4"
|
|
517
|
+
// Cyan
|
|
518
|
+
};
|
|
519
|
+
this.typeColorMap = {
|
|
520
|
+
success: "#2ecc71"
|
|
521
|
+
// Green
|
|
522
|
+
};
|
|
523
|
+
}
|
|
524
|
+
_getLogFn(level) {
|
|
525
|
+
if (level < 1) {
|
|
526
|
+
return console.__error || console.error;
|
|
527
|
+
}
|
|
528
|
+
if (level === 1) {
|
|
529
|
+
return console.__warn || console.warn;
|
|
530
|
+
}
|
|
531
|
+
return console.__log || console.log;
|
|
532
|
+
}
|
|
533
|
+
log(logObj) {
|
|
534
|
+
const consoleLogFn = this._getLogFn(logObj.level);
|
|
535
|
+
const type = logObj.type === "log" ? "" : logObj.type;
|
|
536
|
+
const tag = logObj.tag || "";
|
|
537
|
+
const color = this.typeColorMap[logObj.type] || this.levelColorMap[logObj.level] || this.defaultColor;
|
|
538
|
+
const style = `
|
|
539
|
+
background: ${color};
|
|
540
|
+
border-radius: 0.5em;
|
|
541
|
+
color: white;
|
|
542
|
+
font-weight: bold;
|
|
543
|
+
padding: 2px 0.5em;
|
|
544
|
+
`;
|
|
545
|
+
const badge = `%c${[tag, type].filter(Boolean).join(":")}`;
|
|
546
|
+
if (typeof logObj.args[0] === "string") {
|
|
547
|
+
consoleLogFn(
|
|
548
|
+
`${badge}%c ${logObj.args[0]}`,
|
|
549
|
+
style,
|
|
550
|
+
// Empty string as style resets to default console style
|
|
551
|
+
"",
|
|
552
|
+
...logObj.args.slice(1)
|
|
553
|
+
);
|
|
554
|
+
} else {
|
|
555
|
+
consoleLogFn(badge, style, ...logObj.args);
|
|
556
|
+
}
|
|
557
|
+
}
|
|
558
|
+
}
|
|
559
|
+
|
|
560
|
+
function createConsola(options = {}) {
|
|
561
|
+
const consola2 = createConsola$1({
|
|
562
|
+
reporters: options.reporters || [new BrowserReporter({})],
|
|
563
|
+
prompt(message, options2 = {}) {
|
|
564
|
+
if (options2.type === "confirm") {
|
|
565
|
+
return Promise.resolve(confirm(message));
|
|
566
|
+
}
|
|
567
|
+
return Promise.resolve(prompt(message));
|
|
568
|
+
},
|
|
569
|
+
...options
|
|
570
|
+
});
|
|
571
|
+
return consola2;
|
|
572
|
+
}
|
|
573
|
+
const consola = createConsola();
|
|
574
|
+
|
|
575
|
+
export { consola as c };
|
|
@@ -206,6 +206,10 @@ declare const _default: import("vue").DefineComponent<import("vue").ExtractPropT
|
|
|
206
206
|
type: import("vue").PropType<import("@vunk/shared").AnyFunc>;
|
|
207
207
|
default: import("@vunk/shared").AnyFunc;
|
|
208
208
|
};
|
|
209
|
+
retryTimes: {
|
|
210
|
+
type: NumberConstructor;
|
|
211
|
+
default: number;
|
|
212
|
+
};
|
|
209
213
|
}>, {
|
|
210
214
|
props: import("@vue/shared").LooseRequired<Readonly<import("vue").ExtractPropTypes<{
|
|
211
215
|
enable: {
|
|
@@ -224,11 +228,16 @@ declare const _default: import("vue").DefineComponent<import("vue").ExtractPropT
|
|
|
224
228
|
type: import("vue").PropType<import("@vunk/shared").AnyFunc>;
|
|
225
229
|
default: import("@vunk/shared").AnyFunc;
|
|
226
230
|
};
|
|
231
|
+
retryTimes: {
|
|
232
|
+
type: NumberConstructor;
|
|
233
|
+
default: number;
|
|
234
|
+
};
|
|
227
235
|
}>> & Readonly<{
|
|
228
236
|
"onUpdate:status"?: ((...args: any[]) => any) | undefined;
|
|
229
237
|
}> & {}>;
|
|
230
238
|
emit: (event: "update:status", ...args: any[]) => void;
|
|
231
239
|
theDef: import("vue").ShallowRef<import("@vunk/shared/promise").Deferred<any> | undefined, import("@vunk/shared/promise").Deferred<any> | undefined>;
|
|
240
|
+
retryTimes: number;
|
|
232
241
|
processingDef: {
|
|
233
242
|
_ref: import("vue").ShallowRef<unknown, unknown>;
|
|
234
243
|
readonly value: unknown;
|
|
@@ -254,6 +263,10 @@ declare const _default: import("vue").DefineComponent<import("vue").ExtractPropT
|
|
|
254
263
|
type: import("vue").PropType<import("@vunk/shared").AnyFunc>;
|
|
255
264
|
default: import("@vunk/shared").AnyFunc;
|
|
256
265
|
};
|
|
266
|
+
retryTimes: {
|
|
267
|
+
type: NumberConstructor;
|
|
268
|
+
default: number;
|
|
269
|
+
};
|
|
257
270
|
}>> & Readonly<{
|
|
258
271
|
"onUpdate:status"?: ((...args: any[]) => any) | undefined;
|
|
259
272
|
}>, {
|
|
@@ -261,6 +274,7 @@ declare const _default: import("vue").DefineComponent<import("vue").ExtractPropT
|
|
|
261
274
|
pause: boolean;
|
|
262
275
|
enable: boolean;
|
|
263
276
|
status: import("../../broadcasting-markdown").ParagraphStatus;
|
|
277
|
+
retryTimes: number;
|
|
264
278
|
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
|
|
265
279
|
VkTypingMarkdown: import("vue").DefineComponent<import("vue").ExtractPropTypes<{
|
|
266
280
|
source: {
|
|
@@ -184,6 +184,10 @@ declare const _default: import("vue").DefineComponent<import("vue").ExtractPropT
|
|
|
184
184
|
type: PropType<import("@vunk/shared").AnyFunc>;
|
|
185
185
|
default: import("@vunk/shared").AnyFunc;
|
|
186
186
|
};
|
|
187
|
+
retryTimes: {
|
|
188
|
+
type: NumberConstructor;
|
|
189
|
+
default: number;
|
|
190
|
+
};
|
|
187
191
|
}>, {
|
|
188
192
|
props: import("@vue/shared").LooseRequired<Readonly<import("vue").ExtractPropTypes<{
|
|
189
193
|
enable: {
|
|
@@ -202,11 +206,16 @@ declare const _default: import("vue").DefineComponent<import("vue").ExtractPropT
|
|
|
202
206
|
type: PropType<import("@vunk/shared").AnyFunc>;
|
|
203
207
|
default: import("@vunk/shared").AnyFunc;
|
|
204
208
|
};
|
|
209
|
+
retryTimes: {
|
|
210
|
+
type: NumberConstructor;
|
|
211
|
+
default: number;
|
|
212
|
+
};
|
|
205
213
|
}>> & Readonly<{
|
|
206
214
|
"onUpdate:status"?: ((...args: any[]) => any) | undefined;
|
|
207
215
|
}> & {}>;
|
|
208
216
|
emit: (event: "update:status", ...args: any[]) => void;
|
|
209
217
|
theDef: import("vue").ShallowRef<import("@vunk/shared/promise").Deferred<any> | undefined, import("@vunk/shared/promise").Deferred<any> | undefined>;
|
|
218
|
+
retryTimes: number;
|
|
210
219
|
processingDef: {
|
|
211
220
|
_ref: import("vue").ShallowRef<unknown, unknown>;
|
|
212
221
|
readonly value: unknown;
|
|
@@ -232,6 +241,10 @@ declare const _default: import("vue").DefineComponent<import("vue").ExtractPropT
|
|
|
232
241
|
type: PropType<import("@vunk/shared").AnyFunc>;
|
|
233
242
|
default: import("@vunk/shared").AnyFunc;
|
|
234
243
|
};
|
|
244
|
+
retryTimes: {
|
|
245
|
+
type: NumberConstructor;
|
|
246
|
+
default: number;
|
|
247
|
+
};
|
|
235
248
|
}>> & Readonly<{
|
|
236
249
|
"onUpdate:status"?: ((...args: any[]) => any) | undefined;
|
|
237
250
|
}>, {
|
|
@@ -239,6 +252,7 @@ declare const _default: import("vue").DefineComponent<import("vue").ExtractPropT
|
|
|
239
252
|
pause: boolean;
|
|
240
253
|
enable: boolean;
|
|
241
254
|
status: import("@vunk/plus/components/broadcasting-markdown").ParagraphStatus;
|
|
255
|
+
retryTimes: number;
|
|
242
256
|
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
|
|
243
257
|
VkTypingMarkdown: import("vue").DefineComponent<import("vue").ExtractPropTypes<{
|
|
244
258
|
source: {
|