@nuxt/cli-nightly 3.30.0-20251027-201329-c23e915 → 3.30.0-20251028-094234-3afd02b
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.
|
@@ -10,7 +10,7 @@ import { promises } from "node:fs";
|
|
|
10
10
|
import { join, resolve } from "pathe";
|
|
11
11
|
import { FastResponse, FastURL, serve } from "srvx";
|
|
12
12
|
|
|
13
|
-
//#region ../../node_modules/.pnpm/rou3@0.7.
|
|
13
|
+
//#region ../../node_modules/.pnpm/rou3@0.7.9/node_modules/rou3/dist/index.mjs
|
|
14
14
|
const NullProtoObj = /* @__PURE__ */ (() => {
|
|
15
15
|
const e = function() {};
|
|
16
16
|
return e.prototype = Object.create(null), Object.freeze(e.prototype), e;
|
|
@@ -185,34 +185,15 @@ function routeToRegExp(route = "/") {
|
|
|
185
185
|
}
|
|
186
186
|
|
|
187
187
|
//#endregion
|
|
188
|
-
//#region ../../node_modules/.pnpm/h3@2.0.1-rc.
|
|
188
|
+
//#region ../../node_modules/.pnpm/h3@2.0.1-rc.5_crossws@0.4.1_srvx@0.9.1_/node_modules/h3/dist/h3.mjs
|
|
189
189
|
const kEventNS = "h3.internal.event.";
|
|
190
190
|
const kEventRes = /* @__PURE__ */ Symbol.for(`${kEventNS}res`);
|
|
191
191
|
const kEventResHeaders = /* @__PURE__ */ Symbol.for(`${kEventNS}res.headers`);
|
|
192
192
|
var H3Event = class {
|
|
193
|
-
/**
|
|
194
|
-
* Access to the H3 application instance.
|
|
195
|
-
*/
|
|
196
193
|
app;
|
|
197
|
-
/**
|
|
198
|
-
* Incoming HTTP request info.
|
|
199
|
-
*
|
|
200
|
-
* [MDN Reference](https://developer.mozilla.org/en-US/docs/Web/API/Request)
|
|
201
|
-
*/
|
|
202
194
|
req;
|
|
203
|
-
/**
|
|
204
|
-
* Access to the parsed request URL.
|
|
205
|
-
*
|
|
206
|
-
* [MDN Reference](https://developer.mozilla.org/en-US/docs/Web/API/URL)
|
|
207
|
-
*/
|
|
208
195
|
url;
|
|
209
|
-
/**
|
|
210
|
-
* Event context.
|
|
211
|
-
*/
|
|
212
196
|
context;
|
|
213
|
-
/**
|
|
214
|
-
* @internal
|
|
215
|
-
*/
|
|
216
197
|
static __is_event__ = true;
|
|
217
198
|
constructor(req, context, app) {
|
|
218
199
|
this.context = context || req.context || new NullProtoObj();
|
|
@@ -221,22 +202,12 @@ var H3Event = class {
|
|
|
221
202
|
const _url = req._url;
|
|
222
203
|
this.url = _url && _url instanceof URL ? _url : new FastURL(req.url);
|
|
223
204
|
}
|
|
224
|
-
/**
|
|
225
|
-
* Prepared HTTP response.
|
|
226
|
-
*/
|
|
227
205
|
get res() {
|
|
228
206
|
return this[kEventRes] ||= new H3EventResponse();
|
|
229
207
|
}
|
|
230
|
-
/**
|
|
231
|
-
* Access to runtime specific additional context.
|
|
232
|
-
*
|
|
233
|
-
*/
|
|
234
208
|
get runtime() {
|
|
235
209
|
return this.req.runtime;
|
|
236
210
|
}
|
|
237
|
-
/**
|
|
238
|
-
* Tell the runtime about an ongoing operation that shouldn't close until the promise resolves.
|
|
239
|
-
*/
|
|
240
211
|
waitUntil(promise) {
|
|
241
212
|
this.req.waitUntil?.(promise);
|
|
242
213
|
}
|
|
@@ -246,38 +217,15 @@ var H3Event = class {
|
|
|
246
217
|
toJSON() {
|
|
247
218
|
return this.toString();
|
|
248
219
|
}
|
|
249
|
-
/**
|
|
250
|
-
* Access to the raw Node.js req/res objects.
|
|
251
|
-
*
|
|
252
|
-
* @deprecated Use `event.runtime.{node|deno|bun|...}.` instead.
|
|
253
|
-
*/
|
|
254
220
|
get node() {
|
|
255
221
|
return this.req.runtime?.node;
|
|
256
222
|
}
|
|
257
|
-
/**
|
|
258
|
-
* Access to the incoming request headers.
|
|
259
|
-
*
|
|
260
|
-
* @deprecated Use `event.req.headers` instead.
|
|
261
|
-
*
|
|
262
|
-
*/
|
|
263
223
|
get headers() {
|
|
264
224
|
return this.req.headers;
|
|
265
225
|
}
|
|
266
|
-
/**
|
|
267
|
-
* Access to the incoming request url (pathname+search).
|
|
268
|
-
*
|
|
269
|
-
* @deprecated Use `event.url.pathname + event.url.search` instead.
|
|
270
|
-
*
|
|
271
|
-
* Example: `/api/hello?name=world`
|
|
272
|
-
* */
|
|
273
226
|
get path() {
|
|
274
227
|
return this.url.pathname + this.url.search;
|
|
275
228
|
}
|
|
276
|
-
/**
|
|
277
|
-
* Access to the incoming request method.
|
|
278
|
-
*
|
|
279
|
-
* @deprecated Use `event.req.method` instead.
|
|
280
|
-
*/
|
|
281
229
|
get method() {
|
|
282
230
|
return this.req.method;
|
|
283
231
|
}
|
|
@@ -290,82 +238,29 @@ var H3EventResponse = class {
|
|
|
290
238
|
}
|
|
291
239
|
};
|
|
292
240
|
const DISALLOWED_STATUS_CHARS = /[^\u0009\u0020-\u007E]/g;
|
|
293
|
-
/**
|
|
294
|
-
* Make sure the status message is safe to use in a response.
|
|
295
|
-
*
|
|
296
|
-
* Allowed characters: horizontal tabs, spaces or visible ascii characters: https://www.rfc-editor.org/rfc/rfc7230#section-3.1.2
|
|
297
|
-
*/
|
|
298
241
|
function sanitizeStatusMessage(statusMessage = "") {
|
|
299
242
|
return statusMessage.replace(DISALLOWED_STATUS_CHARS, "");
|
|
300
243
|
}
|
|
301
|
-
/**
|
|
302
|
-
* Make sure the status code is a valid HTTP status code.
|
|
303
|
-
*/
|
|
304
244
|
function sanitizeStatusCode(statusCode, defaultStatusCode = 200) {
|
|
305
245
|
if (!statusCode) return defaultStatusCode;
|
|
306
246
|
if (typeof statusCode === "string") statusCode = +statusCode;
|
|
307
247
|
if (statusCode < 100 || statusCode > 599) return defaultStatusCode;
|
|
308
248
|
return statusCode;
|
|
309
249
|
}
|
|
310
|
-
/**
|
|
311
|
-
* HTTPError
|
|
312
|
-
*/
|
|
313
250
|
var HTTPError = class HTTPError$1 extends Error {
|
|
314
251
|
get name() {
|
|
315
252
|
return "HTTPError";
|
|
316
253
|
}
|
|
317
|
-
/**
|
|
318
|
-
* HTTP status code in range [200...599]
|
|
319
|
-
*/
|
|
320
254
|
status;
|
|
321
|
-
/**
|
|
322
|
-
* HTTP status text
|
|
323
|
-
*
|
|
324
|
-
* **NOTE:** This should be short (max 512 to 1024 characters).
|
|
325
|
-
* Allowed characters are tabs, spaces, visible ASCII characters, and extended characters (byte value 128–255).
|
|
326
|
-
*
|
|
327
|
-
* **TIP:** Use `message` for longer error descriptions in JSON body.
|
|
328
|
-
*/
|
|
329
255
|
statusText;
|
|
330
|
-
/**
|
|
331
|
-
* Additional HTTP headers to be sent in error response.
|
|
332
|
-
*/
|
|
333
256
|
headers;
|
|
334
|
-
/**
|
|
335
|
-
* Original error object that caused this error.
|
|
336
|
-
*/
|
|
337
257
|
cause;
|
|
338
|
-
/**
|
|
339
|
-
* Additional data attached in the error JSON body under `data` key.
|
|
340
|
-
*/
|
|
341
258
|
data;
|
|
342
|
-
/**
|
|
343
|
-
* Additional top level JSON body properties to attach in the error JSON body.
|
|
344
|
-
*/
|
|
345
259
|
body;
|
|
346
|
-
/**
|
|
347
|
-
* Flag to indicate that the error was not handled by the application.
|
|
348
|
-
*
|
|
349
|
-
* Unhandled error stack trace, data and message are hidden in non debug mode for security reasons.
|
|
350
|
-
*/
|
|
351
260
|
unhandled;
|
|
352
|
-
/**
|
|
353
|
-
* Check if the input is an instance of HTTPError using its constructor name.
|
|
354
|
-
*
|
|
355
|
-
* It is safer than using `instanceof` because it works across different contexts (e.g., if the error was thrown in a different module).
|
|
356
|
-
*/
|
|
357
261
|
static isError(input) {
|
|
358
262
|
return input instanceof Error && input?.name === "HTTPError";
|
|
359
263
|
}
|
|
360
|
-
/**
|
|
361
|
-
* Create a new HTTPError with the given status code and optional status text and details.
|
|
362
|
-
*
|
|
363
|
-
* @example
|
|
364
|
-
*
|
|
365
|
-
* HTTPError.status(404)
|
|
366
|
-
* HTTPError.status(418, "I'm a teapot")
|
|
367
|
-
* HTTPError.status(403, "Forbidden", { message: "Not authenticated" })
|
|
368
|
-
*/
|
|
369
264
|
static status(status, statusText, details) {
|
|
370
265
|
return new HTTPError$1({
|
|
371
266
|
...details,
|
|
@@ -398,15 +293,9 @@ var HTTPError = class HTTPError$1 extends Error {
|
|
|
398
293
|
this.data = details?.data;
|
|
399
294
|
this.body = details?.body;
|
|
400
295
|
}
|
|
401
|
-
/**
|
|
402
|
-
* @deprecated Use `status`
|
|
403
|
-
*/
|
|
404
296
|
get statusCode() {
|
|
405
297
|
return this.status;
|
|
406
298
|
}
|
|
407
|
-
/**
|
|
408
|
-
* @deprecated Use `statusText`
|
|
409
|
-
*/
|
|
410
299
|
get statusMessage() {
|
|
411
300
|
return this.statusText;
|
|
412
301
|
}
|
|
@@ -577,7 +466,7 @@ function normalizeMiddleware(input, opts = {}) {
|
|
|
577
466
|
};
|
|
578
467
|
}
|
|
579
468
|
function createMatcher(opts) {
|
|
580
|
-
if (!opts.route && !opts.method && !opts.match) return
|
|
469
|
+
if (!opts.route && !opts.method && !opts.match) return;
|
|
581
470
|
const routeMatcher = opts.route ? routeToRegExp(opts.route) : void 0;
|
|
582
471
|
const method = opts.method?.toUpperCase();
|
|
583
472
|
return function _middlewareMatcher(event) {
|
|
@@ -605,18 +494,11 @@ function callMiddleware(event, middleware, handler, index = 0) {
|
|
|
605
494
|
return nextResult;
|
|
606
495
|
};
|
|
607
496
|
const ret = fn(event, next);
|
|
608
|
-
return
|
|
497
|
+
return isUnhandledResponse(ret) ? next() : typeof ret?.then === "function" ? ret.then((resolved) => isUnhandledResponse(resolved) ? next() : resolved) : ret;
|
|
609
498
|
}
|
|
610
|
-
function
|
|
611
|
-
return val === void 0 || val === kNotFound
|
|
499
|
+
function isUnhandledResponse(val) {
|
|
500
|
+
return val === void 0 || val === kNotFound;
|
|
612
501
|
}
|
|
613
|
-
/**
|
|
614
|
-
* Convert input into a web [Request](https://developer.mozilla.org/en-US/docs/Web/API/Request).
|
|
615
|
-
*
|
|
616
|
-
* If input is a relative URL, it will be normalized into a full path based on headers.
|
|
617
|
-
*
|
|
618
|
-
* If input is already a Request and no options are provided, it will be returned as-is.
|
|
619
|
-
*/
|
|
620
502
|
function toRequest(input, options) {
|
|
621
503
|
if (typeof input === "string") {
|
|
622
504
|
let url = input;
|
|
@@ -674,79 +556,80 @@ function toEventHandler(handler) {
|
|
|
674
556
|
};
|
|
675
557
|
}
|
|
676
558
|
const NoHandler = () => kNotFound;
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
"
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
559
|
+
var H3Core = class {
|
|
560
|
+
config;
|
|
561
|
+
"~middleware";
|
|
562
|
+
"~routes" = [];
|
|
563
|
+
constructor(config = {}) {
|
|
564
|
+
this["~middleware"] = [];
|
|
565
|
+
this.config = config;
|
|
566
|
+
this.fetch = this.fetch.bind(this);
|
|
567
|
+
this.handler = this.handler.bind(this);
|
|
568
|
+
}
|
|
569
|
+
fetch(request) {
|
|
570
|
+
return this["~request"](request);
|
|
571
|
+
}
|
|
572
|
+
handler(event) {
|
|
573
|
+
const route = this["~findRoute"](event);
|
|
574
|
+
if (route) {
|
|
575
|
+
event.context.params = route.params;
|
|
576
|
+
event.context.matchedRoute = route.data;
|
|
577
|
+
}
|
|
578
|
+
const routeHandler = route?.data.handler || NoHandler;
|
|
579
|
+
const middleware = this["~getMiddleware"](event, route);
|
|
580
|
+
return middleware.length > 0 ? callMiddleware(event, middleware, routeHandler) : routeHandler(event);
|
|
581
|
+
}
|
|
582
|
+
"~request"(request, context) {
|
|
583
|
+
const event = new H3Event(request, context, this);
|
|
584
|
+
let handlerRes;
|
|
585
|
+
try {
|
|
586
|
+
if (this.config.onRequest) {
|
|
587
|
+
const hookRes = this.config.onRequest(event);
|
|
588
|
+
handlerRes = typeof hookRes?.then === "function" ? hookRes.then(() => this.handler(event)) : this.handler(event);
|
|
589
|
+
} else handlerRes = this.handler(event);
|
|
590
|
+
} catch (error) {
|
|
591
|
+
handlerRes = Promise.reject(error);
|
|
592
|
+
}
|
|
593
|
+
return toResponse(handlerRes, event, this.config);
|
|
594
|
+
}
|
|
595
|
+
"~findRoute"(_event) {}
|
|
596
|
+
"~addRoute"(_route) {
|
|
597
|
+
this["~routes"].push(_route);
|
|
598
|
+
}
|
|
599
|
+
"~getMiddleware"(_event, route) {
|
|
600
|
+
const routeMiddleware = route?.data.middleware;
|
|
601
|
+
const globalMiddleware = this["~middleware"];
|
|
602
|
+
return routeMiddleware ? [...globalMiddleware, ...routeMiddleware] : globalMiddleware;
|
|
603
|
+
}
|
|
604
|
+
};
|
|
605
|
+
const H3 = /* @__PURE__ */ (() => {
|
|
606
|
+
class H3$1 extends H3Core {
|
|
607
|
+
"~rou3";
|
|
693
608
|
constructor(config = {}) {
|
|
694
|
-
|
|
695
|
-
this
|
|
696
|
-
this.fetch = this.fetch.bind(this);
|
|
609
|
+
super(config);
|
|
610
|
+
this["~rou3"] = createRouter();
|
|
697
611
|
this.request = this.request.bind(this);
|
|
698
|
-
this.handler = this.handler.bind(this);
|
|
699
612
|
config.plugins?.forEach((plugin) => plugin(this));
|
|
700
613
|
}
|
|
701
|
-
fetch(request) {
|
|
702
|
-
return this._request(request);
|
|
703
|
-
}
|
|
704
|
-
request(_req, _init, context) {
|
|
705
|
-
return this._request(toRequest(_req, _init), context);
|
|
706
|
-
}
|
|
707
|
-
_request(request, context) {
|
|
708
|
-
const event = new H3Event(request, context, this);
|
|
709
|
-
let handlerRes;
|
|
710
|
-
try {
|
|
711
|
-
if (this.config.onRequest) {
|
|
712
|
-
const hookRes = this.config.onRequest(event);
|
|
713
|
-
handlerRes = typeof hookRes?.then === "function" ? hookRes.then(() => this.handler(event)) : this.handler(event);
|
|
714
|
-
} else handlerRes = this.handler(event);
|
|
715
|
-
} catch (error) {
|
|
716
|
-
handlerRes = Promise.reject(error);
|
|
717
|
-
}
|
|
718
|
-
return toResponse(handlerRes, event, this.config);
|
|
719
|
-
}
|
|
720
|
-
/**
|
|
721
|
-
* Immediately register an H3 plugin.
|
|
722
|
-
*/
|
|
723
614
|
register(plugin) {
|
|
724
615
|
plugin(this);
|
|
725
616
|
return this;
|
|
726
617
|
}
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
this._routes.push(_route);
|
|
730
|
-
}
|
|
731
|
-
_getMiddleware(_event, route) {
|
|
732
|
-
return route?.data.middleware ? [...this._middleware, ...route.data.middleware] : this._middleware;
|
|
733
|
-
}
|
|
734
|
-
handler(event) {
|
|
735
|
-
const route = this._findRoute(event);
|
|
736
|
-
if (route) {
|
|
737
|
-
event.context.params = route.params;
|
|
738
|
-
event.context.matchedRoute = route.data;
|
|
739
|
-
}
|
|
740
|
-
const routeHandler = route?.data.handler || NoHandler;
|
|
741
|
-
const middleware = this._getMiddleware(event, route);
|
|
742
|
-
return middleware.length > 0 ? callMiddleware(event, middleware, routeHandler) : routeHandler(event);
|
|
618
|
+
request(_req, _init, context) {
|
|
619
|
+
return this["~request"](toRequest(_req, _init), context);
|
|
743
620
|
}
|
|
744
621
|
mount(base, input) {
|
|
745
622
|
if ("handler" in input) {
|
|
746
|
-
if (input.
|
|
747
|
-
|
|
623
|
+
if (input["~middleware"].length > 0) this["~middleware"].push((event, next) => {
|
|
624
|
+
const originalPathname = event.url.pathname;
|
|
625
|
+
if (!originalPathname.startsWith(base)) return next();
|
|
626
|
+
event.url.pathname = event.url.pathname.slice(base.length) || "/";
|
|
627
|
+
return callMiddleware(event, input["~middleware"], () => {
|
|
628
|
+
event.url.pathname = originalPathname;
|
|
629
|
+
return next();
|
|
630
|
+
});
|
|
748
631
|
});
|
|
749
|
-
for (const r of input
|
|
632
|
+
for (const r of input["~routes"]) this["~addRoute"]({
|
|
750
633
|
...r,
|
|
751
634
|
route: base + r.route
|
|
752
635
|
});
|
|
@@ -760,13 +643,10 @@ const H3Core = /* @__PURE__ */ (() => {
|
|
|
760
643
|
}
|
|
761
644
|
return this;
|
|
762
645
|
}
|
|
763
|
-
all(route, handler, opts) {
|
|
764
|
-
return this.on("", route, handler, opts);
|
|
765
|
-
}
|
|
766
646
|
on(method, route, handler, opts) {
|
|
767
647
|
const _method = (method || "").toUpperCase();
|
|
768
648
|
route = new URL(route, "http://_").pathname;
|
|
769
|
-
this
|
|
649
|
+
this["~addRoute"]({
|
|
770
650
|
method: _method,
|
|
771
651
|
route,
|
|
772
652
|
handler: toEventHandler(handler),
|
|
@@ -778,8 +658,15 @@ const H3Core = /* @__PURE__ */ (() => {
|
|
|
778
658
|
});
|
|
779
659
|
return this;
|
|
780
660
|
}
|
|
781
|
-
|
|
782
|
-
return
|
|
661
|
+
all(route, handler, opts) {
|
|
662
|
+
return this.on("", route, handler, opts);
|
|
663
|
+
}
|
|
664
|
+
"~findRoute"(_event) {
|
|
665
|
+
return findRoute(this["~rou3"], _event.req.method, _event.url.pathname);
|
|
666
|
+
}
|
|
667
|
+
"~addRoute"(_route) {
|
|
668
|
+
addRoute(this["~rou3"], _route.method, _route.route, _route);
|
|
669
|
+
super["~addRoute"](_route);
|
|
783
670
|
}
|
|
784
671
|
use(arg1, arg2, arg3) {
|
|
785
672
|
let route;
|
|
@@ -793,36 +680,28 @@ const H3Core = /* @__PURE__ */ (() => {
|
|
|
793
680
|
fn = arg1;
|
|
794
681
|
opts = arg2;
|
|
795
682
|
}
|
|
796
|
-
this.
|
|
683
|
+
this["~middleware"].push(normalizeMiddleware(fn, {
|
|
797
684
|
...opts,
|
|
798
685
|
route
|
|
799
686
|
}));
|
|
800
687
|
return this;
|
|
801
688
|
}
|
|
802
689
|
}
|
|
803
|
-
for (const method of
|
|
690
|
+
for (const method of [
|
|
691
|
+
"GET",
|
|
692
|
+
"POST",
|
|
693
|
+
"PUT",
|
|
694
|
+
"DELETE",
|
|
695
|
+
"PATCH",
|
|
696
|
+
"HEAD",
|
|
697
|
+
"OPTIONS",
|
|
698
|
+
"CONNECT",
|
|
699
|
+
"TRACE"
|
|
700
|
+
]) H3Core.prototype[method.toLowerCase()] = function(route, handler, opts) {
|
|
804
701
|
return this.on(method, route, handler, opts);
|
|
805
702
|
};
|
|
806
|
-
return
|
|
703
|
+
return H3$1;
|
|
807
704
|
})();
|
|
808
|
-
var H3 = class extends H3Core {
|
|
809
|
-
/** @internal */
|
|
810
|
-
_rou3;
|
|
811
|
-
constructor(config = {}) {
|
|
812
|
-
super(config);
|
|
813
|
-
this._rou3 = createRouter();
|
|
814
|
-
}
|
|
815
|
-
_findRoute(_event) {
|
|
816
|
-
return findRoute(this._rou3, _event.req.method, _event.url.pathname);
|
|
817
|
-
}
|
|
818
|
-
_addRoute(_route) {
|
|
819
|
-
addRoute(this._rou3, _route.method, _route.route, _route);
|
|
820
|
-
super._addRoute(_route);
|
|
821
|
-
}
|
|
822
|
-
_normalizeMiddleware(fn, opts) {
|
|
823
|
-
return normalizeMiddleware(fn, opts);
|
|
824
|
-
}
|
|
825
|
-
};
|
|
826
705
|
const lazyEventHandler = defineLazyEventHandler;
|
|
827
706
|
|
|
828
707
|
//#endregion
|
package/dist/dev/index.d.mts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { HTTPSOptions, ListenOptions, ListenURL, Listener } from "listhen";
|
|
2
2
|
import { IncomingMessage, RequestListener, ServerResponse } from "node:http";
|
|
3
3
|
import EventEmitter from "node:events";
|
|
4
|
-
import { AddressInfo } from "node:net";
|
|
5
4
|
import { DotenvOptions } from "c12";
|
|
6
5
|
import { NuxtConfig } from "@nuxt/schema";
|
|
6
|
+
import { AddressInfo } from "node:net";
|
|
7
7
|
|
|
8
8
|
//#region ../nuxi/src/dev/utils.d.ts
|
|
9
9
|
|