@forgewp/compiler 0.2.0 ā 0.4.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/README.md +24 -5
- package/bin/analyze.js +158 -0
- package/bin/cli.js +29 -4
- package/bin/doctor.js +125 -11
- package/bin/export.js +20 -0
- package/bin/fresh.js +32 -343
- package/bin/i18n-extract.js +121 -0
- package/bin/i18n-translate.js +112 -0
- package/bin/make-block.js +27 -60
- package/bin/make-island.js +72 -0
- package/bin/make-post-type.js +6 -6
- package/bin/make-template.js +145 -0
- package/bin/repair.js +2 -2
- package/bin/sync-routes.js +28 -158
- package/define-config.d.ts +1 -0
- package/define-config.js +1 -0
- package/lib/adapters/html-adapter.js +65 -0
- package/lib/adapters/stub-adapter.js +49 -0
- package/lib/add-component.js +290 -73
- package/lib/asset-loader.js +27 -0
- package/lib/block-compiler.js +552 -0
- package/lib/blueprints.js +1459 -501
- package/lib/define-config.d.ts +3 -0
- package/lib/define-config.js +8 -0
- package/lib/diagnostics.js +798 -0
- package/lib/export-theme.js +81 -18
- package/lib/framework-adapter.js +34 -0
- package/lib/functions-builder.js +1801 -0
- package/lib/generate-theme.js +1019 -1143
- package/lib/hydration-scanner.js +674 -0
- package/lib/i18n/extractor.js +60 -0
- package/lib/i18n/providers.js +165 -0
- package/lib/index.d.ts +119 -1
- package/lib/index.js +20 -3
- package/lib/load-config.js +122 -6
- package/lib/markup-processor.js +584 -0
- package/lib/php-builders.js +381 -0
- package/lib/react-adapter.js +1336 -0
- package/lib/render-static.js +9 -82
- package/lib/render-theme.mts +526 -232
- package/lib/screenshot-fallback.png +0 -0
- package/lib/types.js +1 -0
- package/lib/validate-export.js +183 -0
- package/package.json +14 -3
- package/bin/make-component.js +0 -200
|
@@ -0,0 +1,798 @@
|
|
|
1
|
+
import fs from 'node:fs';
|
|
2
|
+
import path from 'node:path';
|
|
3
|
+
import pc from 'picocolors';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Run compiler diagnostics on compiled hydration islands.
|
|
7
|
+
* @param {string} themeRoot
|
|
8
|
+
* @param {Record<string, string>} mapping Kebab island name -> chunk file path
|
|
9
|
+
* @returns {{ heavyCount: number, results: any[] }}
|
|
10
|
+
*/
|
|
11
|
+
export function analyzeHydrationIslands(themeRoot, mapping) {
|
|
12
|
+
const results = [];
|
|
13
|
+
let heavyCount = 0;
|
|
14
|
+
|
|
15
|
+
for (const [islandName, chunkPath] of Object.entries(mapping)) {
|
|
16
|
+
// Vite compiles into 'dist' folder
|
|
17
|
+
const filePath = path.join(themeRoot, 'dist', chunkPath);
|
|
18
|
+
if (fs.existsSync(filePath)) {
|
|
19
|
+
const sizeBytes = fs.statSync(filePath).size;
|
|
20
|
+
const sizeKb = sizeBytes / 1024;
|
|
21
|
+
const isHeavy = sizeKb > 100;
|
|
22
|
+
|
|
23
|
+
if (isHeavy) {
|
|
24
|
+
heavyCount++;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
results.push({
|
|
28
|
+
name: islandName,
|
|
29
|
+
sizeKb,
|
|
30
|
+
isHeavy,
|
|
31
|
+
chunkPath,
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
return {
|
|
37
|
+
heavyCount,
|
|
38
|
+
results,
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* Print a gorgeous CLI diagnostic report.
|
|
44
|
+
* @param {{ heavyCount: number, results: any[] }} analysis
|
|
45
|
+
*/
|
|
46
|
+
export function printDiagnosticsReport(analysis) {
|
|
47
|
+
console.log(`\n𩺠${pc.bold(pc.bgCyan(pc.black(" FORGEWP HYDRATION DIAGNOSTICS ")))}`);
|
|
48
|
+
|
|
49
|
+
if (analysis.results.length === 0) {
|
|
50
|
+
console.log(` ${pc.dim("No active hydration islands detected in this project.")}`);
|
|
51
|
+
console.log("ā".repeat(60) + "\n");
|
|
52
|
+
return;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
for (const item of analysis.results) {
|
|
56
|
+
const paddedName = item.name.padEnd(28, '.');
|
|
57
|
+
const formattedSize = `${item.sizeKb.toFixed(1)} kB`;
|
|
58
|
+
|
|
59
|
+
if (item.isHeavy) {
|
|
60
|
+
console.log(` ā ļø ${pc.yellow(pc.bold(paddedName))} ${pc.red(pc.bold(formattedSize))} ${pc.bgRed(pc.black(" HEAVY "))}`);
|
|
61
|
+
console.log(` ${pc.dim("š Chunk Path:")} dist/${item.chunkPath}`);
|
|
62
|
+
console.log(` ${pc.dim("š Recommendations:")}`);
|
|
63
|
+
console.log(` 1. Split static markup sections out of the component into static wrappers.`);
|
|
64
|
+
console.log(` 2. Avoid heavy external packages inside the island (or lazy load them inside React).`);
|
|
65
|
+
console.log(` 3. Switch to a non-blocking trigger strategy (e.g. trigger="interaction" or trigger="idle").`);
|
|
66
|
+
} else {
|
|
67
|
+
console.log(` ā
${pc.green(paddedName)} ${pc.green(formattedSize)}`);
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
console.log("ā".repeat(60));
|
|
72
|
+
if (analysis.heavyCount > 0) {
|
|
73
|
+
console.log(` ${pc.red(pc.bold("WARNING:"))} Found ${analysis.heavyCount} heavy interactive hydration island(s).`);
|
|
74
|
+
console.log(` š” Keep JS bundles light. Modern Web Vitals rewards minimal runtime overhead!\n`);
|
|
75
|
+
} else {
|
|
76
|
+
console.log(` ${pc.green(pc.bold("SYSTEM OPTIMIZED:"))} All interactive hydration islands are within healthy thresholds (<100 kB).\n`);
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
/**
|
|
81
|
+
* Generate visual dashboard HTML report and save it under .forgewp/analyzer/index.html.
|
|
82
|
+
* @param {string} themeRoot
|
|
83
|
+
* @param {{ heavyCount: number, results: any[] }} analysis
|
|
84
|
+
* @param {any[]} islandsWithProps
|
|
85
|
+
* @param {any} config
|
|
86
|
+
* @returns {string} Path to the generated report
|
|
87
|
+
*/
|
|
88
|
+
export function generateVisualReport(themeRoot, analysis, islandsWithProps, config) {
|
|
89
|
+
const islands = islandsWithProps.map((item) => {
|
|
90
|
+
const analysisMatch = analysis.results.find((a) => a.name === item.name);
|
|
91
|
+
return {
|
|
92
|
+
...item,
|
|
93
|
+
sizeKb: analysisMatch ? analysisMatch.sizeKb : 0,
|
|
94
|
+
isHeavy: analysisMatch ? analysisMatch.isHeavy : false,
|
|
95
|
+
chunkPath: analysisMatch ? analysisMatch.chunkPath : null,
|
|
96
|
+
compiled: !!analysisMatch,
|
|
97
|
+
};
|
|
98
|
+
});
|
|
99
|
+
|
|
100
|
+
// Calculate dynamic performance score
|
|
101
|
+
let score = 100;
|
|
102
|
+
let totalJsKb = 0;
|
|
103
|
+
|
|
104
|
+
for (const island of islands) {
|
|
105
|
+
totalJsKb += island.sizeKb;
|
|
106
|
+
if (island.isHeavy) {
|
|
107
|
+
score -= 15;
|
|
108
|
+
}
|
|
109
|
+
if (island.trigger === "load") {
|
|
110
|
+
score -= 10;
|
|
111
|
+
}
|
|
112
|
+
if (island.smartDiscovered) {
|
|
113
|
+
score -= 5;
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
const violations = analysis.violations || [];
|
|
118
|
+
for (const v of violations) {
|
|
119
|
+
if (v.type === "metadata") score -= 5;
|
|
120
|
+
else if (v.type === "loop") score -= 15;
|
|
121
|
+
else if (v.type === "url") score -= 3;
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
score -= Math.floor(totalJsKb / 10);
|
|
125
|
+
score = Math.max(10, Math.min(100, score));
|
|
126
|
+
|
|
127
|
+
let grade = "F";
|
|
128
|
+
if (score >= 90) grade = "A";
|
|
129
|
+
else if (score >= 80) grade = "B";
|
|
130
|
+
else if (score >= 70) grade = "C";
|
|
131
|
+
else if (score >= 60) grade = "D";
|
|
132
|
+
|
|
133
|
+
const payload = {
|
|
134
|
+
config: {
|
|
135
|
+
name: config.name || "Unknown Theme",
|
|
136
|
+
slug: config.slug || "unknown",
|
|
137
|
+
version: config.version || "1.0.0",
|
|
138
|
+
},
|
|
139
|
+
score,
|
|
140
|
+
grade,
|
|
141
|
+
islands,
|
|
142
|
+
violations,
|
|
143
|
+
};
|
|
144
|
+
|
|
145
|
+
const outDir = path.join(themeRoot, ".forgewp", "analyzer");
|
|
146
|
+
if (!fs.existsSync(outDir)) {
|
|
147
|
+
fs.mkdirSync(outDir, { recursive: true });
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
const htmlContent = ANALYZER_TEMPLATE.replace("__DATA_PLACEHOLDER__", () => JSON.stringify(payload));
|
|
151
|
+
|
|
152
|
+
const reportPath = path.join(outDir, "index.html");
|
|
153
|
+
fs.writeFileSync(reportPath, htmlContent, "utf8");
|
|
154
|
+
|
|
155
|
+
return reportPath;
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
const ANALYZER_TEMPLATE = `<!DOCTYPE html>
|
|
159
|
+
<html lang="en" class="dark">
|
|
160
|
+
<head>
|
|
161
|
+
<meta charset="UTF-8">
|
|
162
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
163
|
+
<title>ForgeWP Hydration Devtools & Analyzer</title>
|
|
164
|
+
<script src="https://cdn.tailwindcss.com"></script>
|
|
165
|
+
<link href="https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@400;500;600;700;800&family=JetBrains+Mono:wght@400;700&display=swap" rel="stylesheet">
|
|
166
|
+
<script src="https://unpkg.com/lucide@latest"></script>
|
|
167
|
+
<script>
|
|
168
|
+
if (typeof tailwind !== 'undefined') {
|
|
169
|
+
tailwind.config = {
|
|
170
|
+
darkMode: 'class',
|
|
171
|
+
theme: {
|
|
172
|
+
extend: {
|
|
173
|
+
fontFamily: {
|
|
174
|
+
sans: ['"Plus Jakarta Sans"', 'sans-serif'],
|
|
175
|
+
mono: ['"JetBrains Mono"', 'monospace'],
|
|
176
|
+
},
|
|
177
|
+
colors: {
|
|
178
|
+
brand: {
|
|
179
|
+
DEFAULT: '#06b6d4',
|
|
180
|
+
hover: '#0891b2',
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
</script>
|
|
188
|
+
<style>
|
|
189
|
+
body {
|
|
190
|
+
background-color: #09090b;
|
|
191
|
+
color: #fafafa;
|
|
192
|
+
}
|
|
193
|
+
.custom-scrollbar::-webkit-scrollbar {
|
|
194
|
+
width: 6px;
|
|
195
|
+
height: 6px;
|
|
196
|
+
}
|
|
197
|
+
.custom-scrollbar::-webkit-scrollbar-track {
|
|
198
|
+
background: transparent;
|
|
199
|
+
}
|
|
200
|
+
.custom-scrollbar::-webkit-scrollbar-thumb {
|
|
201
|
+
background: #27272a;
|
|
202
|
+
border-radius: 4px;
|
|
203
|
+
}
|
|
204
|
+
.custom-scrollbar::-webkit-scrollbar-thumb:hover {
|
|
205
|
+
background: #3f3f46;
|
|
206
|
+
}
|
|
207
|
+
@keyframes pulse-ring {
|
|
208
|
+
0% { transform: scale(0.95); opacity: 0.5; }
|
|
209
|
+
50% { transform: scale(1.1); opacity: 0.8; }
|
|
210
|
+
100% { transform: scale(0.95); opacity: 0.5; }
|
|
211
|
+
}
|
|
212
|
+
.pulsing-dot::after {
|
|
213
|
+
content: '';
|
|
214
|
+
position: absolute;
|
|
215
|
+
width: 100%;
|
|
216
|
+
height: 100%;
|
|
217
|
+
top: 0;
|
|
218
|
+
left: 0;
|
|
219
|
+
background: inherit;
|
|
220
|
+
border-radius: inherit;
|
|
221
|
+
animation: pulse-ring 2s infinite ease-in-out;
|
|
222
|
+
}
|
|
223
|
+
</style>
|
|
224
|
+
</head>
|
|
225
|
+
<body class="min-h-screen font-sans flex flex-col antialiased selection:bg-brand selection:text-black">
|
|
226
|
+
<!-- Header -->
|
|
227
|
+
<header class="border-b border-zinc-800 bg-zinc-950/80 backdrop-blur-md sticky top-0 z-50 px-6 py-4 flex items-center justify-between">
|
|
228
|
+
<div class="flex items-center gap-3">
|
|
229
|
+
<div class="relative w-8 h-8 rounded-lg bg-cyan-500/10 border border-cyan-500 flex items-center justify-center text-cyan-400 font-bold tracking-wider select-none shadow-[0_0_15px_rgba(6,182,212,0.15)]">
|
|
230
|
+
ā”
|
|
231
|
+
</div>
|
|
232
|
+
<div>
|
|
233
|
+
<h1 class="text-sm font-bold tracking-tight text-zinc-100 uppercase">ForgeWP</h1>
|
|
234
|
+
<p class="text-[10px] text-zinc-400 font-mono tracking-widest uppercase">Hydration Devtools & Analyzer</p>
|
|
235
|
+
</div>
|
|
236
|
+
</div>
|
|
237
|
+
<div class="flex items-center gap-3">
|
|
238
|
+
<span class="inline-flex items-center gap-1.5 px-2.5 py-1 rounded-full text-xs font-semibold bg-zinc-900 border border-zinc-800 text-zinc-300">
|
|
239
|
+
<span class="w-1.5 h-1.5 rounded-full bg-emerald-500 relative pulsing-dot"></span>
|
|
240
|
+
Local Dev Simulator
|
|
241
|
+
</span>
|
|
242
|
+
<button onclick="window.location.reload()" class="p-1.5 rounded-lg border border-zinc-800 hover:bg-zinc-900 text-zinc-400 hover:text-zinc-200 transition-colors">
|
|
243
|
+
<i data-lucide="refresh-cw" class="w-4 h-4"></i>
|
|
244
|
+
</button>
|
|
245
|
+
</div>
|
|
246
|
+
</header>
|
|
247
|
+
|
|
248
|
+
<main class="flex-1 flex overflow-hidden">
|
|
249
|
+
<!-- Left panel -->
|
|
250
|
+
<div class="flex-1 overflow-y-auto custom-scrollbar p-6 space-y-6">
|
|
251
|
+
|
|
252
|
+
<!-- Metrics Grid -->
|
|
253
|
+
<div class="grid grid-cols-1 md:grid-cols-4 gap-4">
|
|
254
|
+
<!-- Performance Score -->
|
|
255
|
+
<div class="bg-zinc-900 border border-zinc-800/80 rounded-xl p-5 relative overflow-hidden flex items-center justify-between">
|
|
256
|
+
<div>
|
|
257
|
+
<span class="text-xs text-zinc-400 font-bold uppercase tracking-wider">Performance Score</span>
|
|
258
|
+
<div class="text-2xl font-black mt-1" id="metric-score">--</div>
|
|
259
|
+
<p class="text-[10px] text-zinc-400 mt-1" id="metric-score-text">Calculating Grade...</p>
|
|
260
|
+
</div>
|
|
261
|
+
<div class="w-14 h-14 rounded-full flex items-center justify-center font-black text-2xl border" id="score-badge">
|
|
262
|
+
-
|
|
263
|
+
</div>
|
|
264
|
+
</div>
|
|
265
|
+
|
|
266
|
+
<!-- Total JS Footprint -->
|
|
267
|
+
<div class="bg-zinc-900 border border-zinc-800/80 rounded-xl p-5 relative overflow-hidden flex items-center justify-between">
|
|
268
|
+
<div>
|
|
269
|
+
<span class="text-xs text-zinc-400 font-bold uppercase tracking-wider">Total JS Payload</span>
|
|
270
|
+
<div class="text-2xl font-black mt-1" id="metric-size">--</div>
|
|
271
|
+
<p class="text-[10px] text-zinc-400 mt-1">Across all hydration islands</p>
|
|
272
|
+
</div>
|
|
273
|
+
<div class="p-3 bg-zinc-800/50 rounded-lg border border-zinc-700/50 text-zinc-400">
|
|
274
|
+
<i data-lucide="file-code" class="w-6 h-6"></i>
|
|
275
|
+
</div>
|
|
276
|
+
</div>
|
|
277
|
+
|
|
278
|
+
<!-- Total Islands Count -->
|
|
279
|
+
<div class="bg-zinc-900 border border-zinc-800/80 rounded-xl p-5 relative overflow-hidden flex items-center justify-between">
|
|
280
|
+
<div>
|
|
281
|
+
<span class="text-xs text-zinc-400 font-bold uppercase tracking-wider">Hydration Islands</span>
|
|
282
|
+
<div class="text-2xl font-black mt-1" id="metric-count">--</div>
|
|
283
|
+
<p class="text-[10px] text-zinc-400 mt-1" id="metric-unwrapped">0 unwrapped warning(s)</p>
|
|
284
|
+
</div>
|
|
285
|
+
<div class="p-3 bg-zinc-800/50 rounded-lg border border-zinc-700/50 text-zinc-400">
|
|
286
|
+
<i data-lucide="layout-grid" class="w-6 h-6"></i>
|
|
287
|
+
</div>
|
|
288
|
+
</div>
|
|
289
|
+
|
|
290
|
+
<!-- Average Island Size -->
|
|
291
|
+
<div class="bg-zinc-900 border border-zinc-800/80 rounded-xl p-5 relative overflow-hidden flex items-center justify-between">
|
|
292
|
+
<div>
|
|
293
|
+
<span class="text-xs text-zinc-400 font-bold uppercase tracking-wider">Average Island JS</span>
|
|
294
|
+
<div class="text-2xl font-black mt-1" id="metric-avg">--</div>
|
|
295
|
+
<p class="text-[10px] text-zinc-400 mt-1" id="metric-heavy">0 heavy island(s)</p>
|
|
296
|
+
</div>
|
|
297
|
+
<div class="p-3 bg-zinc-800/50 rounded-lg border border-zinc-700/50 text-zinc-400">
|
|
298
|
+
<i data-lucide="bar-chart-2" class="w-6 h-6"></i>
|
|
299
|
+
</div>
|
|
300
|
+
</div>
|
|
301
|
+
</div>
|
|
302
|
+
|
|
303
|
+
<!-- Route Visual Map -->
|
|
304
|
+
<div class="bg-zinc-900 border border-zinc-800/80 rounded-xl p-6">
|
|
305
|
+
<h2 class="text-sm font-bold uppercase tracking-wider text-zinc-100 flex items-center gap-2 mb-6 select-none">
|
|
306
|
+
<i data-lucide="network" class="w-4 h-4 text-cyan-400"></i>
|
|
307
|
+
Interactive Hydration Graph
|
|
308
|
+
</h2>
|
|
309
|
+
|
|
310
|
+
<div class="border border-zinc-800/50 bg-zinc-950/40 rounded-xl p-6 flex flex-col items-center justify-center min-h-[300px] relative overflow-hidden">
|
|
311
|
+
|
|
312
|
+
<div class="flex flex-col items-center relative z-10 w-full">
|
|
313
|
+
<div class="bg-zinc-900 border-2 border-zinc-700 rounded-xl p-4 flex items-center gap-3 shadow-[0_4px_20px_rgba(0,0,0,0.4)] select-none">
|
|
314
|
+
<div class="w-8 h-8 rounded-lg bg-zinc-800 border border-zinc-700 flex items-center justify-center text-zinc-400">
|
|
315
|
+
<i data-lucide="layout" class="w-4 h-4"></i>
|
|
316
|
+
</div>
|
|
317
|
+
<div class="text-left">
|
|
318
|
+
<div class="text-xs font-bold text-zinc-200">Main Site Template</div>
|
|
319
|
+
<div class="text-[10px] text-zinc-500 font-mono">0 kB client JavaScript</div>
|
|
320
|
+
</div>
|
|
321
|
+
<span class="bg-emerald-500/10 text-emerald-400 text-[9px] font-mono font-bold uppercase px-2 py-0.5 border border-emerald-500/20 rounded">Static HTML</span>
|
|
322
|
+
</div>
|
|
323
|
+
|
|
324
|
+
<div class="mt-12 flex flex-wrap justify-center gap-8 relative w-full" id="graph-islands-container">
|
|
325
|
+
</div>
|
|
326
|
+
</div>
|
|
327
|
+
</div>
|
|
328
|
+
</div>
|
|
329
|
+
|
|
330
|
+
<!-- Static Code Analyzer & Theme Lint Rules -->
|
|
331
|
+
<div class="bg-zinc-900 border border-zinc-800/80 rounded-xl p-6">
|
|
332
|
+
<h2 class="text-sm font-bold uppercase tracking-wider text-zinc-100 flex items-center justify-between mb-6 select-none">
|
|
333
|
+
<span class="flex items-center gap-2">
|
|
334
|
+
<i data-lucide="shield-alert" class="w-4 h-4 text-cyan-400"></i>
|
|
335
|
+
Theme Lint Rules & SEO Best Practices
|
|
336
|
+
</span>
|
|
337
|
+
<span class="text-[10px] bg-cyan-950/40 text-cyan-400 border border-cyan-500/20 px-2 py-0.5 rounded font-mono font-bold" id="lint-status-badge">
|
|
338
|
+
0 Violations
|
|
339
|
+
</span>
|
|
340
|
+
</h2>
|
|
341
|
+
|
|
342
|
+
<div id="lint-passed-alert" class="hidden bg-emerald-950/20 border border-emerald-500/30 rounded-xl p-5 flex items-start gap-4">
|
|
343
|
+
<div class="p-2 bg-emerald-950/60 rounded-lg text-emerald-400">
|
|
344
|
+
<i data-lucide="check-circle" class="w-6 h-6"></i>
|
|
345
|
+
</div>
|
|
346
|
+
<div>
|
|
347
|
+
<h4 class="text-xs font-bold text-emerald-300">Pristine Architecture Audit</h4>
|
|
348
|
+
<p class="text-zinc-400 text-[11px] leading-relaxed mt-1">All pages pass standard metadata requirements, static event handlers are correctly hydrated, and no hardcoded internal URLs were found. Excellent work!</p>
|
|
349
|
+
</div>
|
|
350
|
+
</div>
|
|
351
|
+
|
|
352
|
+
<div id="lint-violations-container" class="space-y-4">
|
|
353
|
+
<!-- Populated dynamically via JS -->
|
|
354
|
+
</div>
|
|
355
|
+
</div>
|
|
356
|
+
|
|
357
|
+
<!-- Islands Table -->
|
|
358
|
+
<div class="bg-zinc-900 border border-zinc-800/80 rounded-xl p-6">
|
|
359
|
+
<div class="flex items-center justify-between mb-6">
|
|
360
|
+
<h2 class="text-sm font-bold uppercase tracking-wider text-zinc-100 flex items-center gap-2 select-none">
|
|
361
|
+
<i data-lucide="list" class="w-4 h-4 text-cyan-400"></i>
|
|
362
|
+
Hydration Island Directory
|
|
363
|
+
</h2>
|
|
364
|
+
<div class="flex items-center gap-3">
|
|
365
|
+
<input type="text" id="search-input" placeholder="Search islands..." class="bg-zinc-950 border border-zinc-800 px-3 py-1.5 rounded-lg text-xs focus:outline-none focus:border-cyan-500 text-zinc-300 w-48 font-medium">
|
|
366
|
+
<select id="filter-type" class="bg-zinc-950 border border-zinc-800 px-2.5 py-1.5 rounded-lg text-xs focus:outline-none focus:border-cyan-500 text-zinc-400 font-semibold">
|
|
367
|
+
<option value="all">All Islands</option>
|
|
368
|
+
<option value="heavy">Heavy (>100 kB)</option>
|
|
369
|
+
<option value="unwrapped">Unwrapped</option>
|
|
370
|
+
</select>
|
|
371
|
+
</div>
|
|
372
|
+
</div>
|
|
373
|
+
|
|
374
|
+
<div class="overflow-x-auto">
|
|
375
|
+
<table class="w-full text-left border-collapse">
|
|
376
|
+
<thead>
|
|
377
|
+
<tr class="border-b border-zinc-800 text-[10px] font-bold uppercase tracking-wider text-zinc-500">
|
|
378
|
+
<th class="pb-3">Component / Chunk</th>
|
|
379
|
+
<th class="pb-3">Trigger Strategy</th>
|
|
380
|
+
<th class="pb-3">Bundle Size</th>
|
|
381
|
+
<th class="pb-3">Constraints</th>
|
|
382
|
+
<th class="pb-3">Source File</th>
|
|
383
|
+
<th class="pb-3 text-right">Action</th>
|
|
384
|
+
</tr>
|
|
385
|
+
</thead>
|
|
386
|
+
<tbody id="islands-table-body" class="text-xs divide-y divide-zinc-800/50">
|
|
387
|
+
</tbody>
|
|
388
|
+
</table>
|
|
389
|
+
</div>
|
|
390
|
+
</div>
|
|
391
|
+
</div>
|
|
392
|
+
|
|
393
|
+
<!-- Right panel -->
|
|
394
|
+
<div class="w-80 border-l border-zinc-800 bg-zinc-950 p-6 flex flex-col justify-between overflow-y-auto custom-scrollbar">
|
|
395
|
+
<div class="space-y-6">
|
|
396
|
+
<div>
|
|
397
|
+
<h2 class="text-xs font-bold uppercase tracking-widest text-zinc-500 mb-2">Selected Island</h2>
|
|
398
|
+
<div id="no-island-selected" class="bg-zinc-900/40 border border-zinc-800/80 rounded-xl p-5 text-center text-zinc-500">
|
|
399
|
+
<i data-lucide="info" class="w-8 h-8 mx-auto mb-2 text-zinc-600"></i>
|
|
400
|
+
<p class="text-xs">Click on any island node or list item to view detailed diagnostics and optimization suggestions.</p>
|
|
401
|
+
</div>
|
|
402
|
+
|
|
403
|
+
<div id="island-details-card" class="hidden space-y-4">
|
|
404
|
+
<div class="bg-zinc-900 border border-zinc-800/80 rounded-xl p-5 space-y-3">
|
|
405
|
+
<div class="flex items-start justify-between">
|
|
406
|
+
<div>
|
|
407
|
+
<h3 class="font-bold text-zinc-100 text-sm" id="details-name">Component</h3>
|
|
408
|
+
<p class="text-[10px] text-zinc-500 font-mono mt-0.5 truncate max-w-[180px]" id="details-chunk">chunk-path</p>
|
|
409
|
+
</div>
|
|
410
|
+
<span class="text-[10px] font-mono font-bold uppercase px-2 py-0.5 rounded" id="details-size-badge">0 kB</span>
|
|
411
|
+
</div>
|
|
412
|
+
|
|
413
|
+
<div class="border-t border-zinc-800 pt-3 space-y-2 text-[11px]">
|
|
414
|
+
<div class="flex justify-between">
|
|
415
|
+
<span class="text-zinc-500 font-semibold">Trigger:</span>
|
|
416
|
+
<span class="text-zinc-300 font-mono font-bold" id="details-trigger">-</span>
|
|
417
|
+
</div>
|
|
418
|
+
<div class="flex justify-between">
|
|
419
|
+
<span class="text-zinc-500 font-semibold">Preload Strategy:</span>
|
|
420
|
+
<span class="text-zinc-300 font-mono font-bold" id="details-preload">-</span>
|
|
421
|
+
</div>
|
|
422
|
+
<div class="flex justify-between">
|
|
423
|
+
<span class="text-zinc-500 font-semibold">Media Query:</span>
|
|
424
|
+
<span class="text-zinc-300 font-mono font-bold" id="details-media">-</span>
|
|
425
|
+
</div>
|
|
426
|
+
<div class="flex justify-between">
|
|
427
|
+
<span class="text-zinc-500 font-semibold">Connection Gating:</span>
|
|
428
|
+
<span class="text-zinc-300 font-mono font-bold" id="details-connection">-</span>
|
|
429
|
+
</div>
|
|
430
|
+
<div class="flex justify-between">
|
|
431
|
+
<span class="text-zinc-500 font-semibold">Client Only:</span>
|
|
432
|
+
<span class="text-zinc-300 font-mono font-bold" id="details-client-only">-</span>
|
|
433
|
+
</div>
|
|
434
|
+
</div>
|
|
435
|
+
</div>
|
|
436
|
+
|
|
437
|
+
<div class="space-y-3">
|
|
438
|
+
<h4 class="text-[10px] font-bold uppercase tracking-wider text-zinc-400">Optimization Roadmap</h4>
|
|
439
|
+
<div class="bg-cyan-950/10 border border-cyan-900/30 rounded-xl p-5 space-y-3" id="optimization-container">
|
|
440
|
+
</div>
|
|
441
|
+
</div>
|
|
442
|
+
</div>
|
|
443
|
+
</div>
|
|
444
|
+
</div>
|
|
445
|
+
|
|
446
|
+
<div class="border-t border-zinc-800 pt-6 mt-6">
|
|
447
|
+
<div class="text-[10px] text-zinc-500 font-mono text-center">
|
|
448
|
+
ForgeWP Theme Package: <span class="text-zinc-400" id="theme-slug">theme-slug</span> v<span class="text-zinc-400" id="theme-version">0.0.0</span>
|
|
449
|
+
</div>
|
|
450
|
+
</div>
|
|
451
|
+
</div>
|
|
452
|
+
</main>
|
|
453
|
+
|
|
454
|
+
<script>
|
|
455
|
+
const DATA = __DATA_PLACEHOLDER__;
|
|
456
|
+
|
|
457
|
+
document.getElementById("theme-slug").textContent = DATA.config.slug;
|
|
458
|
+
document.getElementById("theme-version").textContent = DATA.config.version;
|
|
459
|
+
|
|
460
|
+
// Render Static Lint Rules
|
|
461
|
+
var violations = DATA.violations || [];
|
|
462
|
+
var lintStatusBadge = document.getElementById("lint-status-badge");
|
|
463
|
+
var lintPassedAlert = document.getElementById("lint-passed-alert");
|
|
464
|
+
var lintContainer = document.getElementById("lint-violations-container");
|
|
465
|
+
|
|
466
|
+
lintStatusBadge.textContent = violations.length + " Violation(s)";
|
|
467
|
+
|
|
468
|
+
if (violations.length === 0) {
|
|
469
|
+
lintPassedAlert.classList.remove("hidden");
|
|
470
|
+
lintStatusBadge.className = "text-[10px] bg-emerald-950/40 text-emerald-400 border border-emerald-500/20 px-2 py-0.5 rounded font-mono font-bold";
|
|
471
|
+
} else {
|
|
472
|
+
lintPassedAlert.classList.add("hidden");
|
|
473
|
+
lintStatusBadge.className = "text-[10px] bg-rose-950/40 text-rose-400 border border-rose-500/20 px-2 py-0.5 rounded font-mono font-bold";
|
|
474
|
+
|
|
475
|
+
violations.forEach(function(v) {
|
|
476
|
+
var item = document.createElement("div");
|
|
477
|
+
|
|
478
|
+
var colorClass = "border-zinc-800 bg-zinc-950/30";
|
|
479
|
+
var icon = "alert-circle";
|
|
480
|
+
var iconColor = "text-amber-500";
|
|
481
|
+
var tag = "WARNING";
|
|
482
|
+
var tagClass = "bg-amber-500/10 text-amber-400 border-amber-500/20";
|
|
483
|
+
|
|
484
|
+
if (v.severity === "error") {
|
|
485
|
+
colorClass = "border-rose-900/30 bg-rose-950/5";
|
|
486
|
+
icon = "x-circle";
|
|
487
|
+
iconColor = "text-rose-500";
|
|
488
|
+
tag = "CRITICAL ERROR";
|
|
489
|
+
tagClass = "bg-rose-500/10 text-rose-400 border-rose-500/20";
|
|
490
|
+
} else if (v.type === "metadata") {
|
|
491
|
+
colorClass = "border-amber-900/30 bg-amber-950/5";
|
|
492
|
+
icon = "globe";
|
|
493
|
+
iconColor = "text-amber-500";
|
|
494
|
+
tag = "SEO WARN";
|
|
495
|
+
tagClass = "bg-amber-500/10 text-amber-400 border-amber-500/20";
|
|
496
|
+
} else if (v.type === "url") {
|
|
497
|
+
colorClass = "border-cyan-900/30 bg-cyan-950/5";
|
|
498
|
+
icon = "link-2";
|
|
499
|
+
iconColor = "text-cyan-500";
|
|
500
|
+
tag = "LINK WARN";
|
|
501
|
+
tagClass = "bg-cyan-500/10 text-cyan-400 border-cyan-500/20";
|
|
502
|
+
}
|
|
503
|
+
|
|
504
|
+
item.className = "border rounded-xl p-5 flex items-start gap-4 " + colorClass;
|
|
505
|
+
|
|
506
|
+
var codeSnippet = "";
|
|
507
|
+
if (v.lineContent) {
|
|
508
|
+
codeSnippet = '<div class="mt-2.5 p-2 bg-zinc-950 border border-zinc-800 rounded font-mono text-[10px] text-zinc-400 select-text overflow-x-auto truncate max-w-full">' +
|
|
509
|
+
v.lineContent +
|
|
510
|
+
'</div>';
|
|
511
|
+
}
|
|
512
|
+
|
|
513
|
+
item.innerHTML = \`
|
|
514
|
+
<div class="p-2 bg-zinc-900 border border-zinc-800 rounded-lg \${iconColor}">
|
|
515
|
+
<i data-lucide="\${icon}" class="w-5 h-5"></i>
|
|
516
|
+
</div>
|
|
517
|
+
<div class="flex-1 min-w-0">
|
|
518
|
+
<div class="flex items-center gap-2">
|
|
519
|
+
<span class="text-[9px] font-mono font-bold uppercase px-2 py-0.5 border rounded \${tagClass}">
|
|
520
|
+
\${tag}
|
|
521
|
+
</span>
|
|
522
|
+
<span class="text-[10px] text-zinc-500 font-mono">\${v.file}</span>
|
|
523
|
+
</div>
|
|
524
|
+
<h4 class="text-xs font-bold text-zinc-200 mt-2 select-text">\${v.message}</h4>
|
|
525
|
+
\${codeSnippet}
|
|
526
|
+
</div>
|
|
527
|
+
\`;
|
|
528
|
+
lintContainer.appendChild(item);
|
|
529
|
+
});
|
|
530
|
+
}
|
|
531
|
+
|
|
532
|
+
const score = DATA.score;
|
|
533
|
+
const scoreBadge = document.getElementById("score-badge");
|
|
534
|
+
const metricScore = document.getElementById("metric-score");
|
|
535
|
+
const metricScoreText = document.getElementById("metric-score-text");
|
|
536
|
+
|
|
537
|
+
metricScore.textContent = score + "/100";
|
|
538
|
+
scoreBadge.textContent = DATA.grade;
|
|
539
|
+
|
|
540
|
+
if (score >= 90) {
|
|
541
|
+
scoreBadge.className = "w-14 h-14 rounded-full flex items-center justify-center font-black text-2xl border bg-emerald-950/40 border-emerald-500/50 text-emerald-400 shadow-[0_0_15px_rgba(16,185,129,0.15)]";
|
|
542
|
+
metricScoreText.textContent = "Optimal Performance Grade";
|
|
543
|
+
} else if (score >= 80) {
|
|
544
|
+
scoreBadge.className = "w-14 h-14 rounded-full flex items-center justify-center font-black text-2xl border bg-teal-950/40 border-teal-500/50 text-teal-400 shadow-[0_0_15px_rgba(20,184,166,0.15)]";
|
|
545
|
+
metricScoreText.textContent = "Good Performance Grade";
|
|
546
|
+
} else if (score >= 70) {
|
|
547
|
+
scoreBadge.className = "w-14 h-14 rounded-full flex items-center justify-center font-black text-2xl border bg-amber-950/40 border-amber-500/50 text-amber-400 shadow-[0_0_15px_rgba(245,158,11,0.15)]";
|
|
548
|
+
metricScoreText.textContent = "Moderate Performance Grade";
|
|
549
|
+
} else {
|
|
550
|
+
scoreBadge.className = "w-14 h-14 rounded-full flex items-center justify-center font-black text-2xl border bg-rose-950/40 border-rose-500/50 text-rose-400 shadow-[0_0_15px_rgba(244,63,94,0.15)]";
|
|
551
|
+
metricScoreText.textContent = "Requires Optimization";
|
|
552
|
+
}
|
|
553
|
+
|
|
554
|
+
const totalJsKb = DATA.islands.reduce((acc, curr) => acc + curr.sizeKb, 0);
|
|
555
|
+
document.getElementById("metric-size").textContent = totalJsKb.toFixed(1) + " kB";
|
|
556
|
+
document.getElementById("metric-count").textContent = DATA.islands.length;
|
|
557
|
+
|
|
558
|
+
const unwrappedCount = DATA.islands.filter(i => i.smartDiscovered).length;
|
|
559
|
+
document.getElementById("metric-unwrapped").textContent = unwrappedCount + " unwrapped warning(s)";
|
|
560
|
+
|
|
561
|
+
const heavyCount = DATA.islands.filter(i => i.isHeavy).length;
|
|
562
|
+
document.getElementById("metric-heavy").textContent = heavyCount + " heavy island(s)";
|
|
563
|
+
|
|
564
|
+
const avgSize = DATA.islands.length > 0 ? (totalJsKb / DATA.islands.length) : 0;
|
|
565
|
+
document.getElementById("metric-avg").textContent = avgSize.toFixed(1) + " kB";
|
|
566
|
+
|
|
567
|
+
let selectedIsland = null;
|
|
568
|
+
function selectIsland(island) {
|
|
569
|
+
selectedIsland = island;
|
|
570
|
+
document.getElementById("no-island-selected").classList.add("hidden");
|
|
571
|
+
const detailsCard = document.getElementById("island-details-card");
|
|
572
|
+
detailsCard.classList.remove("hidden");
|
|
573
|
+
|
|
574
|
+
document.getElementById("details-name").textContent = island.name.split("-").map(w => w.charAt(0).toUpperCase() + w.slice(1)).join("");
|
|
575
|
+
document.getElementById("details-chunk").textContent = island.chunkPath ? \`dist/\${island.chunkPath}\` : "not compiled (static)";
|
|
576
|
+
|
|
577
|
+
const sizeBadge = document.getElementById("details-size-badge");
|
|
578
|
+
sizeBadge.textContent = island.sizeKb.toFixed(1) + " kB";
|
|
579
|
+
if (island.isHeavy) {
|
|
580
|
+
sizeBadge.className = "text-[10px] font-mono font-bold uppercase px-2 py-0.5 rounded bg-rose-950/60 border border-rose-500/30 text-rose-400";
|
|
581
|
+
} else if (island.sizeKb > 50) {
|
|
582
|
+
sizeBadge.className = "text-[10px] font-mono font-bold uppercase px-2 py-0.5 rounded bg-amber-950/60 border border-amber-500/30 text-amber-400";
|
|
583
|
+
} else {
|
|
584
|
+
sizeBadge.className = "text-[10px] font-mono font-bold uppercase px-2 py-0.5 rounded bg-emerald-950/60 border border-emerald-500/30 text-emerald-400";
|
|
585
|
+
}
|
|
586
|
+
|
|
587
|
+
document.getElementById("details-trigger").textContent = island.trigger;
|
|
588
|
+
document.getElementById("details-preload").textContent = island.preload || "none";
|
|
589
|
+
document.getElementById("details-media").textContent = island.media || "none";
|
|
590
|
+
document.getElementById("details-connection").textContent = island.connection || "any";
|
|
591
|
+
document.getElementById("details-client-only").textContent = island.clientOnly ? "true" : "false";
|
|
592
|
+
|
|
593
|
+
const optContainer = document.getElementById("optimization-container");
|
|
594
|
+
optContainer.innerHTML = "";
|
|
595
|
+
|
|
596
|
+
const recommendations = [];
|
|
597
|
+
if (island.smartDiscovered) {
|
|
598
|
+
recommendations.push({
|
|
599
|
+
title: "Wrap Component in <Hydrate>",
|
|
600
|
+
text: \`This component was auto-detected because it uses interactive React hooks. Wrap it explicitly in <code><Hydrate trigger="..."></code> to manage when it activates.\`,
|
|
601
|
+
icon: "alert-triangle",
|
|
602
|
+
color: "text-amber-400"
|
|
603
|
+
});
|
|
604
|
+
}
|
|
605
|
+
|
|
606
|
+
if (island.isHeavy) {
|
|
607
|
+
recommendations.push({
|
|
608
|
+
title: "Reduce Bundle Footprint",
|
|
609
|
+
text: "This component is larger than 100 kB. Move non-interactive display panels to parent templates or code-split complex sub-libraries inside the component.",
|
|
610
|
+
icon: "minimize-2",
|
|
611
|
+
color: "text-rose-400"
|
|
612
|
+
});
|
|
613
|
+
}
|
|
614
|
+
|
|
615
|
+
if (island.trigger === "load") {
|
|
616
|
+
recommendations.push({
|
|
617
|
+
title: "Avoid 'load' Hydration Trigger",
|
|
618
|
+
text: "Hydrating on load blocks page interactivity metrics. Change to <code>trigger='visible'</code> or <code>trigger='interaction'</code> to boost performance scores.",
|
|
619
|
+
icon: "zap-off",
|
|
620
|
+
color: "text-amber-400"
|
|
621
|
+
});
|
|
622
|
+
}
|
|
623
|
+
|
|
624
|
+
if (island.sizeKb > 30 && island.preload === "none" && island.trigger === "visible") {
|
|
625
|
+
recommendations.push({
|
|
626
|
+
title: "Enable Near-Visible Preloading",
|
|
627
|
+
text: "Since this is a medium-sized island, set <code>preload='near-visible'</code> to pre-fetch the JS chunk right before the element intersects the viewport.",
|
|
628
|
+
icon: "download",
|
|
629
|
+
color: "text-cyan-400"
|
|
630
|
+
});
|
|
631
|
+
}
|
|
632
|
+
|
|
633
|
+
if (recommendations.length === 0) {
|
|
634
|
+
recommendations.push({
|
|
635
|
+
title: "Optimal Configuration",
|
|
636
|
+
text: "This hydration island is fully optimized! Keep the size light and triggers non-blocking.",
|
|
637
|
+
icon: "check-circle",
|
|
638
|
+
color: "text-emerald-400"
|
|
639
|
+
});
|
|
640
|
+
}
|
|
641
|
+
|
|
642
|
+
recommendations.forEach(r => {
|
|
643
|
+
const div = document.createElement("div");
|
|
644
|
+
div.className = "flex gap-3 text-xs";
|
|
645
|
+
div.innerHTML = \`
|
|
646
|
+
<div class="mt-0.5 \${r.color}"><i data-lucide="\${r.icon}" class="w-4 h-4"></i></div>
|
|
647
|
+
<div>
|
|
648
|
+
<h5 class="font-bold text-zinc-200">\${r.title}</h5>
|
|
649
|
+
<p class="text-zinc-400 text-[11px] leading-relaxed mt-1">\${r.text}</p>
|
|
650
|
+
</div>
|
|
651
|
+
\`;
|
|
652
|
+
optContainer.appendChild(div);
|
|
653
|
+
});
|
|
654
|
+
if (typeof lucide !== "undefined") {
|
|
655
|
+
try { lucide.createIcons(); } catch (e) {}
|
|
656
|
+
}
|
|
657
|
+
}
|
|
658
|
+
|
|
659
|
+
const container = document.getElementById("graph-islands-container");
|
|
660
|
+
DATA.islands.forEach(island => {
|
|
661
|
+
const card = document.createElement("div");
|
|
662
|
+
|
|
663
|
+
let borderClass = "border-zinc-800 hover:border-zinc-700 text-zinc-300 bg-zinc-900/60";
|
|
664
|
+
let dotColor = "bg-emerald-500";
|
|
665
|
+
|
|
666
|
+
if (island.smartDiscovered) {
|
|
667
|
+
borderClass = "border-dashed border-amber-600/50 hover:border-amber-500 text-amber-200 bg-amber-950/10";
|
|
668
|
+
dotColor = "bg-amber-500";
|
|
669
|
+
} else if (island.isHeavy) {
|
|
670
|
+
borderClass = "border-rose-500/50 hover:border-rose-400 text-rose-200 bg-rose-950/10";
|
|
671
|
+
dotColor = "bg-rose-500";
|
|
672
|
+
} else if (island.sizeKb > 50) {
|
|
673
|
+
borderClass = "border-amber-500/40 hover:border-amber-400 text-amber-100 bg-amber-950/5";
|
|
674
|
+
dotColor = "bg-amber-400";
|
|
675
|
+
}
|
|
676
|
+
|
|
677
|
+
const compTitle = island.name.split("-").map(w => w.charAt(0).toUpperCase() + w.slice(1)).join("");
|
|
678
|
+
|
|
679
|
+
card.className = \`cursor-pointer transition-all hover:scale-[1.02] border rounded-xl p-4 flex flex-col items-start gap-2 min-w-[160px] shadow-lg select-none relative \${borderClass}\`;
|
|
680
|
+
card.innerHTML = \`
|
|
681
|
+
<div class="flex items-center justify-between w-full">
|
|
682
|
+
<span class="inline-flex items-center gap-1 text-[10px] font-bold font-mono text-zinc-400">
|
|
683
|
+
<span class="w-1.5 h-1.5 rounded-full \${dotColor}"></span>
|
|
684
|
+
\${island.sizeKb.toFixed(1)} kB
|
|
685
|
+
</span>
|
|
686
|
+
\${island.smartDiscovered ? '<span class="text-[8px] bg-amber-500/20 text-amber-400 border border-amber-500/30 px-1 py-0.2 rounded font-mono font-bold uppercase">Unwrapped</span>' : ''}
|
|
687
|
+
</div>
|
|
688
|
+
<div class="text-xs font-bold text-zinc-200 mt-1">\${compTitle}</div>
|
|
689
|
+
<div class="flex items-center gap-1.5 text-[9px] font-mono text-zinc-500 mt-0.5">
|
|
690
|
+
<i data-lucide="zap" class="w-3 h-3 text-cyan-500"></i>
|
|
691
|
+
trigger="\${island.trigger}"
|
|
692
|
+
</div>
|
|
693
|
+
\`;
|
|
694
|
+
card.onclick = () => selectIsland(island);
|
|
695
|
+
container.appendChild(card);
|
|
696
|
+
});
|
|
697
|
+
|
|
698
|
+
const tableBody = document.getElementById("islands-table-body");
|
|
699
|
+
function renderTable(filterQuery = "", filterType = "all") {
|
|
700
|
+
tableBody.innerHTML = "";
|
|
701
|
+
|
|
702
|
+
const filtered = DATA.islands.filter(island => {
|
|
703
|
+
const matchesQuery = island.name.toLowerCase().includes(filterQuery.toLowerCase()) ||
|
|
704
|
+
island.file.toLowerCase().includes(filterQuery.toLowerCase());
|
|
705
|
+
|
|
706
|
+
if (filterType === "heavy") {
|
|
707
|
+
return matchesQuery && island.isHeavy;
|
|
708
|
+
}
|
|
709
|
+
if (filterType === "unwrapped") {
|
|
710
|
+
return matchesQuery && island.smartDiscovered;
|
|
711
|
+
}
|
|
712
|
+
return matchesQuery;
|
|
713
|
+
});
|
|
714
|
+
|
|
715
|
+
if (filtered.length === 0) {
|
|
716
|
+
tableBody.innerHTML = \`
|
|
717
|
+
<tr>
|
|
718
|
+
<td colspan="6" class="py-8 text-center text-zinc-500 font-medium">
|
|
719
|
+
No matching hydration islands found.
|
|
720
|
+
</td>
|
|
721
|
+
</tr>
|
|
722
|
+
\`;
|
|
723
|
+
return;
|
|
724
|
+
}
|
|
725
|
+
|
|
726
|
+
filtered.forEach(island => {
|
|
727
|
+
const row = document.createElement("tr");
|
|
728
|
+
row.className = "hover:bg-zinc-900/30 transition-colors group cursor-pointer";
|
|
729
|
+
|
|
730
|
+
let sizeBadgeClass = "text-emerald-400 bg-emerald-500/5 border-emerald-500/10";
|
|
731
|
+
if (island.isHeavy) {
|
|
732
|
+
sizeBadgeClass = "text-rose-400 bg-rose-500/5 border-rose-500/10";
|
|
733
|
+
} else if (island.sizeKb > 50) {
|
|
734
|
+
sizeBadgeClass = "text-amber-400 bg-amber-500/5 border-amber-500/10";
|
|
735
|
+
}
|
|
736
|
+
|
|
737
|
+
const compTitle = island.name.split("-").map(w => w.charAt(0).toUpperCase() + w.slice(1)).join("");
|
|
738
|
+
|
|
739
|
+
row.innerHTML = \`
|
|
740
|
+
<td class="py-3.5 font-bold text-zinc-200">
|
|
741
|
+
\${compTitle}
|
|
742
|
+
<div class="text-[9px] text-zinc-500 font-mono font-normal mt-0.5">\${island.name}</div>
|
|
743
|
+
</td>
|
|
744
|
+
<td class="py-3.5">
|
|
745
|
+
<span class="inline-flex items-center gap-1 px-2 py-0.5 rounded bg-zinc-800 text-zinc-300 font-mono text-[10px]">
|
|
746
|
+
\${island.trigger}
|
|
747
|
+
</span>
|
|
748
|
+
</td>
|
|
749
|
+
<td class="py-3.5">
|
|
750
|
+
<span class="inline-flex px-2 py-0.5 rounded border text-[10px] font-mono font-bold \${sizeBadgeClass}">
|
|
751
|
+
\${island.sizeKb.toFixed(1)} kB
|
|
752
|
+
</span>
|
|
753
|
+
</td>
|
|
754
|
+
<td class="py-3.5 font-mono text-[10px] text-zinc-400">
|
|
755
|
+
\${island.media ? 'media: ' + island.media : ''}
|
|
756
|
+
\${island.connection !== 'any' ? 'connection: ' + island.connection : ''}
|
|
757
|
+
\${(!island.media && island.connection === 'any') ? 'none' : ''}
|
|
758
|
+
</td>
|
|
759
|
+
<td class="py-3.5 font-mono text-[10px] text-zinc-500">
|
|
760
|
+
\${island.file}
|
|
761
|
+
</td>
|
|
762
|
+
<td class="py-3.5 text-right">
|
|
763
|
+
<button class="opacity-0 group-hover:opacity-100 text-cyan-400 hover:text-cyan-300 transition-all font-semibold inline-flex items-center gap-1">
|
|
764
|
+
Analyze <i data-lucide="chevron-right" class="w-3.5 h-3.5"></i>
|
|
765
|
+
</button>
|
|
766
|
+
</td>
|
|
767
|
+
\`;
|
|
768
|
+
row.onclick = () => selectIsland(island);
|
|
769
|
+
tableBody.appendChild(row);
|
|
770
|
+
});
|
|
771
|
+
if (typeof lucide !== "undefined") {
|
|
772
|
+
try { lucide.createIcons(); } catch (e) {}
|
|
773
|
+
}
|
|
774
|
+
}
|
|
775
|
+
|
|
776
|
+
const searchInput = document.getElementById("search-input");
|
|
777
|
+
const filterType = document.getElementById("filter-type");
|
|
778
|
+
|
|
779
|
+
searchInput.addEventListener("input", (e) => {
|
|
780
|
+
renderTable(e.target.value, filterType.value);
|
|
781
|
+
});
|
|
782
|
+
|
|
783
|
+
filterType.addEventListener("change", (e) => {
|
|
784
|
+
renderTable(searchInput.value, e.target.value);
|
|
785
|
+
});
|
|
786
|
+
|
|
787
|
+
renderTable();
|
|
788
|
+
if (typeof lucide !== "undefined") {
|
|
789
|
+
try { lucide.createIcons(); } catch (e) {}
|
|
790
|
+
}
|
|
791
|
+
|
|
792
|
+
if (DATA.islands.length > 0) {
|
|
793
|
+
selectIsland(DATA.islands[0]);
|
|
794
|
+
}
|
|
795
|
+
</script>
|
|
796
|
+
</body>
|
|
797
|
+
</html>`;
|
|
798
|
+
|