@antdv-next/x-sdk 0.0.1 → 0.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.
Files changed (54) hide show
  1. package/dist/_util/resolveMaybeRef.d.ts +2 -0
  2. package/dist/_util/resolveMaybeRef.js +7 -0
  3. package/dist/_util/types.js +0 -0
  4. package/dist/chat-providers/AbstractChatProvider.d.ts +2 -2
  5. package/dist/chat-providers/AbstractChatProvider.js +42 -0
  6. package/dist/chat-providers/DeepSeekChatProvider.d.ts +2 -2
  7. package/dist/chat-providers/DeepSeekChatProvider.js +59 -0
  8. package/dist/chat-providers/DefaultChatProvider.d.ts +2 -2
  9. package/dist/chat-providers/DefaultChatProvider.js +26 -0
  10. package/dist/chat-providers/OpenAIChatProvider.d.ts +2 -2
  11. package/dist/chat-providers/OpenAIChatProvider.js +49 -0
  12. package/dist/chat-providers/index.js +4 -1
  13. package/dist/index.d.ts +1 -1
  14. package/dist/index.js +7 -3
  15. package/dist/node_modules/vitest/dist/@vitest/expect/index.js +1456 -0
  16. package/dist/node_modules/vitest/dist/@vitest/pretty-format/index.js +884 -0
  17. package/dist/node_modules/vitest/dist/@vitest/runner/chunk-artifact.js +1543 -0
  18. package/dist/node_modules/vitest/dist/@vitest/snapshot/index.js +660 -0
  19. package/dist/node_modules/vitest/dist/@vitest/spy/index.js +384 -0
  20. package/dist/node_modules/vitest/dist/@vitest/utils/chunk-pathe.M-eThtNZ.js +80 -0
  21. package/dist/node_modules/vitest/dist/@vitest/utils/diff.js +1304 -0
  22. package/dist/node_modules/vitest/dist/@vitest/utils/display.js +556 -0
  23. package/dist/node_modules/vitest/dist/@vitest/utils/error.js +27 -0
  24. package/dist/node_modules/vitest/dist/@vitest/utils/helpers.js +179 -0
  25. package/dist/node_modules/vitest/dist/@vitest/utils/offset.js +25 -0
  26. package/dist/node_modules/vitest/dist/@vitest/utils/serialize.js +75 -0
  27. package/dist/node_modules/vitest/dist/@vitest/utils/source-map.js +371 -0
  28. package/dist/node_modules/vitest/dist/@vitest/utils/timers.js +35 -0
  29. package/dist/node_modules/vitest/dist/chunks/_commonjsHelpers.D26ty3Ew.js +4 -0
  30. package/dist/node_modules/vitest/dist/chunks/rpc.MzXet3jl.js +50 -0
  31. package/dist/node_modules/vitest/dist/chunks/test.CBQUpOM3.js +2640 -0
  32. package/dist/node_modules/vitest/dist/chunks/utils.BX5Fg8C4.js +42 -0
  33. package/dist/node_modules/vitest/dist/vendor/chai.js +2872 -0
  34. package/dist/node_modules/vitest/dist/vendor/magic-string.js +1009 -0
  35. package/dist/node_modules/vitest/dist/vendor/tinyrainbow.js +84 -0
  36. package/dist/x-chat/__tests__/index.test.d.ts +1 -0
  37. package/dist/x-chat/__tests__/index.test.js +257 -0
  38. package/dist/x-chat/index.d.ts +14 -23
  39. package/dist/x-chat/index.js +83 -66
  40. package/dist/x-chat/store.d.ts +2 -0
  41. package/dist/{store-C1diHqNH.js → x-chat/store.js} +15 -9
  42. package/dist/x-conversations/__tests__/index.test.d.ts +1 -0
  43. package/dist/x-conversations/__tests__/index.test.js +36 -0
  44. package/dist/x-conversations/index.d.ts +4 -4
  45. package/dist/x-conversations/index.js +37 -1
  46. package/dist/{x-conversations-BrKWhj5r.js → x-conversations/store.js} +2 -31
  47. package/dist/x-request/__tests__/index.test.d.ts +1 -0
  48. package/dist/x-request/__tests__/index.test.js +90 -0
  49. package/dist/x-request/index.d.ts +36 -11
  50. package/dist/x-request/index.js +246 -1
  51. package/dist/x-request/x-fetch.js +18 -0
  52. package/package.json +1 -1
  53. package/dist/chat-providers-5x9Va7p5.js +0 -167
  54. package/dist/x-request-BSFGaKND.js +0 -234
