@tavus/cvi-ui 0.0.1-beta.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.
Files changed (67) hide show
  1. package/.prettierrc.js +24 -0
  2. package/LICENSE +21 -0
  3. package/README.md +91 -0
  4. package/dev-components/components/cvi-provider/index.tsx +9 -0
  5. package/dev-components/hooks/README.md +499 -0
  6. package/dev-components/hooks/cvi-events-hooks.tsx +168 -0
  7. package/dev-components/hooks/use-cvi-call.tsx +24 -0
  8. package/dev-components/hooks/use-local-camera.tsx +20 -0
  9. package/dev-components/hooks/use-local-microphone.tsx +20 -0
  10. package/dev-components/hooks/use-local-screenshare.tsx +32 -0
  11. package/dev-components/hooks/use-remote-participant-ids.tsx +7 -0
  12. package/dev-components/hooks/use-replica-ids.tsx +9 -0
  13. package/dev-components/hooks/use-request-permissions.tsx +24 -0
  14. package/dev-components/hooks/use-start-haircheck.tsx +60 -0
  15. package/dist/index.js +237334 -0
  16. package/dist/types/cli/add.d.ts +20 -0
  17. package/dist/types/cli/info.d.ts +2 -0
  18. package/dist/types/cli/init.d.ts +23 -0
  19. package/dist/types/components/highlighter.d.ts +6 -0
  20. package/dist/types/components/logger.d.ts +8 -0
  21. package/dist/types/components/spinner.d.ts +4 -0
  22. package/dist/types/constants/components.d.ts +59 -0
  23. package/dist/types/constants/config.d.ts +5 -0
  24. package/dist/types/constants/errors.d.ts +5 -0
  25. package/dist/types/constants/frameworks.d.ts +39 -0
  26. package/dist/types/index.d.ts +1 -0
  27. package/dist/types/preflights/preflight-add.d.ts +15 -0
  28. package/dist/types/preflights/preflight-init.d.ts +9 -0
  29. package/dist/types/utils/add-components.d.ts +5 -0
  30. package/dist/types/utils/get-config.d.ts +51 -0
  31. package/dist/types/utils/get-package-info.d.ts +2 -0
  32. package/dist/types/utils/get-package-manager.d.ts +4 -0
  33. package/dist/types/utils/get-project-info.d.ts +10 -0
  34. package/dist/types/utils/handle-error.d.ts +1 -0
  35. package/dist/types/utils/resolve-components-tree.d.ts +4 -0
  36. package/dist/types/utils/resolve-import.d.ts +2 -0
  37. package/dist/types/utils/update-dependencies.d.ts +4 -0
  38. package/dist/types/utils/update-files.d.ts +14 -0
  39. package/dist/typescript-DhnEO4aV.js +12 -0
  40. package/dist/typescript-XxXP1Woc.js +14 -0
  41. package/eslint.config.js +12 -0
  42. package/package.json +67 -0
  43. package/prepare-scripts/convert-to-js.js +152 -0
  44. package/prepare-scripts/create-templates.js +265 -0
  45. package/rollup.config.js +28 -0
  46. package/src/cli/add.ts +124 -0
  47. package/src/cli/info.ts +21 -0
  48. package/src/cli/init.ts +131 -0
  49. package/src/components/highlighter.ts +8 -0
  50. package/src/components/logger.ts +22 -0
  51. package/src/components/spinner.ts +13 -0
  52. package/src/constants/config.ts +7 -0
  53. package/src/constants/errors.ts +5 -0
  54. package/src/constants/frameworks.ts +40 -0
  55. package/src/index.ts +26 -0
  56. package/src/preflights/preflight-add.ts +56 -0
  57. package/src/preflights/preflight-init.ts +77 -0
  58. package/src/utils/add-components.ts +52 -0
  59. package/src/utils/get-config.ts +60 -0
  60. package/src/utils/get-package-info.ts +14 -0
  61. package/src/utils/get-package-manager.ts +45 -0
  62. package/src/utils/get-project-info.ts +144 -0
  63. package/src/utils/handle-error.ts +34 -0
  64. package/src/utils/resolve-components-tree.ts +35 -0
  65. package/src/utils/update-dependencies.ts +37 -0
  66. package/src/utils/update-files.ts +212 -0
  67. package/tsconfig.json +23 -0
