@vistagenic/vista 0.3.2 → 0.3.3

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.
Files changed (98) hide show
  1. package/bin/vista.js +79 -109
  2. package/dist/ai/embeddings.d.ts +11 -11
  3. package/dist/ai/embeddings.js +71 -71
  4. package/dist/ai/index.d.ts +10 -10
  5. package/dist/ai/index.js +26 -26
  6. package/dist/ai/providers/base.js +85 -85
  7. package/dist/ai/react/react-server.d.ts +1 -1
  8. package/dist/ai/react/react-server.js +17 -17
  9. package/dist/ai/react/use-agent.js +138 -138
  10. package/dist/auth/core.d.ts +140 -140
  11. package/dist/auth/core.js +165 -165
  12. package/dist/auth/index.d.ts +20 -20
  13. package/dist/auth/index.js +369 -369
  14. package/dist/auth/react-server.d.ts +1 -1
  15. package/dist/auth/react-server.js +10 -10
  16. package/dist/auth/react.d.ts +18 -18
  17. package/dist/auth/react.js +71 -71
  18. package/dist/bin/build-rsc-flashpack.js +6 -0
  19. package/dist/bin/build-rsc.js +537 -492
  20. package/dist/bin/build.js +355 -353
  21. package/dist/bin/generate.js +513 -510
  22. package/dist/bin/webpack.config.js +4 -3
  23. package/dist/build/manifest.d.ts +169 -169
  24. package/dist/build/manifest.js +423 -423
  25. package/dist/build/rsc/client-manifest.d.ts +62 -62
  26. package/dist/build/rsc/client-manifest.js +295 -295
  27. package/dist/build/rsc/compiler.js +5 -4
  28. package/dist/build/rsc/native-scanner.d.ts +135 -135
  29. package/dist/build/rsc/native-scanner.js +203 -203
  30. package/dist/build/rsc/react-client-reference-manifest.d.ts +28 -28
  31. package/dist/build/rsc/react-client-reference-manifest.js +240 -240
  32. package/dist/build/standalone.js +260 -254
  33. package/dist/client/dynamic.react-server.d.ts +2 -2
  34. package/dist/client/dynamic.react-server.js +23 -23
  35. package/dist/client/link.react-server.d.ts +2 -2
  36. package/dist/client/link.react-server.js +11 -11
  37. package/dist/client/navigation.react-server.d.ts +1 -1
  38. package/dist/client/navigation.react-server.js +17 -17
  39. package/dist/client/router.react-server.d.ts +1 -1
  40. package/dist/client/router.react-server.js +17 -17
  41. package/dist/client/rsc-router.react-server.d.ts +1 -1
  42. package/dist/client/rsc-router.react-server.js +17 -17
  43. package/dist/client/script.react-server.d.ts +2 -2
  44. package/dist/client/script.react-server.js +23 -23
  45. package/dist/config.d.ts +1 -1
  46. package/dist/config.js +1 -7
  47. package/dist/deploy/adapters/cloudflare.js +43 -19
  48. package/dist/deploy/adapters/docker.d.ts +1 -0
  49. package/dist/deploy/adapters/docker.js +5 -4
  50. package/dist/deploy/adapters/netlify.js +62 -17
  51. package/dist/deploy/adapters/vercel.js +80 -50
  52. package/dist/deploy/preflight.js +4 -3
  53. package/dist/deploy/runtime-pack.d.ts +11 -0
  54. package/dist/deploy/runtime-pack.js +300 -0
  55. package/dist/deploy/utils.d.ts +1 -1
  56. package/dist/deploy/utils.js +31 -2
  57. package/dist/flashpack/command.js +1 -0
  58. package/dist/flashpack/runtime.js +2 -1
  59. package/dist/index.d.ts +23 -23
  60. package/dist/index.js +61 -61
  61. package/dist/server/app-dir.d.ts +22 -0
  62. package/dist/server/app-dir.js +77 -0
  63. package/dist/server/cookie-parse.d.ts +4 -4
  64. package/dist/server/cookie-parse.js +14 -14
  65. package/dist/server/engine.js +5 -5
  66. package/dist/server/image-optimizer.js +2 -1
  67. package/dist/server/index.d.ts +109 -109
  68. package/dist/server/index.js +315 -315
  69. package/dist/server/middleware-runner.d.ts +125 -125
  70. package/dist/server/middleware-runner.js +607 -615
  71. package/dist/server/middleware-security.d.ts +36 -36
  72. package/dist/server/middleware-security.js +183 -183
  73. package/dist/server/module-compile-hook.js +695 -695
  74. package/dist/server/root-resolver.js +6 -5
  75. package/dist/server/rsc-engine-flashpack.d.ts +3 -1
  76. package/dist/server/rsc-engine-flashpack.js +12 -1
  77. package/dist/server/rsc-engine.d.ts +6 -1
  78. package/dist/server/rsc-engine.js +203 -219
  79. package/dist/server/rsc-upstream.js +893 -892
  80. package/dist/server/static-generator.js +4 -3
  81. package/dist/server/structure-validator.js +2 -1
  82. package/dist/server/structure-watch.js +2 -0
  83. package/dist/server/typed-api-runtime.js +639 -635
  84. package/dist/server/vista-import-map.js +134 -134
  85. package/dist/stack/index.d.ts +34 -34
  86. package/dist/stack/index.js +49 -49
  87. package/dist/stack/server/caller.d.ts +13 -13
  88. package/dist/stack/server/caller.js +42 -42
  89. package/dist/stack/server/executor.d.ts +40 -40
  90. package/dist/stack/server/executor.js +222 -222
  91. package/dist/stack/server/index.d.ts +11 -11
  92. package/dist/stack/server/index.js +24 -24
  93. package/dist/stack/server/procedure.d.ts +20 -20
  94. package/dist/stack/server/procedure.js +66 -66
  95. package/dist/stack/server/types.d.ts +113 -113
  96. package/dist/theme/react-server.d.ts +10 -10
  97. package/dist/theme/react-server.js +16 -16
  98. package/package.json +1 -1
