@vistagenic/vista 0.2.16 → 0.3.2

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 (153) hide show
  1. package/bin/vista.js +184 -177
  2. package/dist/ai/agent.d.ts +37 -0
  3. package/dist/ai/agent.js +385 -0
  4. package/dist/ai/embeddings.d.ts +11 -0
  5. package/dist/ai/embeddings.js +71 -0
  6. package/dist/ai/index.d.ts +10 -0
  7. package/dist/ai/index.js +26 -0
  8. package/dist/ai/memory.d.ts +16 -0
  9. package/dist/ai/memory.js +39 -0
  10. package/dist/ai/observability.d.ts +21 -0
  11. package/dist/ai/observability.js +69 -0
  12. package/dist/ai/providers/anthropic.d.ts +2 -0
  13. package/dist/ai/providers/anthropic.js +190 -0
  14. package/dist/ai/providers/base.d.ts +7 -0
  15. package/dist/ai/providers/base.js +85 -0
  16. package/dist/ai/providers/gemini.d.ts +2 -0
  17. package/dist/ai/providers/gemini.js +194 -0
  18. package/dist/ai/providers/index.d.ts +5 -0
  19. package/dist/ai/providers/index.js +21 -0
  20. package/dist/ai/providers/mock.d.ts +8 -0
  21. package/dist/ai/providers/mock.js +77 -0
  22. package/dist/ai/providers/openai.d.ts +2 -0
  23. package/dist/ai/providers/openai.js +211 -0
  24. package/dist/ai/rag.d.ts +35 -0
  25. package/dist/ai/rag.js +110 -0
  26. package/dist/ai/react/index.d.ts +1 -0
  27. package/dist/ai/react/index.js +17 -0
  28. package/dist/ai/react/react-server.d.ts +1 -0
  29. package/dist/ai/react/react-server.js +17 -0
  30. package/dist/ai/react/use-agent.d.ts +23 -0
  31. package/dist/ai/react/use-agent.js +138 -0
  32. package/dist/ai/stream.d.ts +24 -0
  33. package/dist/ai/stream.js +109 -0
  34. package/dist/ai/tool.d.ts +11 -0
  35. package/dist/ai/tool.js +47 -0
  36. package/dist/ai/types.d.ts +117 -0
  37. package/dist/ai/types.js +5 -0
  38. package/dist/auth/core.d.ts +140 -0
  39. package/dist/auth/core.js +165 -0
  40. package/dist/auth/index.d.ts +20 -8
  41. package/dist/auth/index.js +369 -16
  42. package/dist/auth/react-server.d.ts +1 -0
  43. package/dist/auth/react-server.js +10 -0
  44. package/dist/auth/react.d.ts +18 -0
  45. package/dist/auth/react.js +71 -0
  46. package/dist/bin/build-rsc.js +602 -604
  47. package/dist/bin/build.js +389 -388
  48. package/dist/bin/deploy-output.d.ts +2 -7
  49. package/dist/bin/deploy-output.js +3 -76
  50. package/dist/bin/deploy.d.ts +7 -0
  51. package/dist/bin/deploy.js +102 -0
  52. package/dist/bin/dev-error-overlay-snippet.js +778 -552
  53. package/dist/bin/devtools-indicator-snippet.js +387 -387
  54. package/dist/bin/generate.js +510 -248
  55. package/dist/build/manifest.d.ts +169 -139
  56. package/dist/build/manifest.js +423 -367
  57. package/dist/build/rsc/client-manifest.d.ts +62 -52
  58. package/dist/build/rsc/client-manifest.js +295 -193
  59. package/dist/build/rsc/client-reference-plugin.d.ts +37 -37
  60. package/dist/build/rsc/client-reference-plugin.js +160 -160
  61. package/dist/build/rsc/native-scanner.d.ts +135 -123
  62. package/dist/build/rsc/native-scanner.js +203 -170
  63. package/dist/build/rsc/react-client-reference-manifest.d.ts +28 -22
  64. package/dist/build/rsc/react-client-reference-manifest.js +240 -219
  65. package/dist/build/rsc/rsc-renderer.d.ts +99 -99
  66. package/dist/build/rsc/rsc-renderer.js +263 -263
  67. package/dist/build/rsc/server-component-loader.d.ts +19 -19
  68. package/dist/build/rsc/server-component-loader.js +91 -91
  69. package/dist/build/rsc/server-manifest.d.ts +17 -0
  70. package/dist/build/rsc/server-manifest.js +20 -0
  71. package/dist/build/standalone.js +337 -334
  72. package/dist/build/webpack/plugins/vista-flight-plugin.js +5 -5
  73. package/dist/client/dynamic.react-server.d.ts +2 -0
  74. package/dist/client/dynamic.react-server.js +23 -0
  75. package/dist/client/link.react-server.d.ts +2 -0
  76. package/dist/client/link.react-server.js +11 -0
  77. package/dist/client/navigation.react-server.d.ts +1 -0
  78. package/dist/client/navigation.react-server.js +17 -0
  79. package/dist/client/router.react-server.d.ts +1 -0
  80. package/dist/client/router.react-server.js +17 -0
  81. package/dist/client/rsc-router.react-server.d.ts +1 -0
  82. package/dist/client/rsc-router.react-server.js +17 -0
  83. package/dist/client/script.react-server.d.ts +2 -0
  84. package/dist/client/script.react-server.js +23 -0
  85. package/dist/components/client-island.d.ts +34 -34
  86. package/dist/components/client-island.js +75 -75
  87. package/dist/config.d.ts +17 -0
  88. package/dist/config.js +60 -1
  89. package/dist/deploy/adapters/cloudflare.d.ts +2 -0
  90. package/dist/deploy/adapters/cloudflare.js +124 -0
  91. package/dist/deploy/adapters/docker.d.ts +2 -0
  92. package/dist/deploy/adapters/docker.js +112 -0
  93. package/dist/deploy/adapters/index.d.ts +15 -0
  94. package/dist/deploy/adapters/index.js +24 -0
  95. package/dist/deploy/adapters/netlify.d.ts +2 -0
  96. package/dist/deploy/adapters/netlify.js +115 -0
  97. package/dist/deploy/adapters/render.d.ts +2 -0
  98. package/dist/deploy/adapters/render.js +95 -0
  99. package/dist/deploy/adapters/vercel.d.ts +7 -0
  100. package/dist/deploy/adapters/vercel.js +164 -0
  101. package/dist/deploy/cli-runner.d.ts +8 -0
  102. package/dist/deploy/cli-runner.js +58 -0
  103. package/dist/deploy/detect.d.ts +6 -0
  104. package/dist/deploy/detect.js +77 -0
  105. package/dist/deploy/index.d.ts +24 -0
  106. package/dist/deploy/index.js +112 -0
  107. package/dist/deploy/preflight.d.ts +8 -0
  108. package/dist/deploy/preflight.js +80 -0
  109. package/dist/deploy/types.d.ts +48 -0
  110. package/dist/deploy/types.js +2 -0
  111. package/dist/deploy/utils.d.ts +18 -0
  112. package/dist/deploy/utils.js +70 -0
  113. package/dist/dev-error.d.ts +14 -0
  114. package/dist/dev-error.js +1763 -705
  115. package/dist/index.d.ts +23 -21
  116. package/dist/index.js +61 -57
  117. package/dist/server/cookie-parse.d.ts +4 -0
  118. package/dist/server/cookie-parse.js +14 -0
  119. package/dist/server/engine.js +7 -26
  120. package/dist/server/index.d.ts +109 -102
  121. package/dist/server/index.js +315 -286
  122. package/dist/server/middleware-runner.d.ts +125 -57
  123. package/dist/server/middleware-runner.js +615 -218
  124. package/dist/server/middleware-security.d.ts +36 -0
  125. package/dist/server/middleware-security.js +183 -0
  126. package/dist/server/module-compile-hook.js +695 -662
  127. package/dist/server/route-handler-registry.d.ts +65 -0
  128. package/dist/server/route-handler-registry.js +195 -0
  129. package/dist/server/route-patterns.d.ts +67 -0
  130. package/dist/server/route-patterns.js +186 -0
  131. package/dist/server/rsc-engine.js +75 -92
  132. package/dist/server/rsc-module-system.d.ts +33 -33
  133. package/dist/server/rsc-module-system.js +87 -87
  134. package/dist/server/rsc-upstream.js +892 -888
  135. package/dist/server/static-generator.js +10 -10
  136. package/dist/server/typed-api-runtime.d.ts +18 -0
  137. package/dist/server/typed-api-runtime.js +635 -507
  138. package/dist/server/vista-import-map.js +134 -123
  139. package/dist/stack/index.d.ts +34 -32
  140. package/dist/stack/index.js +49 -45
  141. package/dist/stack/server/caller.d.ts +13 -0
  142. package/dist/stack/server/caller.js +42 -0
  143. package/dist/stack/server/executor.d.ts +40 -36
  144. package/dist/stack/server/executor.js +222 -174
  145. package/dist/stack/server/index.d.ts +11 -10
  146. package/dist/stack/server/index.js +24 -23
  147. package/dist/stack/server/procedure.d.ts +20 -18
  148. package/dist/stack/server/procedure.js +66 -58
  149. package/dist/stack/server/types.d.ts +113 -100
  150. package/dist/theme/react-server.d.ts +10 -0
  151. package/dist/theme/react-server.js +16 -0
  152. package/package.json +28 -3
  153. package/LICENSE +0 -21
