@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.
- package/dist/_util/resolveMaybeRef.d.ts +2 -0
- package/dist/_util/resolveMaybeRef.js +7 -0
- package/dist/_util/types.js +0 -0
- package/dist/chat-providers/AbstractChatProvider.d.ts +2 -2
- package/dist/chat-providers/AbstractChatProvider.js +42 -0
- package/dist/chat-providers/DeepSeekChatProvider.d.ts +2 -2
- package/dist/chat-providers/DeepSeekChatProvider.js +59 -0
- package/dist/chat-providers/DefaultChatProvider.d.ts +2 -2
- package/dist/chat-providers/DefaultChatProvider.js +26 -0
- package/dist/chat-providers/OpenAIChatProvider.d.ts +2 -2
- package/dist/chat-providers/OpenAIChatProvider.js +49 -0
- package/dist/chat-providers/index.js +4 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +7 -3
- package/dist/node_modules/vitest/dist/@vitest/expect/index.js +1456 -0
- package/dist/node_modules/vitest/dist/@vitest/pretty-format/index.js +884 -0
- package/dist/node_modules/vitest/dist/@vitest/runner/chunk-artifact.js +1543 -0
- package/dist/node_modules/vitest/dist/@vitest/snapshot/index.js +660 -0
- package/dist/node_modules/vitest/dist/@vitest/spy/index.js +384 -0
- package/dist/node_modules/vitest/dist/@vitest/utils/chunk-pathe.M-eThtNZ.js +80 -0
- package/dist/node_modules/vitest/dist/@vitest/utils/diff.js +1304 -0
- package/dist/node_modules/vitest/dist/@vitest/utils/display.js +556 -0
- package/dist/node_modules/vitest/dist/@vitest/utils/error.js +27 -0
- package/dist/node_modules/vitest/dist/@vitest/utils/helpers.js +179 -0
- package/dist/node_modules/vitest/dist/@vitest/utils/offset.js +25 -0
- package/dist/node_modules/vitest/dist/@vitest/utils/serialize.js +75 -0
- package/dist/node_modules/vitest/dist/@vitest/utils/source-map.js +371 -0
- package/dist/node_modules/vitest/dist/@vitest/utils/timers.js +35 -0
- package/dist/node_modules/vitest/dist/chunks/_commonjsHelpers.D26ty3Ew.js +4 -0
- package/dist/node_modules/vitest/dist/chunks/rpc.MzXet3jl.js +50 -0
- package/dist/node_modules/vitest/dist/chunks/test.CBQUpOM3.js +2640 -0
- package/dist/node_modules/vitest/dist/chunks/utils.BX5Fg8C4.js +42 -0
- package/dist/node_modules/vitest/dist/vendor/chai.js +2872 -0
- package/dist/node_modules/vitest/dist/vendor/magic-string.js +1009 -0
- package/dist/node_modules/vitest/dist/vendor/tinyrainbow.js +84 -0
- package/dist/x-chat/__tests__/index.test.d.ts +1 -0
- package/dist/x-chat/__tests__/index.test.js +257 -0
- package/dist/x-chat/index.d.ts +14 -23
- package/dist/x-chat/index.js +83 -66
- package/dist/x-chat/store.d.ts +2 -0
- package/dist/{store-C1diHqNH.js → x-chat/store.js} +15 -9
- package/dist/x-conversations/__tests__/index.test.d.ts +1 -0
- package/dist/x-conversations/__tests__/index.test.js +36 -0
- package/dist/x-conversations/index.d.ts +4 -4
- package/dist/x-conversations/index.js +37 -1
- package/dist/{x-conversations-BrKWhj5r.js → x-conversations/store.js} +2 -31
- package/dist/x-request/__tests__/index.test.d.ts +1 -0
- package/dist/x-request/__tests__/index.test.js +90 -0
- package/dist/x-request/index.d.ts +36 -11
- package/dist/x-request/index.js +246 -1
- package/dist/x-request/x-fetch.js +18 -0
- package/package.json +1 -1
- package/dist/chat-providers-5x9Va7p5.js +0 -167
- package/dist/x-request-BSFGaKND.js +0 -234
|
@@ -0,0 +1,384 @@
|
|
|
1
|
+
//#region ../../node_modules/vitest/dist/@vitest/spy/index.js
|
|
2
|
+
function isMockFunction(fn) {
|
|
3
|
+
return typeof fn === "function" && "_isMockFunction" in fn && fn._isMockFunction === true;
|
|
4
|
+
}
|
|
5
|
+
var MOCK_RESTORE = /* @__PURE__ */ new Set();
|
|
6
|
+
var REGISTERED_MOCKS = /* @__PURE__ */ new Set();
|
|
7
|
+
var MOCK_CONFIGS = /* @__PURE__ */ new WeakMap();
|
|
8
|
+
function createMockInstance(options = {}) {
|
|
9
|
+
const { originalImplementation, restore, mockImplementation, resetToMockImplementation, resetToMockName } = options;
|
|
10
|
+
if (restore) MOCK_RESTORE.add(restore);
|
|
11
|
+
const config = getDefaultConfig(originalImplementation);
|
|
12
|
+
const state = getDefaultState();
|
|
13
|
+
const mock = createMock({
|
|
14
|
+
config,
|
|
15
|
+
state,
|
|
16
|
+
...options
|
|
17
|
+
});
|
|
18
|
+
const mockLength = (mockImplementation || originalImplementation)?.length ?? 0;
|
|
19
|
+
Object.defineProperty(mock, "length", {
|
|
20
|
+
writable: true,
|
|
21
|
+
enumerable: false,
|
|
22
|
+
value: mockLength,
|
|
23
|
+
configurable: true
|
|
24
|
+
});
|
|
25
|
+
if (resetToMockName) config.mockName = mock.name || "vi.fn()";
|
|
26
|
+
MOCK_CONFIGS.set(mock, config);
|
|
27
|
+
REGISTERED_MOCKS.add(mock);
|
|
28
|
+
mock._isMockFunction = true;
|
|
29
|
+
mock.getMockImplementation = () => {
|
|
30
|
+
return config.onceMockImplementations[0] || config.mockImplementation;
|
|
31
|
+
};
|
|
32
|
+
Object.defineProperty(mock, "mock", {
|
|
33
|
+
configurable: false,
|
|
34
|
+
enumerable: true,
|
|
35
|
+
writable: false,
|
|
36
|
+
value: state
|
|
37
|
+
});
|
|
38
|
+
mock.mockImplementation = function mockImplementation(implementation) {
|
|
39
|
+
config.mockImplementation = implementation;
|
|
40
|
+
return mock;
|
|
41
|
+
};
|
|
42
|
+
mock.mockImplementationOnce = function mockImplementationOnce(implementation) {
|
|
43
|
+
config.onceMockImplementations.push(implementation);
|
|
44
|
+
return mock;
|
|
45
|
+
};
|
|
46
|
+
mock.withImplementation = function withImplementation(implementation, callback) {
|
|
47
|
+
const previousImplementation = config.mockImplementation;
|
|
48
|
+
const previousOnceImplementations = config.onceMockImplementations;
|
|
49
|
+
const reset = () => {
|
|
50
|
+
config.mockImplementation = previousImplementation;
|
|
51
|
+
config.onceMockImplementations = previousOnceImplementations;
|
|
52
|
+
};
|
|
53
|
+
config.mockImplementation = implementation;
|
|
54
|
+
config.onceMockImplementations = [];
|
|
55
|
+
const returnValue = callback();
|
|
56
|
+
if (typeof returnValue === "object" && typeof returnValue?.then === "function") return returnValue.then(() => {
|
|
57
|
+
reset();
|
|
58
|
+
return mock;
|
|
59
|
+
});
|
|
60
|
+
else reset();
|
|
61
|
+
return mock;
|
|
62
|
+
};
|
|
63
|
+
mock.mockReturnThis = function mockReturnThis() {
|
|
64
|
+
return mock.mockImplementation(function() {
|
|
65
|
+
return this;
|
|
66
|
+
});
|
|
67
|
+
};
|
|
68
|
+
mock.mockReturnValue = function mockReturnValue(value) {
|
|
69
|
+
return mock.mockImplementation(function() {
|
|
70
|
+
if (new.target) throwConstructorError("mockReturnValue");
|
|
71
|
+
return value;
|
|
72
|
+
});
|
|
73
|
+
};
|
|
74
|
+
mock.mockReturnValueOnce = function mockReturnValueOnce(value) {
|
|
75
|
+
return mock.mockImplementationOnce(function() {
|
|
76
|
+
if (new.target) throwConstructorError("mockReturnValueOnce");
|
|
77
|
+
return value;
|
|
78
|
+
});
|
|
79
|
+
};
|
|
80
|
+
mock.mockThrow = function mockThrow(value) {
|
|
81
|
+
return mock.mockImplementation(function() {
|
|
82
|
+
throw value;
|
|
83
|
+
});
|
|
84
|
+
};
|
|
85
|
+
mock.mockThrowOnce = function mockThrowOnce(value) {
|
|
86
|
+
return mock.mockImplementationOnce(function() {
|
|
87
|
+
throw value;
|
|
88
|
+
});
|
|
89
|
+
};
|
|
90
|
+
mock.mockResolvedValue = function mockResolvedValue(value) {
|
|
91
|
+
return mock.mockImplementation(function() {
|
|
92
|
+
if (new.target) throwConstructorError("mockResolvedValue");
|
|
93
|
+
return Promise.resolve(value);
|
|
94
|
+
});
|
|
95
|
+
};
|
|
96
|
+
mock.mockResolvedValueOnce = function mockResolvedValueOnce(value) {
|
|
97
|
+
return mock.mockImplementationOnce(function() {
|
|
98
|
+
if (new.target) throwConstructorError("mockResolvedValueOnce");
|
|
99
|
+
return Promise.resolve(value);
|
|
100
|
+
});
|
|
101
|
+
};
|
|
102
|
+
mock.mockRejectedValue = function mockRejectedValue(value) {
|
|
103
|
+
return mock.mockImplementation(function() {
|
|
104
|
+
if (new.target) throwConstructorError("mockRejectedValue");
|
|
105
|
+
return Promise.reject(value);
|
|
106
|
+
});
|
|
107
|
+
};
|
|
108
|
+
mock.mockRejectedValueOnce = function mockRejectedValueOnce(value) {
|
|
109
|
+
return mock.mockImplementationOnce(function() {
|
|
110
|
+
if (new.target) throwConstructorError("mockRejectedValueOnce");
|
|
111
|
+
return Promise.reject(value);
|
|
112
|
+
});
|
|
113
|
+
};
|
|
114
|
+
mock.mockClear = function mockClear() {
|
|
115
|
+
state.calls = [];
|
|
116
|
+
state.contexts = [];
|
|
117
|
+
state.instances = [];
|
|
118
|
+
state.invocationCallOrder = [];
|
|
119
|
+
state.results = [];
|
|
120
|
+
state.settledResults = [];
|
|
121
|
+
return mock;
|
|
122
|
+
};
|
|
123
|
+
mock.mockReset = function mockReset() {
|
|
124
|
+
mock.mockClear();
|
|
125
|
+
config.mockImplementation = resetToMockImplementation ? mockImplementation : void 0;
|
|
126
|
+
config.mockName = resetToMockName ? mock.name || "vi.fn()" : "vi.fn()";
|
|
127
|
+
config.onceMockImplementations = [];
|
|
128
|
+
return mock;
|
|
129
|
+
};
|
|
130
|
+
mock.mockRestore = function mockRestore() {
|
|
131
|
+
mock.mockReset();
|
|
132
|
+
return restore?.();
|
|
133
|
+
};
|
|
134
|
+
mock.mockName = function mockName(name) {
|
|
135
|
+
if (typeof name === "string") config.mockName = name;
|
|
136
|
+
return mock;
|
|
137
|
+
};
|
|
138
|
+
mock.getMockName = function getMockName() {
|
|
139
|
+
return config.mockName || "vi.fn()";
|
|
140
|
+
};
|
|
141
|
+
if (Symbol.dispose) mock[Symbol.dispose] = () => mock.mockRestore();
|
|
142
|
+
if (mockImplementation) mock.mockImplementation(mockImplementation);
|
|
143
|
+
return mock;
|
|
144
|
+
}
|
|
145
|
+
function fn(originalImplementation) {
|
|
146
|
+
if (originalImplementation != null && isMockFunction(originalImplementation)) return originalImplementation;
|
|
147
|
+
return createMockInstance({
|
|
148
|
+
mockImplementation: originalImplementation,
|
|
149
|
+
resetToMockImplementation: true
|
|
150
|
+
});
|
|
151
|
+
}
|
|
152
|
+
function spyOn(object, key, accessor) {
|
|
153
|
+
assert(object != null, "The vi.spyOn() function could not find an object to spy upon. The first argument must be defined.");
|
|
154
|
+
assert(typeof object === "object" || typeof object === "function", "Vitest cannot spy on a primitive value.");
|
|
155
|
+
const [originalDescriptorObject, originalDescriptor] = getDescriptor(object, key) || [];
|
|
156
|
+
assert(originalDescriptor || key in object, `The property "${String(key)}" is not defined on the ${typeof object}.`);
|
|
157
|
+
let accessType = accessor || "value";
|
|
158
|
+
let ssr = false;
|
|
159
|
+
if (accessType === "value" && originalDescriptor && originalDescriptor.value == null && originalDescriptor.get) {
|
|
160
|
+
accessType = "get";
|
|
161
|
+
ssr = true;
|
|
162
|
+
}
|
|
163
|
+
let original;
|
|
164
|
+
if (originalDescriptor) {
|
|
165
|
+
original = originalDescriptor[accessType];
|
|
166
|
+
if (original == null && accessType === "value") original = object[key];
|
|
167
|
+
} else if (accessType !== "value") original = () => object[key];
|
|
168
|
+
else original = object[key];
|
|
169
|
+
const originalImplementation = ssr && original ? original() : original;
|
|
170
|
+
const originalType = typeof originalImplementation;
|
|
171
|
+
assert(originalType === "function" || accessType !== "value" && original == null, `vi.spyOn() can only spy on a function. Received ${originalType}.`);
|
|
172
|
+
if (isMockFunction(originalImplementation)) return originalImplementation;
|
|
173
|
+
const reassign = (cb) => {
|
|
174
|
+
const { value, ...desc } = originalDescriptor || {
|
|
175
|
+
configurable: true,
|
|
176
|
+
writable: true
|
|
177
|
+
};
|
|
178
|
+
if (accessType !== "value") delete desc.writable;
|
|
179
|
+
desc[accessType] = cb;
|
|
180
|
+
Object.defineProperty(object, key, desc);
|
|
181
|
+
};
|
|
182
|
+
const restore = () => {
|
|
183
|
+
if (originalDescriptorObject !== object) Reflect.deleteProperty(object, key);
|
|
184
|
+
else if (originalDescriptor && !original) Object.defineProperty(object, key, originalDescriptor);
|
|
185
|
+
else reassign(original);
|
|
186
|
+
};
|
|
187
|
+
const mock = createMockInstance({
|
|
188
|
+
restore,
|
|
189
|
+
originalImplementation,
|
|
190
|
+
resetToMockName: true
|
|
191
|
+
});
|
|
192
|
+
try {
|
|
193
|
+
reassign(ssr ? () => mock : mock);
|
|
194
|
+
} catch (error) {
|
|
195
|
+
if (error instanceof TypeError && Symbol.toStringTag && object[Symbol.toStringTag] === "Module" && (error.message.includes("Cannot redefine property") || error.message.includes("Cannot replace module namespace") || error.message.includes("can't redefine non-configurable property"))) throw new TypeError(`Cannot spy on export "${String(key)}". Module namespace is not configurable in ESM. See: https://vitest.dev/guide/browser/#limitations`, { cause: error });
|
|
196
|
+
throw error;
|
|
197
|
+
}
|
|
198
|
+
return mock;
|
|
199
|
+
}
|
|
200
|
+
function getDescriptor(obj, method) {
|
|
201
|
+
const objDescriptor = Object.getOwnPropertyDescriptor(obj, method);
|
|
202
|
+
if (objDescriptor) return [obj, objDescriptor];
|
|
203
|
+
let currentProto = Object.getPrototypeOf(obj);
|
|
204
|
+
while (currentProto !== null) {
|
|
205
|
+
const descriptor = Object.getOwnPropertyDescriptor(currentProto, method);
|
|
206
|
+
if (descriptor) return [currentProto, descriptor];
|
|
207
|
+
currentProto = Object.getPrototypeOf(currentProto);
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
function assert(condition, message) {
|
|
211
|
+
if (!condition) throw new Error(message);
|
|
212
|
+
}
|
|
213
|
+
var invocationCallCounter = 1;
|
|
214
|
+
function createMock({ state, config, name: mockName, prototypeState, prototypeConfig, keepMembersImplementation, mockImplementation, prototypeMembers = [] }) {
|
|
215
|
+
const original = config.mockOriginal;
|
|
216
|
+
const pseudoOriginal = mockImplementation;
|
|
217
|
+
const name = mockName || original?.name || "Mock";
|
|
218
|
+
const namedObject = { [name]: (function(...args) {
|
|
219
|
+
registerCalls(args, state, prototypeState);
|
|
220
|
+
registerInvocationOrder(invocationCallCounter++, state, prototypeState);
|
|
221
|
+
const result = {
|
|
222
|
+
type: "incomplete",
|
|
223
|
+
value: void 0
|
|
224
|
+
};
|
|
225
|
+
const settledResult = {
|
|
226
|
+
type: "incomplete",
|
|
227
|
+
value: void 0
|
|
228
|
+
};
|
|
229
|
+
registerResult(result, state, prototypeState);
|
|
230
|
+
registerSettledResult(settledResult, state, prototypeState);
|
|
231
|
+
const context = new.target ? void 0 : this;
|
|
232
|
+
const [instanceIndex, instancePrototypeIndex] = registerInstance(context, state, prototypeState);
|
|
233
|
+
const [contextIndex, contextPrototypeIndex] = registerContext(context, state, prototypeState);
|
|
234
|
+
const implementation = config.onceMockImplementations.shift() || config.mockImplementation || prototypeConfig?.onceMockImplementations.shift() || prototypeConfig?.mockImplementation || original || function() {};
|
|
235
|
+
let returnValue;
|
|
236
|
+
let thrownValue;
|
|
237
|
+
let didThrow = false;
|
|
238
|
+
try {
|
|
239
|
+
if (new.target) {
|
|
240
|
+
returnValue = Reflect.construct(implementation, args, new.target);
|
|
241
|
+
for (const prop of prototypeMembers) {
|
|
242
|
+
const prototypeMock = returnValue[prop];
|
|
243
|
+
if (prototypeMock !== mock.prototype[prop]) continue;
|
|
244
|
+
const isMock = isMockFunction(prototypeMock);
|
|
245
|
+
const prototypeState = isMock ? prototypeMock.mock : void 0;
|
|
246
|
+
const prototypeConfig = isMock ? MOCK_CONFIGS.get(prototypeMock) : void 0;
|
|
247
|
+
returnValue[prop] = createMockInstance({
|
|
248
|
+
originalImplementation: keepMembersImplementation ? prototypeConfig?.mockOriginal : void 0,
|
|
249
|
+
prototypeState,
|
|
250
|
+
prototypeConfig,
|
|
251
|
+
keepMembersImplementation
|
|
252
|
+
});
|
|
253
|
+
}
|
|
254
|
+
} else returnValue = implementation.apply(this, args);
|
|
255
|
+
} catch (error) {
|
|
256
|
+
thrownValue = error;
|
|
257
|
+
didThrow = true;
|
|
258
|
+
if (error instanceof TypeError && error.message.includes("is not a constructor")) console.warn(`[vitest] The ${namedObject[name].getMockName()} mock did not use 'function' or 'class' in its implementation, see https://vitest.dev/api/vi#vi-spyon for examples.`);
|
|
259
|
+
throw error;
|
|
260
|
+
} finally {
|
|
261
|
+
if (didThrow) {
|
|
262
|
+
result.type = "throw";
|
|
263
|
+
result.value = thrownValue;
|
|
264
|
+
settledResult.type = "rejected";
|
|
265
|
+
settledResult.value = thrownValue;
|
|
266
|
+
} else {
|
|
267
|
+
result.type = "return";
|
|
268
|
+
result.value = returnValue;
|
|
269
|
+
if (new.target) {
|
|
270
|
+
state.contexts[contextIndex - 1] = returnValue;
|
|
271
|
+
state.instances[instanceIndex - 1] = returnValue;
|
|
272
|
+
if (contextPrototypeIndex != null && prototypeState) prototypeState.contexts[contextPrototypeIndex - 1] = returnValue;
|
|
273
|
+
if (instancePrototypeIndex != null && prototypeState) prototypeState.instances[instancePrototypeIndex - 1] = returnValue;
|
|
274
|
+
}
|
|
275
|
+
if (returnValue instanceof Promise) returnValue.then((settledValue) => {
|
|
276
|
+
settledResult.type = "fulfilled";
|
|
277
|
+
settledResult.value = settledValue;
|
|
278
|
+
}, (rejectedValue) => {
|
|
279
|
+
settledResult.type = "rejected";
|
|
280
|
+
settledResult.value = rejectedValue;
|
|
281
|
+
});
|
|
282
|
+
else {
|
|
283
|
+
settledResult.type = "fulfilled";
|
|
284
|
+
settledResult.value = returnValue;
|
|
285
|
+
}
|
|
286
|
+
}
|
|
287
|
+
}
|
|
288
|
+
return returnValue;
|
|
289
|
+
}) };
|
|
290
|
+
const mock = namedObject[name];
|
|
291
|
+
const copyPropertiesFrom = original || pseudoOriginal;
|
|
292
|
+
if (copyPropertiesFrom) copyOriginalStaticProperties(mock, copyPropertiesFrom);
|
|
293
|
+
return mock;
|
|
294
|
+
}
|
|
295
|
+
function registerCalls(args, state, prototypeState) {
|
|
296
|
+
state.calls.push(args);
|
|
297
|
+
prototypeState?.calls.push(args);
|
|
298
|
+
}
|
|
299
|
+
function registerInvocationOrder(order, state, prototypeState) {
|
|
300
|
+
state.invocationCallOrder.push(order);
|
|
301
|
+
prototypeState?.invocationCallOrder.push(order);
|
|
302
|
+
}
|
|
303
|
+
function registerResult(result, state, prototypeState) {
|
|
304
|
+
state.results.push(result);
|
|
305
|
+
prototypeState?.results.push(result);
|
|
306
|
+
}
|
|
307
|
+
function registerSettledResult(result, state, prototypeState) {
|
|
308
|
+
state.settledResults.push(result);
|
|
309
|
+
prototypeState?.settledResults.push(result);
|
|
310
|
+
}
|
|
311
|
+
function registerInstance(instance, state, prototypeState) {
|
|
312
|
+
return [state.instances.push(instance), prototypeState?.instances.push(instance)];
|
|
313
|
+
}
|
|
314
|
+
function registerContext(context, state, prototypeState) {
|
|
315
|
+
return [state.contexts.push(context), prototypeState?.contexts.push(context)];
|
|
316
|
+
}
|
|
317
|
+
function copyOriginalStaticProperties(mock, original) {
|
|
318
|
+
const { properties, descriptors } = getAllProperties(original);
|
|
319
|
+
for (const key of properties) {
|
|
320
|
+
const descriptor = descriptors[key];
|
|
321
|
+
if (getDescriptor(mock, key)) continue;
|
|
322
|
+
Object.defineProperty(mock, key, descriptor);
|
|
323
|
+
}
|
|
324
|
+
}
|
|
325
|
+
var ignoreProperties = new Set([
|
|
326
|
+
"length",
|
|
327
|
+
"name",
|
|
328
|
+
"prototype",
|
|
329
|
+
Symbol.for("nodejs.util.promisify.custom")
|
|
330
|
+
]);
|
|
331
|
+
function getAllProperties(original) {
|
|
332
|
+
const properties = /* @__PURE__ */ new Set();
|
|
333
|
+
const descriptors = {};
|
|
334
|
+
while (original && original !== Object.prototype && original !== Function.prototype) {
|
|
335
|
+
const ownProperties = [...Object.getOwnPropertyNames(original), ...Object.getOwnPropertySymbols(original)];
|
|
336
|
+
for (const prop of ownProperties) {
|
|
337
|
+
if (descriptors[prop] || ignoreProperties.has(prop)) continue;
|
|
338
|
+
properties.add(prop);
|
|
339
|
+
descriptors[prop] = Object.getOwnPropertyDescriptor(original, prop);
|
|
340
|
+
}
|
|
341
|
+
original = Object.getPrototypeOf(original);
|
|
342
|
+
}
|
|
343
|
+
return {
|
|
344
|
+
properties,
|
|
345
|
+
descriptors
|
|
346
|
+
};
|
|
347
|
+
}
|
|
348
|
+
function getDefaultConfig(original) {
|
|
349
|
+
return {
|
|
350
|
+
mockImplementation: void 0,
|
|
351
|
+
mockOriginal: original,
|
|
352
|
+
mockName: "vi.fn()",
|
|
353
|
+
onceMockImplementations: []
|
|
354
|
+
};
|
|
355
|
+
}
|
|
356
|
+
function getDefaultState() {
|
|
357
|
+
const state = {
|
|
358
|
+
calls: [],
|
|
359
|
+
contexts: [],
|
|
360
|
+
instances: [],
|
|
361
|
+
invocationCallOrder: [],
|
|
362
|
+
settledResults: [],
|
|
363
|
+
results: [],
|
|
364
|
+
get lastCall() {
|
|
365
|
+
return state.calls.at(-1);
|
|
366
|
+
}
|
|
367
|
+
};
|
|
368
|
+
return state;
|
|
369
|
+
}
|
|
370
|
+
function restoreAllMocks() {
|
|
371
|
+
for (const restore of MOCK_RESTORE) restore();
|
|
372
|
+
MOCK_RESTORE.clear();
|
|
373
|
+
}
|
|
374
|
+
function clearAllMocks() {
|
|
375
|
+
REGISTERED_MOCKS.forEach((mock) => mock.mockClear());
|
|
376
|
+
}
|
|
377
|
+
function resetAllMocks() {
|
|
378
|
+
REGISTERED_MOCKS.forEach((mock) => mock.mockReset());
|
|
379
|
+
}
|
|
380
|
+
function throwConstructorError(shorthand) {
|
|
381
|
+
throw new TypeError(`Cannot use \`${shorthand}\` when called with \`new\`. Use \`mockImplementation\` with a \`class\` keyword instead. See https://vitest.dev/api/mock#class-support for more information.`);
|
|
382
|
+
}
|
|
383
|
+
//#endregion
|
|
384
|
+
export { clearAllMocks, fn, isMockFunction, resetAllMocks, restoreAllMocks, spyOn };
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
//#region ../../node_modules/vitest/dist/@vitest/utils/chunk-pathe.M-eThtNZ.js
|
|
2
|
+
var _DRIVE_LETTER_START_RE = /^[A-Za-z]:\//;
|
|
3
|
+
function normalizeWindowsPath(input = "") {
|
|
4
|
+
if (!input) return input;
|
|
5
|
+
return input.replace(/\\/g, "/").replace(_DRIVE_LETTER_START_RE, (r) => r.toUpperCase());
|
|
6
|
+
}
|
|
7
|
+
var _IS_ABSOLUTE_RE = /^[/\\](?![/\\])|^[/\\]{2}(?!\.)|^[A-Za-z]:[/\\]/;
|
|
8
|
+
function cwd() {
|
|
9
|
+
if (typeof process !== "undefined" && typeof process.cwd === "function") return process.cwd().replace(/\\/g, "/");
|
|
10
|
+
return "/";
|
|
11
|
+
}
|
|
12
|
+
var resolve = function(...arguments_) {
|
|
13
|
+
arguments_ = arguments_.map((argument) => normalizeWindowsPath(argument));
|
|
14
|
+
let resolvedPath = "";
|
|
15
|
+
let resolvedAbsolute = false;
|
|
16
|
+
for (let index = arguments_.length - 1; index >= -1 && !resolvedAbsolute; index--) {
|
|
17
|
+
const path = index >= 0 ? arguments_[index] : cwd();
|
|
18
|
+
if (!path || path.length === 0) continue;
|
|
19
|
+
resolvedPath = `${path}/${resolvedPath}`;
|
|
20
|
+
resolvedAbsolute = isAbsolute(path);
|
|
21
|
+
}
|
|
22
|
+
resolvedPath = normalizeString(resolvedPath, !resolvedAbsolute);
|
|
23
|
+
if (resolvedAbsolute && !isAbsolute(resolvedPath)) return `/${resolvedPath}`;
|
|
24
|
+
return resolvedPath.length > 0 ? resolvedPath : ".";
|
|
25
|
+
};
|
|
26
|
+
function normalizeString(path, allowAboveRoot) {
|
|
27
|
+
let res = "";
|
|
28
|
+
let lastSegmentLength = 0;
|
|
29
|
+
let lastSlash = -1;
|
|
30
|
+
let dots = 0;
|
|
31
|
+
let char = null;
|
|
32
|
+
for (let index = 0; index <= path.length; ++index) {
|
|
33
|
+
if (index < path.length) char = path[index];
|
|
34
|
+
else if (char === "/") break;
|
|
35
|
+
else char = "/";
|
|
36
|
+
if (char === "/") {
|
|
37
|
+
if (lastSlash === index - 1 || dots === 1);
|
|
38
|
+
else if (dots === 2) {
|
|
39
|
+
if (res.length < 2 || lastSegmentLength !== 2 || res[res.length - 1] !== "." || res[res.length - 2] !== ".") {
|
|
40
|
+
if (res.length > 2) {
|
|
41
|
+
const lastSlashIndex = res.lastIndexOf("/");
|
|
42
|
+
if (lastSlashIndex === -1) {
|
|
43
|
+
res = "";
|
|
44
|
+
lastSegmentLength = 0;
|
|
45
|
+
} else {
|
|
46
|
+
res = res.slice(0, lastSlashIndex);
|
|
47
|
+
lastSegmentLength = res.length - 1 - res.lastIndexOf("/");
|
|
48
|
+
}
|
|
49
|
+
lastSlash = index;
|
|
50
|
+
dots = 0;
|
|
51
|
+
continue;
|
|
52
|
+
} else if (res.length > 0) {
|
|
53
|
+
res = "";
|
|
54
|
+
lastSegmentLength = 0;
|
|
55
|
+
lastSlash = index;
|
|
56
|
+
dots = 0;
|
|
57
|
+
continue;
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
if (allowAboveRoot) {
|
|
61
|
+
res += res.length > 0 ? "/.." : "..";
|
|
62
|
+
lastSegmentLength = 2;
|
|
63
|
+
}
|
|
64
|
+
} else {
|
|
65
|
+
if (res.length > 0) res += `/${path.slice(lastSlash + 1, index)}`;
|
|
66
|
+
else res = path.slice(lastSlash + 1, index);
|
|
67
|
+
lastSegmentLength = index - lastSlash - 1;
|
|
68
|
+
}
|
|
69
|
+
lastSlash = index;
|
|
70
|
+
dots = 0;
|
|
71
|
+
} else if (char === "." && dots !== -1) ++dots;
|
|
72
|
+
else dots = -1;
|
|
73
|
+
}
|
|
74
|
+
return res;
|
|
75
|
+
}
|
|
76
|
+
var isAbsolute = function(p) {
|
|
77
|
+
return _IS_ABSOLUTE_RE.test(p);
|
|
78
|
+
};
|
|
79
|
+
//#endregion
|
|
80
|
+
export { resolve };
|