@@ -0,0 +1,556 @@
1
+ import { createDOMElementFilter, format as format$1, plugins } from "../pretty-format/index.js";
2
+ //#region ../../node_modules/vitest/dist/@vitest/utils/display.js
3
+ var ansiColors = {
4
+ bold: ["1", "22"],
5
+ dim: ["2", "22"],
6
+ italic: ["3", "23"],
7
+ underline: ["4", "24"],
8
+ inverse: ["7", "27"],
9
+ hidden: ["8", "28"],
10
+ strike: ["9", "29"],
11
+ black: ["30", "39"],
12
+ red: ["31", "39"],
13
+ green: ["32", "39"],
14
+ yellow: ["33", "39"],
15
+ blue: ["34", "39"],
16
+ magenta: ["35", "39"],
17
+ cyan: ["36", "39"],
18
+ white: ["37", "39"],
19
+ brightblack: ["30;1", "39"],
20
+ brightred: ["31;1", "39"],
21
+ brightgreen: ["32;1", "39"],
22
+ brightyellow: ["33;1", "39"],
23
+ brightblue: ["34;1", "39"],
24
+ brightmagenta: ["35;1", "39"],
25
+ brightcyan: ["36;1", "39"],
26
+ brightwhite: ["37;1", "39"],
27
+ grey: ["90", "39"]
28
+ };
29
+ var styles = {
30
+ special: "cyan",
31
+ number: "yellow",
32
+ bigint: "yellow",
33
+ boolean: "yellow",
34
+ undefined: "grey",
35
+ null: "bold",
36
+ string: "green",
37
+ symbol: "green",
38
+ date: "magenta",
39
+ regexp: "red"
40
+ };
41
+ var truncator = "…";
42
+ function colorise(value, styleType) {
43
+ const color = ansiColors[styles[styleType]] || ansiColors[styleType] || "";
44
+ if (!color) return String(value);
45
+ return `\u001b[${color[0]}m${String(value)}\u001b[${color[1]}m`;
46
+ }
47
+ function normaliseOptions({ showHidden = false, depth = 2, colors = false, customInspect = true, showProxy = false, maxArrayLength = Infinity, breakLength = Infinity, seen = [], truncate = Infinity, stylize = String } = {}, inspect) {
48
+ const options = {
49
+ showHidden: Boolean(showHidden),
50
+ depth: Number(depth),
51
+ colors: Boolean(colors),
52
+ customInspect: Boolean(customInspect),
53
+ showProxy: Boolean(showProxy),
54
+ maxArrayLength: Number(maxArrayLength),
55
+ breakLength: Number(breakLength),
56
+ truncate: Number(truncate),
57
+ seen,
58
+ inspect,
59
+ stylize
60
+ };
61
+ if (options.colors) options.stylize = colorise;
62
+ return options;
63
+ }
64
+ function isHighSurrogate(char) {
65
+ return char >= "\ud800" && char <= "\udbff";
66
+ }
67
+ function truncate(string, length, tail = truncator) {
68
+ string = String(string);
69
+ const tailLength = tail.length;
70
+ const stringLength = string.length;
71
+ if (tailLength > length && stringLength > tailLength) return tail;
72
+ if (stringLength > length && stringLength > tailLength) {
73
+ let end = length - tailLength;
74
+ if (end > 0 && isHighSurrogate(string[end - 1])) end = end - 1;
75
+ return `${string.slice(0, end)}${tail}`;
76
+ }
77
+ return string;
78
+ }
79
+ function inspectList(list, options, inspectItem, separator = ", ") {
80
+ inspectItem = inspectItem || options.inspect;
81
+ const size = list.length;
82
+ if (size === 0) return "";
83
+ const originalLength = options.truncate;
84
+ let output = "";
85
+ let peek = "";
86
+ let truncated = "";
87
+ for (let i = 0; i < size; i += 1) {
88
+ const last = i + 1 === list.length;
89
+ const secondToLast = i + 2 === list.length;
90
+ truncated = `${truncator}(${list.length - i})`;
91
+ const value = list[i];
92
+ options.truncate = originalLength - output.length - (last ? 0 : separator.length);
93
+ const string = peek || inspectItem(value, options) + (last ? "" : separator);
94
+ const nextLength = output.length + string.length;
95
+ const truncatedLength = nextLength + truncated.length;
96
+ if (last && nextLength > originalLength && output.length + truncated.length <= originalLength) break;
97
+ if (!last && !secondToLast && truncatedLength > originalLength) break;
98
+ peek = last ? "" : inspectItem(list[i + 1], options) + (secondToLast ? "" : separator);
99
+ if (!last && secondToLast && truncatedLength > originalLength && nextLength + peek.length > originalLength) break;
100
+ output += string;
101
+ if (!last && !secondToLast && nextLength + peek.length >= originalLength) {
102
+ truncated = `${truncator}(${list.length - i - 1})`;
103
+ break;
104
+ }
105
+ truncated = "";
106
+ }
107
+ return `${output}${truncated}`;
108
+ }
109
+ function quoteComplexKey(key) {
110
+ if (key.match(/^[a-zA-Z_][a-zA-Z_0-9]*$/)) return key;
111
+ return JSON.stringify(key).replace(/'/g, "\\'").replace(/\\"/g, "\"").replace(/(^"|"$)/g, "'");
112
+ }
113
+ function inspectProperty([key, value], options) {
114
+ options.truncate -= 2;
115
+ if (typeof key === "string") key = quoteComplexKey(key);
116
+ else if (typeof key !== "number") key = `[${options.inspect(key, options)}]`;
117
+ options.truncate -= key.length;
118
+ value = options.inspect(value, options);
119
+ return `${key}: ${value}`;
120
+ }
121
+ function inspectArray(array, options) {
122
+ const nonIndexProperties = Object.keys(array).slice(array.length);
123
+ if (!array.length && !nonIndexProperties.length) return "[]";
124
+ options.truncate -= 4;
125
+ const listContents = inspectList(array, options);
126
+ options.truncate -= listContents.length;
127
+ let propertyContents = "";
128
+ if (nonIndexProperties.length) propertyContents = inspectList(nonIndexProperties.map((key) => [key, array[key]]), options, inspectProperty);
129
+ return `[ ${listContents}${propertyContents ? `, ${propertyContents}` : ""} ]`;
130
+ }
131
+ var getArrayName = (array) => {
132
+ if (typeof Buffer === "function" && array instanceof Buffer) return "Buffer";
133
+ if (array[Symbol.toStringTag]) return array[Symbol.toStringTag];
134
+ return array.constructor.name;
135
+ };
136
+ function inspectTypedArray(array, options) {
137
+ const name = getArrayName(array);
138
+ options.truncate -= name.length + 4;
139
+ const nonIndexProperties = Object.keys(array).slice(array.length);
140
+ if (!array.length && !nonIndexProperties.length) return `${name}[]`;
141
+ let output = "";
142
+ for (let i = 0; i < array.length; i++) {
143
+ const string = `${options.stylize(truncate(array[i], options.truncate), "number")}${i === array.length - 1 ? "" : ", "}`;
144
+ options.truncate -= string.length;
145
+ if (array[i] !== array.length && options.truncate <= 3) {
146
+ output += `${truncator}(${array.length - array[i] + 1})`;
147
+ break;
148
+ }
149
+ output += string;
150
+ }
151
+ let propertyContents = "";
152
+ if (nonIndexProperties.length) propertyContents = inspectList(nonIndexProperties.map((key) => [key, array[key]]), options, inspectProperty);
153
+ return `${name}[ ${output}${propertyContents ? `, ${propertyContents}` : ""} ]`;
154
+ }
155
+ function inspectDate(dateObject, options) {
156
+ const stringRepresentation = dateObject.toJSON();
157
+ if (stringRepresentation === null) return "Invalid Date";
158
+ const split = stringRepresentation.split("T");
159
+ const date = split[0];
160
+ return options.stylize(`${date}T${truncate(split[1], options.truncate - date.length - 1)}`, "date");
161
+ }
162
+ function inspectFunction(func, options) {
163
+ const functionType = func[Symbol.toStringTag] || "Function";
164
+ const name = func.name;
165
+ if (!name) return options.stylize(`[${functionType}]`, "special");
166
+ return options.stylize(`[${functionType} ${truncate(name, options.truncate - 11)}]`, "special");
167
+ }
168
+ function inspectMapEntry([key, value], options) {
169
+ options.truncate -= 4;
170
+ key = options.inspect(key, options);
171
+ options.truncate -= key.length;
172
+ value = options.inspect(value, options);
173
+ return `${key} => ${value}`;
174
+ }
175
+ function mapToEntries(map) {
176
+ const entries = [];
177
+ map.forEach((value, key) => {
178
+ entries.push([key, value]);
179
+ });
180
+ return entries;
181
+ }
182
+ function inspectMap(map, options) {
183
+ if (map.size === 0) return "Map{}";
184
+ options.truncate -= 7;
185
+ return `Map{ ${inspectList(mapToEntries(map), options, inspectMapEntry)} }`;
186
+ }
187
+ var isNaN = Number.isNaN || ((i) => i !== i);
188
+ function inspectNumber(number, options) {
189
+ if (isNaN(number)) return options.stylize("NaN", "number");
190
+ if (number === Infinity) return options.stylize("Infinity", "number");
191
+ if (number === -Infinity) return options.stylize("-Infinity", "number");
192
+ if (number === 0) return options.stylize(1 / number === Infinity ? "+0" : "-0", "number");
193
+ return options.stylize(truncate(String(number), options.truncate), "number");
194
+ }
195
+ function inspectBigInt(number, options) {
196
+ let nums = truncate(number.toString(), options.truncate - 1);
197
+ if (nums !== truncator) nums += "n";
198
+ return options.stylize(nums, "bigint");
199
+ }
200
+ function inspectRegExp(value, options) {
201
+ const flags = value.toString().split("/")[2];
202
+ const sourceLength = options.truncate - (2 + flags.length);
203
+ const source = value.source;
204
+ return options.stylize(`/${truncate(source, sourceLength)}/${flags}`, "regexp");
205
+ }
206
+ function arrayFromSet(set) {
207
+ const values = [];
208
+ set.forEach((value) => {
209
+ values.push(value);
210
+ });
211
+ return values;
212
+ }
213
+ function inspectSet(set, options) {
214
+ if (set.size === 0) return "Set{}";
215
+ options.truncate -= 7;
216
+ return `Set{ ${inspectList(arrayFromSet(set), options)} }`;
217
+ }
218
+ var stringEscapeChars = /* @__PURE__ */ new RegExp("['\\u0000-\\u001f\\u007f-\\u009f\\u00ad\\u0600-\\u0604\\u070f\\u17b4\\u17b5\\u200c-\\u200f\\u2028-\\u202f\\u2060-\\u206f\\ufeff\\ufff0-\\uffff]", "g");
219
+ var escapeCharacters = {
220
+ "\b": "\\b",
221
+ " ": "\\t",
222
+ "\n": "\\n",
223
+ "\f": "\\f",
224
+ "\r": "\\r",
225
+ "'": "\\'",
226
+ "\\": "\\\\"
227
+ };
228
+ var hex = 16;
229
+ function escape(char) {
230
+ return escapeCharacters[char] || `\\u${`0000${char.charCodeAt(0).toString(hex)}`.slice(-4)}`;
231
+ }
232
+ function inspectString(string, options) {
233
+ if (stringEscapeChars.test(string)) string = string.replace(stringEscapeChars, escape);
234
+ return options.stylize(`'${truncate(string, options.truncate - 2)}'`, "string");
235
+ }
236
+ function inspectSymbol(value) {
237
+ if ("description" in Symbol.prototype) return value.description ? `Symbol(${value.description})` : "Symbol()";
238
+ return value.toString();
239
+ }
240
+ var getPromiseValue = () => "Promise{…}";
241
+ function inspectObject$1(object, options) {
242
+ const properties = Object.getOwnPropertyNames(object);
243
+ const symbols = Object.getOwnPropertySymbols ? Object.getOwnPropertySymbols(object) : [];
244
+ if (properties.length === 0 && symbols.length === 0) return "{}";
245
+ options.truncate -= 4;
246
+ options.seen = options.seen || [];
247
+ if (options.seen.includes(object)) return "[Circular]";
248
+ options.seen.push(object);
249
+ const propertyContents = inspectList(properties.map((key) => [key, object[key]]), options, inspectProperty);
250
+ const symbolContents = inspectList(symbols.map((key) => [key, object[key]]), options, inspectProperty);
251
+ options.seen.pop();
252
+ let sep = "";
253
+ if (propertyContents && symbolContents) sep = ", ";
254
+ return `{ ${propertyContents}${sep}${symbolContents} }`;
255
+ }
256
+ var toStringTag = typeof Symbol !== "undefined" && Symbol.toStringTag ? Symbol.toStringTag : false;
257
+ function inspectClass(value, options) {
258
+ let name = "";
259
+ if (toStringTag && toStringTag in value) name = value[toStringTag];
260
+ name = name || value.constructor.name;
261
+ if (!name || name === "_class") name = "<Anonymous Class>";
262
+ options.truncate -= name.length;
263
+ return `${name}${inspectObject$1(value, options)}`;
264
+ }
265
+ function inspectArguments(args, options) {
266
+ if (args.length === 0) return "Arguments[]";
267
+ options.truncate -= 13;
268
+ return `Arguments[ ${inspectList(args, options)} ]`;
269
+ }
270
+ var errorKeys = [
271
+ "stack",
272
+ "line",
273
+ "column",
274
+ "name",
275
+ "message",
276
+ "fileName",
277
+ "lineNumber",
278
+ "columnNumber",
279
+ "number",
280
+ "description",
281
+ "cause"
282
+ ];
283
+ function inspectObject(error, options) {
284
+ const properties = Object.getOwnPropertyNames(error).filter((key) => errorKeys.indexOf(key) === -1);
285
+ const name = error.name;
286
+ options.truncate -= name.length;
287
+ let message = "";
288
+ if (typeof error.message === "string") message = truncate(error.message, options.truncate);
289
+ else properties.unshift("message");
290
+ message = message ? `: ${message}` : "";
291
+ options.truncate -= message.length + 5;
292
+ options.seen = options.seen || [];
293
+ if (options.seen.includes(error)) return "[Circular]";
294
+ options.seen.push(error);
295
+ const propertyContents = inspectList(properties.map((key) => [key, error[key]]), options, inspectProperty);
296
+ return `${name}${message}${propertyContents ? ` { ${propertyContents} }` : ""}`;
297
+ }
298
+ function inspectAttribute([key, value], options) {
299
+ options.truncate -= 3;
300
+ if (!value) return `${options.stylize(String(key), "yellow")}`;
301
+ return `${options.stylize(String(key), "yellow")}=${options.stylize(`"${value}"`, "string")}`;
302
+ }
303
+ function inspectNodeCollection(collection, options) {
304
+ return inspectList(collection, options, inspectNode, "\n");
305
+ }
306
+ function inspectNode(node, options) {
307
+ switch (node.nodeType) {
308
+ case 1: return inspectHTML(node, options);
309
+ case 3: return options.inspect(node.data, options);
310
+ default: return options.inspect(node, options);
311
+ }
312
+ }
313
+ function inspectHTML(element, options) {
314
+ const properties = element.getAttributeNames();
315
+ const name = element.tagName.toLowerCase();
316
+ const head = options.stylize(`<${name}`, "special");
317
+ const headClose = options.stylize(`>`, "special");
318
+ const tail = options.stylize(`</${name}>`, "special");
319
+ options.truncate -= name.length * 2 + 5;
320
+ let propertyContents = "";
321
+ if (properties.length > 0) {
322
+ propertyContents += " ";
323
+ propertyContents += inspectList(properties.map((key) => [key, element.getAttribute(key)]), options, inspectAttribute, " ");
324
+ }
325
+ options.truncate -= propertyContents.length;
326
+ const truncate = options.truncate;
327
+ let children = inspectNodeCollection(element.children, options);
328
+ if (children && children.length > truncate) children = `${truncator}(${element.children.length})`;
329
+ return `${head}${propertyContents}${headClose}${children}${tail}`;
330
+ }
331
+ var chaiInspect = typeof Symbol === "function" && typeof Symbol.for === "function" ? Symbol.for("chai/inspect") : "@@chai/inspect";
332
+ var nodeInspect = Symbol.for("nodejs.util.inspect.custom");
333
+ var constructorMap = /* @__PURE__ */ new WeakMap();
334
+ var stringTagMap = {};
335
+ var baseTypesMap = {
336
+ undefined: (value, options) => options.stylize("undefined", "undefined"),
337
+ null: (value, options) => options.stylize("null", "null"),
338
+ boolean: (value, options) => options.stylize(String(value), "boolean"),
339
+ Boolean: (value, options) => options.stylize(String(value), "boolean"),
340
+ number: inspectNumber,
341
+ Number: inspectNumber,
342
+ bigint: inspectBigInt,
343
+ BigInt: inspectBigInt,
344
+ string: inspectString,
345
+ String: inspectString,
346
+ function: inspectFunction,
347
+ Function: inspectFunction,
348
+ symbol: inspectSymbol,
349
+ Symbol: inspectSymbol,
350
+ Array: inspectArray,
351
+ Date: inspectDate,
352
+ Map: inspectMap,
353
+ Set: inspectSet,
354
+ RegExp: inspectRegExp,
355
+ Promise: getPromiseValue,
356
+ WeakSet: (value, options) => options.stylize("WeakSet{…}", "special"),
357
+ WeakMap: (value, options) => options.stylize("WeakMap{…}", "special"),
358
+ Arguments: inspectArguments,
359
+ Int8Array: inspectTypedArray,
360
+ Uint8Array: inspectTypedArray,
361
+ Uint8ClampedArray: inspectTypedArray,
362
+ Int16Array: inspectTypedArray,
363
+ Uint16Array: inspectTypedArray,
364
+ Int32Array: inspectTypedArray,
365
+ Uint32Array: inspectTypedArray,
366
+ Float32Array: inspectTypedArray,
367
+ Float64Array: inspectTypedArray,
368
+ Generator: () => "",
369
+ DataView: () => "",
370
+ ArrayBuffer: () => "",
371
+ Error: inspectObject,
372
+ HTMLCollection: inspectNodeCollection,
373
+ NodeList: inspectNodeCollection
374
+ };
375
+ var inspectCustom = (value, options, type, inspectFn) => {
376
+ if (chaiInspect in value && typeof value[chaiInspect] === "function") return value[chaiInspect](options);
377
+ if (nodeInspect in value && typeof value[nodeInspect] === "function") return value[nodeInspect](options.depth, options, inspectFn);
378
+ if ("inspect" in value && typeof value.inspect === "function") return value.inspect(options.depth, options);
379
+ if ("constructor" in value && constructorMap.has(value.constructor)) return constructorMap.get(value.constructor)(value, options);
380
+ if (stringTagMap[type]) return stringTagMap[type](value, options);
381
+ return "";
382
+ };
383
+ var toString = Object.prototype.toString;
384
+ function inspect$1(value, opts = {}) {
385
+ const options = normaliseOptions(opts, inspect$1);
386
+ const { customInspect } = options;
387
+ let type = value === null ? "null" : typeof value;
388
+ if (type === "object") type = toString.call(value).slice(8, -1);
389
+ if (type in baseTypesMap) return baseTypesMap[type](value, options);
390
+ if (customInspect && value) {
391
+ const output = inspectCustom(value, options, type, inspect$1);
392
+ if (output) {
393
+ if (typeof output === "string") return output;
394
+ return inspect$1(output, options);
395
+ }
396
+ }
397
+ const proto = value ? Object.getPrototypeOf(value) : false;
398
+ if (proto === Object.prototype || proto === null) return inspectObject$1(value, options);
399
+ if (value && typeof HTMLElement === "function" && value instanceof HTMLElement) return inspectHTML(value, options);
400
+ if ("constructor" in value) {
401
+ if (value.constructor !== Object) return inspectClass(value, options);
402
+ return inspectObject$1(value, options);
403
+ }
404
+ if (value === Object(value)) return inspectObject$1(value, options);
405
+ return options.stylize(String(value), type);
406
+ }
407
+ var { AsymmetricMatcher, DOMCollection, DOMElement, Immutable, ReactElement, ReactTestComponent } = plugins;
408
+ var PLUGINS = [
409
+ ReactTestComponent,
410
+ ReactElement,
411
+ DOMElement,
412
+ DOMCollection,
413
+ Immutable,
414
+ AsymmetricMatcher
415
+ ];
416
+ function stringify(object, maxDepth = 10, { maxLength, filterNode, ...options } = {}) {
417
+ const MAX_LENGTH = maxLength ?? 1e4;
418
+ let result;
419
+ const filterFn = typeof filterNode === "string" ? createNodeFilterFromSelector(filterNode) : filterNode;
420
+ const plugins = filterFn ? [
421
+ ReactTestComponent,
422
+ ReactElement,
423
+ createDOMElementFilter(filterFn),
424
+ DOMCollection,
425
+ Immutable,
426
+ AsymmetricMatcher
427
+ ] : PLUGINS;
428
+ try {
429
+ result = format$1(object, {
430
+ maxDepth,
431
+ escapeString: false,
432
+ plugins,
433
+ ...options
434
+ });
435
+ } catch {
436
+ result = format$1(object, {
437
+ callToJSON: false,
438
+ maxDepth,
439
+ escapeString: false,
440
+ plugins,
441
+ ...options
442
+ });
443
+ }
444
+ return result.length >= MAX_LENGTH && maxDepth > 1 ? stringify(object, Math.floor(Math.min(maxDepth, Number.MAX_SAFE_INTEGER) / 2), {
445
+ maxLength,
446
+ filterNode,
447
+ ...options
448
+ }) : result;
449
+ }
450
+ function createNodeFilterFromSelector(selector) {
451
+ const ELEMENT_NODE = 1;
452
+ const COMMENT_NODE = 8;
453
+ return (node) => {
454
+ if (node.nodeType === COMMENT_NODE) return false;
455
+ if (node.nodeType === ELEMENT_NODE && node.matches) try {
456
+ return !node.matches(selector);
457
+ } catch {
458
+ return true;
459
+ }
460
+ return true;
461
+ };
462
+ }
463
+ var formatRegExp = /%[sdjifoOc%]/g;
464
+ function baseFormat(args, options = {}) {
465
+ const formatArg = (item, inspecOptions) => {
466
+ if (options.prettifyObject) return stringify(item, void 0, {
467
+ printBasicPrototype: false,
468
+ escapeString: false
469
+ });
470
+ return inspect(item, inspecOptions);
471
+ };
472
+ if (typeof args[0] !== "string") {
473
+ const objects = [];
474
+ for (let i = 0; i < args.length; i++) objects.push(formatArg(args[i], {
475
+ depth: 0,
476
+ colors: false
477
+ }));
478
+ return objects.join(" ");
479
+ }
480
+ const len = args.length;
481
+ let i = 1;
482
+ const template = args[0];
483
+ let str = String(template).replace(formatRegExp, (x) => {
484
+ if (x === "%%") return "%";
485
+ if (i >= len) return x;
486
+ switch (x) {
487
+ case "%s": {
488
+ const value = args[i++];
489
+ if (typeof value === "bigint") return `${value.toString()}n`;
490
+ if (typeof value === "number" && value === 0 && 1 / value < 0) return "-0";
491
+ if (typeof value === "object" && value !== null) {
492
+ if (typeof value.toString === "function" && value.toString !== Object.prototype.toString) return value.toString();
493
+ return formatArg(value, {
494
+ depth: 0,
495
+ colors: false
496
+ });
497
+ }
498
+ return String(value);
499
+ }
500
+ case "%d": {
501
+ const value = args[i++];
502
+ if (typeof value === "bigint") return `${value.toString()}n`;
503
+ if (typeof value === "symbol") return "NaN";
504
+ return Number(value).toString();
505
+ }
506
+ case "%i": {
507
+ const value = args[i++];
508
+ if (typeof value === "bigint") return `${value.toString()}n`;
509
+ return Number.parseInt(String(value)).toString();
510
+ }
511
+ case "%f": return Number.parseFloat(String(args[i++])).toString();
512
+ case "%o": return formatArg(args[i++], {
513
+ showHidden: true,
514
+ showProxy: true
515
+ });
516
+ case "%O": return formatArg(args[i++]);
517
+ case "%c":
518
+ i++;
519
+ return "";
520
+ case "%j": try {
521
+ return JSON.stringify(args[i++]);
522
+ } catch (err) {
523
+ const m = err.message;
524
+ if (m.includes("circular structure") || m.includes("cyclic structures") || m.includes("cyclic object")) return "[Circular]";
525
+ throw err;
526
+ }
527
+ default: return x;
528
+ }
529
+ });
530
+ for (let x = args[i]; i < len; x = args[++i]) if (x === null || typeof x !== "object") str += ` ${typeof x === "symbol" ? x.toString() : x}`;
531
+ else str += ` ${formatArg(x)}`;
532
+ return str;
533
+ }
534
+ function format(...args) {
535
+ return baseFormat(args);
536
+ }
537
+ function inspect(obj, options = {}) {
538
+ if (options.truncate === 0) options.truncate = Number.POSITIVE_INFINITY;
539
+ return inspect$1(obj, options);
540
+ }
541
+ function objDisplay(obj, options = {}) {
542
+ if (typeof options.truncate === "undefined") options.truncate = 40;
543
+ const str = inspect(obj, options);
544
+ const type = Object.prototype.toString.call(obj);
545
+ if (options.truncate && str.length >= options.truncate) if (type === "[object Function]") {
546
+ const fn = obj;
547
+ return !fn.name ? "[Function]" : `[Function: ${fn.name}]`;
548
+ } else if (type === "[object Array]") return `[ Array(${obj.length}) ]`;
549
+ else if (type === "[object Object]") {
550
+ const keys = Object.keys(obj);
551
+ return `{ Object (${keys.length > 2 ? `${keys.splice(0, 2).join(", ")}, ...` : keys.join(", ")}) }`;
552
+ } else return str;
553
+ return str;
554
+ }
555
+ //#endregion
556
+ export { format, formatRegExp, objDisplay, stringify };
@@ -0,0 +1,27 @@
1
+ import { stringify } from "./display.js";
2
+ import { printDiffOrStringify } from "./diff.js";
3
+ import { serializeValue } from "./serialize.js";
4
+ //#region ../../node_modules/vitest/dist/@vitest/utils/error.js
5
+ function processError(_err, diffOptions, seen = /* @__PURE__ */ new WeakSet()) {
6
+ if (!_err || typeof _err !== "object") return { message: String(_err) };
7
+ const err = _err;
8
+ if (err.showDiff || err.showDiff === void 0 && err.expected !== void 0 && err.actual !== void 0) err.diff = printDiffOrStringify(err.actual, err.expected, {
9
+ ...diffOptions,
10
+ ...err.diffOptions
11
+ });
12
+ if ("expected" in err && typeof err.expected !== "string") err.expected = stringify(err.expected, 10);
13
+ if ("actual" in err && typeof err.actual !== "string") err.actual = stringify(err.actual, 10);
14
+ try {
15
+ if (!seen.has(err) && typeof err.cause === "object") {
16
+ seen.add(err);
17
+ err.cause = processError(err.cause, diffOptions, seen);
18
+ }
19
+ } catch {}
20
+ try {
21
+ return serializeValue(err);
22
+ } catch (e) {
23
+ return serializeValue(/* @__PURE__ */ new Error(`Failed to fully serialize error: ${e?.message}\nInner error message: ${err?.message}`));
24
+ }
25
+ }
26
+ //#endregion
27
+ export { processError };