@absolutejs/absolute 0.19.0-beta.1095 → 0.19.0-beta.1096

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/vue/index.js CHANGED
@@ -98,6 +98,351 @@ var init_constants = __esm(() => {
98
98
  TWO_THIRDS = 2 / 3;
99
99
  });
100
100
 
101
+ // src/utils/stringModifiers.ts
102
+ var normalizeSlug = (str) => str.trim().replace(/\s+/g, "-").replace(/[^A-Za-z0-9\-_]+/g, "").replace(/[-_]{2,}/g, "-"), toKebab = (str) => normalizeSlug(str).replace(/([a-z0-9])([A-Z])/g, "$1-$2").toLowerCase(), toPascal = (str) => {
103
+ if (!str.includes("-") && !str.includes("_")) {
104
+ return str.charAt(0).toUpperCase() + str.slice(1);
105
+ }
106
+ return normalizeSlug(str).split(/[-_]/).filter(Boolean).map((segment) => segment.charAt(0).toUpperCase() + segment.slice(1).toLowerCase()).join("");
107
+ };
108
+
109
+ // src/utils/resolveConvention.ts
110
+ import { basename } from "path";
111
+ var CONVENTIONS_KEY = "__absoluteConventions", isConventionsMap = (value) => Boolean(value) && typeof value === "object", getMap = () => {
112
+ const value = Reflect.get(globalThis, CONVENTIONS_KEY);
113
+ if (isConventionsMap(value))
114
+ return value;
115
+ const empty = {};
116
+ return empty;
117
+ }, derivePageName = (pagePath) => {
118
+ const base = basename(pagePath);
119
+ const dotIndex = base.indexOf(".");
120
+ const name = dotIndex > 0 ? base.slice(0, dotIndex) : base;
121
+ return toPascal(name);
122
+ }, normalizeConventionPageName = (name) => toPascal(name).replace(/\d+$/, ""), hasErrorConvention = (framework) => {
123
+ const conventions = getMap()[framework];
124
+ if (!conventions)
125
+ return false;
126
+ if (conventions.defaults?.error)
127
+ return true;
128
+ return Object.values(conventions.pages ?? {}).some((page) => Boolean(page.error));
129
+ }, resolveErrorConventionPath = (framework, pageName) => {
130
+ const conventions = getMap()[framework];
131
+ if (!conventions)
132
+ return;
133
+ const exact = conventions.pages?.[pageName]?.error;
134
+ if (exact)
135
+ return exact;
136
+ const normalizedPageName = normalizeConventionPageName(pageName);
137
+ for (const [candidate, page] of Object.entries(conventions.pages ?? {})) {
138
+ if (normalizeConventionPageName(candidate) === normalizedPageName) {
139
+ return page.error ?? conventions.defaults?.error;
140
+ }
141
+ }
142
+ return conventions.defaults?.error;
143
+ }, resolveNotFoundConventionPath = (framework) => getMap()[framework]?.defaults?.notFound, setConventions = (map) => {
144
+ Reflect.set(globalThis, CONVENTIONS_KEY, map);
145
+ }, isDev = () => true, buildErrorProps = (error) => {
146
+ if (error instanceof Error) {
147
+ return {
148
+ name: error.name,
149
+ message: error.message,
150
+ ...isDev() && error.stack ? { stack: error.stack } : {}
151
+ };
152
+ }
153
+ return { message: String(error), name: "Error" };
154
+ }, renderReactError = async (conventionPath, errorProps) => {
155
+ const { createElement } = await import("react");
156
+ const { renderToReadableStream } = await import("react-dom/server");
157
+ const mod = await import(conventionPath);
158
+ const ErrorComponent = mod.default;
159
+ if (typeof ErrorComponent !== "function")
160
+ return null;
161
+ const element = createElement(ErrorComponent, errorProps);
162
+ const stream = await renderToReadableStream(element);
163
+ return new Response(stream, {
164
+ headers: { "Content-Type": "text/html" },
165
+ status: 500
166
+ });
167
+ }, renderSvelteError = async (conventionPath, errorProps) => {
168
+ const { render } = await import("svelte/server");
169
+ const mod = await import(conventionPath);
170
+ const ErrorComponent = mod.default;
171
+ if (!ErrorComponent)
172
+ return null;
173
+ const { head, body } = render(ErrorComponent, {
174
+ props: errorProps
175
+ });
176
+ const html = `<!DOCTYPE html><html><head>${head}</head><body>${body}</body></html>`;
177
+ return new Response(html, {
178
+ headers: { "Content-Type": "text/html" },
179
+ status: 500
180
+ });
181
+ }, unescapeVueStyles = (ssrBody) => {
182
+ let styles = "";
183
+ const body = ssrBody.replace(/<style>([\s\S]*?)<\/style>/g, (_, css) => {
184
+ styles += `<style>${css.replace(/&quot;/g, '"').replace(/&amp;/g, "&").replace(/&lt;/g, "<").replace(/&gt;/g, ">")}</style>`;
185
+ return "";
186
+ });
187
+ return { body, styles };
188
+ }, renderVueError = async (conventionPath, errorProps) => {
189
+ const { createSSRApp, h: h4 } = await import("vue");
190
+ const { renderToString } = await import("vue/server-renderer");
191
+ const mod = await import(conventionPath);
192
+ const ErrorComponent = mod.default;
193
+ if (!ErrorComponent)
194
+ return null;
195
+ const app = createSSRApp({
196
+ render: () => h4(ErrorComponent, errorProps)
197
+ });
198
+ const rawBody = await renderToString(app);
199
+ const { styles, body } = unescapeVueStyles(rawBody);
200
+ const html = `<!DOCTYPE html><html><head>${styles}</head><body><div id="root">${body}</div></body></html>`;
201
+ return new Response(html, {
202
+ headers: { "Content-Type": "text/html" },
203
+ status: 500
204
+ });
205
+ }, renderAngularError = async (conventionPath, errorProps) => {
206
+ const mod = await import(conventionPath);
207
+ const renderFn = mod.default;
208
+ if (typeof renderFn !== "function")
209
+ return null;
210
+ const html = renderFn(errorProps);
211
+ return new Response(html, {
212
+ headers: { "Content-Type": "text/html" },
213
+ status: 500
214
+ });
215
+ }, escapeHtml = (value) => value.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;").replace(/'/g, "&#39;"), replaceErrorTokens = (template, errorProps) => template.replace(/\{\{\s*name\s*\}\}/g, escapeHtml(errorProps.name)).replace(/\{\{\s*message\s*\}\}/g, escapeHtml(errorProps.message)).replace(/\{\{\s*stack\s*\}\}/g, errorProps.stack ? escapeHtml(errorProps.stack) : ""), renderHtmlError = async (conventionPath, errorProps) => {
216
+ const template = await Bun.file(conventionPath).text();
217
+ const html = replaceErrorTokens(template, errorProps);
218
+ return new Response(html, {
219
+ headers: { "Content-Type": "text/html" },
220
+ status: 500
221
+ });
222
+ }, logConventionRenderError = (framework, label, renderError) => {
223
+ const message = renderError instanceof Error ? renderError.message : "";
224
+ if (message.includes("Cannot find module") || message.includes("Cannot find package") || message.includes("not found in module")) {
225
+ console.error(`[SSR] Convention ${label} page for ${framework} failed: missing framework package. Ensure the ${framework} runtime is installed (e.g. bun add ${framework === "react" ? "react react-dom" : framework}).`);
226
+ return;
227
+ }
228
+ console.error(`[SSR] Failed to render ${framework} convention ${label} page:`, renderError);
229
+ }, renderEmberError = async () => null, renderEmberNotFound = async () => null, ERROR_RENDERERS, tryFrameworkErrorConvention = async (framework, pageName, errorProps, error) => {
230
+ let conventionPath = resolveErrorConventionPath(framework, pageName);
231
+ if (!conventionPath && error instanceof Error && error.stack) {
232
+ for (const match of error.stack.matchAll(/^\s*at\s+([A-Za-z_$][\w$]*)/gm)) {
233
+ const candidate = match[1];
234
+ if (!candidate)
235
+ continue;
236
+ conventionPath = resolveErrorConventionPath(framework, candidate);
237
+ if (conventionPath)
238
+ break;
239
+ }
240
+ }
241
+ if (!conventionPath)
242
+ return null;
243
+ const renderer = ERROR_RENDERERS[framework];
244
+ if (!renderer)
245
+ return null;
246
+ try {
247
+ return await renderer(conventionPath, errorProps);
248
+ } catch (renderError) {
249
+ logConventionRenderError(framework, "error", renderError);
250
+ }
251
+ return null;
252
+ }, renderConventionError = async (framework, pageName, error) => {
253
+ const errorProps = buildErrorProps(error);
254
+ const frameworkResponse = await tryFrameworkErrorConvention(framework, pageName, errorProps, error);
255
+ if (frameworkResponse)
256
+ return frameworkResponse;
257
+ if (framework !== "html") {
258
+ const htmlResponse = await tryFrameworkErrorConvention("html", pageName, errorProps, error);
259
+ if (htmlResponse)
260
+ return htmlResponse;
261
+ }
262
+ return null;
263
+ }, renderReactNotFound = async (conventionPath) => {
264
+ const { createElement } = await import("react");
265
+ const { renderToReadableStream } = await import("react-dom/server");
266
+ const mod = await import(conventionPath);
267
+ const NotFoundComponent = mod.default;
268
+ if (typeof NotFoundComponent !== "function")
269
+ return null;
270
+ const element = createElement(NotFoundComponent);
271
+ const stream = await renderToReadableStream(element);
272
+ return new Response(stream, {
273
+ headers: { "Content-Type": "text/html" },
274
+ status: 404
275
+ });
276
+ }, renderSvelteNotFound = async (conventionPath) => {
277
+ const { render } = await import("svelte/server");
278
+ const mod = await import(conventionPath);
279
+ const NotFoundComponent = mod.default;
280
+ if (!NotFoundComponent)
281
+ return null;
282
+ const { head, body } = render(NotFoundComponent);
283
+ const html = `<!DOCTYPE html><html><head>${head}</head><body>${body}</body></html>`;
284
+ return new Response(html, {
285
+ headers: { "Content-Type": "text/html" },
286
+ status: 404
287
+ });
288
+ }, renderVueNotFound = async (conventionPath) => {
289
+ const { createSSRApp, h: h4 } = await import("vue");
290
+ const { renderToString } = await import("vue/server-renderer");
291
+ const mod = await import(conventionPath);
292
+ const NotFoundComponent = mod.default;
293
+ if (!NotFoundComponent)
294
+ return null;
295
+ const app = createSSRApp({
296
+ render: () => h4(NotFoundComponent)
297
+ });
298
+ const rawBody = await renderToString(app);
299
+ const { styles, body } = unescapeVueStyles(rawBody);
300
+ const html = `<!DOCTYPE html><html><head>${styles}</head><body><div id="root">${body}</div></body></html>`;
301
+ return new Response(html, {
302
+ headers: { "Content-Type": "text/html" },
303
+ status: 404
304
+ });
305
+ }, renderAngularNotFound = async (conventionPath) => {
306
+ const mod = await import(conventionPath);
307
+ const renderFn = mod.default;
308
+ if (typeof renderFn !== "function")
309
+ return null;
310
+ const html = renderFn();
311
+ return new Response(html, {
312
+ headers: { "Content-Type": "text/html" },
313
+ status: 404
314
+ });
315
+ }, renderHtmlNotFound = async (conventionPath) => {
316
+ const html = await Bun.file(conventionPath).text();
317
+ return new Response(html, {
318
+ headers: { "Content-Type": "text/html" },
319
+ status: 404
320
+ });
321
+ }, NOT_FOUND_RENDERERS, renderConventionNotFound = async (framework) => {
322
+ const conventionPath = resolveNotFoundConventionPath(framework);
323
+ if (!conventionPath)
324
+ return null;
325
+ const renderer = NOT_FOUND_RENDERERS[framework];
326
+ if (!renderer)
327
+ return null;
328
+ try {
329
+ return await renderer(conventionPath);
330
+ } catch (renderError) {
331
+ logConventionRenderError(framework, "not-found", renderError);
332
+ }
333
+ return null;
334
+ }, NOT_FOUND_PRIORITY, renderFirstNotFound = async () => {
335
+ const renderNext = async (frameworks) => {
336
+ const [framework, ...remaining] = frameworks;
337
+ if (!framework) {
338
+ return null;
339
+ }
340
+ if (!getMap()[framework]?.defaults?.notFound) {
341
+ return renderNext(remaining);
342
+ }
343
+ const response = await renderConventionNotFound(framework);
344
+ if (response) {
345
+ return response;
346
+ }
347
+ return renderNext(remaining);
348
+ };
349
+ return renderNext(NOT_FOUND_PRIORITY);
350
+ };
351
+ var init_resolveConvention = __esm(() => {
352
+ ERROR_RENDERERS = {
353
+ angular: renderAngularError,
354
+ ember: renderEmberError,
355
+ html: renderHtmlError,
356
+ react: renderReactError,
357
+ svelte: renderSvelteError,
358
+ vue: renderVueError
359
+ };
360
+ NOT_FOUND_RENDERERS = {
361
+ angular: renderAngularNotFound,
362
+ ember: renderEmberNotFound,
363
+ html: renderHtmlNotFound,
364
+ react: renderReactNotFound,
365
+ svelte: renderSvelteNotFound,
366
+ vue: renderVueNotFound
367
+ };
368
+ NOT_FOUND_PRIORITY = [
369
+ "react",
370
+ "svelte",
371
+ "vue",
372
+ "angular",
373
+ "html"
374
+ ];
375
+ });
376
+
377
+ // src/utils/spaRouteManifest.ts
378
+ import { basename as basename2 } from "path";
379
+ var SPA_ROUTES_KEY = "__absoluteSpaRoutes", setSpaRouteManifest = (hosts) => {
380
+ Reflect.set(globalThis, SPA_ROUTES_KEY, hosts);
381
+ }, getSpaRouteManifest = () => {
382
+ const value = Reflect.get(globalThis, SPA_ROUTES_KEY);
383
+ return Array.isArray(value) ? value : [];
384
+ }, normalizePath = (path) => {
385
+ const withLeadingSlash = path.startsWith("/") ? path : `/${path}`;
386
+ const trimmed = withLeadingSlash.replace(/\/+$/, "");
387
+ return trimmed || "/";
388
+ }, fullRoutePath = (baseHref, routePath) => {
389
+ const base = normalizePath(baseHref);
390
+ const route = normalizePath(routePath);
391
+ if (base !== "/" && (route === base || route.startsWith(`${base}/`))) {
392
+ return route;
393
+ }
394
+ if (base === "/")
395
+ return route;
396
+ return normalizePath(`${base}/${route.replace(/^\/+/, "")}`);
397
+ }, routePattern = (path) => {
398
+ const segments = normalizePath(path).split("/").filter(Boolean);
399
+ let expression = "^";
400
+ for (const segment of segments) {
401
+ if (segment === "*" || segment === "**") {
402
+ expression += "(?:/.*)?";
403
+ continue;
404
+ }
405
+ const parameter = /^:[A-Za-z_$][A-Za-z0-9_$]*(?:\((.*)\))?(\?)?$/.exec(segment);
406
+ if (parameter) {
407
+ const valuePattern = parameter[1] || "[^/]+";
408
+ expression += parameter[2] ? `(?:/${valuePattern})?` : `/${valuePattern}`;
409
+ continue;
410
+ }
411
+ expression += `/${segment.replace(/[.+?^${}()|[\]\\]/g, "\\$&")}`;
412
+ }
413
+ return new RegExp(`${expression || "^/"}/?$`);
414
+ }, sourcePageName = (sourceFile) => basename2(sourceFile).replace(/\.[^.]+$/, "").toLowerCase(), isKnownSpaRoute = (framework, pageName, request) => {
415
+ if (!request)
416
+ return true;
417
+ let pathname;
418
+ try {
419
+ pathname = normalizePath(new URL(request.url).pathname);
420
+ } catch {
421
+ return true;
422
+ }
423
+ const hosts = getSpaRouteManifest().filter((host) => {
424
+ if (host.framework !== framework)
425
+ return false;
426
+ if (sourcePageName(host.sourceFile) !== pageName.toLowerCase())
427
+ return false;
428
+ const base = normalizePath(host.baseHref);
429
+ return base === "/" || pathname === base || pathname.startsWith(`${base}/`);
430
+ });
431
+ if (hosts.length === 0)
432
+ return true;
433
+ return hosts.some((host) => host.routes.some((route) => routePattern(fullRoutePath(host.baseHref, route.path)).test(pathname)));
434
+ }, renderSpaNotFound = async (framework, pageName, request) => {
435
+ if (isKnownSpaRoute(framework, pageName, request))
436
+ return null;
437
+ return await renderFirstNotFound() ?? new Response("Not found", {
438
+ headers: { "Content-Type": "text/plain" },
439
+ status: 404
440
+ });
441
+ };
442
+ var init_spaRouteManifest = __esm(() => {
443
+ init_resolveConvention();
444
+ });
445
+
101
446
  // src/core/devRouteRegistrationCallsite.ts
