@viji-dev/sdk 1.0.0 → 1.0.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 (77) hide show
  1. package/README.md +155 -60
  2. package/bin/viji.js +9 -29
  3. package/dist/assets/artist-dts-BHUsvSI6.js +613 -0
  4. package/dist/assets/artist-dts-p5-Cyw8vmy_.js +736 -0
  5. package/dist/assets/core-CiQx3w0t.js +12 -0
  6. package/dist/assets/dark-plus-C3mMm8J8.js +1 -0
  7. package/dist/assets/docs-api-PBLtY4Ni.js +12381 -0
  8. package/dist/assets/engine-javascript-CXyY7cc8.js +141 -0
  9. package/dist/assets/essentia-wasm.web-0S-sW98u-CYV1l1zv.js +38 -0
  10. package/dist/assets/essentia.js-core.es-DnrJE0uR-DOSrF5_G.js +32 -0
  11. package/dist/assets/glsl-DMyvO4G4.js +1 -0
  12. package/dist/assets/index-BhFxsauQ.js +215 -0
  13. package/dist/assets/index-BqhVeA7U.css +1 -0
  14. package/dist/assets/index-T4TOjvD0.js +1 -0
  15. package/dist/assets/index-Wz9WqGqz.js +52 -0
  16. package/dist/assets/index-t24aGwla.js +1 -0
  17. package/dist/assets/javascript-wDzz0qaB.js +1 -0
  18. package/dist/assets/shader-uniforms-GdaUkQPK.js +1 -0
  19. package/dist/assets/typescript-BPQ3VLAy.js +1 -0
  20. package/dist/assets/viji.worker-CQSJ0SiO-ljtBlcNZ.js +27018 -0
  21. package/{index.html → dist/index.html} +2 -1
  22. package/package.json +31 -35
  23. package/src/cli/commands/build.js +50 -99
  24. package/src/cli/commands/create.js +32 -47
  25. package/src/cli/commands/dev.js +30 -97
  26. package/src/cli/server/dev-server.js +233 -0
  27. package/src/cli/server/scene-scanner.js +93 -0
  28. package/src/cli/server/vite-scene-plugin.d.ts +2 -0
  29. package/src/cli/server/vite-scene-plugin.js +134 -0
  30. package/src/cli/utils/cli-utils.js +29 -139
  31. package/src/cli/utils/scene-compiler.js +10 -17
  32. package/src/templates/scene-templates.js +85 -0
  33. package/.gitignore +0 -29
  34. package/eslint.config.js +0 -37
  35. package/postcss.config.js +0 -6
  36. package/scenes/audio-visualizer/main.js +0 -287
  37. package/scenes/core-demo/main.js +0 -532
  38. package/scenes/demo-scene/main.js +0 -619
  39. package/scenes/global.d.ts +0 -15
  40. package/scenes/particle-system/main.js +0 -349
  41. package/scenes/tsconfig.json +0 -12
  42. package/scenes/video-mirror/main.ts +0 -436
  43. package/src/App.css +0 -42
  44. package/src/App.tsx +0 -279
  45. package/src/cli/commands/init.js +0 -262
  46. package/src/components/SDKPage.tsx +0 -337
  47. package/src/components/core/CoreContainer.tsx +0 -126
  48. package/src/components/ui/DeviceSelectionList.tsx +0 -137
  49. package/src/components/ui/FPSCounter.tsx +0 -78
  50. package/src/components/ui/FileDropzonePanel.tsx +0 -120
  51. package/src/components/ui/FileListPanel.tsx +0 -285
  52. package/src/components/ui/InputExpansionPanel.tsx +0 -31
  53. package/src/components/ui/MediaPlayerControls.tsx +0 -191
  54. package/src/components/ui/MenuContainer.tsx +0 -71
  55. package/src/components/ui/ParametersMenu.tsx +0 -797
  56. package/src/components/ui/ProjectSwitcherMenu.tsx +0 -192
  57. package/src/components/ui/QuickInputControls.tsx +0 -542
  58. package/src/components/ui/SDKMenuSystem.tsx +0 -96
  59. package/src/components/ui/SettingsMenu.tsx +0 -346
  60. package/src/components/ui/SimpleInputControls.tsx +0 -137
  61. package/src/index.css +0 -68
  62. package/src/main.tsx +0 -10
  63. package/src/scenes-hmr.ts +0 -158
  64. package/src/services/project-filesystem.ts +0 -436
  65. package/src/stores/scene-player/index.ts +0 -3
  66. package/src/stores/scene-player/input-manager.store.ts +0 -1045
  67. package/src/stores/scene-player/scene-session.store.ts +0 -659
  68. package/src/styles/globals.css +0 -111
  69. package/src/templates/minimal-template.js +0 -11
  70. package/src/utils/debounce.js +0 -34
  71. package/src/vite-env.d.ts +0 -1
  72. package/tailwind.config.js +0 -18
  73. package/tsconfig.app.json +0 -27
  74. package/tsconfig.json +0 -27
  75. package/tsconfig.node.json +0 -27
  76. package/vite.config.ts +0 -54
  77. /package/{public → dist}/favicon.png +0 -0
