@directivegames/genesys.sdk 4.1.11 → 4.1.13
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/dist/src/dependencies.js
CHANGED
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
* Includes dependencies from the main package.
|
|
10
10
|
*/
|
|
11
11
|
export const DEPENDENCIES = {
|
|
12
|
-
'@directivegames/genesys.js': '4.1.
|
|
12
|
+
'@directivegames/genesys.js': '4.1.24',
|
|
13
13
|
'@electron/rebuild': '4.0.2',
|
|
14
14
|
'@emotion/react': '11.14.0',
|
|
15
15
|
'@emotion/styled': '11.14.1',
|
|
@@ -42,13 +42,13 @@ function findScenesAndPrefabs(dir, files = []) {
|
|
|
42
42
|
else if (entry.endsWith('.prefab.json')) {
|
|
43
43
|
files.push({ path: fullPath, type: 'prefab' });
|
|
44
44
|
}
|
|
45
|
+
else if (entry.endsWith('.material.json')) {
|
|
46
|
+
files.push({ path: fullPath, type: 'material' });
|
|
47
|
+
}
|
|
45
48
|
}
|
|
46
49
|
return files;
|
|
47
50
|
}
|
|
48
|
-
async function migrateSceneFile(filePath, relativePath) {
|
|
49
|
-
// Read the file content
|
|
50
|
-
const content = fs.readFileSync(filePath, 'utf-8');
|
|
51
|
-
const data = JSON.parse(content);
|
|
51
|
+
async function migrateSceneFile(data, filePath, relativePath) {
|
|
52
52
|
// Create a world and load into it
|
|
53
53
|
const world = new ENGINE.World(defaultWorldOptions);
|
|
54
54
|
if (ENGINE.isLegacyData(data)) {
|
|
@@ -69,10 +69,7 @@ async function migrateSceneFile(filePath, relativePath) {
|
|
|
69
69
|
console.log(`✅ ${relativePath}`);
|
|
70
70
|
return true;
|
|
71
71
|
}
|
|
72
|
-
async function migratePrefabFile(filePath, relativePath) {
|
|
73
|
-
// Read the file content
|
|
74
|
-
const content = fs.readFileSync(filePath, 'utf-8');
|
|
75
|
-
const data = JSON.parse(content);
|
|
72
|
+
async function migratePrefabFile(data, filePath, relativePath) {
|
|
76
73
|
let instance;
|
|
77
74
|
if (ENGINE.isLegacyData(data)) {
|
|
78
75
|
// Use WorldSerializer for legacy data
|
|
@@ -90,7 +87,7 @@ async function migratePrefabFile(filePath, relativePath) {
|
|
|
90
87
|
return false;
|
|
91
88
|
}
|
|
92
89
|
// Dump using Dumper
|
|
93
|
-
const dumper = new ENGINE.Dumper();
|
|
90
|
+
const dumper = new ENGINE.Dumper({ flags: ENGINE.DumperFlags.AsPrefab });
|
|
94
91
|
const newData = dumper.dump(instance);
|
|
95
92
|
// Write back to file
|
|
96
93
|
const newContent = JSON.stringify(newData, null, 2);
|
|
@@ -98,24 +95,58 @@ async function migratePrefabFile(filePath, relativePath) {
|
|
|
98
95
|
console.log(`✅ ${relativePath}`);
|
|
99
96
|
return true;
|
|
100
97
|
}
|
|
98
|
+
async function migrateMaterialFile(data, filePath, relativePath) {
|
|
99
|
+
let material;
|
|
100
|
+
if (ENGINE.isLegacyData(data)) {
|
|
101
|
+
console.log(`🔍 Migrated legacy material: ${relativePath}`);
|
|
102
|
+
material = ENGINE.WorldSerializer.importObject(data);
|
|
103
|
+
console.log(`✅ ${relativePath}`);
|
|
104
|
+
}
|
|
105
|
+
else {
|
|
106
|
+
const loader = new ENGINE.Loader();
|
|
107
|
+
material = await loader.loadAsync(data);
|
|
108
|
+
}
|
|
109
|
+
if (!material) {
|
|
110
|
+
console.log(`⚠️ ${relativePath}: Loaded material is null, skipping`);
|
|
111
|
+
return false;
|
|
112
|
+
}
|
|
113
|
+
// Dump using Dumper
|
|
114
|
+
const dumper = new ENGINE.Dumper({ flags: ENGINE.DumperFlags.AsPrefab });
|
|
115
|
+
const newData = dumper.dump(material);
|
|
116
|
+
// Write back to file
|
|
117
|
+
const newContent = JSON.stringify(newData, null, 2);
|
|
118
|
+
fs.writeFileSync(filePath, newContent, 'utf-8');
|
|
119
|
+
console.log(`✅ ${relativePath}`);
|
|
120
|
+
return true;
|
|
121
|
+
}
|
|
101
122
|
async function migrateFile(fileInfo) {
|
|
102
123
|
const { path: filePath, type } = fileInfo;
|
|
103
124
|
const relativePath = path.relative(getProjectRoot(), filePath);
|
|
125
|
+
const content = fs.readFileSync(filePath, 'utf-8');
|
|
126
|
+
const data = JSON.parse(content);
|
|
127
|
+
// if (ENGINE.isUpdateToDateData(data)) {
|
|
128
|
+
// console.log(`ℹ️ ${relativePath}: Already up to date, skipping`);
|
|
129
|
+
// // return 'skipped';
|
|
130
|
+
// }
|
|
104
131
|
try {
|
|
105
132
|
if (type === 'scene') {
|
|
106
|
-
return await migrateSceneFile(filePath, relativePath);
|
|
133
|
+
return await migrateSceneFile(data, filePath, relativePath) ? 'success' : 'failure';
|
|
107
134
|
}
|
|
108
|
-
else {
|
|
109
|
-
return await migratePrefabFile(filePath, relativePath);
|
|
135
|
+
else if (type === 'prefab') {
|
|
136
|
+
return await migratePrefabFile(data, filePath, relativePath) ? 'success' : 'failure';
|
|
137
|
+
}
|
|
138
|
+
else if (type === 'material') {
|
|
139
|
+
return await migrateMaterialFile(data, filePath, relativePath) ? 'success' : 'failure';
|
|
110
140
|
}
|
|
111
141
|
}
|
|
112
142
|
catch (error) {
|
|
113
143
|
console.error(`❌ ${relativePath}: ${error instanceof Error ? error.message : String(error)}`);
|
|
114
|
-
return
|
|
144
|
+
return 'failure';
|
|
115
145
|
}
|
|
116
146
|
finally {
|
|
117
147
|
console.log('');
|
|
118
148
|
}
|
|
149
|
+
return 'skipped';
|
|
119
150
|
}
|
|
120
151
|
async function main() {
|
|
121
152
|
// Game classes are registered via the top-level import of dist/src/game.js
|
|
@@ -131,9 +162,11 @@ async function main() {
|
|
|
131
162
|
}
|
|
132
163
|
const prefabFiles = files.filter(f => f.type === 'prefab');
|
|
133
164
|
const sceneFiles = files.filter(f => f.type === 'scene');
|
|
165
|
+
const materialFiles = files.filter(f => f.type === 'material');
|
|
134
166
|
console.log(`Found ${files.length} files to migrate:`);
|
|
135
167
|
console.log(` - ${prefabFiles.length} prefab file(s)`);
|
|
136
168
|
console.log(` - ${sceneFiles.length} scene file(s)\n`);
|
|
169
|
+
console.log(` - ${materialFiles.length} material file(s)\n`);
|
|
137
170
|
let successCount = 0;
|
|
138
171
|
let failCount = 0;
|
|
139
172
|
// Migrate prefabs first
|
|
@@ -161,6 +194,17 @@ async function main() {
|
|
|
161
194
|
failCount++;
|
|
162
195
|
}
|
|
163
196
|
}
|
|
197
|
+
// Finally migrate materials
|
|
198
|
+
console.log('\n🎨 Migrating materials...\n');
|
|
199
|
+
for (const fileInfo of materialFiles) {
|
|
200
|
+
const success = await migrateFile(fileInfo);
|
|
201
|
+
if (success) {
|
|
202
|
+
successCount++;
|
|
203
|
+
}
|
|
204
|
+
else {
|
|
205
|
+
failCount++;
|
|
206
|
+
}
|
|
207
|
+
}
|
|
164
208
|
}
|
|
165
209
|
console.log(`\n${'='.repeat(60)}`);
|
|
166
210
|
console.log('Migration Summary:');
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@directivegames/genesys.sdk",
|
|
3
|
-
"version": "4.1.
|
|
3
|
+
"version": "4.1.13",
|
|
4
4
|
"description": "Genesys SDK - A development toolkit for game development",
|
|
5
5
|
"author": "Directive Games",
|
|
6
6
|
"main": "index.js",
|
|
@@ -109,7 +109,7 @@
|
|
|
109
109
|
}
|
|
110
110
|
},
|
|
111
111
|
"dependencies": {
|
|
112
|
-
"@directivegames/genesys.js": "^4.1.
|
|
112
|
+
"@directivegames/genesys.js": "^4.1.24",
|
|
113
113
|
"@electron/rebuild": "^4.0.2",
|
|
114
114
|
"@emotion/react": "^11.14.0",
|
|
115
115
|
"@emotion/styled": "^11.14.0",
|
|
@@ -20,7 +20,7 @@ ENGINE.projectContext({ project: 'local-project', storageProvider: storageProvid
|
|
|
20
20
|
|
|
21
21
|
interface FileInfo {
|
|
22
22
|
path: string;
|
|
23
|
-
type: 'scene' | 'prefab';
|
|
23
|
+
type: 'scene' | 'prefab' | 'material';
|
|
24
24
|
}
|
|
25
25
|
|
|
26
26
|
const defaultWorldOptions = {
|
|
@@ -54,17 +54,15 @@ function findScenesAndPrefabs(dir: string, files: FileInfo[] = []): FileInfo[] {
|
|
|
54
54
|
files.push({ path: fullPath, type: 'scene' });
|
|
55
55
|
} else if (entry.endsWith('.prefab.json')) {
|
|
56
56
|
files.push({ path: fullPath, type: 'prefab' });
|
|
57
|
+
} else if (entry.endsWith('.material.json')) {
|
|
58
|
+
files.push({ path: fullPath, type: 'material' });
|
|
57
59
|
}
|
|
58
60
|
}
|
|
59
61
|
|
|
60
62
|
return files;
|
|
61
63
|
}
|
|
62
64
|
|
|
63
|
-
async function migrateSceneFile(filePath: string, relativePath: string): Promise<boolean> {
|
|
64
|
-
// Read the file content
|
|
65
|
-
const content = fs.readFileSync(filePath, 'utf-8');
|
|
66
|
-
const data = JSON.parse(content);
|
|
67
|
-
|
|
65
|
+
async function migrateSceneFile(data: any, filePath: string, relativePath: string): Promise<boolean> {
|
|
68
66
|
// Create a world and load into it
|
|
69
67
|
const world = new ENGINE.World(defaultWorldOptions);
|
|
70
68
|
|
|
@@ -89,11 +87,7 @@ async function migrateSceneFile(filePath: string, relativePath: string): Promise
|
|
|
89
87
|
return true;
|
|
90
88
|
}
|
|
91
89
|
|
|
92
|
-
async function migratePrefabFile(filePath: string, relativePath: string): Promise<boolean> {
|
|
93
|
-
// Read the file content
|
|
94
|
-
const content = fs.readFileSync(filePath, 'utf-8');
|
|
95
|
-
const data = JSON.parse(content);
|
|
96
|
-
|
|
90
|
+
async function migratePrefabFile(data: any, filePath: string, relativePath: string): Promise<boolean> {
|
|
97
91
|
let instance: any;
|
|
98
92
|
|
|
99
93
|
if (ENGINE.isLegacyData(data)) {
|
|
@@ -113,7 +107,7 @@ async function migratePrefabFile(filePath: string, relativePath: string): Promis
|
|
|
113
107
|
}
|
|
114
108
|
|
|
115
109
|
// Dump using Dumper
|
|
116
|
-
const dumper = new ENGINE.Dumper();
|
|
110
|
+
const dumper = new ENGINE.Dumper({flags: ENGINE.DumperFlags.AsPrefab});
|
|
117
111
|
const newData = dumper.dump(instance);
|
|
118
112
|
|
|
119
113
|
// Write back to file
|
|
@@ -124,22 +118,60 @@ async function migratePrefabFile(filePath: string, relativePath: string): Promis
|
|
|
124
118
|
return true;
|
|
125
119
|
}
|
|
126
120
|
|
|
127
|
-
async function
|
|
121
|
+
async function migrateMaterialFile(data: any, filePath: string, relativePath: string): Promise<boolean> {
|
|
122
|
+
let material: any;
|
|
123
|
+
|
|
124
|
+
if (ENGINE.isLegacyData(data)) {
|
|
125
|
+
console.log(`🔍 Migrated legacy material: ${relativePath}`);
|
|
126
|
+
material = ENGINE.WorldSerializer.importObject(data);
|
|
127
|
+
console.log(`✅ ${relativePath}`);
|
|
128
|
+
} else {
|
|
129
|
+
const loader = new ENGINE.Loader();
|
|
130
|
+
material = await loader.loadAsync(data);
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
if (!material) {
|
|
134
|
+
console.log(`⚠️ ${relativePath}: Loaded material is null, skipping`);
|
|
135
|
+
return false;
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
// Dump using Dumper
|
|
139
|
+
const dumper = new ENGINE.Dumper({flags:ENGINE.DumperFlags.AsPrefab});
|
|
140
|
+
const newData = dumper.dump(material);
|
|
141
|
+
// Write back to file
|
|
142
|
+
const newContent = JSON.stringify(newData, null, 2);
|
|
143
|
+
fs.writeFileSync(filePath, newContent, 'utf-8');
|
|
144
|
+
|
|
145
|
+
console.log(`✅ ${relativePath}`);
|
|
146
|
+
return true;
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
async function migrateFile(fileInfo: FileInfo): Promise<'success' | 'failure' | 'skipped'> {
|
|
128
150
|
const { path: filePath, type } = fileInfo;
|
|
129
151
|
const relativePath = path.relative(getProjectRoot(), filePath);
|
|
130
152
|
|
|
153
|
+
const content = fs.readFileSync(filePath, 'utf-8');
|
|
154
|
+
const data = JSON.parse(content);
|
|
155
|
+
// if (ENGINE.isUpdateToDateData(data)) {
|
|
156
|
+
// console.log(`ℹ️ ${relativePath}: Already up to date, skipping`);
|
|
157
|
+
// // return 'skipped';
|
|
158
|
+
// }
|
|
159
|
+
|
|
131
160
|
try {
|
|
132
161
|
if (type === 'scene') {
|
|
133
|
-
return await migrateSceneFile(filePath, relativePath);
|
|
134
|
-
} else {
|
|
135
|
-
return await migratePrefabFile(filePath, relativePath);
|
|
162
|
+
return await migrateSceneFile(data, filePath, relativePath) ? 'success' : 'failure';
|
|
163
|
+
} else if (type === 'prefab') {
|
|
164
|
+
return await migratePrefabFile(data, filePath, relativePath) ? 'success' : 'failure';
|
|
165
|
+
} else if (type === 'material') {
|
|
166
|
+
return await migrateMaterialFile(data, filePath, relativePath) ? 'success' : 'failure';
|
|
136
167
|
}
|
|
137
168
|
} catch (error) {
|
|
138
169
|
console.error(`❌ ${relativePath}: ${error instanceof Error ? error.message : String(error)}`);
|
|
139
|
-
return
|
|
170
|
+
return 'failure';
|
|
140
171
|
} finally {
|
|
141
172
|
console.log('');
|
|
142
173
|
}
|
|
174
|
+
return 'skipped';
|
|
143
175
|
}
|
|
144
176
|
|
|
145
177
|
async function main() {
|
|
@@ -160,9 +192,11 @@ async function main() {
|
|
|
160
192
|
|
|
161
193
|
const prefabFiles = files.filter(f => f.type === 'prefab');
|
|
162
194
|
const sceneFiles = files.filter(f => f.type === 'scene');
|
|
195
|
+
const materialFiles = files.filter(f => f.type === 'material');
|
|
163
196
|
console.log(`Found ${files.length} files to migrate:`);
|
|
164
197
|
console.log(` - ${prefabFiles.length} prefab file(s)`);
|
|
165
198
|
console.log(` - ${sceneFiles.length} scene file(s)\n`);
|
|
199
|
+
console.log(` - ${materialFiles.length} material file(s)\n`);
|
|
166
200
|
|
|
167
201
|
let successCount = 0;
|
|
168
202
|
let failCount = 0;
|
|
@@ -191,6 +225,17 @@ async function main() {
|
|
|
191
225
|
failCount++;
|
|
192
226
|
}
|
|
193
227
|
}
|
|
228
|
+
|
|
229
|
+
// Finally migrate materials
|
|
230
|
+
console.log('\n🎨 Migrating materials...\n');
|
|
231
|
+
for (const fileInfo of materialFiles) {
|
|
232
|
+
const success = await migrateFile(fileInfo);
|
|
233
|
+
if (success) {
|
|
234
|
+
successCount++;
|
|
235
|
+
} else {
|
|
236
|
+
failCount++;
|
|
237
|
+
}
|
|
238
|
+
}
|
|
194
239
|
}
|
|
195
240
|
|
|
196
241
|
console.log(`\n${'='.repeat(60)}`);
|