@evitcastudio/kit 3.0.1 → 3.1.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/LICENSE +21 -21
- package/README.md +123 -123
- package/lib/bundle/cli/cli.js +5681 -3
- package/lib/bundle/cli/kit-game-templates/multi/_gitignore +180 -180
- package/lib/bundle/cli/kit-game-templates/multi/src/client/packets/s-packets.ts +4 -4
- package/lib/bundle/cli/kit-game-templates/multi/src/server/packets/c-packets.ts +4 -4
- package/lib/bundle/cli/kit-game-templates/single/_gitignore +180 -180
- package/lib/bundle/cli/kit-game-templates/single/bun-serve.ts +27 -27
- package/lib/cli/resource-builder.d.ts.map +1 -1
- package/lib/cli/resource-builder.js +190 -0
- package/lib/types/vylo.d.ts +3848 -3848
- package/lib/vendor/vyi/index.d.ts +367 -0
- package/lib/vendor/vyi/index.d.ts.map +1 -0
- package/lib/vendor/vyi/index.js +5647 -0
- package/lib/vendor/vyi/vendor/icon-point/index.d.ts +139 -0
- package/lib/vendor/vyi/vendor/icon-point/index.d.ts.map +1 -0
- package/lib/vendor/vyi/vendor/icon-point/index.js +286 -0
- package/lib/vendor/vyi/vyi-worker-inline.d.ts +2 -0
- package/lib/vendor/vyi/vyi-worker-inline.d.ts.map +1 -0
- package/lib/vendor/vyi/vyi-worker-inline.js +3 -0
- package/package.json +1 -1
- package/lib/bundle/cli/kit-game-templates/multi/resource.json +0 -1
- package/lib/bundle/cli/kit-game-templates/single/resource.json +0 -1
|
@@ -1,180 +1,180 @@
|
|
|
1
|
-
dist/
|
|
2
|
-
lib/
|
|
3
|
-
**/resource.json
|
|
4
|
-
tests/temp/
|
|
5
|
-
|
|
6
|
-
# Based on https://raw.githubusercontent.com/github/gitignore/main/Node.gitignore
|
|
7
|
-
|
|
8
|
-
# Logs
|
|
9
|
-
|
|
10
|
-
logs
|
|
11
|
-
_.log
|
|
12
|
-
npm-debug.log_
|
|
13
|
-
yarn-debug.log*
|
|
14
|
-
yarn-error.log*
|
|
15
|
-
lerna-debug.log*
|
|
16
|
-
.pnpm-debug.log*
|
|
17
|
-
|
|
18
|
-
# Caches
|
|
19
|
-
|
|
20
|
-
.cache
|
|
21
|
-
|
|
22
|
-
# Diagnostic reports (https://nodejs.org/api/report.html)
|
|
23
|
-
|
|
24
|
-
report.[0-9]_.[0-9]_.[0-9]_.[0-9]_.json
|
|
25
|
-
|
|
26
|
-
# Runtime data
|
|
27
|
-
|
|
28
|
-
pids
|
|
29
|
-
_.pid
|
|
30
|
-
_.seed
|
|
31
|
-
*.pid.lock
|
|
32
|
-
|
|
33
|
-
# Directory for instrumented libs generated by jscoverage/JSCover
|
|
34
|
-
|
|
35
|
-
lib-cov
|
|
36
|
-
|
|
37
|
-
# Coverage directory used by tools like istanbul
|
|
38
|
-
|
|
39
|
-
coverage
|
|
40
|
-
*.lcov
|
|
41
|
-
|
|
42
|
-
# nyc test coverage
|
|
43
|
-
|
|
44
|
-
.nyc_output
|
|
45
|
-
|
|
46
|
-
# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files)
|
|
47
|
-
|
|
48
|
-
.grunt
|
|
49
|
-
|
|
50
|
-
# Bower dependency directory (https://bower.io/)
|
|
51
|
-
|
|
52
|
-
bower_components
|
|
53
|
-
|
|
54
|
-
# node-waf configuration
|
|
55
|
-
|
|
56
|
-
.lock-wscript
|
|
57
|
-
|
|
58
|
-
# Compiled binary addons (https://nodejs.org/api/addons.html)
|
|
59
|
-
|
|
60
|
-
build/Release
|
|
61
|
-
|
|
62
|
-
# Dependency directories
|
|
63
|
-
|
|
64
|
-
node_modules/
|
|
65
|
-
jspm_packages/
|
|
66
|
-
|
|
67
|
-
# Snowpack dependency directory (https://snowpack.dev/)
|
|
68
|
-
|
|
69
|
-
web_modules/
|
|
70
|
-
|
|
71
|
-
# TypeScript cache
|
|
72
|
-
|
|
73
|
-
*.tsbuildinfo
|
|
74
|
-
|
|
75
|
-
# Optional npm cache directory
|
|
76
|
-
|
|
77
|
-
.npm
|
|
78
|
-
|
|
79
|
-
# Optional eslint cache
|
|
80
|
-
|
|
81
|
-
.eslintcache
|
|
82
|
-
|
|
83
|
-
# Optional stylelint cache
|
|
84
|
-
|
|
85
|
-
.stylelintcache
|
|
86
|
-
|
|
87
|
-
# Microbundle cache
|
|
88
|
-
|
|
89
|
-
.rpt2_cache/
|
|
90
|
-
.rts2_cache_cjs/
|
|
91
|
-
.rts2_cache_es/
|
|
92
|
-
.rts2_cache_umd/
|
|
93
|
-
|
|
94
|
-
# Optional REPL history
|
|
95
|
-
|
|
96
|
-
.node_repl_history
|
|
97
|
-
|
|
98
|
-
# Output of 'npm pack'
|
|
99
|
-
|
|
100
|
-
*.tgz
|
|
101
|
-
|
|
102
|
-
# Yarn Integrity file
|
|
103
|
-
|
|
104
|
-
.yarn-integrity
|
|
105
|
-
|
|
106
|
-
# dotenv environment variable files
|
|
107
|
-
|
|
108
|
-
.env
|
|
109
|
-
.env.development.local
|
|
110
|
-
.env.test.local
|
|
111
|
-
.env.production.local
|
|
112
|
-
.env.local
|
|
113
|
-
|
|
114
|
-
# parcel-bundler cache (https://parceljs.org/)
|
|
115
|
-
|
|
116
|
-
.parcel-cache
|
|
117
|
-
|
|
118
|
-
# Next.js build output
|
|
119
|
-
|
|
120
|
-
.next
|
|
121
|
-
out
|
|
122
|
-
|
|
123
|
-
# Nuxt.js build / generate output
|
|
124
|
-
|
|
125
|
-
.nuxt
|
|
126
|
-
dist
|
|
127
|
-
|
|
128
|
-
# Gatsby files
|
|
129
|
-
|
|
130
|
-
# Comment in the public line in if your project uses Gatsby and not Next.js
|
|
131
|
-
|
|
132
|
-
# https://nextjs.org/blog/next-9-1#public-directory-support
|
|
133
|
-
|
|
134
|
-
# public
|
|
135
|
-
|
|
136
|
-
# vuepress build output
|
|
137
|
-
|
|
138
|
-
.vuepress/dist
|
|
139
|
-
|
|
140
|
-
# vuepress v2.x temp and cache directory
|
|
141
|
-
|
|
142
|
-
.temp
|
|
143
|
-
|
|
144
|
-
# Docusaurus cache and generated files
|
|
145
|
-
|
|
146
|
-
.docusaurus
|
|
147
|
-
|
|
148
|
-
# Serverless directories
|
|
149
|
-
|
|
150
|
-
.serverless/
|
|
151
|
-
|
|
152
|
-
# FuseBox cache
|
|
153
|
-
|
|
154
|
-
.fusebox/
|
|
155
|
-
|
|
156
|
-
# DynamoDB Local files
|
|
157
|
-
|
|
158
|
-
.dynamodb/
|
|
159
|
-
|
|
160
|
-
# TernJS port file
|
|
161
|
-
|
|
162
|
-
.tern-port
|
|
163
|
-
|
|
164
|
-
# Stores VSCode versions used for testing VSCode extensions
|
|
165
|
-
|
|
166
|
-
.vscode-test
|
|
167
|
-
|
|
168
|
-
# yarn v2
|
|
169
|
-
|
|
170
|
-
.yarn/cache
|
|
171
|
-
.yarn/unplugged
|
|
172
|
-
.yarn/build-state.yml
|
|
173
|
-
.yarn/install-state.gz
|
|
174
|
-
.pnp.*
|
|
175
|
-
|
|
176
|
-
# IntelliJ based IDEs
|
|
177
|
-
.idea
|
|
178
|
-
|
|
179
|
-
# Finder (MacOS) folder config
|
|
180
|
-
.DS_Store
|
|
1
|
+
dist/
|
|
2
|
+
lib/
|
|
3
|
+
**/resource.json
|
|
4
|
+
tests/temp/
|
|
5
|
+
|
|
6
|
+
# Based on https://raw.githubusercontent.com/github/gitignore/main/Node.gitignore
|
|
7
|
+
|
|
8
|
+
# Logs
|
|
9
|
+
|
|
10
|
+
logs
|
|
11
|
+
_.log
|
|
12
|
+
npm-debug.log_
|
|
13
|
+
yarn-debug.log*
|
|
14
|
+
yarn-error.log*
|
|
15
|
+
lerna-debug.log*
|
|
16
|
+
.pnpm-debug.log*
|
|
17
|
+
|
|
18
|
+
# Caches
|
|
19
|
+
|
|
20
|
+
.cache
|
|
21
|
+
|
|
22
|
+
# Diagnostic reports (https://nodejs.org/api/report.html)
|
|
23
|
+
|
|
24
|
+
report.[0-9]_.[0-9]_.[0-9]_.[0-9]_.json
|
|
25
|
+
|
|
26
|
+
# Runtime data
|
|
27
|
+
|
|
28
|
+
pids
|
|
29
|
+
_.pid
|
|
30
|
+
_.seed
|
|
31
|
+
*.pid.lock
|
|
32
|
+
|
|
33
|
+
# Directory for instrumented libs generated by jscoverage/JSCover
|
|
34
|
+
|
|
35
|
+
lib-cov
|
|
36
|
+
|
|
37
|
+
# Coverage directory used by tools like istanbul
|
|
38
|
+
|
|
39
|
+
coverage
|
|
40
|
+
*.lcov
|
|
41
|
+
|
|
42
|
+
# nyc test coverage
|
|
43
|
+
|
|
44
|
+
.nyc_output
|
|
45
|
+
|
|
46
|
+
# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files)
|
|
47
|
+
|
|
48
|
+
.grunt
|
|
49
|
+
|
|
50
|
+
# Bower dependency directory (https://bower.io/)
|
|
51
|
+
|
|
52
|
+
bower_components
|
|
53
|
+
|
|
54
|
+
# node-waf configuration
|
|
55
|
+
|
|
56
|
+
.lock-wscript
|
|
57
|
+
|
|
58
|
+
# Compiled binary addons (https://nodejs.org/api/addons.html)
|
|
59
|
+
|
|
60
|
+
build/Release
|
|
61
|
+
|
|
62
|
+
# Dependency directories
|
|
63
|
+
|
|
64
|
+
node_modules/
|
|
65
|
+
jspm_packages/
|
|
66
|
+
|
|
67
|
+
# Snowpack dependency directory (https://snowpack.dev/)
|
|
68
|
+
|
|
69
|
+
web_modules/
|
|
70
|
+
|
|
71
|
+
# TypeScript cache
|
|
72
|
+
|
|
73
|
+
*.tsbuildinfo
|
|
74
|
+
|
|
75
|
+
# Optional npm cache directory
|
|
76
|
+
|
|
77
|
+
.npm
|
|
78
|
+
|
|
79
|
+
# Optional eslint cache
|
|
80
|
+
|
|
81
|
+
.eslintcache
|
|
82
|
+
|
|
83
|
+
# Optional stylelint cache
|
|
84
|
+
|
|
85
|
+
.stylelintcache
|
|
86
|
+
|
|
87
|
+
# Microbundle cache
|
|
88
|
+
|
|
89
|
+
.rpt2_cache/
|
|
90
|
+
.rts2_cache_cjs/
|
|
91
|
+
.rts2_cache_es/
|
|
92
|
+
.rts2_cache_umd/
|
|
93
|
+
|
|
94
|
+
# Optional REPL history
|
|
95
|
+
|
|
96
|
+
.node_repl_history
|
|
97
|
+
|
|
98
|
+
# Output of 'npm pack'
|
|
99
|
+
|
|
100
|
+
*.tgz
|
|
101
|
+
|
|
102
|
+
# Yarn Integrity file
|
|
103
|
+
|
|
104
|
+
.yarn-integrity
|
|
105
|
+
|
|
106
|
+
# dotenv environment variable files
|
|
107
|
+
|
|
108
|
+
.env
|
|
109
|
+
.env.development.local
|
|
110
|
+
.env.test.local
|
|
111
|
+
.env.production.local
|
|
112
|
+
.env.local
|
|
113
|
+
|
|
114
|
+
# parcel-bundler cache (https://parceljs.org/)
|
|
115
|
+
|
|
116
|
+
.parcel-cache
|
|
117
|
+
|
|
118
|
+
# Next.js build output
|
|
119
|
+
|
|
120
|
+
.next
|
|
121
|
+
out
|
|
122
|
+
|
|
123
|
+
# Nuxt.js build / generate output
|
|
124
|
+
|
|
125
|
+
.nuxt
|
|
126
|
+
dist
|
|
127
|
+
|
|
128
|
+
# Gatsby files
|
|
129
|
+
|
|
130
|
+
# Comment in the public line in if your project uses Gatsby and not Next.js
|
|
131
|
+
|
|
132
|
+
# https://nextjs.org/blog/next-9-1#public-directory-support
|
|
133
|
+
|
|
134
|
+
# public
|
|
135
|
+
|
|
136
|
+
# vuepress build output
|
|
137
|
+
|
|
138
|
+
.vuepress/dist
|
|
139
|
+
|
|
140
|
+
# vuepress v2.x temp and cache directory
|
|
141
|
+
|
|
142
|
+
.temp
|
|
143
|
+
|
|
144
|
+
# Docusaurus cache and generated files
|
|
145
|
+
|
|
146
|
+
.docusaurus
|
|
147
|
+
|
|
148
|
+
# Serverless directories
|
|
149
|
+
|
|
150
|
+
.serverless/
|
|
151
|
+
|
|
152
|
+
# FuseBox cache
|
|
153
|
+
|
|
154
|
+
.fusebox/
|
|
155
|
+
|
|
156
|
+
# DynamoDB Local files
|
|
157
|
+
|
|
158
|
+
.dynamodb/
|
|
159
|
+
|
|
160
|
+
# TernJS port file
|
|
161
|
+
|
|
162
|
+
.tern-port
|
|
163
|
+
|
|
164
|
+
# Stores VSCode versions used for testing VSCode extensions
|
|
165
|
+
|
|
166
|
+
.vscode-test
|
|
167
|
+
|
|
168
|
+
# yarn v2
|
|
169
|
+
|
|
170
|
+
.yarn/cache
|
|
171
|
+
.yarn/unplugged
|
|
172
|
+
.yarn/build-state.yml
|
|
173
|
+
.yarn/install-state.gz
|
|
174
|
+
.pnp.*
|
|
175
|
+
|
|
176
|
+
# IntelliJ based IDEs
|
|
177
|
+
.idea
|
|
178
|
+
|
|
179
|
+
# Finder (MacOS) folder config
|
|
180
|
+
.DS_Store
|
|
@@ -1,28 +1,28 @@
|
|
|
1
|
-
import { logMessage } from './bun-build.ts';
|
|
2
|
-
|
|
3
|
-
const server = Bun.serve({
|
|
4
|
-
port: 8090,
|
|
5
|
-
fetch(req) {
|
|
6
|
-
const path = new URL(req.url).pathname;
|
|
7
|
-
// Default to index.html if the user hits the root URL
|
|
8
|
-
const target = path === "/" ? "/index.html" : path;
|
|
9
|
-
|
|
10
|
-
return new Response(Bun.file(`./dist${target}`));
|
|
11
|
-
},
|
|
12
|
-
});
|
|
13
|
-
|
|
14
|
-
// signal interrupt event
|
|
15
|
-
process.on('SIGINT', () => {
|
|
16
|
-
logMessage('info', 'Shutting down server...');
|
|
17
|
-
server.stop();
|
|
18
|
-
process.exit(0);
|
|
19
|
-
});
|
|
20
|
-
|
|
21
|
-
// signal termination event
|
|
22
|
-
process.on('SIGTERM', () => {
|
|
23
|
-
logMessage('info', 'Shutting down server...');
|
|
24
|
-
server.stop();
|
|
25
|
-
process.exit(0);
|
|
26
|
-
});
|
|
27
|
-
|
|
1
|
+
import { logMessage } from './bun-build.ts';
|
|
2
|
+
|
|
3
|
+
const server = Bun.serve({
|
|
4
|
+
port: 8090,
|
|
5
|
+
fetch(req) {
|
|
6
|
+
const path = new URL(req.url).pathname;
|
|
7
|
+
// Default to index.html if the user hits the root URL
|
|
8
|
+
const target = path === "/" ? "/index.html" : path;
|
|
9
|
+
|
|
10
|
+
return new Response(Bun.file(`./dist${target}`));
|
|
11
|
+
},
|
|
12
|
+
});
|
|
13
|
+
|
|
14
|
+
// signal interrupt event
|
|
15
|
+
process.on('SIGINT', () => {
|
|
16
|
+
logMessage('info', 'Shutting down server...');
|
|
17
|
+
server.stop();
|
|
18
|
+
process.exit(0);
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
// signal termination event
|
|
22
|
+
process.on('SIGTERM', () => {
|
|
23
|
+
logMessage('info', 'Shutting down server...');
|
|
24
|
+
server.stop();
|
|
25
|
+
process.exit(0);
|
|
26
|
+
});
|
|
27
|
+
|
|
28
28
|
logMessage('info', `Ready to play at http://localhost:8090`);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"resource-builder.d.ts","sourceRoot":"","sources":["../../src/cli/resource-builder.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;
|
|
1
|
+
{"version":3,"file":"resource-builder.d.ts","sourceRoot":"","sources":["../../src/cli/resource-builder.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AA8X9C;;GAEG;AACH,wBAAsB,gBAAgB,CAAC,EAAE,WAAW,EAAE,YAAY,EAAE,OAAO,EAAE,WAAW,EAAE,EAAE,cAAc,GAAG,OAAO,CAAC,IAAI,CAAC,CA2BzH"}
|
|
@@ -2,6 +2,7 @@ import { promises as fs } from 'fs';
|
|
|
2
2
|
import { join, extname, basename } from 'path';
|
|
3
3
|
import chalk from 'chalk';
|
|
4
4
|
import { v4 as uuidv4 } from 'uuid';
|
|
5
|
+
import { VYI } from '../vendor/vyi';
|
|
5
6
|
// Logging helpers
|
|
6
7
|
const log = console.log;
|
|
7
8
|
const info = chalk.hex('#ffa552');
|
|
@@ -109,12 +110,197 @@ async function processAllFiles() {
|
|
|
109
110
|
await Promise.all(copyOperations);
|
|
110
111
|
logVerbose(`[Kit CLI] All resources have been processed.`);
|
|
111
112
|
await saveResourceJSON();
|
|
113
|
+
const boundsData = await buildBoundsJSON();
|
|
114
|
+
await saveBoundsJSON(boundsData);
|
|
115
|
+
const pointsData = await buildIconPointsJSON();
|
|
116
|
+
await saveIconPointsJSON(pointsData);
|
|
117
|
+
const sizesData = await buildSizesJSON();
|
|
118
|
+
await saveSizesJSON(sizesData);
|
|
112
119
|
}
|
|
113
120
|
catch (pError) {
|
|
114
121
|
const errorMessage = pError instanceof Error ? pError.message : String(pError);
|
|
115
122
|
logError(`[Error] Processing files in batch: ${errorMessage}`);
|
|
116
123
|
}
|
|
117
124
|
}
|
|
125
|
+
/**
|
|
126
|
+
* Builds the bounds map from all processed vyi files.
|
|
127
|
+
*/
|
|
128
|
+
async function buildBoundsJSON() {
|
|
129
|
+
const boundsData = {};
|
|
130
|
+
for (const { filePath, type } of resourcesToProcess) {
|
|
131
|
+
if (type !== 'icon')
|
|
132
|
+
continue;
|
|
133
|
+
try {
|
|
134
|
+
const fileBuffer = await fs.readFile(filePath);
|
|
135
|
+
const vyi = new VYI().parse(fileBuffer);
|
|
136
|
+
const atlasName = basename(filePath, '.vyi');
|
|
137
|
+
const atlasEntry = {};
|
|
138
|
+
for (const icon of vyi.getIcons()) {
|
|
139
|
+
const iconName = icon.getName();
|
|
140
|
+
const iconBounds = icon.getBoundsExport();
|
|
141
|
+
const hasIconBounds = Object.keys(iconBounds).length > 0;
|
|
142
|
+
const iconEntry = {};
|
|
143
|
+
if (hasIconBounds) {
|
|
144
|
+
iconEntry.bounds = iconBounds;
|
|
145
|
+
}
|
|
146
|
+
const statesEntry = {};
|
|
147
|
+
for (const state of icon.getStates()) {
|
|
148
|
+
const stateName = state.getName();
|
|
149
|
+
const stateBounds = state.getBoundsExport();
|
|
150
|
+
if (Object.keys(stateBounds).length > 0) {
|
|
151
|
+
statesEntry[stateName] = {
|
|
152
|
+
bounds: stateBounds
|
|
153
|
+
};
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
if (Object.keys(statesEntry).length > 0) {
|
|
157
|
+
iconEntry.states = statesEntry;
|
|
158
|
+
}
|
|
159
|
+
if (Object.keys(iconEntry).length > 0) {
|
|
160
|
+
atlasEntry[iconName] = iconEntry;
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
if (Object.keys(atlasEntry).length > 0) {
|
|
164
|
+
boundsData[atlasName] = atlasEntry;
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
catch (pError) {
|
|
168
|
+
logError(`[Error] Failed to parse bounds from ${filePath}: ${pError}`);
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
return boundsData;
|
|
172
|
+
}
|
|
173
|
+
/**
|
|
174
|
+
* Saves the bounds JSON to a file.
|
|
175
|
+
*/
|
|
176
|
+
async function saveBoundsJSON(pBoundsData) {
|
|
177
|
+
const filePath = 'bounds.json';
|
|
178
|
+
try {
|
|
179
|
+
await fs.writeFile(filePath, JSON.stringify(pBoundsData));
|
|
180
|
+
}
|
|
181
|
+
catch (pError) {
|
|
182
|
+
logError(`[Error] Saving bounds JSON: ${pError}`);
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
/**
|
|
186
|
+
* Builds the icon points map from all processed vyi files.
|
|
187
|
+
*/
|
|
188
|
+
async function buildIconPointsJSON() {
|
|
189
|
+
const pointsData = {};
|
|
190
|
+
for (const { filePath, type } of resourcesToProcess) {
|
|
191
|
+
if (type !== 'icon')
|
|
192
|
+
continue;
|
|
193
|
+
try {
|
|
194
|
+
const fileBuffer = await fs.readFile(filePath);
|
|
195
|
+
const vyi = new VYI().parse(fileBuffer);
|
|
196
|
+
const atlasName = basename(filePath, '.vyi');
|
|
197
|
+
const atlasEntry = {};
|
|
198
|
+
for (const icon of vyi.getIcons()) {
|
|
199
|
+
const iconName = icon.getName();
|
|
200
|
+
const iconPoints = icon.getIconPointsExport();
|
|
201
|
+
const hasIconPoints = iconPoints && iconPoints.length > 0;
|
|
202
|
+
const iconEntry = {};
|
|
203
|
+
if (hasIconPoints) {
|
|
204
|
+
const pointsMap = {};
|
|
205
|
+
for (const pt of iconPoints) {
|
|
206
|
+
pointsMap[pt.id] = {
|
|
207
|
+
width: pt.width,
|
|
208
|
+
height: pt.height,
|
|
209
|
+
x: pt.x,
|
|
210
|
+
y: pt.y
|
|
211
|
+
};
|
|
212
|
+
}
|
|
213
|
+
iconEntry.points = pointsMap;
|
|
214
|
+
}
|
|
215
|
+
const statesEntry = {};
|
|
216
|
+
for (const state of icon.getStates()) {
|
|
217
|
+
const stateName = state.getName();
|
|
218
|
+
const statePoints = state.getIconPointsExport();
|
|
219
|
+
if (statePoints && statePoints.length > 0) {
|
|
220
|
+
const statePointsMap = {};
|
|
221
|
+
for (const pt of statePoints) {
|
|
222
|
+
statePointsMap[pt.id] = {
|
|
223
|
+
width: pt.width,
|
|
224
|
+
height: pt.height,
|
|
225
|
+
x: pt.x,
|
|
226
|
+
y: pt.y
|
|
227
|
+
};
|
|
228
|
+
}
|
|
229
|
+
statesEntry[stateName] = {
|
|
230
|
+
points: statePointsMap
|
|
231
|
+
};
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
if (Object.keys(statesEntry).length > 0) {
|
|
235
|
+
iconEntry.states = statesEntry;
|
|
236
|
+
}
|
|
237
|
+
if (Object.keys(iconEntry).length > 0) {
|
|
238
|
+
atlasEntry[iconName] = iconEntry;
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
if (Object.keys(atlasEntry).length > 0) {
|
|
242
|
+
pointsData[atlasName] = atlasEntry;
|
|
243
|
+
}
|
|
244
|
+
}
|
|
245
|
+
catch (pError) {
|
|
246
|
+
logError(`[Error] Failed to parse icon points from ${filePath}: ${pError}`);
|
|
247
|
+
}
|
|
248
|
+
}
|
|
249
|
+
return pointsData;
|
|
250
|
+
}
|
|
251
|
+
/**
|
|
252
|
+
* Saves the icon points JSON to a file.
|
|
253
|
+
*/
|
|
254
|
+
async function saveIconPointsJSON(pPointsData) {
|
|
255
|
+
const filePath = 'icon-points.json';
|
|
256
|
+
try {
|
|
257
|
+
await fs.writeFile(filePath, JSON.stringify(pPointsData));
|
|
258
|
+
}
|
|
259
|
+
catch (pError) {
|
|
260
|
+
logError(`[Error] Saving icon points JSON: ${pError}`);
|
|
261
|
+
}
|
|
262
|
+
}
|
|
263
|
+
/**
|
|
264
|
+
* Builds the sizes map from all processed vyi files.
|
|
265
|
+
*/
|
|
266
|
+
async function buildSizesJSON() {
|
|
267
|
+
const sizesData = {};
|
|
268
|
+
for (const { filePath, type } of resourcesToProcess) {
|
|
269
|
+
if (type !== 'icon')
|
|
270
|
+
continue;
|
|
271
|
+
try {
|
|
272
|
+
const fileBuffer = await fs.readFile(filePath);
|
|
273
|
+
const vyi = new VYI().parse(fileBuffer);
|
|
274
|
+
const atlasName = basename(filePath, '.vyi');
|
|
275
|
+
const atlasEntry = {};
|
|
276
|
+
for (const icon of vyi.getIcons()) {
|
|
277
|
+
atlasEntry[icon.getName()] = {
|
|
278
|
+
width: icon.getWidth(),
|
|
279
|
+
height: icon.getHeight()
|
|
280
|
+
};
|
|
281
|
+
}
|
|
282
|
+
if (Object.keys(atlasEntry).length > 0) {
|
|
283
|
+
sizesData[atlasName] = atlasEntry;
|
|
284
|
+
}
|
|
285
|
+
}
|
|
286
|
+
catch (pError) {
|
|
287
|
+
logError(`[Error] Failed to parse sizes from ${filePath}: ${pError}`);
|
|
288
|
+
}
|
|
289
|
+
}
|
|
290
|
+
return sizesData;
|
|
291
|
+
}
|
|
292
|
+
/**
|
|
293
|
+
* Saves the sizes JSON to a file.
|
|
294
|
+
*/
|
|
295
|
+
async function saveSizesJSON(pSizesData) {
|
|
296
|
+
const filePath = 'sizes.json';
|
|
297
|
+
try {
|
|
298
|
+
await fs.writeFile(filePath, JSON.stringify(pSizesData));
|
|
299
|
+
}
|
|
300
|
+
catch (pError) {
|
|
301
|
+
logError(`[Error] Saving sizes JSON: ${pError}`);
|
|
302
|
+
}
|
|
303
|
+
}
|
|
118
304
|
/**
|
|
119
305
|
* Clears specified directories within a base directory.
|
|
120
306
|
* @param pBaseDirectory - The path to the base directory.
|
|
@@ -164,6 +350,7 @@ export async function processResources({ inDirectory, outDirectory, verbose, ign
|
|
|
164
350
|
isVerbose = verbose;
|
|
165
351
|
ignoringSound = ignoreSound;
|
|
166
352
|
resourceJSON = initializeResourceJSON();
|
|
353
|
+
resourcesToProcess.length = 0;
|
|
167
354
|
// Validate inputs
|
|
168
355
|
if (!resourceInDirectory || !resourceOutDirectory) {
|
|
169
356
|
logError('[Error] Input and output directories must be specified');
|
|
@@ -177,6 +364,9 @@ export async function processResources({ inDirectory, outDirectory, verbose, ign
|
|
|
177
364
|
else {
|
|
178
365
|
logAlert('No resources found!');
|
|
179
366
|
await saveResourceJSON();
|
|
367
|
+
await saveBoundsJSON({});
|
|
368
|
+
await saveIconPointsJSON({});
|
|
369
|
+
await saveSizesJSON({});
|
|
180
370
|
}
|
|
181
371
|
}
|
|
182
372
|
function logVerbose(pMessage) {
|