@useavalon/avalon 0.1.13 → 0.1.15
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/mod.js +1 -0
- package/dist/src/build/integration-bundler-plugin.js +1 -0
- package/dist/src/build/integration-config.js +1 -0
- package/dist/src/build/integration-detection-plugin.js +1 -0
- package/dist/src/build/integration-resolver-plugin.js +1 -0
- package/dist/src/build/island-manifest.js +1 -0
- package/dist/src/build/island-types-generator.js +5 -0
- package/dist/src/build/mdx-island-transform.js +2 -0
- package/dist/src/build/mdx-plugin.js +1 -0
- package/dist/src/build/page-island-transform.js +3 -0
- package/dist/src/build/prop-extractors/index.js +1 -0
- package/dist/src/build/prop-extractors/lit.js +1 -0
- package/dist/src/build/prop-extractors/qwik.js +1 -0
- package/dist/src/build/prop-extractors/solid.js +1 -0
- package/dist/src/build/prop-extractors/svelte.js +1 -0
- package/dist/src/build/prop-extractors/vue.js +1 -0
- package/dist/src/build/sidecar-file-manager.js +1 -0
- package/dist/src/build/sidecar-renderer.js +6 -0
- package/dist/src/client/adapters/index.js +1 -0
- package/dist/src/client/components.js +1 -0
- package/dist/src/client/css-hmr-handler.js +1 -0
- package/dist/src/client/framework-adapter.js +13 -0
- package/dist/src/client/hmr-coordinator.js +1 -0
- package/dist/src/client/hmr-error-overlay.js +214 -0
- package/dist/src/client/main.js +39 -0
- package/dist/src/components/Image.js +1 -0
- package/dist/src/components/IslandErrorBoundary.js +1 -0
- package/dist/src/components/LayoutDataErrorBoundary.js +1 -0
- package/dist/src/components/LayoutErrorBoundary.js +1 -0
- package/dist/src/components/PersistentIsland.js +1 -0
- package/dist/src/components/StreamingErrorBoundary.js +1 -0
- package/dist/src/components/StreamingLayout.js +29 -0
- package/dist/src/core/components/component-analyzer.js +1 -0
- package/dist/src/core/components/component-detection.js +5 -0
- package/dist/src/core/components/enhanced-framework-detector.js +1 -0
- package/dist/src/core/components/framework-registry.js +1 -0
- package/dist/src/core/content/mdx-processor.js +1 -0
- package/dist/src/core/integrations/index.js +1 -0
- package/dist/src/core/integrations/loader.js +1 -0
- package/dist/src/core/integrations/registry.js +1 -0
- package/dist/src/core/islands/island-persistence.js +1 -0
- package/dist/src/core/islands/island-state-serializer.js +1 -0
- package/dist/src/core/islands/persistent-island-context.js +1 -0
- package/dist/src/core/islands/use-persistent-state.js +1 -0
- package/dist/src/core/layout/enhanced-layout-resolver.js +1 -0
- package/dist/src/core/layout/layout-cache-manager.js +1 -0
- package/dist/src/core/layout/layout-composer.js +1 -0
- package/dist/src/core/layout/layout-data-loader.js +1 -0
- package/dist/src/core/layout/layout-discovery.js +1 -0
- package/dist/src/core/layout/layout-matcher.js +1 -0
- package/dist/src/core/layout/layout-types.js +1 -0
- package/dist/src/core/modules/framework-module-resolver.js +1 -0
- package/dist/src/islands/component-analysis.js +1 -0
- package/dist/src/islands/css-utils.js +17 -0
- package/dist/src/islands/discovery/index.js +1 -0
- package/dist/src/islands/discovery/registry.js +1 -0
- package/dist/src/islands/discovery/resolver.js +2 -0
- package/dist/src/islands/discovery/scanner.js +1 -0
- package/dist/src/islands/discovery/types.js +1 -0
- package/dist/src/islands/discovery/validator.js +18 -0
- package/dist/src/islands/discovery/watcher.js +1 -0
- package/dist/src/islands/framework-detection.js +1 -0
- package/dist/src/islands/integration-loader.js +1 -0
- package/dist/src/islands/island.js +1 -0
- package/dist/src/islands/render-cache.js +1 -0
- package/dist/src/islands/types.js +1 -0
- package/dist/src/islands/universal-css-collector.js +5 -0
- package/dist/src/islands/universal-head-collector.js +2 -0
- package/dist/src/layout-system.js +1 -0
- package/dist/src/middleware/discovery.js +1 -0
- package/dist/src/middleware/executor.js +1 -0
- package/dist/src/middleware/index.js +1 -0
- package/dist/src/middleware/types.js +1 -0
- package/dist/src/nitro/build-config.js +1 -0
- package/dist/src/nitro/config.js +1 -0
- package/dist/src/nitro/error-handler.js +198 -0
- package/dist/src/nitro/index.js +1 -0
- package/dist/src/nitro/island-manifest.js +2 -0
- package/dist/src/nitro/middleware-adapter.js +1 -0
- package/dist/src/nitro/renderer.js +183 -0
- package/dist/src/nitro/route-discovery.js +1 -0
- package/dist/src/nitro/types.js +1 -0
- package/dist/src/render/collect-css.js +3 -0
- package/dist/src/render/error-pages.js +48 -0
- package/dist/src/render/isolated-ssr-renderer.js +1 -0
- package/dist/src/render/ssr.js +90 -0
- package/dist/src/schemas/api.js +1 -0
- package/dist/src/schemas/core.js +1 -0
- package/dist/src/schemas/index.js +1 -0
- package/dist/src/schemas/layout.js +1 -0
- package/dist/src/schemas/routing/index.js +1 -0
- package/dist/src/schemas/routing.js +1 -0
- package/dist/src/types/as-island.js +1 -0
- package/dist/src/types/layout.js +1 -0
- package/dist/src/types/routing.js +1 -0
- package/dist/src/types/types.js +1 -0
- package/dist/src/utils/dev-logger.js +12 -0
- package/dist/src/utils/fs.js +1 -0
- package/dist/src/vite-plugin/auto-discover.js +1 -0
- package/dist/src/vite-plugin/config.js +1 -0
- package/dist/src/vite-plugin/errors.js +1 -0
- package/dist/src/vite-plugin/image-optimization.js +45 -0
- package/dist/src/vite-plugin/integration-activator.js +1 -0
- package/dist/src/vite-plugin/island-sidecar-plugin.js +1 -0
- package/dist/src/vite-plugin/module-discovery.js +1 -0
- package/dist/src/vite-plugin/nitro-integration.js +42 -0
- package/dist/src/vite-plugin/plugin.js +1 -0
- package/dist/src/vite-plugin/types.js +1 -0
- package/dist/src/vite-plugin/validation.js +2 -0
- package/package.json +14 -20
- package/mod.ts +0 -302
- package/src/build/integration-bundler-plugin.ts +0 -116
- package/src/build/integration-config.ts +0 -168
- package/src/build/integration-detection-plugin.ts +0 -117
- package/src/build/integration-resolver-plugin.ts +0 -90
- package/src/build/island-manifest.ts +0 -269
- package/src/build/island-types-generator.ts +0 -476
- package/src/build/mdx-island-transform.ts +0 -464
- package/src/build/mdx-plugin.ts +0 -98
- package/src/build/page-island-transform.ts +0 -598
- package/src/build/prop-extractors/index.ts +0 -21
- package/src/build/prop-extractors/lit.ts +0 -140
- package/src/build/prop-extractors/qwik.ts +0 -16
- package/src/build/prop-extractors/solid.ts +0 -125
- package/src/build/prop-extractors/svelte.ts +0 -194
- package/src/build/prop-extractors/vue.ts +0 -111
- package/src/build/sidecar-file-manager.ts +0 -104
- package/src/build/sidecar-renderer.ts +0 -30
- package/src/client/adapters/index.ts +0 -21
- package/src/client/components.ts +0 -35
- package/src/client/css-hmr-handler.ts +0 -344
- package/src/client/framework-adapter.ts +0 -462
- package/src/client/hmr-coordinator.ts +0 -396
- package/src/client/hmr-error-overlay.js +0 -533
- package/src/client/main.js +0 -824
- package/src/components/Image.tsx +0 -123
- package/src/components/IslandErrorBoundary.tsx +0 -145
- package/src/components/LayoutDataErrorBoundary.tsx +0 -141
- package/src/components/LayoutErrorBoundary.tsx +0 -127
- package/src/components/PersistentIsland.tsx +0 -52
- package/src/components/StreamingErrorBoundary.tsx +0 -233
- package/src/components/StreamingLayout.tsx +0 -538
- package/src/core/components/component-analyzer.ts +0 -192
- package/src/core/components/component-detection.ts +0 -508
- package/src/core/components/enhanced-framework-detector.ts +0 -500
- package/src/core/components/framework-registry.ts +0 -563
- package/src/core/content/mdx-processor.ts +0 -46
- package/src/core/integrations/index.ts +0 -19
- package/src/core/integrations/loader.ts +0 -125
- package/src/core/integrations/registry.ts +0 -175
- package/src/core/islands/island-persistence.ts +0 -325
- package/src/core/islands/island-state-serializer.ts +0 -258
- package/src/core/islands/persistent-island-context.tsx +0 -80
- package/src/core/islands/use-persistent-state.ts +0 -68
- package/src/core/layout/enhanced-layout-resolver.ts +0 -322
- package/src/core/layout/layout-cache-manager.ts +0 -485
- package/src/core/layout/layout-composer.ts +0 -357
- package/src/core/layout/layout-data-loader.ts +0 -516
- package/src/core/layout/layout-discovery.ts +0 -243
- package/src/core/layout/layout-matcher.ts +0 -299
- package/src/core/layout/layout-types.ts +0 -110
- package/src/core/modules/framework-module-resolver.ts +0 -273
- package/src/islands/component-analysis.ts +0 -213
- package/src/islands/css-utils.ts +0 -565
- package/src/islands/discovery/index.ts +0 -80
- package/src/islands/discovery/registry.ts +0 -340
- package/src/islands/discovery/resolver.ts +0 -477
- package/src/islands/discovery/scanner.ts +0 -386
- package/src/islands/discovery/types.ts +0 -117
- package/src/islands/discovery/validator.ts +0 -544
- package/src/islands/discovery/watcher.ts +0 -368
- package/src/islands/framework-detection.ts +0 -428
- package/src/islands/integration-loader.ts +0 -490
- package/src/islands/island.tsx +0 -565
- package/src/islands/render-cache.ts +0 -550
- package/src/islands/types.ts +0 -80
- package/src/islands/universal-css-collector.ts +0 -157
- package/src/islands/universal-head-collector.ts +0 -137
- package/src/layout-system.ts +0 -218
- package/src/middleware/discovery.ts +0 -268
- package/src/middleware/executor.ts +0 -315
- package/src/middleware/index.ts +0 -76
- package/src/middleware/types.ts +0 -99
- package/src/nitro/build-config.ts +0 -576
- package/src/nitro/config.ts +0 -483
- package/src/nitro/error-handler.ts +0 -636
- package/src/nitro/index.ts +0 -173
- package/src/nitro/island-manifest.ts +0 -584
- package/src/nitro/middleware-adapter.ts +0 -260
- package/src/nitro/renderer.ts +0 -1471
- package/src/nitro/route-discovery.ts +0 -439
- package/src/nitro/types.ts +0 -321
- package/src/render/collect-css.ts +0 -198
- package/src/render/error-pages.ts +0 -79
- package/src/render/isolated-ssr-renderer.ts +0 -654
- package/src/render/ssr.ts +0 -1030
- package/src/schemas/api.ts +0 -30
- package/src/schemas/core.ts +0 -64
- package/src/schemas/index.ts +0 -212
- package/src/schemas/layout.ts +0 -279
- package/src/schemas/routing/index.ts +0 -38
- package/src/schemas/routing.ts +0 -376
- package/src/types/as-island.ts +0 -20
- package/src/types/layout.ts +0 -285
- package/src/types/routing.ts +0 -555
- package/src/types/types.ts +0 -5
- package/src/utils/dev-logger.ts +0 -299
- package/src/utils/fs.ts +0 -151
- package/src/vite-plugin/auto-discover.ts +0 -551
- package/src/vite-plugin/config.ts +0 -266
- package/src/vite-plugin/errors.ts +0 -127
- package/src/vite-plugin/image-optimization.ts +0 -156
- package/src/vite-plugin/integration-activator.ts +0 -126
- package/src/vite-plugin/island-sidecar-plugin.ts +0 -176
- package/src/vite-plugin/module-discovery.ts +0 -189
- package/src/vite-plugin/nitro-integration.ts +0 -1354
- package/src/vite-plugin/plugin.ts +0 -403
- package/src/vite-plugin/types.ts +0 -327
- package/src/vite-plugin/validation.ts +0 -228
- /package/{src → dist/src}/client/types/framework-runtime.d.ts +0 -0
- /package/{src → dist/src}/client/types/vite-hmr.d.ts +0 -0
- /package/{src → dist/src}/client/types/vite-virtual-modules.d.ts +0 -0
- /package/{src → dist/src}/layout-system.d.ts +0 -0
- /package/{src → dist/src}/types/image.d.ts +0 -0
- /package/{src → dist/src}/types/index.d.ts +0 -0
- /package/{src → dist/src}/types/island-jsx.d.ts +0 -0
- /package/{src → dist/src}/types/island-prop.d.ts +0 -0
- /package/{src → dist/src}/types/mdx.d.ts +0 -0
- /package/{src → dist/src}/types/urlpattern.d.ts +0 -0
- /package/{src → dist/src}/types/vite-env.d.ts +0 -0
|
@@ -1,533 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* HMR Error Overlay
|
|
3
|
-
*
|
|
4
|
-
* Provides detailed error feedback when HMR fails for island components.
|
|
5
|
-
* Displays file paths, error details, and suggestions for fixing issues.
|
|
6
|
-
*/
|
|
7
|
-
|
|
8
|
-
/**
|
|
9
|
-
* Create and show the HMR error overlay
|
|
10
|
-
* @param {Object} options - Error options
|
|
11
|
-
* @param {string} options.framework - The framework name
|
|
12
|
-
* @param {string} options.src - The component source path
|
|
13
|
-
* @param {Error} options.error - The error that occurred
|
|
14
|
-
* @param {string} [options.filePath] - The full file path (if available)
|
|
15
|
-
* @param {number} [options.line] - The line number (if available)
|
|
16
|
-
* @param {number} [options.column] - The column number (if available)
|
|
17
|
-
*/
|
|
18
|
-
export function showHMRErrorOverlay({ framework, src, error, filePath, line, column }) {
|
|
19
|
-
// Remove existing overlay
|
|
20
|
-
removeHMRErrorOverlay();
|
|
21
|
-
|
|
22
|
-
const overlay = document.createElement('div');
|
|
23
|
-
overlay.id = 'avalon-hmr-error-overlay';
|
|
24
|
-
overlay.style.cssText = `
|
|
25
|
-
position: fixed;
|
|
26
|
-
top: 0;
|
|
27
|
-
left: 0;
|
|
28
|
-
right: 0;
|
|
29
|
-
bottom: 0;
|
|
30
|
-
background: rgba(0, 0, 0, 0.85);
|
|
31
|
-
z-index: 99999;
|
|
32
|
-
display: flex;
|
|
33
|
-
align-items: center;
|
|
34
|
-
justify-content: center;
|
|
35
|
-
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
|
|
36
|
-
backdrop-filter: blur(4px);
|
|
37
|
-
`;
|
|
38
|
-
|
|
39
|
-
const container = document.createElement('div');
|
|
40
|
-
container.style.cssText = `
|
|
41
|
-
background: #1a1a2e;
|
|
42
|
-
border-radius: 12px;
|
|
43
|
-
max-width: 700px;
|
|
44
|
-
width: 90%;
|
|
45
|
-
max-height: 80vh;
|
|
46
|
-
overflow: auto;
|
|
47
|
-
box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
|
|
48
|
-
border: 1px solid rgba(255, 255, 255, 0.1);
|
|
49
|
-
`;
|
|
50
|
-
|
|
51
|
-
// Header
|
|
52
|
-
const header = document.createElement('div');
|
|
53
|
-
header.style.cssText = `
|
|
54
|
-
background: linear-gradient(135deg, #e74c3c, #c0392b);
|
|
55
|
-
padding: 16px 20px;
|
|
56
|
-
display: flex;
|
|
57
|
-
align-items: center;
|
|
58
|
-
justify-content: space-between;
|
|
59
|
-
border-radius: 12px 12px 0 0;
|
|
60
|
-
`;
|
|
61
|
-
|
|
62
|
-
const title = document.createElement('div');
|
|
63
|
-
title.style.cssText = `
|
|
64
|
-
display: flex;
|
|
65
|
-
align-items: center;
|
|
66
|
-
gap: 10px;
|
|
67
|
-
color: white;
|
|
68
|
-
font-weight: 600;
|
|
69
|
-
font-size: 16px;
|
|
70
|
-
`;
|
|
71
|
-
title.innerHTML = `
|
|
72
|
-
<span style="font-size: 20px;">⚠️</span>
|
|
73
|
-
<span>HMR Update Failed</span>
|
|
74
|
-
`;
|
|
75
|
-
|
|
76
|
-
const closeBtn = document.createElement('button');
|
|
77
|
-
closeBtn.style.cssText = `
|
|
78
|
-
background: rgba(255, 255, 255, 0.2);
|
|
79
|
-
border: none;
|
|
80
|
-
color: white;
|
|
81
|
-
width: 28px;
|
|
82
|
-
height: 28px;
|
|
83
|
-
border-radius: 6px;
|
|
84
|
-
cursor: pointer;
|
|
85
|
-
font-size: 18px;
|
|
86
|
-
display: flex;
|
|
87
|
-
align-items: center;
|
|
88
|
-
justify-content: center;
|
|
89
|
-
transition: background 0.2s;
|
|
90
|
-
`;
|
|
91
|
-
closeBtn.textContent = '×';
|
|
92
|
-
closeBtn.onmouseover = () => closeBtn.style.background = 'rgba(255, 255, 255, 0.3)';
|
|
93
|
-
closeBtn.onmouseout = () => closeBtn.style.background = 'rgba(255, 255, 255, 0.2)';
|
|
94
|
-
closeBtn.onclick = removeHMRErrorOverlay;
|
|
95
|
-
|
|
96
|
-
header.appendChild(title);
|
|
97
|
-
header.appendChild(closeBtn);
|
|
98
|
-
|
|
99
|
-
// Content
|
|
100
|
-
const content = document.createElement('div');
|
|
101
|
-
content.style.cssText = `
|
|
102
|
-
padding: 20px;
|
|
103
|
-
color: #e0e0e0;
|
|
104
|
-
`;
|
|
105
|
-
|
|
106
|
-
// File info section
|
|
107
|
-
const fileInfo = document.createElement('div');
|
|
108
|
-
fileInfo.style.cssText = `
|
|
109
|
-
background: rgba(255, 255, 255, 0.05);
|
|
110
|
-
border-radius: 8px;
|
|
111
|
-
padding: 12px 16px;
|
|
112
|
-
margin-bottom: 16px;
|
|
113
|
-
font-family: 'SF Mono', Monaco, 'Cascadia Code', monospace;
|
|
114
|
-
font-size: 13px;
|
|
115
|
-
`;
|
|
116
|
-
|
|
117
|
-
const displayPath = filePath || src;
|
|
118
|
-
const locationInfo = line ? `:${line}${column ? `:${column}` : ''}` : '';
|
|
119
|
-
|
|
120
|
-
fileInfo.innerHTML = `
|
|
121
|
-
<div style="color: #888; font-size: 11px; text-transform: uppercase; letter-spacing: 0.5px; margin-bottom: 6px;">
|
|
122
|
-
Component
|
|
123
|
-
</div>
|
|
124
|
-
<div style="color: #61dafb; word-break: break-all;">
|
|
125
|
-
${escapeHtml(displayPath)}${locationInfo}
|
|
126
|
-
</div>
|
|
127
|
-
<div style="margin-top: 8px; color: #888; font-size: 11px; text-transform: uppercase; letter-spacing: 0.5px; margin-bottom: 6px;">
|
|
128
|
-
Framework
|
|
129
|
-
</div>
|
|
130
|
-
<div style="color: #a78bfa;">
|
|
131
|
-
${escapeHtml(framework)}
|
|
132
|
-
</div>
|
|
133
|
-
`;
|
|
134
|
-
|
|
135
|
-
// Error message section
|
|
136
|
-
const errorSection = document.createElement('div');
|
|
137
|
-
errorSection.style.cssText = `
|
|
138
|
-
margin-bottom: 16px;
|
|
139
|
-
`;
|
|
140
|
-
|
|
141
|
-
const errorLabel = document.createElement('div');
|
|
142
|
-
errorLabel.style.cssText = `
|
|
143
|
-
color: #888;
|
|
144
|
-
font-size: 11px;
|
|
145
|
-
text-transform: uppercase;
|
|
146
|
-
letter-spacing: 0.5px;
|
|
147
|
-
margin-bottom: 8px;
|
|
148
|
-
`;
|
|
149
|
-
errorLabel.textContent = 'Error Message';
|
|
150
|
-
|
|
151
|
-
const errorMessage = document.createElement('div');
|
|
152
|
-
errorMessage.style.cssText = `
|
|
153
|
-
background: rgba(231, 76, 60, 0.1);
|
|
154
|
-
border: 1px solid rgba(231, 76, 60, 0.3);
|
|
155
|
-
border-radius: 8px;
|
|
156
|
-
padding: 12px 16px;
|
|
157
|
-
color: #ff6b6b;
|
|
158
|
-
font-family: 'SF Mono', Monaco, 'Cascadia Code', monospace;
|
|
159
|
-
font-size: 13px;
|
|
160
|
-
white-space: pre-wrap;
|
|
161
|
-
word-break: break-word;
|
|
162
|
-
`;
|
|
163
|
-
errorMessage.textContent = error.message || String(error);
|
|
164
|
-
|
|
165
|
-
errorSection.appendChild(errorLabel);
|
|
166
|
-
errorSection.appendChild(errorMessage);
|
|
167
|
-
|
|
168
|
-
// Stack trace section (if available)
|
|
169
|
-
if (error.stack) {
|
|
170
|
-
const stackSection = document.createElement('div');
|
|
171
|
-
stackSection.style.cssText = `
|
|
172
|
-
margin-bottom: 16px;
|
|
173
|
-
`;
|
|
174
|
-
|
|
175
|
-
const stackLabel = document.createElement('div');
|
|
176
|
-
stackLabel.style.cssText = `
|
|
177
|
-
color: #888;
|
|
178
|
-
font-size: 11px;
|
|
179
|
-
text-transform: uppercase;
|
|
180
|
-
letter-spacing: 0.5px;
|
|
181
|
-
margin-bottom: 8px;
|
|
182
|
-
display: flex;
|
|
183
|
-
align-items: center;
|
|
184
|
-
justify-content: space-between;
|
|
185
|
-
`;
|
|
186
|
-
|
|
187
|
-
const stackLabelText = document.createElement('span');
|
|
188
|
-
stackLabelText.textContent = 'Stack Trace';
|
|
189
|
-
|
|
190
|
-
const toggleBtn = document.createElement('button');
|
|
191
|
-
toggleBtn.style.cssText = `
|
|
192
|
-
background: rgba(255, 255, 255, 0.1);
|
|
193
|
-
border: none;
|
|
194
|
-
color: #888;
|
|
195
|
-
padding: 4px 8px;
|
|
196
|
-
border-radius: 4px;
|
|
197
|
-
cursor: pointer;
|
|
198
|
-
font-size: 11px;
|
|
199
|
-
`;
|
|
200
|
-
toggleBtn.textContent = 'Show';
|
|
201
|
-
|
|
202
|
-
stackLabel.appendChild(stackLabelText);
|
|
203
|
-
stackLabel.appendChild(toggleBtn);
|
|
204
|
-
|
|
205
|
-
const stackTrace = document.createElement('div');
|
|
206
|
-
stackTrace.style.cssText = `
|
|
207
|
-
background: rgba(0, 0, 0, 0.3);
|
|
208
|
-
border-radius: 8px;
|
|
209
|
-
padding: 12px 16px;
|
|
210
|
-
color: #888;
|
|
211
|
-
font-family: 'SF Mono', Monaco, 'Cascadia Code', monospace;
|
|
212
|
-
font-size: 11px;
|
|
213
|
-
white-space: pre-wrap;
|
|
214
|
-
word-break: break-word;
|
|
215
|
-
max-height: 200px;
|
|
216
|
-
overflow: auto;
|
|
217
|
-
display: none;
|
|
218
|
-
`;
|
|
219
|
-
stackTrace.textContent = formatStackTrace(error.stack);
|
|
220
|
-
|
|
221
|
-
toggleBtn.onclick = () => {
|
|
222
|
-
const isHidden = stackTrace.style.display === 'none';
|
|
223
|
-
stackTrace.style.display = isHidden ? 'block' : 'none';
|
|
224
|
-
toggleBtn.textContent = isHidden ? 'Hide' : 'Show';
|
|
225
|
-
};
|
|
226
|
-
|
|
227
|
-
stackSection.appendChild(stackLabel);
|
|
228
|
-
stackSection.appendChild(stackTrace);
|
|
229
|
-
content.appendChild(stackSection);
|
|
230
|
-
}
|
|
231
|
-
|
|
232
|
-
// Suggestions section
|
|
233
|
-
const suggestions = getSuggestions(error, framework);
|
|
234
|
-
if (suggestions.length > 0) {
|
|
235
|
-
const suggestionsSection = document.createElement('div');
|
|
236
|
-
suggestionsSection.style.cssText = `
|
|
237
|
-
background: rgba(46, 204, 113, 0.1);
|
|
238
|
-
border: 1px solid rgba(46, 204, 113, 0.3);
|
|
239
|
-
border-radius: 8px;
|
|
240
|
-
padding: 12px 16px;
|
|
241
|
-
`;
|
|
242
|
-
|
|
243
|
-
const suggestionsLabel = document.createElement('div');
|
|
244
|
-
suggestionsLabel.style.cssText = `
|
|
245
|
-
color: #2ecc71;
|
|
246
|
-
font-size: 12px;
|
|
247
|
-
font-weight: 600;
|
|
248
|
-
margin-bottom: 8px;
|
|
249
|
-
display: flex;
|
|
250
|
-
align-items: center;
|
|
251
|
-
gap: 6px;
|
|
252
|
-
`;
|
|
253
|
-
suggestionsLabel.innerHTML = '<span>💡</span><span>Suggestions</span>';
|
|
254
|
-
|
|
255
|
-
const suggestionsList = document.createElement('ul');
|
|
256
|
-
suggestionsList.style.cssText = `
|
|
257
|
-
margin: 0;
|
|
258
|
-
padding-left: 20px;
|
|
259
|
-
color: #a0a0a0;
|
|
260
|
-
font-size: 13px;
|
|
261
|
-
line-height: 1.6;
|
|
262
|
-
`;
|
|
263
|
-
|
|
264
|
-
for (const suggestion of suggestions) {
|
|
265
|
-
const li = document.createElement('li');
|
|
266
|
-
li.textContent = suggestion;
|
|
267
|
-
suggestionsList.appendChild(li);
|
|
268
|
-
}
|
|
269
|
-
|
|
270
|
-
suggestionsSection.appendChild(suggestionsLabel);
|
|
271
|
-
suggestionsSection.appendChild(suggestionsList);
|
|
272
|
-
content.appendChild(suggestionsSection);
|
|
273
|
-
}
|
|
274
|
-
|
|
275
|
-
// Footer
|
|
276
|
-
const footer = document.createElement('div');
|
|
277
|
-
footer.style.cssText = `
|
|
278
|
-
padding: 12px 20px;
|
|
279
|
-
border-top: 1px solid rgba(255, 255, 255, 0.1);
|
|
280
|
-
display: flex;
|
|
281
|
-
justify-content: space-between;
|
|
282
|
-
align-items: center;
|
|
283
|
-
font-size: 12px;
|
|
284
|
-
color: #666;
|
|
285
|
-
`;
|
|
286
|
-
|
|
287
|
-
const timestamp = document.createElement('span');
|
|
288
|
-
timestamp.textContent = `${new Date().toLocaleTimeString()}`;
|
|
289
|
-
|
|
290
|
-
const actions = document.createElement('div');
|
|
291
|
-
actions.style.cssText = `
|
|
292
|
-
display: flex;
|
|
293
|
-
gap: 8px;
|
|
294
|
-
`;
|
|
295
|
-
|
|
296
|
-
const reloadBtn = document.createElement('button');
|
|
297
|
-
reloadBtn.style.cssText = `
|
|
298
|
-
background: #3498db;
|
|
299
|
-
border: none;
|
|
300
|
-
color: white;
|
|
301
|
-
padding: 6px 12px;
|
|
302
|
-
border-radius: 6px;
|
|
303
|
-
cursor: pointer;
|
|
304
|
-
font-size: 12px;
|
|
305
|
-
font-weight: 500;
|
|
306
|
-
`;
|
|
307
|
-
reloadBtn.textContent = 'Reload Page';
|
|
308
|
-
reloadBtn.onclick = () => globalThis.location.reload();
|
|
309
|
-
|
|
310
|
-
const dismissBtn = document.createElement('button');
|
|
311
|
-
dismissBtn.style.cssText = `
|
|
312
|
-
background: rgba(255, 255, 255, 0.1);
|
|
313
|
-
border: none;
|
|
314
|
-
color: #888;
|
|
315
|
-
padding: 6px 12px;
|
|
316
|
-
border-radius: 6px;
|
|
317
|
-
cursor: pointer;
|
|
318
|
-
font-size: 12px;
|
|
319
|
-
`;
|
|
320
|
-
dismissBtn.textContent = 'Dismiss';
|
|
321
|
-
dismissBtn.onclick = removeHMRErrorOverlay;
|
|
322
|
-
|
|
323
|
-
actions.appendChild(dismissBtn);
|
|
324
|
-
actions.appendChild(reloadBtn);
|
|
325
|
-
|
|
326
|
-
footer.appendChild(timestamp);
|
|
327
|
-
footer.appendChild(actions);
|
|
328
|
-
|
|
329
|
-
// Assemble
|
|
330
|
-
content.insertBefore(fileInfo, content.firstChild);
|
|
331
|
-
content.insertBefore(errorSection, content.children[1]);
|
|
332
|
-
|
|
333
|
-
container.appendChild(header);
|
|
334
|
-
container.appendChild(content);
|
|
335
|
-
container.appendChild(footer);
|
|
336
|
-
overlay.appendChild(container);
|
|
337
|
-
|
|
338
|
-
// Add keyboard handler
|
|
339
|
-
const handleKeydown = (e) => {
|
|
340
|
-
if (e.key === 'Escape') {
|
|
341
|
-
removeHMRErrorOverlay();
|
|
342
|
-
}
|
|
343
|
-
};
|
|
344
|
-
document.addEventListener('keydown', handleKeydown);
|
|
345
|
-
overlay._keydownHandler = handleKeydown;
|
|
346
|
-
|
|
347
|
-
document.body.appendChild(overlay);
|
|
348
|
-
}
|
|
349
|
-
|
|
350
|
-
/**
|
|
351
|
-
* Remove the HMR error overlay
|
|
352
|
-
*/
|
|
353
|
-
export function removeHMRErrorOverlay() {
|
|
354
|
-
const overlay = document.getElementById('avalon-hmr-error-overlay');
|
|
355
|
-
if (overlay) {
|
|
356
|
-
if (overlay._keydownHandler) {
|
|
357
|
-
document.removeEventListener('keydown', overlay._keydownHandler);
|
|
358
|
-
}
|
|
359
|
-
overlay.remove();
|
|
360
|
-
}
|
|
361
|
-
}
|
|
362
|
-
|
|
363
|
-
/**
|
|
364
|
-
* Escape HTML special characters
|
|
365
|
-
* @param {string} str - String to escape
|
|
366
|
-
* @returns {string} Escaped string
|
|
367
|
-
*/
|
|
368
|
-
function escapeHtml(str) {
|
|
369
|
-
const div = document.createElement('div');
|
|
370
|
-
div.textContent = str;
|
|
371
|
-
return div.innerHTML;
|
|
372
|
-
}
|
|
373
|
-
|
|
374
|
-
/**
|
|
375
|
-
* Format stack trace for display
|
|
376
|
-
* @param {string} stack - Raw stack trace
|
|
377
|
-
* @returns {string} Formatted stack trace
|
|
378
|
-
*/
|
|
379
|
-
function formatStackTrace(stack) {
|
|
380
|
-
return stack
|
|
381
|
-
.split('\n')
|
|
382
|
-
.map(line => line.trim())
|
|
383
|
-
.filter(line => line.length > 0)
|
|
384
|
-
.join('\n');
|
|
385
|
-
}
|
|
386
|
-
|
|
387
|
-
/**
|
|
388
|
-
* Get suggestions based on the error
|
|
389
|
-
* @param {Error} error - The error
|
|
390
|
-
* @param {string} framework - The framework name
|
|
391
|
-
* @returns {string[]} Array of suggestions
|
|
392
|
-
*/
|
|
393
|
-
function getSuggestions(error, framework) {
|
|
394
|
-
const suggestions = [];
|
|
395
|
-
const message = error.message?.toLowerCase() || '';
|
|
396
|
-
|
|
397
|
-
// Common error patterns
|
|
398
|
-
if (message.includes('no default export')) {
|
|
399
|
-
suggestions.push('Ensure your component has a default export');
|
|
400
|
-
suggestions.push('Check that the export statement is correct: export default ComponentName');
|
|
401
|
-
}
|
|
402
|
-
|
|
403
|
-
if (message.includes('cannot find module') || message.includes('module not found')) {
|
|
404
|
-
suggestions.push('Check that the import path is correct');
|
|
405
|
-
suggestions.push('Verify the file exists at the specified location');
|
|
406
|
-
suggestions.push('Check for typos in the file name or path');
|
|
407
|
-
}
|
|
408
|
-
|
|
409
|
-
if (message.includes('syntax error') || message.includes('unexpected token')) {
|
|
410
|
-
suggestions.push('Check for syntax errors in your component');
|
|
411
|
-
suggestions.push('Ensure all brackets and parentheses are properly closed');
|
|
412
|
-
}
|
|
413
|
-
|
|
414
|
-
if (message.includes('hydration') || message.includes('mismatch')) {
|
|
415
|
-
suggestions.push('Ensure server and client render the same initial content');
|
|
416
|
-
suggestions.push('Check for browser-only code that runs during SSR');
|
|
417
|
-
}
|
|
418
|
-
|
|
419
|
-
// Framework-specific suggestions
|
|
420
|
-
switch (framework) {
|
|
421
|
-
case 'vue':
|
|
422
|
-
if (message.includes('template')) {
|
|
423
|
-
suggestions.push('Check your Vue template syntax');
|
|
424
|
-
}
|
|
425
|
-
break;
|
|
426
|
-
case 'svelte':
|
|
427
|
-
if (message.includes('compile')) {
|
|
428
|
-
suggestions.push('Check your Svelte component syntax');
|
|
429
|
-
suggestions.push('Ensure reactive statements use $: prefix');
|
|
430
|
-
}
|
|
431
|
-
break;
|
|
432
|
-
case 'solid':
|
|
433
|
-
if (message.includes('signal') || message.includes('reactive')) {
|
|
434
|
-
suggestions.push('Check your Solid.js signal usage');
|
|
435
|
-
}
|
|
436
|
-
break;
|
|
437
|
-
case 'lit':
|
|
438
|
-
if (message.includes('custom element') || message.includes('define')) {
|
|
439
|
-
suggestions.push('Ensure your Lit element is properly decorated with @customElement');
|
|
440
|
-
}
|
|
441
|
-
break;
|
|
442
|
-
}
|
|
443
|
-
|
|
444
|
-
// Generic suggestions if none matched
|
|
445
|
-
if (suggestions.length === 0) {
|
|
446
|
-
suggestions.push('Check the browser console for more details');
|
|
447
|
-
suggestions.push('Try reloading the page');
|
|
448
|
-
}
|
|
449
|
-
|
|
450
|
-
return suggestions;
|
|
451
|
-
}
|
|
452
|
-
|
|
453
|
-
/**
|
|
454
|
-
* Show a toast notification for HMR events
|
|
455
|
-
* @param {Object} options - Toast options
|
|
456
|
-
* @param {string} options.message - The message to display
|
|
457
|
-
* @param {string} [options.type='info'] - The type: 'success', 'error', 'info'
|
|
458
|
-
* @param {number} [options.duration=3000] - Duration in milliseconds
|
|
459
|
-
*/
|
|
460
|
-
export function showHMRToast({ message, type = 'info', duration = 3000 }) {
|
|
461
|
-
// Remove existing toast
|
|
462
|
-
const existing = document.getElementById('avalon-hmr-toast');
|
|
463
|
-
if (existing) {
|
|
464
|
-
existing.remove();
|
|
465
|
-
}
|
|
466
|
-
|
|
467
|
-
const colors = {
|
|
468
|
-
success: { bg: '#2ecc71', icon: '✓' },
|
|
469
|
-
error: { bg: '#e74c3c', icon: '✕' },
|
|
470
|
-
info: { bg: '#3498db', icon: 'ℹ' },
|
|
471
|
-
};
|
|
472
|
-
|
|
473
|
-
const { bg, icon } = colors[type] || colors.info;
|
|
474
|
-
|
|
475
|
-
const toast = document.createElement('div');
|
|
476
|
-
toast.id = 'avalon-hmr-toast';
|
|
477
|
-
toast.style.cssText = `
|
|
478
|
-
position: fixed;
|
|
479
|
-
bottom: 20px;
|
|
480
|
-
right: 20px;
|
|
481
|
-
background: ${bg};
|
|
482
|
-
color: white;
|
|
483
|
-
padding: 12px 16px;
|
|
484
|
-
border-radius: 8px;
|
|
485
|
-
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
|
|
486
|
-
font-size: 13px;
|
|
487
|
-
display: flex;
|
|
488
|
-
align-items: center;
|
|
489
|
-
gap: 8px;
|
|
490
|
-
box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
|
|
491
|
-
z-index: 99998;
|
|
492
|
-
animation: slideIn 0.3s ease;
|
|
493
|
-
`;
|
|
494
|
-
|
|
495
|
-
toast.innerHTML = `
|
|
496
|
-
<span style="font-weight: bold;">${icon}</span>
|
|
497
|
-
<span>${escapeHtml(message)}</span>
|
|
498
|
-
`;
|
|
499
|
-
|
|
500
|
-
// Add animation styles
|
|
501
|
-
const style = document.createElement('style');
|
|
502
|
-
style.textContent = `
|
|
503
|
-
@keyframes slideIn {
|
|
504
|
-
from {
|
|
505
|
-
transform: translateX(100%);
|
|
506
|
-
opacity: 0;
|
|
507
|
-
}
|
|
508
|
-
to {
|
|
509
|
-
transform: translateX(0);
|
|
510
|
-
opacity: 1;
|
|
511
|
-
}
|
|
512
|
-
}
|
|
513
|
-
@keyframes slideOut {
|
|
514
|
-
from {
|
|
515
|
-
transform: translateX(0);
|
|
516
|
-
opacity: 1;
|
|
517
|
-
}
|
|
518
|
-
to {
|
|
519
|
-
transform: translateX(100%);
|
|
520
|
-
opacity: 0;
|
|
521
|
-
}
|
|
522
|
-
}
|
|
523
|
-
`;
|
|
524
|
-
toast.appendChild(style);
|
|
525
|
-
|
|
526
|
-
document.body.appendChild(toast);
|
|
527
|
-
|
|
528
|
-
// Auto-remove after duration
|
|
529
|
-
setTimeout(() => {
|
|
530
|
-
toast.style.animation = 'slideOut 0.3s ease';
|
|
531
|
-
setTimeout(() => toast.remove(), 300);
|
|
532
|
-
}, duration);
|
|
533
|
-
}
|