@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
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Viji SDK
|
|
2
2
|
|
|
3
|
-
Professional toolkit for creating interactive Viji scenes.
|
|
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
|
|
15
|
-
mkdir my-
|
|
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
|
|
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
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
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
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
51
|
+
| Option | Default | Description |
|
|
52
|
+
|--------|---------|-------------|
|
|
53
|
+
| `--port` | `3000` | Server port |
|
|
54
|
+
| `--host` | `localhost` | Server host |
|
|
55
|
+
| `--open` | `false` | Open browser automatically |
|
|
37
56
|
|
|
38
|
-
|
|
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> [
|
|
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
|
-
|
|
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
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
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
|
-
|
|
97
|
+
Available contexts: `viji.useContext('2d')`, `viji.useContext('webgl')`, `viji.useContext('webgl2')`.
|
|
98
|
+
|
|
99
|
+
### P5 Renderer
|
|
63
100
|
|
|
64
|
-
|
|
101
|
+
```javascript
|
|
102
|
+
// @renderer p5
|
|
65
103
|
|
|
66
|
-
|
|
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
|
-
|
|
73
|
-
|
|
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
|
-
|
|
77
|
-
|
|
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
|
-
|
|
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
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
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
|
-
##
|
|
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
|
-
|
|
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
|
-
##
|
|
190
|
+
## License
|
|
96
191
|
|
|
97
|
-
Copyright (c) 2025 Artem Verkhovskiy and Dmitry Manoilenko.
|
|
98
|
-
All rights reserved
|
|
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('
|
|
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('--
|
|
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', '
|
|
49
|
-
.option('
|
|
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
|
|
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'
|
|
59
|
-
.description('Build scene: bundle multi-file projects into one
|
|
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('
|
|
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('
|
|
51
|
+
console.error('Unhandled promise rejection:', reason);
|
|
71
52
|
process.exit(1);
|
|
72
53
|
});
|
|
73
54
|
|
|
74
|
-
// Parse and execute
|
|
75
55
|
program.parse();
|