juxscript 1.1.74 → 1.1.75
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/dom-structure-map.json +1 -1
- package/machinery/compiler3.js +2 -2
- package/machinery/serve.js +65 -5
- package/package.json +1 -1
package/dom-structure-map.json
CHANGED
package/machinery/compiler3.js
CHANGED
|
@@ -507,8 +507,8 @@ navigate(location.pathname);
|
|
|
507
507
|
*/
|
|
508
508
|
copyPublicFolder() {
|
|
509
509
|
// ✅ Use configured public path or resolve from paths object
|
|
510
|
-
const publicSrc = this.paths.public
|
|
511
|
-
? this.paths.public
|
|
510
|
+
const publicSrc = this.paths.public
|
|
511
|
+
? this.paths.public
|
|
512
512
|
: path.resolve(process.cwd(), this.publicDir);
|
|
513
513
|
|
|
514
514
|
if (!fs.existsSync(publicSrc)) {
|
package/machinery/serve.js
CHANGED
|
@@ -29,10 +29,36 @@ function getArgValue(flag, shortFlag, defaultValue) {
|
|
|
29
29
|
const PORT = parseInt(getArgValue('--port', '-p', process.env.PORT || '3000'));
|
|
30
30
|
const WS_PORT = parseInt(getArgValue('--ws-port', '-w', process.env.WS_PORT || String(PORT + 1)));
|
|
31
31
|
|
|
32
|
-
//
|
|
32
|
+
// ✅ Load juxconfig.js to get configured paths
|
|
33
33
|
const PROJECT_ROOT = process.cwd();
|
|
34
|
-
const
|
|
35
|
-
|
|
34
|
+
const JUX_CONFIG_PATH = path.resolve(PROJECT_ROOT, 'juxconfig.js');
|
|
35
|
+
|
|
36
|
+
let rawConfig = {};
|
|
37
|
+
try {
|
|
38
|
+
const imported = await import(JUX_CONFIG_PATH);
|
|
39
|
+
rawConfig = imported.config || {};
|
|
40
|
+
console.log(`⚙️ Loaded config: ${JUX_CONFIG_PATH}`);
|
|
41
|
+
} catch (err) {
|
|
42
|
+
console.warn(`⚠️ No juxconfig.js found, using defaults`);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
// ✅ Extract configured directories
|
|
46
|
+
const directories = {
|
|
47
|
+
source: rawConfig.directories?.source || './jux',
|
|
48
|
+
distribution: rawConfig.directories?.distribution || './.jux-dist',
|
|
49
|
+
public: rawConfig.directories?.public || './public'
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
// ✅ Resolve absolute paths
|
|
53
|
+
const paths = {
|
|
54
|
+
source: path.resolve(PROJECT_ROOT, directories.source),
|
|
55
|
+
distribution: path.resolve(PROJECT_ROOT, directories.distribution),
|
|
56
|
+
public: path.resolve(PROJECT_ROOT, directories.public)
|
|
57
|
+
};
|
|
58
|
+
|
|
59
|
+
// Resolve paths relative to CWD (user's project)
|
|
60
|
+
const DIST_DIR = paths.distribution;
|
|
61
|
+
const SRC_DIR = paths.source;
|
|
36
62
|
|
|
37
63
|
const app = express();
|
|
38
64
|
let lastBuildResult = { success: true, errors: [] };
|
|
@@ -43,7 +69,9 @@ if (!fs.existsSync(DIST_DIR) || !fs.existsSync(path.join(DIST_DIR, 'index.html')
|
|
|
43
69
|
|
|
44
70
|
const compiler = new JuxCompiler({
|
|
45
71
|
srcDir: SRC_DIR,
|
|
46
|
-
distDir: DIST_DIR
|
|
72
|
+
distDir: DIST_DIR,
|
|
73
|
+
publicDir: directories.public, // ✅ Pass configured name
|
|
74
|
+
paths // ✅ Pass resolved paths
|
|
47
75
|
});
|
|
48
76
|
|
|
49
77
|
try {
|
|
@@ -199,7 +227,9 @@ if (HOT_RELOAD) {
|
|
|
199
227
|
|
|
200
228
|
const compiler = new JuxCompiler({
|
|
201
229
|
srcDir: SRC_DIR,
|
|
202
|
-
distDir: DIST_DIR
|
|
230
|
+
distDir: DIST_DIR,
|
|
231
|
+
publicDir: directories.public, // ✅ Pass configured name
|
|
232
|
+
paths // ✅ Pass resolved paths
|
|
203
233
|
});
|
|
204
234
|
|
|
205
235
|
watcher = createWatcher(SRC_DIR, {
|
|
@@ -228,6 +258,36 @@ if (HOT_RELOAD) {
|
|
|
228
258
|
console.log(`👀 Watching: ${SRC_DIR}`);
|
|
229
259
|
}
|
|
230
260
|
});
|
|
261
|
+
|
|
262
|
+
// ✅ ALSO watch public/ directory if it exists
|
|
263
|
+
if (fs.existsSync(paths.public)) {
|
|
264
|
+
console.log(`👀 Watching public assets: ${paths.public}`);
|
|
265
|
+
|
|
266
|
+
const publicWatcher = createWatcher(paths.public, {
|
|
267
|
+
onChange: async (changedFiles) => {
|
|
268
|
+
console.log('📦 Public asset changed, copying...');
|
|
269
|
+
|
|
270
|
+
try {
|
|
271
|
+
// Just copy public folder, don't rebuild everything
|
|
272
|
+
compiler.copyPublicFolder();
|
|
273
|
+
console.log('✅ Public assets updated');
|
|
274
|
+
broadcast({ type: 'reload', files: changedFiles });
|
|
275
|
+
} catch (err) {
|
|
276
|
+
console.warn('⚠️ Error copying public assets:', err.message);
|
|
277
|
+
}
|
|
278
|
+
},
|
|
279
|
+
onReady: () => {
|
|
280
|
+
// Silent, already logged main watcher
|
|
281
|
+
}
|
|
282
|
+
});
|
|
283
|
+
|
|
284
|
+
// ✅ Store reference for cleanup
|
|
285
|
+
const originalShutdown = shutdown;
|
|
286
|
+
shutdown = () => {
|
|
287
|
+
if (publicWatcher) publicWatcher.close();
|
|
288
|
+
originalShutdown();
|
|
289
|
+
};
|
|
290
|
+
}
|
|
231
291
|
}
|
|
232
292
|
|
|
233
293
|
server.listen(PORT, () => {
|