nitropack-nightly 2.11.1-20250305-120252.94a73b50 → 2.11.2-20250305-134511.9f4dffdb
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/core/index.mjs +79 -45
- package/dist/kit/index.d.mts +1 -1
- package/dist/kit/index.d.ts +1 -1
- package/dist/meta/index.d.mts +1 -1
- package/dist/meta/index.d.ts +1 -1
- package/dist/meta/index.mjs +1 -1
- package/dist/runtime/internal/app.mjs +21 -26
- package/dist/shared/{nitro.BSXIveQI.d.mts → nitro.0NUDI83a.d.mts} +1 -0
- package/dist/shared/{nitro.BSXIveQI.d.ts → nitro.0NUDI83a.d.ts} +1 -0
- package/dist/types/index.d.mts +2 -2
- package/dist/types/index.d.ts +2 -2
- package/package.json +1 -1
package/dist/core/index.mjs
CHANGED
|
@@ -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
|
}
|
|
@@ -2824,51 +2903,6 @@ $1`
|
|
|
2824
2903
|
}
|
|
2825
2904
|
}
|
|
2826
2905
|
|
|
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
2906
|
async function prepare(nitro) {
|
|
2873
2907
|
await prepareDir(nitro.options.output.dir);
|
|
2874
2908
|
if (!nitro.options.noPublicDir) {
|
package/dist/kit/index.d.mts
CHANGED
package/dist/kit/index.d.ts
CHANGED
package/dist/meta/index.d.mts
CHANGED
package/dist/meta/index.d.ts
CHANGED
package/dist/meta/index.mjs
CHANGED
|
@@ -2,7 +2,6 @@ import destr from "destr";
|
|
|
2
2
|
import {
|
|
3
3
|
createApp,
|
|
4
4
|
createRouter,
|
|
5
|
-
eventHandler,
|
|
6
5
|
fetchWithEvent,
|
|
7
6
|
isEvent,
|
|
8
7
|
lazyEventHandler,
|
|
@@ -46,6 +45,27 @@ function createNitroApp() {
|
|
|
46
45
|
return errorHandler(error, event);
|
|
47
46
|
},
|
|
48
47
|
onRequest: async (event) => {
|
|
48
|
+
event.context.nitro = event.context.nitro || { errors: [] };
|
|
49
|
+
const envContext = event.node.req?.__unenv__;
|
|
50
|
+
if (envContext) {
|
|
51
|
+
Object.assign(event.context, envContext);
|
|
52
|
+
}
|
|
53
|
+
event.fetch = (req, init) => fetchWithEvent(event, req, init, { fetch: localFetch });
|
|
54
|
+
event.$fetch = (req, init) => fetchWithEvent(event, req, init, {
|
|
55
|
+
fetch: $fetch
|
|
56
|
+
});
|
|
57
|
+
event.waitUntil = (promise) => {
|
|
58
|
+
if (!event.context.nitro._waitUntilPromises) {
|
|
59
|
+
event.context.nitro._waitUntilPromises = [];
|
|
60
|
+
}
|
|
61
|
+
event.context.nitro._waitUntilPromises.push(promise);
|
|
62
|
+
if (envContext?.waitUntil) {
|
|
63
|
+
envContext.waitUntil(promise);
|
|
64
|
+
}
|
|
65
|
+
};
|
|
66
|
+
event.captureError = (error, context) => {
|
|
67
|
+
captureError(error, { event, ...context });
|
|
68
|
+
};
|
|
49
69
|
await nitroApp.hooks.callHook("request", event).catch((error) => {
|
|
50
70
|
captureError(error, { event, tags: ["request"] });
|
|
51
71
|
});
|
|
@@ -83,31 +103,6 @@ function createNitroApp() {
|
|
|
83
103
|
});
|
|
84
104
|
globalThis.$fetch = $fetch;
|
|
85
105
|
h3App.use(createRouteRulesHandler({ localFetch }));
|
|
86
|
-
h3App.use(
|
|
87
|
-
eventHandler((event) => {
|
|
88
|
-
event.context.nitro = event.context.nitro || { errors: [] };
|
|
89
|
-
const envContext = event.node.req?.__unenv__;
|
|
90
|
-
if (envContext) {
|
|
91
|
-
Object.assign(event.context, envContext);
|
|
92
|
-
}
|
|
93
|
-
event.fetch = (req, init) => fetchWithEvent(event, req, init, { fetch: localFetch });
|
|
94
|
-
event.$fetch = (req, init) => fetchWithEvent(event, req, init, {
|
|
95
|
-
fetch: $fetch
|
|
96
|
-
});
|
|
97
|
-
event.waitUntil = (promise) => {
|
|
98
|
-
if (!event.context.nitro._waitUntilPromises) {
|
|
99
|
-
event.context.nitro._waitUntilPromises = [];
|
|
100
|
-
}
|
|
101
|
-
event.context.nitro._waitUntilPromises.push(promise);
|
|
102
|
-
if (envContext?.waitUntil) {
|
|
103
|
-
envContext.waitUntil(promise);
|
|
104
|
-
}
|
|
105
|
-
};
|
|
106
|
-
event.captureError = (error, context) => {
|
|
107
|
-
captureError(error, { event, ...context });
|
|
108
|
-
};
|
|
109
|
-
})
|
|
110
|
-
);
|
|
111
106
|
for (const h of handlers) {
|
|
112
107
|
let handler = h.lazy ? lazyEventHandler(h.handler) : h.handler;
|
|
113
108
|
if (h.middleware || !h.route) {
|
|
@@ -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.
|
package/dist/types/index.d.mts
CHANGED
|
@@ -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.
|
|
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.
|
|
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';
|
package/dist/types/index.d.ts
CHANGED
|
@@ -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.
|
|
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.
|
|
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