@evitcastudio/kit 3.2.2 → 3.3.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 +224 -224
- package/lib/bundle/cli/cli.js +1876 -133
- package/lib/bundle/cli/kit-game-templates/multi/_gitignore +180 -180
- package/lib/bundle/cli/kit-game-templates/multi/package.json +5 -1
- package/lib/bundle/cli/kit-game-templates/multi/resource.json +7 -1
- 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/package.json +5 -1
- package/lib/bundle/cli/kit-game-templates/single/resource.json +7 -1
- package/lib/cli/app-bundler.d.ts.map +1 -1
- package/lib/cli/app-bundler.js +15 -3
- package/lib/cli/resource-builder.d.ts.map +1 -1
- package/lib/cli/resource-builder.js +135 -29
- package/lib/cli-runner.cjs +1 -1
- package/lib/types/vylo.d.ts +3848 -3848
- package/lib/vendor/vyi/index.js +26 -26
- package/package.json +74 -73
|
@@ -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
|
|
@@ -10,8 +10,12 @@
|
|
|
10
10
|
},
|
|
11
11
|
"scripts": {
|
|
12
12
|
"build": "kit build",
|
|
13
|
+
"build:prod": "kit build --prod",
|
|
13
14
|
"watch": "kit build --watch",
|
|
14
|
-
"host": "kit host -b"
|
|
15
|
+
"host": "kit host -b",
|
|
16
|
+
"host:prod": "kit host -b --prod",
|
|
17
|
+
"doctor": "kit doctor",
|
|
18
|
+
"create:plugin": "kit create plugin"
|
|
15
19
|
},
|
|
16
20
|
"keywords": [],
|
|
17
21
|
"dependencies": {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"app-bundler.d.ts","sourceRoot":"","sources":["../../src/cli/app-bundler.ts"],"names":[],"mappings":"AAKA,MAAM,MAAM,mBAAmB,GAAG,QAAQ,GAAG,OAAO,GAAG,MAAM,CAAC;AAE9D,MAAM,WAAW,gBAAgB;IAC7B,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,SAAS,CAAC,EAAE,MAAM,GAAG,QAAQ,GAAG,QAAQ,GAAG,UAAU,CAAC;IACtD,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,OAAO,CAAC,EAAE,OAAO,CAAC;CACrB;AAED,MAAM,WAAW,eAAe;IAC5B,YAAY,EAAE,mBAAmB,CAAC;IAClC,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,OAAO,EAAE,OAAO,CAAC;CACpB;AAED;;;;GAIG;AACH,wBAAgB,kBAAkB,CAAC,OAAO,EAAE,MAAM,GAAG,mBAAmB,CAYvE;AA+DD;;;;;;GAMG;AACH,wBAAsB,SAAS,CAAC,YAAY,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,QAAQ,GAAE,gBAAqB,GAAG,OAAO,CAAC,eAAe,CAAC,
|
|
1
|
+
{"version":3,"file":"app-bundler.d.ts","sourceRoot":"","sources":["../../src/cli/app-bundler.ts"],"names":[],"mappings":"AAKA,MAAM,MAAM,mBAAmB,GAAG,QAAQ,GAAG,OAAO,GAAG,MAAM,CAAC;AAE9D,MAAM,WAAW,gBAAgB;IAC7B,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,SAAS,CAAC,EAAE,MAAM,GAAG,QAAQ,GAAG,QAAQ,GAAG,UAAU,CAAC;IACtD,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,OAAO,CAAC,EAAE,OAAO,CAAC;CACrB;AAED,MAAM,WAAW,eAAe;IAC5B,YAAY,EAAE,mBAAmB,CAAC;IAClC,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,OAAO,EAAE,OAAO,CAAC;CACpB;AAED;;;;GAIG;AACH,wBAAgB,kBAAkB,CAAC,OAAO,EAAE,MAAM,GAAG,mBAAmB,CAYvE;AA+DD;;;;;;GAMG;AACH,wBAAsB,SAAS,CAAC,YAAY,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,QAAQ,GAAE,gBAAqB,GAAG,OAAO,CAAC,eAAe,CAAC,CAyLhI"}
|
package/lib/cli/app-bundler.js
CHANGED
|
@@ -123,7 +123,11 @@ export async function bundleApp(pProjectRoot, pOutDir, pOptions = {}) {
|
|
|
123
123
|
const startStamp = Date.now();
|
|
124
124
|
const clientResult = await Bun.build({
|
|
125
125
|
entrypoints: [join(srcDir, 'index.ts')],
|
|
126
|
-
naming:
|
|
126
|
+
naming: {
|
|
127
|
+
entry: 'index.[ext]',
|
|
128
|
+
chunk: '[name]-[hash].[ext]',
|
|
129
|
+
asset: '[name].[ext]'
|
|
130
|
+
},
|
|
127
131
|
outdir: pOutDir,
|
|
128
132
|
target: 'browser',
|
|
129
133
|
banner,
|
|
@@ -162,7 +166,11 @@ export async function bundleApp(pProjectRoot, pOutDir, pOptions = {}) {
|
|
|
162
166
|
const clientStart = Date.now();
|
|
163
167
|
const clientResult = await Bun.build({
|
|
164
168
|
entrypoints: [clientEntry],
|
|
165
|
-
naming:
|
|
169
|
+
naming: {
|
|
170
|
+
entry: 'index.[ext]',
|
|
171
|
+
chunk: '[name]-[hash].[ext]',
|
|
172
|
+
asset: '[name].[ext]'
|
|
173
|
+
},
|
|
166
174
|
outdir: pOutDir,
|
|
167
175
|
target: 'browser',
|
|
168
176
|
banner,
|
|
@@ -189,7 +197,11 @@ export async function bundleApp(pProjectRoot, pOutDir, pOptions = {}) {
|
|
|
189
197
|
const serverStart = Date.now();
|
|
190
198
|
const serverResult = await Bun.build({
|
|
191
199
|
entrypoints: [serverEntry],
|
|
192
|
-
naming:
|
|
200
|
+
naming: {
|
|
201
|
+
entry: 'server.[ext]',
|
|
202
|
+
chunk: '[name]-[hash].[ext]',
|
|
203
|
+
asset: '[name].[ext]'
|
|
204
|
+
},
|
|
193
205
|
outdir: pOutDir,
|
|
194
206
|
target: 'node',
|
|
195
207
|
banner,
|
|
@@ -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;AA0oB9C;;GAEG;AACH,wBAAsB,gBAAgB,CAAC,EAAE,WAAW,EAAE,YAAY,EAAE,YAAY,EAAE,KAAK,EAAE,OAAO,EAAE,WAAW,EAAE,GAAG,EAAE,MAAM,EAAE,SAAS,EAAE,SAAS,EAAE,IAAI,EAAE,EAAE,cAAc,GAAG,OAAO,CAAC,IAAI,CAAC,CAsCvL"}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import { promises as fs,
|
|
2
|
-
import { join, extname, basename, resolve } from 'path';
|
|
1
|
+
import { promises as fs, existsSync } from 'fs';
|
|
2
|
+
import { join, extname, basename, resolve, relative } from 'path';
|
|
3
3
|
import chalk from 'chalk';
|
|
4
|
+
import { watch as chokidarWatch } from 'chokidar';
|
|
4
5
|
import { v4 as uuidv4 } from 'uuid';
|
|
5
6
|
import { VYI } from '../vendor/vyi';
|
|
6
7
|
import { bundleApp } from './app-bundler';
|
|
@@ -130,7 +131,8 @@ async function mirrorDirectory(pSourceDir, pDestDir) {
|
|
|
130
131
|
const ext = extname(entry.name).slice(1);
|
|
131
132
|
// Copy all assets except internal Vylocity engine binary formats
|
|
132
133
|
if (!isEngineExtension(ext)) {
|
|
133
|
-
await fs.
|
|
134
|
+
const data = await fs.readFile(srcPath);
|
|
135
|
+
await fs.writeFile(destPath, data);
|
|
134
136
|
}
|
|
135
137
|
}
|
|
136
138
|
}
|
|
@@ -374,7 +376,11 @@ async function clearResourceTypeDirectories(pBaseDirectory) {
|
|
|
374
376
|
async function copyFile(pSource, pDestinationDir, pNewName) {
|
|
375
377
|
try {
|
|
376
378
|
await fs.mkdir(pDestinationDir, { recursive: true });
|
|
377
|
-
|
|
379
|
+
// Use readFile + writeFile instead of fs.copyFile to avoid macOS APFS
|
|
380
|
+
// clone operations, which emit phantom FSEvents on the source file and
|
|
381
|
+
// cause external editors (e.g. Viewer) to falsely detect modifications.
|
|
382
|
+
const data = await fs.readFile(pSource);
|
|
383
|
+
await fs.writeFile(join(pDestinationDir, pNewName), data);
|
|
378
384
|
}
|
|
379
385
|
catch (pError) {
|
|
380
386
|
logError(`[Error] Copying file ${pSource}: ${pError}`);
|
|
@@ -430,39 +436,139 @@ async function runBuild() {
|
|
|
430
436
|
*/
|
|
431
437
|
async function runWatch() {
|
|
432
438
|
await runBuild();
|
|
433
|
-
|
|
439
|
+
const pathsToWatch = [];
|
|
440
|
+
if (existsSync(resourceInDirectory)) {
|
|
441
|
+
pathsToWatch.push(resourceInDirectory);
|
|
442
|
+
}
|
|
443
|
+
const srcDir = join(projectRootDirectory, 'src');
|
|
444
|
+
if (shouldBundleApp && existsSync(srcDir) && srcDir !== resourceInDirectory) {
|
|
445
|
+
pathsToWatch.push(srcDir);
|
|
446
|
+
}
|
|
447
|
+
const displayPaths = pathsToWatch
|
|
448
|
+
.map(p => chalk.bold(relative(projectRootDirectory, p) || p))
|
|
449
|
+
.join(', ');
|
|
450
|
+
console.log(chalk.cyan(`\nWatching for changes in: ${displayPaths}`));
|
|
434
451
|
let debounceTimer = null;
|
|
452
|
+
let isRebuilding = false;
|
|
453
|
+
let queuedChange = null;
|
|
435
454
|
const triggerRebuild = (pFilename) => {
|
|
436
455
|
if (debounceTimer)
|
|
437
456
|
clearTimeout(debounceTimer);
|
|
438
457
|
debounceTimer = setTimeout(async () => {
|
|
439
|
-
|
|
440
|
-
|
|
458
|
+
if (isRebuilding) {
|
|
459
|
+
queuedChange = pFilename;
|
|
460
|
+
return;
|
|
461
|
+
}
|
|
462
|
+
isRebuilding = true;
|
|
463
|
+
try {
|
|
464
|
+
console.log(chalk.dim(`\nFile changed: ${pFilename}, rebuilding...`));
|
|
465
|
+
await runBuild();
|
|
466
|
+
}
|
|
467
|
+
finally {
|
|
468
|
+
isRebuilding = false;
|
|
469
|
+
if (queuedChange) {
|
|
470
|
+
const next = queuedChange;
|
|
471
|
+
queuedChange = null;
|
|
472
|
+
triggerRebuild(next);
|
|
473
|
+
}
|
|
474
|
+
}
|
|
441
475
|
}, 150);
|
|
442
476
|
};
|
|
443
|
-
const
|
|
444
|
-
|
|
445
|
-
const
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
477
|
+
const normalizedOutDir = resourceOutDirectory ? resourceOutDirectory.replace(/\\/g, '/') : '';
|
|
478
|
+
const isIgnored = (pPath) => {
|
|
479
|
+
const normalized = pPath.replace(/\\/g, '/');
|
|
480
|
+
// Ignore output directory
|
|
481
|
+
if (normalizedOutDir && (normalized === normalizedOutDir || normalized.startsWith(`${normalizedOutDir}/`))) {
|
|
482
|
+
return true;
|
|
483
|
+
}
|
|
484
|
+
// Ignore VCS and dependency folders
|
|
485
|
+
if (/(^|[/\\])(\.git|node_modules|\.DS_Store|Thumbs\.db)($|[/\\])/.test(normalized)) {
|
|
486
|
+
return true;
|
|
487
|
+
}
|
|
488
|
+
// Ignore vendor directory (precompiled/static vendor assets)
|
|
489
|
+
if (/(^|[/\\])vendor([/\\]|$)/.test(normalized)) {
|
|
490
|
+
return true;
|
|
491
|
+
}
|
|
492
|
+
// Ignore sourcemaps
|
|
493
|
+
if (normalized.endsWith('.map')) {
|
|
494
|
+
return true;
|
|
495
|
+
}
|
|
496
|
+
// Ignore generated manifest metadata files in project root
|
|
497
|
+
if (normalized.endsWith('resource.json') ||
|
|
498
|
+
normalized.endsWith('bounds.json') ||
|
|
499
|
+
normalized.endsWith('icon-points.json') ||
|
|
500
|
+
normalized.endsWith('sizes.json')) {
|
|
501
|
+
return true;
|
|
502
|
+
}
|
|
503
|
+
return false;
|
|
504
|
+
};
|
|
505
|
+
// Track known file modification times and sizes to eliminate phantom change events from copy/read operations
|
|
506
|
+
const fileStats = new Map();
|
|
507
|
+
const recordFileStat = async (pFilePath) => {
|
|
508
|
+
try {
|
|
509
|
+
const stats = await fs.stat(pFilePath);
|
|
510
|
+
if (stats.isFile()) {
|
|
511
|
+
fileStats.set(resolve(pFilePath), { mtime: stats.mtimeMs, size: stats.size });
|
|
512
|
+
}
|
|
513
|
+
}
|
|
514
|
+
catch {
|
|
515
|
+
// Ignored
|
|
516
|
+
}
|
|
517
|
+
};
|
|
518
|
+
const primeDirectoryStats = async (pDirPath) => {
|
|
519
|
+
try {
|
|
520
|
+
const entries = await fs.readdir(pDirPath, { withFileTypes: true });
|
|
521
|
+
for (const entry of entries) {
|
|
522
|
+
const fullPath = join(pDirPath, entry.name);
|
|
523
|
+
if (isIgnored(fullPath))
|
|
524
|
+
continue;
|
|
525
|
+
if (entry.isDirectory()) {
|
|
526
|
+
await primeDirectoryStats(fullPath);
|
|
527
|
+
}
|
|
528
|
+
else if (entry.isFile()) {
|
|
529
|
+
await recordFileStat(fullPath);
|
|
530
|
+
}
|
|
531
|
+
}
|
|
532
|
+
}
|
|
533
|
+
catch {
|
|
534
|
+
// Ignored
|
|
535
|
+
}
|
|
536
|
+
};
|
|
537
|
+
for (const p of pathsToWatch) {
|
|
538
|
+
await primeDirectoryStats(p);
|
|
462
539
|
}
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
540
|
+
const watcher = chokidarWatch(pathsToWatch, {
|
|
541
|
+
ignored: isIgnored,
|
|
542
|
+
ignoreInitial: true,
|
|
543
|
+
awaitWriteFinish: {
|
|
544
|
+
stabilityThreshold: 100,
|
|
545
|
+
pollInterval: 50
|
|
546
|
+
}
|
|
547
|
+
});
|
|
548
|
+
watcher.on('all', async (event, filePath) => {
|
|
549
|
+
if (event === 'addDir' || event === 'unlinkDir')
|
|
550
|
+
return;
|
|
551
|
+
const absPath = resolve(filePath);
|
|
552
|
+
if (event === 'unlink') {
|
|
553
|
+
fileStats.delete(absPath);
|
|
554
|
+
const relativePath = relative(projectRootDirectory, filePath).replace(/\\/g, '/');
|
|
555
|
+
triggerRebuild(relativePath);
|
|
556
|
+
return;
|
|
557
|
+
}
|
|
558
|
+
// Verify mtime or size actually changed to eliminate phantom OS events
|
|
559
|
+
const stats = await fs.stat(absPath).catch(() => null);
|
|
560
|
+
if (!stats)
|
|
561
|
+
return;
|
|
562
|
+
const prev = fileStats.get(absPath);
|
|
563
|
+
if (prev && prev.mtime === stats.mtimeMs && prev.size === stats.size) {
|
|
564
|
+
return;
|
|
565
|
+
}
|
|
566
|
+
fileStats.set(absPath, { mtime: stats.mtimeMs, size: stats.size });
|
|
567
|
+
const relativePath = relative(projectRootDirectory, filePath).replace(/\\/g, '/');
|
|
568
|
+
triggerRebuild(relativePath);
|
|
569
|
+
});
|
|
570
|
+
process.on('SIGINT', async () => {
|
|
571
|
+
await watcher.close();
|
|
466
572
|
process.exit(0);
|
|
467
573
|
});
|
|
468
574
|
}
|
package/lib/cli-runner.cjs
CHANGED