@@ -12,9 +12,10 @@
12
12
 
13
13
  <!-- Permissions for media access -->
14
14
  <meta http-equiv="Feature-Policy" content="camera 'self'; microphone 'self'; display-capture 'self'" />
15
+ <script type="module" crossorigin src="/assets/index-BhFxsauQ.js"></script>
16
+ <link rel="stylesheet" crossorigin href="/assets/index-BqhVeA7U.css">
15
17
  </head>
16
18
  <body>
17
19
  <div id="root"></div>
18
- <script type="module" src="/src/main.tsx"></script>
19
20
  </body>
20
21
  </html>
package/package.json CHANGED
@@ -1,7 +1,6 @@
1
1
  {
2
2
  "name": "@viji-dev/sdk",
3
- "private": false,
4
- "version": "1.0.0",
3
+ "version": "1.0.1",
5
4
  "type": "module",
6
5
  "description": "Professional toolkit for creating interactive Viji scenes",
7
6
  "keywords": [
@@ -17,28 +16,11 @@
17
16
  "bin": {
18
17
  "viji": "./bin/viji.js"
19
18
  },
20
- "scripts": {
21
- "dev": "vite",
22
- "build": "tsc -b && vite build",
23
- "lint": "eslint .",
24
- "preview": "vite preview",
25
- "cli:dev": "node bin/viji.js dev",
26
- "cli:build": "node bin/viji.js build",
27
- "cli:create": "node bin/viji.js create"
28
- },
29
- "main": "src/main.tsx",
30
19
  "files": [
31
20
  "bin/",
32
- "src/",
33
- "scenes/",
34
- "public/",
35
- "index.html",
36
- "vite.config.ts",
37
- "tsconfig*.json",
38
- "tailwind.config.js",
39
- "postcss.config.js",
40
- "eslint.config.js",
41
- ".gitignore",
21
+ "src/cli/",
22
+ "src/templates/",
23
+ "dist/",
42
24
  "README.md",
43
25
  "LICENSE"
44
26
  ],
@@ -51,32 +33,46 @@
51
33
  "url": "https://github.com/viji-dev/sdk/issues"
52
34
  },
53
35
  "dependencies": {
54
- "@heroicons/react": "^2.2.0",
55
- "@heroui/react": "^2.7.11",
56
- "@viji-dev/core": "^0.2.4",
57
- "autoprefixer": "^10.4.21",
36
+ "@viji-dev/core": "^0.3.31",
58
37
  "chokidar": "^4.0.0",
59
- "clsx": "^2.1.1",
60
38
  "commander": "^12.0.0",
61
- "framer-motion": "^12.18.1",
62
- "react": "^19.1.1",
63
- "react-dom": "^19.1.1",
64
- "tailwind-merge": "^3.3.1",
65
- "tailwindcss": "^3.4.17",
66
- "zustand": "^5.0.6"
39
+ "ws": "^8.18.0"
67
40
  },
68
41
  "devDependencies": {
69
42
  "@eslint/js": "^9.33.0",
43
+ "@heroicons/react": "^2.2.0",
44
+ "@heroui/react": "^2.7.11",
45
+ "@heroui/shared-icons": "^2.1.10",
46
+ "@heroui/theme": "^2.4.17",
70
47
  "@types/node": "^24.3.0",
71
48
  "@types/react": "^19.1.10",
72
49
  "@types/react-dom": "^19.1.7",
50
+ "@types/ws": "^8.5.10",
73
51
  "@vitejs/plugin-react": "^4.5.2",
52
+ "autoprefixer": "^10.4.21",
53
+ "clsx": "^2.1.1",
74
54
  "eslint": "^9.33.0",
75
55
  "eslint-plugin-react-hooks": "^5.2.0",
76
56
  "eslint-plugin-react-refresh": "^0.4.20",
57
+ "framer-motion": "^12.18.1",
77
58
  "globals": "^16.3.0",
59
+ "postcss": "^8.4.49",
60
+ "react": "^19.1.1",
61
+ "react-dom": "^19.1.1",
62
+ "react-markdown": "^10.1.0",
63
+ "react-router-dom": "^7.6.2",
64
+ "remark-gfm": "^4.0.1",
65
+ "tailwind-merge": "^3.3.1",
66
+ "tailwindcss": "^3.4.17",
78
67
  "typescript": "~5.8.3",
79
68
  "typescript-eslint": "^8.39.1",
80
- "vite": "^6.3.5"
69
+ "vite": "^6.3.5",
70
+ "zustand": "^5.0.6",
71
+ "@viji-dev/design-system": "0.1.0",
72
+ "@viji-dev/docs-viewer": "0.1.0"
73
+ },
74
+ "scripts": {
75
+ "dev": "vite",
76
+ "build": "tsc -b && vite build"
81
77
  }
82
- }
78
+ }
@@ -1,147 +1,98 @@
1
- /**
2
- * Build Command - Compile scenes for platform deployment
3
- */
4
-
5
1
  import { mkdir, writeFile } from 'fs/promises';
