vite-plugin-smart-prefetch 0.3.6 → 0.3.8
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/index.cjs +102 -290
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +102 -290
- package/dist/index.js.map +1 -1
- package/package.json +6 -4
package/dist/index.cjs
CHANGED
|
@@ -163,6 +163,7 @@ ${"\u2550".repeat(60)}`);
|
|
|
163
163
|
let filteredCount = 0;
|
|
164
164
|
let emptyPathCount = 0;
|
|
165
165
|
let lowCountCount = 0;
|
|
166
|
+
let selfTransitionCount = 0;
|
|
166
167
|
const rawData = rows.map((row) => ({
|
|
167
168
|
previous_page_path: row.previous_page_path,
|
|
168
169
|
page_path: row.page_path,
|
|
@@ -186,7 +187,7 @@ ${"\u2550".repeat(60)}`);
|
|
|
186
187
|
if (this.debug && index < 5) {
|
|
187
188
|
console.log(` Normalized: "${normalizedPrevious}" \u2192 "${normalizedCurrent}"`);
|
|
188
189
|
}
|
|
189
|
-
if (normalizedCurrent && transitionCount >= minSessions) {
|
|
190
|
+
if (normalizedCurrent && transitionCount >= minSessions && normalizedPrevious !== normalizedCurrent) {
|
|
190
191
|
navigationData.push({
|
|
191
192
|
from: normalizedPrevious,
|
|
192
193
|
to: normalizedCurrent,
|
|
@@ -208,6 +209,11 @@ ${"\u2550".repeat(60)}`);
|
|
|
208
209
|
if (this.debug && index < 5) {
|
|
209
210
|
console.log(` \u274C FILTERED: transition count ${transitionCount} < minSessions ${minSessions}`);
|
|
210
211
|
}
|
|
212
|
+
} else if (normalizedPrevious === normalizedCurrent) {
|
|
213
|
+
selfTransitionCount++;
|
|
214
|
+
if (this.debug && index < 5) {
|
|
215
|
+
console.log(` \u274C FILTERED: self-to-self transition (user stayed on same page)`);
|
|
216
|
+
}
|
|
211
217
|
}
|
|
212
218
|
}
|
|
213
219
|
});
|
|
@@ -218,6 +224,7 @@ ${"\u2550".repeat(60)}`);
|
|
|
218
224
|
console.log(` \u274C Filtered out: ${filteredCount}`);
|
|
219
225
|
console.log(` \u2022 Empty paths: ${emptyPathCount}`);
|
|
220
226
|
console.log(` \u2022 Low transition count: ${lowCountCount}`);
|
|
227
|
+
console.log(` \u2022 Self-to-self transitions: ${selfTransitionCount}`);
|
|
221
228
|
this.saveDataForInspection(rawData, navigationData);
|
|
222
229
|
console.log(`
|
|
223
230
|
${"\u2550".repeat(60)}`);
|
|
@@ -465,6 +472,7 @@ ${"\u2550".repeat(60)}`);
|
|
|
465
472
|
const navigationData = [];
|
|
466
473
|
let processedCount = 0;
|
|
467
474
|
let filteredCount = 0;
|
|
475
|
+
let selfTransitionCount = 0;
|
|
468
476
|
const segmentCounts = /* @__PURE__ */ new Map();
|
|
469
477
|
console.log(`
|
|
470
478
|
${"\u2500".repeat(56)}`);
|
|
@@ -485,7 +493,7 @@ ${"\u2550".repeat(60)}`);
|
|
|
485
493
|
if (this.debug && index < 3) {
|
|
486
494
|
console.log(` Normalized: "${normalizedPrevious}" \u2192 "${normalizedCurrent}" | segment: "${segment}"`);
|
|
487
495
|
}
|
|
488
|
-
if (normalizedCurrent && transitionCount >= 1) {
|
|
496
|
+
if (normalizedCurrent && transitionCount >= 1 && normalizedPrevious !== normalizedCurrent) {
|
|
489
497
|
navigationData.push({
|
|
490
498
|
from: normalizedPrevious,
|
|
491
499
|
to: normalizedCurrent,
|
|
@@ -499,6 +507,9 @@ ${"\u2550".repeat(60)}`);
|
|
|
499
507
|
}
|
|
500
508
|
} else {
|
|
501
509
|
filteredCount++;
|
|
510
|
+
if (normalizedPrevious === normalizedCurrent) {
|
|
511
|
+
selfTransitionCount++;
|
|
512
|
+
}
|
|
502
513
|
if (this.debug && index < 3) {
|
|
503
514
|
console.log(` \u274C FILTERED`);
|
|
504
515
|
}
|
|
@@ -509,6 +520,7 @@ ${"\u2550".repeat(60)}`);
|
|
|
509
520
|
console.log(` Processing Summary:`);
|
|
510
521
|
console.log(` \u2705 Accepted: ${processedCount}`);
|
|
511
522
|
console.log(` \u274C Filtered out: ${filteredCount}`);
|
|
523
|
+
console.log(` \u2022 Self-to-self transitions: ${selfTransitionCount}`);
|
|
512
524
|
console.log(`
|
|
513
525
|
${"\u2550".repeat(60)}`);
|
|
514
526
|
console.log(`\u{1F4CA} STAGE 4: FINAL RESULTS (SEGMENTED)`);
|
|
@@ -800,7 +812,15 @@ var MarkovChainTrainer = class {
|
|
|
800
812
|
};
|
|
801
813
|
|
|
802
814
|
// src/plugin/config-generator.ts
|
|
803
|
-
var
|
|
815
|
+
var ConfigGenerator = class {
|
|
816
|
+
/**
|
|
817
|
+
* NOTE: Hardcoded route/component mappings have been REMOVED to make the plugin generic.
|
|
818
|
+
* The plugin now uses dynamic strategies (direct match, pattern match, fuzzy match)
|
|
819
|
+
* to discover routes from the Vite manifest and actual file structure.
|
|
820
|
+
*
|
|
821
|
+
* This allows the plugin to work with ANY project structure without project-specific
|
|
822
|
+
* configuration hardcoded in the plugin code.
|
|
823
|
+
*/
|
|
804
824
|
constructor(manifest, manualRules = {}, debug = false, vite) {
|
|
805
825
|
this.vite = null;
|
|
806
826
|
this.isDev = false;
|
|
@@ -989,224 +1009,69 @@ var _ConfigGenerator = class _ConfigGenerator {
|
|
|
989
1009
|
return merged;
|
|
990
1010
|
}
|
|
991
1011
|
/**
|
|
992
|
-
*
|
|
993
|
-
*
|
|
994
|
-
*
|
|
995
|
-
|
|
996
|
-
|
|
997
|
-
|
|
998
|
-
|
|
999
|
-
|
|
1000
|
-
|
|
1001
|
-
|
|
1002
|
-
|
|
1003
|
-
return null;
|
|
1004
|
-
}
|
|
1005
|
-
const chunkName = _ConfigGenerator.COMPONENT_TO_CHUNK_NAME[componentName];
|
|
1006
|
-
if (!chunkName) {
|
|
1007
|
-
if (this.debug) {
|
|
1008
|
-
console.log(` \u274C Component ${componentName} not in COMPONENT_TO_CHUNK_NAME mapping`);
|
|
1009
|
-
}
|
|
1010
|
-
return null;
|
|
1011
|
-
}
|
|
1012
|
-
const chunkEntry = Object.entries(this.manifest).find(
|
|
1013
|
-
([key, entry]) => entry.name === chunkName || key.includes(chunkName)
|
|
1014
|
-
);
|
|
1015
|
-
if (!chunkEntry) {
|
|
1016
|
-
if (this.debug) {
|
|
1017
|
-
console.log(` \u274C Chunk name ${chunkName} not found in manifest`);
|
|
1018
|
-
}
|
|
1019
|
-
return null;
|
|
1020
|
-
}
|
|
1021
|
-
const chunkFile = chunkEntry[1].file;
|
|
1022
|
-
if (this.debug) {
|
|
1023
|
-
console.log(
|
|
1024
|
-
` \u2705 Via-Name Strategy: ${route} \u2192 ${componentName} \u2192 ${chunkName} \u2192 ${chunkFile}`
|
|
1025
|
-
);
|
|
1026
|
-
}
|
|
1027
|
-
return chunkFile;
|
|
1028
|
-
}
|
|
1029
|
-
/**
|
|
1030
|
-
* Map route to chunk file using Vite manifest
|
|
1031
|
-
* Tries multiple strategies to find the correct chunk
|
|
1012
|
+
* Map BigQuery route to Vite manifest chunk file
|
|
1013
|
+
*
|
|
1014
|
+
* The routes come from BigQuery navigation data (e.g., /purchase-order, /dispatch-order/:id)
|
|
1015
|
+
* We match them directly to manifest entries without trying to discover routes.
|
|
1016
|
+
*
|
|
1017
|
+
* Strategy: Match route segments against manifest file paths, ignoring hash suffixes
|
|
1018
|
+
* Example:
|
|
1019
|
+
* Route: /purchase-order/:id
|
|
1020
|
+
* Normalized: /purchase-order
|
|
1021
|
+
* Manifest: src/pages/purchase-order/index.tsx → {file: assets/purchase-order-abc123.js}
|
|
1022
|
+
* Match: YES → return assets/purchase-order-abc123.js
|
|
1032
1023
|
*/
|
|
1033
1024
|
routeToChunk(route) {
|
|
1034
|
-
const viaName = this.routeToChunkViaName(route);
|
|
1035
|
-
if (viaName) {
|
|
1036
|
-
return viaName;
|
|
1037
|
-
}
|
|
1038
|
-
const directMatch = this.findDirectMatch(route);
|
|
1039
|
-
if (directMatch) {
|
|
1040
|
-
return directMatch;
|
|
1041
|
-
}
|
|
1042
|
-
const patternMatch = this.findPatternMatch(route);
|
|
1043
|
-
if (patternMatch) {
|
|
1044
|
-
return patternMatch;
|
|
1045
|
-
}
|
|
1046
|
-
const fuzzyMatch = this.findFuzzyMatch(route);
|
|
1047
|
-
if (fuzzyMatch) {
|
|
1048
|
-
return fuzzyMatch;
|
|
1049
|
-
}
|
|
1050
|
-
return null;
|
|
1051
|
-
}
|
|
1052
|
-
/**
|
|
1053
|
-
* Strategy 1: Direct path match
|
|
1054
|
-
*/
|
|
1055
|
-
findDirectMatch(route) {
|
|
1056
1025
|
const normalizedRoute = route.replace(/\/[:$]\w+/g, "");
|
|
1057
|
-
const cleanRoutePath = normalizedRoute.replace(/^\//, "");
|
|
1058
1026
|
const routeSegments = normalizedRoute.split("/").filter(Boolean);
|
|
1059
|
-
|
|
1060
|
-
const
|
|
1061
|
-
|
|
1062
|
-
}).join("/");
|
|
1063
|
-
let singleSegmentPascal = null;
|
|
1064
|
-
if (routeSegments.length === 1) {
|
|
1065
|
-
const segment = routeSegments[0];
|
|
1066
|
-
const words = segment.split("-");
|
|
1067
|
-
singleSegmentPascal = words.map((w) => w.charAt(0).toUpperCase() + w.slice(1).toLowerCase()).join("");
|
|
1068
|
-
}
|
|
1069
|
-
const patterns = [
|
|
1070
|
-
// HIGHEST PRIORITY: Exact page component name matches
|
|
1071
|
-
singleSegmentPascal ? `src/pages/${singleSegmentPascal}.tsx` : null,
|
|
1072
|
-
singleSegmentPascal ? `src/pages/${singleSegmentPascal}.ts` : null,
|
|
1073
|
-
singleSegmentPascal ? `src/pages/${singleSegmentPascal}.jsx` : null,
|
|
1074
|
-
singleSegmentPascal ? `src/pages/${singleSegmentPascal}.js` : null,
|
|
1075
|
-
// For multi-segment routes with hyphens
|
|
1076
|
-
`src/pages/${pascalCaseComponent}.tsx`,
|
|
1077
|
-
`src/pages/${pascalCaseComponent}.ts`,
|
|
1078
|
-
`src/pages/${pascalCaseComponent}.jsx`,
|
|
1079
|
-
`src/pages/${pascalCaseComponent}.js`,
|
|
1080
|
-
// Features folder
|
|
1081
|
-
`src/features${normalizedRoute}/index.ts`,
|
|
1082
|
-
`src/features${normalizedRoute}/index.tsx`,
|
|
1083
|
-
`src/features${normalizedRoute}/index.js`,
|
|
1084
|
-
`src/features${normalizedRoute}/index.jsx`,
|
|
1085
|
-
// Pages folder - try both directory and file formats
|
|
1086
|
-
`src/pages${normalizedRoute}/index.tsx`,
|
|
1087
|
-
`src/pages${normalizedRoute}/index.ts`,
|
|
1088
|
-
`src/pages${normalizedRoute}/index.jsx`,
|
|
1089
|
-
`src/pages${normalizedRoute}/index.js`,
|
|
1090
|
-
`src/pages${normalizedRoute}.tsx`,
|
|
1091
|
-
`src/pages${normalizedRoute}.ts`,
|
|
1092
|
-
`src/pages${normalizedRoute}.jsx`,
|
|
1093
|
-
`src/pages${normalizedRoute}.js`,
|
|
1094
|
-
// Fallback to old capitalize method (single capital letter)
|
|
1095
|
-
`src/pages/${this.capitalize(cleanRoutePath)}.tsx`,
|
|
1096
|
-
`src/pages/${this.capitalize(cleanRoutePath)}.ts`,
|
|
1097
|
-
// Full paths with app prefix
|
|
1098
|
-
`apps/farmart-pro/src/features${normalizedRoute}/index.ts`,
|
|
1099
|
-
`apps/farmart-pro/src/features${normalizedRoute}/index.tsx`,
|
|
1100
|
-
`apps/farmart-pro/src/pages${normalizedRoute}/index.tsx`
|
|
1101
|
-
].filter(Boolean);
|
|
1102
|
-
for (let i = 0; i < patterns.length; i++) {
|
|
1103
|
-
const pattern = patterns[i];
|
|
1104
|
-
if (!pattern) continue;
|
|
1105
|
-
const entry = this.manifest[pattern];
|
|
1106
|
-
if (entry) {
|
|
1107
|
-
return entry.file;
|
|
1108
|
-
}
|
|
1109
|
-
}
|
|
1110
|
-
return null;
|
|
1111
|
-
}
|
|
1112
|
-
/**
|
|
1113
|
-
* Capitalize first letter of string
|
|
1114
|
-
*/
|
|
1115
|
-
capitalize(str) {
|
|
1116
|
-
return str.charAt(0).toUpperCase() + str.slice(1);
|
|
1117
|
-
}
|
|
1118
|
-
/**
|
|
1119
|
-
* Strategy 2: Pattern matching with wildcards
|
|
1120
|
-
*/
|
|
1121
|
-
findPatternMatch(route) {
|
|
1122
|
-
const routeSegments = route.split("/").filter(Boolean);
|
|
1123
|
-
if (routeSegments.length === 0) return null;
|
|
1124
|
-
const candidates = Object.entries(this.manifest).filter(([path2]) => {
|
|
1125
|
-
const pathSegments = path2.split("/").filter(Boolean);
|
|
1126
|
-
return routeSegments.every(
|
|
1127
|
-
(segment) => pathSegments.some(
|
|
1128
|
-
(ps) => ps.toLowerCase().includes(segment.replace(/[:$]\w+/, "").toLowerCase())
|
|
1129
|
-
)
|
|
1027
|
+
if (routeSegments.length === 0) {
|
|
1028
|
+
const candidates2 = Object.entries(this.manifest).filter(
|
|
1029
|
+
([path2]) => path2 === "src/pages/index.tsx" || path2 === "src/app.tsx" || path2 === "src/App.tsx" || path2 === "src/main.tsx"
|
|
1130
1030
|
);
|
|
1131
|
-
|
|
1132
|
-
|
|
1133
|
-
if (!pathA.includes("/pages/") && pathB.includes("/pages/")) return 1;
|
|
1134
|
-
const aIsEntry = pathA.includes("index.tsx") || pathA.includes("index.ts");
|
|
1135
|
-
const bIsEntry = pathB.includes("index.tsx") || pathB.includes("index.ts");
|
|
1136
|
-
if (aIsEntry && !bIsEntry) return -1;
|
|
1137
|
-
if (!aIsEntry && bIsEntry) return 1;
|
|
1138
|
-
if (pathA.includes(".tsx") && !pathB.includes(".tsx")) return -1;
|
|
1139
|
-
if (!pathA.includes(".tsx") && pathB.includes(".tsx")) return 1;
|
|
1140
|
-
return 0;
|
|
1141
|
-
});
|
|
1142
|
-
if (candidates.length > 0) {
|
|
1143
|
-
if (this.debug) {
|
|
1144
|
-
console.log(` \u2705 Pattern match found: ${candidates[0][0]} \u2192 ${candidates[0][1].file}`);
|
|
1145
|
-
}
|
|
1146
|
-
return candidates[0][1].file;
|
|
1147
|
-
}
|
|
1148
|
-
if (this.debug) {
|
|
1149
|
-
console.log(` No pattern match found`);
|
|
1150
|
-
}
|
|
1151
|
-
return null;
|
|
1152
|
-
}
|
|
1153
|
-
/**
|
|
1154
|
-
* Strategy 3: Fuzzy matching
|
|
1155
|
-
* Converts route to camelCase/PascalCase and searches
|
|
1156
|
-
*/
|
|
1157
|
-
findFuzzyMatch(route) {
|
|
1158
|
-
const cleanRoute = route.replace(/\/[:$]\w+/g, "");
|
|
1159
|
-
const routeSegments = cleanRoute.split("/").filter(Boolean);
|
|
1160
|
-
const pascalCase = routeSegments.map((segment) => {
|
|
1161
|
-
const words = segment.split("-");
|
|
1162
|
-
return words.map((word) => word.charAt(0).toUpperCase() + word.slice(1).toLowerCase()).join("");
|
|
1163
|
-
}).join("");
|
|
1164
|
-
const camelCase = pascalCase.charAt(0).toLowerCase() + pascalCase.slice(1);
|
|
1165
|
-
if (this.debug) {
|
|
1166
|
-
console.log(` Fuzzy match - Route: ${route}`);
|
|
1167
|
-
console.log(` Trying PascalCase: ${pascalCase}, camelCase: ${camelCase}`);
|
|
1031
|
+
if (candidates2.length > 0) return candidates2[0][1].file;
|
|
1032
|
+
return null;
|
|
1168
1033
|
}
|
|
1169
|
-
const candidates = Object.entries(this.manifest).filter(([path2
|
|
1170
|
-
if (path2.startsWith("
|
|
1034
|
+
const candidates = Object.entries(this.manifest).filter(([path2]) => {
|
|
1035
|
+
if (path2.startsWith("node_modules") || path2.startsWith("_")) {
|
|
1171
1036
|
return false;
|
|
1172
1037
|
}
|
|
1173
|
-
const
|
|
1174
|
-
|
|
1175
|
-
|
|
1176
|
-
return true;
|
|
1177
|
-
}
|
|
1178
|
-
if (fileName.includes(pascalCase) || fileName.includes(camelCase)) {
|
|
1179
|
-
return true;
|
|
1180
|
-
}
|
|
1181
|
-
const pathSegments = path2.toLowerCase().split("/");
|
|
1182
|
-
const lowerPascal = pascalCase.toLowerCase();
|
|
1183
|
-
const lowerCamel = camelCase.toLowerCase();
|
|
1184
|
-
return pathSegments.some(
|
|
1185
|
-
(seg) => seg.includes(lowerPascal) || seg.includes(lowerCamel)
|
|
1038
|
+
const pathLower = path2.toLowerCase();
|
|
1039
|
+
return routeSegments.every(
|
|
1040
|
+
(segment) => pathLower.includes(segment.toLowerCase())
|
|
1186
1041
|
);
|
|
1187
|
-
}).sort(([pathA
|
|
1188
|
-
|
|
1189
|
-
|
|
1190
|
-
if (
|
|
1191
|
-
|
|
1192
|
-
|
|
1193
|
-
if (
|
|
1194
|
-
if (
|
|
1195
|
-
if (
|
|
1196
|
-
|
|
1197
|
-
|
|
1198
|
-
|
|
1199
|
-
|
|
1042
|
+
}).sort(([pathA], [pathB]) => {
|
|
1043
|
+
let scoreA = 0;
|
|
1044
|
+
let scoreB = 0;
|
|
1045
|
+
if (pathA.includes("/pages/")) scoreA += 10;
|
|
1046
|
+
if (pathB.includes("/pages/")) scoreB += 10;
|
|
1047
|
+
if (pathA.includes("index.tsx")) scoreA += 8;
|
|
1048
|
+
if (pathB.includes("index.tsx")) scoreB += 8;
|
|
1049
|
+
if (pathA.includes("index.ts")) scoreA += 7;
|
|
1050
|
+
if (pathB.includes("index.ts")) scoreB += 7;
|
|
1051
|
+
const pathASegments = pathA.split("/").map((s) => s.toLowerCase()).filter((s) => s && !s.startsWith("."));
|
|
1052
|
+
const pathBSegments = pathB.split("/").map((s) => s.toLowerCase()).filter((s) => s && !s.startsWith("."));
|
|
1053
|
+
const matchCountA = routeSegments.filter(
|
|
1054
|
+
(seg) => pathASegments.some((ps) => ps.includes(seg.toLowerCase()))
|
|
1055
|
+
).length;
|
|
1056
|
+
const matchCountB = routeSegments.filter(
|
|
1057
|
+
(seg) => pathBSegments.some((ps) => ps.includes(seg.toLowerCase()))
|
|
1058
|
+
).length;
|
|
1059
|
+
scoreA += matchCountA * 5;
|
|
1060
|
+
scoreB += matchCountB * 5;
|
|
1061
|
+
return scoreB - scoreA;
|
|
1200
1062
|
});
|
|
1201
1063
|
if (candidates.length > 0) {
|
|
1202
|
-
const
|
|
1064
|
+
const manifestEntry = candidates[0][1];
|
|
1203
1065
|
if (this.debug) {
|
|
1204
|
-
console.log(` \u2705
|
|
1066
|
+
console.log(` \u2705 Found chunk for route ${route}`);
|
|
1067
|
+
console.log(` Manifest: ${candidates[0][0]}`);
|
|
1068
|
+
console.log(` Chunk file: ${manifestEntry.file}`);
|
|
1205
1069
|
}
|
|
1206
|
-
return
|
|
1070
|
+
return manifestEntry.file;
|
|
1207
1071
|
}
|
|
1208
1072
|
if (this.debug) {
|
|
1209
|
-
console.log(` No
|
|
1073
|
+
console.log(` \u26A0\uFE0F No chunk found for route: ${route}`);
|
|
1074
|
+
console.log(` Searched for segments: ${routeSegments.join(", ")}`);
|
|
1210
1075
|
}
|
|
1211
1076
|
return null;
|
|
1212
1077
|
}
|
|
@@ -1324,90 +1189,6 @@ var _ConfigGenerator = class _ConfigGenerator {
|
|
|
1324
1189
|
return segmentConfigs;
|
|
1325
1190
|
}
|
|
1326
1191
|
};
|
|
1327
|
-
/**
|
|
1328
|
-
* Maps routes to their component names based on vite.config.ts chunk strategy
|
|
1329
|
-
* This is derived from the route configuration in src/routes/index.ts
|
|
1330
|
-
* Note: These are the core routes from vite.config.ts chunking strategy
|
|
1331
|
-
* Routes not listed here will fall through to fuzzy matching
|
|
1332
|
-
*/
|
|
1333
|
-
_ConfigGenerator.ROUTE_TO_COMPONENT_NAME = {
|
|
1334
|
-
"/": "Home",
|
|
1335
|
-
"/home": "Home",
|
|
1336
|
-
"/dashboard": "Dashboard",
|
|
1337
|
-
"/profile": "Profile",
|
|
1338
|
-
"/settings": "Settings",
|
|
1339
|
-
"/preferences": "Preferences",
|
|
1340
|
-
"/privacy": "Privacy",
|
|
1341
|
-
"/security": "Security",
|
|
1342
|
-
"/analytics": "Analytics",
|
|
1343
|
-
"/reports": "Reports",
|
|
1344
|
-
"/metrics": "Metrics",
|
|
1345
|
-
"/projects": "Projects",
|
|
1346
|
-
"/tasks": "Tasks",
|
|
1347
|
-
"/teams": "Teams",
|
|
1348
|
-
"/workspaces": "Workspaces",
|
|
1349
|
-
"/workflows": "Workflows",
|
|
1350
|
-
"/templates": "Templates",
|
|
1351
|
-
"/logs": "Logs",
|
|
1352
|
-
"/audit-logs": "AuditLogs",
|
|
1353
|
-
"/integrations": "Integrations",
|
|
1354
|
-
"/api-docs": "ApiDocs",
|
|
1355
|
-
"/api-documentation": "ApiDocs",
|
|
1356
|
-
// Alias for space-separated variant
|
|
1357
|
-
"/support": "Support",
|
|
1358
|
-
"/help": "Help",
|
|
1359
|
-
"/billing": "Billing",
|
|
1360
|
-
"/plans": "Plans",
|
|
1361
|
-
"/usage": "Usage",
|
|
1362
|
-
"/permissions": "Permissions",
|
|
1363
|
-
"/notifications": "Notifications"
|
|
1364
|
-
};
|
|
1365
|
-
/**
|
|
1366
|
-
* Maps component names to chunk names based on vite.config.ts manualChunks strategy
|
|
1367
|
-
* Each component is assigned to a specific chunk group for code splitting
|
|
1368
|
-
*
|
|
1369
|
-
* Note: Core components (Home, Dashboard) are not in manual chunks - they're part of main bundle
|
|
1370
|
-
* For these, we return the main bundle file path 'js/index-*.js' which will be resolved from manifest
|
|
1371
|
-
*/
|
|
1372
|
-
_ConfigGenerator.COMPONENT_TO_CHUNK_NAME = {
|
|
1373
|
-
// Core components - loaded with main bundle (not code-split)
|
|
1374
|
-
Home: "index",
|
|
1375
|
-
// Special marker for main entry point
|
|
1376
|
-
Dashboard: "index",
|
|
1377
|
-
// User Profile & Settings chunk
|
|
1378
|
-
Profile: "chunk-user-profile",
|
|
1379
|
-
Settings: "chunk-user-profile",
|
|
1380
|
-
Preferences: "chunk-user-profile",
|
|
1381
|
-
Privacy: "chunk-user-profile",
|
|
1382
|
-
Security: "chunk-user-profile",
|
|
1383
|
-
// Analytics & Reporting chunk
|
|
1384
|
-
Analytics: "chunk-analytics",
|
|
1385
|
-
Reports: "chunk-analytics",
|
|
1386
|
-
Metrics: "chunk-analytics",
|
|
1387
|
-
// Project Management chunk
|
|
1388
|
-
Projects: "chunk-projects",
|
|
1389
|
-
Tasks: "chunk-projects",
|
|
1390
|
-
Teams: "chunk-projects",
|
|
1391
|
-
Workspaces: "chunk-projects",
|
|
1392
|
-
// Workflows & Operations chunk
|
|
1393
|
-
Workflows: "chunk-operations",
|
|
1394
|
-
Templates: "chunk-operations",
|
|
1395
|
-
Logs: "chunk-operations",
|
|
1396
|
-
AuditLogs: "chunk-operations",
|
|
1397
|
-
// Integration chunk
|
|
1398
|
-
Integrations: "chunk-integrations",
|
|
1399
|
-
ApiDocs: "chunk-integrations",
|
|
1400
|
-
Support: "chunk-integrations",
|
|
1401
|
-
Help: "chunk-integrations",
|
|
1402
|
-
// Billing & Plans chunk
|
|
1403
|
-
Billing: "chunk-billing",
|
|
1404
|
-
Plans: "chunk-billing",
|
|
1405
|
-
Usage: "chunk-billing",
|
|
1406
|
-
// Admin & Notifications chunk
|
|
1407
|
-
Permissions: "chunk-admin",
|
|
1408
|
-
Notifications: "chunk-admin"
|
|
1409
|
-
};
|
|
1410
|
-
var ConfigGenerator = _ConfigGenerator;
|
|
1411
1192
|
|
|
1412
1193
|
// src/plugin/cache-manager.ts
|
|
1413
1194
|
var fs = __toESM(require("fs"), 1);
|
|
@@ -1829,6 +1610,37 @@ function smartPrefetch(options = {}) {
|
|
|
1829
1610
|
framework: '${framework}',
|
|
1830
1611
|
debug: ${debug},
|
|
1831
1612
|
};
|
|
1613
|
+
|
|
1614
|
+
// Initialize prefetch manager after page load
|
|
1615
|
+
// This allows the app to be built first, then PrefetchManager can load the config
|
|
1616
|
+
if (document.readyState === 'loading') {
|
|
1617
|
+
document.addEventListener('DOMContentLoaded', initPrefetch);
|
|
1618
|
+
} else {
|
|
1619
|
+
initPrefetch();
|
|
1620
|
+
}
|
|
1621
|
+
|
|
1622
|
+
async function initPrefetch() {
|
|
1623
|
+
try {
|
|
1624
|
+
// Dynamically import PrefetchManager from the bundled app
|
|
1625
|
+
// The app should have @farmart/vite-plugin-smart-prefetch/runtime in its dependencies
|
|
1626
|
+
const { PrefetchManager } = await import('@farmart/vite-plugin-smart-prefetch/runtime');
|
|
1627
|
+
const manager = new PrefetchManager('${strategy}', ${debug});
|
|
1628
|
+
await manager.init();
|
|
1629
|
+
|
|
1630
|
+
// Expose manager globally for debugging
|
|
1631
|
+
window.__PREFETCH_MANAGER__ = manager;
|
|
1632
|
+
if (${debug}) {
|
|
1633
|
+
console.log('\u2705 Smart Prefetch Manager initialized');
|
|
1634
|
+
}
|
|
1635
|
+
} catch (error) {
|
|
1636
|
+
if (${debug}) {
|
|
1637
|
+
console.warn('\u26A0\uFE0F Could not initialize Smart Prefetch Manager:', error);
|
|
1638
|
+
console.log('This is expected if:');
|
|
1639
|
+
console.log('1. @farmart/vite-plugin-smart-prefetch/runtime is not installed');
|
|
1640
|
+
console.log('2. prefetch-config.json was not generated (BigQuery data fetch failed)');
|
|
1641
|
+
}
|
|
1642
|
+
}
|
|
1643
|
+
}
|
|
1832
1644
|
`,
|
|
1833
1645
|
injectTo: "head"
|
|
1834
1646
|
}
|