@directivegames/genesys.sdk 4.2.4 → 4.2.5

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.
@@ -52,6 +52,7 @@ export const DEV_DEPENDENCIES = {
52
52
  '@types/react': '19.2.7',
53
53
  '@types/react-dom': '19.2.3',
54
54
  '@types/three': '0.182.0',
55
+ '@types/node': '22.19.1',
55
56
  '@types/ws': '8.18.1',
56
57
  '@typescript-eslint/eslint-plugin': '8.48.0',
57
58
  '@typescript-eslint/parser': '8.48.0',
@@ -1,3 +1,17 @@
1
+ /**
2
+ * Migration script for Genesys scene, prefab, and material files.
3
+ *
4
+ * Migration order: Scenes → Prefabs → Materials
5
+ * This order is important because the engine cannot load new prefab data with old scene data.
6
+ *
7
+ * The migration runs TWICE:
8
+ * - Pass 1: Updates all files to the new format
9
+ * - Pass 2: Re-processes all files to ensure prefab instances in scenes are saved correctly
10
+ * (prefab instances are only serialized properly when both the prefab and scene
11
+ * data are at the same version)
12
+ *
13
+ * Usage: pnpm migrate (requires running `pnpm build` first to compile game classes)
14
+ */
1
15
  import fs from 'fs';
2
16
  import path from 'path';
3
17
  import * as ENGINE from '@directivegames/genesys.js';
@@ -148,31 +162,16 @@ async function migrateFile(fileInfo) {
148
162
  }
149
163
  return 'skipped';
150
164
  }
