@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.
- package/README.md +155 -60
- package/bin/viji.js +9 -29
- package/dist/assets/artist-dts-BHUsvSI6.js +613 -0
- package/dist/assets/artist-dts-p5-Cyw8vmy_.js +736 -0
- package/dist/assets/core-CiQx3w0t.js +12 -0
- package/dist/assets/dark-plus-C3mMm8J8.js +1 -0
- package/dist/assets/docs-api-PBLtY4Ni.js +12381 -0
- package/dist/assets/engine-javascript-CXyY7cc8.js +141 -0
- package/dist/assets/essentia-wasm.web-0S-sW98u-CYV1l1zv.js +38 -0
- package/dist/assets/essentia.js-core.es-DnrJE0uR-DOSrF5_G.js +32 -0
- package/dist/assets/glsl-DMyvO4G4.js +1 -0
- package/dist/assets/index-BhFxsauQ.js +215 -0
- package/dist/assets/index-BqhVeA7U.css +1 -0
- package/dist/assets/index-T4TOjvD0.js +1 -0
- package/dist/assets/index-Wz9WqGqz.js +52 -0
- package/dist/assets/index-t24aGwla.js +1 -0
- package/dist/assets/javascript-wDzz0qaB.js +1 -0
- package/dist/assets/shader-uniforms-GdaUkQPK.js +1 -0
- package/dist/assets/typescript-BPQ3VLAy.js +1 -0
- package/dist/assets/viji.worker-CQSJ0SiO-ljtBlcNZ.js +27018 -0
- package/{index.html → dist/index.html} +2 -1
- package/package.json +31 -35
- package/src/cli/commands/build.js +50 -99
- package/src/cli/commands/create.js +32 -47
- package/src/cli/commands/dev.js +30 -97
- package/src/cli/server/dev-server.js +233 -0
- package/src/cli/server/scene-scanner.js +93 -0
- package/src/cli/server/vite-scene-plugin.d.ts +2 -0
- package/src/cli/server/vite-scene-plugin.js +134 -0
- package/src/cli/utils/cli-utils.js +29 -139
- package/src/cli/utils/scene-compiler.js +10 -17
- package/src/templates/scene-templates.js +85 -0
- package/.gitignore +0 -29
- package/eslint.config.js +0 -37
- package/postcss.config.js +0 -6
- package/scenes/audio-visualizer/main.js +0 -287
- package/scenes/core-demo/main.js +0 -532
- package/scenes/demo-scene/main.js +0 -619
- package/scenes/global.d.ts +0 -15
- package/scenes/particle-system/main.js +0 -349
- package/scenes/tsconfig.json +0 -12
- package/scenes/video-mirror/main.ts +0 -436
- package/src/App.css +0 -42
- package/src/App.tsx +0 -279
- package/src/cli/commands/init.js +0 -262
- package/src/components/SDKPage.tsx +0 -337
- package/src/components/core/CoreContainer.tsx +0 -126
- package/src/components/ui/DeviceSelectionList.tsx +0 -137
- package/src/components/ui/FPSCounter.tsx +0 -78
- package/src/components/ui/FileDropzonePanel.tsx +0 -120
- package/src/components/ui/FileListPanel.tsx +0 -285
- package/src/components/ui/InputExpansionPanel.tsx +0 -31
- package/src/components/ui/MediaPlayerControls.tsx +0 -191
- package/src/components/ui/MenuContainer.tsx +0 -71
- package/src/components/ui/ParametersMenu.tsx +0 -797
- package/src/components/ui/ProjectSwitcherMenu.tsx +0 -192
- package/src/components/ui/QuickInputControls.tsx +0 -542
- package/src/components/ui/SDKMenuSystem.tsx +0 -96
- package/src/components/ui/SettingsMenu.tsx +0 -346
- package/src/components/ui/SimpleInputControls.tsx +0 -137
- package/src/index.css +0 -68
- package/src/main.tsx +0 -10
- package/src/scenes-hmr.ts +0 -158
- package/src/services/project-filesystem.ts +0 -436
- package/src/stores/scene-player/index.ts +0 -3
- package/src/stores/scene-player/input-manager.store.ts +0 -1045
- package/src/stores/scene-player/scene-session.store.ts +0 -659
- package/src/styles/globals.css +0 -111
- package/src/templates/minimal-template.js +0 -11
- package/src/utils/debounce.js +0 -34
- package/src/vite-env.d.ts +0 -1
- package/tailwind.config.js +0 -18
- package/tsconfig.app.json +0 -27
- package/tsconfig.json +0 -27
- package/tsconfig.node.json +0 -27
- package/vite.config.ts +0 -54
- /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
|
-
"
|
|
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
|
-
"
|
|
34
|
-
"
|
|
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
|
-
"@
|
|
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
|
-
"
|
|
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 {
|
|
3
|
+
import { existsSync } from 'fs';
|
|
8
4
|
import { SceneCompiler } from '../utils/scene-compiler.js';
|
|
9
|
-
import { validateProject, createSpinner, formatFileSize, formatDuration
|
|
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
|
-
|
|
20
|
-
|
|
21
|
-
|
|
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
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
if (!
|
|
31
|
-
console.error(
|
|
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(
|
|
42
|
-
validation.issues.forEach(issue => console.error(`
|
|
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
|
-
|
|
49
|
-
|
|
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(
|
|
53
|
-
console.log(
|
|
54
|
-
console.log(
|
|
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('
|
|
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('
|
|
100
|
-
console.log(`
|
|
101
|
-
console.log(`
|
|
102
|
-
console.log(`
|
|
103
|
-
console.log(`
|
|
104
|
-
|
|
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('
|
|
72
|
+
console.log('Warnings:');
|
|
116
73
|
buildResult.warnings.forEach(warning => {
|
|
117
|
-
console.log(`
|
|
74
|
+
console.log(` - ${warning}`);
|
|
118
75
|
});
|
|
119
76
|
}
|
|
120
|
-
|
|
121
|
-
|
|
77
|
+
|
|
78
|
+
const scene = buildResult.metadata.scene;
|
|
122
79
|
if (!scene.validation.isValid) {
|
|
123
80
|
console.log('');
|
|
124
|
-
console.log('
|
|
81
|
+
console.log('Validation Issues:');
|
|
125
82
|
scene.validation.issues.forEach(issue => {
|
|
126
|
-
console.log(`
|
|
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('
|
|
87
|
+
spinner.stop('Build failed');
|
|
136
88
|
console.error('');
|
|
137
|
-
console.error('
|
|
138
|
-
|
|
139
|
-
if (
|
|
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
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
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
|
-
|
|
21
|
-
console.log(`📁 Scene: ${sceneName}`);
|
|
22
|
-
console.log(`🎯 Language: ${options.lang || 'js'}`);
|
|
9
|
+
const renderer = options.renderer || 'native';
|
|
23
10
|
|
|
24
|
-
|
|
25
|
-
|
|
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
|
-
|
|
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
|
-
|
|
35
|
-
const scenesDir = join(
|
|
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(
|
|
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
|
-
|
|
49
|
-
const
|
|
50
|
-
const
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
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('
|
|
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('
|
|
53
|
+
console.error('Failed to create scene:', error.message);
|
|
69
54
|
process.exit(1);
|
|
70
55
|
}
|
|
71
56
|
}
|
package/src/cli/commands/dev.js
CHANGED
|
@@ -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 {
|
|
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
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
const
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
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
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
21
|
+
const { server, watcher } = await startDevServer({
|
|
22
|
+
port,
|
|
23
|
+
host,
|
|
24
|
+
open,
|
|
25
|
+
scenesDir,
|
|
26
|
+
});
|
|
40
27
|
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
28
|
+
const shutdown = () => {
|
|
29
|
+
console.log('\nStopping dev server...');
|
|
30
|
+
watcher.close();
|
|
31
|
+
server.close();
|
|
32
|
+
process.exit(0);
|
|
33
|
+
};
|
|
44
34
|
|
|
45
|
-
|
|
46
|
-
|
|
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
|
-
|
|
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
|
}
|