102
447
  var exports_devRouteRegistrationCallsite = {};
103
448
  __export(exports_devRouteRegistrationCallsite, {
@@ -1113,20 +1458,12 @@ body{min-height:100vh;background:linear-gradient(135deg,rgba(15,23,42,0.98) 0%,r
1113
1458
  </div>
1114
1459
  <div class="content">
1115
1460
  <div class="label">What went wrong</div>
1116
- <pre class="message">${message.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;")}</pre>
1117
- <div class="hint">A component threw during server-side rendering. Check the terminal for the full stack trace.</div>
1118
- </div>
1119
- </div>
1120
- </body>
1121
- </html>`;
1122
- };
1123
-
1124
- // src/utils/stringModifiers.ts
1125
- var normalizeSlug = (str) => str.trim().replace(/\s+/g, "-").replace(/[^A-Za-z0-9\-_]+/g, "").replace(/[-_]{2,}/g, "-"), toKebab = (str) => normalizeSlug(str).replace(/([a-z0-9])([A-Z])/g, "$1-$2").toLowerCase(), toPascal = (str) => {
1126
- if (!str.includes("-") && !str.includes("_")) {
1127
- return str.charAt(0).toUpperCase() + str.slice(1);
1128
- }
1129
- return normalizeSlug(str).split(/[-_]/).filter(Boolean).map((segment) => segment.charAt(0).toUpperCase() + segment.slice(1).toLowerCase()).join("");
1461
+ <pre class="message">${message.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;")}</pre>
1462
+ <div class="hint">A component threw during server-side rendering. Check the terminal for the full stack trace.</div>
1463
+ </div>
1464
+ </div>
1465
+ </body>
1466
+ </html>`;
1130
1467
  };
1131
1468
 
1132
1469
  // src/cli/scripts/telemetry.ts
@@ -3262,7 +3599,7 @@ var init_stylePreprocessor = __esm(() => {
3262
3599
 
3263
3600
  // src/core/svelteServerModule.ts
3264
3601
  import { mkdir as mkdir2, readdir as readdir3 } from "fs/promises";
3265
- import { basename as basename3, dirname as dirname6, extname as extname2, join as join8, relative as relative3, resolve as resolve7 } from "path";
3602
+ import { basename as basename4, dirname as dirname6, extname as extname2, join as join8, relative as relative3, resolve as resolve7 } from "path";
3266
3603
  var serverCacheRoot2, compiledModuleCache2, originalSourcePathCache, transpiler, ensureRelativeImportPath = (from, target) => {
3267
3604
  const importPath = relative3(dirname6(from), target).replace(/\\/g, "/");
3268
3605
  return importPath.startsWith(".") ? importPath : `./${importPath}`;
@@ -3293,7 +3630,7 @@ var serverCacheRoot2, compiledModuleCache2, originalSourcePathCache, transpiler,
3293
3630
  return found;
3294
3631
  }
3295
3632
  return searchDirectoryLevel(nextStack, targetFileName);
3296
- }, findSourceFileByBasename = async (searchRoot, targetFileName) => searchDirectoryLevel([searchRoot], targetFileName), normalizeBuiltSvelteFileName = (sourcePath) => basename3(sourcePath).replace(/-[a-z0-9]{6,}(?=\.svelte$)/i, ""), resolveOriginalSourcePath = async (sourcePath) => {
3633
+ }, findSourceFileByBasename = async (searchRoot, targetFileName) => searchDirectoryLevel([searchRoot], targetFileName), normalizeBuiltSvelteFileName = (sourcePath) => basename4(sourcePath).replace(/-[a-z0-9]{6,}(?=\.svelte$)/i, ""), resolveOriginalSourcePath = async (sourcePath) => {
3297
3634
  const cachedPath = originalSourcePathCache.get(sourcePath);
3298
3635
  if (cachedPath !== undefined) {
3299
3636
  return cachedPath;
@@ -4221,7 +4558,7 @@ var registerStreamSlotForSsr = (props) => {
4221
4558
  // src/vue/pageHandler.ts
4222
4559
  init_constants();
4223
4560
  import { readdir } from "fs/promises";
4224
- import { basename as basename2, dirname as dirname3 } from "path";
4561
+ import { basename as basename3, dirname as dirname3 } from "path";
4225
4562
 
4226
4563
  // src/utils/inlinePageCss.ts
4227
4564
  var siblingCssCache = new Map;
@@ -4335,6 +4672,9 @@ var resolveSpaChildCss = async (siblingJsPath, requestUrl) => {
4335
4672
  `);
4336
4673
  };
4337
4674
 
4675
+ // src/vue/pageHandler.ts
4676
+ init_spaRouteManifest();
4677
+
4338
4678
  // src/core/islandPageContext.ts
4339
4679
  var BOOTSTRAP_MANIFEST_KEY = "BootstrapClient";
4340
4680
  var ISLAND_MARKER = 'data-island="true"';
@@ -4667,303 +5007,9 @@ var captureStreamingSlotWarningCallsite = () => {
4667
5007
  return extractCallsiteFromStack(stack);
4668
5008
  };
4669
5009
  var runWithStreamingSlotWarningScope = (task, metadata) => ensureWarningStorage().run({ handlerCallsite: metadata?.handlerCallsite, hasWarned: false }, task);
4670
- // src/utils/resolveConvention.ts
4671
- import { basename } from "path";
4672
- var CONVENTIONS_KEY = "__absoluteConventions";
4673
- var isConventionsMap = (value) => Boolean(value) && typeof value === "object";
4674
- var getMap = () => {
4675
- const value = Reflect.get(globalThis, CONVENTIONS_KEY);
4676
- if (isConventionsMap(value))
4677
- return value;
4678
- const empty = {};
4679
- return empty;
4680
- };
4681
- var derivePageName = (pagePath) => {
4682
- const base = basename(pagePath);
4683
- const dotIndex = base.indexOf(".");
4684
- const name = dotIndex > 0 ? base.slice(0, dotIndex) : base;
4685
- return toPascal(name);
4686
- };
4687
- var normalizeConventionPageName = (name) => toPascal(name).replace(/\d+$/, "");
4688
- var hasErrorConvention = (framework) => {
4689
- const conventions = getMap()[framework];
4690
- if (!conventions)
4691
- return false;
4692
- if (conventions.defaults?.error)
4693
- return true;
4694
- return Object.values(conventions.pages ?? {}).some((page) => Boolean(page.error));
4695
- };
4696
- var resolveErrorConventionPath = (framework, pageName) => {
4697
- const conventions = getMap()[framework];
4698
- if (!conventions)
4699
- return;
4700
- const exact = conventions.pages?.[pageName]?.error;
4701
- if (exact)
4702
- return exact;
4703
- const normalizedPageName = normalizeConventionPageName(pageName);
4704
- for (const [candidate, page] of Object.entries(conventions.pages ?? {})) {
4705
- if (normalizeConventionPageName(candidate) === normalizedPageName) {
4706
- return page.error ?? conventions.defaults?.error;
4707
- }
4708
- }
4709
- return conventions.defaults?.error;
4710
- };
4711
- var resolveNotFoundConventionPath = (framework) => getMap()[framework]?.defaults?.notFound;
4712
- var setConventions = (map) => {
4713
- Reflect.set(globalThis, CONVENTIONS_KEY, map);
4714
- };
4715
- var isDev = () => true;
4716
- var buildErrorProps = (error) => {
4717
- if (error instanceof Error) {
4718
- return {
4719
- name: error.name,
4720
- message: error.message,
4721
- ...isDev() && error.stack ? { stack: error.stack } : {}
4722
- };
4723
- }
4724
- return { message: String(error), name: "Error" };
4725
- };
4726
- var renderReactError = async (conventionPath, errorProps) => {
4727
- const { createElement } = await import("react");
4728
- const { renderToReadableStream } = await import("react-dom/server");
4729
- const mod = await import(conventionPath);
4730
- const ErrorComponent = mod.default;
4731
- if (typeof ErrorComponent !== "function")
4732
- return null;
4733
- const element = createElement(ErrorComponent, errorProps);
4734
- const stream = await renderToReadableStream(element);
4735
- return new Response(stream, {
4736
- headers: { "Content-Type": "text/html" },
4737
- status: 500
4738
- });
4739
- };
4740
- var renderSvelteError = async (conventionPath, errorProps) => {
4741
- const { render } = await import("svelte/server");
4742
- const mod = await import(conventionPath);
4743
- const ErrorComponent = mod.default;
4744
- if (!ErrorComponent)
4745
- return null;
4746
- const { head, body } = render(ErrorComponent, {
4747
- props: errorProps
4748
- });
4749
- const html = `<!DOCTYPE html><html><head>${head}</head><body>${body}</body></html>`;
4750
- return new Response(html, {
4751
- headers: { "Content-Type": "text/html" },
4752
- status: 500
4753
- });
4754
- };
4755
- var unescapeVueStyles = (ssrBody) => {
4756
- let styles = "";
4757
- const body = ssrBody.replace(/<style>([\s\S]*?)<\/style>/g, (_, css) => {
4758
- styles += `<style>${css.replace(/&quot;/g, '"').replace(/&amp;/g, "&").replace(/&lt;/g, "<").replace(/&gt;/g, ">")}</style>`;
4759
- return "";
4760
- });
4761
- return { body, styles };
4762
- };
4763
- var renderVueError = async (conventionPath, errorProps) => {
4764
- const { createSSRApp, h: h4 } = await import("vue");
4765
- const { renderToString } = await import("vue/server-renderer");
4766
- const mod = await import(conventionPath);
4767
- const ErrorComponent = mod.default;
4768
- if (!ErrorComponent)
4769
- return null;
4770
- const app = createSSRApp({
4771
- render: () => h4(ErrorComponent, errorProps)
4772
- });
4773
- const rawBody = await renderToString(app);
4774
- const { styles, body } = unescapeVueStyles(rawBody);
4775
- const html = `<!DOCTYPE html><html><head>${styles}</head><body><div id="root">${body}</div></body></html>`;
4776
- return new Response(html, {
4777
- headers: { "Content-Type": "text/html" },
4778
- status: 500
4779
- });
4780
- };
4781
- var renderAngularError = async (conventionPath, errorProps) => {
4782
- const mod = await import(conventionPath);
4783
- const renderFn = mod.default;
4784
- if (typeof renderFn !== "function")
4785
- return null;
4786
- const html = renderFn(errorProps);
4787
- return new Response(html, {
4788
- headers: { "Content-Type": "text/html" },
4789
- status: 500
4790
- });
4791
- };
4792
- var escapeHtml = (value) => value.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;").replace(/'/g, "&#39;");
4793
- var replaceErrorTokens = (template, errorProps) => template.replace(/\{\{\s*name\s*\}\}/g, escapeHtml(errorProps.name)).replace(/\{\{\s*message\s*\}\}/g, escapeHtml(errorProps.message)).replace(/\{\{\s*stack\s*\}\}/g, errorProps.stack ? escapeHtml(errorProps.stack) : "");
4794
- var renderHtmlError = async (conventionPath, errorProps) => {
4795
- const template = await Bun.file(conventionPath).text();
4796
- const html = replaceErrorTokens(template, errorProps);
4797
- return new Response(html, {
4798
- headers: { "Content-Type": "text/html" },
4799
- status: 500
4800
- });
4801
- };
4802
- var logConventionRenderError = (framework, label, renderError) => {
4803
- const message = renderError instanceof Error ? renderError.message : "";
4804
- if (message.includes("Cannot find module") || message.includes("Cannot find package") || message.includes("not found in module")) {
4805
- console.error(`[SSR] Convention ${label} page for ${framework} failed: missing framework package. Ensure the ${framework} runtime is installed (e.g. bun add ${framework === "react" ? "react react-dom" : framework}).`);
4806
- return;
4807
- }
4808
- console.error(`[SSR] Failed to render ${framework} convention ${label} page:`, renderError);
4809
- };
4810
- var renderEmberError = async () => null;
4811
- var renderEmberNotFound = async () => null;
4812
- var ERROR_RENDERERS = {
4813
- angular: renderAngularError,
4814
- ember: renderEmberError,
4815
- html: renderHtmlError,
4816
- react: renderReactError,
4817
- svelte: renderSvelteError,
4818
- vue: renderVueError
4819
- };
4820
- var tryFrameworkErrorConvention = async (framework, pageName, errorProps, error) => {
4821
- let conventionPath = resolveErrorConventionPath(framework, pageName);
4822
- if (!conventionPath && error instanceof Error && error.stack) {
4823
- for (const match of error.stack.matchAll(/^\s*at\s+([A-Za-z_$][\w$]*)/gm)) {
4824
- const candidate = match[1];
4825
- if (!candidate)
4826
- continue;
4827
- conventionPath = resolveErrorConventionPath(framework, candidate);
4828
- if (conventionPath)
4829
- break;
4830
- }
4831
- }
4832
- if (!conventionPath)
4833
- return null;
4834
- const renderer = ERROR_RENDERERS[framework];
4835
- if (!renderer)
4836
- return null;
4837
- try {
4838
- return await renderer(conventionPath, errorProps);
4839
- } catch (renderError) {
4840
- logConventionRenderError(framework, "error", renderError);
4841
- }
4842
- return null;
4843
- };
4844
- var renderConventionError = async (framework, pageName, error) => {
4845
- const errorProps = buildErrorProps(error);
4846
- const frameworkResponse = await tryFrameworkErrorConvention(framework, pageName, errorProps, error);
4847
- if (frameworkResponse)
4848
- return frameworkResponse;
4849
- if (framework !== "html") {
4850
- const htmlResponse = await tryFrameworkErrorConvention("html", pageName, errorProps, error);
4851
- if (htmlResponse)
4852
- return htmlResponse;
4853
- }
4854
- return null;
4855
- };
4856
- var renderReactNotFound = async (conventionPath) => {
4857
- const { createElement } = await import("react");
4858
- const { renderToReadableStream } = await import("react-dom/server");
4859
- const mod = await import(conventionPath);
4860
- const NotFoundComponent = mod.default;
4861
- if (typeof NotFoundComponent !== "function")
4862
- return null;
4863
- const element = createElement(NotFoundComponent);
4864
- const stream = await renderToReadableStream(element);
4865
- return new Response(stream, {
4866
- headers: { "Content-Type": "text/html" },
4867
- status: 404
4868
- });
4869
- };
4870
- var renderSvelteNotFound = async (conventionPath) => {
4871
- const { render } = await import("svelte/server");
4872
- const mod = await import(conventionPath);
4873
- const NotFoundComponent = mod.default;
4874
- if (!NotFoundComponent)
4875
- return null;
4876
- const { head, body } = render(NotFoundComponent);
4877
- const html = `<!DOCTYPE html><html><head>${head}</head><body>${body}</body></html>`;
4878
- return new Response(html, {
4879
- headers: { "Content-Type": "text/html" },
4880
- status: 404
4881
- });
4882
- };
4883
- var renderVueNotFound = async (conventionPath) => {
4884
- const { createSSRApp, h: h4 } = await import("vue");
4885
- const { renderToString } = await import("vue/server-renderer");
4886
- const mod = await import(conventionPath);
4887
- const NotFoundComponent = mod.default;
4888
- if (!NotFoundComponent)
4889
- return null;
4890
- const app = createSSRApp({
4891
- render: () => h4(NotFoundComponent)
4892
- });
4893
- const rawBody = await renderToString(app);
4894
- const { styles, body } = unescapeVueStyles(rawBody);
4895
- const html = `<!DOCTYPE html><html><head>${styles}</head><body><div id="root">${body}</div></body></html>`;
4896
- return new Response(html, {
4897
- headers: { "Content-Type": "text/html" },
4898
- status: 404
4899
- });
4900
- };
4901
- var renderAngularNotFound = async (conventionPath) => {
4902
- const mod = await import(conventionPath);
4903
- const renderFn = mod.default;
4904
- if (typeof renderFn !== "function")
4905
- return null;
4906
- const html = renderFn();
4907
- return new Response(html, {
4908
- headers: { "Content-Type": "text/html" },
4909
- status: 404
4910
- });
4911
- };
4912
- var renderHtmlNotFound = async (conventionPath) => {
4913
- const html = await Bun.file(conventionPath).text();
4914
- return new Response(html, {
4915
- headers: { "Content-Type": "text/html" },
4916
- status: 404
4917
- });
4918
- };
4919
- var NOT_FOUND_RENDERERS = {
4920
- angular: renderAngularNotFound,
4921
- ember: renderEmberNotFound,
4922
- html: renderHtmlNotFound,
4923
- react: renderReactNotFound,
4924
- svelte: renderSvelteNotFound,
4925
- vue: renderVueNotFound
4926
- };
4927
- var renderConventionNotFound = async (framework) => {
4928
- const conventionPath = resolveNotFoundConventionPath(framework);
4929
- if (!conventionPath)
4930
- return null;
4931
- const renderer = NOT_FOUND_RENDERERS[framework];
4932
- if (!renderer)
4933
- return null;
4934
- try {
4935
- return await renderer(conventionPath);
4936
- } catch (renderError) {
4937
- logConventionRenderError(framework, "not-found", renderError);
4938
- }
4939
- return null;
4940
- };
4941
- var NOT_FOUND_PRIORITY = [
4942
- "react",
4943
- "svelte",
4944
- "vue",
4945
- "angular",
4946
- "html"
4947
- ];
4948
- var renderFirstNotFound = async () => {
4949
- const renderNext = async (frameworks) => {
4950
- const [framework, ...remaining] = frameworks;
4951
- if (!framework) {
4952
- return null;
4953
- }
4954
- if (!getMap()[framework]?.defaults?.notFound) {
4955
- return renderNext(remaining);
4956
- }
4957
- const response = await renderConventionNotFound(framework);
4958
- if (response) {
4959
- return response;
4960
- }
4961
- return renderNext(remaining);
4962
- };
4963
- return renderNext(NOT_FOUND_PRIORITY);
4964
- };
4965
5010
 
4966
5011
  // src/vue/pageHandler.ts
5012
+ init_resolveConvention();
4967
5013
  var isRecord2 = (value) => typeof value === "object" && value !== null;
4968
5014
  var isGenericVueComponent = (value) => typeof value === "function" || isRecord2(value);
4969
5015
  var readHasIslands = (value) => {
@@ -4982,7 +5028,7 @@ var readHasSpaRoutes = (value) => isRecord2(value) && Array.isArray(value["route
4982
5028
  var readDefaultExport = (value) => isRecord2(value) ? value.default : undefined;
4983
5029
  var resolveCurrentGeneratedVueModulePath = async (pagePath) => {
4984
5030
  const pageDirectory = dirname3(pagePath);
4985
- const expectedPrefix = `${basename2(pagePath, ".js").split(".")[0]}.`;
5031
+ const expectedPrefix = `${basename3(pagePath, ".js").split(".")[0]}.`;
4986
5032
  try {
4987
5033
  const pageEntries = await readdir(pageDirectory, {
4988
5034
  withFileTypes: true
@@ -5039,6 +5085,9 @@ var handleVuePageRequest = async (input) => {
5039
5085
  throw new Error('handleVuePageRequest: `indexPath` is required when `client` is `"auto"` (the default). Pass `client: "none"` to ship a SSR-only page with no client bundle.');
5040
5086
  }
5041
5087
  try {
5088
+ const spaNotFound = await renderSpaNotFound("vue", derivePageName(resolvedPagePath), input.request);
5089
+ if (spaNotFound)
5090
+ return withPageCacheHeaders(spaNotFound, input.request);
5042
5091
  const handlerCallsite = resolvedOptions?.collectStreamingSlots === true ? undefined : getCurrentRouteRegistrationCallsite() ?? captureStreamingSlotWarningCallsite();
5043
5092
  const renderPageResponse = async () => {
5044
5093
  const resolvePageComponent = async () => {
@@ -5608,5 +5657,5 @@ export {
5608
5657
  Image
5609
5658
  };
5610
5659
 
5611
- //# debugId=214220BE4E9490D964756E2164756E21
5660
+ //# debugId=7888FE5416ADF26B64756E2164756E21
5612
5661
  //# sourceMappingURL=index.js.map