@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
package/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # Viji SDK
2
2
 
3
- Professional toolkit for creating interactive Viji scenes. Includes a CLI, workspace management, local development UI (Vite-based), and a production build pipeline that outputs a single deployable `scene.js`. Uses `@viji-dev/core` under the hood.
3
+ Professional toolkit for creating interactive Viji scenes. Install globally, create scenes with a single command, and launch a local development server with live reload. Uses `@viji-dev/core` under the hood.
4
4
 
5
5
  ## Installation
6
6
 
@@ -8,96 +8,191 @@ Professional toolkit for creating interactive Viji scenes. Includes a CLI, works
8
8
  npm install -g @viji-dev/sdk
9
9
  ```
10
10
 
11
+ No other prerequisites required — just your IDE.
12
+
11
13
  ## Quick Start
12
14
 
13
15
  ```bash
14
- # Create a new workspace
15
- mkdir my-viji-workspace
16
- cd my-viji-workspace
17
- viji init .
16
+ # Create a project directory and enter it
17
+ mkdir my-project && cd my-project
18
18
 
19
- # Create your first scene
20
- viji create my-scene --lang=ts
19
+ # Create your first scene (native renderer is the default)
20
+ viji create my-scene
21
21
 
22
- # Start development server
22
+ # Start the development server
23
23
  viji dev
24
24
  ```
25
25
 
26
+ Open `http://localhost:3000` in your browser to see the SDK UI. Edit `scenes/my-scene/main.js` in your IDE — changes appear in real time.
27
+
26
28
  ## CLI Commands
27
29
 
28
- ### `viji init [workspace-name]`
29
- Initialize a new Viji workspace with complete development environment.
30
- - Use `viji init .` to initialize in current directory
31
- - Use `viji init my-workspace` to create new directory
30
+ ### `viji create <scene-name> [--renderer <type>]`
31
+
32
+ Create a new scene in the `scenes/` folder.
33
+
34
+ - `viji create my-scene` — native renderer (Canvas 2D / WebGL), the default
35
+ - `viji create my-scene --renderer p5` — P5.js renderer
36
+ - `viji create my-scene --renderer shader` — GLSL fragment shader
37
+
38
+ Creates the following structure:
39
+
40
+ ```
41
+ scenes/
42
+ └── my-scene/
43
+ └── main.js # or main.glsl for shader scenes
44
+ global.d.ts # generated once for IDE type support
45
+ ```
46
+
47
+ ### `viji dev [--port <port>] [--host <host>] [--open]`
48
+
49
+ Start the development server with live reload.
32
50
 
33
- ### `viji create <scene-name> [--lang=js|ts]`
34
- Create a new scene in the current workspace.
35
- - Must be run inside a Viji workspace
36
- - Creates scene in `scenes/<scene-name>/` folder
51
+ | Option | Default | Description |
52
+ |--------|---------|-------------|
53
+ | `--port` | `3000` | Server port |
54
+ | `--host` | `localhost` | Server host |
55
+ | `--open` | `false` | Open browser automatically |
37
56
 
38
- ### `viji dev [--port=5173] [--host=localhost] [--open]`
39
- Start development server with hot reload.
40
- - Must be run inside a Viji workspace
41
- - Opens browser-based development UI
57
+ The server watches the `scenes/` directory for changes and pushes updates to the browser UI in real time via WebSocket.
42
58
 
43
- ### `viji build <scene-name> [--output=dist/scene.js]`
44
- Build a scene for platform deployment.
45
- - Compiles multi-file project to single JS file
46
- - Ready for copy-paste to Viji platform
59
+ ### `viji build <scene-name> [-o <file>]`
47
60
 
48
- ## Workspace Structure
61
+ Bundle a scene into a single file for deployment.
49
62
 
63
+ ```bash
64
+ viji build my-scene # outputs dist/my-scene.js
65
+ viji build my-scene -o bundle/output.js # custom output path
50
66
  ```
