nitropack-nightly 2.11.0-20250205-132346.c99b22fd → 2.11.0-20250206-184858.0f7c3eaf

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.
@@ -38,6 +38,7 @@ import { version } from 'nitropack/meta';
38
38
  import { gzipSize } from 'gzip-size';
39
39
  import prettyBytes from 'pretty-bytes';
40
40
  import zlib from 'node:zlib';
41
+ import { walk, parse } from 'ultrahtml';
41
42
  import { Worker } from 'node:worker_threads';
42
43
  import { setResponseHeaders, getRequestURL, setResponseStatus, getResponseHeader, setResponseHeader, getRequestHeader, send, getRequestHeaders, eventHandler, createError, createApp, fromNodeMiddleware, toNodeListener } from 'h3';
43
44
  import { createProxyServer } from 'httpxy';
@@ -1784,7 +1785,6 @@ function isCompressibleMime(mimeType) {
1784
1785
 
1785
1786
  const allowedExtensions = /* @__PURE__ */ new Set(["", ".json"]);
1786
1787
  const linkParents$1 = /* @__PURE__ */ new Map();
1787
- const LINK_REGEX = /(?<=\s)href=(?!&quot;)["']?([^"'>]+)/g;
1788
1788
  const HTML_ENTITIES = {
1789
1789
  "&lt;": "<",
1790
1790
  "&gt;": ">",
@@ -1798,13 +1798,19 @@ function escapeHtml(text) {
1798
1798
  (ch) => HTML_ENTITIES[ch] || ch
1799
1799
  );
1800
1800
  }
1801
- function extractLinks(html, from, res, crawlLinks) {
1801
+ async function extractLinks(html, from, res, crawlLinks) {
1802
1802
  const links = [];
1803
1803
  const _links = [];
1804
1804
  if (crawlLinks) {
1805
- _links.push(
1806
- ...[...html.matchAll(LINK_REGEX)].map((m) => escapeHtml(m[1])).filter((m) => !decodeURIComponent(m).startsWith("#")).filter((link) => allowedExtensions.has(getExtension(link)))
1807
- );
1805
+ await walk(parse(html), (node) => {
1806
+ if (!node.attributes?.href) {
1807
+ return;
1808
+ }
1809
+ const link = escapeHtml(node.attributes.href);
1810
+ if (!decodeURIComponent(link).startsWith("#") && allowedExtensions.has(getExtension(link))) {
1811
+ _links.push(link);
1812
+ }
1813
+ });
1808
1814
  }
1809
1815
  const header = res.headers.get("x-nitro-prerender") || "";
1810
1816
  _links.push(...header.split(",").map((i) => decodeURIComponent(i.trim())));
@@ -2037,7 +2043,7 @@ async function prerender(nitro) {
2037
2043
  _route.skip = true;
2038
2044
  }
2039
2045
  if (!_route.error && (isImplicitHTML || route.endsWith(".html"))) {
2040
- const extractedLinks = extractLinks(
2046
+ const extractedLinks = await extractLinks(
2041
2047
  dataBuff.toString("utf8"),
2042
2048
  route,
2043
2049
  res,
@@ -1,3 +1,3 @@
1
- const version = "2.11.0-20250205-132346.c99b22fd";
1
+ const version = "2.11.0-20250206-184858.0f7c3eaf";
2
2
 
3
3
  export { version };
@@ -1,3 +1,3 @@
1
- const version = "2.11.0-20250205-132346.c99b22fd";
1
+ const version = "2.11.0-20250206-184858.0f7c3eaf";
2
2
 
3
3
  export { version };
@@ -1,3 +1,3 @@
1
- const version = "2.11.0-20250205-132346.c99b22fd";
1
+ const version = "2.11.0-20250206-184858.0f7c3eaf";
2
2
 
3
3
  export { version };
@@ -11,9 +11,9 @@ import {
11
11
  import { createHooks } from "hookable";
12
12
  import { Headers, createFetch } from "ofetch";
13
13
  import {
14
- createCall,
15
- createFetch as createLocalFetch
16
- } from "unenv/runtime/fetch/index";
14
+ fetchNodeRequestHandler,
15
+ callNodeRequestHandler
16
+ } from "node-mock-http";
17
17
  import errorHandler from "#nitro-internal-virtual/error-handler";
18
18
  import { plugins } from "#nitro-internal-virtual/plugins";
19
19
  import { handlers } from "#nitro-internal-virtual/server-handlers";
@@ -64,11 +64,18 @@ function createNitroApp() {
64
64
  const router = createRouter({
65
65
  preemptive: true
66
66
  });
67
- const localCall = createCall(toNodeListener(h3App));
68
- const _localFetch = createLocalFetch(localCall, (u, i) => globalThis.fetch(u, i));
69
- const localFetch = (input, init) => _localFetch(input, init).then(
70
- (response) => normalizeFetchResponse(response)
71
- );
67
+ const nodeHandler = toNodeListener(h3App);
68
+ const localCall = (aRequest) => callNodeRequestHandler(nodeHandler, aRequest);
69
+ const localFetch = (input, init) => {
70
+ if (!input.toString().startsWith("/")) {
71
+ return globalThis.fetch(input, init);
72
+ }
73
+ return fetchNodeRequestHandler(
74
+ nodeHandler,
75
+ input,
76
+ init
77
+ ).then((response) => normalizeFetchResponse(response));
78
+ };
72
79
  const $fetch = createFetch({
73
80
  fetch: localFetch,
74
81
  Headers,
@@ -4,7 +4,7 @@ import { a as NitroConfig, N as NitroModule, b as NitroOptions } from '../shared
4
4
  export { A as AppConfig, C as CacheEntry, c as CacheOptions, d as CachedEventHandlerOptions, e as CompressOptions, g as DatabaseConnectionConfig, h as DatabaseConnectionConfigs, D as DatabaseConnectionName, l as DevServerOptions, I as EsbuildOptions, O as HTTPStatusCode, L as LoadConfigOptions, u as Nitro, y as NitroBuildInfo, q as NitroDevEventHandler, n as NitroDevServer, v as NitroDynamicConfig, r as NitroErrorHandler, p as NitroEventHandler, x as NitroFrameworkInfo, s as NitroHooks, t as NitroModuleInput, k as NitroOpenAPIConfig, E as NitroPreset, F as NitroPresetMeta, Q as NitroRouteConfig, o as NitroRouteMeta, T as NitroRouteRules, j as NitroRuntimeConfig, i as NitroRuntimeConfigApp, w as NitroTypes, m as NitroWorker, J as NodeExternalsOptions, B as PrerenderGenerateRoute, z as PrerenderRoute, P as PublicAssetDir, M as RawOptions, R as ResponseCacheEntry, G as RollupConfig, H as RollupVirtualOptions, S as ServerAssetDir, K as ServerAssetOptions, f as StorageMounts, V as VirtualModule } from '../shared/nitro.BwjZlymJ.mjs';
5
5
  import { Hookable } from 'hookable';
6
6
  import { NitroRuntimeHooks as NitroRuntimeHooks$1 } from 'nitropack';
7
- import { createCall, createFetch } from 'unenv/runtime/fetch/index';
7
+ import { AbstractRequest, AbstractResponse } from 'node-mock-http';
8
8
  import { CaptureError as CaptureError$1, CapturedErrorContext as CapturedErrorContext$1, CacheOptions } from 'nitropack/types';
9
9
  import 'consola';
10
10
  import 'nitropack/presets';
@@ -52,8 +52,8 @@ interface NitroApp {
52
52
  h3App: App;
53
53
  router: Router;
54
54
  hooks: Hookable<NitroRuntimeHooks>;
55
- localCall: ReturnType<typeof createCall>;
56
- localFetch: ReturnType<typeof createFetch>;
55
+ localCall: (aRequest: AbstractRequest) => Promise<AbstractResponse>;
56
+ localFetch: (req: string | URL | Request, init?: RequestInit & AbstractRequest) => Promise<Response>;
57
57
  captureError: CaptureError;
58
58
  }
59
59
  interface NitroAppPlugin {
@@ -4,7 +4,7 @@ import { a as NitroConfig, N as NitroModule, b as NitroOptions } from '../shared
4
4
  export { A as AppConfig, C as CacheEntry, c as CacheOptions, d as CachedEventHandlerOptions, e as CompressOptions, g as DatabaseConnectionConfig, h as DatabaseConnectionConfigs, D as DatabaseConnectionName, l as DevServerOptions, I as EsbuildOptions, O as HTTPStatusCode, L as LoadConfigOptions, u as Nitro, y as NitroBuildInfo, q as NitroDevEventHandler, n as NitroDevServer, v as NitroDynamicConfig, r as NitroErrorHandler, p as NitroEventHandler, x as NitroFrameworkInfo, s as NitroHooks, t as NitroModuleInput, k as NitroOpenAPIConfig, E as NitroPreset, F as NitroPresetMeta, Q as NitroRouteConfig, o as NitroRouteMeta, T as NitroRouteRules, j as NitroRuntimeConfig, i as NitroRuntimeConfigApp, w as NitroTypes, m as NitroWorker, J as NodeExternalsOptions, B as PrerenderGenerateRoute, z as PrerenderRoute, P as PublicAssetDir, M as RawOptions, R as ResponseCacheEntry, G as RollupConfig, H as RollupVirtualOptions, S as ServerAssetDir, K as ServerAssetOptions, f as StorageMounts, V as VirtualModule } from '../shared/nitro.BwjZlymJ.js';
5
5
  import { Hookable } from 'hookable';
6
6
  import { NitroRuntimeHooks as NitroRuntimeHooks$1 } from 'nitropack';
7
- import { createCall, createFetch } from 'unenv/runtime/fetch/index';
7
+ import { AbstractRequest, AbstractResponse } from 'node-mock-http';
8
8
  import { CaptureError as CaptureError$1, CapturedErrorContext as CapturedErrorContext$1, CacheOptions } from 'nitropack/types';
9
9
  import 'consola';
10
10
  import 'nitropack/presets';
@@ -52,8 +52,8 @@ interface NitroApp {
52
52
  h3App: App;
53
53
  router: Router;
54
54
  hooks: Hookable<NitroRuntimeHooks>;
55
- localCall: ReturnType<typeof createCall>;
56
- localFetch: ReturnType<typeof createFetch>;
55
+ localCall: (aRequest: AbstractRequest) => Promise<AbstractResponse>;
56
+ localFetch: (req: string | URL | Request, init?: RequestInit & AbstractRequest) => Promise<Response>;
57
57
  captureError: CaptureError;
58
58
  }
59
59
  interface NitroAppPlugin {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nitropack-nightly",
3
- "version": "2.11.0-20250205-132346.c99b22fd",
3
+ "version": "2.11.0-20250206-184858.0f7c3eaf",
4
4
  "description": "Build and Deploy Universal JavaScript Servers",
5
5
  "repository": "nitrojs/nitro",
6
6
  "license": "MIT",
@@ -142,6 +142,7 @@
142
142
  "mime": "^4.0.6",
143
143
  "mlly": "^1.7.4",
144
144
  "node-fetch-native": "^1.6.6",
145
+ "node-mock-http": "^1.0.0",
145
146
  "ofetch": "^1.4.1",
146
147
  "ohash": "^1.1.4",
147
148
  "openapi-typescript": "^7.6.0",
@@ -159,6 +160,7 @@
159
160
  "source-map": "^0.7.4",
160
161
  "std-env": "^3.8.0",
161
162
  "ufo": "^1.5.4",
163
+ "ultrahtml": "^1.5.3",
162
164
  "uncrypto": "^0.1.3",
163
165
  "unctx": "^2.4.1",
164
166
  "unenv": "^1.10.0",