@copilotkit/angular 0.1.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/package.json ADDED
@@ -0,0 +1,95 @@
1
+ {
2
+ "name": "@copilotkit/angular",
3
+ "version": "0.1.1",
4
+ "description": "Angular library for CopilotKit",
5
+ "license": "MIT",
6
+ "repository": {
7
+ "type": "git",
8
+ "url": "https://github.com/CopilotKit/CopilotKit.git",
9
+ "directory": "packages/angular"
10
+ },
11
+ "type": "module",
12
+ "main": "dist/fesm2022/copilotkit-angular.mjs",
13
+ "module": "dist/fesm2022/copilotkit-angular.mjs",
14
+ "types": "dist/types/copilotkit-angular.d.ts",
15
+ "exports": {
16
+ ".": {
17
+ "import": {
18
+ "types": "./dist/types/copilotkit-angular.d.ts",
19
+ "default": "./dist/fesm2022/copilotkit-angular.mjs"
20
+ }
21
+ },
22
+ "./styles.css": "./dist/styles.css"
23
+ },
24
+ "publishConfig": {
25
+ "access": "public"
26
+ },
27
+ "scripts": {
28
+ "build": "ng-packagr -p ng-package.json && npm run build:css",
29
+ "build:css": "tailwindcss -i ./src/styles/globals.css -o ./src/styles/generated.css && node scripts/scope-preflight.mjs ./src/styles/generated.css && mkdir -p ./dist && cp ./src/styles/generated.css ./dist/styles.css",
30
+ "dev": "concurrently \"ng-packagr -p ng-package.json --watch\" \"npm run dev:css\"",
31
+ "dev:css": "tailwindcss -i ./src/styles/globals.css -o ./src/styles/generated.css --watch",
32
+ "check-types": "tsc --noEmit",
33
+ "test": "vitest run",
34
+ "test:watch": "vitest --watch",
35
+ "publint": "publint .",
36
+ "attw": "attw --pack . --profile node16"
37
+ },
38
+ "dependencies": {
39
+ "@ag-ui/client": "0.0.57",
40
+ "@ag-ui/core": "0.0.57",
41
+ "@copilotkit/a2ui-renderer": "workspace:*",
42
+ "@copilotkit/core": "workspace:*",
43
+ "@copilotkit/shared": "workspace:*",
44
+ "@jetbrains/websandbox": "^1.1.3",
45
+ "clsx": "^2.1.1",
46
+ "highlight.js": "^11.11.1",
47
+ "katex": "^0.16.22",
48
+ "lucide-angular": "^0.540.0",
49
+ "marked": "^16.2.0",
50
+ "rxjs": "^7.8.1",
51
+ "tailwind-merge": "^2.6.0",
52
+ "tslib": "^2.6.0",
53
+ "zod-to-json-schema": "^3.24.5"
54
+ },
55
+ "devDependencies": {
56
+ "@analogjs/vite-plugin-angular": "^1.20.2",
57
+ "@analogjs/vitest-angular": "^1.20.2",
58
+ "@angular/cdk": "^21.2.13",
59
+ "@angular/common": "^21.2.15",
60
+ "@angular/compiler": "^21.2.15",
61
+ "@angular/compiler-cli": "^21.2.15",
62
+ "@angular/core": "^21.2.15",
63
+ "@angular/platform-browser": "^21.2.15",
64
+ "@angular/platform-browser-dynamic": "^21.2.15",
65
+ "@copilotkit/typescript-config": "workspace:*",
66
+ "@lucide/build-icons": "^1.1.0",
67
+ "@tailwindcss/cli": "^4.1.11",
68
+ "@tailwindcss/postcss": "^4.1.11",
69
+ "@tailwindcss/typography": "^0.5.16",
70
+ "@types/katex": "^0.16.7",
71
+ "@types/node": "^22.5.1",
72
+ "@vitest/ui": "^3.2.4",
73
+ "autoprefixer": "^10.4.16",
74
+ "concurrently": "^9.1.0",
75
+ "jsdom": "^24.0.0",
76
+ "ng-packagr": "^21.2.3",
77
+ "postcss": "^8.4.31",
78
+ "reflect-metadata": "^0.2.2",
79
+ "rimraf": "^6.0.1",
80
+ "rxjs": "^7.8.1",
81
+ "tailwindcss": "^4.0.8",
82
+ "tslib": "^2.8.1",
83
+ "tw-animate-css": "^1.3.5",
84
+ "typescript": "5.9.3",
85
+ "vite": "^7.1.4",
86
+ "vitest": "^3.2.4",
87
+ "zod": "^3.22.4"
88
+ },
89
+ "peerDependencies": {
90
+ "@angular/cdk": "^19.0.0 || ^20.0.0 || ^21.0.0",
91
+ "@angular/common": "^19.0.0 || ^20.0.0 || ^21.0.0",
92
+ "@angular/core": "^19.0.0 || ^20.0.0 || ^21.0.0",
93
+ "rxjs": "^7.8.0"
94
+ }
95
+ }
@@ -0,0 +1,100 @@
1
+ /**
2
+ * Post-processes compiled Tailwind CSS to scope all @layer base rules
3
+ * under [data-copilotkit], preventing CopilotKit styles from leaking
4
+ * into the host application.
5
+ *
6
+ * Run after `tailwindcss` CLI: node scripts/scope-preflight.mjs <file>
7
+ */
8
+
9
+ import { readFileSync, writeFileSync } from "fs";
10
+ import postcss from "postcss";
11
+
12
+ const SCOPE = "[data-copilotkit]";
13
+ const file = process.argv[2];
14
+ if (!file) {
15
+ console.error("Usage: node scripts/scope-preflight.mjs <css-file>");
16
+ process.exit(1);
17
+ }
18
+
19
+ /** Selectors that are already scoped and should be left alone. */
20
+ function isAlreadyScoped(selector) {
21
+ return (
22
+ selector.includes("[data-copilot") || selector.includes("[data-sidebar")
23
+ );
24
+ }
25
+
26
+ /** Rewrite a single selector to be scoped under [data-copilotkit]. */
27
+ function scopeSelector(sel) {
28
+ sel = sel.trim();
29
+
30
+ // Already scoped — keep as-is
31
+ if (isAlreadyScoped(sel)) return sel;
32
+
33
+ // html, :host → [data-copilotkit]
34
+ if (sel === "html" || sel === ":host" || sel === "html,:host") {
35
+ return SCOPE;
36
+ }
37
+
38
+ // body → null (remove)
39
+ if (sel === "body") return null;
40
+
41
+ // ::backdrop → null (cannot be scoped to a container)
42
+ if (sel === "::backdrop") return null;
43
+
44
+ // Bare universal selector → scope to container + descendants
45
+ if (sel === "*") return `${SCOPE}, ${SCOPE} *`;
46
+
47
+ // Pseudo-elements (::) and vendor pseudo-classes (:-) → descendant only
48
+ // These can't be combined with an attribute selector suffix
49
+ if (sel.startsWith(":")) {
50
+ return `${SCOPE} ${sel}`;
51
+ }
52
+
53
+ // Element / attribute selectors → descendant AND self-matching
54
+ // e.g. button → [data-copilotkit] button, button[data-copilotkit]
55
+ // This ensures <button data-copilotkit> also receives the preflight reset
56
+ return `${SCOPE} ${sel}, ${sel}${SCOPE}`;
57
+ }
58
+
59
+ function scopeRule(rule) {
60
+ const newSelectors = [];
61
+
62
+ for (const sel of rule.selectors) {
63
+ const scoped = scopeSelector(sel);
64
+ if (scoped !== null) {
65
+ // scopeSelector may return comma-separated selectors (for *)
66
+ if (typeof scoped === "string" && scoped.includes(", ")) {
67
+ newSelectors.push(...scoped.split(", "));
68
+ } else if (scoped) {
69
+ newSelectors.push(scoped);
70
+ }
71
+ }
72
+ }
73
+
74
+ if (newSelectors.length === 0) {
75
+ rule.remove();
76
+ } else {
77
+ rule.selectors = newSelectors;
78
+ }
79
+ }
80
+
81
+ /** Recursively scope all rules within a node (handles @supports, @media, etc.) */
82
+ function scopeChildren(node) {
83
+ node.walk((child) => {
84
+ if (child.type === "rule") {
85
+ scopeRule(child);
86
+ }
87
+ // @supports / @media blocks are walked automatically
88
+ });
89
+ }
90
+
91
+ // --- Main ---
92
+ const css = readFileSync(file, "utf8");
93
+ const root = postcss.parse(css);
94
+
95
+ root.walkAtRules("layer", (layer) => {
96
+ if (layer.params !== "base") return;
97
+ scopeChildren(layer);
98
+ });
99
+
100
+ writeFileSync(file, root.toString());
package/tsconfig.json ADDED
@@ -0,0 +1,42 @@
1
+ {
2
+ "extends": "@copilotkit/typescript-config/base.json",
3
+ "compilerOptions": {
4
+ "outDir": "./dist",
5
+ "declaration": true,
6
+ "declarationMap": true,
7
+ "sourceMap": true,
8
+ "lib": ["ES2022", "DOM"],
9
+ "target": "ES2022",
10
+ "module": "ES2022",
11
+ "moduleResolution": "bundler",
12
+ "experimentalDecorators": true,
13
+ "emitDecoratorMetadata": true,
14
+ "strict": true,
15
+ "esModuleInterop": true,
16
+ "skipLibCheck": true,
17
+ "forceConsistentCasingInFileNames": true,
18
+ "importHelpers": true,
19
+ "types": ["node"],
20
+ "paths": {
21
+ "@copilotkit/a2ui-renderer/web-components": [
22
+ "../a2ui-renderer/src/web-components/index.ts"
23
+ ],
24
+ "@copilotkit/a2ui-renderer/web-components/define": [
25
+ "../a2ui-renderer/src/web-components/define.ts"
26
+ ],
27
+ "@copilotkit/core": ["../core/dist/index.d.mts", "../core/src/index.ts"],
28
+ "@copilotkit/shared": [
29
+ "../shared/dist/index.d.mts",
30
+ "../shared/src/index.ts"
31
+ ]
32
+ }
33
+ },
34
+ "include": ["src/**/*"],
35
+ "exclude": ["node_modules", "dist", "**/*.spec.ts", "**/*.test.ts"],
36
+ "angularCompilerOptions": {
37
+ "enableI18nLegacyMessageIdFormat": false,
38
+ "strictInjectionParameters": true,
39
+ "strictInputAccessModifiers": true,
40
+ "strictTemplates": true
41
+ }
42
+ }
@@ -0,0 +1,47 @@
1
+ /// <reference types="vitest" />
2
+ import { defineConfig } from "vite";
3
+ import angular from "@analogjs/vite-plugin-angular";
4
+ import { fileURLToPath } from "node:url";
5
+ import { dirname, resolve } from "node:path";
6
+
7
+ const __dirname = dirname(fileURLToPath(import.meta.url));
8
+ const r = (...p: string[]) => resolve(__dirname, ...p);
9
+
10
+ export default defineConfig(({ mode }) => ({
11
+ plugins: [angular()],
12
+ resolve: {
13
+ dedupe: [
14
+ "@angular/core",
15
+ "@angular/common",
16
+ "@angular/platform-browser",
17
+ "@angular/platform-browser-dynamic",
18
+ "@angular/compiler",
19
+ "@angular/core/testing",
20
+ ],
21
+ },
22
+ test: {
23
+ globals: true,
24
+ environment: "jsdom",
25
+ setupFiles: [r("src/test-setup.ts")], // Use absolute path
26
+ include: ["src/**/*.{spec,test}.{ts,tsx}"],
27
+ pool: "threads",
28
+ poolOptions: { threads: { singleThread: true } },
29
+ reporters: [["default", { summary: false }]],
30
+ silent: true,
31
+ coverage: {
32
+ provider: "v8",
33
+ reporter: ["text", "json", "html"],
34
+ exclude: [
35
+ "node_modules/",
36
+ "dist/",
37
+ "*.config.*",
38
+ "src/test-setup.ts",
39
+ "src/index.ts",
40
+ "src/public-api.ts",
41
+ ],
42
+ },
43
+ },
44
+ define: {
45
+ "import.meta.vitest": mode !== "production",
46
+ },
47
+ }));