@antdv-next/x-sdk 0.0.2 → 0.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/dist/chat-providers/types/model.d.ts +1 -1
- package/dist/node_modules/.pnpm/@jridgewell_sourcemap-codec@1.5.5/node_modules/@jridgewell/sourcemap-codec/dist/sourcemap-codec.js +76 -0
- package/dist/node_modules/{vitest/dist/@vitest/expect → .pnpm/@vitest_expect@4.1.10/node_modules/@vitest/expect/dist}/index.js +76 -51
- package/dist/node_modules/{vitest/dist/@vitest/pretty-format → .pnpm/@vitest_pretty-format@4.1.10/node_modules/@vitest/pretty-format/dist}/index.js +11 -10
- package/dist/node_modules/{vitest/dist/@vitest/runner → .pnpm/@vitest_runner@4.1.10/node_modules/@vitest/runner/dist}/chunk-artifact.js +18 -41
- package/dist/node_modules/.pnpm/@vitest_runner@4.1.10/node_modules/@vitest/runner/dist/index.js +2 -0
- package/dist/node_modules/.pnpm/@vitest_runner@4.1.10/node_modules/@vitest/runner/dist/utils.js +2 -0
- package/dist/node_modules/{vitest/dist/@vitest/snapshot → .pnpm/@vitest_snapshot@4.1.10/node_modules/@vitest/snapshot/dist}/index.js +455 -195
- package/dist/node_modules/{vitest/dist/@vitest/spy → .pnpm/@vitest_spy@4.1.10/node_modules/@vitest/spy/dist}/index.js +3 -3
- package/dist/node_modules/{vitest/dist/@vitest/utils → .pnpm/@vitest_utils@4.1.10/node_modules/@vitest/utils/dist}/chunk-pathe.M-eThtNZ.js +2 -2
- package/dist/node_modules/{vitest/dist/@vitest/utils → .pnpm/@vitest_utils@4.1.10/node_modules/@vitest/utils/dist}/diff.js +40 -30
- package/dist/node_modules/{vitest/dist/@vitest/utils → .pnpm/@vitest_utils@4.1.10/node_modules/@vitest/utils/dist}/display.js +3 -3
- package/dist/node_modules/.pnpm/@vitest_utils@4.1.10/node_modules/@vitest/utils/dist/error.js +34 -0
- package/dist/node_modules/{vitest/dist/@vitest/utils → .pnpm/@vitest_utils@4.1.10/node_modules/@vitest/utils/dist}/helpers.js +3 -3
- package/dist/node_modules/{vitest/dist/@vitest/utils → .pnpm/@vitest_utils@4.1.10/node_modules/@vitest/utils/dist}/offset.js +1 -1
- package/dist/node_modules/{vitest/dist/@vitest/utils → .pnpm/@vitest_utils@4.1.10/node_modules/@vitest/utils/dist}/serialize.js +1 -1
- package/dist/node_modules/{vitest/dist/@vitest/utils → .pnpm/@vitest_utils@4.1.10/node_modules/@vitest/utils/dist}/source-map.js +6 -6
- package/dist/node_modules/{vitest/dist/@vitest/utils → .pnpm/@vitest_utils@4.1.10/node_modules/@vitest/utils/dist}/timers.js +1 -1
- package/dist/node_modules/{vitest/dist/vendor/chai.js → .pnpm/chai@6.2.2/node_modules/chai/index.js} +103 -3
- package/dist/node_modules/{vitest/dist/vendor/magic-string.js → .pnpm/magic-string@0.30.21/node_modules/magic-string/dist/magic-string.es.js} +4 -76
- package/dist/node_modules/.pnpm/tinyrainbow@3.1.1/node_modules/tinyrainbow/dist/index.js +84 -0
- package/dist/node_modules/.pnpm/vitest@4.1.10_@types_node@24.12.0_@vitest_browser-preview@4.1.10_@vitest_coverage-v8@4._55bf307888d746e7433721e12ae091d9/node_modules/vitest/dist/chunks/_commonjsHelpers.D26ty3Ew.js +4 -0
- package/dist/node_modules/{vitest → .pnpm/vitest@4.1.10_@types_node@24.12.0_@vitest_browser-preview@4.1.10_@vitest_coverage-v8@4._55bf307888d746e7433721e12ae091d9/node_modules/vitest}/dist/chunks/rpc.MzXet3jl.js +2 -2
- package/dist/node_modules/{vitest/dist/chunks/test.CBQUpOM3.js → .pnpm/vitest@4.1.10_@types_node@24.12.0_@vitest_browser-preview@4.1.10_@vitest_coverage-v8@4._55bf307888d746e7433721e12ae091d9/node_modules/vitest/dist/chunks/test.DNmyFkvJ.js} +383 -327
- package/dist/node_modules/{vitest → .pnpm/vitest@4.1.10_@types_node@24.12.0_@vitest_browser-preview@4.1.10_@vitest_coverage-v8@4._55bf307888d746e7433721e12ae091d9/node_modules/vitest}/dist/chunks/utils.BX5Fg8C4.js +3 -3
- package/dist/x-chat/__tests__/index.test.js +3 -2
- package/dist/x-chat/index.js +3 -2
- package/dist/x-conversations/__tests__/index.test.js +2 -2
- package/dist/x-request/__tests__/index.test.js +2 -2
- package/dist/x-stream/__tests__/index.test.d.ts +1 -0
- package/dist/x-stream/__tests__/index.test.js +62 -0
- package/dist/x-stream/index.js +16 -5
- package/package.json +2 -1
- package/dist/node_modules/vitest/dist/@vitest/utils/error.js +0 -27
- package/dist/node_modules/vitest/dist/chunks/_commonjsHelpers.D26ty3Ew.js +0 -4
- package/dist/node_modules/vitest/dist/vendor/tinyrainbow.js +0 -84
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { getSafeTimers } from "
|
|
2
|
-
//#region ../../node_modules/vitest/dist/chunks/utils.BX5Fg8C4.js
|
|
1
|
+
import { getSafeTimers } from "../../../../../@vitest_utils@4.1.10/node_modules/@vitest/utils/dist/timers.js";
|
|
2
|
+
//#region ../../node_modules/.pnpm/vitest@4.1.10_@types+node@24.12.0_@vitest+browser-preview@4.1.10_@vitest+coverage-v8@4._55bf307888d746e7433721e12ae091d9/node_modules/vitest/dist/chunks/utils.BX5Fg8C4.js
|
|
3
3
|
var NAME_WORKER_STATE = "__vitest_worker__";
|
|
4
4
|
function getWorkerState() {
|
|
5
5
|
const workerState = globalThis[NAME_WORKER_STATE];
|
|
@@ -39,4 +39,4 @@ async function waitForImportsToResolve() {
|
|
|
39
39
|
await waitForImportsToResolve();
|
|
40
40
|
}
|
|
41
41
|
//#endregion
|
|
42
|
-
export { getWorkerState, isChildProcess, resetModules, waitForImportsToResolve };
|
|
42
|
+
export { getWorkerState as g, isChildProcess as i, resetModules as r, waitForImportsToResolve as w };
|
|
@@ -2,11 +2,12 @@ import AbstractChatProvider from "../../chat-providers/AbstractChatProvider.js";
|
|
|
2
2
|
import { AbstractXRequestClass } from "../../x-request/index.js";
|
|
3
3
|
import { chatMessagesStoreHelper } from "../store.js";
|
|
4
4
|
import useXChat from "../index.js";
|
|
5
|
-
import { describe, it } from "../../node_modules/
|
|
6
|
-
import { globalExpect, vi } from "../../node_modules/vitest/dist/chunks/test.
|
|
5
|
+
import { h as describe, m as it } from "../../node_modules/.pnpm/@vitest_runner@4.1.10/node_modules/@vitest/runner/dist/chunk-artifact.js";
|
|
6
|
+
import { g as globalExpect, v as vi } from "../../node_modules/.pnpm/vitest@4.1.10_@types_node@24.12.0_@vitest_browser-preview@4.1.10_@vitest_coverage-v8@4._55bf307888d746e7433721e12ae091d9/node_modules/vitest/dist/chunks/test.DNmyFkvJ.js";
|
|
7
7
|
import { computed, effectScope, nextTick, reactive, readonly, ref } from "vue";
|
|
8
8
|
//#region src/x-chat/__tests__/index.test.ts
|
|
9
9
|
var MockManualRequest = class extends AbstractXRequestClass {
|
|
10
|
+
shouldFail;
|
|
10
11
|
_asyncHandler = Promise.resolve();
|
|
11
12
|
_state = reactive({
|
|
12
13
|
isTimeout: false,
|
package/dist/x-chat/index.js
CHANGED
|
@@ -178,12 +178,13 @@ function useXChat(config) {
|
|
|
178
178
|
updatingMsgId = msg.id;
|
|
179
179
|
}
|
|
180
180
|
} else {
|
|
181
|
-
|
|
181
|
+
const transformData = activeProvider.transformMessage({
|
|
182
182
|
chunk,
|
|
183
183
|
status,
|
|
184
184
|
chunks,
|
|
185
185
|
responseHeaders
|
|
186
|
-
})
|
|
186
|
+
});
|
|
187
|
+
msg = createMessage(transformData, status);
|
|
187
188
|
requestStore.setMessages((ori) => {
|
|
188
189
|
return [...ori.filter((info) => info.id !== loadingMsgId), msg];
|
|
189
190
|
});
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import useXConversations from "../index.js";
|
|
2
|
-
import { describe, it } from "../../node_modules/
|
|
3
|
-
import { globalExpect } from "../../node_modules/vitest/dist/chunks/test.
|
|
2
|
+
import { h as describe, m as it } from "../../node_modules/.pnpm/@vitest_runner@4.1.10/node_modules/@vitest/runner/dist/chunk-artifact.js";
|
|
3
|
+
import { g as globalExpect } from "../../node_modules/.pnpm/vitest@4.1.10_@types_node@24.12.0_@vitest_browser-preview@4.1.10_@vitest_coverage-v8@4._55bf307888d746e7433721e12ae091d9/node_modules/vitest/dist/chunks/test.DNmyFkvJ.js";
|
|
4
4
|
import { effectScope, nextTick, ref } from "vue";
|
|
5
5
|
//#region src/x-conversations/__tests__/index.test.ts
|
|
6
6
|
describe("useXConversations", () => {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import XRequest from "../index.js";
|
|
2
|
-
import { describe, it } from "../../node_modules/
|
|
3
|
-
import { globalExpect, vi } from "../../node_modules/vitest/dist/chunks/test.
|
|
2
|
+
import { h as describe, m as it } from "../../node_modules/.pnpm/@vitest_runner@4.1.10/node_modules/@vitest/runner/dist/chunk-artifact.js";
|
|
3
|
+
import { g as globalExpect, v as vi } from "../../node_modules/.pnpm/vitest@4.1.10_@types_node@24.12.0_@vitest_browser-preview@4.1.10_@vitest_coverage-v8@4._55bf307888d746e7433721e12ae091d9/node_modules/vitest/dist/chunks/test.DNmyFkvJ.js";
|
|
4
4
|
import { ref } from "vue";
|
|
5
5
|
//#region src/x-request/__tests__/index.test.ts
|
|
6
6
|
describe("XRequest", () => {
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import XStream from "../index.js";
|
|
2
|
+
import { h as describe, m as it } from "../../node_modules/.pnpm/@vitest_runner@4.1.10/node_modules/@vitest/runner/dist/chunk-artifact.js";
|
|
3
|
+
import { g as globalExpect, v as vi } from "../../node_modules/.pnpm/vitest@4.1.10_@types_node@24.12.0_@vitest_browser-preview@4.1.10_@vitest_coverage-v8@4._55bf307888d746e7433721e12ae091d9/node_modules/vitest/dist/chunks/test.DNmyFkvJ.js";
|
|
4
|
+
//#region src/x-stream/__tests__/index.test.ts
|
|
5
|
+
var encoder = new TextEncoder();
|
|
6
|
+
describe("XStream", () => {
|
|
7
|
+
it("cancels the source and releases the reader lock on early exit", async () => {
|
|
8
|
+
const cancel = vi.fn();
|
|
9
|
+
const stream = XStream({ readableStream: new ReadableStream({
|
|
10
|
+
start(controller) {
|
|
11
|
+
controller.enqueue(encoder.encode("data: first\n\n"));
|
|
12
|
+
},
|
|
13
|
+
cancel
|
|
14
|
+
}) });
|
|
15
|
+
for await (const value of stream) {
|
|
16
|
+
globalExpect(value).toEqual({ data: "first" });
|
|
17
|
+
break;
|
|
18
|
+
}
|
|
19
|
+
globalExpect(stream.locked).toBe(false);
|
|
20
|
+
await vi.waitFor(() => globalExpect(cancel).toHaveBeenCalledOnce());
|
|
21
|
+
const reader = stream.getReader();
|
|
22
|
+
await globalExpect(reader.read()).resolves.toEqual({
|
|
23
|
+
done: true,
|
|
24
|
+
value: void 0
|
|
25
|
+
});
|
|
26
|
+
reader.releaseLock();
|
|
27
|
+
});
|
|
28
|
+
it("preserves the consumer error when cancellation fails", async () => {
|
|
29
|
+
const consumerError = /* @__PURE__ */ new Error("consumer failed");
|
|
30
|
+
const cancelError = /* @__PURE__ */ new Error("cancel failed");
|
|
31
|
+
const cancel = vi.fn(() => Promise.reject(cancelError));
|
|
32
|
+
const stream = XStream({ readableStream: new ReadableStream({
|
|
33
|
+
start(controller) {
|
|
34
|
+
controller.enqueue(encoder.encode("data: first\n\n"));
|
|
35
|
+
},
|
|
36
|
+
cancel
|
|
37
|
+
}) });
|
|
38
|
+
const consume = async () => {
|
|
39
|
+
for await (const _value of stream) throw consumerError;
|
|
40
|
+
};
|
|
41
|
+
await globalExpect(consume()).rejects.toBe(consumerError);
|
|
42
|
+
globalExpect(cancel).toHaveBeenCalledOnce();
|
|
43
|
+
globalExpect(stream.locked).toBe(false);
|
|
44
|
+
});
|
|
45
|
+
it("releases the reader lock without cancellation after normal completion", async () => {
|
|
46
|
+
const cancel = vi.fn();
|
|
47
|
+
const stream = XStream({ readableStream: new ReadableStream({
|
|
48
|
+
start(controller) {
|
|
49
|
+
controller.enqueue(encoder.encode("data: first\n\n"));
|
|
50
|
+
controller.enqueue(encoder.encode("data: second\n\n"));
|
|
51
|
+
controller.close();
|
|
52
|
+
},
|
|
53
|
+
cancel
|
|
54
|
+
}) });
|
|
55
|
+
const values = [];
|
|
56
|
+
for await (const value of stream) values.push(value);
|
|
57
|
+
globalExpect(values).toEqual([{ data: "first" }, { data: "second" }]);
|
|
58
|
+
globalExpect(cancel).not.toHaveBeenCalled();
|
|
59
|
+
globalExpect(stream.locked).toBe(false);
|
|
60
|
+
});
|
|
61
|
+
});
|
|
62
|
+
//#endregion
|
package/dist/x-stream/index.js
CHANGED
|
@@ -101,11 +101,22 @@ function XStream(options) {
|
|
|
101
101
|
/** support async iterator */
|
|
102
102
|
stream[Symbol.asyncIterator] = async function* () {
|
|
103
103
|
const reader = this.getReader();
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
104
|
+
let completed = false;
|
|
105
|
+
try {
|
|
106
|
+
while (true) {
|
|
107
|
+
const { done, value } = await reader.read();
|
|
108
|
+
if (done) {
|
|
109
|
+
completed = true;
|
|
110
|
+
break;
|
|
111
|
+
}
|
|
112
|
+
if (!value) continue;
|
|
113
|
+
yield value;
|
|
114
|
+
}
|
|
115
|
+
} finally {
|
|
116
|
+
if (!completed) try {
|
|
117
|
+
await reader.cancel();
|
|
118
|
+
} catch {}
|
|
119
|
+
reader.releaseLock();
|
|
109
120
|
}
|
|
110
121
|
};
|
|
111
122
|
return stream;
|
package/package.json
CHANGED
|
@@ -1,27 +0,0 @@
|
|
|
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 };
|
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
//#region ../../node_modules/vitest/dist/chunks/_commonjsHelpers.D26ty3Ew.js
|
|
2
|
-
var commonjsGlobal = typeof globalThis !== "undefined" ? globalThis : typeof window !== "undefined" ? window : typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : {};
|
|
3
|
-
//#endregion
|
|
4
|
-
export { commonjsGlobal };
|
|
@@ -1,84 +0,0 @@
|
|
|
1
|
-
//#region ../../node_modules/vitest/dist/vendor/tinyrainbow.mjs
|
|
2
|
-
var d = {
|
|
3
|
-
reset: [0, 0],
|
|
4
|
-
bold: [
|
|
5
|
-
1,
|
|
6
|
-
22,
|
|
7
|
-
"\x1B[22m\x1B[1m"
|
|
8
|
-
],
|
|
9
|
-
dim: [
|
|
10
|
-
2,
|
|
11
|
-
22,
|
|
12
|
-
"\x1B[22m\x1B[2m"
|
|
13
|
-
],
|
|
14
|
-
italic: [3, 23],
|
|
15
|
-
underline: [4, 24],
|
|
16
|
-
inverse: [7, 27],
|
|
17
|
-
hidden: [8, 28],
|
|
18
|
-
strikethrough: [9, 29],
|
|
19
|
-
black: [30, 39],
|
|
20
|
-
red: [31, 39],
|
|
21
|
-
green: [32, 39],
|
|
22
|
-
yellow: [33, 39],
|
|
23
|
-
blue: [34, 39],
|
|
24
|
-
magenta: [35, 39],
|
|
25
|
-
cyan: [36, 39],
|
|
26
|
-
white: [37, 39],
|
|
27
|
-
gray: [90, 39],
|
|
28
|
-
bgBlack: [40, 49],
|
|
29
|
-
bgRed: [41, 49],
|
|
30
|
-
bgGreen: [42, 49],
|
|
31
|
-
bgYellow: [43, 49],
|
|
32
|
-
bgBlue: [44, 49],
|
|
33
|
-
bgMagenta: [45, 49],
|
|
34
|
-
bgCyan: [46, 49],
|
|
35
|
-
bgWhite: [47, 49],
|
|
36
|
-
blackBright: [90, 39],
|
|
37
|
-
redBright: [91, 39],
|
|
38
|
-
greenBright: [92, 39],
|
|
39
|
-
yellowBright: [93, 39],
|
|
40
|
-
blueBright: [94, 39],
|
|
41
|
-
magentaBright: [95, 39],
|
|
42
|
-
cyanBright: [96, 39],
|
|
43
|
-
whiteBright: [97, 39],
|
|
44
|
-
bgBlackBright: [100, 49],
|
|
45
|
-
bgRedBright: [101, 49],
|
|
46
|
-
bgGreenBright: [102, 49],
|
|
47
|
-
bgYellowBright: [103, 49],
|
|
48
|
-
bgBlueBright: [104, 49],
|
|
49
|
-
bgMagentaBright: [105, 49],
|
|
50
|
-
bgCyanBright: [106, 49],
|
|
51
|
-
bgWhiteBright: [107, 49]
|
|
52
|
-
};
|
|
53
|
-
function g(e) {
|
|
54
|
-
return String(e);
|
|
55
|
-
}
|
|
56
|
-
g.open = "";
|
|
57
|
-
g.close = "";
|
|
58
|
-
function h() {
|
|
59
|
-
let e = typeof process != "undefined" ? process : void 0, n = (e == null ? void 0 : e.env) || {}, a = n.FORCE_TTY !== "false", i = (e == null ? void 0 : e.argv) || [];
|
|
60
|
-
return !("NO_COLOR" in n || i.includes("--no-color")) && ("FORCE_COLOR" in n || i.includes("--color") || (e == null ? void 0 : e.platform) === "win32" || a && n.TERM !== "dumb" || "CI" in n) || typeof window != "undefined" && !!window.chrome;
|
|
61
|
-
}
|
|
62
|
-
function f() {
|
|
63
|
-
let e = h(), n = (r, t, u, o) => {
|
|
64
|
-
let l = "", s = 0;
|
|
65
|
-
do
|
|
66
|
-
l += r.substring(s, o) + u, s = o + t.length, o = r.indexOf(t, s);
|
|
67
|
-
while (~o);
|
|
68
|
-
return l + r.substring(s);
|
|
69
|
-
}, a = (r, t, u = r) => {
|
|
70
|
-
let o = (l) => {
|
|
71
|
-
let s = String(l), b = s.indexOf(t, r.length);
|
|
72
|
-
return ~b ? r + n(s, t, u, b) + t : r + s + t;
|
|
73
|
-
};
|
|
74
|
-
return o.open = r, o.close = t, o;
|
|
75
|
-
}, i = { isColorSupported: e }, c = (r) => `\x1B[${r}m`;
|
|
76
|
-
for (let r in d) {
|
|
77
|
-
let t = d[r];
|
|
78
|
-
i[r] = e ? a(c(t[0]), c(t[1]), t[2]) : g;
|
|
79
|
-
}
|
|
80
|
-
return i;
|
|
81
|
-
}
|
|
82
|
-
var C = f();
|
|
83
|
-
//#endregion
|
|
84
|
-
export { C };
|