@gnsx/genesys.sdk 4.3.5 → 5.0.6

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.
@@ -10,6 +10,24 @@ import { ALL_DEPENDENCIES } from '../dependencies.js';
10
10
  const __dirname = path.dirname(fileURLToPath(import.meta.url));
11
11
  // Fix PATH on macOS when running as a GUI app
12
12
  fixPath();
13
+ /**
14
+ * Get the version of a dependency, resolving symlinks to absolute paths.
15
+ * If the version is a symlink (starts with 'link:'), it will be resolved to an absolute path.
16
+ * Otherwise, the version string is returned as-is.
17
+ *
18
+ * @param name - The name of the dependency
19
+ * @returns The version string or absolute path for symlinked dependencies
20
+ */
21
+ export function getDependencyVersion(name) {
22
+ const version = ALL_DEPENDENCIES[name];
23
+ // Check if this is a symlink (e.g., 'link:../genesys.js')
24
+ if (version.startsWith('link:')) {
25
+ // Extract the relative path from the link
26
+ const relativePath = version.substring(5); // Remove 'link:' prefix
27
+ return `link:${path.resolve(getProjectRoot(), relativePath)}`;
28
+ }
29
+ return version;
30
+ }
13
31
  export function mockBrowserEnvironment() {
14
32
  const dom = new JSDOM('<!DOCTYPE html><p>Hello world</p>');
15
33
  global.window = dom.window;
@@ -39,7 +57,7 @@ export function checkEngineVersion(engineVersion) {
39
57
  }
40
58
  }
41
59
  export function getEngineVersion() {
42
- return ALL_DEPENDENCIES['@gnsx/genesys.js'];
60
+ return getDependencyVersion('@gnsx/genesys.js');
43
61
  }
