@copilotkit/vue 1.83.0 → 2.0.0-rc.1
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/AGENTS.md +1 -1
- package/dist/index.cjs +76 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.mjs +14290 -287
- package/dist/index.mjs.map +1 -1
- package/dist/styles.css +1 -1
- package/dist/v2/components/A2UIMessageRenderer.d.ts.map +1 -1
- package/dist/v2/components/a2ui/catalog.d.ts +1 -1
- package/dist/v2/components/a2ui/catalog.d.ts.map +1 -1
- package/dist/v2/components/chat/BasicMarkdown.vue.d.ts +9 -0
- package/dist/v2/components/chat/BasicMarkdown.vue.d.ts.map +1 -0
- package/dist/v2/components/chat/CopilotChatAssistantMessage.vue.d.ts.map +1 -1
- package/dist/v2/components/chat/CopilotChatReasoningMessage.vue.d.ts.map +1 -1
- package/dist/v2/components/chat/StreamingMarkdownDefault.vue.d.ts +10 -0
- package/dist/v2/components/chat/StreamingMarkdownDefault.vue.d.ts.map +1 -0
- package/dist/v2/components/chat/index.d.ts +2 -0
- package/dist/v2/components/chat/index.d.ts.map +1 -1
- package/dist/v2/hooks/index.d.ts +0 -1
- package/dist/v2/hooks/index.d.ts.map +1 -1
- package/dist/v2/hooks/use-pin-to-send.d.ts +1 -1
- package/dist/v2/index.cjs +1 -1
- package/dist/v2/index.mjs +195 -188
- package/dist/v2/providers/CopilotKitProvider.types.d.ts +10 -0
- package/dist/v2/providers/CopilotKitProvider.types.d.ts.map +1 -1
- package/dist/v2/providers/CopilotKitProvider.vue.d.ts.map +1 -1
- package/dist/v2/providers/index.d.ts +1 -0
- package/dist/v2/providers/index.d.ts.map +1 -1
- package/dist/v2/providers/markdown-renderer.d.ts +23 -0
- package/dist/v2/providers/markdown-renderer.d.ts.map +1 -0
- package/package.json +8 -9
- package/src/styles/globals.css +0 -97
- package/src/v2/components/A2UIMessageRenderer.ts +3 -2
- package/src/v2/components/a2ui/catalog.ts +4 -2
- package/src/v2/components/chat/BasicMarkdown.vue +158 -0
- package/src/v2/components/chat/CopilotChatAssistantMessage.vue +27 -536
- package/src/v2/components/chat/CopilotChatReasoningMessage.vue +7 -2
- package/src/v2/components/chat/StreamingMarkdownDefault.vue +57 -0
- package/src/v2/components/chat/__tests__/BasicMarkdown.test.ts +69 -0
- package/src/v2/components/chat/__tests__/CopilotChat.e2e.test.ts +53 -16
- package/src/v2/components/chat/__tests__/CopilotChat.licenseWarning.test.ts +5 -7
- package/src/v2/components/chat/__tests__/CopilotChatAssistantMessage.markdown.test.ts +54 -0
- package/src/v2/components/chat/__tests__/CopilotChatAssistantMessage.test.ts +0 -41
- package/src/v2/components/chat/__tests__/CopilotChatToolRerenders.e2e.test.ts +18 -4
- package/src/v2/components/chat/__tests__/markdown-renderer-config.e2e.test.ts +59 -0
- package/src/v2/components/chat/index.ts +2 -0
- package/src/v2/hooks/__tests__/use-agent.e2e.test.ts +7 -3
- package/src/v2/hooks/__tests__/use-frontend-tool.e2e.test.ts +7 -3
- package/src/v2/hooks/index.ts +0 -1
- package/src/v2/hooks/use-pin-to-send.ts +1 -1
- package/src/v2/providers/CopilotKitProvider.types.ts +10 -0
- package/src/v2/providers/CopilotKitProvider.vue +2 -0
- package/src/v2/providers/__tests__/CopilotKitProvider.headersAtSendTime.test.ts +1 -1
- package/src/v2/providers/__tests__/markdown-renderer.test.ts +40 -0
- package/src/v2/providers/index.ts +1 -0
- package/src/v2/providers/markdown-renderer.ts +39 -0
- package/vite.config.ts +1 -3
- package/dist/use-render-activity-message-B7sDGUl4.cjs +0 -70
- package/dist/use-render-activity-message-B7sDGUl4.cjs.map +0 -1
- package/dist/use-render-activity-message-mQvByEYF.js +0 -12544
- package/dist/use-render-activity-message-mQvByEYF.js.map +0 -1
- package/dist/v2/hooks/use-katex-styles.d.ts +0 -22
- package/dist/v2/hooks/use-katex-styles.d.ts.map +0 -1
- package/src/v2/hooks/__tests__/use-katex-styles.test.ts +0 -69
- package/src/v2/hooks/use-katex-styles.ts +0 -44
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Dynamically loads KaTeX CSS at runtime to avoid Next.js-style
|
|
3
|
-
* "Global CSS cannot be imported from within node_modules" build errors and
|
|
4
|
-
* to keep the CSS out of the static import graph.
|
|
5
|
-
*
|
|
6
|
-
* Uses a module-level singleton flag so the stylesheet is only loaded once,
|
|
7
|
-
* regardless of how many components call this composable.
|
|
8
|
-
*
|
|
9
|
-
* Mirrors the React `useKatexStyles` hook: returns `void`, never throws, and
|
|
10
|
-
* logs a warning with equivalent intent if the dynamic import fails.
|
|
11
|
-
*
|
|
12
|
-
* @example
|
|
13
|
-
* ```vue
|
|
14
|
-
* <script setup lang="ts">
|
|
15
|
-
* import { useKatexStyles } from "@copilotkit/vue";
|
|
16
|
-
*
|
|
17
|
-
* useKatexStyles();
|
|
18
|
-
* </script>
|
|
19
|
-
* ```
|
|
20
|
-
*/
|
|
21
|
-
export declare function useKatexStyles(): void;
|
|
22
|
-
//# sourceMappingURL=use-katex-styles.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"use-katex-styles.d.ts","sourceRoot":"","sources":["../../../src/v2/hooks/use-katex-styles.ts"],"names":[],"mappings":"AAMA;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAgB,cAAc,IAAI,IAAI,CAiBrC"}
|
|
@@ -1,69 +0,0 @@
|
|
|
1
|
-
import { beforeEach, describe, expect, it, vi } from "vitest";
|
|
2
|
-
import { defineComponent, h, nextTick } from "vue";
|
|
3
|
-
import { render } from "@testing-library/vue";
|
|
4
|
-
|
|
5
|
-
// Mock the katex CSS import globally so the dynamic import resolves cleanly
|
|
6
|
-
// in the test environment.
|
|
7
|
-
vi.mock("katex/dist/katex.min.css", () => ({}));
|
|
8
|
-
|
|
9
|
-
describe("useKatexStyles", () => {
|
|
10
|
-
beforeEach(() => {
|
|
11
|
-
// Reset module state (the singleton `injected` flag) between tests so
|
|
12
|
-
// each case can exercise the dynamic-import branch.
|
|
13
|
-
vi.resetModules();
|
|
14
|
-
});
|
|
15
|
-
|
|
16
|
-
async function loadHook() {
|
|
17
|
-
const mod = await import("../use-katex-styles");
|
|
18
|
-
return mod.useKatexStyles;
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
function mountWith(hook: () => void) {
|
|
22
|
-
return render(
|
|
23
|
-
defineComponent({
|
|
24
|
-
setup() {
|
|
25
|
-
hook();
|
|
26
|
-
return () => h("div");
|
|
27
|
-
},
|
|
28
|
-
}),
|
|
29
|
-
);
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
it("renders without error (dynamic import succeeds)", async () => {
|
|
33
|
-
const useKatexStyles = await loadHook();
|
|
34
|
-
|
|
35
|
-
expect(() => {
|
|
36
|
-
mountWith(useKatexStyles);
|
|
37
|
-
}).not.toThrow();
|
|
38
|
-
await nextTick();
|
|
39
|
-
});
|
|
40
|
-
|
|
41
|
-
it("does not throw when katex CSS import fails", async () => {
|
|
42
|
-
vi.doMock("katex/dist/katex.min.css", () => {
|
|
43
|
-
throw new Error("CSS not found");
|
|
44
|
-
});
|
|
45
|
-
|
|
46
|
-
const useKatexStyles = await loadHook();
|
|
47
|
-
|
|
48
|
-
expect(() => {
|
|
49
|
-
mountWith(useKatexStyles);
|
|
50
|
-
}).not.toThrow();
|
|
51
|
-
await nextTick();
|
|
52
|
-
});
|
|
53
|
-
|
|
54
|
-
it("does not use a static katex CSS import in the component", async () => {
|
|
55
|
-
// Regression guard: ensure the static import doesn't creep back.
|
|
56
|
-
const fs = await import("fs");
|
|
57
|
-
const path = await import("path");
|
|
58
|
-
const componentPath = path.resolve(
|
|
59
|
-
__dirname,
|
|
60
|
-
"../../components/chat/CopilotChatAssistantMessage.vue",
|
|
61
|
-
);
|
|
62
|
-
const source = fs.readFileSync(componentPath, "utf-8");
|
|
63
|
-
|
|
64
|
-
// Should NOT have a static import of katex CSS anywhere in the SFC.
|
|
65
|
-
expect(source).not.toMatch(/import\s+['"]katex\/dist\/katex\.min\.css['"]/);
|
|
66
|
-
// Should use the composable instead.
|
|
67
|
-
expect(source).toMatch(/useKatexStyles/);
|
|
68
|
-
});
|
|
69
|
-
});
|
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
import { onMounted } from "vue";
|
|
2
|
-
|
|
3
|
-
// Module-level singleton flag so the stylesheet is only injected once per
|
|
4
|
-
// module graph (matches the React singleton injection intent).
|
|
5
|
-
let injected = false;
|
|
6
|
-
|
|
7
|
-
/**
|
|
8
|
-
* Dynamically loads KaTeX CSS at runtime to avoid Next.js-style
|
|
9
|
-
* "Global CSS cannot be imported from within node_modules" build errors and
|
|
10
|
-
* to keep the CSS out of the static import graph.
|
|
11
|
-
*
|
|
12
|
-
* Uses a module-level singleton flag so the stylesheet is only loaded once,
|
|
13
|
-
* regardless of how many components call this composable.
|
|
14
|
-
*
|
|
15
|
-
* Mirrors the React `useKatexStyles` hook: returns `void`, never throws, and
|
|
16
|
-
* logs a warning with equivalent intent if the dynamic import fails.
|
|
17
|
-
*
|
|
18
|
-
* @example
|
|
19
|
-
* ```vue
|
|
20
|
-
* <script setup lang="ts">
|
|
21
|
-
* import { useKatexStyles } from "@copilotkit/vue";
|
|
22
|
-
*
|
|
23
|
-
* useKatexStyles();
|
|
24
|
-
* </script>
|
|
25
|
-
* ```
|
|
26
|
-
*/
|
|
27
|
-
export function useKatexStyles(): void {
|
|
28
|
-
onMounted(() => {
|
|
29
|
-
if (injected || typeof document === "undefined") return;
|
|
30
|
-
injected = true;
|
|
31
|
-
|
|
32
|
-
// Dynamic import defers CSS loading to runtime, bypassing build-time
|
|
33
|
-
// static analysis that rejects global CSS from node_modules.
|
|
34
|
-
// The `@vite-ignore` + indirect specifier keeps TypeScript from trying
|
|
35
|
-
// to resolve a type declaration for the CSS module while still letting
|
|
36
|
-
// the bundler handle the actual side-effect import at runtime.
|
|
37
|
-
const katexStylesSpecifier = "katex/dist/katex.min.css";
|
|
38
|
-
void import(/* @vite-ignore */ katexStylesSpecifier).catch(() => {
|
|
39
|
-
console.warn(
|
|
40
|
-
"[CopilotKit] Failed to load katex styles — math content may render without formatting",
|
|
41
|
-
);
|
|
42
|
-
});
|
|
43
|
-
});
|
|
44
|
-
}
|