@nuxt/nitro-server-nightly 5.0.0-29662277.ceb92e62 → 5.0.0-29662437.89c933ea

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 (46) hide show
  1. package/dist/h3.d.mts +3 -0
  2. package/dist/h3.mjs +3 -0
  3. package/dist/index.d.mts +5 -1
  4. package/dist/index.mjs +23 -2
  5. package/dist/runtime/handlers/error.mjs +16 -38
  6. package/dist/runtime/handlers/island.mjs +50 -101
  7. package/dist/runtime/handlers/renderer.mjs +64 -171
  8. package/dist/runtime/middleware/base-url.mjs +8 -15
  9. package/dist/runtime/middleware/no-ssr.mjs +3 -1
  10. package/dist/runtime/nuxt/src/app/island-hash.mjs +36 -0
  11. package/dist/runtime/plugins/dev-server-logs.mjs +17 -34
  12. package/dist/runtime/templates/error-500.mjs +4 -1
  13. package/dist/runtime/utils/app-config.mjs +7 -16
  14. package/dist/runtime/utils/cache-driver.mjs +33 -0
  15. package/dist/runtime/utils/cache.mjs +18 -22
  16. package/dist/runtime/utils/config.mjs +4 -1
  17. package/dist/runtime/utils/dev.mjs +4 -1
  18. package/dist/runtime/utils/error.mjs +9 -7
  19. package/dist/runtime/utils/paths.mjs +7 -4
  20. package/dist/runtime/utils/renderer/app.mjs +10 -11
  21. package/dist/runtime/utils/renderer/build-files.mjs +26 -51
  22. package/dist/runtime/utils/renderer/inline-styles.mjs +6 -9
  23. package/dist/runtime/utils/renderer/islands.mjs +22 -34
  24. package/dist/runtime/utils/renderer/payload.mjs +17 -19
  25. package/package.json +10 -9
  26. package/dist/runtime/h3-compat.d.mts +0 -6
  27. package/dist/runtime/h3-compat.mjs +0 -8
  28. package/dist/runtime/handlers/error.d.mts +0 -3
  29. package/dist/runtime/handlers/island.d.mts +0 -3
  30. package/dist/runtime/handlers/renderer.d.mts +0 -18
  31. package/dist/runtime/middleware/base-url.d.mts +0 -3
  32. package/dist/runtime/middleware/no-ssr.d.mts +0 -3
  33. package/dist/runtime/plugins/dev-server-logs.d.mts +0 -3
  34. package/dist/runtime/templates/error-500.d.mts +0 -2
  35. package/dist/runtime/utils/app-config.d.mts +0 -3
  36. package/dist/runtime/utils/cache-driver.js +0 -38
  37. package/dist/runtime/utils/cache.d.mts +0 -17
  38. package/dist/runtime/utils/config.d.mts +0 -1
  39. package/dist/runtime/utils/dev.d.mts +0 -3
  40. package/dist/runtime/utils/error.d.mts +0 -6
  41. package/dist/runtime/utils/paths.d.mts +0 -4
  42. package/dist/runtime/utils/renderer/app.d.mts +0 -6
  43. package/dist/runtime/utils/renderer/build-files.d.mts +0 -16
  44. package/dist/runtime/utils/renderer/inline-styles.d.mts +0 -2
  45. package/dist/runtime/utils/renderer/islands.d.mts +0 -9
  46. package/dist/runtime/utils/renderer/payload.d.mts +0 -19