151
- async function main() {
152
- // Game classes are registered via the top-level import of dist/src/game.js
153
- // Make sure to run `pnpm build` first!
154
- const projectRoot = getProjectRoot();
155
- const assetsFolder = path.join(projectRoot, 'assets');
156
- console.log(`📁 Scanning for scene and prefab files in: ${assetsFolder}\n`);
157
- // Find all scene and prefab files in the assets folder
158
- const files = findScenesAndPrefabs(assetsFolder);
159
- if (files.length === 0) {
160
- console.log('⚠️ No scene or prefab files found.');
161
- return;
162
- }
163
- const prefabFiles = files.filter(f => f.type === 'prefab');
164
- const sceneFiles = files.filter(f => f.type === 'scene');
165
- const materialFiles = files.filter(f => f.type === 'material');
166
- console.log(`Found ${files.length} files to migrate:`);
167
- console.log(` - ${prefabFiles.length} prefab file(s)`);
168
- console.log(` - ${sceneFiles.length} scene file(s)\n`);
169
- console.log(` - ${materialFiles.length} material file(s)\n`);
165
+ async function runMigrationPass(sceneFiles, prefabFiles, materialFiles, passNumber) {
170
166
  let successCount = 0;
171
167
  let failCount = 0;
172
- // Migrate prefabs first
173
- if (prefabFiles.length > 0) {
174
- console.log('📦 Migrating prefabs...\n');
175
- for (const fileInfo of prefabFiles) {
168
+ console.log(`\n${'='.repeat(60)}`);
169
+ console.log(`Migration Pass ${passNumber}`);
170
+ console.log(`${'='.repeat(60)}\n`);
171
+ // Migrate scenes first (must be done before prefabs to ensure engine can load new prefab data)
172
+ if (sceneFiles.length > 0) {
173
+ console.log('🌍 Migrating scenes...\n');
174
+ for (const fileInfo of sceneFiles) {
176
175
  const success = await migrateFile(fileInfo);
177
176
  if (success) {
178
177
  successCount++;
@@ -182,10 +181,10 @@ async function main() {
182
181
  }
183
182
  }
184
183
  }
185
- // Then migrate scenes
186
- if (sceneFiles.length > 0) {
187
- console.log('\n🌍 Migrating scenes...\n');
188
- for (const fileInfo of sceneFiles) {
184
+ // Then migrate prefabs
185
+ if (prefabFiles.length > 0) {
186
+ console.log('\n📦 Migrating prefabs...\n');
187
+ for (const fileInfo of prefabFiles) {
189
188
  const success = await migrateFile(fileInfo);
190
189
  if (success) {
191
190
  successCount++;
@@ -194,7 +193,9 @@ async function main() {
194
193
  failCount++;
195
194
  }
196
195
  }
197
- // Finally migrate materials
196
+ }
197
+ // Finally migrate materials
198
+ if (materialFiles.length > 0) {
198
199
  console.log('\n🎨 Migrating materials...\n');
199
200
  for (const fileInfo of materialFiles) {
200
201
  const success = await migrateFile(fileInfo);
@@ -206,13 +207,41 @@ async function main() {
206
207
  }
207
208
  }
208
209
  }
210
+ return { successCount, failCount };
211
+ }
212
+ async function main() {
213
+ // Game classes are registered via the top-level import of dist/src/game.js
214
+ // Make sure to run `pnpm build` first!
215
+ const projectRoot = getProjectRoot();
216
+ const assetsFolder = path.join(projectRoot, 'assets');
217
+ console.log(`📁 Scanning for scene and prefab files in: ${assetsFolder}\n`);
218
+ // Find all scene and prefab files in the assets folder
219
+ const files = findScenesAndPrefabs(assetsFolder);
220
+ if (files.length === 0) {
221
+ console.log('⚠️ No scene or prefab files found.');
222
+ return;
223
+ }
224
+ const prefabFiles = files.filter(f => f.type === 'prefab');
225
+ const sceneFiles = files.filter(f => f.type === 'scene');
226
+ const materialFiles = files.filter(f => f.type === 'material');
227
+ console.log(`Found ${files.length} files to migrate:`);
228
+ console.log(` - ${sceneFiles.length} scene file(s)`);
229
+ console.log(` - ${prefabFiles.length} prefab file(s)`);
230
+ console.log(` - ${materialFiles.length} material file(s)`);
231
+ // Run migration twice to ensure prefab instances in scenes are saved properly
232
+ // (prefab instances are only saved correctly when both prefab and scene data are the same version)
233
+ const pass1 = await runMigrationPass(sceneFiles, prefabFiles, materialFiles, 1);
234
+ const pass2 = await runMigrationPass(sceneFiles, prefabFiles, materialFiles, 2);
235
+ const totalSuccess = pass1.successCount + pass2.successCount;
236
+ const totalFail = pass1.failCount + pass2.failCount;
209
237
  console.log(`\n${'='.repeat(60)}`);
210
238
  console.log('Migration Summary:');
211
- console.log(` Total files: ${files.length}`);
212
- console.log(` Successful: ${successCount}`);
213
- console.log(` Failed: ${failCount}`);
239
+ console.log(` Total files per pass: ${files.length}`);
240
+ console.log(` Pass 1 - Successful: ${pass1.successCount}, Failed: ${pass1.failCount}`);
241
+ console.log(` Pass 2 - Successful: ${pass2.successCount}, Failed: ${pass2.failCount}`);
242
+ console.log(` Total - Successful: ${totalSuccess}, Failed: ${totalFail}`);
214
243
  console.log(`${'='.repeat(60)}`);
215
- if (failCount > 0) {
244
+ if (totalFail > 0) {
216
245
  process.exit(1);
217
246
  }
218
247
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@directivegames/genesys.sdk",
3
- "version": "4.2.4",
3
+ "version": "4.2.5",
4
4
  "description": "Genesys SDK - A development toolkit for game development",
5
5
  "author": "Directive Games",
6
6
  "main": "index.js",
@@ -152,6 +152,7 @@
152
152
  "@types/react": "^19.2.0",
153
153
  "@types/react-dom": "^19.2.0",
154
154
  "@types/three": "^0.182.0",
155
+ "@types/node": "^22.15.21",
155
156
  "@types/ws": "^8.18.1",
156
157
  "@typescript-eslint/eslint-plugin": "^8.29.1",
157
158
  "@typescript-eslint/parser": "^8.29.1",
@@ -1,3 +1,18 @@
1
+ /**
2
+ * Migration script for Genesys scene, prefab, and material files.
3
+ *
4
+ * Migration order: Scenes → Prefabs → Materials
5
+ * This order is important because the engine cannot load new prefab data with old scene data.
6
+ *
7
+ * The migration runs TWICE:
8
+ * - Pass 1: Updates all files to the new format
9
+ * - Pass 2: Re-processes all files to ensure prefab instances in scenes are saved correctly
10
+ * (prefab instances are only serialized properly when both the prefab and scene
11
+ * data are at the same version)
12
+ *
13
+ * Usage: pnpm migrate (requires running `pnpm build` first to compile game classes)
14
+ */
15
+
1
16
  import fs from 'fs';
2
17
  import path from 'path';
3
18
 
@@ -174,37 +189,28 @@ async function migrateFile(fileInfo: FileInfo): Promise<'success' | 'failure' |
174
189
  return 'skipped';
175
190
  }
176
191
 
177
- async function main() {
178
- // Game classes are registered via the top-level import of dist/src/game.js
179
- // Make sure to run `pnpm build` first!
180
-
181
- const projectRoot = getProjectRoot();
182
- const assetsFolder = path.join(projectRoot, 'assets');
183
- console.log(`📁 Scanning for scene and prefab files in: ${assetsFolder}\n`);
184
-
185
- // Find all scene and prefab files in the assets folder
186
- const files = findScenesAndPrefabs(assetsFolder);
187
-
188
- if (files.length === 0) {
189
- console.log('⚠️ No scene or prefab files found.');
190
- return;
191
- }
192
-
193
- const prefabFiles = files.filter(f => f.type === 'prefab');
194
- const sceneFiles = files.filter(f => f.type === 'scene');
195
- const materialFiles = files.filter(f => f.type === 'material');
196
- console.log(`Found ${files.length} files to migrate:`);
197
- console.log(` - ${prefabFiles.length} prefab file(s)`);
198
- console.log(` - ${sceneFiles.length} scene file(s)\n`);
199
- console.log(` - ${materialFiles.length} material file(s)\n`);
192
+ interface MigrationResult {
193
+ successCount: number;
194
+ failCount: number;
195
+ }
200
196
 
197
+ async function runMigrationPass(
198
+ sceneFiles: FileInfo[],
199
+ prefabFiles: FileInfo[],
200
+ materialFiles: FileInfo[],
201
+ passNumber: number
202
+ ): Promise<MigrationResult> {
201
203
  let successCount = 0;
202
204
  let failCount = 0;
203
205
 
204
- // Migrate prefabs first
205
- if (prefabFiles.length > 0) {
206
- console.log('📦 Migrating prefabs...\n');
207
- for (const fileInfo of prefabFiles) {
206
+ console.log(`\n${'='.repeat(60)}`);
207
+ console.log(`Migration Pass ${passNumber}`);
208
+ console.log(`${'='.repeat(60)}\n`);
209
+
210
+ // Migrate scenes first (must be done before prefabs to ensure engine can load new prefab data)
211
+ if (sceneFiles.length > 0) {
212
+ console.log('🌍 Migrating scenes...\n');
213
+ for (const fileInfo of sceneFiles) {
208
214
  const success = await migrateFile(fileInfo);
209
215
  if (success) {
210
216
  successCount++;
@@ -214,10 +220,10 @@ async function main() {
214
220
  }
215
221
  }
216
222
 
217
- // Then migrate scenes
218
- if (sceneFiles.length > 0) {
219
- console.log('\n🌍 Migrating scenes...\n');
220
- for (const fileInfo of sceneFiles) {
223
+ // Then migrate prefabs
224
+ if (prefabFiles.length > 0) {
225
+ console.log('\n📦 Migrating prefabs...\n');
226
+ for (const fileInfo of prefabFiles) {
221
227
  const success = await migrateFile(fileInfo);
222
228
  if (success) {
223
229
  successCount++;
@@ -225,8 +231,10 @@ async function main() {
225
231
  failCount++;
226
232
  }
227
233
  }
234
+ }
228
235
 
229
- // Finally migrate materials
236
+ // Finally migrate materials
237
+ if (materialFiles.length > 0) {
230
238
  console.log('\n🎨 Migrating materials...\n');
231
239
  for (const fileInfo of materialFiles) {
232
240
  const success = await migrateFile(fileInfo);
@@ -238,14 +246,50 @@ async function main() {
238
246
  }
239
247
  }
240
248
 
249
+ return { successCount, failCount };
250
+ }
251
+
252
+ async function main() {
253
+ // Game classes are registered via the top-level import of dist/src/game.js
254
+ // Make sure to run `pnpm build` first!
255
+
256
+ const projectRoot = getProjectRoot();
257
+ const assetsFolder = path.join(projectRoot, 'assets');
258
+ console.log(`📁 Scanning for scene and prefab files in: ${assetsFolder}\n`);
259
+
260
+ // Find all scene and prefab files in the assets folder
261
+ const files = findScenesAndPrefabs(assetsFolder);
262
+
263
+ if (files.length === 0) {
264
+ console.log('⚠️ No scene or prefab files found.');
265
+ return;
266
+ }
267
+
268
+ const prefabFiles = files.filter(f => f.type === 'prefab');
269
+ const sceneFiles = files.filter(f => f.type === 'scene');
270
+ const materialFiles = files.filter(f => f.type === 'material');
271
+ console.log(`Found ${files.length} files to migrate:`);
272
+ console.log(` - ${sceneFiles.length} scene file(s)`);
273
+ console.log(` - ${prefabFiles.length} prefab file(s)`);
274
+ console.log(` - ${materialFiles.length} material file(s)`);
275
+
276
+ // Run migration twice to ensure prefab instances in scenes are saved properly
277
+ // (prefab instances are only saved correctly when both prefab and scene data are the same version)
278
+ const pass1 = await runMigrationPass(sceneFiles, prefabFiles, materialFiles, 1);
279
+ const pass2 = await runMigrationPass(sceneFiles, prefabFiles, materialFiles, 2);
280
+
281
+ const totalSuccess = pass1.successCount + pass2.successCount;
282
+ const totalFail = pass1.failCount + pass2.failCount;
283
+
241
284
  console.log(`\n${'='.repeat(60)}`);
242
285
  console.log('Migration Summary:');
243
- console.log(` Total files: ${files.length}`);
244
- console.log(` Successful: ${successCount}`);
245
- console.log(` Failed: ${failCount}`);
286
+ console.log(` Total files per pass: ${files.length}`);
287
+ console.log(` Pass 1 - Successful: ${pass1.successCount}, Failed: ${pass1.failCount}`);
288
+ console.log(` Pass 2 - Successful: ${pass2.successCount}, Failed: ${pass2.failCount}`);
289
+ console.log(` Total - Successful: ${totalSuccess}, Failed: ${totalFail}`);
246
290
  console.log(`${'='.repeat(60)}`);
247
291
 
248
- if (failCount > 0) {
292
+ if (totalFail > 0) {
249
293
  process.exit(1);
250
294
  }
251
295
  }