@viji-dev/sdk 1.0.3 → 1.0.4

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  # Viji SDK
2
2
 
3
- Development environment for [Viji Creative](https://viji.art) scenes. Write scene code in your IDE, preview it live in the browser with real-time parameter controls, audio analysis, video input, and interaction handling — the same execution environment as the Viji platform. Supports Canvas 2D, WebGL, P5.js, and GLSL shaders.
3
+ Development environment for [Viji](https://www.viji.io) scenes. Write scene code in your IDE, preview it live in the browser with real-time parameter controls, audio analysis, video input, and interaction handling — the same execution environment as the Viji platform. Supports Canvas 2D, WebGL, P5.js, and GLSL shaders.
4
4
 
5
5
  ## Installation
6
6
 
@@ -41,14 +41,7 @@ Create a new scene in the `scenes/` folder.
41
41
  - `viji create my-scene --renderer p5` — P5.js renderer
42
42
  - `viji create my-scene --renderer shader` — GLSL fragment shader
43
43
 
44
- Creates the following structure:
45
-
46
- ```
47
- scenes/
48
- └── my-scene/
49
- └── main.js # or main.glsl for shader scenes
50
- global.d.ts # generated once for IDE type support
51
- ```
44
+ On the first run, the SDK installs type definitions locally for IDE autocompletion. This creates `node_modules/`, `package.json`, and `global.d.ts` in your workspace — all auto-generated, no manual setup needed.
52
45
 
53
46
  ### `viji dev [--port <port>] [--host <host>] [--open]`
54
47
 
@@ -94,11 +87,11 @@ my-viji-scenes/
94
87
  │ │ └── main.glsl
95
88
  │ └── p5-sketch/
96
89
  │ └── main.js
97
- └── global.d.ts # IDE type support (auto-generated)
90
+ ├── global.d.ts # IDE type support (auto-generated)
91
+ ├── node_modules/ # type definitions (auto-generated)
92
+ └── package.json # auto-generated
98
93
  ```
99
94
 
100
- No configuration files, no `node_modules`, no build tools in your workspace. Everything is handled by the globally installed SDK.
101
-
102
95
  ## License
103
96
 
104
97
  Copyright (c) 2025 Artem Verkhovskiy and Dmitry Manoilenko.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@viji-dev/sdk",
3
- "version": "1.0.3",
3
+ "version": "1.0.4",
4
4
  "type": "module",
5
5
  "description": "Professional toolkit for creating interactive Viji scenes",
6
6
  "keywords": [
@@ -1,17 +1,20 @@
1
- import { mkdir, writeFile, readFile } from 'fs/promises';
1
+ import { mkdir, writeFile } from 'fs/promises';
2
2
  import { existsSync } from 'fs';
3
- import { join, dirname } from 'path';
4
- import { createRequire } from 'module';
5
- import { getSceneTemplate, getGlobalDtsFileName, getSceneFileExtension, VALID_RENDERERS } from '../../templates/scene-templates.js';
3
+ import { join } from 'path';
4
+ import { execSync } from 'child_process';
5
+ import { getSceneTemplate, getGlobalDtsContent, getSceneFileExtension, VALID_RENDERERS } from '../../templates/scene-templates.js';
6
6
  import { validateProjectName } from '../utils/cli-utils.js';
7
7
 
8
- function resolveCoreDtsPath(fileName) {
8
+ function ensureCoreTypes(cwd) {
9
+ const coreDtsPath = join(cwd, 'node_modules', '@viji-dev', 'core', 'dist', 'artist-global.d.ts');
10
+ if (existsSync(coreDtsPath)) return true;
11
+
9
12
  try {
10
- const require = createRequire(import.meta.url);
11
- const coreEntry = require.resolve('@viji-dev/core');
12
- return join(dirname(coreEntry), fileName);
13
+ console.log('Installing type definitions...');
14
+ execSync('npm install --save-dev @viji-dev/core', { cwd, stdio: 'pipe' });
15
+ return existsSync(coreDtsPath);
13
16
  } catch {
14
- return null;
17
+ return false;
15
18
  }
16
19
  }
17
20
 
@@ -49,17 +52,10 @@ export async function createCommand(sceneName, options) {
49
52
 
50
53
  const globalDtsPath = join(cwd, 'global.d.ts');
51
54
  if (!existsSync(globalDtsPath)) {
52
- const dtsFileName = getGlobalDtsFileName(renderer);
53
- if (dtsFileName) {
54
- const dtsSourcePath = resolveCoreDtsPath(dtsFileName);
55
- if (dtsSourcePath && existsSync(dtsSourcePath)) {
56
- const dtsContent = await readFile(dtsSourcePath, 'utf-8');
57
- await writeFile(globalDtsPath, dtsContent);
58
- console.log('Created global.d.ts for IDE type support');
59
- } else {
60
- console.warn('Could not locate core type definitions — global.d.ts was not created.');
61
- console.warn('IDE autocompletion for the Viji API may not be available.');
62
- }
55
+ const dtsContent = getGlobalDtsContent(renderer);
56
+ if (dtsContent && ensureCoreTypes(cwd)) {
57
+ await writeFile(globalDtsPath, dtsContent);
58
+ console.log('Created global.d.ts for IDE type support');
63
59
  }
64
60
  }
65
61
 
@@ -60,9 +60,9 @@ void main() {
60
60
  `,
61
61
  };
62
62
 
63
- const GLOBAL_DTS_FILE = {
64
- native: 'artist-global.d.ts',
65
- p5: 'artist-global-p5.d.ts',
63
+ const GLOBAL_DTS = {
64
+ native: '/// <reference path="node_modules/@viji-dev/core/dist/artist-global.d.ts" />\n',
65
+ p5: '/// <reference path="node_modules/@viji-dev/core/dist/artist-global-p5.d.ts" />\n',
66
66
  shader: null,
67
67
  };
68
68
 
@@ -74,8 +74,8 @@ export function getSceneTemplate(renderer = 'native') {
74
74
  return template;
75
75
  }
76
76
 
77
- export function getGlobalDtsFileName(renderer = 'native') {
78
- return GLOBAL_DTS_FILE[renderer] ?? GLOBAL_DTS_FILE.native;
77
+ export function getGlobalDtsContent(renderer = 'native') {
78
+ return GLOBAL_DTS[renderer] ?? GLOBAL_DTS.native;
79
79
  }
80
80
 
81
81
  export function getSceneFileExtension(renderer = 'native') {