package/dist/h3.d.mts ADDED
@@ -0,0 +1,3 @@
1
+ import { EventHandlerRequest, H3Error, H3Event, HTTPError, createError, deleteCookie, getCookie, getRequestURL, sanitizeStatusCode, setCookie } from "nitro/h3";
2
+ export * from "nitro/h3";
3
+ export { type EventHandlerRequest, H3Error, H3Event, HTTPError, createError, deleteCookie, getCookie, getRequestURL, sanitizeStatusCode, setCookie };
package/dist/h3.mjs ADDED
@@ -0,0 +1,3 @@
1
+ import { H3Error, H3Event, HTTPError, createError, deleteCookie, getCookie, getRequestURL, sanitizeStatusCode, setCookie } from "nitro/h3";
2
+ export * from "nitro/h3";
3
+ export { H3Error, H3Event, HTTPError, createError, deleteCookie, getCookie, getRequestURL, sanitizeStatusCode, setCookie };
package/dist/index.d.mts CHANGED
@@ -4,6 +4,8 @@ import { Nitro, NitroConfig, NitroDevEventHandler, NitroEventHandler, NitroOptio
4
4
  import { LogObject } from "consola";
5
5
  import { NuxtIslandContext, NuxtIslandResponse, NuxtRenderHTMLContext } from "nuxt/app";
6
6
  import { HookResult, RuntimeConfig, TSReference } from "nuxt/schema";
7
+
8
+ //#region src/augments.d.ts
7
9
  declare module "nitro/types" {
8
10
  interface NitroRuntimeConfigApp {
9
11
  baseURL: string;
@@ -16,7 +18,6 @@ declare module "nitro/types" {
16
18
  /** @deprecated Use `noScripts` instead */
17
19
  experimentalNoScripts?: boolean;
18
20
  appMiddleware?: Record<string, boolean>;
19
- appLayout?: string | false;
20
21
  }
21
22
  }
22
23
  declare module "nitro/types" {
@@ -245,7 +246,10 @@ declare module "nuxt/schema" {
245
246
  rules?: NitroRouteConfig;
246
247
  }
247
248
  }
249
+ //#endregion
250
+ //#region src/index.d.ts
248
251
  declare function bundle(nuxt: Nuxt & {
249
252
  _nitro?: Nitro;
250
253
  }): Promise<void>;
254
+ //#endregion
251
255
  export { bundle };
package/dist/index.mjs CHANGED
@@ -18,10 +18,20 @@ import { ImpoundPlugin } from "impound";
18
18
  import { resolveModulePath } from "exsolve";
19
19
  import { runtimeDependencies } from "nitro/meta";
20
20
  import { resolveModuleExportNames } from "mlly";
21
- var version = "5.0.0-29662277.ceb92e62";
21
+ //#region package.json
22
+ var version = "5.0.0-29662437.89c933ea";
23
+ //#endregion
24
+ //#region src/utils.ts
22
25
  function toArray(value) {
23
26
  return Array.isArray(value) ? value : [value];
24
27
  }
28
+ /**
29
+ * Build the `resolve.conditions` array applied to the SSR vite environment.
30
+ *
31
+ * `'import'` is required so that packages whose top-level `exports` map is
32
+ * keyed only by `import`/`require` (notably `vue` and `vue-router`) resolve
33
+ * when the only available copy is nested under `nuxt`'s own `node_modules`.
34
+ */
25
35
  function getSsrResolveConditions(exportConditions) {
26
36
  const conditions = [...exportConditions || []];
27
37
  if (!conditions.includes("import")) conditions.push("import");
@@ -30,9 +40,13 @@ function getSsrResolveConditions(exportConditions) {
30
40
  let _distDir = dirname(fileURLToPath(import.meta.url));
31
41
  if (/(?:chunks|shared)$/.test(_distDir)) _distDir = dirname(_distDir);
32
42
  const distDir = _distDir;
43
+ //#endregion
44
+ //#region ../ui-templates/dist/templates/spa-loading-icon.ts
33
45
  const template = () => {
34
46
  return "<svg xmlns=\"http://www.w3.org/2000/svg\" width=\"80\" fill=\"none\" class=\"nuxt-spa-loading\" viewBox=\"0 0 37 25\"><path d=\"M24.236 22.006h10.742L25.563 5.822l-8.979 14.31a4 4 0 0 1-3.388 1.874H2.978l11.631-20 5.897 10.567\"/></svg><style>.nuxt-spa-loading{position:fixed;top:50%;left:50%;transform:translate(-50%,-50%)}.nuxt-spa-loading>path{fill:none;stroke:#00dc82;stroke-width:4px;stroke-linecap:round;stroke-linejoin:round;stroke-dasharray:128;stroke-dashoffset:128;animation:nuxt-spa-loading-move 3s linear infinite}@keyframes nuxt-spa-loading-move{to{stroke-dashoffset:-128}}</style>";
35
47
  };
48
+ //#endregion
49
+ //#region ../nuxt/src/core/plugins/import-protection.ts
36
50
  function createImportProtectionPatterns(nuxt, options) {
37
51
  const patterns = [];
38
52
  const context = contextFlags[options.context];
@@ -92,6 +106,8 @@ const contextFlags = {
92
106
  "nuxt-app": "the Vue part of your app",
93
107
  "shared": "the #shared directory"
94
108
  };
109
+ //#endregion
110
+ //#region src/templates.ts
95
111
  const nitroSchemaTemplate = {
96
112
  filename: "types/nitro-nuxt.d.ts",
97
113
  async getContents({ nuxt }) {
@@ -143,6 +159,8 @@ declare module 'nitro/types' {
143
159
  function renderReference(ref, baseDir) {
144
160
  return `/// <reference ${"path" in ref ? `path="${isAbsolute(ref.path) ? relative(baseDir, ref.path) : ref.path}"` : `types="${ref.types}"`} />`;
145
161
  }
162
+ //#endregion
163
+ //#region src/imports.ts
146
164
  const v2ImportsPreset = [
147
165
  {
148
166
  from: "nitro/app",
@@ -204,6 +222,8 @@ async function getH3ImportsPreset() {
204
222
  imports: (await resolveModuleExportNames("nitro/h3", { url: import.meta.url })).filter((n) => !/^[A-Z]/.test(n) && n !== "use")
205
223
  };
206
224
  }
225
+ //#endregion
226
+ //#region src/index.ts
207
227
  const logLevelMapReverse = {
208
228
  silent: 0,
209
229
  info: 3,
@@ -252,7 +272,7 @@ async function bundle(nuxt) {
252
272
  });
253
273
  if (nuxt.options.experimental.componentIslands) {
254
274
  const islandHandlerPath = JSON.stringify(resolve(distDir, "runtime/handlers/island"));
255
- const h3Path = JSON.stringify(resolve(distDir, "runtime/h3-compat"));
275
+ const h3Path = JSON.stringify(resolve(distDir, "h3"));
256
276
  const ISLAND_RENDERER_KEY = "#internal/nuxt/island-renderer.mjs";
257
277
  nuxt.options.nitro.virtual ||= {};
258
278
  nuxt.options.nitro.virtual[ISLAND_RENDERER_KEY] = () => {
@@ -921,4 +941,5 @@ async function spaLoadingTemplate(nuxt) {
921
941
  if (nuxt.options.spaLoadingTemplate) logger.warn(`Could not load custom \`spaLoadingTemplate\` path as it does not exist: \`${nuxt.options.spaLoadingTemplate}\`.`);
922
942
  return "";
923
943
  }
944
+ //#endregion
924
945
  export { bundle };
@@ -1,44 +1,33 @@
1
- import { withQuery } from "ufo";
2
- import { serverFetch } from "nitro";
3
1
  import { isJsonRequest } from "../utils/error.mjs";
4
2
  import { generateErrorOverlayHTML } from "../utils/dev.mjs";
5
- export default (async function errorhandler(error, event, { defaultHandler }) {
6
-
3
+ import { withQuery } from "ufo";
4
+ import { serverFetch } from "nitro";
5
+ //#region src/runtime/handlers/error.ts
6
+ var error_default = async function errorhandler(error, event, { defaultHandler }) {
7
7
  const defaultRes = await defaultHandler(error, event, { json: true });
8
-
9
8
  const status = error.status || 500;
10
9
  const headers = new Headers(error.headers);
11
10
  if (isJsonRequest(event) || status === 404 && defaultRes.status === 302) {
12
11
  const setCookies = new Set(headers.getSetCookie());
13
12
  const headerEntries = [new Headers(defaultRes.headers), ..."res" in event ? [event.res.headers.entries()] : []];
14
- for (const entries of headerEntries) {
15
- mergeHeaders(headers, entries, setCookies);
16
- }
13
+ for (const entries of headerEntries) mergeHeaders(headers, entries, setCookies);
17
14
  return new Response(typeof defaultRes.body === "string" ? defaultRes.body : JSON.stringify(defaultRes.body, null, 2), {
18
15
  headers,
19
16
  status: defaultRes.status,
20
17
  statusText: defaultRes.statusText
21
18
  });
22
19
  }
23
- if (import.meta.dev && defaultRes.body && typeof defaultRes.body !== "string" && Array.isArray(defaultRes.body.stack)) {
24
-
25
- defaultRes.body.stack = defaultRes.body.stack.join("\n");
26
- }
20
+ if (import.meta.dev && defaultRes.body && typeof defaultRes.body !== "string" && Array.isArray(defaultRes.body.stack)) defaultRes.body.stack = defaultRes.body.stack.join("\n");
27
21
  const errorObject = defaultRes.body || {};
28
-
29
22
  errorObject.data ??= error.data;
30
23
  errorObject.url = event.req.url;
31
-
32
-
33
- mergeHeaders(headers, new Headers(defaultRes.headers), new Set(), IGNORED_ERROR_HEADERS);
34
-
24
+ mergeHeaders(headers, new Headers(defaultRes.headers), /* @__PURE__ */ new Set(), IGNORED_ERROR_HEADERS);
35
25
  const isRenderingError = event.url?.pathname.startsWith("/__nuxt_error") || !!event.context.nuxt?.["~rendering-error"];
36
26
  if (!isRenderingError) {
37
27
  const eventContext = event.context;
38
28
  eventContext.nuxt ||= {};
39
29
  eventContext.nuxt["~rendering-error"] = true;
40
30
  }
41
-
42
31
  const res = !isRenderingError && await serverFetch(withQuery("/__nuxt_error", errorObject), {
43
32
  headers: event.req.headers,
44
33
  redirect: "manual"
@@ -46,13 +35,9 @@ export default (async function errorhandler(error, event, { defaultHandler }) {
46
35
  "~internal": true,
47
36
  "~rendering-error": true
48
37
  } }).catch(() => null);
49
-
50
38
  if (!res) {
51
- const { template } = await import("../templates/error-500");
52
- if (import.meta.dev) {
53
-
54
- errorObject.description = errorObject.message;
55
- }
39
+ const { template } = await import("../templates/error-500.mjs");
40
+ if (import.meta.dev) errorObject.description = errorObject.message;
56
41
  headers.set("Content-Type", "text/html;charset=UTF-8");
57
42
  return new Response(template(errorObject), {
58
43
  headers,
@@ -63,36 +48,29 @@ export default (async function errorhandler(error, event, { defaultHandler }) {
63
48
  let html = await res.text();
64
49
  if (import.meta.dev && !import.meta.test && typeof html === "string") {
65
50
  const prettyResponse = await defaultHandler(error, event, { json: false });
66
- if (typeof prettyResponse.body === "string") {
67
- html = html.replace("</body>", `${generateErrorOverlayHTML(prettyResponse.body, { startMinimized: 300 <= error.status && error.status < 500 })}</body>`);
68
- }
51
+ if (typeof prettyResponse.body === "string") html = html.replace("</body>", `${generateErrorOverlayHTML(prettyResponse.body, { startMinimized: 300 <= error.status && error.status < 500 })}</body>`);
69
52
  }
70
53
  const setCookies = new Set(headers.getSetCookie());
71
54
  mergeHeaders(headers, res.headers, setCookies);
72
- if ("res" in event) {
73
- mergeHeaders(headers, event.res.headers, setCookies);
74
- }
55
+ if ("res" in event) mergeHeaders(headers, event.res.headers, setCookies);
75
56
  return new Response(html, {
76
57
  headers,
77
58
  status: res.status && res.status !== 200 ? res.status : defaultRes.status,
78
59
  statusText: res.statusText || defaultRes.statusText
79
60
  });
80
- });
81
-
61
+ };
82
62
  const IGNORED_ERROR_HEADERS = new Set(["content-type", "content-security-policy"]);
83
63
  function mergeHeaders(target, overrides, setCookies, ignore) {
84
64
  for (const [name, value] of overrides) {
85
- if (ignore?.has(name)) {
86
- continue;
87
- }
65
+ if (ignore?.has(name)) continue;
88
66
  if (name === "set-cookie") {
89
67
  if (!setCookies.has(value)) {
90
68
  setCookies.add(value);
91
69
  target.append(name, value);
92
70
  }
93
- } else {
94
- target.set(name, value);
95
- }
71
+ } else target.set(name, value);
96
72
  }
97
73
  return target;
98
74
  }
75
+ //#endregion
76
+ export { error_default as default };
@@ -1,23 +1,22 @@
1
- import { useNitroHooks } from "nitro/app";
2
- import { destr } from "destr";
3
- import { HTTPError, defineEventHandler, getQuery, readBody } from "nitro/h3";
4
- import { resolveUnrefHeadInput } from "@unhead/vue";
5
- import { getRequestDependencies } from "vue-bundle-renderer/runtime";
6
- import { getQuery as getURLQuery } from "ufo";
7
- import { computeIslandHash, filterIslandProps } from "#app/island-hash";
1
+ import { computeIslandHash, filterIslandProps } from "../nuxt/src/app/island-hash.mjs";
8
2
  import { islandCache, islandPropCache } from "../utils/cache.mjs";
9
3
  import { createSSRContext } from "../utils/renderer/app.mjs";
10
4
  import { getSSRRenderer } from "../utils/renderer/build-files.mjs";
11
5
  import { renderInlineStyles } from "../utils/renderer/inline-styles.mjs";
12
6
  import { getClientIslandResponse, getServerComponentHTML, getSlotIslandResponse } from "../utils/renderer/islands.mjs";
7
+ import { getQuery } from "ufo";
8
+ import { useNitroHooks } from "nitro/app";
9
+ import { destr } from "destr";
10
+ import { HTTPError, defineEventHandler, getQuery as getQuery$1, readBody } from "nitro/h3";
11
+ import { resolveUnrefHeadInput } from "@unhead/vue";
12
+ import { getRequestDependencies } from "vue-bundle-renderer/runtime";
13
+ //#region src/runtime/handlers/island.ts
13
14
  const ISLAND_SUFFIX_RE = /\.json(?:\?.*)?$/;
14
15
  const handler = defineEventHandler(async (event) => {
15
16
  event.res.headers.set("content-type", "application/json;charset=utf-8");
16
17
  event.res.headers.set("x-powered-by", "Nuxt");
17
18
  const islandPath = event.url.pathname;
18
- if (import.meta.prerender && await islandCache.hasItem(islandPath)) {
19
- return islandCache.getItem(islandPath);
20
- }
19
+ if (import.meta.prerender && await islandCache.hasItem(islandPath)) return islandCache.getItem(islandPath);
21
20
  const islandContext = await getIslandContext(event);
22
21
  const ssrContext = {
23
22
  ...createSSRContext(event),
@@ -25,72 +24,45 @@ const handler = defineEventHandler(async (event) => {
25
24
  noSSR: false,
26
25
  url: islandContext.url
27
26
  };
28
-
29
27
  const renderer = await getSSRRenderer();
30
28
  const renderResult = await renderer.renderToString(ssrContext).catch(async (err) => {
31
- if (ssrContext["~renderResponse"] && err?.message === "skipping render") {
32
- return {};
33
- }
29
+ if (ssrContext["~renderResponse"] && err?.message === "skipping render") return {};
34
30
  await ssrContext.nuxt?.hooks.callHook("app:error", err);
35
31
  throw err;
36
32
  });
37
-
38
-
39
33
  await ssrContext.nuxt?.hooks.callHook("app:rendered", {
40
34
  ssrContext,
41
35
  renderResult
42
36
  });
43
37
  if (ssrContext["~renderResponse"]) {
44
38
  const response = ssrContext["~renderResponse"];
45
- if (response.status && response.status >= 400) {
46
- throw new HTTPError({
47
- status: response.status,
48
- statusText: response.statusText
49
- });
50
- }
39
+ if (response.status && response.status >= 400) throw new HTTPError({
40
+ status: response.status,
41
+ statusText: response.statusText
42
+ });
51
43
  return returnIslandResponse(event, response);
52
44
  }
53
-
54
- if (ssrContext.payload?.error) {
55
- throw ssrContext.payload.error;
56
- }
45
+ if (ssrContext.payload?.error) throw ssrContext.payload.error;
57
46
  const inlinedStyles = await renderInlineStyles(ssrContext.modules ?? []);
58
- if (inlinedStyles.length) {
59
- ssrContext.head.push({ style: inlinedStyles });
60
- }
47
+ if (inlinedStyles.length) ssrContext.head.push({ style: inlinedStyles });
61
48
  if (import.meta.dev) {
62
49
  const { styles } = getRequestDependencies(ssrContext, renderer.rendererContext);
63
50
  const link = [];
64
51
  for (const resource of Object.values(styles)) {
65
-
66
- if ("inline" in getURLQuery(resource.file)) {
67
- continue;
68
- }
69
-
70
-
71
- if (resource.file.includes("scoped") && !resource.file.includes("pages/")) {
72
- link.push({
73
- rel: "stylesheet",
74
- href: renderer.rendererContext.buildAssetsURL(resource.file),
75
- crossorigin: ""
76
- });
77
- }
78
- }
79
- if (link.length) {
80
- ssrContext.head.push({ link });
52
+ if ("inline" in getQuery(resource.file)) continue;
53
+ if (resource.file.includes("scoped") && !resource.file.includes("pages/")) link.push({
54
+ rel: "stylesheet",
55
+ href: renderer.rendererContext.buildAssetsURL(resource.file),
56
+ crossorigin: ""
57
+ });
81
58
  }
59
+ if (link.length) ssrContext.head.push({ link });
82
60
  }
83
61
  const islandHead = {};
84
- for (const entry of ssrContext.head.entries.values()) {
85
-
86
- for (const [key, value] of Object.entries(resolveUnrefHeadInput(entry.input))) {
87
- const currentValue = islandHead[key];
88
- if (Array.isArray(currentValue)) {
89
- currentValue.push(...value);
90
- } else {
91
- islandHead[key] = value;
92
- }
93
- }
62
+ for (const entry of ssrContext.head.entries.values()) for (const [key, value] of Object.entries(resolveUnrefHeadInput(entry.input))) {
63
+ const currentValue = islandHead[key];
64
+ if (Array.isArray(currentValue)) currentValue.push(...value);
65
+ else islandHead[key] = value;
94
66
  }
95
67
  const islandResponse = {
96
68
  id: islandContext.id,
@@ -110,17 +82,10 @@ const handler = defineEventHandler(async (event) => {
110
82
  }
111
83
  return islandResponse;
112
84
  });
113
- export default handler;
114
85
  function returnIslandResponse(event, response) {
115
- for (const header in response.headers || {}) {
116
- event.res.headers.set(header, response.headers[header]);
117
- }
118
- if (response.status) {
119
- event.res.status = response.status;
120
- }
121
- if (response.statusText) {
122
- event.res.statusText = response.statusText;
123
- }
86
+ for (const header in response.headers || {}) event.res.headers.set(header, response.headers[header]);
87
+ if (response.status) event.res.status = response.status;
88
+ if (response.statusText) event.res.statusText = response.statusText;
124
89
  return response.body;
125
90
  }
126
91
  const ISLAND_PATH_PREFIX = "/__nuxt_island/";
@@ -128,48 +93,30 @@ const VALID_COMPONENT_NAME_RE = /^[a-z][\w.-]*$/i;
128
93
  async function getIslandContext(event) {
129
94
  let url = event.url.pathname + event.url.search + event.url.hash;
130
95
  const islandPath = event.url.pathname;
131
- if (import.meta.prerender && await islandPropCache.hasItem(islandPath)) {
132
-
133
-
134
- url = await islandPropCache.getItem(islandPath);
135
- }
136
- if (!url.startsWith(ISLAND_PATH_PREFIX)) {
137
- throw new HTTPError({
138
- status: 400,
139
- statusText: "Invalid island request path"
140
- });
141
- }
142
- const componentParts = url.substring(ISLAND_PATH_PREFIX.length).replace(ISLAND_SUFFIX_RE, "").split("_");
143
- const hashId = componentParts.length > 1 ? componentParts.pop() : undefined;
96
+ if (import.meta.prerender && await islandPropCache.hasItem(islandPath)) url = await islandPropCache.getItem(islandPath);
97
+ if (!url.startsWith(ISLAND_PATH_PREFIX)) throw new HTTPError({
98
+ status: 400,
99
+ statusText: "Invalid island request path"
100
+ });
101
+ const componentParts = url.substring(15).replace(ISLAND_SUFFIX_RE, "").split("_");
102
+ const hashId = componentParts.length > 1 ? componentParts.pop() : void 0;
144
103
  const componentName = componentParts.join("_");
145
- if (!componentName || !VALID_COMPONENT_NAME_RE.test(componentName)) {
146
- throw new HTTPError({
147
- status: 400,
148
- statusText: "Invalid island component name"
149
- });
150
- }
151
- const rawContext = event.req.method === "GET" ? getQuery(event) : await readBody(event);
104
+ if (!componentName || !VALID_COMPONENT_NAME_RE.test(componentName)) throw new HTTPError({
105
+ status: 400,
106
+ statusText: "Invalid island component name"
107
+ });
108
+ const rawContext = event.req.method === "GET" ? getQuery$1(event) : await readBody(event);
152
109
  const rawProps = destr(rawContext?.props) || {};
153
110
  const filteredProps = filterIslandProps(rawProps);
154
-
155
-
156
111
  const clientContext = {};
157
112
  if (rawContext && typeof rawContext === "object") {
158
- for (const key in rawContext) {
159
- if (key !== "props") {
160
- clientContext[key] = rawContext[key];
161
- }
162
- }
163
- }
164
-
165
-
166
- const expectedHash = computeIslandHash(componentName, filteredProps, clientContext, undefined);
167
- if (!hashId || hashId !== expectedHash) {
168
- throw new HTTPError({
169
- status: 400,
170
- statusText: "Invalid island request hash"
171
- });
113
+ for (const key in rawContext) if (key !== "props") clientContext[key] = rawContext[key];
172
114
  }
115
+ const expectedHash = computeIslandHash(componentName, filteredProps, clientContext, void 0);
116
+ if (!hashId || hashId !== expectedHash) throw new HTTPError({
117
+ status: 400,
118
+ statusText: "Invalid island request hash"
119
+ });
173
120
  return {
174
121
  url: typeof rawContext?.url === "string" ? rawContext.url : "/",
175
122
  id: hashId,
@@ -179,3 +126,5 @@ async function getIslandContext(event) {
179
126
  components: {}
180
127
  };
181
128
  }
129
+ //#endregion
130
+ export { handler as default };