44
62
  export function getAppVersion() {
45
63
  const pkg = JSON.parse(fs.readFileSync(path.join(getProjectRoot(), 'package.json'), 'utf8'));
@@ -1,8 +1,7 @@
1
1
  import fs from 'fs';
2
2
  import path from 'path';
3
3
  import * as ENGINE from '@gnsx/genesys.js';
4
- import { ALL_DEPENDENCIES } from '../../dependencies.js';
5
- import { copyAsync, existsAsync, getEngineVersion, getProjectRoot, mkdirAsync, readdirAsync, runCommandAsync, writeFileAsync } from '../common.js';
4
+ import { copyAsync, existsAsync, getDependencyVersion, getEngineVersion, getProjectRoot, mkdirAsync, readdirAsync, runCommandAsync, writeFileAsync } from '../common.js';
6
5
  import { IgnoredFiles } from '../index.js';
7
6
  export const packProjectFiles = {
8
7
  packageJson: {
@@ -28,13 +27,13 @@ export const packProjectFiles = {
28
27
  main: 'dist/src/index.js',
29
28
  peerDependencies: {
30
29
  '@gnsx/genesys.js': `${getEngineVersion()}`,
31
- 'three': ALL_DEPENDENCIES['three'],
30
+ 'three': getDependencyVersion('three'),
32
31
  },
33
32
  devDependencies: {
34
- '@types/three': ALL_DEPENDENCIES['@types/three'],
35
- 'nanoid': ALL_DEPENDENCIES['nanoid'],
36
- 'ajv': ALL_DEPENDENCIES['ajv'],
37
- 'esbuild': ALL_DEPENDENCIES['esbuild'],
33
+ '@types/three': getDependencyVersion('@types/three'),
34
+ 'nanoid': getDependencyVersion('nanoid'),
35
+ 'ajv': getDependencyVersion('ajv'),
36
+ 'esbuild': getDependencyVersion('esbuild'),
38
37
  'canvas': '3.1.0',
39
38
  'get-port': '7.1.0',
40
39
  'zod-to-json-schema': '3.24.6',
@@ -1,9 +1,8 @@
1
1
  import fs from 'fs';
2
2
  import path from 'path';
3
3
  import * as ENGINE from '@gnsx/genesys.js';
4
- import { ALL_DEPENDENCIES } from '../../dependencies.js';
5
4
  import { deletedTemplateItems, sharedTemplateItems } from '../../templates/src/index.js';
6
- import { copyAsync, existsAsync, getEngineVersion, getProjectRoot, mkdirAsync, readdirAsync, runCommandAsync, writeFileAsync } from '../common.js';
5
+ import { copyAsync, existsAsync, getDependencyVersion, getEngineVersion, getProjectRoot, mkdirAsync, readdirAsync, runCommandAsync, writeFileAsync } from '../common.js';
7
6
  import { IgnoredFiles } from '../index.js';
8
7
  // Available project templates
9
8
  export const TEMPLATES = [
@@ -34,22 +33,22 @@ export const projectFiles = {
34
33
  type: 'module',
35
34
  dependencies: {
36
35
  '@gnsx/genesys.js': `${getEngineVersion()}`,
37
- 'three': ALL_DEPENDENCIES['three'],
36
+ 'three': getDependencyVersion('three'),
38
37
  },
39
38
  devDependencies: {
40
- '@types/three': ALL_DEPENDENCIES['@types/three'],
41
- 'nanoid': ALL_DEPENDENCIES['nanoid'],
42
- 'ajv': ALL_DEPENDENCIES['ajv'],
43
- 'esbuild': ALL_DEPENDENCIES['esbuild'],
39
+ '@types/three': getDependencyVersion('@types/three'),
40
+ 'nanoid': getDependencyVersion('nanoid'),
41
+ 'ajv': getDependencyVersion('ajv'),
42
+ 'esbuild': getDependencyVersion('esbuild'),
44
43
  'canvas': '3.1.0',
45
44
  'get-port': '7.1.0',
46
- 'zod-to-json-schema': '3.24.6',
45
+ 'zod-to-json-schema': getDependencyVersion('zod-to-json-schema'),
47
46
  'ws': '8.18.2',
48
47
  '@types/node': '22.15.21',
49
48
  '@types/jsdom': '21.1.7',
50
49
  '@modelcontextprotocol/sdk': '1.22.0',
51
50
  'tsx': '4.20.3', // pin the tsx version to avoid import issues of the @webxr-input-profiles/motion-controllers module in game projects
52
- 'zod': '3.24.4',
51
+ 'zod': getDependencyVersion('zod'),
53
52
  'jsdom': '26.1.0',
54
53
  'typescript': '5.8.3',
55
54
  'vite': '7.1.7',
@@ -12,71 +12,71 @@ export const DEPENDENCIES = {
12
12
  '@electron/rebuild': '4.0.2',
13
13
  '@emotion/react': '11.14.0',
14
14
  '@emotion/styled': '11.14.1',
15
- '@gnsx/genesys.js': '4.2.20',
16
- '@mui/icons-material': '7.3.5',
15
+ '@gnsx/genesys.js': 'link:../genesys.js',
16
+ '@mui/icons-material': '7.3.7',
17
17
  '@mui/lab': '7.0.0',
18
- '@mui/material': '7.3.5',
19
- '@sentry/electron': '7.5.0',
18
+ '@mui/material': '7.3.7',
19
+ '@sentry/electron': '7.7.0',
20
20
  'chokidar': '4.0.3',
21
21
  'commander': '14.0.2',
22
22
  'core-util-is': '1.0.3',
23
- 'cors': '2.8.5',
23
+ 'cors': '2.8.6',
24
24
  'electron-devtools-installer': '4.0.0',
25
25
  'electron-is-dev': '3.0.1',
26
26
  'electron-log': '5.4.3',
27
27
  'electron-store': '11.0.2',
28
28
  'electron-updater': '6.7.3',
29
29
  'esbuild': '0.25.12',
30
- 'express': '5.1.0',
30
+ 'express': '5.2.1',
31
31
  'fix-path': '4.0.0',
32
- 'jsdom': '27.2.0',
32
+ 'jsdom': '27.4.0',
33
33
  'minimatch': '10.1.1',
34
34
  'multer': '2.0.2',
35
- 'node-abi': '4.24.0',
36
- 'react': '19.2.0',
37
- 'react-dom': '19.2.0',
35
+ 'node-abi': '4.26.0',
36
+ 'react': '19.2.4',
37
+ 'react-dom': '19.2.4',
38
38
  'three': '0.182.0',
39
39
  'upath': '2.0.1',
40
- 'ws': '8.18.3',
40
+ 'ws': '8.19.0',
41
41
  'zod': '3.25.76',
42
42
  };
43
43
  export const DEV_DEPENDENCIES = {
44
44
  '@electron/notarize': '3.1.1',
45
- '@modelcontextprotocol/sdk': '1.22.0',
45
+ '@modelcontextprotocol/sdk': '1.25.3',
46
46
  '@types/cors': '2.8.19',
47
47
  '@types/electron-store': '3.2.2',
48
- '@types/express': '5.0.5',
48
+ '@types/express': '5.0.6',
49
49
  '@types/jsdom': '27.0.0',
50
50
  '@types/minimatch': '5.1.2',
51
51
  '@types/multer': '1.4.13',
52
- '@types/node': '22.19.1',
53
- '@types/react': '19.2.7',
52
+ '@types/node': '22.19.7',
53
+ '@types/react': '19.2.9',
54
54
  '@types/react-dom': '19.2.3',
55
55
  '@types/three': '0.182.0',
56
56
  '@types/ws': '8.18.1',
57
- '@typescript-eslint/eslint-plugin': '8.48.0',
58
- '@typescript-eslint/parser': '8.48.0',
57
+ '@typescript-eslint/eslint-plugin': '8.54.0',
58
+ '@typescript-eslint/parser': '8.54.0',
59
59
  '@vitejs/plugin-react': '4.7.0',
60
60
  'ajv': '8.17.1',
61
61
  'concurrently': '9.2.1',
62
62
  'dotenv-cli': '8.0.0',
63
- 'electron': '39.2.7',
63
+ 'electron': '39.3.0',
64
64
  'electron-builder': '26.4.0',
65
- 'eslint': '9.39.1',
65
+ 'eslint': '9.39.2',
66
66
  'eslint-plugin-import': '2.32.0',
67
67
  'get-port': '7.1.0',
68
68
  'nanoid': '5.1.6',
69
69
  'nodemon': '3.1.11',
70
70
  'ts-morph': '27.0.2',
71
71
  'tsc-watch': '7.2.0',
72
- 'tsx': '4.20.6',
72
+ 'tsx': '4.21.0',
73
73
  'typescript': '5.9.3',
74
74
  'vite': '6.4.1',
75
75
  'vite-plugin-mkcert': '1.17.9',
76
76
  'vite-plugin-node-polyfills': '0.24.0',
77
77
  'wait-on': '8.0.5',
78
- 'yaml': '2.8.1',
79
- 'zod-to-json-schema': '3.25.0',
78
+ 'yaml': '2.8.2',
79
+ 'zod-to-json-schema': '3.25.1',
80
80
  };
81
81
  export const ALL_DEPENDENCIES = {
82
82
  ...DEPENDENCIES,
package/package.json CHANGED
@@ -1,15 +1,10 @@
1
1
  {
2
2
  "name": "@gnsx/genesys.sdk",
3
- "version": "4.3.5",
3
+ "version": "5.0.6",
4
4
  "description": "Genesys SDK - A development toolkit for game development",
5
5
  "author": "Directive Games",
6
6
  "main": "index.js",
7
7
  "type": "module",
8
- "pnpm": {
9
- "onlyBuiltDependencies": [
10
- "electron"
11
- ]
12
- },
13
8
  "publishConfig": {
14
9
  "access": "public"
15
10
  },
@@ -40,7 +35,9 @@
40
35
  "cli": "pnpm exec tsx src/core/cli.ts",
41
36
  "cli:new": "pnpm exec tsx src/core/cli.ts new",
42
37
  "cli:build": "pnpm exec tsx src/core/cli.ts build",
43
- "cli:new-asset-pack": "pnpm exec tsx src/core/cli.ts new-asset-pack"
38
+ "cli:new-asset-pack": "pnpm exec tsx src/core/cli.ts new-asset-pack",
39
+ "publish:prepare": "cd ../.. && pnpm exec tsx scripts/prepare-publish.ts packages/genesys.sdk",
40
+ "publish:restore": "cd ../.. && pnpm exec tsx scripts/prepare-publish.ts restore packages/genesys.sdk"
44
41
  },
45
42
  "build": {
46
43
  "artifactName": "Genesys-Setup-${version}.${ext}",
@@ -112,7 +109,7 @@
112
109
  "@electron/rebuild": "^4.0.2",
113
110
  "@emotion/react": "^11.14.0",
114
111
  "@emotion/styled": "^11.14.0",
115
- "@gnsx/genesys.js": "^4.2.20",
112
+ "@gnsx/genesys.js": "workspace:*",
116
113
  "@mui/icons-material": "^7.1.0",
117
114
  "@mui/lab": "^7.0.0-beta.12",
118
115
  "@mui/material": "^7.1.0",
@@ -22,6 +22,33 @@ interface PnpmLockFile {
22
22
  }>;
23
23
  }
24
24
 
25
+ /**
26
+ * Read dependency versions from node_modules package.json files
27
+ */
28
+ function getVersionsFromNodeModules(
29
+ dependencyNames: string[],
30
+ ): Record<string, string> {
31
+ const versions: Record<string, string> = {};
32
+ const nodeModulesPath = path.join(process.cwd(), 'node_modules');
33
+
34
+ for (const depName of dependencyNames) {
35
+ try {
36
+ const depPackageJsonPath = path.join(nodeModulesPath, depName, 'package.json');
37
+
38
+ if (fs.existsSync(depPackageJsonPath)) {
39
+ const depPackageJson = JSON.parse(fs.readFileSync(depPackageJsonPath, 'utf-8'));
40
+ if (depPackageJson.version) {
41
+ versions[depName] = depPackageJson.version;
42
+ }
43
+ }
44
+ } catch (error) {
45
+ console.warn(`⚠️ Could not read version for ${depName}:`, error instanceof Error ? error.message : error);
46
+ }
47
+ }
48
+
49
+ return versions;
50
+ }
51
+
25
52
  function generateDependenciesFile(): void {
26
53
  try {
27
54
  // Read main package.json to get dependency lists
@@ -29,17 +56,7 @@ function generateDependenciesFile(): void {
29
56
  const packageJsonContent = fs.readFileSync(packageJsonPath, 'utf-8');
30
57
  const packageJson: PackageJson = JSON.parse(packageJsonContent);
31
58
 
32
- // Read pnpm-lock.yaml to get exact versions
33
- const pnpmLockPath = path.join(process.cwd(), 'pnpm-lock.yaml');
34
- if (!fs.existsSync(pnpmLockPath)) {
35
- // this is a valid case when this package is installed as a dependency of another package
36
- console.log('⚠️ Could not read pnpm-lock.yaml, skipping dependency versions');
37
- return;
38
- }
39
- const pnpmLockContent = fs.readFileSync(pnpmLockPath, 'utf-8');
40
- const pnpmLock: PnpmLockFile = YAML.parse(pnpmLockContent);
41
-
42
- // Extract dependency lists from both package.json files
59
+ // Extract dependency lists from package.json
43
60
  const mainDependencyNames = Object.keys(packageJson.dependencies ?? {});
44
61
  const mainDevDependencyNames = Object.keys(packageJson.devDependencies ?? {});
45
62
 
@@ -47,45 +64,100 @@ function generateDependenciesFile(): void {
47
64
  const allDependencyNames = [...new Set([...mainDependencyNames])];
48
65
  const allDevDependencyNames = [...new Set([...mainDevDependencyNames])];
49
66
 
50
- // Helper function to extract version from pnpm lock entry
51
- const extractVersion = (versionString: string): string => {
52
- // pnpm versions can include peer dependency info in parentheses, e.g., "11.14.0(@types/react@19.2.7)(react@19.2.0)"
53
- // We only want the base version number
54
- return versionString.split('(')[0];
55
- };
56
-
57
- // Get exact versions from pnpm-lock.yaml
58
- const dependencies: Record<string, string> = {};
59
- const devDependencies: Record<string, string> = {};
60
-
61
- // Get importers (root workspace)
62
- const rootImporter = pnpmLock.importers?.['.'];
63
-
64
- // Process production dependencies
65
- for (const depName of allDependencyNames) {
66
- // Check root workspace first
67
- let version = rootImporter?.dependencies?.[depName]?.version;
68
- if (version) {
69
- dependencies[depName] = extractVersion(version);
67
+ // Check environment variable to determine which code path to use
68
+ const useNodeModules = process.env.USE_NODE_MODULES_VERSIONS === 'true';
69
+
70
+ let dependencies: Record<string, string> = {};
71
+ let devDependencies: Record<string, string> = {};
72
+
73
+ if (useNodeModules) {
74
+ // New code path: Read versions from node_modules package.json files
75
+ console.log('📦 Reading dependency versions from node_modules package.json files...');
76
+ dependencies = getVersionsFromNodeModules(allDependencyNames);
77
+ devDependencies = getVersionsFromNodeModules(allDevDependencyNames);
78
+ } else {
79
+ // Original code path: Read versions from pnpm-lock.yaml
80
+ console.log('📦 Reading dependency versions from pnpm-lock.yaml...');
81
+
82
+ // Find the monorepo root by looking for pnpm-workspace.yaml
83
+ let currentDir = process.cwd();
84
+ let pnpmLockPath = '';
85
+ let workspaceRoot = '';
86
+ let relativePackagePath = '';
87
+
88
+ // Search up the directory tree for pnpm-workspace.yaml
89
+ while (currentDir !== path.parse(currentDir).root) {
90
+ const workspaceYamlPath = path.join(currentDir, 'pnpm-workspace.yaml');
91
+ const lockPath = path.join(currentDir, 'pnpm-lock.yaml');
92
+
93
+ if (fs.existsSync(workspaceYamlPath) && fs.existsSync(lockPath)) {
94
+ workspaceRoot = currentDir;
95
+ pnpmLockPath = lockPath;
96
+ relativePackagePath = path.relative(workspaceRoot, process.cwd()).replace(/\\/g, '/');
97
+ break;
98
+ }
99
+
100
+ currentDir = path.dirname(currentDir);
70
101
  }
71
- }
72
102
 
73
- // Process dev dependencies
74
- for (const depName of allDevDependencyNames) {
75
- // Check root workspace first
76
- let version = rootImporter?.devDependencies?.[depName]?.version;
77
- if (version) {
78
- devDependencies[depName] = extractVersion(version);
103
+ // Fallback to checking current directory if not in a workspace
104
+ if (!pnpmLockPath) {
105
+ pnpmLockPath = path.join(process.cwd(), 'pnpm-lock.yaml');
106
+ relativePackagePath = '.';
107
+ }
108
+
109
+ if (!fs.existsSync(pnpmLockPath)) {
110
+ // this is a valid case when this package is installed as a dependency of another package
111
+ console.log('⚠️ Could not read pnpm-lock.yaml, skipping dependency versions');
112
+ return;
113
+ }
114
+
115
+ const pnpmLockContent = fs.readFileSync(pnpmLockPath, 'utf-8');
116
+ const pnpmLock: PnpmLockFile = YAML.parse(pnpmLockContent);
117
+
118
+ // Helper function to extract version from pnpm lock entry
119
+ const extractVersion = (versionString: string): string => {
120
+ // pnpm versions can include peer dependency info in parentheses, e.g., "11.14.0(@types/react@19.2.7)(react@19.2.0)"
121
+ // We only want the base version number
122
+ return versionString.split('(')[0];
123
+ };
124
+
125
+ // Get the correct importer (either current package or root)
126
+ const packageImporter = pnpmLock.importers?.[relativePackagePath];
127
+ const rootImporter = pnpmLock.importers?.['.'];
128
+
129
+ // Process production dependencies
130
+ for (const depName of allDependencyNames) {
131
+ // Check package-specific importer first, then fall back to root
132
+ let version = packageImporter?.dependencies?.[depName]?.version ??
133
+ rootImporter?.dependencies?.[depName]?.version;
134
+ if (version) {
135
+ dependencies[depName] = extractVersion(version);
136
+ }
137
+ }
138
+
139
+ // Process dev dependencies
140
+ for (const depName of allDevDependencyNames) {
141
+ // Check package-specific importer first, then fall back to root
142
+ let version = packageImporter?.devDependencies?.[depName]?.version ??
143
+ rootImporter?.devDependencies?.[depName]?.version;
144
+ if (version) {
145
+ devDependencies[depName] = extractVersion(version);
146
+ }
79
147
  }
80
148
  }
81
149
 
82
150
  // Generate TypeScript content
151
+ const versionSource = useNodeModules
152
+ ? 'node_modules package.json files'
153
+ : 'pnpm-lock.yaml';
154
+
83
155
  const tsContent = `/**
84
156
  * Auto-generated file containing all package dependencies and their exact installed versions.
85
157
  * This file is generated by the post-install script.
86
158
  * Do not edit manually - it will be overwritten on next install.
87
159
  *
88
- * Versions are extracted from pnpm-lock.yaml to show exact installed versions,
160
+ * Versions are extracted from ${versionSource} to show exact installed versions,
89
161
  * not the version ranges from package.json.
90
162
  *
91
163
  * Includes dependencies from the main package.