srvx 0.11.12 → 0.11.14

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.
@@ -55,7 +55,8 @@ const FastURL = /* @__PURE__ */ (() => {
55
55
  #searchParams;
56
56
  #pos;
57
57
  constructor(url) {
58
- if (typeof url === "string") this.#href = url;
58
+ if (typeof url === "string") if (url[0] === "/") this.#href = url;
59
+ else this.#url = new NativeURL(url);
59
60
  else if (_needsNormRE.test(url.pathname)) this.#url = new NativeURL(`${url.protocol || "http:"}//${url.host || "localhost"}${url.pathname}${url.search || ""}`);
60
61
  else {
61
62
  this.#protocol = url.protocol;
@@ -1,4 +1,3 @@
1
- import "../_chunks/_utils.mjs";
2
1
  import { r as wrapFetch, t as errorPlugin } from "../_chunks/_plugins.mjs";
3
2
  //#region src/adapters/_aws/utils.ts
4
3
  function awsRequest(event, context) {
@@ -1,4 +1,3 @@
1
- import "../_chunks/_utils.mjs";
2
1
  import { t as FastURL } from "../_chunks/_url.mjs";
3
2
  import { a as resolveTLSOptions, i as resolvePortAndHost, n as fmtURL, r as printListening, t as createWaitUntil } from "../_chunks/_utils2.mjs";
4
3
  import { n as gracefulShutdownPlugin, r as wrapFetch } from "../_chunks/_plugins.mjs";
@@ -1,4 +1,3 @@
1
- import "../_chunks/_utils.mjs";
2
1
  import { r as wrapFetch, t as errorPlugin } from "../_chunks/_plugins.mjs";
3
2
  //#region src/adapters/bunny.ts
4
3
  const FastURL = URL;
@@ -1,4 +1,3 @@
1
- import "../_chunks/_utils.mjs";
2
1
  import { r as wrapFetch, t as errorPlugin } from "../_chunks/_plugins.mjs";
3
2
  //#region src/adapters/cloudflare.ts
4
3
  const FastURL = URL;
@@ -1,4 +1,3 @@
1
- import "../_chunks/_utils.mjs";
2
1
  import { t as FastURL } from "../_chunks/_url.mjs";
3
2
  import { a as resolveTLSOptions, i as resolvePortAndHost, n as fmtURL, r as printListening, t as createWaitUntil } from "../_chunks/_utils2.mjs";
4
3
  import { n as gracefulShutdownPlugin, r as wrapFetch } from "../_chunks/_plugins.mjs";
@@ -1,4 +1,3 @@
1
- import "../_chunks/_utils.mjs";
2
1
  import { t as createWaitUntil } from "../_chunks/_utils2.mjs";
3
2
  import { r as wrapFetch, t as errorPlugin } from "../_chunks/_plugins.mjs";
4
3
  //#region src/adapters/generic.ts
@@ -1,4 +1,3 @@
1
- import "../_chunks/_utils.mjs";
2
1
  import { n as lazyInherit, t as FastURL } from "../_chunks/_url.mjs";
3
2
  import { a as resolveTLSOptions, i as resolvePortAndHost, n as fmtURL, r as printListening, t as createWaitUntil } from "../_chunks/_utils2.mjs";
4
3
  import { n as gracefulShutdownPlugin, r as wrapFetch, t as errorPlugin } from "../_chunks/_plugins.mjs";
@@ -756,6 +755,7 @@ var NodeServer = class {
756
755
  waitUntil;
757
756
  #isSecure;
758
757
  #listeningPromise;
758
+ #listenError;
759
759
  #wait;
760
760
  constructor(options) {
761
761
  this.options = {
@@ -809,16 +809,30 @@ var NodeServer = class {
809
809
  else if (this.#isSecure) server = nodeHTTPS.createServer(this.serveOptions, handler);
810
810
  else server = nodeHTTP.createServer(this.serveOptions, handler);
811
811
  this.node.server = server;
812
- if (!options.manual) this.serve();
812
+ if (!options.manual) this.serve().catch(() => {});
813
813
  }
814
814
  serve() {
815
- if (this.#listeningPromise) return Promise.resolve(this.#listeningPromise).then(() => this);
816
- this.#listeningPromise = new Promise((resolve) => {
817
- this.node.server.listen(this.serveOptions, () => {
815
+ if (this.#listeningPromise) return this.#listeningPromise.then(() => this);
816
+ const server = this.node?.server;
817
+ if (!server) return Promise.reject(/* @__PURE__ */ new Error("Server not initialized"));
818
+ this.#listenError = void 0;
819
+ this.#listeningPromise = new Promise((resolve, reject) => {
820
+ const onError = (error) => {
821
+ server.off("listening", onListening);
822
+ this.#listenError = error;
823
+ this.#listeningPromise = void 0;
824
+ reject(error);
825
+ };
826
+ const onListening = () => {
827
+ server.off("error", onError);
818
828
  printListening(this.options, this.url);
819
829
  resolve();
820
- });
830
+ };
831
+ server.once("error", onError);
832
+ server.once("listening", onListening);
833
+ server.listen(this.serveOptions);
821
834
  });
835
+ return this.#listeningPromise.then(() => this);
822
836
  }
823
837
  get url() {
824
838
  const addr = this.node?.server?.address();
@@ -826,6 +840,7 @@ var NodeServer = class {
826
840
  return typeof addr === "string" ? addr : fmtURL(addr.address, addr.port, this.#isSecure);
827
841
  }
828
842
  ready() {
843
+ if (this.#listenError) return Promise.reject(this.#listenError);
829
844
  return Promise.resolve(this.#listeningPromise).then(() => this);
830
845
  }
831
846
  async close(closeAll) {
@@ -1,4 +1,3 @@
1
- import "../_chunks/_utils.mjs";
2
1
  import { r as wrapFetch, t as errorPlugin } from "../_chunks/_plugins.mjs";
3
2
  //#region src/adapters/service-worker.ts
4
3
  const FastURL = URL;
package/dist/cli.mjs CHANGED
@@ -184,7 +184,7 @@ function getResponseFormat(res) {
184
184
  //#region src/cli/_meta.ts
185
185
  const srvxMeta = {
186
186
  name: "srvx",
187
- version: "0.11.11",
187
+ version: "0.11.14",
188
188
  description: "Universal Server."
189
189
  };
190
190
  //#endregion
package/dist/log.d.mts CHANGED
@@ -2,6 +2,6 @@ import { ServerMiddleware } from "./types.mjs";
2
2
 
3
3
  //#region src/log.d.ts
4
4
  interface LogOptions {}
5
- declare const log: (_options?: LogOptions) => ServerMiddleware;
5
+ declare const log: (options?: LogOptions) => ServerMiddleware;
6
6
  //#endregion
7
7
  export { LogOptions, log };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "srvx",
3
- "version": "0.11.12",
3
+ "version": "0.11.14",
4
4
  "description": "Universal Server.",
5
5
  "homepage": "https://srvx.h3.dev",
6
6
  "license": "MIT",
@@ -59,38 +59,38 @@
59
59
  "vitest": "vitest"
60
60
  },
61
61
  "devDependencies": {
62
- "@cloudflare/workers-types": "^4.20260313.1",
63
- "@hono/node-server": "^1.19.11",
62
+ "@cloudflare/workers-types": "^4.20260401.1",
63
+ "@hono/node-server": "^1.19.12",
64
64
  "@mitata/counters": "^0.0.8",
65
65
  "@mjackson/node-fetch-server": "^0.7.0",
66
66
  "@types/aws-lambda": "^8.10.161",
67
- "@types/bun": "^1.3.10",
67
+ "@types/bun": "^1.3.11",
68
68
  "@types/deno": "^2.5.0",
69
69
  "@types/express": "^5.0.6",
70
70
  "@types/node": "^25.5.0",
71
71
  "@types/node-forge": "^1.3.14",
72
- "@types/serviceworker": "^0.0.193",
73
- "@typescript/native-preview": "^7.0.0-dev.20260315.1",
74
- "@vitest/coverage-v8": "^4.1.0",
72
+ "@types/serviceworker": "^0.0.194",
73
+ "@typescript/native-preview": "^7.0.0-dev.20260401.1",
74
+ "@vitest/coverage-v8": "^4.1.2",
75
75
  "@whatwg-node/server": "^0.10.18",
76
76
  "automd": "^0.4.3",
77
77
  "changelogen": "^0.6.2",
78
78
  "eslint-config-unjs": "^0.6.2",
79
79
  "execa": "^9.6.1",
80
80
  "express": "^5.2.1",
81
- "fastify": "^5.8.2",
81
+ "fastify": "^5.8.4",
82
82
  "get-port-please": "^3.2.0",
83
83
  "mdbox": "^0.1.1",
84
84
  "mitata": "^1.0.34",
85
- "node-forge": "^1.3.3",
85
+ "node-forge": "^1.4.0",
86
86
  "obuild": "^0.4.32",
87
- "oxfmt": "^0.40.0",
88
- "oxlint": "^1.55.0",
89
- "srvx-release": "npm:srvx@^0.11.9",
87
+ "oxfmt": "^0.43.0",
88
+ "oxlint": "^1.58.0",
89
+ "srvx-release": "npm:srvx@^0.11.13",
90
90
  "tslib": "^2.8.1",
91
- "typescript": "^5.9.3",
92
- "undici": "^7.24.3",
93
- "vitest": "^4.1.0"
91
+ "typescript": "^6.0.2",
92
+ "undici": "^7.24.7",
93
+ "vitest": "^4.1.2"
94
94
  },
95
95
  "resolutions": {
96
96
  "srvx": "link:."
@@ -98,5 +98,5 @@
98
98
  "engines": {
99
99
  "node": ">=20.16.0"
100
100
  },
101
- "packageManager": "pnpm@10.32.1"
101
+ "packageManager": "pnpm@10.33.0"
102
102
  }