@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,219 +1,240 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.normalizeReactClientReferenceManifest = normalizeReactClientReferenceManifest;
7
- exports.normalizeReactServerConsumerManifest = normalizeReactServerConsumerManifest;
8
- const fs_1 = __importDefault(require("fs"));
9
- const url_1 = require("url");
10
- function extractExportNames(source) {
11
- const exports = new Set();
12
- if (/export\s+default\s+/.test(source)) {
13
- exports.add('default');
14
- }
15
- const namedExportRegex = /export\s+(?:async\s+)?(?:function|const|let|var|class)\s+([A-Za-z_$][\w$]*)/g;
16
- let match;
17
- while ((match = namedExportRegex.exec(source)) !== null) {
18
- exports.add(match[1]);
19
- }
20
- const reExportRegex = /export\s+\{([^}]+)\}/g;
21
- while ((match = reExportRegex.exec(source)) !== null) {
22
- const names = match[1]
23
- .split(',')
24
- .map((entry) => entry
25
- .trim()
26
- .split(/\s+as\s+/)
27
- .pop()
28
- ?.trim())
29
- .filter(Boolean);
30
- for (const name of names) {
31
- exports.add(name);
32
- }
33
- }
34
- const commonJsExportRegex = /exports\.([A-Za-z_$][\w$]*)\s*=/g;
35
- while ((match = commonJsExportRegex.exec(source)) !== null) {
36
- if (match[1] !== '__esModule') {
37
- exports.add(match[1]);
38
- }
39
- }
40
- if (/module\.exports\s*=/.test(source) || /exports\.default\s*=/.test(source)) {
41
- exports.add('default');
42
- }
43
- return Array.from(exports);
44
- }
45
- function resolveManifestFilePath(specifier) {
46
- const baseSpecifier = specifier.split('#', 1)[0];
47
- if (!baseSpecifier.startsWith('file://')) {
48
- return null;
49
- }
50
- try {
51
- return (0, url_1.fileURLToPath)(baseSpecifier);
52
- }
53
- catch {
54
- try {
55
- return decodeURI(baseSpecifier
56
- .replace(/^file:\/\/\//, '')
57
- .replace(/^file:\/\//, ''));
58
- }
59
- catch {
60
- return null;
61
- }
62
- }
63
- }
64
- function addDriveLetterVariants(specifier, variants) {
65
- variants.add(specifier);
66
- const match = specifier.match(/^file:\/\/\/([A-Za-z]):/);
67
- if (!match) {
68
- return;
69
- }
70
- const lowerDrive = match[1].toLowerCase();
71
- const upperDrive = match[1].toUpperCase();
72
- variants.add(specifier.replace(/^file:\/\/\/([A-Za-z]):/, `file:///${lowerDrive}:`));
73
- variants.add(specifier.replace(/^file:\/\/\/([A-Za-z]):/, `file:///${upperDrive}:`));
74
- }
75
- function buildSpecifierVariants(specifier) {
76
- const baseSpecifier = specifier.split('#', 1)[0];
77
- const variants = new Set();
78
- addDriveLetterVariants(baseSpecifier, variants);
79
- if (baseSpecifier.startsWith('file://')) {
80
- try {
81
- addDriveLetterVariants(decodeURI(baseSpecifier), variants);
82
- }
83
- catch {
84
- // ignore decode failures
85
- }
86
- try {
87
- addDriveLetterVariants((0, url_1.pathToFileURL)((0, url_1.fileURLToPath)(baseSpecifier)).toString(), variants);
88
- }
89
- catch {
90
- // ignore encode failures
91
- }
92
- }
93
- return Array.from(variants);
94
- }
95
- function createAliasedEntry(entry, exportName) {
96
- if (exportName === '') {
97
- return {
98
- ...entry,
99
- name: '',
100
- };
101
- }
102
- return {
103
- ...entry,
104
- name: exportName,
105
- };
106
- }
107
- function normalizeReactClientReferenceManifest(input) {
108
- const manifest = { ...input };
109
- for (const [rawSpecifier, rawEntry] of Object.entries(input || {})) {
110
- if (!rawEntry || typeof rawEntry !== 'object') {
111
- continue;
112
- }
113
- const entry = {
114
- id: rawEntry.id,
115
- chunks: Array.isArray(rawEntry.chunks) ? rawEntry.chunks : [],
116
- name: rawEntry.name || '*',
117
- };
118
- const sourcePath = resolveManifestFilePath(rawSpecifier);
119
- const exportNames = new Set();
120
- if (entry.name && entry.name !== '*') {
121
- exportNames.add(entry.name);
122
- }
123
- if (sourcePath && fs_1.default.existsSync(sourcePath)) {
124
- try {
125
- const source = fs_1.default.readFileSync(sourcePath, 'utf-8');
126
- for (const exportName of extractExportNames(source)) {
127
- exportNames.add(exportName);
128
- }
129
- }
130
- catch {
131
- // Keep manifest normalization resilient even if a source file disappears mid-build.
132
- }
133
- }
134
- for (const baseSpecifier of buildSpecifierVariants(rawSpecifier)) {
135
- if (!manifest[baseSpecifier]) {
136
- manifest[baseSpecifier] = entry;
137
- }
138
- const emptyExportKey = `${baseSpecifier}#`;
139
- if (!manifest[emptyExportKey]) {
140
- manifest[emptyExportKey] = createAliasedEntry(entry, '');
141
- }
142
- const defaultExportKey = `${baseSpecifier}#default`;
143
- if (!manifest[defaultExportKey]) {
144
- manifest[defaultExportKey] = createAliasedEntry(entry, 'default');
145
- }
146
- for (const exportName of exportNames) {
147
- const exportKey = `${baseSpecifier}#${exportName}`;
148
- if (!manifest[exportKey]) {
149
- manifest[exportKey] = createAliasedEntry(entry, exportName);
150
- }
151
- }
152
- }
153
- }
154
- return manifest;
155
- }
156
- function normalizeReactServerConsumerManifest(input) {
157
- if (!input?.moduleMap) {
158
- return input;
159
- }
160
- for (const [moduleKey, rawExportsMap] of Object.entries(input.moduleMap)) {
161
- const normalizedExportsMap = {};
162
- const exportNames = new Set();
163
- let sourceSpecifier = null;
164
- let seedEntry = null;
165
- for (const [exportName, rawEntry] of Object.entries(rawExportsMap || {})) {
166
- const entry = {
167
- id: rawEntry?.id ?? rawEntry?.specifier ?? moduleKey,
168
- chunks: Array.isArray(rawEntry?.chunks) ? rawEntry.chunks : [],
169
- name: rawEntry?.name || exportName,
170
- };
171
- normalizedExportsMap[exportName] = entry;
172
- if (exportName !== '*') {
173
- exportNames.add(exportName);
174
- }
175
- if (entry.name && entry.name !== '*') {
176
- exportNames.add(entry.name);
177
- }
178
- if (!seedEntry) {
179
- seedEntry = entry;
180
- }
181
- if (!sourceSpecifier && typeof entry.id === 'string' && entry.id.startsWith('file://')) {
182
- sourceSpecifier = entry.id;
183
- }
184
- if (!sourceSpecifier && typeof rawEntry?.specifier === 'string' && rawEntry.specifier.startsWith('file://')) {
185
- sourceSpecifier = rawEntry.specifier;
186
- }
187
- }
188
- const sourcePath = sourceSpecifier ? resolveManifestFilePath(sourceSpecifier) : null;
189
- if (sourcePath && fs_1.default.existsSync(sourcePath)) {
190
- try {
191
- const source = fs_1.default.readFileSync(sourcePath, 'utf-8');
192
- for (const exportName of extractExportNames(source)) {
193
- exportNames.add(exportName);
194
- }
195
- }
196
- catch {
197
- // Keep manifest normalization resilient even if the source file changes mid-build.
198
- }
199
- }
200
- if (seedEntry) {
201
- if (!normalizedExportsMap['*']) {
202
- normalizedExportsMap['*'] = {
203
- ...seedEntry,
204
- name: '*',
205
- };
206
- }
207
- for (const exportName of exportNames) {
208
- if (!normalizedExportsMap[exportName]) {
209
- normalizedExportsMap[exportName] = {
210
- ...seedEntry,
211
- name: exportName,
212
- };
213
- }
214
- }
215
- }
216
- input.moduleMap[moduleKey] = normalizedExportsMap;
217
- }
218
- return input;
219
- }
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.normalizeReactClientReferenceManifest = normalizeReactClientReferenceManifest;
7
+ exports.normalizeReactServerConsumerManifest = normalizeReactServerConsumerManifest;
8
+ exports.createGuardedReactClientManifest = createGuardedReactClientManifest;
9
+ const fs_1 = __importDefault(require("fs"));
10
+ const url_1 = require("url");
11
+ function extractExportNames(source) {
12
+ const exports = new Set();
13
+ if (/export\s+default\s+/.test(source)) {
14
+ exports.add('default');
15
+ }
16
+ const namedExportRegex = /export\s+(?:async\s+)?(?:function|const|let|var|class)\s+([A-Za-z_$][\w$]*)/g;
17
+ let match;
18
+ while ((match = namedExportRegex.exec(source)) !== null) {
19
+ exports.add(match[1]);
20
+ }
21
+ const reExportRegex = /export\s+\{([^}]+)\}/g;
22
+ while ((match = reExportRegex.exec(source)) !== null) {
23
+ const names = match[1]
24
+ .split(',')
25
+ .map((entry) => entry
26
+ .trim()
27
+ .split(/\s+as\s+/)
28
+ .pop()
29
+ ?.trim())
30
+ .filter(Boolean);
31
+ for (const name of names) {
32
+ exports.add(name);
33
+ }
34
+ }
35
+ const commonJsExportRegex = /exports\.([A-Za-z_$][\w$]*)\s*=/g;
36
+ while ((match = commonJsExportRegex.exec(source)) !== null) {
37
+ if (match[1] !== '__esModule') {
38
+ exports.add(match[1]);
39
+ }
40
+ }
41
+ if (/module\.exports\s*=/.test(source) || /exports\.default\s*=/.test(source)) {
42
+ exports.add('default');
43
+ }
44
+ return Array.from(exports);
45
+ }
46
+ function resolveManifestFilePath(specifier) {
47
+ const baseSpecifier = specifier.split('#', 1)[0];
48
+ if (!baseSpecifier.startsWith('file://')) {
49
+ return null;
50
+ }
51
+ try {
52
+ return (0, url_1.fileURLToPath)(baseSpecifier);
53
+ }
54
+ catch {
55
+ try {
56
+ return decodeURI(baseSpecifier
57
+ .replace(/^file:\/\/\//, '')
58
+ .replace(/^file:\/\//, ''));
59
+ }
60
+ catch {
61
+ return null;
62
+ }
63
+ }
64
+ }
65
+ function addDriveLetterVariants(specifier, variants) {
66
+ variants.add(specifier);
67
+ const match = specifier.match(/^file:\/\/\/([A-Za-z]):/);
68
+ if (!match) {
69
+ return;
70
+ }
71
+ const lowerDrive = match[1].toLowerCase();
72
+ const upperDrive = match[1].toUpperCase();
73
+ variants.add(specifier.replace(/^file:\/\/\/([A-Za-z]):/, `file:///${lowerDrive}:`));
74
+ variants.add(specifier.replace(/^file:\/\/\/([A-Za-z]):/, `file:///${upperDrive}:`));
75
+ }
76
+ function buildSpecifierVariants(specifier) {
77
+ const baseSpecifier = specifier.split('#', 1)[0];
78
+ const variants = new Set();
79
+ addDriveLetterVariants(baseSpecifier, variants);
80
+ if (baseSpecifier.startsWith('file://')) {
81
+ try {
82
+ addDriveLetterVariants(decodeURI(baseSpecifier), variants);
83
+ }
84
+ catch {
85
+ // ignore decode failures
86
+ }
87
+ try {
88
+ addDriveLetterVariants((0, url_1.pathToFileURL)((0, url_1.fileURLToPath)(baseSpecifier)).toString(), variants);
89
+ }
90
+ catch {
91
+ // ignore encode failures
92
+ }
93
+ }
94
+ return Array.from(variants);
95
+ }
96
+ function createAliasedEntry(entry, exportName) {
97
+ if (exportName === '') {
98
+ return {
99
+ ...entry,
100
+ name: '',
101
+ };
102
+ }
103
+ return {
104
+ ...entry,
105
+ name: exportName,
106
+ };
107
+ }
108
+ function normalizeReactClientReferenceManifest(input) {
109
+ const manifest = { ...input };
110
+ for (const [rawSpecifier, rawEntry] of Object.entries(input || {})) {
111
+ if (!rawEntry || typeof rawEntry !== 'object') {
112
+ continue;
113
+ }
114
+ const entry = {
115
+ id: rawEntry.id,
116
+ chunks: Array.isArray(rawEntry.chunks) ? rawEntry.chunks : [],
117
+ name: rawEntry.name || '*',
118
+ };
119
+ const sourcePath = resolveManifestFilePath(rawSpecifier);
120
+ const exportNames = new Set();
121
+ if (entry.name && entry.name !== '*') {
122
+ exportNames.add(entry.name);
123
+ }
124
+ if (sourcePath && fs_1.default.existsSync(sourcePath)) {
125
+ try {
126
+ const source = fs_1.default.readFileSync(sourcePath, 'utf-8');
127
+ for (const exportName of extractExportNames(source)) {
128
+ exportNames.add(exportName);
129
+ }
130
+ }
131
+ catch {
132
+ // Keep manifest normalization resilient even if a source file disappears mid-build.
133
+ }
134
+ }
135
+ for (const baseSpecifier of buildSpecifierVariants(rawSpecifier)) {
136
+ if (!manifest[baseSpecifier]) {
137
+ manifest[baseSpecifier] = entry;
138
+ }
139
+ const emptyExportKey = `${baseSpecifier}#`;
140
+ if (!manifest[emptyExportKey]) {
141
+ manifest[emptyExportKey] = createAliasedEntry(entry, '');
142
+ }
143
+ const defaultExportKey = `${baseSpecifier}#default`;
144
+ if (!manifest[defaultExportKey]) {
145
+ manifest[defaultExportKey] = createAliasedEntry(entry, 'default');
146
+ }
147
+ for (const exportName of exportNames) {
148
+ const exportKey = `${baseSpecifier}#${exportName}`;
149
+ if (!manifest[exportKey]) {
150
+ manifest[exportKey] = createAliasedEntry(entry, exportName);
151
+ }
152
+ }
153
+ }
154
+ }
155
+ return manifest;
156
+ }
157
+ function normalizeReactServerConsumerManifest(input) {
158
+ if (!input?.moduleMap) {
159
+ return input;
160
+ }
161
+ for (const [moduleKey, rawExportsMap] of Object.entries(input.moduleMap)) {
162
+ const normalizedExportsMap = {};
163
+ const exportNames = new Set();
164
+ let sourceSpecifier = null;
165
+ let seedEntry = null;
166
+ for (const [exportName, rawEntry] of Object.entries(rawExportsMap || {})) {
167
+ const entry = {
168
+ id: rawEntry?.id ?? rawEntry?.specifier ?? moduleKey,
169
+ chunks: Array.isArray(rawEntry?.chunks) ? rawEntry.chunks : [],
170
+ name: rawEntry?.name || exportName,
171
+ };
172
+ normalizedExportsMap[exportName] = entry;
173
+ if (exportName !== '*') {
174
+ exportNames.add(exportName);
175
+ }
176
+ if (entry.name && entry.name !== '*') {
177
+ exportNames.add(entry.name);
178
+ }
179
+ if (!seedEntry) {
180
+ seedEntry = entry;
181
+ }
182
+ if (!sourceSpecifier && typeof entry.id === 'string' && entry.id.startsWith('file://')) {
183
+ sourceSpecifier = entry.id;
184
+ }
185
+ if (!sourceSpecifier && typeof rawEntry?.specifier === 'string' && rawEntry.specifier.startsWith('file://')) {
186
+ sourceSpecifier = rawEntry.specifier;
187
+ }
188
+ }
189
+ const sourcePath = sourceSpecifier ? resolveManifestFilePath(sourceSpecifier) : null;
190
+ if (sourcePath && fs_1.default.existsSync(sourcePath)) {
191
+ try {
192
+ const source = fs_1.default.readFileSync(sourcePath, 'utf-8');
193
+ for (const exportName of extractExportNames(source)) {
194
+ exportNames.add(exportName);
195
+ }
196
+ }
197
+ catch {
198
+ // Keep manifest normalization resilient even if the source file changes mid-build.
199
+ }
200
+ }
201
+ if (seedEntry) {
202
+ if (!normalizedExportsMap['*']) {
203
+ normalizedExportsMap['*'] = {
204
+ ...seedEntry,
205
+ name: '*',
206
+ };
207
+ }
208
+ for (const exportName of exportNames) {
209
+ if (!normalizedExportsMap[exportName]) {
210
+ normalizedExportsMap[exportName] = {
211
+ ...seedEntry,
212
+ name: exportName,
213
+ };
214
+ }
215
+ }
216
+ }
217
+ input.moduleMap[moduleKey] = normalizedExportsMap;
218
+ }
219
+ return input;
220
+ }
221
+ /**
222
+ * React looks up `file://...#ExportName` in the Flight manifest and throws a
223
+ * generic error when the key is missing. Wrap the manifest so the message names
224
+ * the file and the scan-directory requirement.
225
+ */
226
+ function createGuardedReactClientManifest(manifest) {
227
+ return new Proxy(manifest, {
228
+ get(target, prop, receiver) {
229
+ if (typeof prop === 'string' &&
230
+ (prop.startsWith('file:') || prop.includes('#')) &&
231
+ !Object.prototype.hasOwnProperty.call(target, prop)) {
232
+ const fileHint = prop.split('#')[0];
233
+ throw new Error(`Could not find the module "${prop}" in the React Client Manifest. ` +
234
+ `Client Components need a 'use client' directive and must live under a scanned project directory ` +
235
+ `(app/, components/, utils/, lib/, src/, ...). Missing: ${fileHint}`);
236
+ }
237
+ return Reflect.get(target, prop, receiver);
238
+ },
239
+ });
240
+ }