@vesk/adapter 0.2.60 → 0.2.62
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/default-pages.d.ts +66 -0
- package/dist/default-pages.d.ts.map +1 -0
- package/dist/default-pages.js +146 -0
- package/dist/dev-server.d.ts.map +1 -1
- package/dist/dev-server.js +3 -2
- package/dist/hmr.d.ts.map +1 -1
- package/dist/hmr.js +2 -1
- package/dist/platform-handler.d.ts.map +1 -1
- package/dist/platform-handler.js +9 -2
- package/dist/prod-server.d.ts.map +1 -1
- package/dist/prod-server.js +4 -3
- package/dist/ssr-function.d.ts.map +1 -1
- package/dist/ssr-function.js +2 -1
- package/package.json +4 -4
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Branded built-in fallback pages.
|
|
3
|
+
*
|
|
4
|
+
* These are the pages a Vesk app gets when it has NOT defined its own
|
|
5
|
+
* `app/not-found.vsk` / `app/error.vsk` (or when rendering one throws). They
|
|
6
|
+
* deliberately mirror the shape of Next.js' built-in 404/500 page — a large
|
|
7
|
+
* status code, a hairline divider, the message — but carry the Vesk design
|
|
8
|
+
* language (light-default monochrome that follows `prefers-color-scheme`, a
|
|
9
|
+
* single rust accent, sharp corners, Space Grotesk / JetBrains Mono with system
|
|
10
|
+
* fallbacks) instead of the generic `<h1>404</h1>` that shipped before.
|
|
11
|
+
*
|
|
12
|
+
* The module is intentionally dependency-free and side-effect-free: the HTML
|
|
13
|
+
* is a plain string, so it can be served by the Node prod server, the dev
|
|
14
|
+
* server, the generated platform (edge) handler, and inlined into generated
|
|
15
|
+
* error bodies — all from this one source of truth.
|
|
16
|
+
*
|
|
17
|
+
* Fonts are NOT fetched here: a fallback page must render instantly and
|
|
18
|
+
* without network access, so the stacks degrade to system fonts gracefully.
|
|
19
|
+
*/
|
|
20
|
+
export interface DefaultPageOptions {
|
|
21
|
+
/** HTTP status shown and set by the caller (404 / 500). */
|
|
22
|
+
status?: number;
|
|
23
|
+
/** Document `<title>`. */
|
|
24
|
+
title?: string;
|
|
25
|
+
/** Short label rendered next to the big status code. */
|
|
26
|
+
message?: string;
|
|
27
|
+
/** The requested path, shown as a muted detail line when present. */
|
|
28
|
+
url?: string;
|
|
29
|
+
/** Primary action target. Pass `null` to omit the button. */
|
|
30
|
+
homeHref?: string | null;
|
|
31
|
+
/** Primary action label. */
|
|
32
|
+
homeLabel?: string;
|
|
33
|
+
/** Extra markup for `<head>` (baked onHead-plugin snippets). */
|
|
34
|
+
headExtra?: string;
|
|
35
|
+
/** Paint the status code in the rust accent (used for 5xx). */
|
|
36
|
+
accentStatus?: boolean;
|
|
37
|
+
}
|
|
38
|
+
export declare function escapeDefaultPageHtml(value: unknown): string;
|
|
39
|
+
/**
|
|
40
|
+
* Render a complete, self-contained HTML document for a built-in fallback page.
|
|
41
|
+
*/
|
|
42
|
+
export declare function renderDefaultPage(opts?: DefaultPageOptions): string;
|
|
43
|
+
/** The built-in 404: matches Next.js' "This page could not be found." shape. */
|
|
44
|
+
export declare function renderDefaultNotFoundPage(opts?: {
|
|
45
|
+
url?: string;
|
|
46
|
+
headExtra?: string;
|
|
47
|
+
}): string;
|
|
48
|
+
/** The built-in 500: never leaks a stack trace; message is opt-in (dev). */
|
|
49
|
+
export declare function renderDefaultErrorPage(opts?: {
|
|
50
|
+
status?: number;
|
|
51
|
+
message?: string;
|
|
52
|
+
url?: string;
|
|
53
|
+
headExtra?: string;
|
|
54
|
+
}): string;
|
|
55
|
+
/**
|
|
56
|
+
* Compact, self-contained error panel for contexts where a full document is
|
|
57
|
+
* wrong — chiefly the generated `__renderErrorBody` fallback, which is injected
|
|
58
|
+
* as the page body *inside* the app's layout chain when `error.vsk` exists but
|
|
59
|
+
* throws mid-render. Inline styles only (no external class dependency) so it
|
|
60
|
+
* survives inside any user layout.
|
|
61
|
+
*/
|
|
62
|
+
export declare function renderDefaultErrorFragment(opts?: {
|
|
63
|
+
status?: number;
|
|
64
|
+
message?: string;
|
|
65
|
+
}): string;
|
|
66
|
+
//# sourceMappingURL=default-pages.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"default-pages.d.ts","sourceRoot":"","sources":["../src/default-pages.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAEH,MAAM,WAAW,kBAAkB;IAClC,2DAA2D;IAC3D,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,0BAA0B;IAC1B,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,wDAAwD;IACxD,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,qEAAqE;IACrE,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,6DAA6D;IAC7D,QAAQ,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACzB,4BAA4B;IAC5B,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,gEAAgE;IAChE,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,+DAA+D;IAC/D,YAAY,CAAC,EAAE,OAAO,CAAC;CACvB;AAED,wBAAgB,qBAAqB,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,CAO5D;AAgDD;;GAEG;AACH,wBAAgB,iBAAiB,CAAC,IAAI,GAAE,kBAAuB,GAAG,MAAM,CAgCvE;AAED,gFAAgF;AAChF,wBAAgB,yBAAyB,CAAC,IAAI,GAAE;IAAE,GAAG,CAAC,EAAE,MAAM,CAAC;IAAC,SAAS,CAAC,EAAE,MAAM,CAAA;CAAO,GAAG,MAAM,CAQjG;AAED,4EAA4E;AAC5E,wBAAgB,sBAAsB,CAAC,IAAI,GAAE;IAAE,MAAM,CAAC,EAAE,MAAM,CAAC;IAAC,OAAO,CAAC,EAAE,MAAM,CAAC;IAAC,GAAG,CAAC,EAAE,MAAM,CAAC;IAAC,SAAS,CAAC,EAAE,MAAM,CAAA;CAAO,GAAG,MAAM,CAWjI;AAED;;;;;;GAMG;AACH,wBAAgB,0BAA0B,CAAC,IAAI,GAAE;IAAE,MAAM,CAAC,EAAE,MAAM,CAAC;IAAC,OAAO,CAAC,EAAE,MAAM,CAAA;CAAO,GAAG,MAAM,CASnG"}
|
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Branded built-in fallback pages.
|
|
3
|
+
*
|
|
4
|
+
* These are the pages a Vesk app gets when it has NOT defined its own
|
|
5
|
+
* `app/not-found.vsk` / `app/error.vsk` (or when rendering one throws). They
|
|
6
|
+
* deliberately mirror the shape of Next.js' built-in 404/500 page — a large
|
|
7
|
+
* status code, a hairline divider, the message — but carry the Vesk design
|
|
8
|
+
* language (light-default monochrome that follows `prefers-color-scheme`, a
|
|
9
|
+
* single rust accent, sharp corners, Space Grotesk / JetBrains Mono with system
|
|
10
|
+
* fallbacks) instead of the generic `<h1>404</h1>` that shipped before.
|
|
11
|
+
*
|
|
12
|
+
* The module is intentionally dependency-free and side-effect-free: the HTML
|
|
13
|
+
* is a plain string, so it can be served by the Node prod server, the dev
|
|
14
|
+
* server, the generated platform (edge) handler, and inlined into generated
|
|
15
|
+
* error bodies — all from this one source of truth.
|
|
16
|
+
*
|
|
17
|
+
* Fonts are NOT fetched here: a fallback page must render instantly and
|
|
18
|
+
* without network access, so the stacks degrade to system fonts gracefully.
|
|
19
|
+
*/
|
|
20
|
+
export function escapeDefaultPageHtml(value) {
|
|
21
|
+
return String(value ?? '')
|
|
22
|
+
.replace(/&/g, '&')
|
|
23
|
+
.replace(/</g, '<')
|
|
24
|
+
.replace(/>/g, '>')
|
|
25
|
+
.replace(/"/g, '"')
|
|
26
|
+
.replace(/'/g, ''');
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Theme tokens lifted from the vesk-doc `app/global.css` design system. Light is
|
|
30
|
+
* the default (matching the general web default); `prefers-color-scheme: dark`
|
|
31
|
+
* swaps to the inverted band so the page follows the visitor's theme. Kept
|
|
32
|
+
* inline so the page is fully self-contained.
|
|
33
|
+
*/
|
|
34
|
+
const DEFAULT_PAGE_CSS = [
|
|
35
|
+
':root{color-scheme:light;',
|
|
36
|
+
'--vsk-bg:oklch(0.941 0.014 88);',
|
|
37
|
+
'--vsk-fg:oklch(0.185 0.008 62);',
|
|
38
|
+
'--vsk-surface:oklch(0.965 0.012 88);',
|
|
39
|
+
'--vsk-muted:oklch(0.475 0.014 72);',
|
|
40
|
+
'--vsk-accent:oklch(0.560 0.140 42);',
|
|
41
|
+
'--vsk-border:oklch(0.86 0.012 82);',
|
|
42
|
+
'--vsk-border-strong:oklch(0.72 0.014 80);',
|
|
43
|
+
'--vsk-font:"Space Grotesk",ui-sans-serif,system-ui,-apple-system,"Segoe UI",Roboto,Helvetica,Arial,sans-serif;',
|
|
44
|
+
'--vsk-mono:"JetBrains Mono",ui-monospace,SFMono-Regular,Menlo,Consolas,monospace;}',
|
|
45
|
+
'@media (prefers-color-scheme:dark){:root{color-scheme:dark;',
|
|
46
|
+
'--vsk-bg:oklch(0.155 0.006 60);',
|
|
47
|
+
'--vsk-fg:oklch(0.931 0.014 88);',
|
|
48
|
+
'--vsk-surface:oklch(0.196 0.008 70);',
|
|
49
|
+
'--vsk-muted:oklch(0.618 0.016 80);',
|
|
50
|
+
'--vsk-accent:oklch(0.632 0.132 45);',
|
|
51
|
+
'--vsk-border:oklch(0.29 0.009 75);',
|
|
52
|
+
'--vsk-border-strong:oklch(0.40 0.011 75);}}',
|
|
53
|
+
'*{box-sizing:border-box}',
|
|
54
|
+
'html,body{margin:0;min-height:100%}',
|
|
55
|
+
'body{background:var(--vsk-bg);color:var(--vsk-fg);font-family:var(--vsk-font);-webkit-font-smoothing:antialiased;text-rendering:optimizeLegibility}',
|
|
56
|
+
'.vsk-page{min-height:100vh;display:flex;align-items:center;justify-content:center;padding:24px}',
|
|
57
|
+
'.vsk-page__card{width:100%;max-width:540px;border:1px solid var(--vsk-border);background:var(--vsk-surface);padding:clamp(28px,6vw,44px);text-align:center}',
|
|
58
|
+
'@supports (background:color-mix(in oklab,red,red)){.vsk-page__card{background:color-mix(in oklab,var(--vsk-surface) 60%,transparent)}}',
|
|
59
|
+
'.vsk-page__brand{margin:0 0 26px;font-family:var(--vsk-mono);font-size:10px;line-height:1;letter-spacing:.24em;text-transform:uppercase;color:var(--vsk-muted)}',
|
|
60
|
+
'.vsk-page__brand b{color:var(--vsk-fg);font-weight:600}',
|
|
61
|
+
'.vsk-page__row{display:flex;align-items:center;justify-content:center;gap:0;flex-wrap:wrap}',
|
|
62
|
+
'.vsk-page__status{font-size:clamp(34px,9vw,46px);font-weight:600;line-height:1;letter-spacing:-.03em;padding-right:22px;margin-right:22px;border-right:1px solid var(--vsk-border-strong)}',
|
|
63
|
+
'.vsk-page--error .vsk-page__status{color:var(--vsk-accent)}',
|
|
64
|
+
'.vsk-page__msg{font-family:var(--vsk-mono);font-size:13px;line-height:1.5;color:var(--vsk-muted);text-align:left;max-width:270px}',
|
|
65
|
+
'@media (max-width:440px){.vsk-page__row{flex-direction:column}.vsk-page__status{padding:0 0 16px;margin:0 0 16px;border-right:0;border-bottom:1px solid var(--vsk-border-strong)}.vsk-page__msg{text-align:center}}',
|
|
66
|
+
'.vsk-page__detail{margin:20px 0 0;font-family:var(--vsk-mono);font-size:11px;line-height:1.6;color:var(--vsk-muted);word-break:break-all}',
|
|
67
|
+
'.vsk-page__actions{margin-top:30px;display:flex;justify-content:center;gap:10px;flex-wrap:wrap}',
|
|
68
|
+
'.vsk-page__btn{display:inline-block;padding:11px 22px;font-size:13px;font-weight:500;line-height:1;text-decoration:none;border:1px solid var(--vsk-fg);background:var(--vsk-fg);color:var(--vsk-bg);transition:opacity .18s cubic-bezier(.2,0,0,1)}',
|
|
69
|
+
'.vsk-page__btn:hover{opacity:.86}',
|
|
70
|
+
'.vsk-page__btn--ghost{background:transparent;color:var(--vsk-fg);border-color:var(--vsk-border-strong)}',
|
|
71
|
+
'.vsk-page__btn--ghost:hover{background:var(--vsk-fg);color:var(--vsk-bg);border-color:var(--vsk-fg);opacity:1}',
|
|
72
|
+
].join('');
|
|
73
|
+
/**
|
|
74
|
+
* Render a complete, self-contained HTML document for a built-in fallback page.
|
|
75
|
+
*/
|
|
76
|
+
export function renderDefaultPage(opts = {}) {
|
|
77
|
+
const status = opts.status ?? 404;
|
|
78
|
+
const title = escapeDefaultPageHtml(opts.title ?? `${status} — Vesk`);
|
|
79
|
+
const message = escapeDefaultPageHtml(opts.message ?? 'This page could not be found.');
|
|
80
|
+
const url = opts.url ? escapeDefaultPageHtml(opts.url) : '';
|
|
81
|
+
const headExtra = opts.headExtra || '';
|
|
82
|
+
const homeHref = opts.homeHref === undefined ? '/' : opts.homeHref;
|
|
83
|
+
const homeLabel = escapeDefaultPageHtml(opts.homeLabel ?? 'Back to home');
|
|
84
|
+
const variant = `vsk-page${opts.accentStatus ? ' vsk-page--error' : ''}`;
|
|
85
|
+
const action = homeHref === null
|
|
86
|
+
? ''
|
|
87
|
+
: `<a class="vsk-page__btn" href="${escapeDefaultPageHtml(homeHref)}">${homeLabel}</a>`;
|
|
88
|
+
return '<!DOCTYPE html><html lang="en"><head><meta charset="utf-8">' +
|
|
89
|
+
'<meta name="viewport" content="width=device-width, initial-scale=1">' +
|
|
90
|
+
'<meta name="robots" content="noindex">' +
|
|
91
|
+
`<title>${title}</title>` +
|
|
92
|
+
`<style>${DEFAULT_PAGE_CSS}</style>` +
|
|
93
|
+
headExtra +
|
|
94
|
+
'</head><body>' +
|
|
95
|
+
`<main class="${variant}" data-vesk-default-page="${status}">` +
|
|
96
|
+
'<div class="vsk-page__card">' +
|
|
97
|
+
'<p class="vsk-page__brand"><b>Vesk</b> · built-in error page</p>' +
|
|
98
|
+
'<div class="vsk-page__row">' +
|
|
99
|
+
`<span class="vsk-page__status">${status}</span>` +
|
|
100
|
+
`<span class="vsk-page__msg">${message}</span>` +
|
|
101
|
+
'</div>' +
|
|
102
|
+
(url ? `<p class="vsk-page__detail">${url}</p>` : '') +
|
|
103
|
+
(action ? `<div class="vsk-page__actions">${action}</div>` : '') +
|
|
104
|
+
'</div></main>' +
|
|
105
|
+
'</body></html>';
|
|
106
|
+
}
|
|
107
|
+
/** The built-in 404: matches Next.js' "This page could not be found." shape. */
|
|
108
|
+
export function renderDefaultNotFoundPage(opts = {}) {
|
|
109
|
+
return renderDefaultPage({
|
|
110
|
+
status: 404,
|
|
111
|
+
title: '404 — Not Found',
|
|
112
|
+
message: 'This page could not be found.',
|
|
113
|
+
url: opts.url,
|
|
114
|
+
headExtra: opts.headExtra,
|
|
115
|
+
});
|
|
116
|
+
}
|
|
117
|
+
/** The built-in 500: never leaks a stack trace; message is opt-in (dev). */
|
|
118
|
+
export function renderDefaultErrorPage(opts = {}) {
|
|
119
|
+
const status = opts.status ?? 500;
|
|
120
|
+
return renderDefaultPage({
|
|
121
|
+
status,
|
|
122
|
+
title: `${status} — Internal Server Error`,
|
|
123
|
+
message: opts.message || 'Internal Server Error',
|
|
124
|
+
url: opts.url,
|
|
125
|
+
headExtra: opts.headExtra,
|
|
126
|
+
accentStatus: true,
|
|
127
|
+
homeHref: null,
|
|
128
|
+
});
|
|
129
|
+
}
|
|
130
|
+
/**
|
|
131
|
+
* Compact, self-contained error panel for contexts where a full document is
|
|
132
|
+
* wrong — chiefly the generated `__renderErrorBody` fallback, which is injected
|
|
133
|
+
* as the page body *inside* the app's layout chain when `error.vsk` exists but
|
|
134
|
+
* throws mid-render. Inline styles only (no external class dependency) so it
|
|
135
|
+
* survives inside any user layout.
|
|
136
|
+
*/
|
|
137
|
+
export function renderDefaultErrorFragment(opts = {}) {
|
|
138
|
+
const status = opts.status ?? 500;
|
|
139
|
+
const message = escapeDefaultPageHtml(opts.message || 'Internal Server Error');
|
|
140
|
+
return '<div data-vesk-default-error-fragment="' + status + '" style="display:flex;align-items:center;justify-content:center;min-height:60vh;padding:32px">' +
|
|
141
|
+
'<div style="display:flex;flex-direction:column;align-items:center;gap:10px;text-align:center;font-family:ui-monospace,SFMono-Regular,Menlo,Consolas,monospace">' +
|
|
142
|
+
'<div style="display:flex;align-items:center">' +
|
|
143
|
+
'<span style="font-size:24px;font-weight:500;line-height:49px;padding-right:23px;margin-right:20px;border-right:1px solid currentColor;opacity:.85">' + status + '</span>' +
|
|
144
|
+
'<span style="font-size:14px;line-height:49px;opacity:.7">' + message + '</span>' +
|
|
145
|
+
'</div></div></div>';
|
|
146
|
+
}
|
package/dist/dev-server.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dev-server.d.ts","sourceRoot":"","sources":["../src/dev-server.ts"],"names":[],"mappings":"AAEA,OAAO,EAAgB,KAAK,MAAM,EAA6C,MAAM,WAAW,CAAC;AASjG,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"dev-server.d.ts","sourceRoot":"","sources":["../src/dev-server.ts"],"names":[],"mappings":"AAEA,OAAO,EAAgB,KAAK,MAAM,EAA6C,MAAM,WAAW,CAAC;AASjG,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,OAAO,CAAC;AAM7C,OAAO,KAAK,EAAa,gBAAgB,EAAwB,MAAM,yBAAyB,CAAC;AAgBjG;;;;;GAKG;AACH,MAAM,WAAW,WAAW;IAC1B,MAAM,EAAE,IAAI,GAAG,WAAW,GAAG,OAAO,GAAG,MAAM,CAAC;IAC9C,aAAa,EAAE,MAAM,GAAG,IAAI,CAAC;IAC7B,KAAK,EAAE,eAAe,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI,CAAC;IACxD,QAAQ,EAAE,OAAO,CAAC;IAClB,cAAc,EAAE,MAAM,CAAC;IACvB;+EAC2E;IAC3E,gBAAgB,CAAC,EAAE,OAAO,CAAC;CAC5B;AAED,mEAAmE;AACnE,wBAAgB,kBAAkB,IAAI,WAAW,CAEhD;AAuCD,wBAAgB,YAAY,CAAC,QAAQ,EAAE,MAAM,GAAG,KAAK,GAAG;IAAE,MAAM,EAAE,MAAM,CAAA;CAAE,CAIzE;AAkBD,MAAM,WAAW,gBAAgB;IAC/B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CAAC,CAorBvG"}
|
package/dist/dev-server.js
CHANGED
|
@@ -11,6 +11,7 @@ import { buildErrorPayload, createHmrServer } from './hmr';
|
|
|
11
11
|
import * as hmrApi from './hmr';
|
|
12
12
|
import { createDevApiRouter } from './dev-api';
|
|
13
13
|
import { resolveRuntimeErrorPayload, renderDevErrorPage } from './ssr-error';
|
|
14
|
+
import { renderDefaultNotFoundPage, renderDefaultErrorPage } from '@vesk/adapter/src/default-pages';
|
|
14
15
|
import { buildTreeShakenRuntime, runtimeExportNames } from '@vesk/adapter/src/client-bundle';
|
|
15
16
|
import { resolveWithin, installMdReadHook } from '@vesk/adapter/src/paths';
|
|
16
17
|
import { getPluginRecords } from './plugins';
|
|
@@ -381,7 +382,7 @@ export async function startDevServer(appDir, options) {
|
|
|
381
382
|
return injectDevScripts(renderDevErrorPage(payload, { status: 500, url: pathname }));
|
|
382
383
|
}
|
|
383
384
|
catch {
|
|
384
|
-
return
|
|
385
|
+
return injectDevScripts(renderDefaultErrorPage({ message: e instanceof Error ? e.message : undefined, url: pathname }));
|
|
385
386
|
}
|
|
386
387
|
}
|
|
387
388
|
let eventsMod = null;
|
|
@@ -752,7 +753,7 @@ export async function startDevServer(appDir, options) {
|
|
|
752
753
|
}
|
|
753
754
|
}
|
|
754
755
|
res.writeHead(404, { 'Content-Type': 'text/html' });
|
|
755
|
-
res.end(
|
|
756
|
+
res.end(injectDevScripts(renderDefaultNotFoundPage({ url: url.pathname })));
|
|
756
757
|
});
|
|
757
758
|
const hmr = createHmrServer(server, appDir, devDir, componentMap);
|
|
758
759
|
hmrSession = hmr;
|
package/dist/hmr.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"hmr.d.ts","sourceRoot":"","sources":["../src/hmr.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,WAAW,CAAC;
|
|
1
|
+
{"version":3,"file":"hmr.d.ts","sourceRoot":"","sources":["../src/hmr.ts"],"names":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AAM,EAClB,MAAM,EAAE,MAAM,EACd,MAAM,EAAE,MAAM,EACd,YAAY,CAAC,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,GACjC;IACD,SAAS,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,KAAK,IAAI,CAAC;IAClE,gBAAgB,EAAE,CAAC,QAAQ,EAAE,MAAM,GAAG,IAAI,EAAE,WAAW,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,EAAE,SAAS,EAAE,SAAS,EAAE,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IACvH,WAAW,EAAE,MAAM,UAAU,CAAC,OAAO,WAAW,CAAC,CAAC;CACnD,CA6KA"}
|
package/dist/hmr.js
CHANGED
|
@@ -7,6 +7,7 @@ import { buildHmrEvalSnippet } from './client-bundle';
|
|
|
7
7
|
import { resolveComponentName, randomToken } from '@vesk/compiler/src/server-codegen';
|
|
8
8
|
import { resolveErrorFile, persistedStoreSsrCode } from '@vesk/adapter/src/ssr-function';
|
|
9
9
|
import { resolveCssUrls, hasBuiltGlobalCss } from '@vesk/adapter/src/css';
|
|
10
|
+
import { renderDefaultErrorFragment } from '@vesk/adapter/src/default-pages';
|
|
10
11
|
import { isAllowedWsUpgrade } from '@vesk/adapter/src/paths';
|
|
11
12
|
import { parseCompilerError, buildCodeframe } from '@vesk/adapter/src/error-codeframe';
|
|
12
13
|
import { suggestFor } from '@vesk/adapter/src/error-tips';
|
|
@@ -434,7 +435,7 @@ function regenerateSsrFunction(routeNode, appDir, outDir, componentMap, options)
|
|
|
434
435
|
' const result = await renderPage(_errorSrc, _errorComp, props, __componentRegistry, { hydrate: true, cached: _errorCompiled, sourcePath: _errorPath });',
|
|
435
436
|
' return result.body;',
|
|
436
437
|
' } catch {',
|
|
437
|
-
|
|
438
|
+
` return ${JSON.stringify(renderDefaultErrorFragment())};`,
|
|
438
439
|
' }',
|
|
439
440
|
'}',
|
|
440
441
|
].join('\n');
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"platform-handler.d.ts","sourceRoot":"","sources":["../src/platform-handler.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,SAAS,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;
|
|
1
|
+
{"version":3,"file":"platform-handler.d.ts","sourceRoot":"","sources":["../src/platform-handler.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,SAAS,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AASvE,MAAM,WAAW,oBAAoB;IACnC,SAAS,EAAE,SAAS,EAAE,CAAC;IACvB,SAAS,EAAE,YAAY,EAAE,CAAC;IAC1B,gBAAgB,EAAE,MAAM,EAAE,CAAC;IAC3B,aAAa,EAAE,OAAO,CAAC;IACvB,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,iFAAiF;IACjF,MAAM,EAAE,MAAM,CAAC;CAChB;AAED,wBAAgB,SAAS,CAAC,QAAQ,EAAE,MAAM,EAAE,GAAG,MAAM,CAMpD;AAED,wBAAgB,YAAY,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,CAGrD;AAED,wBAAgB,IAAI,CAAC,CAAC,EAAE,MAAM,GAAG,MAAM,CAEtC;AAgBD;;;;;GAKG;AACH,wBAAgB,6BAA6B,CAAC,KAAK,EAAE,oBAAoB,GAAG,MAAM,CAyMjF;AAED,MAAM,WAAW,qBAAqB;IACpC,kEAAkE;IAClE,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,EAAE,MAAM,CAAC;CACf;AAED,wBAAsB,qBAAqB,CAAC,OAAO,EAAE,qBAAqB,GAAG,OAAO,CAAC,IAAI,CAAC,CAsFzF;AAED,MAAM,WAAW,oBAAoB;IACnC,MAAM,EAAE,MAAM,CAAC;IACf,SAAS,EAAE,SAAS,EAAE,CAAC;IACvB,SAAS,EAAE,YAAY,EAAE,CAAC;IAC1B,gBAAgB,EAAE,MAAM,EAAE,CAAC;IAC3B,aAAa,EAAE,OAAO,CAAC;IACvB,SAAS,CAAC,EAAE,OAAO,CAAC;CACrB"}
|
package/dist/platform-handler.js
CHANGED
|
@@ -1,6 +1,11 @@
|
|
|
1
1
|
import { existsSync } from 'node:fs';
|
|
2
2
|
import { resolve, dirname, join } from 'node:path';
|
|
3
3
|
import { fileURLToPath } from 'node:url';
|
|
4
|
+
// Relative (not `@vesk/adapter/src/...`) so the compiled module keeps working
|
|
5
|
+
// when the dist is copied into a registry-style node_modules layout — see
|
|
6
|
+
// platform-handler.test.ts. No other runtime import in this file, so the pack
|
|
7
|
+
// stays standalone.
|
|
8
|
+
import { renderDefaultNotFoundPage } from './default-pages';
|
|
4
9
|
const __dirname = dirname(fileURLToPath(import.meta.url));
|
|
5
10
|
export function routeName(segments) {
|
|
6
11
|
const parts = segments.filter(Boolean).map(s => {
|
|
@@ -65,6 +70,7 @@ export function generatePlatformHandlerSource(input) {
|
|
|
65
70
|
? `const __prerendered = new Set(${JSON.stringify(prerenderedPaths)});\n`
|
|
66
71
|
: 'const __prerendered = new Set();\n';
|
|
67
72
|
const isrCache = 'const __isrCache = new Map();';
|
|
73
|
+
const defaultNotFoundLine = `const __defaultNotFoundHtml = ${JSON.stringify(renderDefaultNotFoundPage())};`;
|
|
68
74
|
const serverStoreLine = hasEvents ? 'const __serverStore = globalThis.__vesk_server_ctx || {};' : '';
|
|
69
75
|
const eventsStartLine = hasEvents ? ' await __eventsStart({ server: null });' : '';
|
|
70
76
|
const eventsRequestLine = hasEvents ? ' await __eventsRequest(mwCtx);' : '';
|
|
@@ -80,6 +86,7 @@ ${mwImport}
|
|
|
80
86
|
${eventsImport}
|
|
81
87
|
${prerenderedList}
|
|
82
88
|
${isrCache}
|
|
89
|
+
${defaultNotFoundLine}
|
|
83
90
|
const __routes = [${routeEntries.join(',\n')}];
|
|
84
91
|
|
|
85
92
|
async function __invokeRoute(route, request) {
|
|
@@ -93,7 +100,7 @@ async function __invokeRoute(route, request) {
|
|
|
93
100
|
});
|
|
94
101
|
}
|
|
95
102
|
if (e && typeof e === 'object' && e.name === 'NotFoundError') {
|
|
96
|
-
return new Response(
|
|
103
|
+
return new Response(__defaultNotFoundHtml, {
|
|
97
104
|
status: 404,
|
|
98
105
|
headers: { 'Content-Type': 'text/html' },
|
|
99
106
|
});
|
|
@@ -220,7 +227,7 @@ ${eventsRequestLine}
|
|
|
220
227
|
return response;
|
|
221
228
|
}
|
|
222
229
|
|
|
223
|
-
return new Response(
|
|
230
|
+
return new Response(__defaultNotFoundHtml, {
|
|
224
231
|
status: 404,
|
|
225
232
|
headers: { 'Content-Type': 'text/html' },
|
|
226
233
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"prod-server.d.ts","sourceRoot":"","sources":["../src/prod-server.ts"],"names":[],"mappings":"AAEA,OAAO,EAA2D,KAAK,MAAM,EAAE,MAAM,WAAW,CAAC;
|
|
1
|
+
{"version":3,"file":"prod-server.d.ts","sourceRoot":"","sources":["../src/prod-server.ts"],"names":[],"mappings":"AAEA,OAAO,EAA2D,KAAK,MAAM,EAAE,MAAM,WAAW,CAAC;AAkDjG,wBAAgB,YAAY,CAAC,QAAQ,EAAE,MAAM,GAAG,KAAK,GAAG;IAAE,MAAM,EAAE,MAAM,CAAA;CAAE,CAIzE;AAkGD,wBAAsB,eAAe,CAAC,MAAM,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE;IAAE,IAAI,CAAC,EAAE,MAAM,CAAC;IAAC,IAAI,CAAC,EAAE,MAAM,CAAC;IAAC,YAAY,CAAC,EAAE,MAAM,CAAA;CAAE,GAAG,OAAO,CAAC,MAAM,CAAC,CAqexI"}
|
package/dist/prod-server.js
CHANGED
|
@@ -10,6 +10,7 @@ import { executeError } from '@vesk/adapter/src/events';
|
|
|
10
10
|
import { resolveWithin, installMdReadHook } from '@vesk/adapter/src/paths';
|
|
11
11
|
import { resolveCssUrls, hasBuiltGlobalCss } from '@vesk/adapter/src/css';
|
|
12
12
|
import { loadVeskConfig } from '@vesk/adapter/src/load-config';
|
|
13
|
+
import { renderDefaultNotFoundPage, renderDefaultErrorPage } from '@vesk/adapter/src/default-pages';
|
|
13
14
|
const __dirname = dirname(fileURLToPath(import.meta.url));
|
|
14
15
|
async function readBody(req, maxBytes = DEFAULT_MAX_BODY_BYTES) {
|
|
15
16
|
const chunks = [];
|
|
@@ -522,7 +523,7 @@ export async function startProdServer(outDir, options) {
|
|
|
522
523
|
}
|
|
523
524
|
if (err.name === 'NotFoundError') {
|
|
524
525
|
res.writeHead(404, { 'Content-Type': 'text/html' });
|
|
525
|
-
res.end(notFoundHtml ||
|
|
526
|
+
res.end(notFoundHtml || renderDefaultNotFoundPage({ url: url.pathname, headExtra: bakedHeadExtra }));
|
|
526
527
|
return;
|
|
527
528
|
}
|
|
528
529
|
console.error('vesk ssr error:', err.message);
|
|
@@ -554,7 +555,7 @@ export async function startProdServer(outDir, options) {
|
|
|
554
555
|
catch { }
|
|
555
556
|
}
|
|
556
557
|
res.writeHead(500, { 'Content-Type': 'text/html' });
|
|
557
|
-
res.end(errorHtml || '
|
|
558
|
+
res.end(errorHtml || renderDefaultErrorPage({ message: process.env.NODE_ENV !== 'production' ? err.message : undefined, url: url.pathname, headExtra: bakedHeadExtra }));
|
|
558
559
|
return;
|
|
559
560
|
}
|
|
560
561
|
}
|
|
@@ -562,7 +563,7 @@ export async function startProdServer(outDir, options) {
|
|
|
562
563
|
}
|
|
563
564
|
}
|
|
564
565
|
res.writeHead(404, { 'Content-Type': 'text/html' });
|
|
565
|
-
res.end(notFoundHtml ||
|
|
566
|
+
res.end(notFoundHtml || renderDefaultNotFoundPage({ url: url.pathname, headExtra: bakedHeadExtra }));
|
|
566
567
|
});
|
|
567
568
|
try {
|
|
568
569
|
await eventsMod?.executeStart?.({ server, port, host });
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ssr-function.d.ts","sourceRoot":"","sources":["../src/ssr-function.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"ssr-function.d.ts","sourceRoot":"","sources":["../src/ssr-function.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,SAAS,EAAkB,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAI7F,wBAAgB,gBAAgB,CAAC,SAAS,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAQjF;AAgED;;;2EAG2E;AAC3E,wBAAgB,qBAAqB,IAAI,MAAM,CA4C9C;AAED,wBAAgB,mBAAmB,CACjC,SAAS,EAAE,SAAS,EACpB,MAAM,EAAE,MAAM,EACd,MAAM,EAAE,MAAM,EACd,YAAY,CAAC,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,EAClC,OAAO,CAAC,EAAE,kBAAkB,GAC3B;IAAE,QAAQ,EAAE,MAAM,CAAC;IAAC,QAAQ,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE,CA4btD"}
|
package/dist/ssr-function.js
CHANGED
|
@@ -2,6 +2,7 @@ import { readFileSync, existsSync } from 'node:fs';
|
|
|
2
2
|
import { resolve, relative, join } from 'node:path';
|
|
3
3
|
import { resolveComponentName, precompileFile } from '@vesk/compiler/src/server-codegen';
|
|
4
4
|
import { resolveCssUrls, hasBuiltGlobalCss } from '@vesk/adapter/src/css';
|
|
5
|
+
import { renderDefaultErrorFragment } from '@vesk/adapter/src/default-pages';
|
|
5
6
|
// Finds the nearest error.vsk walking up from the route's own directory to the
|
|
6
7
|
// app root, mirroring the router's findErrorComponent chain semantics.
|
|
7
8
|
export function resolveErrorFile(sourceDir, appDir) {
|
|
@@ -210,7 +211,7 @@ export function generateSsrFunction(routeNode, appDir, outDir, componentMap, opt
|
|
|
210
211
|
' const result = await renderPage(\'\', _errorComp, props, __componentRegistry, { hydrate: true, cached: _errorCompiled });',
|
|
211
212
|
' return result.body;',
|
|
212
213
|
' } catch {',
|
|
213
|
-
|
|
214
|
+
` return ${JSON.stringify(renderDefaultErrorFragment())};`,
|
|
214
215
|
' }',
|
|
215
216
|
'}',
|
|
216
217
|
'',
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vesk/adapter",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.62",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Vesk adapter — builds deployable .vesk/ output for Deno and Node serverless",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -23,9 +23,9 @@
|
|
|
23
23
|
"sharp": "^0.35.3"
|
|
24
24
|
},
|
|
25
25
|
"dependencies": {
|
|
26
|
-
"@vesk/compiler": "^0.2.
|
|
27
|
-
"@vesk/runtime": "^0.2.
|
|
28
|
-
"@vesk/types": "^0.2.
|
|
26
|
+
"@vesk/compiler": "^0.2.62",
|
|
27
|
+
"@vesk/runtime": "^0.2.62",
|
|
28
|
+
"@vesk/types": "^0.2.62"
|
|
29
29
|
},
|
|
30
30
|
"devDependencies": {
|
|
31
31
|
"@types/ws": "^8.18.1",
|