6
2
  import { dirname, resolve, join } from 'path';
7
- import { fileURLToPath } from 'url';
3
+ import { existsSync } from 'fs';
8
4
  import { SceneCompiler } from '../utils/scene-compiler.js';
9
- import { validateProject, createSpinner, formatFileSize, formatDuration, isVijiWorkspace, findWorkspaceRoot } from '../utils/cli-utils.js';
10
-
11
- const __filename = fileURLToPath(import.meta.url);
12
- const __dirname = dirname(__filename);
5
+ import { validateProject, createSpinner, formatFileSize, formatDuration } from '../utils/cli-utils.js';
13
6
 
14
7
  export async function buildCommand(sceneName, options) {
15
8
  const startTime = Date.now();
16
9
  const spinner = createSpinner('Building Viji scene...');
17
-
10
+
18
11
  try {
19
- // Check if we're in a Viji workspace
20
- const workspaceRoot = findWorkspaceRoot();
21
- if (!workspaceRoot) {
22
- console.error('❌ Not in a Viji workspace.');
23
- console.log('💡 Run "viji init my-workspace" to create a workspace first');
12
+ if (!sceneName) {
13
+ console.error('Please specify a scene name to build');
14
+ console.log('Usage: viji build <scene-name>');
24
15
  process.exit(1);
25
16
  }
26
17
 
27
- console.log('🏠 Workspace:', workspaceRoot);
28
-
29
- // If no scene name provided, show available scenes
30
- if (!sceneName) {
31
- console.error('❌ Please specify a scene name to build');
32
- console.log('💡 Usage: viji build <scene-name>');
33
- // TODO: List available scenes
18
+ const cwd = process.cwd();
19
+ const scenePath = join(cwd, 'scenes', sceneName);
20
+
21
+ if (!existsSync(scenePath)) {
22
+ console.error(`Scene not found: scenes/${sceneName}`);
34
23
  process.exit(1);
35
24
  }
36
-
37
- // Validate scene exists
38
- const scenePath = join(workspaceRoot, 'scenes', sceneName);
25
+
39
26
  const validation = validateProject(scenePath);
40
27
  if (!validation.valid) {
41
- console.error(`❌ Invalid scene "${sceneName}":`);
42
- validation.issues.forEach(issue => console.error(` ${issue}`));
28
+ console.error(`Invalid scene "${sceneName}":`);
29
+ validation.issues.forEach(issue => console.error(` - ${issue}`));
43
30
  process.exit(1);
44
31
  }
45
-
32
+
46
33
  const { projectDir, mainScene } = validation.paths;
47
-
48
- // Parse build options
49
- const outputFile = resolve(projectDir, options.output || 'dist/scene.js');
34
+ const outputFile = options.output
35
+ ? resolve(cwd, options.output)
36
+ : join(cwd, 'dist', `${sceneName}.js`);
50
37
  const outputDir = dirname(outputFile);
51
-
52
- console.log('📦 Building Viji scene for deployment...');
53
- console.log('📁 Project:', projectDir);
54
- console.log('📄 Scene file:', mainScene);
55
- console.log('📤 Output:', outputFile);
38
+
39
+ console.log(`Building scene: ${sceneName}`);
40
+ console.log(`Source: ${mainScene}`);
41
+ console.log(`Output: ${outputFile}`);
56
42
  console.log('');
57
-
58
- // Create output directory
43
+
59
44
  await mkdir(outputDir, { recursive: true });
60
-
61
- // Initialize compiler with options
45
+
62
46
  const compiler = new SceneCompiler({ minify: false });
63
-
47
+
64
48
  spinner.start();
65
49
  spinner.update('Analyzing scene structure...');
66
-
67
- // Compile scene
50
+
68
51
  const buildResult = await compiler.compile(mainScene, outputFile);
69
-
52
+
70
53
  spinner.update('Writing output files...');
71
-
72
- // Write main bundle
54
+
73
55
  await writeFile(outputFile, buildResult.code);
74
-
75
- // No source maps/minify in current simple build
76
-
77
- // Write metadata
56
+
78
57
  const metadataFile = outputFile.replace(/\.js$/i, '.meta.json');
79
58
  await writeFile(metadataFile, JSON.stringify(buildResult.metadata, null, 2));
80
-
59
+
81
60
  const buildTime = Date.now() - startTime;
82
- spinner.stop('Build completed successfully!');
83
-
84
- // Display results
85
- console.log('');
86
- console.log('📊 Build Results:');
87
- console.log(` 📦 Bundle size: ${formatFileSize(buildResult.code.length)}`);
88
- console.log(` ⏱️ Build time: ${formatDuration(buildTime)}`);
89
- console.log(` 🎯 Scene file: ${outputFile}`);
90
- console.log(` 📋 Metadata: ${metadataFile}`);
91
-
92
- if (options.sourceMap && buildResult.sourceMap) {
93
- console.log(` 🗺️ Source map: ${outputFile}.map`);
94
- }
95
-
96
- // Display scene info
97
- const scene = buildResult.metadata.scene;
61
+ spinner.stop('Build completed successfully!');
62
+
98
63
  console.log('');
99
- console.log('🎨 Scene Info:');
100
- console.log(` 🎛️ Parameters: ${scene.parameters.length} groups`);
101
- console.log(` 📤 Exports: ${scene.exports.join(', ')}`);
102
- console.log(` 🔗 Dependencies: ${scene.dependencies}`);
103
- console.log(` 🖼️ Assets: ${scene.assets}`);
104
- console.log(` 🎨 Shaders: ${scene.shaders}`);
105
- console.log(` 🚀 Complexity: ${buildResult.metadata.performance.complexity}`);
106
- console.log(` 💾 Est. Memory: ${buildResult.metadata.performance.estimatedMemory}`);
107
-
108
- if (buildResult.metadata.performance.features.length > 0) {
109
- console.log(` ✨ Features: ${buildResult.metadata.performance.features.join(', ')}`);
110
- }
111
-
112
- // Display warnings
64
+ console.log('Build Results:');
65
+ console.log(` Bundle size: ${formatFileSize(buildResult.code.length)}`);
66
+ console.log(` Build time: ${formatDuration(buildTime)}`);
67
+ console.log(` Scene file: ${outputFile}`);
68
+ console.log(` Metadata: ${metadataFile}`);
69
+
113
70
  if (buildResult.warnings.length > 0) {
114
71
  console.log('');
115
- console.log('⚠️ Warnings:');
72
+ console.log('Warnings:');
116
73
  buildResult.warnings.forEach(warning => {
117
- console.log(` ${warning}`);
74
+ console.log(` - ${warning}`);
118
75
  });
119
76
  }
120
-
121
- // Display validation issues
77
+
78
+ const scene = buildResult.metadata.scene;
122
79
  if (!scene.validation.isValid) {
123
80
  console.log('');
124
- console.log('Validation Issues:');
81
+ console.log('Validation Issues:');
125
82
  scene.validation.issues.forEach(issue => {
126
- console.log(` ${issue}`);
83
+ console.log(` - ${issue}`);
127
84
  });
128
85
  }
129
-
130
- console.log('');
131
- console.log('🚀 Your scene is ready for deployment!');
132
- console.log('📋 Upload the bundle to the Viji platform to share your creation.');
133
-
134
86
  } catch (error) {
135
- spinner.stop('💥 Build failed');
87
+ spinner.stop('Build failed');
136
88
  console.error('');
137
- console.error('💥 Build failed:', error.message);
138
-
139
- if (error.stack && process.env.DEBUG) {
89
+ console.error('Build failed:', error.message);
90
+
91
+ if (process.env.DEBUG) {
140
92
  console.error('');
141
- console.error('Stack trace:');
142
93
  console.error(error.stack);
143
94
  }
144
-
95
+
145
96
  process.exit(1);
146
97
  }
147
- }
98
+ }
@@ -1,71 +1,56 @@
1
- /**
2
- * Create Command - Generate new Viji scene projects (minimal)
3
- */
4
-
5
1
  import { mkdir, writeFile } from 'fs/promises';
6
2
  import { existsSync } from 'fs';
7
- import { join, resolve } from 'path';
8
- import { fileURLToPath } from 'url';
9
- import { dirname } from 'path';
10
- import { isVijiWorkspace, findWorkspaceRoot } from '../utils/cli-utils.js';
11
-
12
- const __filename = fileURLToPath(import.meta.url);
13
- const __dirname = dirname(__filename);
14
-
15
- // Shared minimal template (single source of truth)
16
- import { getMinimalSceneTemplate } from '../../templates/minimal-template.js';
3
+ import { join } from 'path';
4
+ import { getSceneTemplate, getGlobalDts, getSceneFileExtension, VALID_RENDERERS } from '../../templates/scene-templates.js';
5
+ import { validateProjectName } from '../utils/cli-utils.js';
17
6
 
18
7
  export async function createCommand(sceneName, options) {
19
8
  try {
20
- console.log('🎨 Creating new Viji scene...');
21
- console.log(`📁 Scene: ${sceneName}`);
22
- console.log(`🎯 Language: ${options.lang || 'js'}`);
9
+ const renderer = options.renderer || 'native';
23
10
 
24
- // Check if we're in a Viji workspace
25
- const workspaceRoot = findWorkspaceRoot();
26
- if (!workspaceRoot) {
27
- console.error('❌ Not in a Viji workspace.');
28
- console.log('💡 Run "viji init my-workspace" to create a workspace first');
11
+ if (!VALID_RENDERERS.includes(renderer)) {
12
+ console.error(`Unknown renderer: "${renderer}". Valid options: ${VALID_RENDERERS.join(', ')}`);
29
13
  process.exit(1);
30
14
  }
31
15
 
32
- console.log('🏠 Workspace:', workspaceRoot);
16
+ const nameValidation = validateProjectName(sceneName);
17
+ if (!nameValidation.valid) {
18
+ console.error(`Invalid scene name: ${nameValidation.issues.join(', ')}`);
19
+ process.exit(1);
20
+ }
33
21
 
34
- // Create scene inside workspace scenes/ directory
35
- const scenesDir = join(workspaceRoot, 'scenes');
22
+ const cwd = process.cwd();
23
+ const scenesDir = join(cwd, 'scenes');
36
24
  const scenePath = join(scenesDir, sceneName);
37
25
 
38
- // Ensure scene doesn't already exist
39
26
  if (existsSync(scenePath)) {
40
- console.error(`❌ Scene already exists: ${scenePath}`);
27
+ console.error(`Scene already exists: ${scenePath}`);
41
28
  process.exit(1);
42
29
  }
43
30
 
44
- // Create scene folder
45
31
  await mkdir(scenePath, { recursive: true });
46
- console.log(`✅ Created scene directory: ${scenePath}`);
47
32
 
48
- // Write minimal scene
49
- const lang = options.lang === 'ts' ? 'ts' : 'js';
50
- const mainName = lang === 'ts' ? 'main.ts' : 'main.js';
51
- const mainPath = join(scenePath, mainName);
52
-
53
- const contents = getMinimalSceneTemplate(lang)
54
- .replace('New TypeScript Scene', `${sceneName} - minimal scene`)
55
- .replace('New JavaScript Scene', `${sceneName} - minimal scene`);
56
-
57
- await writeFile(mainPath, contents);
58
- console.log(`📝 Created scene file: ${join(scenePath, mainName)}`);
33
+ const ext = getSceneFileExtension(renderer);
34
+ const mainFile = `main${ext}`;
35
+ const mainPath = join(scenePath, mainFile);
36
+ await writeFile(mainPath, getSceneTemplate(renderer));
37
+ console.log(`Created scene: scenes/${sceneName}/${mainFile} [${renderer} renderer]`);
38
+
39
+ const globalDtsPath = join(cwd, 'global.d.ts');
40
+ if (!existsSync(globalDtsPath)) {
41
+ const dtsContent = getGlobalDts(renderer);
42
+ if (dtsContent) {
43
+ await writeFile(globalDtsPath, dtsContent);
44
+ console.log('Created global.d.ts for IDE type support');
45
+ }
46
+ }
59
47
 
60
- console.log('🎉 Scene created successfully!');
61
- console.log('');
62
- console.log('📚 Next steps:');
63
- console.log(' viji dev # Start development server');
64
- console.log(` # Edit scenes/${sceneName}/${mainName} in your IDE`);
65
48
  console.log('');
66
- console.log('🚀 Happy coding!');
49
+ console.log('Next steps:');
50
+ console.log(' viji dev Start the development server');
51
+ console.log(` Edit scenes/${sceneName}/${mainFile} in your IDE`);
67
52
  } catch (error) {
68
- console.error('💥 Failed to create scene:', error.message);
53
+ console.error('Failed to create scene:', error.message);
69
54
  process.exit(1);
70
55
  }
71
56
  }
@@ -1,108 +1,41 @@
1
- /**
2
- * Dev Command - Start development server with hot reload
3
- */
4
-
5
- import { spawn } from 'child_process';
6
- import { join, resolve } from 'path';
7
- import { fileURLToPath } from 'url';
8
- import { dirname } from 'path';
1
+ import { join } from 'path';
9
2
  import { existsSync } from 'fs';
10
- import { createRequire } from 'module';
11
- import { isVijiWorkspace, findWorkspaceRoot } from '../utils/cli-utils.js';
12
-
13
- const __filename = fileURLToPath(import.meta.url);
14
- const __dirname = dirname(__filename);
3
+ import { startDevServer } from '../server/dev-server.js';
15
4
 
16
5
  export async function devCommand(options) {
17
6
  try {
18
- console.log('🔥 Starting Viji development server...');
19
-
20
- // Check if we're in a Viji workspace
21
- const workspaceRoot = findWorkspaceRoot();
22
- if (!workspaceRoot) {
23
- console.error('❌ Not in a Viji workspace.');
24
- console.log('💡 Run "viji init my-workspace" to create a workspace first');
25
- process.exit(1);
7
+ const port = parseInt(options.port, 10) || 3000;
8
+ const host = options.host || 'localhost';
9
+ const open = options.open || false;
10
+ const cwd = process.cwd();
11
+ const scenesDir = join(cwd, 'scenes');
12
+
13
+ if (!existsSync(scenesDir)) {
14
+ console.log('No scenes/ directory found. Creating it now.');
15
+ const { mkdir } = await import('fs/promises');
16
+ await mkdir(scenesDir, { recursive: true });
17
+ console.log('Tip: run "viji create my-scene" to create your first scene');
18
+ console.log('');
26
19
  }
27
-
28
- console.log('🏠 Workspace:', workspaceRoot);
29
- await startDevServer(workspaceRoot, options);
30
- } catch (error) {
31
- console.error('💥 Failed to start development server:', error.message);
32
- process.exit(1);
33
- }
34
- }
35
20
 
36
- async function startDevServer(workspaceRoot, options) {
37
- const { port, host, open } = options;
38
-
39
- console.log(`🌐 Development server will start on: http://${host}:${port}`);
21
+ const { server, watcher } = await startDevServer({
22
+ port,
23
+ host,
24
+ open,
25
+ scenesDir,
26
+ });
40
27
 
41
- // Build Vite args and run in workspace directory
42
- const viteArgs = ['run', 'dev', '--', '--port', String(port), '--host', host];
43
- if (open) viteArgs.push('--open');
28
+ const shutdown = () => {
29
+ console.log('\nStopping dev server...');
30
+ watcher.close();
31
+ server.close();
32
+ process.exit(0);
33
+ };
44
34
 
45
- const viteProcess = spawn('npm', viteArgs, {
46
- cwd: workspaceRoot,
47
- stdio: 'inherit',
48
- env: {
49
- ...process.env
50
- }
51
- });
52
-
53
- // Handle process termination
54
- process.on('SIGINT', () => {
55
- console.log('\n🛑 Stopping development server...');
56
- viteProcess.kill('SIGINT');
57
- process.exit(0);
58
- });
59
-
60
- process.on('SIGTERM', () => {
61
- viteProcess.kill('SIGTERM');
62
- process.exit(0);
63
- });
64
-
65
- viteProcess.on('exit', (code) => {
66
- if (code !== 0) {
67
- console.error(`❌ Development server exited with code ${code}`);
68
- process.exit(code);
69
- }
70
- });
71
-
72
- console.log('✅ Development server started!');
73
- }
74
-
75
- function findSDKDirectory() {
76
- // Try to find SDK directory from current working directory upwards
77
- let currentPath = process.cwd();
78
-
79
- while (currentPath !== '/') {
80
- const potentialSDK = join(currentPath, 'node_modules', 'viji-sdk');
81
- if (existsSync(potentialSDK)) {
82
- return potentialSDK;
83
- }
84
-
85
- const parentPath = dirname(currentPath);
86
- if (parentPath === currentPath) break;
87
- currentPath = parentPath;
88
- }
89
-
90
- // Try global installation
91
- try {
92
- const require = createRequire(import.meta.url);
93
- const globalSDK = require.resolve('viji-sdk');
94
- if (globalSDK) {
95
- return dirname(dirname(globalSDK)); // Go up from lib/index.js to root
96
- }
35
+ process.on('SIGINT', shutdown);
36
+ process.on('SIGTERM', shutdown);
97
37
  } catch (error) {
98
- // Not found globally
99
- }
100
-
101
- // Try relative to this CLI file
102
- const relativeSDK = resolve(__dirname, '..', '..', '..');
103
- if (existsSync(join(relativeSDK, 'package.json'))) {
104
- return relativeSDK;
38
+ console.error('Failed to start development server:', error.message);
39
+ process.exit(1);
105
40
  }
106
-
107
- return null;
108
41
  }