@@ -1,135 +1,135 @@
1
- /**
2
- * Vista RSC Native Scanner
3
- *
4
- * Uses Rust-powered native bindings for blazing fast component scanning.
5
- * Falls back to TypeScript implementation if native module unavailable.
6
- */
7
- export interface NapiScannedComponent {
8
- absolutePath: string;
9
- relativePath: string;
10
- isClient: boolean;
11
- directiveLine: number;
12
- componentType: string;
13
- exports: string[];
14
- clientHooksUsed: string[];
15
- hasMetadata: boolean;
16
- hasGenerateMetadata: boolean;
17
- }
18
- export interface NapiServerComponentError {
19
- file: string;
20
- message: string;
21
- hooks: string[];
22
- }
23
- export interface NapiScanResult {
24
- clientComponents: NapiScannedComponent[];
25
- serverComponents: NapiScannedComponent[];
26
- pages: NapiScannedComponent[];
27
- layouts: NapiScannedComponent[];
28
- apiRoutes: NapiScannedComponent[];
29
- errors: NapiServerComponentError[];
30
- totalFiles: number;
31
- scanTimeMs: number;
32
- }
33
- export interface NapiClientModuleEntry {
34
- id: string;
35
- path: string;
36
- absolutePath: string;
37
- chunkName: string;
38
- exports: string[];
39
- asyncLoad: boolean;
40
- }
41
- export interface NapiClientManifest {
42
- buildId: string;
43
- clientModules: NapiClientModuleEntry[];
44
- }
45
- export interface NapiRouteEntry {
46
- pattern: string;
47
- pagePath: string;
48
- layoutPaths: string[];
49
- loadingPath: string | null;
50
- errorPath: string | null;
51
- routeType: string;
52
- }
53
- export interface NapiServerModuleEntry {
54
- id: string;
55
- path: string;
56
- absolutePath: string;
57
- componentType: string;
58
- hasMetadata: boolean;
59
- hasGenerateMetadata: boolean;
60
- }
61
- export interface NapiServerManifest {
62
- buildId: string;
63
- serverModules: NapiServerModuleEntry[];
64
- routes: NapiRouteEntry[];
65
- }
66
- export interface NapiClientScanRoot {
67
- dir: string;
68
- prefix: string;
69
- }
70
- /**
71
- * Check if native module is available
72
- */
73
- export declare function isNativeAvailable(): boolean;
74
- /**
75
- * Scan app directory using Rust native code
76
- * Returns null if native module is not available
77
- */
78
- export declare function scanAppNative(appDir: string): NapiScanResult | null;
79
- /**
80
- * Generate client manifest using Rust native code
81
- */
82
- export declare function generateClientManifestNative(appDir: string, buildId: string): NapiClientManifest | null;
83
- /**
84
- * Generate client manifest from an explicit project root plus `app/`
85
- */
86
- export declare function generateClientManifestForProjectNative(cwd: string, appDir: string, buildId: string): NapiClientManifest | null;
87
- /**
88
- * Discover project-level client scan roots using Rust native code
89
- */
90
- export declare function discoverProjectClientRootsNative(cwd: string): NapiClientScanRoot[] | null;
91
- /**
92
- * Generate server manifest using Rust native code
93
- */
94
- export declare function generateServerManifestNative(appDir: string, buildId: string): NapiServerManifest | null;
95
- /**
96
- * Generate unique mount ID for client component
97
- */
98
- export declare function generateMountIdNative(): string | null;
99
- /**
100
- * Reset mount ID counter (call at start of each request)
101
- */
102
- export declare function resetMountCounterNative(): boolean;
103
- /**
104
- * Convert NAPI scan result to internal format
105
- */
106
- export declare function convertScanResult(result: NapiScanResult): {
107
- clientComponents: {
108
- absolutePath: string;
109
- relativePath: string;
110
- isClient: boolean;
111
- directiveLine: number;
112
- componentType: string;
113
- exports: string[];
114
- clientHooksUsed: string[];
115
- hasMetadata: boolean;
116
- hasGenerateMetadata: boolean;
117
- }[];
118
- serverComponents: {
119
- absolutePath: string;
120
- relativePath: string;
121
- isClient: boolean;
122
- directiveLine: number;
123
- componentType: string;
124
- exports: string[];
125
- clientHooksUsed: any[];
126
- hasMetadata: boolean;
127
- hasGenerateMetadata: boolean;
128
- }[];
129
- pages: NapiScannedComponent[];
130
- layouts: NapiScannedComponent[];
131
- apiRoutes: NapiScannedComponent[];
132
- errors: NapiServerComponentError[];
133
- totalFiles: number;
134
- scanTimeMs: number;
135
- };
1
+ /**
2
+ * Vista RSC Native Scanner
3
+ *
4
+ * Uses Rust-powered native bindings for blazing fast component scanning.
5
+ * Falls back to TypeScript implementation if native module unavailable.
6
+ */
7
+ export interface NapiScannedComponent {
8
+ absolutePath: string;
9
+ relativePath: string;
10
+ isClient: boolean;
11
+ directiveLine: number;
12
+ componentType: string;
13
+ exports: string[];
14
+ clientHooksUsed: string[];
15
+ hasMetadata: boolean;
16
+ hasGenerateMetadata: boolean;
17
+ }
18
+ export interface NapiServerComponentError {
19
+ file: string;
20
+ message: string;
21
+ hooks: string[];
22
+ }
23
+ export interface NapiScanResult {
24
+ clientComponents: NapiScannedComponent[];
25
+ serverComponents: NapiScannedComponent[];
26
+ pages: NapiScannedComponent[];
27
+ layouts: NapiScannedComponent[];
28
+ apiRoutes: NapiScannedComponent[];
29
+ errors: NapiServerComponentError[];
30
+ totalFiles: number;
31
+ scanTimeMs: number;
32
+ }
33
+ export interface NapiClientModuleEntry {
34
+ id: string;
35
+ path: string;
36
+ absolutePath: string;
37
+ chunkName: string;
38
+ exports: string[];
39
+ asyncLoad: boolean;
40
+ }
41
+ export interface NapiClientManifest {
42
+ buildId: string;
43
+ clientModules: NapiClientModuleEntry[];
44
+ }
45
+ export interface NapiRouteEntry {
46
+ pattern: string;
47
+ pagePath: string;
48
+ layoutPaths: string[];
49
+ loadingPath: string | null;
50
+ errorPath: string | null;
51
+ routeType: string;
52
+ }
53
+ export interface NapiServerModuleEntry {
54
+ id: string;
55
+ path: string;
56
+ absolutePath: string;
57
+ componentType: string;
58
+ hasMetadata: boolean;
59
+ hasGenerateMetadata: boolean;
60
+ }
61
+ export interface NapiServerManifest {
62
+ buildId: string;
63
+ serverModules: NapiServerModuleEntry[];
64
+ routes: NapiRouteEntry[];
65
+ }
66
+ export interface NapiClientScanRoot {
67
+ dir: string;
68
+ prefix: string;
69
+ }
70
+ /**
71
+ * Check if native module is available
72
+ */
73
+ export declare function isNativeAvailable(): boolean;
74
+ /**
75
+ * Scan app directory using Rust native code
76
+ * Returns null if native module is not available
77
+ */
78
+ export declare function scanAppNative(appDir: string): NapiScanResult | null;
79
+ /**
80
+ * Generate client manifest using Rust native code
81
+ */
82
+ export declare function generateClientManifestNative(appDir: string, buildId: string): NapiClientManifest | null;
83
+ /**
84
+ * Generate client manifest from an explicit project root plus `app/`
85
+ */
86
+ export declare function generateClientManifestForProjectNative(cwd: string, appDir: string, buildId: string): NapiClientManifest | null;
87
+ /**
88
+ * Discover project-level client scan roots using Rust native code
89
+ */
90
+ export declare function discoverProjectClientRootsNative(cwd: string): NapiClientScanRoot[] | null;
91
+ /**
92
+ * Generate server manifest using Rust native code
93
+ */
94
+ export declare function generateServerManifestNative(appDir: string, buildId: string): NapiServerManifest | null;
95
+ /**
96
+ * Generate unique mount ID for client component
97
+ */
98
+ export declare function generateMountIdNative(): string | null;
99
+ /**
100
+ * Reset mount ID counter (call at start of each request)
101
+ */
102
+ export declare function resetMountCounterNative(): boolean;
103
+ /**
104
+ * Convert NAPI scan result to internal format
105
+ */
106
+ export declare function convertScanResult(result: NapiScanResult): {
107
+ clientComponents: {
108
+ absolutePath: string;
109
+ relativePath: string;
110
+ isClient: boolean;
111
+ directiveLine: number;
112
+ componentType: string;
113
+ exports: string[];
114
+ clientHooksUsed: string[];
115
+ hasMetadata: boolean;
116
+ hasGenerateMetadata: boolean;
117
+ }[];
118
+ serverComponents: {
119
+ absolutePath: string;
120
+ relativePath: string;
121
+ isClient: boolean;
122
+ directiveLine: number;
123
+ componentType: string;
124
+ exports: string[];
125
+ clientHooksUsed: any[];
126
+ hasMetadata: boolean;
127
+ hasGenerateMetadata: boolean;
128
+ }[];
129
+ pages: NapiScannedComponent[];
130
+ layouts: NapiScannedComponent[];
131
+ apiRoutes: NapiScannedComponent[];
132
+ errors: NapiServerComponentError[];
133
+ totalFiles: number;
134
+ scanTimeMs: number;
135
+ };
@@ -1,203 +1,203 @@
1
- "use strict";
2
- /**
3
- * Vista RSC Native Scanner
4
- *
5
- * Uses Rust-powered native bindings for blazing fast component scanning.
6
- * Falls back to TypeScript implementation if native module unavailable.
7
- */
8
- var __importDefault = (this && this.__importDefault) || function (mod) {
9
- return (mod && mod.__esModule) ? mod : { "default": mod };
10
- };
11
- Object.defineProperty(exports, "__esModule", { value: true });
12
- exports.isNativeAvailable = isNativeAvailable;
13
- exports.scanAppNative = scanAppNative;
14
- exports.generateClientManifestNative = generateClientManifestNative;
15
- exports.generateClientManifestForProjectNative = generateClientManifestForProjectNative;
16
- exports.discoverProjectClientRootsNative = discoverProjectClientRootsNative;
17
- exports.generateServerManifestNative = generateServerManifestNative;
18
- exports.generateMountIdNative = generateMountIdNative;
19
- exports.resetMountCounterNative = resetMountCounterNative;
20
- exports.convertScanResult = convertScanResult;
21
- const path_1 = __importDefault(require("path"));
22
- let nativeModule = null;
23
- let nativeLoadError = null;
24
- /**
25
- * Try to load the native Rust module
26
- */
27
- function loadNativeModule() {
28
- if (nativeModule !== null)
29
- return nativeModule;
30
- if (nativeLoadError !== null)
31
- return null;
32
- // Try multiple paths since we might be running from src or dist
33
- const possiblePaths = [
34
- // From compiled dist/build/rsc/native-scanner.js
35
- path_1.default.resolve(__dirname, '../../../../../crates/vista-napi'),
36
- // From source src/build/rsc/native-scanner.ts
37
- path_1.default.resolve(__dirname, '../../../../crates/vista-napi'),
38
- // From workspace root
39
- path_1.default.resolve(process.cwd(), '../crates/vista-napi'),
40
- // Try @aspect-build/vista-napi as npm package
41
- '@aspect-build/vista-napi',
42
- ];
43
- const _debug = !!process.env.VISTA_DEBUG;
44
- for (const modulePath of possiblePaths) {
45
- try {
46
- // eslint-disable-next-line @typescript-eslint/no-require-imports
47
- nativeModule = require(modulePath);
48
- if (_debug)
49
- console.log('[Vista JS RSC] Using Rust-powered scanner');
50
- return nativeModule;
51
- }
52
- catch {
53
- // Continue trying other paths
54
- }
55
- }
56
- nativeLoadError = new Error('Native module not found');
57
- if (_debug)
58
- console.warn('⚠ Native module unavailable, using TypeScript fallback');
59
- return null;
60
- }
61
- /**
62
- * Check if native module is available
63
- */
64
- function isNativeAvailable() {
65
- return loadNativeModule() !== null;
66
- }
67
- /**
68
- * Scan app directory using Rust native code
69
- * Returns null if native module is not available
70
- */
71
- function scanAppNative(appDir) {
72
- const native = loadNativeModule();
73
- if (!native)
74
- return null;
75
- try {
76
- const startTime = performance.now();
77
- const result = native.rscScanApp(appDir);
78
- const scanTime = performance.now() - startTime;
79
- if (process.env.VISTA_DEBUG) {
80
- console.log(`🦀 Native scan completed in ${scanTime.toFixed(2)}ms (${result.totalFiles} files)`);
81
- }
82
- return result;
83
- }
84
- catch (e) {
85
- console.error('Native scan failed:', e);
86
- return null;
87
- }
88
- }
89
- /**
90
- * Generate client manifest using Rust native code
91
- */
92
- function generateClientManifestNative(appDir, buildId) {
93
- const native = loadNativeModule();
94
- if (!native)
95
- return null;
96
- try {
97
- return native.rscGenerateClientManifest(appDir, buildId);
98
- }
99
- catch (e) {
100
- console.error('Native client manifest generation failed:', e);
101
- return null;
102
- }
103
- }
104
- /**
105
- * Generate client manifest from an explicit project root plus `app/`
106
- */
107
- function generateClientManifestForProjectNative(cwd, appDir, buildId) {
108
- const native = loadNativeModule();
109
- if (!native || typeof native.rscGenerateClientManifestForProject !== 'function') {
110
- return null;
111
- }
112
- try {
113
- return native.rscGenerateClientManifestForProject(cwd, appDir, buildId);
114
- }
115
- catch (e) {
116
- console.error('Native project client manifest generation failed:', e);
117
- return null;
118
- }
119
- }
120
- /**
121
- * Discover project-level client scan roots using Rust native code
122
- */
123
- function discoverProjectClientRootsNative(cwd) {
124
- const native = loadNativeModule();
125
- if (!native?.rscDiscoverProjectClientRoots)
126
- return null;
127
- try {
128
- return native.rscDiscoverProjectClientRoots(cwd);
129
- }
130
- catch (e) {
131
- console.error('Native client-root discovery failed:', e);
132
- return null;
133
- }
134
- }
135
- /**
136
- * Generate server manifest using Rust native code
137
- */
138
- function generateServerManifestNative(appDir, buildId) {
139
- const native = loadNativeModule();
140
- if (!native)
141
- return null;
142
- try {
143
- return native.rscGenerateServerManifest(appDir, buildId);
144
- }
145
- catch (e) {
146
- console.error('Native server manifest generation failed:', e);
147
- return null;
148
- }
149
- }
150
- /**
151
- * Generate unique mount ID for client component
152
- */
153
- function generateMountIdNative() {
154
- const native = loadNativeModule();
155
- if (!native)
156
- return null;
157
- return native.rscGenerateMountId();
158
- }
159
- /**
160
- * Reset mount ID counter (call at start of each request)
161
- */
162
- function resetMountCounterNative() {
163
- const native = loadNativeModule();
164
- if (!native)
165
- return false;
166
- native.rscResetMountCounter();
167
- return true;
168
- }
169
- /**
170
- * Convert NAPI scan result to internal format
171
- */
172
- function convertScanResult(result) {
173
- return {
174
- clientComponents: result.clientComponents.map((c) => ({
175
- absolutePath: c.absolutePath,
176
- relativePath: c.relativePath,
177
- isClient: c.isClient,
178
- directiveLine: c.directiveLine,
179
- componentType: c.componentType,
180
- exports: c.exports,
181
- clientHooksUsed: c.clientHooksUsed,
182
- hasMetadata: c.hasMetadata,
183
- hasGenerateMetadata: c.hasGenerateMetadata,
184
- })),
185
- serverComponents: result.serverComponents.map((c) => ({
186
- absolutePath: c.absolutePath,
187
- relativePath: c.relativePath,
188
- isClient: false,
189
- directiveLine: 0,
190
- componentType: c.componentType,
191
- exports: c.exports,
192
- clientHooksUsed: [],
193
- hasMetadata: c.hasMetadata,
194
- hasGenerateMetadata: c.hasGenerateMetadata,
195
- })),
196
- pages: result.pages,
197
- layouts: result.layouts,
198
- apiRoutes: result.apiRoutes,
199
- errors: result.errors,
200
- totalFiles: result.totalFiles,
201
- scanTimeMs: result.scanTimeMs,
202
- };
203
- }
1
+ "use strict";
2
+ /**
3
+ * Vista RSC Native Scanner
4
+ *
5
+ * Uses Rust-powered native bindings for blazing fast component scanning.
6
+ * Falls back to TypeScript implementation if native module unavailable.
7
+ */
8
+ var __importDefault = (this && this.__importDefault) || function (mod) {
9
+ return (mod && mod.__esModule) ? mod : { "default": mod };
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.isNativeAvailable = isNativeAvailable;
13
+ exports.scanAppNative = scanAppNative;
14
+ exports.generateClientManifestNative = generateClientManifestNative;
15
+ exports.generateClientManifestForProjectNative = generateClientManifestForProjectNative;
16
+ exports.discoverProjectClientRootsNative = discoverProjectClientRootsNative;
17
+ exports.generateServerManifestNative = generateServerManifestNative;
18
+ exports.generateMountIdNative = generateMountIdNative;
19
+ exports.resetMountCounterNative = resetMountCounterNative;
20
+ exports.convertScanResult = convertScanResult;
21
+ const path_1 = __importDefault(require("path"));
22
+ let nativeModule = null;
23
+ let nativeLoadError = null;
24
+ /**
25
+ * Try to load the native Rust module
26
+ */
27
+ function loadNativeModule() {
28
+ if (nativeModule !== null)
29
+ return nativeModule;
30
+ if (nativeLoadError !== null)
31
+ return null;
32
+ // Try multiple paths since we might be running from src or dist
33
+ const possiblePaths = [
34
+ // From compiled dist/build/rsc/native-scanner.js
35
+ path_1.default.resolve(__dirname, '../../../../../crates/vista-napi'),
36
+ // From source src/build/rsc/native-scanner.ts
37
+ path_1.default.resolve(__dirname, '../../../../crates/vista-napi'),
38
+ // From workspace root
39
+ path_1.default.resolve(process.cwd(), '../crates/vista-napi'),
40
+ // Try @aspect-build/vista-napi as npm package
41
+ '@aspect-build/vista-napi',
42
+ ];
43
+ const _debug = !!process.env.VISTA_DEBUG;
44
+ for (const modulePath of possiblePaths) {
45
+ try {
46
+ // eslint-disable-next-line @typescript-eslint/no-require-imports
47
+ nativeModule = require(modulePath);
48
+ if (_debug)
49
+ console.log('[Vista JS RSC] Using Rust-powered scanner');
50
+ return nativeModule;
51
+ }
52
+ catch {
53
+ // Continue trying other paths
54
+ }
55
+ }
56
+ nativeLoadError = new Error('Native module not found');
57
+ if (_debug)
58
+ console.warn('⚠ Native module unavailable, using TypeScript fallback');
59
+ return null;
60
+ }
61
+ /**
62
+ * Check if native module is available
63
+ */
64
+ function isNativeAvailable() {
65
+ return loadNativeModule() !== null;
66
+ }
67
+ /**
68
+ * Scan app directory using Rust native code
69
+ * Returns null if native module is not available
70
+ */
71
+ function scanAppNative(appDir) {
72
+ const native = loadNativeModule();
73
+ if (!native)
74
+ return null;
75
+ try {
76
+ const startTime = performance.now();
77
+ const result = native.rscScanApp(appDir);
78
+ const scanTime = performance.now() - startTime;
79
+ if (process.env.VISTA_DEBUG) {
80
+ console.log(`🦀 Native scan completed in ${scanTime.toFixed(2)}ms (${result.totalFiles} files)`);
81
+ }
82
+ return result;
83
+ }
84
+ catch (e) {
85
+ console.error('Native scan failed:', e);
86
+ return null;
87
+ }
88
+ }
89
+ /**
90
+ * Generate client manifest using Rust native code
91
+ */
92
+ function generateClientManifestNative(appDir, buildId) {
93
+ const native = loadNativeModule();
94
+ if (!native)
95
+ return null;
96
+ try {
97
+ return native.rscGenerateClientManifest(appDir, buildId);
98
+ }
99
+ catch (e) {
100
+ console.error('Native client manifest generation failed:', e);
101
+ return null;
102
+ }
103
+ }
104
+ /**
105
+ * Generate client manifest from an explicit project root plus `app/`
106
+ */
107
+ function generateClientManifestForProjectNative(cwd, appDir, buildId) {
108
+ const native = loadNativeModule();
109
+ if (!native || typeof native.rscGenerateClientManifestForProject !== 'function') {
110
+ return null;
111
+ }
112
+ try {
113
+ return native.rscGenerateClientManifestForProject(cwd, appDir, buildId);
114
+ }
115
+ catch (e) {
116
+ console.error('Native project client manifest generation failed:', e);
117
+ return null;
118
+ }
119
+ }
120
+ /**
121
+ * Discover project-level client scan roots using Rust native code
122
+ */
123
+ function discoverProjectClientRootsNative(cwd) {
124
+ const native = loadNativeModule();
125
+ if (!native?.rscDiscoverProjectClientRoots)
126
+ return null;
127
+ try {
128
+ return native.rscDiscoverProjectClientRoots(cwd);
129
+ }
130
+ catch (e) {
131
+ console.error('Native client-root discovery failed:', e);
132
+ return null;
133
+ }
134
+ }
135
+ /**
136
+ * Generate server manifest using Rust native code
137
+ */
138
+ function generateServerManifestNative(appDir, buildId) {
139
+ const native = loadNativeModule();
140
+ if (!native)
141
+ return null;
142
+ try {
143
+ return native.rscGenerateServerManifest(appDir, buildId);
144
+ }
145
+ catch (e) {
146
+ console.error('Native server manifest generation failed:', e);
147
+ return null;
148
+ }
149
+ }
150
+ /**
151
+ * Generate unique mount ID for client component
152
+ */
153
+ function generateMountIdNative() {
154
+ const native = loadNativeModule();
155
+ if (!native)
156
+ return null;
157
+ return native.rscGenerateMountId();
158
+ }
159
+ /**
160
+ * Reset mount ID counter (call at start of each request)
161
+ */
162
+ function resetMountCounterNative() {
163
+ const native = loadNativeModule();
164
+ if (!native)
165
+ return false;
166
+ native.rscResetMountCounter();
167
+ return true;
168
+ }
169
+ /**
170
+ * Convert NAPI scan result to internal format
171
+ */
172
+ function convertScanResult(result) {
173
+ return {
174
+ clientComponents: result.clientComponents.map((c) => ({
175
+ absolutePath: c.absolutePath,
176
+ relativePath: c.relativePath,
177
+ isClient: c.isClient,
178
+ directiveLine: c.directiveLine,
179
+ componentType: c.componentType,
180
+ exports: c.exports,
181
+ clientHooksUsed: c.clientHooksUsed,
182
+ hasMetadata: c.hasMetadata,
183
+ hasGenerateMetadata: c.hasGenerateMetadata,
184
+ })),
185
+ serverComponents: result.serverComponents.map((c) => ({
186
+ absolutePath: c.absolutePath,
187
+ relativePath: c.relativePath,
188
+ isClient: false,
189
+ directiveLine: 0,
190
+ componentType: c.componentType,
191
+ exports: c.exports,
192
+ clientHooksUsed: [],
193
+ hasMetadata: c.hasMetadata,
194
+ hasGenerateMetadata: c.hasGenerateMetadata,
195
+ })),
196
+ pages: result.pages,
197
+ layouts: result.layouts,
198
+ apiRoutes: result.apiRoutes,
199
+ errors: result.errors,
200
+ totalFiles: result.totalFiles,
201
+ scanTimeMs: result.scanTimeMs,
202
+ };
203
+ }