51
- my-workspace/
52
- ├── src/ # Development UI (React + Vite)
53
- ├── scenes/ # Your scenes
54
- │ ├── my-scene/
55
- │ │ └── main.ts # Scene entry point
56
- │ └── another-scene/
57
- ├── vite.config.ts # Vite configuration
58
- ├── package.json # Dependencies
59
- └── ... # TypeScript configs, etc.
67
+
68
+ Multi-file scenes (with local imports) are resolved and concatenated automatically.
69
+
70
+ ## Scene API
71
+
72
+ ### Native Renderer
73
+
74
+ ```javascript
75
+ // @renderer native
76
+
77
+ const speed = viji.slider(1.0, { min: 0.1, max: 5.0, label: 'Speed' });
78
+ const baseColor = viji.color('#4488ff', { label: 'Color' });
79
+
80
+ function render(viji) {
81
+ const ctx = viji.useContext('2d');
82
+ const { width, height, time } = viji;
83
+
84
+ ctx.fillStyle = '#000000';
85
+ ctx.fillRect(0, 0, width, height);
86
+
87
+ const x = width / 2 + Math.cos(time * speed.value) * 100;
88
+ const y = height / 2 + Math.sin(time * speed.value) * 100;
89
+
90
+ ctx.beginPath();
91
+ ctx.arc(x, y, 40, 0, Math.PI * 2);
92
+ ctx.fillStyle = baseColor.value;
93
+ ctx.fill();
94
+ }
60
95
  ```
61
96
 
62
- ## Scene Development
97
+ Available contexts: `viji.useContext('2d')`, `viji.useContext('webgl')`, `viji.useContext('webgl2')`.
98
+
99
+ ### P5 Renderer
63
100
 
64
- Each scene is a folder in `scenes/` with a `main.js` or `main.ts` entry point:
101
+ ```javascript
102
+ // @renderer p5
65
103
 
66
- ```typescript
67
- // scenes/my-scene/main.ts
68
- export const parameters = [
69
- // Parameter definitions
70
- ];
104
+ const speed = viji.slider(1.0, { min: 0.1, max: 5.0, label: 'Speed' });
71
105
 