@@ -1,52 +1,62 @@
1
- /**
2
- * Client Component Manifest Generator
3
- *
4
- * Scans the app directory and builds a manifest of all Client Components.
5
- * Client components are those with 'use client' directive.
6
- *
7
- * The manifest maps component paths to their chunk names for client-side loading.
8
- */
9
- export interface ClientComponentEntry {
10
- /** Unique ID for this component */
11
- id: string;
12
- /** Relative path from app directory */
13
- path: string;
14
- /** Absolute file path */
15
- absolutePath: string;
16
- /** Generated chunk name */
17
- chunkName: string;
18
- /** Exported names from this module */
19
- exports: string[];
20
- /** Is async/lazy loaded */
21
- async: boolean;
22
- }
23
- export interface ClientManifest {
24
- /** Build ID for cache busting */
25
- buildId: string;
26
- /** Map of module ID to client component info */
27
- clientModules: Record<string, ClientComponentEntry>;
28
- /** Map of module path to module ID (for lookups) */
29
- pathToId: Record<string, string>;
30
- /** SSR module mapping (server paths to client chunks) */
31
- ssrModuleMapping: Record<string, string>;
32
- }
33
- /**
34
- * Generate the client component manifest
35
- */
36
- export declare function generateClientManifest(cwd: string, appDir: string): ClientManifest;
37
- export declare function generateClientManifestWithRoots(cwd: string, appDir: string, additionalRoots?: Array<{
38
- dir: string;
39
- prefix?: string;
40
- }>): ClientManifest;
41
- /**
42
- * Get client component info by module ID
43
- */
44
- export declare function getClientComponent(manifest: ClientManifest, moduleId: string): ClientComponentEntry | undefined;
45
- /**
46
- * Get client component by file path
47
- */
48
- export declare function getClientComponentByPath(manifest: ClientManifest, filePath: string): ClientComponentEntry | undefined;
49
- /**
50
- * Check if a path is a client component
51
- */
52
- export declare function isClientComponentPath(manifest: ClientManifest, filePath: string): boolean;
1
+ /**
2
+ * Client Component Manifest Generator
3
+ *
4
+ * Scans the app directory and builds a manifest of all Client Components.
5
+ * Client components are those with 'use client' directive.
6
+ *
7
+ * The manifest maps component paths to their chunk names for client-side loading.
8
+ */
9
+ /**
10
+ * Top-level app directories that may contain `'use client'` modules.
11
+ * Discovery is directory membership, not the import graph, so `utils/`,
12
+ * `lib/`, and `src/` have to be scanned explicitly or they never enter
13
+ * the React Client Manifest.
14
+ */
15
+ export declare function discoverProjectClientRoots(cwd: string): Array<{
16
+ dir: string;
17
+ prefix: string;
18
+ }>;
19
+ export interface ClientComponentEntry {
20
+ /** Unique ID for this component */
21
+ id: string;
22
+ /** Relative path from app directory */
23
+ path: string;
24
+ /** Absolute file path */
25
+ absolutePath: string;
26
+ /** Generated chunk name */
27
+ chunkName: string;
28
+ /** Exported names from this module */
29
+ exports: string[];
30
+ /** Is async/lazy loaded */
31
+ async: boolean;
32
+ }
33
+ export interface ClientManifest {
34
+ /** Build ID for cache busting */
35
+ buildId: string;
36
+ /** Map of module ID to client component info */
37
+ clientModules: Record<string, ClientComponentEntry>;
38
+ /** Map of module path to module ID (for lookups) */
39
+ pathToId: Record<string, string>;
40
+ /** SSR module mapping (server paths to client chunks) */
41
+ ssrModuleMapping: Record<string, string>;
42
+ }
43
+ /**
44
+ * Generate the client component manifest
45
+ */
46
+ export declare function generateClientManifest(cwd: string, appDir: string): ClientManifest;
47
+ export declare function generateClientManifestWithRoots(cwd: string, appDir: string, additionalRoots?: Array<{
48
+ dir: string;
49
+ prefix?: string;
50
+ }>): ClientManifest;
51
+ /**
52
+ * Get client component info by module ID
53
+ */
54
+ export declare function getClientComponent(manifest: ClientManifest, moduleId: string): ClientComponentEntry | undefined;
55
+ /**
56
+ * Get client component by file path
57
+ */
58
+ export declare function getClientComponentByPath(manifest: ClientManifest, filePath: string): ClientComponentEntry | undefined;
59
+ /**
60
+ * Check if a path is a client component
61
+ */
62
+ export declare function isClientComponentPath(manifest: ClientManifest, filePath: string): boolean;
@@ -1,193 +1,295 @@
1
- "use strict";
2
- /**
3
- * Client Component Manifest Generator
4
- *
5
- * Scans the app directory and builds a manifest of all Client Components.
6
- * Client components are those with 'use client' directive.
7
- *
8
- * The manifest maps component paths to their chunk names for client-side loading.
9
- */
10
- var __importDefault = (this && this.__importDefault) || function (mod) {
11
- return (mod && mod.__esModule) ? mod : { "default": mod };
12
- };
13
- Object.defineProperty(exports, "__esModule", { value: true });
14
- exports.generateClientManifest = generateClientManifest;
15
- exports.generateClientManifestWithRoots = generateClientManifestWithRoots;
16
- exports.getClientComponent = getClientComponent;
17
- exports.getClientComponentByPath = getClientComponentByPath;
18
- exports.isClientComponentPath = isClientComponentPath;
19
- const fs_1 = __importDefault(require("fs"));
20
- const path_1 = __importDefault(require("path"));
21
- const component_identity_1 = require("./component-identity");
22
- const constants_1 = require("../../constants");
23
- // Try to load Rust NAPI bindings
24
- let rustNative = null;
25
- try {
26
- const possiblePaths = [
27
- path_1.default.resolve(__dirname, '../../../../../crates/vista-napi'),
28
- path_1.default.resolve(__dirname, '../../../../crates/vista-napi'),
29
- ];
30
- for (const p of possiblePaths) {
31
- try {
32
- rustNative = require(p);
33
- break;
34
- }
35
- catch (e) {
36
- // Try next
37
- }
38
- }
39
- }
40
- catch (e) {
41
- // Fallback to JS
42
- }
43
- /**
44
- * Check if source has 'use client' directive
45
- */
46
- function hasClientDirective(source) {
47
- const trimmed = source.trimStart();
48
- if (trimmed.startsWith("'use client'") || trimmed.startsWith('"use client"')) {
49
- return true;
50
- }
51
- if (rustNative?.isClientComponent) {
52
- return rustNative.isClientComponent(source);
53
- }
54
- return false;
55
- }
56
- /**
57
- * Extract export names from source (simple regex approach)
58
- */
59
- function extractExports(source) {
60
- const exports = [];
61
- // Default export
62
- if (/export\s+default\s+/.test(source)) {
63
- exports.push('default');
64
- }
65
- // Named exports: export function Name, export const Name, export class Name
66
- const namedExportRegex = /export\s+(?:async\s+)?(?:function|const|let|var|class)\s+([A-Z][a-zA-Z0-9_]*)/g;
67
- let match;
68
- while ((match = namedExportRegex.exec(source)) !== null) {
69
- exports.push(match[1]);
70
- }
71
- // Export { Name1, Name2 }
72
- const reExportRegex = /export\s+\{([^}]+)\}/g;
73
- while ((match = reExportRegex.exec(source)) !== null) {
74
- const names = match[1]
75
- .split(',')
76
- .map((n) => n
77
- .trim()
78
- .split(/\s+as\s+/)
79
- .pop()
80
- ?.trim())
81
- .filter(Boolean);
82
- exports.push(...names);
83
- }
84
- return [...new Set(exports)];
85
- }
86
- /**
87
- * Scan directory recursively for client components
88
- */
89
- function scanForClientComponents(dir, scanRoot, components, pathPrefix = '') {
90
- if (!fs_1.default.existsSync(dir))
91
- return;
92
- const items = fs_1.default.readdirSync(dir, { withFileTypes: true });
93
- for (const item of items) {
94
- const fullPath = path_1.default.join(dir, item.name);
95
- if (item.isDirectory()) {
96
- if (!item.name.startsWith('.') && item.name !== 'node_modules') {
97
- scanForClientComponents(fullPath, scanRoot, components, pathPrefix);
98
- }
99
- }
100
- else if (item.isFile()) {
101
- const ext = path_1.default.extname(item.name);
102
- if (!['.tsx', '.ts', '.jsx', '.js'].includes(ext))
103
- continue;
104
- try {
105
- const source = fs_1.default.readFileSync(fullPath, 'utf-8');
106
- if (hasClientDirective(source)) {
107
- const relativePathBase = (0, component_identity_1.relativeComponentPath)(scanRoot, fullPath);
108
- const relativePath = pathPrefix ? `${pathPrefix}${relativePathBase}` : relativePathBase;
109
- const moduleId = (0, component_identity_1.createComponentId)('client', relativePath);
110
- components.push({
111
- id: moduleId,
112
- path: relativePath,
113
- absolutePath: fullPath,
114
- chunkName: (0, component_identity_1.createChunkName)(relativePath),
115
- exports: extractExports(source),
116
- async: false,
117
- });
118
- }
119
- }
120
- catch (e) {
121
- console.warn(`[Vista RSC] Failed to read ${fullPath}:`, e);
122
- }
123
- }
124
- }
125
- }
126
- /**
127
- * Generate the client component manifest
128
- */
129
- function generateClientManifest(cwd, appDir) {
130
- return generateClientManifestWithRoots(cwd, appDir);
131
- }
132
- function generateClientManifestWithRoots(cwd, appDir, additionalRoots = []) {
133
- const components = [];
134
- scanForClientComponents(appDir, appDir, components);
135
- for (const root of additionalRoots) {
136
- if (!fs_1.default.existsSync(root.dir))
137
- continue;
138
- scanForClientComponents(root.dir, root.dir, components, root.prefix || '');
139
- }
140
- const clientModules = {};
141
- const pathToId = {};
142
- const ssrModuleMapping = {};
143
- for (const component of components) {
144
- clientModules[component.id] = component;
145
- const normalizedRelativePath = (0, component_identity_1.normalizeComponentPath)(component.path);
146
- const normalizedAbsolutePath = (0, component_identity_1.normalizeComponentPath)(component.absolutePath);
147
- pathToId[component.path] = component.id;
148
- pathToId[normalizedRelativePath] = component.id;
149
- pathToId[component.absolutePath] = component.id;
150
- pathToId[normalizedAbsolutePath] = component.id;
151
- // Map server path to client chunk for SSR
152
- ssrModuleMapping[component.absolutePath] = `${constants_1.STATIC_CHUNKS_PATH}${component.chunkName}.js`;
153
- ssrModuleMapping[normalizedAbsolutePath] = `${constants_1.STATIC_CHUNKS_PATH}${component.chunkName}.js`;
154
- }
155
- // Get or generate build ID
156
- const buildIdPath = path_1.default.join(cwd, constants_1.BUILD_DIR, 'BUILD_ID');
157
- let buildId = 'dev';
158
- try {
159
- if (fs_1.default.existsSync(buildIdPath)) {
160
- buildId = fs_1.default.readFileSync(buildIdPath, 'utf-8').trim();
161
- }
162
- }
163
- catch (e) {
164
- // Use dev
165
- }
166
- return {
167
- buildId,
168
- clientModules,
169
- pathToId,
170
- ssrModuleMapping,
171
- };
172
- }
173
- /**
174
- * Get client component info by module ID
175
- */
176
- function getClientComponent(manifest, moduleId) {
177
- return manifest.clientModules[moduleId];
178
- }
179
- /**
180
- * Get client component by file path
181
- */
182
- function getClientComponentByPath(manifest, filePath) {
183
- const moduleId = manifest.pathToId[filePath];
184
- if (!moduleId)
185
- return undefined;
186
- return manifest.clientModules[moduleId];
187
- }
188
- /**
189
- * Check if a path is a client component
190
- */
191
- function isClientComponentPath(manifest, filePath) {
192
- return filePath in manifest.pathToId;
193
- }
1
+ "use strict";
2
+ /**
3
+ * Client Component Manifest Generator
4
+ *
5
+ * Scans the app directory and builds a manifest of all Client Components.
6
+ * Client components are those with 'use client' directive.
7
+ *
8
+ * The manifest maps component paths to their chunk names for client-side loading.
9
+ */
10
+ var __importDefault = (this && this.__importDefault) || function (mod) {
11
+ return (mod && mod.__esModule) ? mod : { "default": mod };
12
+ };
13
+ Object.defineProperty(exports, "__esModule", { value: true });
14
+ exports.discoverProjectClientRoots = discoverProjectClientRoots;
15
+ exports.generateClientManifest = generateClientManifest;
16
+ exports.generateClientManifestWithRoots = generateClientManifestWithRoots;
17
+ exports.getClientComponent = getClientComponent;
18
+ exports.getClientComponentByPath = getClientComponentByPath;
19
+ exports.isClientComponentPath = isClientComponentPath;
20
+ const fs_1 = __importDefault(require("fs"));
21
+ const path_1 = __importDefault(require("path"));
22
+ const component_identity_1 = require("./component-identity");
23
+ const constants_1 = require("../../constants");
24
+ const native_scanner_1 = require("./native-scanner");
25
+ const PROJECT_CLIENT_SCAN_SKIP = new Set([
26
+ 'node_modules',
27
+ '.vista',
28
+ '.flash',
29
+ 'dist',
30
+ 'public',
31
+ 'coverage',
32
+ 'build',
33
+ 'out',
34
+ ]);
35
+ /**
36
+ * Top-level app directories that may contain `'use client'` modules.
37
+ * Discovery is directory membership, not the import graph, so `utils/`,
38
+ * `lib/`, and `src/` have to be scanned explicitly or they never enter
39
+ * the React Client Manifest.
40
+ */
41
+ function discoverProjectClientRoots(cwd) {
42
+ const roots = [];
43
+ if (!fs_1.default.existsSync(cwd)) {
44
+ return roots;
45
+ }
46
+ let entries;
47
+ try {
48
+ entries = fs_1.default.readdirSync(cwd, { withFileTypes: true });
49
+ }
50
+ catch {
51
+ return roots;
52
+ }
53
+ for (const entry of entries) {
54
+ if (!entry.isDirectory())
55
+ continue;
56
+ if (entry.name.startsWith('.'))
57
+ continue;
58
+ if (PROJECT_CLIENT_SCAN_SKIP.has(entry.name))
59
+ continue;
60
+ roots.push({
61
+ dir: path_1.default.join(cwd, entry.name),
62
+ prefix: `${entry.name.replace(/\\/g, '/')}/`,
63
+ });
64
+ }
65
+ return roots;
66
+ }
67
+ // Try to load Rust NAPI bindings
68
+ let rustNative = null;
69
+ try {
70
+ const possiblePaths = [
71
+ path_1.default.resolve(__dirname, '../../../../../crates/vista-napi'),
72
+ path_1.default.resolve(__dirname, '../../../../crates/vista-napi'),
73
+ ];
74
+ for (const p of possiblePaths) {
75
+ try {
76
+ rustNative = require(p);
77
+ break;
78
+ }
79
+ catch (e) {
80
+ // Try next
81
+ }
82
+ }
83
+ }
84
+ catch (e) {
85
+ // Fallback to JS
86
+ }
87
+ /**
88
+ * Check if source has 'use client' directive
89
+ */
90
+ function hasClientDirective(source) {
91
+ const trimmed = source.trimStart();
92
+ if (trimmed.startsWith("'use client'") || trimmed.startsWith('"use client"')) {
93
+ return true;
94
+ }
95
+ if (rustNative?.isClientComponent) {
96
+ return rustNative.isClientComponent(source);
97
+ }
98
+ return false;
99
+ }
100
+ /**
101
+ * Extract export names from source (simple regex approach)
102
+ */
103
+ function extractExports(source) {
104
+ const exports = [];
105
+ // Default export
106
+ if (/export\s+default\s+/.test(source)) {
107
+ exports.push('default');
108
+ }
109
+ // Named exports: export function Name, export const Name, export class Name
110
+ const namedExportRegex = /export\s+(?:async\s+)?(?:function|const|let|var|class)\s+([A-Z][a-zA-Z0-9_]*)/g;
111
+ let match;
112
+ while ((match = namedExportRegex.exec(source)) !== null) {
113
+ exports.push(match[1]);
114
+ }
115
+ // Export { Name1, Name2 }
116
+ const reExportRegex = /export\s+\{([^}]+)\}/g;
117
+ while ((match = reExportRegex.exec(source)) !== null) {
118
+ const names = match[1]
119
+ .split(',')
120
+ .map((n) => n
121
+ .trim()
122
+ .split(/\s+as\s+/)
123
+ .pop()
124
+ ?.trim())
125
+ .filter(Boolean);
126
+ exports.push(...names);
127
+ }
128
+ return [...new Set(exports)];
129
+ }
130
+ function isSameOrInside(target, ancestor) {
131
+ const resolvedTarget = path_1.default.resolve(target);
132
+ const resolvedAncestor = path_1.default.resolve(ancestor);
133
+ if (resolvedTarget === resolvedAncestor)
134
+ return true;
135
+ const prefix = resolvedAncestor.endsWith(path_1.default.sep)
136
+ ? resolvedAncestor
137
+ : `${resolvedAncestor}${path_1.default.sep}`;
138
+ return resolvedTarget.startsWith(prefix);
139
+ }
140
+ function additionalRootsMatchDiscovery(cwd, appDir, additionalRoots) {
141
+ const discovered = discoverProjectClientRoots(cwd).filter((root) => path_1.default.resolve(root.dir) !== path_1.default.resolve(appDir));
142
+ if (additionalRoots.length !== discovered.length)
143
+ return false;
144
+ const extra = new Set(additionalRoots.map((root) => path_1.default.resolve(root.dir)));
145
+ return discovered.every((root) => extra.has(path_1.default.resolve(root.dir)));
146
+ }
147
+ /**
148
+ * Scan directory recursively for client components
149
+ */
150
+ function scanForClientComponents(dir, scanRoot, components, pathPrefix = '', skipInside) {
151
+ if (!fs_1.default.existsSync(dir))
152
+ return;
153
+ if (skipInside && isSameOrInside(dir, skipInside))
154
+ return;
155
+ const items = fs_1.default.readdirSync(dir, { withFileTypes: true });
156
+ for (const item of items) {
157
+ const fullPath = path_1.default.join(dir, item.name);
158
+ if (item.isDirectory()) {
159
+ if (!item.name.startsWith('.') && item.name !== 'node_modules') {
160
+ scanForClientComponents(fullPath, scanRoot, components, pathPrefix, skipInside);
161
+ }
162
+ }
163
+ else if (item.isFile()) {
164
+ if (skipInside && isSameOrInside(fullPath, skipInside))
165
+ continue;
166
+ const ext = path_1.default.extname(item.name);
167
+ if (!['.tsx', '.ts', '.jsx', '.js'].includes(ext))
168
+ continue;
169
+ try {
170
+ const source = fs_1.default.readFileSync(fullPath, 'utf-8');
171
+ if (hasClientDirective(source)) {
172
+ const relativePathBase = (0, component_identity_1.relativeComponentPath)(scanRoot, fullPath);
173
+ const relativePath = pathPrefix ? `${pathPrefix}${relativePathBase}` : relativePathBase;
174
+ const moduleId = (0, component_identity_1.createComponentId)('client', relativePath);
175
+ components.push({
176
+ id: moduleId,
177
+ path: relativePath,
178
+ absolutePath: fullPath,
179
+ chunkName: (0, component_identity_1.createChunkName)(relativePath),
180
+ exports: extractExports(source),
181
+ async: false,
182
+ });
183
+ }
184
+ }
185
+ catch (e) {
186
+ console.warn(`[Vista RSC] Failed to read ${fullPath}:`, e);
187
+ }
188
+ }
189
+ }
190
+ }
191
+ /**
192
+ * Generate the client component manifest
193
+ */
194
+ function generateClientManifest(cwd, appDir) {
195
+ const additionalRoots = discoverProjectClientRoots(cwd).filter((root) => path_1.default.resolve(root.dir) !== path_1.default.resolve(appDir));
196
+ return generateClientManifestWithRoots(cwd, appDir, additionalRoots);
197
+ }
198
+ function readBuildId(cwd) {
199
+ const buildIdPath = path_1.default.join(cwd, constants_1.BUILD_DIR, 'BUILD_ID');
200
+ try {
201
+ if (fs_1.default.existsSync(buildIdPath)) {
202
+ return fs_1.default.readFileSync(buildIdPath, 'utf-8').trim();
203
+ }
204
+ }
205
+ catch {
206
+ // Use dev
207
+ }
208
+ return 'dev';
209
+ }
210
+ function nativeClientManifestToJs(native) {
211
+ const clientModules = {};
212
+ const pathToId = {};
213
+ const ssrModuleMapping = {};
214
+ for (const component of native.clientModules) {
215
+ const entry = {
216
+ id: component.id,
217
+ path: component.path,
218
+ absolutePath: component.absolutePath,
219
+ chunkName: component.chunkName,
220
+ exports: component.exports,
221
+ async: component.asyncLoad,
222
+ };
223
+ clientModules[component.id] = entry;
224
+ const normalizedRelativePath = (0, component_identity_1.normalizeComponentPath)(component.path);
225
+ const normalizedAbsolutePath = (0, component_identity_1.normalizeComponentPath)(component.absolutePath);
226
+ pathToId[component.path] = component.id;
227
+ pathToId[normalizedRelativePath] = component.id;
228
+ pathToId[component.absolutePath] = component.id;
229
+ pathToId[normalizedAbsolutePath] = component.id;
230
+ ssrModuleMapping[component.absolutePath] = `${constants_1.STATIC_CHUNKS_PATH}${component.chunkName}.js`;
231
+ ssrModuleMapping[normalizedAbsolutePath] = `${constants_1.STATIC_CHUNKS_PATH}${component.chunkName}.js`;
232
+ }
233
+ return {
234
+ buildId: native.buildId,
235
+ clientModules,
236
+ pathToId,
237
+ ssrModuleMapping,
238
+ };
239
+ }
240
+ function generateClientManifestWithRoots(cwd, appDir, additionalRoots = []) {
241
+ if (additionalRootsMatchDiscovery(cwd, appDir, additionalRoots)) {
242
+ const native = (0, native_scanner_1.generateClientManifestForProjectNative)(cwd, appDir, readBuildId(cwd));
243
+ if (native && Array.isArray(native.clientModules)) {
244
+ return nativeClientManifestToJs(native);
245
+ }
246
+ }
247
+ const components = [];
248
+ scanForClientComponents(appDir, appDir, components);
249
+ for (const root of additionalRoots) {
250
+ if (!fs_1.default.existsSync(root.dir))
251
+ continue;
252
+ scanForClientComponents(root.dir, root.dir, components, root.prefix || '', appDir);
253
+ }
254
+ const clientModules = {};
255
+ const pathToId = {};
256
+ const ssrModuleMapping = {};
257
+ for (const component of components) {
258
+ clientModules[component.id] = component;
259
+ const normalizedRelativePath = (0, component_identity_1.normalizeComponentPath)(component.path);
260
+ const normalizedAbsolutePath = (0, component_identity_1.normalizeComponentPath)(component.absolutePath);
261
+ pathToId[component.path] = component.id;
262
+ pathToId[normalizedRelativePath] = component.id;
263
+ pathToId[component.absolutePath] = component.id;
264
+ pathToId[normalizedAbsolutePath] = component.id;
265
+ ssrModuleMapping[component.absolutePath] = `${constants_1.STATIC_CHUNKS_PATH}${component.chunkName}.js`;
266
+ ssrModuleMapping[normalizedAbsolutePath] = `${constants_1.STATIC_CHUNKS_PATH}${component.chunkName}.js`;
267
+ }
268
+ return {
269
+ buildId: readBuildId(cwd),
270
+ clientModules,
271
+ pathToId,
272
+ ssrModuleMapping,
273
+ };
274
+ }
275
+ /**
276
+ * Get client component info by module ID
277
+ */
278
+ function getClientComponent(manifest, moduleId) {
279
+ return manifest.clientModules[moduleId];
280
+ }
281
+ /**
282
+ * Get client component by file path
283
+ */
284
+ function getClientComponentByPath(manifest, filePath) {
285
+ const moduleId = manifest.pathToId[filePath];
286
+ if (!moduleId)
287
+ return undefined;
288
+ return manifest.clientModules[moduleId];
289
+ }
290
+ /**
291
+ * Check if a path is a client component
292
+ */
293
+ function isClientComponentPath(manifest, filePath) {
294
+ return filePath in manifest.pathToId;
295
+ }