@mandujs/core 0.18.2 → 0.18.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.
- package/package.json +8 -2
- package/src/bundler/build.ts +39 -35
- package/src/bundler/css.ts +332 -302
- package/src/bundler/dev.ts +34 -3
- package/src/config/mandu.ts +1 -1
- package/src/config/validate.ts +1 -1
- package/src/contract/registry.ts +591 -568
- package/src/resource/generator.ts +5 -4
- package/src/runtime/escape.ts +12 -0
- package/src/runtime/server.ts +1 -1
- package/src/runtime/shims.ts +48 -0
- package/src/runtime/ssr.ts +29 -10
- package/src/runtime/streaming-ssr.ts +13 -0
package/src/bundler/dev.ts
CHANGED
|
@@ -428,6 +428,7 @@ export function generateHMRClientScript(port: number): string {
|
|
|
428
428
|
let reconnectAttempts = 0;
|
|
429
429
|
const maxReconnectAttempts = ${TIMEOUTS.HMR_MAX_RECONNECT};
|
|
430
430
|
const reconnectDelay = ${TIMEOUTS.HMR_RECONNECT_DELAY};
|
|
431
|
+
const staleIslands = new Set();
|
|
431
432
|
|
|
432
433
|
function connect() {
|
|
433
434
|
try {
|
|
@@ -464,8 +465,9 @@ export function generateHMRClientScript(port: number): string {
|
|
|
464
465
|
function scheduleReconnect() {
|
|
465
466
|
if (reconnectAttempts < maxReconnectAttempts) {
|
|
466
467
|
reconnectAttempts++;
|
|
467
|
-
|
|
468
|
-
|
|
468
|
+
var delay = Math.min(reconnectDelay * Math.pow(2, reconnectAttempts - 1), 30000);
|
|
469
|
+
console.log('[Mandu HMR] Reconnecting in ' + delay + 'ms (' + reconnectAttempts + '/' + maxReconnectAttempts + ')');
|
|
470
|
+
setTimeout(connect, delay);
|
|
469
471
|
}
|
|
470
472
|
}
|
|
471
473
|
|
|
@@ -483,6 +485,7 @@ export function generateHMRClientScript(port: number): string {
|
|
|
483
485
|
case 'island-update':
|
|
484
486
|
const routeId = message.data?.routeId;
|
|
485
487
|
console.log('[Mandu HMR] Island updated:', routeId);
|
|
488
|
+
staleIslands.add(routeId);
|
|
486
489
|
|
|
487
490
|
// 현재 페이지의 island인지 확인
|
|
488
491
|
const island = document.querySelector('[data-mandu-island="' + routeId + '"]');
|
|
@@ -533,7 +536,19 @@ export function generateHMRClientScript(port: number): string {
|
|
|
533
536
|
const overlay = document.createElement('div');
|
|
534
537
|
overlay.id = 'mandu-hmr-error';
|
|
535
538
|
overlay.style.cssText = 'position:fixed;top:0;left:0;right:0;bottom:0;background:rgba(0,0,0,0.9);color:#ff6b6b;font-family:monospace;padding:40px;z-index:99999;overflow:auto;';
|
|
536
|
-
|
|
539
|
+
const h2 = document.createElement('h2');
|
|
540
|
+
h2.style.cssText = 'color:#ff6b6b;margin:0 0 20px;';
|
|
541
|
+
h2.textContent = '🔥 Build Error';
|
|
542
|
+
const pre = document.createElement('pre');
|
|
543
|
+
pre.style.cssText = 'white-space:pre-wrap;word-break:break-all;';
|
|
544
|
+
pre.textContent = message || 'Unknown error';
|
|
545
|
+
const btn = document.createElement('button');
|
|
546
|
+
btn.style.cssText = 'position:fixed;top:20px;right:20px;background:#333;color:#fff;border:none;padding:10px 20px;cursor:pointer;';
|
|
547
|
+
btn.textContent = 'Close';
|
|
548
|
+
btn.onclick = function() { overlay.remove(); };
|
|
549
|
+
overlay.appendChild(h2);
|
|
550
|
+
overlay.appendChild(pre);
|
|
551
|
+
overlay.appendChild(btn);
|
|
537
552
|
document.body.appendChild(overlay);
|
|
538
553
|
}
|
|
539
554
|
|
|
@@ -549,6 +564,22 @@ export function generateHMRClientScript(port: number): string {
|
|
|
549
564
|
if (ws) ws.close();
|
|
550
565
|
});
|
|
551
566
|
|
|
567
|
+
// 페이지 이동 시 stale island 감지 후 리로드 (#115)
|
|
568
|
+
function checkStaleIslandsOnNavigation() {
|
|
569
|
+
if (staleIslands.size === 0) return;
|
|
570
|
+
for (const id of staleIslands) {
|
|
571
|
+
if (document.querySelector('[data-mandu-island="' + id + '"]')) {
|
|
572
|
+
console.log('[Mandu HMR] Stale island detected after navigation, reloading...');
|
|
573
|
+
location.reload();
|
|
574
|
+
return;
|
|
575
|
+
}
|
|
576
|
+
}
|
|
577
|
+
}
|
|
578
|
+
window.addEventListener('popstate', checkStaleIslandsOnNavigation);
|
|
579
|
+
window.addEventListener('pageshow', function(e) {
|
|
580
|
+
if (e.persisted) checkStaleIslandsOnNavigation();
|
|
581
|
+
});
|
|
582
|
+
|
|
552
583
|
// Ping 전송 (연결 유지)
|
|
553
584
|
setInterval(function() {
|
|
554
585
|
if (ws && ws.readyState === WebSocket.OPEN) {
|
package/src/config/mandu.ts
CHANGED
package/src/config/validate.ts
CHANGED
|
@@ -71,7 +71,7 @@ const ServerConfigSchema = z
|
|
|
71
71
|
*/
|
|
72
72
|
const GuardConfigSchema = z
|
|
73
73
|
.object({
|
|
74
|
-
preset: z.enum(["mandu", "fsd", "clean", "hexagonal", "atomic"]).default("mandu"),
|
|
74
|
+
preset: z.enum(["mandu", "fsd", "clean", "hexagonal", "atomic", "cqrs"]).default("mandu"),
|
|
75
75
|
srcDir: z.string().default("src"),
|
|
76
76
|
exclude: z.array(z.string()).default([]),
|
|
77
77
|
realtime: z.boolean().default(true),
|