nitropack-nightly 2.11.1-20250305-120920.c9d10320 → 2.11.2-20250305-141326.058819aa

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.
@@ -1925,6 +1925,75 @@ function matchesIgnorePattern(path, pattern) {
1925
1925
  return false;
1926
1926
  }
1927
1927
 
1928
+ const NEGATION_RE = /^(!?)(.*)$/;
1929
+ const PARENT_DIR_GLOB_RE = /!?\.\.\//;
1930
+ async function scanUnprefixedPublicAssets(nitro) {
1931
+ const scannedPaths = [];
1932
+ for (const asset of nitro.options.publicAssets) {
1933
+ if (asset.baseURL && asset.baseURL !== "/" && !asset.fallthrough) {
1934
+ continue;
1935
+ }
1936
+ if (!await isDirectory(asset.dir)) {
1937
+ continue;
1938
+ }
1939
+ const includePatterns = getIncludePatterns(nitro, asset.dir);
1940
+ const publicAssets = await globby(includePatterns, {
1941
+ cwd: asset.dir,
1942
+ absolute: false,
1943
+ dot: true
1944
+ });
1945
+ scannedPaths.push(
1946
+ ...publicAssets.map((file) => join(asset.baseURL || "/", file))
1947
+ );
1948
+ }
1949
+ return scannedPaths;
1950
+ }
1951
+ async function copyPublicAssets(nitro) {
1952
+ if (nitro.options.noPublicDir) {
1953
+ return;
1954
+ }
1955
+ for (const asset of nitro.options.publicAssets) {
1956
+ const srcDir = asset.dir;
1957
+ const dstDir = join(nitro.options.output.publicDir, asset.baseURL);
1958
+ if (await isDirectory(srcDir)) {
1959
+ const includePatterns = getIncludePatterns(nitro, srcDir);
1960
+ const publicAssets = await globby(includePatterns, {
1961
+ cwd: srcDir,
1962
+ absolute: false,
1963
+ dot: true
1964
+ });
1965
+ await Promise.all(
1966
+ publicAssets.map(async (file) => {
1967
+ const src = join(srcDir, file);
1968
+ const dst = join(dstDir, file);
1969
+ if (!existsSync(dst)) {
1970
+ await promises.cp(src, dst);
1971
+ }
1972
+ })
1973
+ );
1974
+ }
1975
+ }
1976
+ if (nitro.options.compressPublicAssets) {
1977
+ await compressPublicAssets(nitro);
1978
+ }
1979
+ nitro.logger.success(
1980
+ "Generated public " + prettyPath(nitro.options.output.publicDir)
1981
+ );
1982
+ }
1983
+ function getIncludePatterns(nitro, srcDir) {
1984
+ return [
1985
+ "**",
1986
+ ...nitro.options.ignore.map((p) => {
1987
+ const [_, negation, pattern] = p.match(NEGATION_RE) || [];
1988
+ return (
1989
+ // Convert ignore to include patterns
1990
+ (negation ? "" : "!") + // Make non-glob patterns relative to publicAssetDir
1991
+ (pattern.startsWith("*") ? pattern : relative(srcDir, resolve(nitro.options.srcDir, pattern)))
1992
+ );
1993
+ })
1994
+ ].filter((p) => !PARENT_DIR_GLOB_RE.test(p));
1995
+ }
1996
+
1928
1997
  const JsonSigRx = /^\s*["[{]|^\s*-?\d{1,16}(\.\d{1,17})?([Ee][+-]?\d+)?\s*$/;
1929
1998
  const linkParents = /* @__PURE__ */ new Map();
1930
1999
  async function prerender(nitro) {
@@ -1982,6 +2051,10 @@ async function prerender(nitro) {
1982
2051
  const failedRoutes = /* @__PURE__ */ new Set();
1983
2052
  const skippedRoutes = /* @__PURE__ */ new Set();
1984
2053
  const displayedLengthWarns = /* @__PURE__ */ new Set();
2054
+ const publicAssetBases = nitro.options.publicAssets.filter(
2055
+ (a) => !!a.baseURL && a.baseURL !== "/" && !a.fallthrough
2056
+ ).map((a) => withTrailingSlash(a.baseURL));
2057
+ const scannedPublicAssets = nitro.options.prerender.ignoreUnprefixedPublicAssets ? new Set(await scanUnprefixedPublicAssets(nitro)) : /* @__PURE__ */ new Set();
1985
2058
  const canPrerender = (route = "/") => {
1986
2059
  if (generatedRoutes.has(route) || skippedRoutes.has(route)) {
1987
2060
  return false;
@@ -1991,6 +2064,12 @@ async function prerender(nitro) {
1991
2064
  return false;
1992
2065
  }
1993
2066
  }
2067
+ if (publicAssetBases.some((base) => route.startsWith(base))) {
2068
+ return false;
2069
+ }
2070
+ if (scannedPublicAssets.has(route)) {
2071
+ return false;
2072
+ }
1994
2073
  if (_getRouteRules(route).prerender === false) {
1995
2074
  return false;
1996
2075
  }
@@ -2201,14 +2280,15 @@ class NodeDevWorker {
2201
2280
  !this.closed && this.#address && this.#proxy && this.#worker
2202
2281
  );
2203
2282
  }
2204
- handleEvent(event) {
2283
+ async handleEvent(event) {
2205
2284
  if (!this.#address || !this.#proxy) {
2206
2285
  throw createError({
2207
2286
  status: 503,
2208
2287
  statusText: "Dev worker is unavailable"
2209
2288
  });
2210
2289
  }
2211
- return this.#proxy.handleEvent(event, { target: this.#address });
2290
+ event._handled = true;
2291
+ await this.#proxy.handleEvent(event, { target: this.#address });
2212
2292
  }
2213
2293
  handleUpgrade(req, socket, head) {
2214
2294
  if (!this.ready) {
@@ -2824,51 +2904,6 @@ $1`
2824
2904
  }
2825
2905
  }
2826
2906
 
2827
- const NEGATION_RE = /^(!?)(.*)$/;
2828
- const PARENT_DIR_GLOB_RE = /!?\.\.\//;
2829
- async function copyPublicAssets(nitro) {
2830
- if (nitro.options.noPublicDir) {
2831
- return;
2832
- }
2833
- for (const asset of nitro.options.publicAssets) {
2834
- const srcDir = asset.dir;
2835
- const dstDir = join(nitro.options.output.publicDir, asset.baseURL);
2836
- if (await isDirectory(srcDir)) {
2837
- const includePatterns = [
2838
- "**",
2839
- ...nitro.options.ignore.map((p) => {
2840
- const [_, negation, pattern] = p.match(NEGATION_RE) || [];
2841
- return (
2842
- // Convert ignore to include patterns
2843
- (negation ? "" : "!") + // Make non-glob patterns relative to publicAssetDir
2844
- (pattern.startsWith("*") ? pattern : relative(srcDir, resolve(nitro.options.srcDir, pattern)))
2845
- );
2846
- })
2847
- ].filter((p) => !PARENT_DIR_GLOB_RE.test(p));
2848
- const publicAssets = await globby(includePatterns, {
2849
- cwd: srcDir,
2850
- absolute: false,
2851
- dot: true
2852
- });
2853
- await Promise.all(
2854
- publicAssets.map(async (file) => {
2855
- const src = join(srcDir, file);
2856
- const dst = join(dstDir, file);
2857
- if (!existsSync(dst)) {
2858
- await promises.cp(src, dst);
2859
- }
2860
- })
2861
- );
2862
- }
2863
- }
2864
- if (nitro.options.compressPublicAssets) {
2865
- await compressPublicAssets(nitro);
2866
- }
2867
- nitro.logger.success(
2868
- "Generated public " + prettyPath(nitro.options.output.publicDir)
2869
- );
2870
- }
2871
-
2872
2907
  async function prepare(nitro) {
2873
2908
  await prepareDir(nitro.options.output.dir);
2874
2909
  if (!nitro.options.noPublicDir) {
@@ -1,5 +1,5 @@
1
1
  import { NitroPreset, NitroPresetMeta, Nitro } from 'nitropack/types';
2
- import { N as NitroModule } from '../shared/nitro.BSXIveQI.mjs';
2
+ import { N as NitroModule } from '../shared/nitro.0NUDI83a.mjs';
3
3
  import 'consola';
4
4
  import 'h3';
5
5
  import 'hookable';
@@ -1,5 +1,5 @@
1
1
  import { NitroPreset, NitroPresetMeta, Nitro } from 'nitropack/types';
2
- import { N as NitroModule } from '../shared/nitro.BSXIveQI.js';
2
+ import { N as NitroModule } from '../shared/nitro.0NUDI83a.js';
3
3
  import 'consola';
4
4
  import 'h3';
5
5
  import 'hookable';
@@ -1,3 +1,3 @@
1
- const version = "2.11.1-20250305-120920.c9d10320";
1
+ const version = "2.11.2-20250305-141326.058819aa";
2
2
 
3
3
  export { version };
@@ -1,3 +1,3 @@
1
- const version = "2.11.1-20250305-120920.c9d10320";
1
+ const version = "2.11.2-20250305-141326.058819aa";
2
2
 
3
3
  export { version };
@@ -1,3 +1,3 @@
1
- const version = "2.11.1-20250305-120920.c9d10320";
1
+ const version = "2.11.2-20250305-141326.058819aa";
2
2
 
3
3
  export { version };
@@ -485,6 +485,7 @@ interface NitroOptions extends PresetOptions {
485
485
  crawlLinks: boolean;
486
486
  failOnError: boolean;
487
487
  ignore: Array<string | RegExp | ((path: string) => undefined | null | boolean)>;
488
+ ignoreUnprefixedPublicAssets: boolean;
488
489
  routes: string[];
489
490
  /**
490
491
  * Amount of retries. Pass Infinity to retry indefinitely.
@@ -485,6 +485,7 @@ interface NitroOptions extends PresetOptions {
485
485
  crawlLinks: boolean;
486
486
  failOnError: boolean;
487
487
  ignore: Array<string | RegExp | ((path: string) => undefined | null | boolean)>;
488
+ ignoreUnprefixedPublicAssets: boolean;
488
489
  routes: string[];
489
490
  /**
490
491
  * Amount of retries. Pass Infinity to retry indefinitely.
@@ -1,7 +1,7 @@
1
1
  import { App, Router, H3Event, RouterMethod } from 'h3';
2
2
  import { FetchRequest, FetchOptions, FetchResponse } from 'ofetch';
3
- import { a as NitroOptions, b as NitroConfig, N as NitroModule } from '../shared/nitro.BSXIveQI.mjs';
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.BSXIveQI.mjs';
3
+ import { a as NitroOptions, b as NitroConfig, N as NitroModule } from '../shared/nitro.0NUDI83a.mjs';
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.0NUDI83a.mjs';
5
5
  import { Hookable } from 'hookable';
6
6
  import { NitroRuntimeHooks as NitroRuntimeHooks$1 } from 'nitropack';
7
7
  import { AbstractRequest, AbstractResponse } from 'node-mock-http';
@@ -1,7 +1,7 @@
1
1
  import { App, Router, H3Event, RouterMethod } from 'h3';
2
2
  import { FetchRequest, FetchOptions, FetchResponse } from 'ofetch';
3
- import { a as NitroOptions, b as NitroConfig, N as NitroModule } from '../shared/nitro.BSXIveQI.js';
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.BSXIveQI.js';
3
+ import { a as NitroOptions, b as NitroConfig, N as NitroModule } from '../shared/nitro.0NUDI83a.js';
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.0NUDI83a.js';
5
5
  import { Hookable } from 'hookable';
6
6
  import { NitroRuntimeHooks as NitroRuntimeHooks$1 } from 'nitropack';
7
7
  import { AbstractRequest, AbstractResponse } from 'node-mock-http';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nitropack-nightly",
3
- "version": "2.11.1-20250305-120920.c9d10320",
3
+ "version": "2.11.2-20250305-141326.058819aa",
4
4
  "description": "Build and Deploy Universal JavaScript Servers",
5
5
  "repository": "nitrojs/nitro",
6
6
  "license": "MIT",