72
- export function init(canvas: HTMLCanvasElement, audioContext: AudioContext) {
73
- // Initialization code
106
+ function render(viji, p5) {
107
+ p5.background(0);
108
+ const x = viji.width / 2 + p5.cos(viji.time * speed.value) * 100;
109
+ const y = viji.height / 2 + p5.sin(viji.time * speed.value) * 100;
110
+ p5.noStroke();
111
+ p5.fill(255);
112
+ p5.ellipse(x, y, 80, 80);
74
113
  }
114
+ ```
115
+
116
+ ### GLSL Shader
75
117
 
76
- export function render(state: any, inputs: any, params: any) {
77
- // Main render loop
118
+ ```glsl
119
+ // @renderer shader
120
+ precision highp float;
121
+
122
+ uniform vec2 u_resolution;
123
+ uniform float u_time;
124
+ uniform vec2 u_mouse;
125
+
126
+ void main() {
127
+ vec2 uv = gl_FragCoord.xy / u_resolution;
128
+ vec3 col = 0.5 + 0.5 * cos(u_time + uv.xyx + vec3(0.0, 2.0, 4.0));
129
+ gl_FragColor = vec4(col, 1.0);
78
130
  }
79
131
  ```
80
132
 
81
- ## Features
133
+ Shader scenes receive a full set of uniforms automatically: `u_resolution`, `u_time`, `u_deltaTime`, `u_mouse`, `u_audio*`, `u_video*`, and more. See the core documentation for the complete uniform list.
134
+
135
+ ## Parameter System
136
+
137
+ Parameters create UI controls that artists can tweak in real time:
138
+
139
+ ```javascript
140
+ const speed = viji.slider(1.0, { min: 0, max: 10, label: 'Speed' });
141
+ const tint = viji.color('#ff0000', { label: 'Tint' });
142
+ const mirror = viji.toggle(false, { label: 'Mirror' });
143
+ const mode = viji.select('circles', { options: ['circles', 'squares', 'lines'], label: 'Mode' });
144
+ const label = viji.text('Hello', { label: 'Label' });
145
+ const count = viji.number(5, { min: 1, max: 100, step: 1, label: 'Count' });
146
+ const bg = viji.image(null, { label: 'Background' });
147
+ const reset = viji.button({ label: 'Reset' });
148
+ ```
149
+
150
+ Access values via `speed.value`, `tint.value`, etc. Button parameters expose `reset.pressed`.
151
+
152
+ ## Viji API
153
+
154
+ The `viji` object passed to `render()` provides:
82
155
 
83
- - **🎨 Complete Development Environment**: Full React UI for scene development
84
- - **🔥 Hot Reload**: Instant updates when you save scene files
85
- - **📁 Workspace Management**: Organize multiple scenes in one project
86
- - **🛠️ TypeScript Support**: Full type safety and IDE integration
87
- - **📦 Single-File Build**: Compile to platform-ready scene.js
88
- - **🎯 Platform Compatible**: Uses same Core runtime as Viji platform
156
+ | Property | Type | Description |
157
+ |----------|------|-------------|
158
+ | `canvas` | `OffscreenCanvas` | The rendering canvas |
159
+ | `width`, `height` | `number` | Canvas dimensions |
160
+ | `time` | `number` | Elapsed time in seconds |
161
+ | `deltaTime` | `number` | Time since last frame |
162
+ | `frameCount` | `number` | Total frames rendered |
163
+ | `fps` | `number` | Current frames per second |
164
+ | `audio` | `AudioAPI` | Audio analysis (volume, bands, beat, spectral) |
165
+ | `video` | `VideoAPI` | Video input |
166
+ | `mouse` | `MouseAPI` | Mouse position and buttons |
167
+ | `keyboard` | `KeyboardAPI` | Key states (`isPressed`, `wasPressed`, `wasReleased`) |
168
+ | `touches` | `TouchAPI` | Touch points |
169
+ | `pointer` | `PointerAPI` | Unified pointer input |
170
+ | `device` | `DeviceSensorState` | Accelerometer, gyroscope |
89
171
 
90
- ## Documentation
172
+ ## Project Structure
173
+
174
+ After creating a few scenes, your project looks like this:
175
+
176
+ ```
177
+ my-project/
178
+ ├── scenes/
179
+ │ ├── my-scene/
180
+ │ │ └── main.js
181
+ │ ├── shader-demo/
182
+ │ │ └── main.glsl
183
+ │ └── p5-sketch/
184
+ │ └── main.js
185
+ └── global.d.ts # IDE type support (auto-generated)
186
+ ```
91
187
 
92
- - SDK package: `docs/02-sdk-package.md`
93
- - Implementation guide: `docs/06-cursor-implementation-guide.md`
188
+ No configuration files, no `node_modules`, no build tools in the artist's directory. Everything is handled by the globally installed SDK.
94
189
 
95
- ## 📄 License
190
+ ## License
96
191
 
97
- Copyright (c) 2025 Artem Verkhovskiy and Dmitry Manoilenko.
98
- All rights reserved - see the LICENSE file for details.
192
+ Copyright (c) 2025 Artem Verkhovskiy and Dmitry Manoilenko.
193
+ All rights reserved see the LICENSE file for details.
99
194
 
100
195
  ## Contributor License Agreement
101
196
 
102
- By contributing, you agree to the [CLA](./CLA.md).
103
- Please also confirm your agreement by filling out this short [form](https://forms.gle/A49WTz8nj5b99Yev7).
197
+ By contributing, you agree to the [CLA](./CLA.md).
198
+ Please also confirm your agreement by filling out this short [form](https://forms.gle/A49WTz8nj5b99Yev7).
package/bin/viji.js CHANGED
@@ -1,22 +1,15 @@
1
1
  #!/usr/bin/env node
2
2
 
3
- /**
4
- * Viji SDK Command Line Interface
5
- * Professional toolkit for creating interactive Viji scenes
6
- */
7
-
8
3
  import { createRequire } from 'module';
9
4
  const require = createRequire(import.meta.url);
10
5
  const { program } = require('commander');
11
6
  import { createCommand } from '../src/cli/commands/create.js';
12
7
  import { devCommand } from '../src/cli/commands/dev.js';
13
8
  import { buildCommand } from '../src/cli/commands/build.js';
14
- import { initCommand } from '../src/cli/commands/init.js';
15
9
  import { fileURLToPath } from 'url';
16
10
  import { dirname, join } from 'path';
17
11
  import { readFileSync } from 'fs';
18
12
 
19
- // Get package.json version
20
13
  const __filename = fileURLToPath(import.meta.url);
21
14
  const __dirname = dirname(__filename);
22
15
  const packagePath = join(__dirname, '..', 'package.json');
@@ -24,52 +17,39 @@ const packageJson = JSON.parse(readFileSync(packagePath, 'utf8'));
24
17
 
25
18
  program
26
19
  .name('viji')
27
- .description('🎨 Viji SDK - Professional toolkit for creating interactive scenes')
20
+ .description('Viji SDK - Professional toolkit for creating interactive scenes')
28
21
  .version(packageJson.version);
29
22
 
30
- // Command: Initialize new workspace
31
- program
32
- .command('init')
33
- .argument('[workspace-name]', 'Name of the workspace (use "." for current directory)', '.')
34
- .description('Initialize a new Viji workspace')
35
- .action(initCommand);
36
-
37
- // Command: Create new scene
38
23
  program
39
24
  .command('create')
40
25
  .argument('<scene-name>', 'Name of the new scene')
41
- .option('--lang <lang>', 'Scene language (js|ts)', 'js')
26
+ .option('--renderer <type>', 'Renderer type (native|p5|shader)', 'native')
42
27
  .description('Create a new scene in the current workspace')
43
28
  .action(createCommand);
44
29
 
45
- // Command: Start development server
46
30
  program
47
31
  .command('dev')
48
- .option('-p, --port <port>', 'Development server port', '5173')
49
- .option('-h, --host <host>', 'Development server host', 'localhost')
32
+ .option('-p, --port <port>', 'Development server port', '3000')
33
+ .option('--host <host>', 'Development server host', 'localhost')
50
34
  .option('--open', 'Open browser automatically', false)
51
- .description('Start development server with hot reload')
35
+ .description('Start development server with live reload')
52
36
  .action(devCommand);
53
37
 
54
- // Command: Build for production
55
38
  program
56
39
  .command('build')
57
40
  .argument('<scene-name>', 'Name of the scene to build')
58
- .option('-o, --output <file>', 'Output file path', 'dist/scene.js')
59
- .description('Build scene: bundle multi-file projects into one, no minify')
41
+ .option('-o, --output <file>', 'Output file path')
42
+ .description('Build scene: bundle multi-file projects into one')
60
43
  .action(buildCommand);
61
44
 
62
-
63
- // Global error handling
64
45
  process.on('uncaughtException', (error) => {
65
- console.error('💥 Unexpected error:', error.message);
46
+ console.error('Unexpected error:', error.message);
66
47
  process.exit(1);
67
48
  });
68
49
 
69
50
  process.on('unhandledRejection', (reason) => {
70
- console.error('💥 Unhandled promise rejection:', reason);
51
+ console.error('Unhandled promise rejection:', reason);
71
52
  process.exit(1);
72
53
  });
73
54
 
74
- // Parse and execute
75
55
  program.parse();