vite-plugin-smart-prefetch 0.3.4 ā 0.3.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/react 2/index.cjs +700 -0
- package/dist/react 2/index.cjs.map +1 -0
- package/dist/react 2/index.d.cts +157 -0
- package/dist/react 2/index.d.ts +157 -0
- package/dist/react 2/index.js +660 -0
- package/dist/react 2/index.js.map +1 -0
- package/dist/runtime 2/index.cjs +582 -0
- package/dist/runtime 2/index.cjs.map +1 -0
- package/dist/runtime 2/index.d.cts +192 -0
- package/dist/runtime 2/index.d.ts +192 -0
- package/dist/runtime 2/index.js +549 -0
- package/dist/runtime 2/index.js.map +1 -0
- package/package.json +1 -1
|
@@ -0,0 +1,549 @@
|
|
|
1
|
+
// src/runtime/prefetch-manager.ts
|
|
2
|
+
var PrefetchManager = class {
|
|
3
|
+
constructor(strategy = "hybrid", debug = false) {
|
|
4
|
+
this.config = null;
|
|
5
|
+
this.prefetched = /* @__PURE__ */ new Set();
|
|
6
|
+
this.observer = null;
|
|
7
|
+
this.strategy = strategy;
|
|
8
|
+
this.debug = debug;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Initialize the prefetch manager
|
|
12
|
+
* Loads configuration and sets up observers
|
|
13
|
+
*/
|
|
14
|
+
async init() {
|
|
15
|
+
if (this.debug) {
|
|
16
|
+
console.log("\u{1F680} Smart Prefetch Manager - Initializing...");
|
|
17
|
+
console.log(" Strategy:", this.strategy);
|
|
18
|
+
console.log(" Debug mode: enabled");
|
|
19
|
+
}
|
|
20
|
+
try {
|
|
21
|
+
if (this.debug) {
|
|
22
|
+
console.log("\u{1F4E5} Fetching prefetch-config.json...");
|
|
23
|
+
}
|
|
24
|
+
const response = await fetch("/prefetch-config.json");
|
|
25
|
+
if (!response.ok) {
|
|
26
|
+
if (response.status === 404) {
|
|
27
|
+
if (this.debug) {
|
|
28
|
+
console.warn("\u26A0\uFE0F Prefetch config not found (404)");
|
|
29
|
+
console.log(" This is expected if:");
|
|
30
|
+
console.log(" 1. You haven't built the app yet (run `pnpm build`)");
|
|
31
|
+
console.log(" 2. The plugin failed to generate the config during build");
|
|
32
|
+
console.log(" Prefetch manager will be inactive until config is available");
|
|
33
|
+
}
|
|
34
|
+
return;
|
|
35
|
+
}
|
|
36
|
+
throw new Error(`Failed to load prefetch config: ${response.statusText}`);
|
|
37
|
+
}
|
|
38
|
+
this.config = await response.json();
|
|
39
|
+
if (this.debug && this.config) {
|
|
40
|
+
console.log("\u2705 Config loaded successfully");
|
|
41
|
+
console.log(` Routes with prefetch rules: ${Object.keys(this.config.routes).length} ${typeof this.config.routes}`);
|
|
42
|
+
console.log(` Environment: ${this.config.environment}`);
|
|
43
|
+
console.log(` Config version: ${this.config.version || "N/A"}`);
|
|
44
|
+
console.groupCollapsed("\u{1F4CB} Available prefetch rules:");
|
|
45
|
+
Object.entries(this.config.routes).forEach(([source, data]) => {
|
|
46
|
+
console.log(
|
|
47
|
+
`${source} \u2192 ${data.prefetch.length} target(s)`,
|
|
48
|
+
data.prefetch.map((t) => t.route)
|
|
49
|
+
);
|
|
50
|
+
});
|
|
51
|
+
console.groupEnd();
|
|
52
|
+
}
|
|
53
|
+
if (this.strategy === "visible" || this.strategy === "hybrid") {
|
|
54
|
+
this.initIntersectionObserver();
|
|
55
|
+
if (this.debug) {
|
|
56
|
+
console.log("\u{1F441}\uFE0F IntersectionObserver initialized for visibility-based prefetching");
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
if (this.debug) {
|
|
60
|
+
console.log("\u2705 Prefetch Manager fully initialized");
|
|
61
|
+
console.log("\u{1F4A1} Run window.__PREFETCH_DEBUG__() to see current state");
|
|
62
|
+
window.__PREFETCH_DEBUG__ = () => this.logDebugInfo();
|
|
63
|
+
}
|
|
64
|
+
} catch (error) {
|
|
65
|
+
if (this.debug) {
|
|
66
|
+
console.error("\u274C Failed to initialize Prefetch Manager:", error);
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* Prefetch routes based on current route
|
|
72
|
+
*/
|
|
73
|
+
prefetch(currentRoute) {
|
|
74
|
+
const cleanRoute = currentRoute.split("?")[0].split("#")[0];
|
|
75
|
+
if (this.debug) {
|
|
76
|
+
console.log(`\u{1F4CD} Checking prefetch for route: ${currentRoute}`);
|
|
77
|
+
if (currentRoute !== cleanRoute) {
|
|
78
|
+
console.log(` Clean route: ${cleanRoute}`);
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
if (!this.config) {
|
|
82
|
+
if (this.debug) {
|
|
83
|
+
console.warn("\u26A0\uFE0F Config not loaded yet - cannot prefetch");
|
|
84
|
+
console.log(" Make sure the app was built with the plugin enabled");
|
|
85
|
+
}
|
|
86
|
+
return;
|
|
87
|
+
}
|
|
88
|
+
if (!this.shouldPrefetch()) {
|
|
89
|
+
if (this.debug) {
|
|
90
|
+
console.log("\u23ED\uFE0F Skipping prefetch due to network conditions");
|
|
91
|
+
}
|
|
92
|
+
return;
|
|
93
|
+
}
|
|
94
|
+
let routeConfig = this.config.routes[cleanRoute] || this.config.routes[currentRoute];
|
|
95
|
+
const matchedRoute = routeConfig ? this.config.routes[cleanRoute] ? cleanRoute : currentRoute : null;
|
|
96
|
+
if (!routeConfig) {
|
|
97
|
+
if (this.debug) {
|
|
98
|
+
console.warn(`\u26A0\uFE0F No prefetch rules configured for route: ${cleanRoute}`);
|
|
99
|
+
console.groupCollapsed("Available routes in config:");
|
|
100
|
+
Object.keys(this.config.routes).forEach((route) => {
|
|
101
|
+
const targets = this.config.routes[route].prefetch;
|
|
102
|
+
console.log(` ${route} \u2192 ${targets.length} target(s)`, targets.map((t) => t.route));
|
|
103
|
+
});
|
|
104
|
+
console.groupEnd();
|
|
105
|
+
console.log(`\u{1F4A1} Tip: Make sure your manualRules key matches exactly: "${cleanRoute}"`);
|
|
106
|
+
}
|
|
107
|
+
return;
|
|
108
|
+
}
|
|
109
|
+
console.log(`\u2705 Found prefetch rule for: ${matchedRoute}`);
|
|
110
|
+
console.log(` Total targets to prefetch: ${routeConfig.prefetch.length}`);
|
|
111
|
+
console.log(` Strategy: ${this.strategy}`);
|
|
112
|
+
if (this.debug) {
|
|
113
|
+
console.groupCollapsed(`\u{1F4CA} Prefetch Rules for: ${matchedRoute}`);
|
|
114
|
+
routeConfig.prefetch.forEach((target, index) => {
|
|
115
|
+
console.log(` ${index + 1}. ${target.route} (${target.priority} priority, ${(target.probability * 100).toFixed(1)}%)`);
|
|
116
|
+
});
|
|
117
|
+
console.groupEnd();
|
|
118
|
+
}
|
|
119
|
+
routeConfig.prefetch.forEach((target) => {
|
|
120
|
+
this.prefetchTarget(target);
|
|
121
|
+
});
|
|
122
|
+
}
|
|
123
|
+
/**
|
|
124
|
+
* Prefetch a specific target
|
|
125
|
+
*/
|
|
126
|
+
prefetchTarget(target) {
|
|
127
|
+
if (this.prefetched.has(target.route)) {
|
|
128
|
+
return;
|
|
129
|
+
}
|
|
130
|
+
switch (this.strategy) {
|
|
131
|
+
case "auto":
|
|
132
|
+
this.injectPrefetchLink(target);
|
|
133
|
+
break;
|
|
134
|
+
case "hover":
|
|
135
|
+
break;
|
|
136
|
+
case "visible":
|
|
137
|
+
break;
|
|
138
|
+
case "idle":
|
|
139
|
+
this.prefetchOnIdle(target);
|
|
140
|
+
break;
|
|
141
|
+
case "hybrid":
|
|
142
|
+
this.prefetchHybrid(target);
|
|
143
|
+
break;
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
/**
|
|
147
|
+
* Hybrid strategy: prioritize based on probability
|
|
148
|
+
* FOR TESTING: Fetch all priorities to verify chunks are correct
|
|
149
|
+
*/
|
|
150
|
+
prefetchHybrid(target) {
|
|
151
|
+
if (target.priority === "high" || target.probability >= 0.7) {
|
|
152
|
+
console.log(` \u26A1 High priority (${(target.probability * 100).toFixed(1)}%) - Prefetching immediately`);
|
|
153
|
+
this.injectPrefetchLink(target);
|
|
154
|
+
} else if (target.priority === "medium" || target.probability >= 0.4) {
|
|
155
|
+
console.log(` \u23F1\uFE0F Medium priority (${(target.probability * 100).toFixed(1)}%) - Fetching immediately (TESTING MODE)`);
|
|
156
|
+
this.injectPrefetchLink(target);
|
|
157
|
+
} else {
|
|
158
|
+
console.log(` \u{1F514} Low priority (${(target.probability * 100).toFixed(1)}%) - Fetching immediately (TESTING MODE)`);
|
|
159
|
+
this.injectPrefetchLink(target);
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
/**
|
|
163
|
+
* Prefetch during idle time
|
|
164
|
+
*/
|
|
165
|
+
prefetchOnIdle(target) {
|
|
166
|
+
if ("requestIdleCallback" in window) {
|
|
167
|
+
requestIdleCallback(() => {
|
|
168
|
+
this.injectPrefetchLink(target);
|
|
169
|
+
});
|
|
170
|
+
} else {
|
|
171
|
+
setTimeout(() => {
|
|
172
|
+
this.injectPrefetchLink(target);
|
|
173
|
+
}, 1e3);
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
/**
|
|
177
|
+
* Inject prefetch link into DOM
|
|
178
|
+
*/
|
|
179
|
+
injectPrefetchLink(target) {
|
|
180
|
+
if (this.prefetched.has(target.route)) {
|
|
181
|
+
if (this.debug) {
|
|
182
|
+
console.log(` \u23ED\uFE0F Already prefetched: ${target.route}`);
|
|
183
|
+
}
|
|
184
|
+
return;
|
|
185
|
+
}
|
|
186
|
+
const link = document.createElement("link");
|
|
187
|
+
link.rel = "modulepreload";
|
|
188
|
+
link.href = `/${target.chunk}`;
|
|
189
|
+
link.setAttribute("data-prefetch-route", target.route);
|
|
190
|
+
link.setAttribute("data-prefetch-priority", target.priority);
|
|
191
|
+
link.setAttribute("data-prefetch-probability", target.probability.toString());
|
|
192
|
+
console.groupCollapsed(`\u{1F517} PREFETCH: ${target.route}`);
|
|
193
|
+
console.log(` \u{1F4C4} Page/Route: ${target.route}`);
|
|
194
|
+
console.log(` \u{1F4E6} Main Chunk: ${target.chunk}`);
|
|
195
|
+
console.log(` \u{1F310} Full URL: ${window.location.origin}/${target.chunk}`);
|
|
196
|
+
console.log(` \u2B50 Priority: ${target.priority}`);
|
|
197
|
+
console.log(` \u{1F4CA} Probability: ${(target.probability * 100).toFixed(1)}%`);
|
|
198
|
+
if (this.debug) {
|
|
199
|
+
console.log(` Link element:`, link);
|
|
200
|
+
}
|
|
201
|
+
document.head.appendChild(link);
|
|
202
|
+
let totalChunksForThisRoute = 1;
|
|
203
|
+
if (target.imports && target.imports.length > 0) {
|
|
204
|
+
console.log(` \u{1F4DA} Dependencies (${target.imports.length}):`);
|
|
205
|
+
target.imports.forEach((importChunk, index) => {
|
|
206
|
+
const importId = `import:${importChunk}`;
|
|
207
|
+
if (this.prefetched.has(importId)) {
|
|
208
|
+
console.log(` ${index + 1}. ${importChunk} (already prefetched)`);
|
|
209
|
+
return;
|
|
210
|
+
}
|
|
211
|
+
const importLink = document.createElement("link");
|
|
212
|
+
importLink.rel = "modulepreload";
|
|
213
|
+
importLink.href = `/${importChunk}`;
|
|
214
|
+
importLink.setAttribute("data-prefetch-import", "true");
|
|
215
|
+
importLink.setAttribute("data-prefetch-parent", target.route);
|
|
216
|
+
document.head.appendChild(importLink);
|
|
217
|
+
this.prefetched.add(importId);
|
|
218
|
+
totalChunksForThisRoute++;
|
|
219
|
+
console.log(` ${index + 1}. ${importChunk} \u2705`);
|
|
220
|
+
});
|
|
221
|
+
}
|
|
222
|
+
this.prefetched.add(target.route);
|
|
223
|
+
console.log(` \u2705 Total chunks injected: ${totalChunksForThisRoute}`);
|
|
224
|
+
console.log(` \u{1F4C8} Overall prefetched count: ${this.prefetched.size}`);
|
|
225
|
+
if (this.debug) {
|
|
226
|
+
console.log(` DOM Status: Link tag added to document.head`);
|
|
227
|
+
setTimeout(() => {
|
|
228
|
+
const addedLink = document.querySelector(`link[data-prefetch-route="${target.route}"]`);
|
|
229
|
+
if (addedLink) {
|
|
230
|
+
console.log(` \u2714\uFE0F DOM Verification: Link exists`);
|
|
231
|
+
console.log(` href:`, addedLink.href);
|
|
232
|
+
} else {
|
|
233
|
+
console.error(` \u274C ERROR: Link tag not found in DOM`);
|
|
234
|
+
}
|
|
235
|
+
}, 100);
|
|
236
|
+
}
|
|
237
|
+
console.groupEnd();
|
|
238
|
+
}
|
|
239
|
+
/**
|
|
240
|
+
* Check if prefetching should be performed based on network conditions
|
|
241
|
+
*/
|
|
242
|
+
shouldPrefetch() {
|
|
243
|
+
const nav = navigator;
|
|
244
|
+
const connection = nav.connection || nav.mozConnection || nav.webkitConnection;
|
|
245
|
+
if (!connection) {
|
|
246
|
+
return true;
|
|
247
|
+
}
|
|
248
|
+
if (connection.saveData) {
|
|
249
|
+
if (this.debug) console.log(" \u26A0\uFE0F Data Saver enabled");
|
|
250
|
+
return false;
|
|
251
|
+
}
|
|
252
|
+
const slowConnections = ["slow-2g", "2g"];
|
|
253
|
+
if (slowConnections.includes(connection.effectiveType)) {
|
|
254
|
+
if (this.debug) console.log(` \u26A0\uFE0F Slow connection: ${connection.effectiveType}`);
|
|
255
|
+
return false;
|
|
256
|
+
}
|
|
257
|
+
if (connection.type === "cellular" && connection.effectiveType !== "4g") {
|
|
258
|
+
if (this.debug) console.log(" \u26A0\uFE0F Metered connection");
|
|
259
|
+
return false;
|
|
260
|
+
}
|
|
261
|
+
return true;
|
|
262
|
+
}
|
|
263
|
+
/**
|
|
264
|
+
* Initialize IntersectionObserver for 'visible' strategy
|
|
265
|
+
*/
|
|
266
|
+
initIntersectionObserver() {
|
|
267
|
+
this.observer = new IntersectionObserver(
|
|
268
|
+
(entries) => {
|
|
269
|
+
entries.forEach((entry) => {
|
|
270
|
+
if (entry.isIntersecting) {
|
|
271
|
+
const route = entry.target.getAttribute("data-prefetch-route");
|
|
272
|
+
if (route && this.config) {
|
|
273
|
+
Object.values(this.config.routes).forEach((routeConfig) => {
|
|
274
|
+
const target = routeConfig.prefetch.find((t) => t.route === route);
|
|
275
|
+
if (target) {
|
|
276
|
+
this.injectPrefetchLink(target);
|
|
277
|
+
}
|
|
278
|
+
});
|
|
279
|
+
}
|
|
280
|
+
}
|
|
281
|
+
});
|
|
282
|
+
},
|
|
283
|
+
{
|
|
284
|
+
rootMargin: "50px"
|
|
285
|
+
// Start prefetch 50px before element is visible
|
|
286
|
+
}
|
|
287
|
+
);
|
|
288
|
+
}
|
|
289
|
+
/**
|
|
290
|
+
* Observe an element for visibility-based prefetching
|
|
291
|
+
*/
|
|
292
|
+
observeLink(element, route) {
|
|
293
|
+
if (this.observer) {
|
|
294
|
+
element.setAttribute("data-prefetch-route", route);
|
|
295
|
+
this.observer.observe(element);
|
|
296
|
+
}
|
|
297
|
+
}
|
|
298
|
+
/**
|
|
299
|
+
* Manually trigger prefetch for a specific route
|
|
300
|
+
* Useful for hover events
|
|
301
|
+
*/
|
|
302
|
+
prefetchRoute(route) {
|
|
303
|
+
if (!this.config) return;
|
|
304
|
+
Object.values(this.config.routes).forEach((routeConfig) => {
|
|
305
|
+
const target = routeConfig.prefetch.find((t) => t.route === route);
|
|
306
|
+
if (target) {
|
|
307
|
+
this.injectPrefetchLink(target);
|
|
308
|
+
}
|
|
309
|
+
});
|
|
310
|
+
}
|
|
311
|
+
/**
|
|
312
|
+
* Get prefetch statistics
|
|
313
|
+
*/
|
|
314
|
+
getStats() {
|
|
315
|
+
return {
|
|
316
|
+
totalPrefetched: this.prefetched.size,
|
|
317
|
+
prefetchedRoutes: Array.from(this.prefetched),
|
|
318
|
+
configLoaded: this.config !== null,
|
|
319
|
+
strategy: this.strategy
|
|
320
|
+
};
|
|
321
|
+
}
|
|
322
|
+
/**
|
|
323
|
+
* Check if a route has been prefetched
|
|
324
|
+
*/
|
|
325
|
+
isPrefetched(route) {
|
|
326
|
+
return this.prefetched.has(route);
|
|
327
|
+
}
|
|
328
|
+
/**
|
|
329
|
+
* Clear all prefetch state
|
|
330
|
+
*/
|
|
331
|
+
clear() {
|
|
332
|
+
this.prefetched.clear();
|
|
333
|
+
if (this.observer) {
|
|
334
|
+
this.observer.disconnect();
|
|
335
|
+
}
|
|
336
|
+
}
|
|
337
|
+
/**
|
|
338
|
+
* Get all prefetch link elements currently in the DOM
|
|
339
|
+
*/
|
|
340
|
+
getActivePrefetchLinks() {
|
|
341
|
+
return Array.from(document.querySelectorAll('link[rel="modulepreload"][data-prefetch-route]'));
|
|
342
|
+
}
|
|
343
|
+
/**
|
|
344
|
+
* Log current state for debugging
|
|
345
|
+
*/
|
|
346
|
+
logDebugInfo() {
|
|
347
|
+
console.group("\u{1F41B} Smart Prefetch Debug Info");
|
|
348
|
+
console.log("Strategy:", this.strategy);
|
|
349
|
+
console.log("Config loaded:", this.config !== null);
|
|
350
|
+
console.log("Total prefetch entries:", this.prefetched.size);
|
|
351
|
+
console.log("Prefetched items:", Array.from(this.prefetched));
|
|
352
|
+
const links = this.getActivePrefetchLinks();
|
|
353
|
+
console.log("\n\u{1F517} Active Link Tags in DOM:", links.length);
|
|
354
|
+
if (links.length > 0) {
|
|
355
|
+
console.table(links.map((link) => ({
|
|
356
|
+
route: link.getAttribute("data-prefetch-route"),
|
|
357
|
+
chunk: link.href.replace(window.location.origin + "/", ""),
|
|
358
|
+
priority: link.getAttribute("data-prefetch-priority"),
|
|
359
|
+
probability: link.getAttribute("data-prefetch-probability")
|
|
360
|
+
})));
|
|
361
|
+
}
|
|
362
|
+
if (this.config) {
|
|
363
|
+
console.log("\n\u{1F4CA} Configuration Summary:");
|
|
364
|
+
console.log("Available routes in config:", Object.keys(this.config.routes).length);
|
|
365
|
+
console.log("Config environment:", this.config.environment);
|
|
366
|
+
console.group("\u{1F4CB} All configured routes with prefetch targets:");
|
|
367
|
+
Object.entries(this.config.routes).forEach(([route, data]) => {
|
|
368
|
+
console.group(`${route}`);
|
|
369
|
+
data.prefetch.forEach((t, idx) => {
|
|
370
|
+
console.log(` ${idx + 1}. ${t.route} (${t.priority}, ${(t.probability * 100).toFixed(1)}%) \u2192 ${t.chunk}`);
|
|
371
|
+
});
|
|
372
|
+
console.groupEnd();
|
|
373
|
+
});
|
|
374
|
+
console.groupEnd();
|
|
375
|
+
console.log("\n\u{1F4A1} Current location:", window.location.pathname);
|
|
376
|
+
console.log("\u{1F4A1} Clean route:", window.location.pathname.split("?")[0].split("#")[0]);
|
|
377
|
+
}
|
|
378
|
+
console.groupEnd();
|
|
379
|
+
}
|
|
380
|
+
/**
|
|
381
|
+
* Log all prefetched pages and chunks (summary view)
|
|
382
|
+
*/
|
|
383
|
+
logPrefetchSummary() {
|
|
384
|
+
const links = this.getActivePrefetchLinks();
|
|
385
|
+
const routeLinks = links.filter((l) => !l.getAttribute("data-prefetch-import"));
|
|
386
|
+
const dependencyLinks = links.filter((l) => l.getAttribute("data-prefetch-import"));
|
|
387
|
+
console.group("\u{1F4CA} PREFETCH SUMMARY");
|
|
388
|
+
console.log(`Total pages prefetched: ${routeLinks.length}`);
|
|
389
|
+
console.log(`Total dependency chunks: ${dependencyLinks.length}`);
|
|
390
|
+
console.log(`Total overall entries: ${this.prefetched.size}`);
|
|
391
|
+
if (routeLinks.length > 0) {
|
|
392
|
+
console.group("\u{1F4C4} Pages/Routes Prefetched:");
|
|
393
|
+
const pageTable = routeLinks.map((link) => ({
|
|
394
|
+
route: link.getAttribute("data-prefetch-route"),
|
|
395
|
+
chunk: link.href.replace(window.location.origin + "/", ""),
|
|
396
|
+
priority: link.getAttribute("data-prefetch-priority"),
|
|
397
|
+
probability: `${link.getAttribute("data-prefetch-probability")}`
|
|
398
|
+
}));
|
|
399
|
+
console.table(pageTable);
|
|
400
|
+
console.groupEnd();
|
|
401
|
+
}
|
|
402
|
+
if (dependencyLinks.length > 0) {
|
|
403
|
+
console.group("\u{1F4E6} Dependency Chunks Prefetched:");
|
|
404
|
+
const depsTable = dependencyLinks.map((link) => ({
|
|
405
|
+
parentRoute: link.getAttribute("data-prefetch-parent"),
|
|
406
|
+
chunk: link.href.replace(window.location.origin + "/", "")
|
|
407
|
+
}));
|
|
408
|
+
console.table(depsTable);
|
|
409
|
+
console.groupEnd();
|
|
410
|
+
}
|
|
411
|
+
console.groupEnd();
|
|
412
|
+
}
|
|
413
|
+
};
|
|
414
|
+
|
|
415
|
+
// src/runtime/debug-utils.ts
|
|
416
|
+
function getPrefetchLinks() {
|
|
417
|
+
return Array.from(document.querySelectorAll('link[rel="prefetch"]'));
|
|
418
|
+
}
|
|
419
|
+
function getPluginPrefetchLinks() {
|
|
420
|
+
return Array.from(document.querySelectorAll('link[rel="prefetch"][data-prefetch-route]'));
|
|
421
|
+
}
|
|
422
|
+
function logPrefetchLinks() {
|
|
423
|
+
const allLinks = getPrefetchLinks();
|
|
424
|
+
const pluginLinks = getPluginPrefetchLinks();
|
|
425
|
+
console.group("\u{1F517} Prefetch Link Tags in DOM");
|
|
426
|
+
console.log(`Total prefetch links: ${allLinks.length}`);
|
|
427
|
+
console.log(`Plugin-managed links: ${pluginLinks.length}`);
|
|
428
|
+
if (pluginLinks.length > 0) {
|
|
429
|
+
console.group("Plugin-managed links:");
|
|
430
|
+
console.table(
|
|
431
|
+
pluginLinks.map((link) => ({
|
|
432
|
+
route: link.getAttribute("data-prefetch-route"),
|
|
433
|
+
href: link.href,
|
|
434
|
+
priority: link.getAttribute("data-prefetch-priority"),
|
|
435
|
+
probability: link.getAttribute("data-prefetch-probability"),
|
|
436
|
+
loaded: link.hasAttribute("data-loaded")
|
|
437
|
+
}))
|
|
438
|
+
);
|
|
439
|
+
console.groupEnd();
|
|
440
|
+
}
|
|
441
|
+
const otherLinks = allLinks.filter((link) => !link.hasAttribute("data-prefetch-route"));
|
|
442
|
+
if (otherLinks.length > 0) {
|
|
443
|
+
console.group("Other prefetch links:");
|
|
444
|
+
console.table(
|
|
445
|
+
otherLinks.map((link) => ({
|
|
446
|
+
href: link.href,
|
|
447
|
+
as: link.getAttribute("as")
|
|
448
|
+
}))
|
|
449
|
+
);
|
|
450
|
+
console.groupEnd();
|
|
451
|
+
}
|
|
452
|
+
console.groupEnd();
|
|
453
|
+
}
|
|
454
|
+
function monitorPrefetchActivity() {
|
|
455
|
+
console.log("\u{1F50D} Monitoring prefetch activity...");
|
|
456
|
+
console.log("Press the returned stop function to stop monitoring");
|
|
457
|
+
const observer = new MutationObserver((mutations) => {
|
|
458
|
+
mutations.forEach((mutation) => {
|
|
459
|
+
mutation.addedNodes.forEach((node) => {
|
|
460
|
+
if (node.nodeName === "LINK") {
|
|
461
|
+
const link = node;
|
|
462
|
+
if (link.rel === "prefetch") {
|
|
463
|
+
console.log("\u2795 New prefetch link added:", {
|
|
464
|
+
route: link.getAttribute("data-prefetch-route") || "N/A",
|
|
465
|
+
href: link.href,
|
|
466
|
+
priority: link.getAttribute("data-prefetch-priority")
|
|
467
|
+
});
|
|
468
|
+
}
|
|
469
|
+
}
|
|
470
|
+
});
|
|
471
|
+
mutation.removedNodes.forEach((node) => {
|
|
472
|
+
if (node.nodeName === "LINK") {
|
|
473
|
+
const link = node;
|
|
474
|
+
if (link.rel === "prefetch") {
|
|
475
|
+
console.log("\u2796 Prefetch link removed:", {
|
|
476
|
+
route: link.getAttribute("data-prefetch-route") || "N/A",
|
|
477
|
+
href: link.href
|
|
478
|
+
});
|
|
479
|
+
}
|
|
480
|
+
}
|
|
481
|
+
});
|
|
482
|
+
});
|
|
483
|
+
});
|
|
484
|
+
observer.observe(document.head, {
|
|
485
|
+
childList: true,
|
|
486
|
+
subtree: true
|
|
487
|
+
});
|
|
488
|
+
return () => {
|
|
489
|
+
console.log("\u{1F6D1} Stopped monitoring prefetch activity");
|
|
490
|
+
observer.disconnect();
|
|
491
|
+
};
|
|
492
|
+
}
|
|
493
|
+
function checkPluginConfiguration() {
|
|
494
|
+
console.group("\u{1F527} Smart Prefetch Plugin Configuration Check");
|
|
495
|
+
const globalConfig = window.__SMART_PREFETCH__;
|
|
496
|
+
if (globalConfig) {
|
|
497
|
+
console.log("\u2705 Global config found:", globalConfig);
|
|
498
|
+
} else {
|
|
499
|
+
console.warn("\u274C Global config not found on window.__SMART_PREFETCH__");
|
|
500
|
+
console.log(" The plugin may not be properly configured in vite.config");
|
|
501
|
+
}
|
|
502
|
+
fetch("/prefetch-config.json").then((res) => {
|
|
503
|
+
if (res.ok) {
|
|
504
|
+
console.log("\u2705 prefetch-config.json is accessible");
|
|
505
|
+
return res.json();
|
|
506
|
+
} else {
|
|
507
|
+
throw new Error(`HTTP ${res.status}: ${res.statusText}`);
|
|
508
|
+
}
|
|
509
|
+
}).then((config) => {
|
|
510
|
+
console.log("\u{1F4CB} Config content:", config);
|
|
511
|
+
console.log(` Routes: ${Object.keys(config.routes).length}`);
|
|
512
|
+
console.log(` Environment: ${config.environment}`);
|
|
513
|
+
}).catch((error) => {
|
|
514
|
+
console.error("\u274C Cannot access prefetch-config.json:", error.message);
|
|
515
|
+
console.log(" Make sure to build the app first: pnpm build");
|
|
516
|
+
}).finally(() => {
|
|
517
|
+
console.groupEnd();
|
|
518
|
+
});
|
|
519
|
+
if (typeof window.__PREFETCH_DEBUG__ === "function") {
|
|
520
|
+
console.log("\u2705 Debug function available: window.__PREFETCH_DEBUG__()");
|
|
521
|
+
} else {
|
|
522
|
+
console.warn("\u26A0\uFE0F Debug function not available (may not be initialized yet)");
|
|
523
|
+
}
|
|
524
|
+
}
|
|
525
|
+
function exposeDebugUtils() {
|
|
526
|
+
const w = window;
|
|
527
|
+
w.__PREFETCH_UTILS__ = {
|
|
528
|
+
getPrefetchLinks,
|
|
529
|
+
getPluginPrefetchLinks,
|
|
530
|
+
logPrefetchLinks,
|
|
531
|
+
monitorPrefetchActivity,
|
|
532
|
+
checkPluginConfiguration
|
|
533
|
+
};
|
|
534
|
+
console.log("\u{1F4A1} Debug utilities exposed:");
|
|
535
|
+
console.log(" window.__PREFETCH_UTILS__.getPrefetchLinks()");
|
|
536
|
+
console.log(" window.__PREFETCH_UTILS__.logPrefetchLinks()");
|
|
537
|
+
console.log(" window.__PREFETCH_UTILS__.monitorPrefetchActivity()");
|
|
538
|
+
console.log(" window.__PREFETCH_UTILS__.checkPluginConfiguration()");
|
|
539
|
+
}
|
|
540
|
+
export {
|
|
541
|
+
PrefetchManager,
|
|
542
|
+
checkPluginConfiguration,
|
|
543
|
+
exposeDebugUtils,
|
|
544
|
+
getPluginPrefetchLinks,
|
|
545
|
+
getPrefetchLinks,
|
|
546
|
+
logPrefetchLinks,
|
|
547
|
+
monitorPrefetchActivity
|
|
548
|
+
};
|
|
549
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/runtime/prefetch-manager.ts","../../src/runtime/debug-utils.ts"],"sourcesContent":["/**\n * Prefetch Manager (Runtime)\n * Manages route prefetching in the browser\n */\n\nimport type { PrefetchConfig, PrefetchStrategy, PrefetchTarget } from '../types';\n\nexport class PrefetchManager {\n private config: PrefetchConfig | null = null;\n private prefetched = new Set<string>();\n private strategy: PrefetchStrategy;\n private observer: IntersectionObserver | null = null;\n private debug: boolean;\n\n constructor(strategy: PrefetchStrategy = 'hybrid', debug = false) {\n this.strategy = strategy;\n this.debug = debug;\n }\n\n /**\n * Initialize the prefetch manager\n * Loads configuration and sets up observers\n */\n async init(): Promise<void> {\n if (this.debug) {\n console.log('š Smart Prefetch Manager - Initializing...');\n console.log(' Strategy:', this.strategy);\n console.log(' Debug mode: enabled');\n }\n\n try {\n // Load prefetch configuration\n if (this.debug) {\n console.log('š„ Fetching prefetch-config.json...');\n }\n\n const response = await fetch('/prefetch-config.json');\n\n // Gracefully handle missing config file (common in development)\n if (!response.ok) {\n if (response.status === 404) {\n if (this.debug) {\n console.warn('ā ļø Prefetch config not found (404)');\n console.log(' This is expected if:');\n console.log(' 1. You haven\\'t built the app yet (run `pnpm build`)');\n console.log(' 2. The plugin failed to generate the config during build');\n console.log(' Prefetch manager will be inactive until config is available');\n }\n return;\n }\n throw new Error(`Failed to load prefetch config: ${response.statusText}`);\n }\n\n this.config = await response.json();\n\n if (this.debug && this.config) {\n console.log('ā
Config loaded successfully');\n console.log(` Routes with prefetch rules: ${Object.keys(this.config.routes).length} ${typeof this.config.routes}`);\n console.log(` Environment: ${this.config.environment}`);\n console.log(` Config version: ${this.config.version || 'N/A'}`);\n\n // List all routes with prefetch rules\n console.groupCollapsed('š Available prefetch rules:');\n Object.entries(this.config.routes).forEach(([source, data]: [string, any]) => {\n console.log(`${source} ā ${data.prefetch.length} target(s)`,\n data.prefetch.map((t: any) => t.route));\n });\n console.groupEnd();\n }\n\n // Set up intersection observer for 'visible' strategy\n if (this.strategy === 'visible' || this.strategy === 'hybrid') {\n this.initIntersectionObserver();\n if (this.debug) {\n console.log('šļø IntersectionObserver initialized for visibility-based prefetching');\n }\n }\n\n if (this.debug) {\n console.log('ā
Prefetch Manager fully initialized');\n console.log('š” Run window.__PREFETCH_DEBUG__() to see current state');\n\n // Expose debug helper globally\n (window as any).__PREFETCH_DEBUG__ = () => this.logDebugInfo();\n }\n } catch (error) {\n // Only log error if debug mode is enabled\n if (this.debug) {\n console.error('ā Failed to initialize Prefetch Manager:', error);\n }\n }\n }\n\n /**\n * Prefetch routes based on current route\n */\n prefetch(currentRoute: string): void {\n // Strip query parameters and hash from the route\n const cleanRoute = currentRoute.split('?')[0].split('#')[0];\n\n if (this.debug) {\n console.log(`š Checking prefetch for route: ${currentRoute}`);\n if (currentRoute !== cleanRoute) {\n console.log(` Clean route: ${cleanRoute}`);\n }\n }\n\n if (!this.config) {\n if (this.debug) {\n console.warn('ā ļø Config not loaded yet - cannot prefetch');\n console.log(' Make sure the app was built with the plugin enabled');\n }\n return;\n }\n\n // Check network conditions\n if (!this.shouldPrefetch()) {\n if (this.debug) {\n console.log('āļø Skipping prefetch due to network conditions');\n }\n return;\n }\n\n // Try to find route config (try both clean and original route)\n let routeConfig = this.config.routes[cleanRoute] || this.config.routes[currentRoute];\n const matchedRoute = routeConfig ? (this.config.routes[cleanRoute] ? cleanRoute : currentRoute) : null;\n\n if (!routeConfig) {\n if (this.debug) {\n console.warn(`ā ļø No prefetch rules configured for route: ${cleanRoute}`);\n console.groupCollapsed('Available routes in config:');\n Object.keys(this.config.routes).forEach(route => {\n const targets = this.config!.routes[route].prefetch;\n console.log(` ${route} ā ${targets.length} target(s)`, targets.map(t => t.route));\n });\n console.groupEnd();\n console.log(`š” Tip: Make sure your manualRules key matches exactly: \"${cleanRoute}\"`);\n }\n return;\n }\n\n // Always log when a route is found and prefetch is about to happen\n console.log(`ā
Found prefetch rule for: ${matchedRoute}`);\n console.log(` Total targets to prefetch: ${routeConfig.prefetch.length}`);\n console.log(` Strategy: ${this.strategy}`);\n\n if (this.debug) {\n console.groupCollapsed(`š Prefetch Rules for: ${matchedRoute}`);\n routeConfig.prefetch.forEach((target, index) => {\n console.log(` ${index + 1}. ${target.route} (${target.priority} priority, ${(target.probability * 100).toFixed(1)}%)`);\n });\n console.groupEnd();\n }\n\n // Prefetch based on strategy\n routeConfig.prefetch.forEach((target) => {\n this.prefetchTarget(target);\n });\n }\n\n /**\n * Prefetch a specific target\n */\n private prefetchTarget(target: PrefetchTarget & { chunk: string }): void {\n // Check if already prefetched\n if (this.prefetched.has(target.route)) {\n return;\n }\n\n // Apply strategy-based prefetching\n switch (this.strategy) {\n case 'auto':\n this.injectPrefetchLink(target);\n break;\n\n case 'hover':\n // Hover is handled by link components\n break;\n\n case 'visible':\n // Visible is handled by IntersectionObserver\n break;\n\n case 'idle':\n this.prefetchOnIdle(target);\n break;\n\n case 'hybrid':\n this.prefetchHybrid(target);\n break;\n }\n }\n\n /**\n * Hybrid strategy: prioritize based on probability\n * FOR TESTING: Fetch all priorities to verify chunks are correct\n */\n private prefetchHybrid(target: PrefetchTarget & { chunk: string }): void {\n if (target.priority === 'high' || target.probability >= 0.7) {\n // High priority: prefetch immediately\n console.log(` ā” High priority (${(target.probability * 100).toFixed(1)}%) - Prefetching immediately`);\n this.injectPrefetchLink(target);\n } else if (target.priority === 'medium' || target.probability >= 0.4) {\n // Medium priority: prefetch on idle (FOR TESTING: fetch immediately)\n console.log(` ā±ļø Medium priority (${(target.probability * 100).toFixed(1)}%) - Fetching immediately (TESTING MODE)`);\n this.injectPrefetchLink(target); // Changed from prefetchOnIdle to immediate for testing\n } else {\n // Low priority: wait for visibility or hover (FOR TESTING: fetch immediately)\n console.log(` š Low priority (${(target.probability * 100).toFixed(1)}%) - Fetching immediately (TESTING MODE)`);\n this.injectPrefetchLink(target); // Changed from deferred to immediate for testing\n }\n }\n\n /**\n * Prefetch during idle time\n */\n private prefetchOnIdle(target: PrefetchTarget & { chunk: string }): void {\n if ('requestIdleCallback' in window) {\n requestIdleCallback(() => {\n this.injectPrefetchLink(target);\n });\n } else {\n // Fallback for browsers without requestIdleCallback\n setTimeout(() => {\n this.injectPrefetchLink(target);\n }, 1000);\n }\n }\n\n /**\n * Inject prefetch link into DOM\n */\n private injectPrefetchLink(target: PrefetchTarget & { chunk: string }): void {\n if (this.prefetched.has(target.route)) {\n if (this.debug) {\n console.log(` āļø Already prefetched: ${target.route}`);\n }\n return;\n }\n\n const link = document.createElement('link');\n // Use modulepreload for better ES module support (triggers actual fetch)\n link.rel = 'modulepreload';\n link.href = `/${target.chunk}`;\n link.setAttribute('data-prefetch-route', target.route);\n link.setAttribute('data-prefetch-priority', target.priority);\n link.setAttribute('data-prefetch-probability', target.probability.toString());\n\n // Always log prefetch with details\n console.groupCollapsed(`š PREFETCH: ${target.route}`);\n console.log(` š Page/Route: ${target.route}`);\n console.log(` š¦ Main Chunk: ${target.chunk}`);\n console.log(` š Full URL: ${window.location.origin}/${target.chunk}`);\n console.log(` ā Priority: ${target.priority}`);\n console.log(` š Probability: ${(target.probability * 100).toFixed(1)}%`);\n\n if (this.debug) {\n console.log(` Link element:`, link);\n }\n\n // Add to head\n document.head.appendChild(link);\n\n // Track total chunks being fetched\n let totalChunksForThisRoute = 1; // Main chunk\n\n // Also prefetch all dependency chunks (imports)\n if (target.imports && target.imports.length > 0) {\n console.log(` š Dependencies (${target.imports.length}):`);\n target.imports.forEach((importChunk, index) => {\n // Skip if already prefetched by another route\n const importId = `import:${importChunk}`;\n if (this.prefetched.has(importId)) {\n console.log(` ${index + 1}. ${importChunk} (already prefetched)`);\n return;\n }\n\n const importLink = document.createElement('link');\n importLink.rel = 'modulepreload';\n importLink.href = `/${importChunk}`;\n importLink.setAttribute('data-prefetch-import', 'true');\n importLink.setAttribute('data-prefetch-parent', target.route);\n document.head.appendChild(importLink);\n this.prefetched.add(importId);\n totalChunksForThisRoute++;\n\n console.log(` ${index + 1}. ${importChunk} ā
`);\n });\n }\n\n // Mark as prefetched\n this.prefetched.add(target.route);\n\n console.log(` ā
Total chunks injected: ${totalChunksForThisRoute}`);\n console.log(` š Overall prefetched count: ${this.prefetched.size}`);\n\n if (this.debug) {\n console.log(` DOM Status: Link tag added to document.head`);\n\n // Verify the link was actually added and check if it loaded\n setTimeout(() => {\n const addedLink = document.querySelector(`link[data-prefetch-route=\"${target.route}\"]`);\n if (addedLink) {\n console.log(` āļø DOM Verification: Link exists`);\n console.log(` href:`, (addedLink as HTMLLinkElement).href);\n } else {\n console.error(` ā ERROR: Link tag not found in DOM`);\n }\n }, 100);\n }\n\n console.groupEnd();\n }\n\n /**\n * Check if prefetching should be performed based on network conditions\n */\n private shouldPrefetch(): boolean {\n // Check if Network Information API is available\n const nav = navigator as any;\n const connection = nav.connection || nav.mozConnection || nav.webkitConnection;\n\n if (!connection) {\n // API not available, assume prefetch is OK\n return true;\n }\n\n // Respect Data Saver mode\n if (connection.saveData) {\n if (this.debug) console.log(' ā ļø Data Saver enabled');\n return false;\n }\n\n // Check connection speed\n const slowConnections = ['slow-2g', '2g'];\n if (slowConnections.includes(connection.effectiveType)) {\n if (this.debug) console.log(` ā ļø Slow connection: ${connection.effectiveType}`);\n return false;\n }\n\n // Check if metered connection (conservative approach)\n if (connection.type === 'cellular' && connection.effectiveType !== '4g') {\n if (this.debug) console.log(' ā ļø Metered connection');\n return false;\n }\n\n return true;\n }\n\n /**\n * Initialize IntersectionObserver for 'visible' strategy\n */\n private initIntersectionObserver(): void {\n this.observer = new IntersectionObserver(\n (entries) => {\n entries.forEach((entry) => {\n if (entry.isIntersecting) {\n const route = entry.target.getAttribute('data-prefetch-route');\n if (route && this.config) {\n // Find the target in config\n Object.values(this.config.routes).forEach((routeConfig) => {\n const target = routeConfig.prefetch.find((t) => t.route === route);\n if (target) {\n this.injectPrefetchLink(target);\n }\n });\n }\n }\n });\n },\n {\n rootMargin: '50px', // Start prefetch 50px before element is visible\n }\n );\n }\n\n /**\n * Observe an element for visibility-based prefetching\n */\n observeLink(element: HTMLElement, route: string): void {\n if (this.observer) {\n element.setAttribute('data-prefetch-route', route);\n this.observer.observe(element);\n }\n }\n\n /**\n * Manually trigger prefetch for a specific route\n * Useful for hover events\n */\n prefetchRoute(route: string): void {\n if (!this.config) return;\n\n // Find this route in all route configs\n Object.values(this.config.routes).forEach((routeConfig) => {\n const target = routeConfig.prefetch.find((t) => t.route === route);\n if (target) {\n this.injectPrefetchLink(target);\n }\n });\n }\n\n /**\n * Get prefetch statistics\n */\n getStats(): {\n totalPrefetched: number;\n prefetchedRoutes: string[];\n configLoaded: boolean;\n strategy: PrefetchStrategy;\n } {\n return {\n totalPrefetched: this.prefetched.size,\n prefetchedRoutes: Array.from(this.prefetched),\n configLoaded: this.config !== null,\n strategy: this.strategy,\n };\n }\n\n /**\n * Check if a route has been prefetched\n */\n isPrefetched(route: string): boolean {\n return this.prefetched.has(route);\n }\n\n /**\n * Clear all prefetch state\n */\n clear(): void {\n this.prefetched.clear();\n if (this.observer) {\n this.observer.disconnect();\n }\n }\n\n /**\n * Get all prefetch link elements currently in the DOM\n */\n getActivePrefetchLinks(): HTMLLinkElement[] {\n return Array.from(document.querySelectorAll('link[rel=\"modulepreload\"][data-prefetch-route]'));\n }\n\n /**\n * Log current state for debugging\n */\n logDebugInfo(): void {\n console.group('š Smart Prefetch Debug Info');\n console.log('Strategy:', this.strategy);\n console.log('Config loaded:', this.config !== null);\n console.log('Total prefetch entries:', this.prefetched.size);\n console.log('Prefetched items:', Array.from(this.prefetched));\n\n const links = this.getActivePrefetchLinks();\n console.log('\\nš Active Link Tags in DOM:', links.length);\n\n if (links.length > 0) {\n console.table(links.map(link => ({\n route: link.getAttribute('data-prefetch-route'),\n chunk: link.href.replace(window.location.origin + '/', ''),\n priority: link.getAttribute('data-prefetch-priority'),\n probability: link.getAttribute('data-prefetch-probability'),\n })));\n }\n\n if (this.config) {\n console.log('\\nš Configuration Summary:');\n console.log('Available routes in config:', Object.keys(this.config.routes).length);\n console.log('Config environment:', this.config.environment);\n\n console.group('š All configured routes with prefetch targets:');\n Object.entries(this.config.routes).forEach(([route, data]: [string, any]) => {\n console.group(`${route}`);\n data.prefetch.forEach((t: any, idx: number) => {\n console.log(` ${idx + 1}. ${t.route} (${t.priority}, ${(t.probability * 100).toFixed(1)}%) ā ${t.chunk}`);\n });\n console.groupEnd();\n });\n console.groupEnd();\n\n console.log('\\nš” Current location:', window.location.pathname);\n console.log('š” Clean route:', window.location.pathname.split('?')[0].split('#')[0]);\n }\n\n console.groupEnd();\n }\n\n /**\n * Log all prefetched pages and chunks (summary view)\n */\n logPrefetchSummary(): void {\n const links = this.getActivePrefetchLinks();\n const routeLinks = links.filter(l => !l.getAttribute('data-prefetch-import'));\n const dependencyLinks = links.filter(l => l.getAttribute('data-prefetch-import'));\n\n console.group('š PREFETCH SUMMARY');\n console.log(`Total pages prefetched: ${routeLinks.length}`);\n console.log(`Total dependency chunks: ${dependencyLinks.length}`);\n console.log(`Total overall entries: ${this.prefetched.size}`);\n\n if (routeLinks.length > 0) {\n console.group('š Pages/Routes Prefetched:');\n const pageTable = routeLinks.map(link => ({\n route: link.getAttribute('data-prefetch-route'),\n chunk: link.href.replace(window.location.origin + '/', ''),\n priority: link.getAttribute('data-prefetch-priority'),\n probability: `${link.getAttribute('data-prefetch-probability')}`,\n }));\n console.table(pageTable);\n console.groupEnd();\n }\n\n if (dependencyLinks.length > 0) {\n console.group('š¦ Dependency Chunks Prefetched:');\n const depsTable = dependencyLinks.map(link => ({\n parentRoute: link.getAttribute('data-prefetch-parent'),\n chunk: link.href.replace(window.location.origin + '/', ''),\n }));\n console.table(depsTable);\n console.groupEnd();\n }\n\n console.groupEnd();\n }\n}\n","/**\n * Debug Utilities for Smart Prefetch Plugin\n * Helper functions to inspect and debug prefetch behavior\n */\n\n/**\n * Get all prefetch link elements from the DOM\n */\nexport function getPrefetchLinks(): HTMLLinkElement[] {\n return Array.from(document.querySelectorAll('link[rel=\"prefetch\"]'));\n}\n\n/**\n * Get prefetch links added by our plugin (with data attributes)\n */\nexport function getPluginPrefetchLinks(): HTMLLinkElement[] {\n return Array.from(document.querySelectorAll('link[rel=\"prefetch\"][data-prefetch-route]'));\n}\n\n/**\n * Log all prefetch links in a formatted way\n */\nexport function logPrefetchLinks(): void {\n const allLinks = getPrefetchLinks();\n const pluginLinks = getPluginPrefetchLinks();\n\n console.group('š Prefetch Link Tags in DOM');\n console.log(`Total prefetch links: ${allLinks.length}`);\n console.log(`Plugin-managed links: ${pluginLinks.length}`);\n\n if (pluginLinks.length > 0) {\n console.group('Plugin-managed links:');\n console.table(\n pluginLinks.map((link) => ({\n route: link.getAttribute('data-prefetch-route'),\n href: link.href,\n priority: link.getAttribute('data-prefetch-priority'),\n probability: link.getAttribute('data-prefetch-probability'),\n loaded: link.hasAttribute('data-loaded'),\n }))\n );\n console.groupEnd();\n }\n\n const otherLinks = allLinks.filter((link) => !link.hasAttribute('data-prefetch-route'));\n if (otherLinks.length > 0) {\n console.group('Other prefetch links:');\n console.table(\n otherLinks.map((link) => ({\n href: link.href,\n as: link.getAttribute('as'),\n }))\n );\n console.groupEnd();\n }\n\n console.groupEnd();\n}\n\n/**\n * Monitor prefetch activity in real-time\n */\nexport function monitorPrefetchActivity(): () => void {\n console.log('š Monitoring prefetch activity...');\n console.log('Press the returned stop function to stop monitoring');\n\n const observer = new MutationObserver((mutations) => {\n mutations.forEach((mutation) => {\n mutation.addedNodes.forEach((node) => {\n if (node.nodeName === 'LINK') {\n const link = node as HTMLLinkElement;\n if (link.rel === 'prefetch') {\n console.log('ā New prefetch link added:', {\n route: link.getAttribute('data-prefetch-route') || 'N/A',\n href: link.href,\n priority: link.getAttribute('data-prefetch-priority'),\n });\n }\n }\n });\n\n mutation.removedNodes.forEach((node) => {\n if (node.nodeName === 'LINK') {\n const link = node as HTMLLinkElement;\n if (link.rel === 'prefetch') {\n console.log('ā Prefetch link removed:', {\n route: link.getAttribute('data-prefetch-route') || 'N/A',\n href: link.href,\n });\n }\n }\n });\n });\n });\n\n observer.observe(document.head, {\n childList: true,\n subtree: true,\n });\n\n return () => {\n console.log('š Stopped monitoring prefetch activity');\n observer.disconnect();\n };\n}\n\n/**\n * Check if the smart prefetch plugin is properly configured\n */\nexport function checkPluginConfiguration(): void {\n console.group('š§ Smart Prefetch Plugin Configuration Check');\n\n // Check global config\n const globalConfig = (window as any).__SMART_PREFETCH__;\n if (globalConfig) {\n console.log('ā
Global config found:', globalConfig);\n } else {\n console.warn('ā Global config not found on window.__SMART_PREFETCH__');\n console.log(' The plugin may not be properly configured in vite.config');\n }\n\n // Check if config file is accessible\n fetch('/prefetch-config.json')\n .then((res) => {\n if (res.ok) {\n console.log('ā
prefetch-config.json is accessible');\n return res.json();\n } else {\n throw new Error(`HTTP ${res.status}: ${res.statusText}`);\n }\n })\n .then((config) => {\n console.log('š Config content:', config);\n console.log(` Routes: ${Object.keys(config.routes).length}`);\n console.log(` Environment: ${config.environment}`);\n })\n .catch((error) => {\n console.error('ā Cannot access prefetch-config.json:', error.message);\n console.log(' Make sure to build the app first: pnpm build');\n })\n .finally(() => {\n console.groupEnd();\n });\n\n // Check debug function\n if (typeof (window as any).__PREFETCH_DEBUG__ === 'function') {\n console.log('ā
Debug function available: window.__PREFETCH_DEBUG__()');\n } else {\n console.warn('ā ļø Debug function not available (may not be initialized yet)');\n }\n}\n\n/**\n * Expose all debug utilities globally for console access\n */\nexport function exposeDebugUtils(): void {\n const w = window as any;\n w.__PREFETCH_UTILS__ = {\n getPrefetchLinks,\n getPluginPrefetchLinks,\n logPrefetchLinks,\n monitorPrefetchActivity,\n checkPluginConfiguration,\n };\n\n console.log('š” Debug utilities exposed:');\n console.log(' window.__PREFETCH_UTILS__.getPrefetchLinks()');\n console.log(' window.__PREFETCH_UTILS__.logPrefetchLinks()');\n console.log(' window.__PREFETCH_UTILS__.monitorPrefetchActivity()');\n console.log(' window.__PREFETCH_UTILS__.checkPluginConfiguration()');\n}\n"],"mappings":";AAOO,IAAM,kBAAN,MAAsB;AAAA,EAO3B,YAAY,WAA6B,UAAU,QAAQ,OAAO;AANlE,SAAQ,SAAgC;AACxC,SAAQ,aAAa,oBAAI,IAAY;AAErC,SAAQ,WAAwC;AAI9C,SAAK,WAAW;AAChB,SAAK,QAAQ;AAAA,EACf;AAAA;AAAA;AAAA;AAAA;AAAA,EAMA,MAAM,OAAsB;AAC1B,QAAI,KAAK,OAAO;AACd,cAAQ,IAAI,oDAA6C;AACzD,cAAQ,IAAI,gBAAgB,KAAK,QAAQ;AACzC,cAAQ,IAAI,wBAAwB;AAAA,IACtC;AAEA,QAAI;AAEF,UAAI,KAAK,OAAO;AACd,gBAAQ,IAAI,4CAAqC;AAAA,MACnD;AAEA,YAAM,WAAW,MAAM,MAAM,uBAAuB;AAGpD,UAAI,CAAC,SAAS,IAAI;AAChB,YAAI,SAAS,WAAW,KAAK;AAC3B,cAAI,KAAK,OAAO;AACd,oBAAQ,KAAK,+CAAqC;AAClD,oBAAQ,IAAI,yBAAyB;AACrC,oBAAQ,IAAI,wDAAyD;AACrE,oBAAQ,IAAI,6DAA6D;AACzE,oBAAQ,IAAI,gEAAgE;AAAA,UAC9E;AACA;AAAA,QACF;AACA,cAAM,IAAI,MAAM,mCAAmC,SAAS,UAAU,EAAE;AAAA,MAC1E;AAEA,WAAK,SAAS,MAAM,SAAS,KAAK;AAElC,UAAI,KAAK,SAAS,KAAK,QAAQ;AAC7B,gBAAQ,IAAI,mCAA8B;AAC1C,gBAAQ,IAAI,kCAAkC,OAAO,KAAK,KAAK,OAAO,MAAM,EAAE,MAAM,IAAI,OAAO,KAAK,OAAO,MAAM,EAAE;AACnH,gBAAQ,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aAAO,IAAI,KAAK;AAAA,IAClB,OAAO;AACL,YAAM,IAAI,MAAM,QAAQ,IAAI,MAAM,KAAK,IAAI,UAAU,EAAE;AAAA,IACzD;AAAA,EACF,CAAC,EACA,KAAK,CAAC,WAAW;AAChB,YAAQ,IAAI,6BAAsB,MAAM;AACxC,YAAQ,IAAI,cAAc,OAAO,KAAK,OAAO,MAAM,EAAE,MAAM,EAAE;AAC7D,YAAQ,IAAI,mBAAmB,OAAO,WAAW,EAAE;AAAA,EACrD,CAAC,EACA,MAAM,CAAC,UAAU;AAChB,YAAQ,MAAM,8CAAyC,MAAM,OAAO;AACpE,YAAQ,IAAI,iDAAiD;AAAA,EAC/D,CAAC,EACA,QAAQ,MAAM;AACb,YAAQ,SAAS;AAAA,EACnB,CAAC;AAGH,MAAI,OAAQ,OAAe,uBAAuB,YAAY;AAC5D,YAAQ,IAAI,8DAAyD;AAAA,EACvE,OAAO;AACL,YAAQ,KAAK,yEAA+D;AAAA,EAC9E;AACF;AAKO,SAAS,mBAAyB;AACvC,QAAM,IAAI;AACV,IAAE,qBAAqB;AAAA,IACrB;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF;AAEA,UAAQ,IAAI,oCAA6B;AACzC,UAAQ,IAAI,iDAAiD;AAC7D,UAAQ,IAAI,iDAAiD;AAC7D,UAAQ,IAAI,wDAAwD;AACpE,UAAQ,IAAI,yDAAyD;AACvE;","names":[]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "vite-plugin-smart-prefetch",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.5",
|
|
4
4
|
"description": "Smart prefetch plugin for Vite with BigQuery GA4 analytics. Supports React Router DOM and TanStack Router with intelligent dynamic route matching.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.cjs",
|