@navigate-ai/vite 0.1.25 → 0.1.27
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/ClippyVitePlugin.js +20 -8
- package/package.json +2 -2
package/dist/ClippyVitePlugin.js
CHANGED
|
@@ -18,20 +18,30 @@ function generatePolicyFromFiles(files) {
|
|
|
18
18
|
// Free memory: drop components/jsxTree from files that are not
|
|
19
19
|
// route-defining files or route component targets — we only need
|
|
20
20
|
// those for element extraction in PolicyGenerator.
|
|
21
|
+
// Walk to MAX_GRAPH_DEPTH (3) to match PolicyGenerator expansion depth.
|
|
22
|
+
const MAX_GRAPH_DEPTH = 3;
|
|
21
23
|
const routeFiles = new Set();
|
|
24
|
+
function addFilesAtDepth(sourceFile, depth) {
|
|
25
|
+
if (depth > MAX_GRAPH_DEPTH)
|
|
26
|
+
return;
|
|
27
|
+
if (!sourceFile || routeFiles.has(sourceFile.filePath))
|
|
28
|
+
return;
|
|
29
|
+
routeFiles.add(sourceFile.filePath);
|
|
30
|
+
// Recurse into imports
|
|
31
|
+
for (const candidates of (sourceFile.imports?.values() ?? [])) {
|
|
32
|
+
for (const candidate of candidates) {
|
|
33
|
+
if (candidate.components.length > 0) {
|
|
34
|
+
addFilesAtDepth(candidate, depth + 1);
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
}
|
|
22
39
|
for (const sf of graph.getAllFiles()) {
|
|
23
40
|
if (sf.routes.length > 0)
|
|
24
41
|
routeFiles.add(sf.filePath);
|
|
25
42
|
for (const route of sf.routes) {
|
|
26
43
|
if (route.resolvedComponent) {
|
|
27
|
-
|
|
28
|
-
// Also keep files imported by the component (one-level expansion targets)
|
|
29
|
-
for (const candidates of (route.resolvedComponent.imports?.values() ?? [])) {
|
|
30
|
-
for (const candidate of candidates) {
|
|
31
|
-
if (candidate.components.length > 0)
|
|
32
|
-
routeFiles.add(candidate.filePath);
|
|
33
|
-
}
|
|
34
|
-
}
|
|
44
|
+
addFilesAtDepth(route.resolvedComponent, 1);
|
|
35
45
|
}
|
|
36
46
|
}
|
|
37
47
|
}
|
|
@@ -74,6 +84,8 @@ export function clippyVitePlugin(options) {
|
|
|
74
84
|
const result = processFile(source, cleanId);
|
|
75
85
|
// Accumulate metadata for policy generation
|
|
76
86
|
if (result.sourceFile) {
|
|
87
|
+
// Memory optimization: clear source string, keep metadata
|
|
88
|
+
result.sourceFile.source = '';
|
|
77
89
|
accumulatedFiles.set(cleanId, result.sourceFile);
|
|
78
90
|
}
|
|
79
91
|
// Return modified source if IDs were injected
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@navigate-ai/vite",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.27",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"module": "dist/index.js",
|
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
}
|
|
19
19
|
},
|
|
20
20
|
"dependencies": {
|
|
21
|
-
"@navigate_ai/plugin-shared": "^0.1.
|
|
21
|
+
"@navigate_ai/plugin-shared": "^0.1.27"
|
|
22
22
|
},
|
|
23
23
|
"peerDependencies": {
|
|
24
24
|
"@babel/parser": "^7.0.0",
|