@@ -0,0 +1,20 @@
1
+ #!/usr/bin/env node
2
+ import { z } from 'zod';
3
+ import { Command } from 'commander';
4
+ export declare const addOptionsSchema: z.ZodObject<{
5
+ components: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
6
+ overwrite: z.ZodBoolean;
7
+ cwd: z.ZodString;
8
+ silent: z.ZodBoolean;
9
+ }, "strip", z.ZodTypeAny, {
10
+ cwd: string;
11
+ silent: boolean;
12
+ overwrite: boolean;
13
+ components?: string[] | undefined;
14
+ }, {
15
+ cwd: string;
16
+ silent: boolean;
17
+ overwrite: boolean;
18
+ components?: string[] | undefined;
19
+ }>;
20
+ export declare const add: Command;
@@ -0,0 +1,2 @@
1
+ import { Command } from 'commander';
2
+ export declare const info: Command;
@@ -0,0 +1,23 @@
1
+ import { Command } from 'commander';
2
+ import { z } from 'zod';
3
+ export declare const initOptionsSchema: z.ZodObject<{
4
+ cwd: z.ZodString;
5
+ silent: z.ZodBoolean;
6
+ components: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
7
+ }, "strip", z.ZodTypeAny, {
8
+ cwd: string;
9
+ silent: boolean;
10
+ components?: string[] | undefined;
11
+ }, {
12
+ cwd: string;
13
+ silent: boolean;
14
+ components?: string[] | undefined;
15
+ }>;
16
+ export declare const init: Command;
17
+ export declare function runInit(options: z.infer<typeof initOptionsSchema>): Promise<{
18
+ tsx: boolean;
19
+ resolvedPaths: {
20
+ components: string;
21
+ cwd: string;
22
+ };
23
+ }>;
@@ -0,0 +1,6 @@
1
+ export declare const highlighter: {
2
+ error: typeof import("kleur/colors").print;
3
+ warn: typeof import("kleur/colors").print;
4
+ info: typeof import("kleur/colors").print;
5
+ success: typeof import("kleur/colors").print;
6
+ };
@@ -0,0 +1,8 @@
1
+ export declare const logger: {
2
+ error(...args: unknown[]): void;
3
+ warn(...args: unknown[]): void;
4
+ info(...args: unknown[]): void;
5
+ success(...args: unknown[]): void;
6
+ log(...args: unknown[]): void;
7
+ break(): void;
8
+ };
@@ -0,0 +1,4 @@
1
+ import { type Options } from "ora";
2
+ export declare function spinner(text: Options["text"], options?: {
3
+ silent?: boolean;
4
+ }): import("ora").Ora;
@@ -0,0 +1,59 @@
1
+ export type ComponentType = 'component' | 'hook' | 'block';
2
+ export declare const COMPONENTS: {
3
+ 'replica-video': {
4
+ name: string;
5
+ path: string;
6
+ type: ComponentType;
7
+ componentsDependencies: never[];
8
+ dependency: never[];
9
+ };
10
+ 'local-video': {
11
+ name: string;
12
+ path: string;
13
+ type: ComponentType;
14
+ componentsDependencies: never[];
15
+ dependency: never[];
16
+ };
17
+ 'cvi-provider': {
18
+ name: string;
19
+ path: string;
20
+ type: ComponentType;
21
+ componentsDependencies: never[];
22
+ dependency: string[];
23
+ };
24
+ conversation: {
25
+ name: string;
26
+ path: string;
27
+ type: ComponentType;
28
+ componentsDependencies: never[];
29
+ dependency: never[];
30
+ };
31
+ 'hair-check': {
32
+ name: string;
33
+ path: string;
34
+ type: ComponentType;
35
+ componentsDependencies: never[];
36
+ dependency: never[];
37
+ };
38
+ controls: {
39
+ name: string;
40
+ path: string;
41
+ type: ComponentType;
42
+ componentsDependencies: never[];
43
+ dependency: never[];
44
+ };
45
+ 'cvi-hooks': {
46
+ name: string;
47
+ path: string;
48
+ type: ComponentType;
49
+ componentsDependencies: never[];
50
+ dependency: never[];
51
+ };
52
+ 'cvi-events-hooks': {
53
+ name: string;
54
+ path: string;
55
+ type: ComponentType;
56
+ componentsDependencies: never[];
57
+ dependency: never[];
58
+ };
59
+ };
@@ -0,0 +1,5 @@
1
+ export declare const CONFIG: {
2
+ tsx: boolean;
3
+ };
4
+ export declare const CONFIG_NAME = "cvi-components.json";
5
+ export declare const DEFAULT_DEPENDENCIES: string[];
@@ -0,0 +1,5 @@
1
+ export declare const MISSING_DIR_OR_EMPTY_PROJECT = "1";
2
+ export declare const EXISTING_CONFIG = "2";
3
+ export declare const MISSING_CONFIG = "3";
4
+ export declare const FAILED_CONFIG_READ = "4";
5
+ export declare const UNSUPPORTED_FRAMEWORK = "7";
@@ -0,0 +1,39 @@
1
+ export declare const FRAMEWORKS: {
2
+ readonly 'next-app': {
3
+ readonly name: "next-app";
4
+ readonly label: "Next.js";
5
+ };
6
+ readonly 'next-pages': {
7
+ readonly name: "next-pages";
8
+ readonly label: "Next.js";
9
+ };
10
+ readonly remix: {
11
+ readonly name: "remix";
12
+ readonly label: "Remix";
13
+ };
14
+ readonly 'react-router': {
15
+ readonly name: "react-router";
16
+ readonly label: "React Router";
17
+ };
18
+ readonly vite: {
19
+ readonly name: "vite";
20
+ readonly label: "Vite";
21
+ };
22
+ readonly astro: {
23
+ readonly name: "astro";
24
+ readonly label: "Astro";
25
+ };
26
+ readonly 'tanstack-start': {
27
+ readonly name: "tanstack-start";
28
+ readonly label: "TanStack Start";
29
+ };
30
+ readonly gatsby: {
31
+ readonly name: "gatsby";
32
+ readonly label: "Gatsby";
33
+ };
34
+ readonly manual: {
35
+ readonly name: "manual";
36
+ readonly label: "Manual";
37
+ };
38
+ };
39
+ export type Framework = (typeof FRAMEWORKS)[keyof typeof FRAMEWORKS];
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,15 @@
1
+ import { addOptionsSchema } from '@/src/cli/add';
2
+ import { z } from 'zod';
3
+ export declare function preFlightAdd(options: z.infer<typeof addOptionsSchema>): Promise<{
4
+ errors: Record<string, boolean>;
5
+ config: null;
6
+ } | {
7
+ errors: Record<string, boolean>;
8
+ config: {
9
+ tsx: boolean;
10
+ resolvedPaths: {
11
+ components: string;
12
+ cwd: string;
13
+ };
14
+ };
15
+ }>;
@@ -0,0 +1,9 @@
1
+ import { initOptionsSchema } from '@/src/cli/init';
2
+ import { z } from 'zod';
3
+ export declare function preFlightInit(options: z.infer<typeof initOptionsSchema>): Promise<{
4
+ errors: Record<string, boolean>;
5
+ projectInfo: null;
6
+ } | {
7
+ errors: Record<string, boolean>;
8
+ projectInfo: import("@/src/utils/get-project-info").ProjectInfo;
9
+ }>;
@@ -0,0 +1,5 @@
1
+ import { type Config } from '@/src/utils/get-config';
2
+ export declare function addComponents(components: string[], config: Config, options: {
3
+ overwrite?: boolean;
4
+ silent?: boolean;
5
+ }): Promise<void>;
@@ -0,0 +1,51 @@
1
+ import { z } from 'zod';
2
+ export declare const rawConfigSchema: z.ZodObject<{
3
+ tsx: z.ZodDefault<z.ZodBoolean>;
4
+ }, "strict", z.ZodTypeAny, {
5
+ tsx: boolean;
6
+ }, {
7
+ tsx?: boolean | undefined;
8
+ }>;
9
+ export type RawConfig = z.infer<typeof rawConfigSchema>;
10
+ export declare const configSchema: z.ZodObject<z.objectUtil.extendShape<{
11
+ tsx: z.ZodDefault<z.ZodBoolean>;
12
+ }, {
13
+ resolvedPaths: z.ZodObject<{
14
+ cwd: z.ZodString;
15
+ components: z.ZodString;
16
+ }, "strip", z.ZodTypeAny, {
17
+ components: string;
18
+ cwd: string;
19
+ }, {
20
+ components: string;
21
+ cwd: string;
22
+ }>;
23
+ }>, "strict", z.ZodTypeAny, {
24
+ tsx: boolean;
25
+ resolvedPaths: {
26
+ components: string;
27
+ cwd: string;
28
+ };
29
+ }, {
30
+ resolvedPaths: {
31
+ components: string;
32
+ cwd: string;
33
+ };
34
+ tsx?: boolean | undefined;
35
+ }>;
36
+ export type Config = z.infer<typeof configSchema>;
37
+ export declare function getConfig(cwd: string): Promise<{
38
+ tsx: boolean;
39
+ resolvedPaths: {
40
+ components: string;
41
+ cwd: string;
42
+ };
43
+ } | null>;
44
+ export declare function resolveConfigPaths(cwd: string, config: RawConfig): Promise<{
45
+ tsx: boolean;
46
+ resolvedPaths: {
47
+ components: string;
48
+ cwd: string;
49
+ };
50
+ }>;
51
+ export declare function getRawConfig(cwd: string): Promise<RawConfig | null>;
@@ -0,0 +1,2 @@
1
+ import { type PackageJson } from "type-fest";
2
+ export declare function getPackageInfo(cwd?: string, shouldThrow?: boolean): PackageJson | null;
@@ -0,0 +1,4 @@
1
+ export declare function getPackageManager(targetDir: string, { withFallback }?: {
2
+ withFallback?: boolean;
3
+ }): Promise<"yarn" | "pnpm" | "bun" | "npm" | "deno">;
4
+ export declare function getPackageRunner(cwd: string): Promise<"pnpm dlx" | "bunx" | "npx">;
@@ -0,0 +1,10 @@
1
+ import { Framework } from '@/src/constants/frameworks';
2
+ import { Config } from '@/src/utils/get-config';
3
+ export type ProjectInfo = {
4
+ framework: Framework;
5
+ isTsx: boolean;
6
+ isSrcDir: boolean;
7
+ };
8
+ export declare function getProjectInfo(cwd: string): Promise<ProjectInfo | null>;
9
+ export declare function isTypeScriptProject(cwd: string): Promise<boolean>;
10
+ export declare function getProjectConfig(cwd: string, defaultProjectInfo?: ProjectInfo | null): Promise<Config | null>;
@@ -0,0 +1 @@
1
+ export declare function handleError(error: unknown): void;
@@ -0,0 +1,4 @@
1
+ export declare function resolveComponentsTree(components: string[]): {
2
+ dependencies: string[];
3
+ componentsDependencies: string[];
4
+ };
@@ -0,0 +1,2 @@
1
+ import { type ConfigLoaderSuccessResult } from "tsconfig-paths";
2
+ export declare function resolveImport(importPath: string, config: Pick<ConfigLoaderSuccessResult, "absoluteBaseUrl" | "paths">): Promise<string | undefined>;
@@ -0,0 +1,4 @@
1
+ import { Config } from '@/src/utils/get-config';
2
+ export declare function updateDependencies(dependencies: string[], config: Config, options: {
3
+ silent?: boolean;
4
+ }): Promise<void>;
@@ -0,0 +1,14 @@
1
+ import { Config } from '@/src/utils/get-config';
2
+ import { spinner } from '@/src/components/spinner';
3
+ export declare function updateFiles(files: string[], config: Config, options: {
4
+ overwrite?: boolean;
5
+ force?: boolean;
6
+ silent?: boolean;
7
+ rootSpinner?: ReturnType<typeof spinner>;
8
+ isRemote?: boolean;
9
+ }): Promise<{
10
+ filesCreated: string[];
11
+ filesUpdated: string[];
12
+ filesSkipped: string[];
13
+ }>;
14
+ export declare function getNormalizedFileContent(content: string): Promise<string>;
@@ -0,0 +1,12 @@
1
+ #!/usr/bin/env node
2
+ import { g as getDefaultExportFromCjs, r as requireTypescript } from './index.js';
3
+
4
+ var typescriptExports = requireTypescript();
5
+ var typescript = /*@__PURE__*/getDefaultExportFromCjs(typescriptExports);
6
+
7
+ var typescript$1 = /*#__PURE__*/Object.freeze({
8
+ __proto__: null,
9
+ default: typescript
10
+ });
11
+
12
+ export { typescript$1 as t };
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env node
2
+ 'use strict';
3
+
4
+ var index = require('./index.js');
5
+
6
+ var typescriptExports = index.requireTypescript();
7
+ var typescript = /*@__PURE__*/index.getDefaultExportFromCjs(typescriptExports);
8
+
9
+ var typescript$1 = /*#__PURE__*/Object.freeze({
10
+ __proto__: null,
11
+ default: typescript
12
+ });
13
+
14
+ exports.typescript = typescript$1;
@@ -0,0 +1,12 @@
1
+ import { defineConfig } from "eslint/config";
2
+ import globals from "globals";
3
+ import js from "@eslint/js";
4
+ import tseslint from "typescript-eslint";
5
+
6
+
7
+ export default defineConfig([
8
+ { files: ["**/*.{js,mjs,cjs,ts}"] },
9
+ { files: ["**/*.{js,mjs,cjs,ts}"], languageOptions: { globals: {...globals.browser, ...globals.node} } },
10
+ { files: ["**/*.{js,mjs,cjs,ts}"], plugins: { js }, extends: ["js/recommended"] },
11
+ tseslint.configs.recommended,
12
+ ]);
package/package.json ADDED
@@ -0,0 +1,67 @@
1
+ {
2
+ "name": "@tavus/cvi-ui",
3
+ "version": "0.0.1-beta.1",
4
+ "description": "A CLI tool for installing and managing CVI components",
5
+ "publishConfig": {
6
+ "access": "public"
7
+ },
8
+ "keywords": [
9
+ "cvi",
10
+ "conversational-video-interface",
11
+ "ai-replica",
12
+ "react",
13
+ "components",
14
+ "hooks",
15
+ "tavus"
16
+ ],
17
+ "author": "Tavus",
18
+ "license": "MIT",
19
+ "type": "module",
20
+ "scripts": {
21
+ "build": "rollup -c",
22
+ "start": "node dist/index.js",
23
+ "create-templates": "node prepare-scripts/create-templates.js",
24
+ "convert-to-js": "node prepare-scripts/convert-to-js.js",
25
+ "prepare": "npm run convert-to-js && npm run create-templates"
26
+ },
27
+ "main": "dist/index.js",
28
+ "bin": "./dist/index.js",
29
+ "homepage": "https://github.com/Tavus-Engineering",
30
+ "repository": {
31
+ "type": "git",
32
+ "url": "https://github.com/Tavus-Engineering"
33
+ },
34
+ "devDependencies": {
35
+ "@babel/generator": "^7.27.5",
36
+ "@babel/parser": "^7.27.5",
37
+ "@babel/traverse": "^7.27.4",
38
+ "@eslint/js": "^9.24.0",
39
+ "@rollup/plugin-commonjs": "^28.0.3",
40
+ "@rollup/plugin-json": "^6.1.0",
41
+ "@rollup/plugin-node-resolve": "^16.0.1",
42
+ "@rollup/plugin-typescript": "^12.1.2",
43
+ "@types/fs-extra": "^11.0.4",
44
+ "@types/node": "^22.14.0",
45
+ "@types/prompts": "^2.4.9",
46
+ "eslint": "^9.24.0",
47
+ "globals": "^16.0.0",
48
+ "prettier": "^3.5.3",
49
+ "rollup": "^4.41.1",
50
+ "rollup-plugin-copy": "^3.5.0",
51
+ "type-fest": "^4.39.1",
52
+ "typescript": "^5.8.3",
53
+ "typescript-eslint": "^8.29.1"
54
+ },
55
+ "dependencies": {
56
+ "@antfu/ni": "^24.3.0",
57
+ "commander": "^13.1.0",
58
+ "cosmiconfig": "^9.0.0",
59
+ "execa": "^9.5.2",
60
+ "fs-extra": "^11.3.0",
61
+ "kleur": "^4.1.5",
62
+ "ora": "^8.2.0",
63
+ "prompts": "^2.4.2",
64
+ "tsconfig-paths": "^4.2.0",
65
+ "zod": "^3.24.2"
66
+ }
67
+ }
@@ -0,0 +1,152 @@
1
+ import fs from 'fs';
2
+ import path from 'path';
3
+ import { fileURLToPath } from 'url';
4
+ import { parse } from '@babel/parser';
5
+ import traverse from '@babel/traverse';
6
+ import generate from '@babel/generator';
7
+ import prettier from 'prettier';
8
+
9
+ const __filename = fileURLToPath(import.meta.url);
10
+ const __dirname = path.dirname(__filename);
11
+ const projectRoot = path.resolve(__dirname, '..');
12
+
13
+ // Function to convert TypeScript code to JavaScript by removing types
14
+ function convertToJs(content) {
15
+ const ast = parse(content, {
16
+ sourceType: 'module',
17
+ plugins: ['typescript', 'jsx'],
18
+ });
19
+
20
+ traverse.default(ast, {
21
+ // Remove type annotations
22
+ TSTypeAnnotation(path) {
23
+ path.remove();
24
+ },
25
+ // Remove type parameters
26
+ TSTypeParameter(path) {
27
+ path.remove();
28
+ },
29
+ // Remove type parameter instantiation (generics like <T>)
30
+ TSTypeParameterInstantiation(path) {
31
+ path.remove();
32
+ },
33
+ // Remove interface declarations
34
+ TSInterfaceDeclaration(path) {
35
+ path.remove();
36
+ },
37
+ // Remove type declarations
38
+ TSTypeAliasDeclaration(path) {
39
+ path.remove();
40
+ },
41
+ // Remove type imports
42
+ ImportDeclaration(path) {
43
+ if (path.node.importKind === 'type') {
44
+ path.remove();
45
+ }
46
+ },
47
+ // Remove type assertions
48
+ TSTypeAssertion(path) {
49
+ path.replaceWith(path.node.expression);
50
+ },
51
+ // Remove type parameters from functions
52
+ TSTypeParameterDeclaration(path) {
53
+ path.remove();
54
+ },
55
+ // Handle non-null assertion operator (!)
56
+ TSNonNullExpression(path) {
57
+ path.replaceWith(path.node.expression);
58
+ },
59
+ // Handle type assertions
60
+ TSAsExpression(path) {
61
+ // For method calls with type assertions like (obj.method as any)(args)
62
+ if (path.parent.type === 'CallExpression' && path.parent.callee === path.node) {
63
+ const expression = path.node.expression;
64
+ path.parent.callee = expression;
65
+ path.remove();
66
+ return;
67
+ }
68
+
69
+ // For all type assertions, just replace with the expression
70
+ path.replaceWith(path.node.expression);
71
+ }
72
+ });
73
+
74
+ const output = generate.default(ast, {
75
+ retainLines: true,
76
+ compact: false,
77
+ });
78
+
79
+ return output.code;
80
+ }
81
+
82
+ // Function to format code with Prettier
83
+ async function formatCode(code, filePath) {
84
+ const config = await prettier.resolveConfig(filePath);
85
+ return prettier.format(code, {
86
+ ...config,
87
+ filepath: filePath,
88
+ });
89
+ }
90
+
91
+ // Main function to process all templates
92
+ async function convertTemplates() {
93
+ const templatesDir = path.join(projectRoot, 'dev-components');
94
+ const outputDir = path.join(projectRoot, 'jsx-templates');
95
+ const components = [];
96
+
97
+ // Create output directory if it doesn't exist
98
+ if (!fs.existsSync(outputDir)) {
99
+ fs.mkdirSync(outputDir, { recursive: true });
100
+ }
101
+
102
+ // Process all TSX and TS files in the templates directory
103
+ async function processDirectory(dir) {
104
+ const items = fs.readdirSync(dir);
105
+
106
+ for (const item of items) {
107
+ const itemPath = path.join(dir, item);
108
+ const stat = fs.statSync(itemPath);
109
+
110
+ if (stat.isDirectory()) {
111
+ await processDirectory(itemPath);
112
+ } else if (item.endsWith('.tsx') || item.endsWith('.ts')) {
113
+ const relativePath = path.relative(templatesDir, itemPath);
114
+ const outputPath = path.join(outputDir, relativePath)
115
+ .replace('.tsx', '.jsx')
116
+ .replace('.ts', '.js');
117
+
118
+ // Ensure the output directory exists
119
+ const outputDirPath = path.dirname(outputPath);
120
+ if (!fs.existsSync(outputDirPath)) {
121
+ fs.mkdirSync(outputDirPath, { recursive: true });
122
+ }
123
+
124
+ const content = fs.readFileSync(itemPath, 'utf-8');
125
+ const jsContent = convertToJs(content);
126
+ const formattedContent = await formatCode(jsContent, outputPath);
127
+
128
+ fs.writeFileSync(outputPath, formattedContent);
129
+ console.log(`Converted: ${outputPath}`);
130
+
131
+ components.push(outputPath);
132
+ } else if (item.endsWith('.css')) {
133
+ // Handle CSS files
134
+ const relativePath = path.relative(templatesDir, itemPath);
135
+ const outputPath = path.join(outputDir, relativePath);
136
+
137
+ // Ensure the output directory exists
138
+ const outputDirPath = path.dirname(outputPath);
139
+ if (!fs.existsSync(outputDirPath)) {
140
+ fs.mkdirSync(outputDirPath, { recursive: true });
141
+ }
142
+
143
+ fs.copyFileSync(itemPath, outputPath);
144
+ console.log(`Copied CSS: ${outputPath}`);
145
+ }
146
+ }
147
+ }
148
+
149
+ await processDirectory(templatesDir);
150
+ }
151
+
152
+ convertTemplates().catch(console.error);