@revealui/core 0.3.0 → 0.5.0
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/client/admin/components/AdminDashboard.d.ts.map +1 -1
- package/dist/client/admin/components/AdminDashboard.js +20 -3
- package/dist/client/richtext/index.d.ts.map +1 -1
- package/dist/client/richtext/plugins/FloatingToolbarPlugin.js +1 -3
- package/dist/collections/operations/create.d.ts +2 -1
- package/dist/collections/operations/create.d.ts.map +1 -1
- package/dist/collections/operations/create.js +28 -1
- package/dist/database/type-adapter.d.ts.map +1 -1
- package/dist/features.d.ts +7 -3
- package/dist/features.d.ts.map +1 -1
- package/dist/features.js +2 -0
- package/dist/globals/GlobalOperations.d.ts.map +1 -1
- package/dist/globals/GlobalOperations.js +12 -2
- package/dist/index.d.ts +11 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +11 -1
- package/dist/license.d.ts +6 -0
- package/dist/license.d.ts.map +1 -1
- package/dist/license.js +14 -1
- package/dist/monitoring/alerts.d.ts +4 -4
- package/dist/monitoring/alerts.d.ts.map +1 -1
- package/dist/plugins/nested-docs.d.ts.map +1 -1
- package/dist/plugins/nested-docs.js +0 -1
- package/dist/queries/queryBuilder.d.ts.map +1 -1
- package/dist/queries/queryBuilder.js +4 -3
- package/dist/richtext/index.d.ts.map +1 -1
- package/dist/storage/vercel-blob.d.ts.map +1 -1
- package/dist/storage/vercel-blob.js +3 -0
- package/dist/types/api.d.ts.map +1 -1
- package/dist/types/config.d.ts.map +1 -1
- package/dist/types/core.d.ts +1 -1
- package/dist/types/core.d.ts.map +1 -1
- package/dist/types/extensions.d.ts.map +1 -1
- package/dist/types/frontend.d.ts.map +1 -1
- package/dist/types/legacy.d.ts.map +1 -1
- package/dist/types/query.d.ts.map +1 -1
- package/dist/types/runtime.d.ts +1 -0
- package/dist/types/runtime.d.ts.map +1 -1
- package/dist/utils/error-responses.d.ts.map +1 -1
- package/dist/utils/error-responses.js +2 -3
- package/package.json +23 -23
- package/dist/caching/app-cache.d.ts +0 -242
- package/dist/caching/app-cache.d.ts.map +0 -1
- package/dist/caching/app-cache.js +0 -438
- package/dist/caching/cdn-config.d.ts +0 -155
- package/dist/caching/cdn-config.d.ts.map +0 -1
- package/dist/caching/cdn-config.js +0 -415
- package/dist/caching/edge-cache.d.ts +0 -177
- package/dist/caching/edge-cache.d.ts.map +0 -1
- package/dist/caching/edge-cache.js +0 -414
- package/dist/caching/service-worker.d.ts +0 -157
- package/dist/caching/service-worker.d.ts.map +0 -1
- package/dist/caching/service-worker.js +0 -438
- package/dist/client/admin/utils/auth.d.ts +0 -23
- package/dist/client/admin/utils/auth.d.ts.map +0 -1
- package/dist/client/admin/utils/auth.js +0 -52
- package/dist/client/http/client.d.ts +0 -15
- package/dist/client/http/client.d.ts.map +0 -1
- package/dist/client/http/client.js +0 -49
- package/dist/client/http/fetchBanner.d.ts +0 -18
- package/dist/client/http/fetchBanner.d.ts.map +0 -1
- package/dist/client/http/fetchBanner.js +0 -44
- package/dist/client/http/fetchCard.d.ts +0 -18
- package/dist/client/http/fetchCard.d.ts.map +0 -1
- package/dist/client/http/fetchCard.js +0 -46
- package/dist/client/http/fetchEvents.d.ts +0 -18
- package/dist/client/http/fetchEvents.d.ts.map +0 -1
- package/dist/client/http/fetchEvents.js +0 -44
- package/dist/client/http/fetchHero.d.ts +0 -17
- package/dist/client/http/fetchHero.d.ts.map +0 -1
- package/dist/client/http/fetchHero.js +0 -55
- package/dist/client/http/fetchMainInfos.d.ts +0 -17
- package/dist/client/http/fetchMainInfos.d.ts.map +0 -1
- package/dist/client/http/fetchMainInfos.js +0 -44
- package/dist/client/http/fetchVideos.d.ts +0 -13
- package/dist/client/http/fetchVideos.d.ts.map +0 -1
- package/dist/client/http/fetchVideos.js +0 -36
- package/dist/client/http/index.d.ts +0 -19
- package/dist/client/http/index.d.ts.map +0 -1
- package/dist/client/http/index.js +0 -11
- package/dist/error-handling/circuit-breaker.d.ts +0 -262
- package/dist/error-handling/circuit-breaker.d.ts.map +0 -1
- package/dist/error-handling/circuit-breaker.js +0 -550
- package/dist/error-handling/retry.d.ts +0 -194
- package/dist/error-handling/retry.d.ts.map +0 -1
- package/dist/error-handling/retry.js +0 -455
- package/dist/errors/index.d.ts +0 -23
- package/dist/errors/index.d.ts.map +0 -1
- package/dist/errors/index.js +0 -40
- package/dist/generated/agents/index.d.ts +0 -8
- package/dist/generated/agents/index.d.ts.map +0 -1
- package/dist/generated/agents/index.js +0 -7
- package/dist/generated/components/index.d.ts +0 -8
- package/dist/generated/components/index.d.ts.map +0 -1
- package/dist/generated/components/index.js +0 -7
- package/dist/generated/functions/index.d.ts +0 -8
- package/dist/generated/functions/index.d.ts.map +0 -1
- package/dist/generated/functions/index.js +0 -7
- package/dist/generated/hooks/index.d.ts +0 -8
- package/dist/generated/hooks/index.d.ts.map +0 -1
- package/dist/generated/hooks/index.js +0 -7
- package/dist/generated/plans/index.d.ts +0 -8
- package/dist/generated/plans/index.d.ts.map +0 -1
- package/dist/generated/plans/index.js +0 -7
- package/dist/generated/prompts/index.d.ts +0 -8
- package/dist/generated/prompts/index.d.ts.map +0 -1
- package/dist/generated/prompts/index.js +0 -7
- package/dist/generated/tools/index.d.ts +0 -8
- package/dist/generated/tools/index.d.ts.map +0 -1
- package/dist/generated/tools/index.js +0 -7
- package/dist/generated/types/supabase.d.ts +0 -193
- package/dist/generated/types/supabase.d.ts.map +0 -1
- package/dist/generated/types/supabase.js +0 -5
- package/dist/optimization/asset-optimizer.d.ts +0 -206
- package/dist/optimization/asset-optimizer.d.ts.map +0 -1
- package/dist/optimization/asset-optimizer.js +0 -336
- package/dist/optimization/build-optimizer.d.ts +0 -202
- package/dist/optimization/build-optimizer.d.ts.map +0 -1
- package/dist/optimization/build-optimizer.js +0 -271
- package/dist/optimization/bundle-analyzer.d.ts +0 -98
- package/dist/optimization/bundle-analyzer.d.ts.map +0 -1
- package/dist/optimization/bundle-analyzer.js +0 -346
- package/dist/optimization/code-splitting.d.ts +0 -121
- package/dist/optimization/code-splitting.d.ts.map +0 -1
- package/dist/optimization/code-splitting.js +0 -261
- package/dist/plugin/index.d.ts +0 -12
- package/dist/plugin/index.d.ts.map +0 -1
- package/dist/plugin/index.js +0 -4
- package/dist/security/audit.d.ts +0 -188
- package/dist/security/audit.d.ts.map +0 -1
- package/dist/security/audit.js +0 -433
- package/dist/security/auth.d.ts +0 -110
- package/dist/security/auth.d.ts.map +0 -1
- package/dist/security/auth.js +0 -257
- package/dist/security/authorization.d.ts +0 -211
- package/dist/security/authorization.d.ts.map +0 -1
- package/dist/security/authorization.js +0 -492
- package/dist/security/encryption.d.ts +0 -226
- package/dist/security/encryption.d.ts.map +0 -1
- package/dist/security/encryption.js +0 -534
- package/dist/security/gdpr-storage.d.ts +0 -102
- package/dist/security/gdpr-storage.d.ts.map +0 -1
- package/dist/security/gdpr-storage.js +0 -65
- package/dist/security/gdpr.d.ts +0 -320
- package/dist/security/gdpr.d.ts.map +0 -1
- package/dist/security/gdpr.js +0 -531
- package/dist/security/headers.d.ts +0 -184
- package/dist/security/headers.d.ts.map +0 -1
- package/dist/security/headers.js +0 -420
- package/dist/utils/jwt-validation.d.ts +0 -14
- package/dist/utils/jwt-validation.d.ts.map +0 -1
- package/dist/utils/jwt-validation.js +0 -36
- package/dist/utils/request-headers.d.ts +0 -15
- package/dist/utils/request-headers.d.ts.map +0 -1
- package/dist/utils/request-headers.js +0 -31
|
@@ -1,346 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Bundle Analyzer
|
|
3
|
-
*
|
|
4
|
-
* Analyzes bundle size, dependencies, and optimization opportunities
|
|
5
|
-
*/
|
|
6
|
-
import { readdirSync, readFileSync, statSync } from 'node:fs';
|
|
7
|
-
import { extname, join, relative } from 'node:path';
|
|
8
|
-
/**
|
|
9
|
-
* Analyze bundle directory
|
|
10
|
-
*/
|
|
11
|
-
export function analyzeBundleDirectory(bundlePath) {
|
|
12
|
-
const files = [];
|
|
13
|
-
let totalSize = 0;
|
|
14
|
-
// Recursively scan directory
|
|
15
|
-
function scanDirectory(dir) {
|
|
16
|
-
const entries = readdirSync(dir, { withFileTypes: true });
|
|
17
|
-
for (const entry of entries) {
|
|
18
|
-
const fullPath = join(dir, entry.name);
|
|
19
|
-
if (entry.isDirectory()) {
|
|
20
|
-
scanDirectory(fullPath);
|
|
21
|
-
}
|
|
22
|
-
else if (entry.isFile()) {
|
|
23
|
-
const stats = statSync(fullPath);
|
|
24
|
-
const relativePath = relative(bundlePath, fullPath);
|
|
25
|
-
const ext = extname(entry.name);
|
|
26
|
-
files.push({
|
|
27
|
-
path: relativePath,
|
|
28
|
-
size: stats.size,
|
|
29
|
-
type: ext,
|
|
30
|
-
relativeSize: 0, // Will calculate after total
|
|
31
|
-
});
|
|
32
|
-
totalSize += stats.size;
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
scanDirectory(bundlePath);
|
|
37
|
-
// Calculate relative sizes
|
|
38
|
-
for (const file of files) {
|
|
39
|
-
file.relativeSize = (file.size / totalSize) * 100;
|
|
40
|
-
}
|
|
41
|
-
// Find large files (>100KB)
|
|
42
|
-
const largeFiles = files.filter((f) => f.size > 100 * 1024).sort((a, b) => b.size - a.size);
|
|
43
|
-
return {
|
|
44
|
-
totalSize,
|
|
45
|
-
files,
|
|
46
|
-
chunks: [], // Would need webpack stats for this
|
|
47
|
-
dependencies: [],
|
|
48
|
-
duplicates: [],
|
|
49
|
-
largeFiles,
|
|
50
|
-
};
|
|
51
|
-
}
|
|
52
|
-
/**
|
|
53
|
-
* Format file size
|
|
54
|
-
*/
|
|
55
|
-
export function formatSize(bytes) {
|
|
56
|
-
if (bytes < 1024)
|
|
57
|
-
return `${bytes} B`;
|
|
58
|
-
if (bytes < 1024 * 1024)
|
|
59
|
-
return `${(bytes / 1024).toFixed(2)} KB`;
|
|
60
|
-
return `${(bytes / (1024 * 1024)).toFixed(2)} MB`;
|
|
61
|
-
}
|
|
62
|
-
/**
|
|
63
|
-
* Analyze webpack stats
|
|
64
|
-
*/
|
|
65
|
-
export function analyzeWebpackStats(statsPath) {
|
|
66
|
-
const statsJson = JSON.parse(readFileSync(statsPath, 'utf-8'));
|
|
67
|
-
const files = [];
|
|
68
|
-
const chunks = [];
|
|
69
|
-
const dependencies = new Map();
|
|
70
|
-
let totalSize = 0;
|
|
71
|
-
// Process assets
|
|
72
|
-
if (statsJson.assets) {
|
|
73
|
-
for (const asset of statsJson.assets) {
|
|
74
|
-
files.push({
|
|
75
|
-
path: asset.name,
|
|
76
|
-
size: asset.size,
|
|
77
|
-
type: extname(asset.name),
|
|
78
|
-
relativeSize: 0,
|
|
79
|
-
});
|
|
80
|
-
totalSize += asset.size;
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
// Calculate relative sizes
|
|
84
|
-
for (const file of files) {
|
|
85
|
-
file.relativeSize = (file.size / totalSize) * 100;
|
|
86
|
-
}
|
|
87
|
-
// Process chunks
|
|
88
|
-
if (statsJson.chunks) {
|
|
89
|
-
for (const chunk of statsJson.chunks) {
|
|
90
|
-
chunks.push({
|
|
91
|
-
name: chunk.names?.[0] || chunk.id,
|
|
92
|
-
size: chunk.size,
|
|
93
|
-
files: chunk.files || [],
|
|
94
|
-
dependencies: [],
|
|
95
|
-
});
|
|
96
|
-
}
|
|
97
|
-
}
|
|
98
|
-
// Process modules for dependencies
|
|
99
|
-
if (statsJson.modules) {
|
|
100
|
-
for (const module of statsJson.modules) {
|
|
101
|
-
const match = module.name?.match(/node_modules\/(@?[^/]+\/[^/]+|@?[^/]+)/);
|
|
102
|
-
if (match) {
|
|
103
|
-
const pkgName = match[1];
|
|
104
|
-
const existing = dependencies.get(pkgName);
|
|
105
|
-
if (existing) {
|
|
106
|
-
existing.instances++;
|
|
107
|
-
existing.size += module.size || 0;
|
|
108
|
-
}
|
|
109
|
-
else {
|
|
110
|
-
dependencies.set(pkgName, {
|
|
111
|
-
name: pkgName,
|
|
112
|
-
version: 'unknown',
|
|
113
|
-
size: module.size || 0,
|
|
114
|
-
instances: 1,
|
|
115
|
-
treeshakeable: false,
|
|
116
|
-
});
|
|
117
|
-
}
|
|
118
|
-
}
|
|
119
|
-
}
|
|
120
|
-
}
|
|
121
|
-
const largeFiles = files.filter((f) => f.size > 100 * 1024).sort((a, b) => b.size - a.size);
|
|
122
|
-
return {
|
|
123
|
-
totalSize,
|
|
124
|
-
files,
|
|
125
|
-
chunks,
|
|
126
|
-
dependencies: Array.from(dependencies.values()).sort((a, b) => b.size - a.size),
|
|
127
|
-
duplicates: [],
|
|
128
|
-
largeFiles,
|
|
129
|
-
};
|
|
130
|
-
}
|
|
131
|
-
/**
|
|
132
|
-
* Find duplicate dependencies
|
|
133
|
-
*/
|
|
134
|
-
export function findDuplicateDependencies(stats) {
|
|
135
|
-
// Group dependencies by base package name (strip scope version differences)
|
|
136
|
-
const byName = new Map();
|
|
137
|
-
for (const dep of stats.dependencies) {
|
|
138
|
-
// Normalize: @scope/pkg-name → base name without version suffix
|
|
139
|
-
const baseName = dep.name.replace(/-\d+$/, '');
|
|
140
|
-
const existing = byName.get(baseName);
|
|
141
|
-
if (existing) {
|
|
142
|
-
existing.push(dep);
|
|
143
|
-
}
|
|
144
|
-
else {
|
|
145
|
-
byName.set(baseName, [dep]);
|
|
146
|
-
}
|
|
147
|
-
}
|
|
148
|
-
const duplicates = [];
|
|
149
|
-
for (const [name, deps] of byName.entries()) {
|
|
150
|
-
// Multiple instances of the same dependency indicate duplicates
|
|
151
|
-
if (deps.length > 1 || deps.some((d) => d.instances > 1)) {
|
|
152
|
-
const versions = [...new Set(deps.map((d) => d.version))];
|
|
153
|
-
const totalSize = deps.reduce((sum, d) => sum + d.size, 0);
|
|
154
|
-
duplicates.push({
|
|
155
|
-
name,
|
|
156
|
-
versions,
|
|
157
|
-
totalSize,
|
|
158
|
-
locations: deps.map((d) => d.name),
|
|
159
|
-
});
|
|
160
|
-
}
|
|
161
|
-
}
|
|
162
|
-
return duplicates.sort((a, b) => b.totalSize - a.totalSize);
|
|
163
|
-
}
|
|
164
|
-
export function getOptimizationSuggestions(stats) {
|
|
165
|
-
const suggestions = [];
|
|
166
|
-
// Check total bundle size
|
|
167
|
-
if (stats.totalSize > 500 * 1024) {
|
|
168
|
-
suggestions.push({
|
|
169
|
-
type: 'bundle-split',
|
|
170
|
-
severity: 'critical',
|
|
171
|
-
message: `Total bundle size (${formatSize(stats.totalSize)}) exceeds 500KB. Consider code splitting.`,
|
|
172
|
-
potentialSavings: stats.totalSize - 500 * 1024,
|
|
173
|
-
});
|
|
174
|
-
}
|
|
175
|
-
// Check for large files
|
|
176
|
-
for (const file of stats.largeFiles) {
|
|
177
|
-
if (file.size > 200 * 1024) {
|
|
178
|
-
suggestions.push({
|
|
179
|
-
type: 'dynamic-import',
|
|
180
|
-
severity: 'warning',
|
|
181
|
-
message: `Large file ${file.path} (${formatSize(file.size)}). Consider lazy loading.`,
|
|
182
|
-
potentialSavings: file.size * 0.7, // Assume 70% can be deferred
|
|
183
|
-
file: file.path,
|
|
184
|
-
});
|
|
185
|
-
}
|
|
186
|
-
}
|
|
187
|
-
// Check for duplicate dependencies
|
|
188
|
-
if (stats.duplicates.length > 0) {
|
|
189
|
-
for (const dup of stats.duplicates) {
|
|
190
|
-
suggestions.push({
|
|
191
|
-
type: 'dependency',
|
|
192
|
-
severity: 'warning',
|
|
193
|
-
message: `Duplicate dependency ${dup.name} found in ${dup.versions.length} versions`,
|
|
194
|
-
potentialSavings: dup.totalSize * 0.5,
|
|
195
|
-
});
|
|
196
|
-
}
|
|
197
|
-
}
|
|
198
|
-
// Check for large dependencies
|
|
199
|
-
for (const dep of stats.dependencies) {
|
|
200
|
-
if (dep.size > 100 * 1024) {
|
|
201
|
-
suggestions.push({
|
|
202
|
-
type: 'tree-shaking',
|
|
203
|
-
severity: 'info',
|
|
204
|
-
message: `Large dependency ${dep.name} (${formatSize(dep.size)}). Verify tree shaking.`,
|
|
205
|
-
});
|
|
206
|
-
}
|
|
207
|
-
}
|
|
208
|
-
return suggestions.sort((a, b) => {
|
|
209
|
-
const severityOrder = { critical: 0, warning: 1, info: 2 };
|
|
210
|
-
return severityOrder[a.severity] - severityOrder[b.severity];
|
|
211
|
-
});
|
|
212
|
-
}
|
|
213
|
-
/**
|
|
214
|
-
* Generate bundle report
|
|
215
|
-
*/
|
|
216
|
-
export function generateBundleReport(stats) {
|
|
217
|
-
const suggestions = getOptimizationSuggestions(stats);
|
|
218
|
-
let report = '# Bundle Analysis Report\n\n';
|
|
219
|
-
report += `## Summary\n\n`;
|
|
220
|
-
report += `- Total Size: ${formatSize(stats.totalSize)}\n`;
|
|
221
|
-
report += `- Files: ${stats.files.length}\n`;
|
|
222
|
-
report += `- Chunks: ${stats.chunks.length}\n`;
|
|
223
|
-
report += `- Dependencies: ${stats.dependencies.length}\n`;
|
|
224
|
-
report += `- Large Files: ${stats.largeFiles.length}\n\n`;
|
|
225
|
-
if (stats.largeFiles.length > 0) {
|
|
226
|
-
report += `## Large Files (>100KB)\n\n`;
|
|
227
|
-
report += `| File | Size | % of Total |\n`;
|
|
228
|
-
report += `|------|------|------------|\n`;
|
|
229
|
-
for (const file of stats.largeFiles.slice(0, 10)) {
|
|
230
|
-
report += `| ${file.path} | ${formatSize(file.size)} | ${file.relativeSize.toFixed(1)}% |\n`;
|
|
231
|
-
}
|
|
232
|
-
report += '\n';
|
|
233
|
-
}
|
|
234
|
-
if (stats.dependencies.length > 0) {
|
|
235
|
-
report += `## Top Dependencies\n\n`;
|
|
236
|
-
report += `| Package | Size | Instances |\n`;
|
|
237
|
-
report += `|---------|------|----------|\n`;
|
|
238
|
-
for (const dep of stats.dependencies.slice(0, 10)) {
|
|
239
|
-
report += `| ${dep.name} | ${formatSize(dep.size)} | ${dep.instances} |\n`;
|
|
240
|
-
}
|
|
241
|
-
report += '\n';
|
|
242
|
-
}
|
|
243
|
-
if (suggestions.length > 0) {
|
|
244
|
-
report += `## Optimization Suggestions\n\n`;
|
|
245
|
-
for (const suggestion of suggestions) {
|
|
246
|
-
const icon = suggestion.severity === 'critical' ? '🔴' : suggestion.severity === 'warning' ? '⚠️' : 'ℹ️';
|
|
247
|
-
report += `${icon} **${suggestion.type}**: ${suggestion.message}\n`;
|
|
248
|
-
if (suggestion.potentialSavings) {
|
|
249
|
-
report += ` Potential savings: ${formatSize(suggestion.potentialSavings)}\n`;
|
|
250
|
-
}
|
|
251
|
-
report += '\n';
|
|
252
|
-
}
|
|
253
|
-
}
|
|
254
|
-
return report;
|
|
255
|
-
}
|
|
256
|
-
export function compareBundles(before, after) {
|
|
257
|
-
const sizeDiff = after.totalSize - before.totalSize;
|
|
258
|
-
const sizeChangePercent = (sizeDiff / before.totalSize) * 100;
|
|
259
|
-
const beforeFiles = new Set(before.files.map((f) => f.path));
|
|
260
|
-
const afterFiles = new Set(after.files.map((f) => f.path));
|
|
261
|
-
const filesAdded = after.files.filter((f) => !beforeFiles.has(f.path)).length;
|
|
262
|
-
const filesRemoved = before.files.filter((f) => !afterFiles.has(f.path)).length;
|
|
263
|
-
const filesChanged = after.files.filter((f) => {
|
|
264
|
-
const beforeFile = before.files.find((bf) => bf.path === f.path);
|
|
265
|
-
return beforeFile && beforeFile.size !== f.size;
|
|
266
|
-
}).length;
|
|
267
|
-
const newLargeFiles = after.largeFiles.filter((f) => {
|
|
268
|
-
const beforeFile = before.files.find((bf) => bf.path === f.path);
|
|
269
|
-
return !beforeFile || beforeFile.size < 100 * 1024;
|
|
270
|
-
});
|
|
271
|
-
const improvements = [];
|
|
272
|
-
const regressions = [];
|
|
273
|
-
if (sizeDiff < 0) {
|
|
274
|
-
improvements.push(`Total bundle size reduced by ${formatSize(Math.abs(sizeDiff))}`);
|
|
275
|
-
}
|
|
276
|
-
else if (sizeDiff > 0) {
|
|
277
|
-
regressions.push(`Total bundle size increased by ${formatSize(sizeDiff)}`);
|
|
278
|
-
}
|
|
279
|
-
if (after.largeFiles.length < before.largeFiles.length) {
|
|
280
|
-
improvements.push(`${before.largeFiles.length - after.largeFiles.length} fewer large files`);
|
|
281
|
-
}
|
|
282
|
-
else if (after.largeFiles.length > before.largeFiles.length) {
|
|
283
|
-
regressions.push(`${after.largeFiles.length - before.largeFiles.length} new large files`);
|
|
284
|
-
}
|
|
285
|
-
return {
|
|
286
|
-
sizeDiff,
|
|
287
|
-
sizeChangePercent,
|
|
288
|
-
filesAdded,
|
|
289
|
-
filesRemoved,
|
|
290
|
-
filesChanged,
|
|
291
|
-
newLargeFiles,
|
|
292
|
-
improvements,
|
|
293
|
-
regressions,
|
|
294
|
-
};
|
|
295
|
-
}
|
|
296
|
-
/**
|
|
297
|
-
* Get bundle health score (0-100)
|
|
298
|
-
*/
|
|
299
|
-
export function getBundleHealthScore(stats) {
|
|
300
|
-
const factors = [];
|
|
301
|
-
// Factor 1: Total size (40% weight)
|
|
302
|
-
let sizeScore = 100;
|
|
303
|
-
if (stats.totalSize > 1024 * 1024) {
|
|
304
|
-
sizeScore = Math.max(0, 100 - ((stats.totalSize - 1024 * 1024) / (1024 * 1024)) * 50);
|
|
305
|
-
}
|
|
306
|
-
else if (stats.totalSize > 500 * 1024) {
|
|
307
|
-
sizeScore = 100 - ((stats.totalSize - 500 * 1024) / (500 * 1024)) * 30;
|
|
308
|
-
}
|
|
309
|
-
factors.push({
|
|
310
|
-
name: 'Bundle Size',
|
|
311
|
-
score: sizeScore,
|
|
312
|
-
weight: 0.4,
|
|
313
|
-
reason: `Total size: ${formatSize(stats.totalSize)}`,
|
|
314
|
-
});
|
|
315
|
-
// Factor 2: Large files (30% weight)
|
|
316
|
-
const largeFileScore = Math.max(0, 100 - stats.largeFiles.length * 10);
|
|
317
|
-
factors.push({
|
|
318
|
-
name: 'Large Files',
|
|
319
|
-
score: largeFileScore,
|
|
320
|
-
weight: 0.3,
|
|
321
|
-
reason: `${stats.largeFiles.length} files over 100KB`,
|
|
322
|
-
});
|
|
323
|
-
// Factor 3: Chunks (20% weight)
|
|
324
|
-
const optimalChunks = 10;
|
|
325
|
-
const chunkScore = 100 - Math.abs(stats.chunks.length - optimalChunks) * 5;
|
|
326
|
-
factors.push({
|
|
327
|
-
name: 'Code Splitting',
|
|
328
|
-
score: Math.max(0, chunkScore),
|
|
329
|
-
weight: 0.2,
|
|
330
|
-
reason: `${stats.chunks.length} chunks (optimal: ~${optimalChunks})`,
|
|
331
|
-
});
|
|
332
|
-
// Factor 4: Duplicates (10% weight)
|
|
333
|
-
const duplicateScore = Math.max(0, 100 - stats.duplicates.length * 20);
|
|
334
|
-
factors.push({
|
|
335
|
-
name: 'Dependencies',
|
|
336
|
-
score: duplicateScore,
|
|
337
|
-
weight: 0.1,
|
|
338
|
-
reason: `${stats.duplicates.length} duplicate dependencies`,
|
|
339
|
-
});
|
|
340
|
-
// Calculate weighted score
|
|
341
|
-
const totalScore = factors.reduce((sum, factor) => sum + factor.score * factor.weight, 0);
|
|
342
|
-
return {
|
|
343
|
-
score: Math.round(totalScore),
|
|
344
|
-
factors,
|
|
345
|
-
};
|
|
346
|
-
}
|
|
@@ -1,121 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Code Splitting Utilities
|
|
3
|
-
*
|
|
4
|
-
* Helpers for dynamic imports, lazy loading, and code splitting
|
|
5
|
-
*/
|
|
6
|
-
import { type ComponentType, type LazyExoticComponent } from 'react';
|
|
7
|
-
/**
|
|
8
|
-
* Lazy load component with retry logic
|
|
9
|
-
*/
|
|
10
|
-
export interface LazyLoadOptions {
|
|
11
|
-
maxRetries?: number;
|
|
12
|
-
retryDelay?: number;
|
|
13
|
-
fallback?: ComponentType;
|
|
14
|
-
}
|
|
15
|
-
export declare function lazyWithRetry<TProps = Record<string, unknown>>(importFn: () => Promise<{
|
|
16
|
-
default: ComponentType<TProps>;
|
|
17
|
-
}>, options?: LazyLoadOptions): LazyExoticComponent<ComponentType<TProps>>;
|
|
18
|
-
/**
|
|
19
|
-
* Preload component
|
|
20
|
-
*/
|
|
21
|
-
export declare function preloadComponent<T = unknown>(importFn: () => Promise<T>): Promise<T>;
|
|
22
|
-
/**
|
|
23
|
-
* Lazy load with prefetch on hover
|
|
24
|
-
*/
|
|
25
|
-
export declare function lazyWithPrefetch<TProps = Record<string, unknown>>(importFn: () => Promise<{
|
|
26
|
-
default: ComponentType<TProps>;
|
|
27
|
-
}>): {
|
|
28
|
-
Component: LazyExoticComponent<ComponentType<TProps>>;
|
|
29
|
-
prefetch: () => void;
|
|
30
|
-
};
|
|
31
|
-
/**
|
|
32
|
-
* Route-based code splitting helper
|
|
33
|
-
*/
|
|
34
|
-
export interface RouteConfig<TProps = Record<string, unknown>> {
|
|
35
|
-
path: string;
|
|
36
|
-
component: () => Promise<{
|
|
37
|
-
default: ComponentType<TProps>;
|
|
38
|
-
}>;
|
|
39
|
-
preload?: boolean;
|
|
40
|
-
}
|
|
41
|
-
export declare function createRoutes(configs: RouteConfig[]): {
|
|
42
|
-
path: string;
|
|
43
|
-
Component: LazyExoticComponent<ComponentType<Record<string, unknown>>>;
|
|
44
|
-
preload: (() => Promise<{
|
|
45
|
-
default: ComponentType<Record<string, unknown>>;
|
|
46
|
-
}>) | undefined;
|
|
47
|
-
}[];
|
|
48
|
-
/**
|
|
49
|
-
* Chunk naming helper
|
|
50
|
-
*/
|
|
51
|
-
export declare function createChunkName(name: string): string;
|
|
52
|
-
/**
|
|
53
|
-
* Prefetch multiple components
|
|
54
|
-
*/
|
|
55
|
-
export declare function prefetchComponents<T = unknown>(importFns: Array<() => Promise<T>>): Promise<T[]>;
|
|
56
|
-
/**
|
|
57
|
-
* Idle callback prefetch
|
|
58
|
-
*/
|
|
59
|
-
export declare function prefetchOnIdle(importFn: () => Promise<unknown>): void;
|
|
60
|
-
/**
|
|
61
|
-
* Intersection observer prefetch
|
|
62
|
-
*/
|
|
63
|
-
export declare function prefetchOnVisible(element: HTMLElement | null, importFn: () => Promise<unknown>, options?: IntersectionObserverInit): () => void;
|
|
64
|
-
/**
|
|
65
|
-
* Media query based loading
|
|
66
|
-
*/
|
|
67
|
-
export declare function loadOnMediaQuery(query: string, importFn: () => Promise<unknown>): () => void;
|
|
68
|
-
/**
|
|
69
|
-
* Load on interaction (click, hover, focus)
|
|
70
|
-
*/
|
|
71
|
-
export declare function loadOnInteraction(element: HTMLElement | null, importFn: () => Promise<unknown>, events?: string[]): () => void;
|
|
72
|
-
/**
|
|
73
|
-
* Split vendors into separate chunks
|
|
74
|
-
*/
|
|
75
|
-
export interface VendorChunkConfig {
|
|
76
|
-
name: string;
|
|
77
|
-
test: RegExp;
|
|
78
|
-
priority?: number;
|
|
79
|
-
}
|
|
80
|
-
export declare const VENDOR_CHUNK_CONFIGS: VendorChunkConfig[];
|
|
81
|
-
/**
|
|
82
|
-
* Generate webpack splitChunks config
|
|
83
|
-
*/
|
|
84
|
-
export declare function generateSplitChunksConfig(customChunks?: VendorChunkConfig[]): {
|
|
85
|
-
chunks: string;
|
|
86
|
-
maxInitialRequests: number;
|
|
87
|
-
maxAsyncRequests: number;
|
|
88
|
-
minSize: number;
|
|
89
|
-
cacheGroups: Record<string, unknown>;
|
|
90
|
-
};
|
|
91
|
-
/**
|
|
92
|
-
* Module concatenation helper
|
|
93
|
-
*/
|
|
94
|
-
export declare function shouldConcatenateModule(modulePath: string): boolean;
|
|
95
|
-
/**
|
|
96
|
-
* Inline critical scripts
|
|
97
|
-
*/
|
|
98
|
-
export declare function shouldInlineScript(scriptPath: string, size: number): boolean;
|
|
99
|
-
/**
|
|
100
|
-
* Bundle budget checker
|
|
101
|
-
*/
|
|
102
|
-
export interface BundleBudget {
|
|
103
|
-
maxSize: number;
|
|
104
|
-
maxInitialSize: number;
|
|
105
|
-
maxAsyncSize: number;
|
|
106
|
-
maxCSSSize: number;
|
|
107
|
-
}
|
|
108
|
-
export declare const DEFAULT_BUDGETS: BundleBudget;
|
|
109
|
-
export interface BudgetViolation {
|
|
110
|
-
type: 'total' | 'initial' | 'async' | 'css';
|
|
111
|
-
actual: number;
|
|
112
|
-
budget: number;
|
|
113
|
-
exceeded: number;
|
|
114
|
-
}
|
|
115
|
-
export declare function checkBundleBudgets(stats: {
|
|
116
|
-
totalSize: number;
|
|
117
|
-
initialSize: number;
|
|
118
|
-
asyncSizes: number[];
|
|
119
|
-
cssSize: number;
|
|
120
|
-
}, budgets?: BundleBudget): BudgetViolation[];
|
|
121
|
-
//# sourceMappingURL=code-splitting.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"code-splitting.d.ts","sourceRoot":"","sources":["../../src/optimization/code-splitting.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,KAAK,aAAa,EAAE,KAAK,mBAAmB,EAAQ,MAAM,OAAO,CAAA;AAG1E;;GAEG;AACH,MAAM,WAAW,eAAe;IAC9B,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,QAAQ,CAAC,EAAE,aAAa,CAAA;CACzB;AAED,wBAAgB,aAAa,CAAC,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC5D,QAAQ,EAAE,MAAM,OAAO,CAAC;IAAE,OAAO,EAAE,aAAa,CAAC,MAAM,CAAC,CAAA;CAAE,CAAC,EAC3D,OAAO,GAAE,eAAoB,GAC5B,mBAAmB,CAAC,aAAa,CAAC,MAAM,CAAC,CAAC,CA6B5C;AAED;;GAEG;AACH,wBAAgB,gBAAgB,CAAC,CAAC,GAAG,OAAO,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,CAEpF;AAED;;GAEG;AACH,wBAAgB,gBAAgB,CAAC,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC/D,QAAQ,EAAE,MAAM,OAAO,CAAC;IAAE,OAAO,EAAE,aAAa,CAAC,MAAM,CAAC,CAAA;CAAE,CAAC,GAC1D;IACD,SAAS,EAAE,mBAAmB,CAAC,aAAa,CAAC,MAAM,CAAC,CAAC,CAAA;IACrD,QAAQ,EAAE,MAAM,IA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