trpc-nuxt-module 4.1.2 → 4.3.1

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/README.md CHANGED
@@ -77,7 +77,7 @@ const { data } = await $trpc.greeting.useQuery(name);
77
77
 
78
78
  ## <a name="documentation">📖 Documentation</a>
79
79
 
80
- We highly recommend you take a look at the [documentation](https://esposter.com/docs/api/modules/trpc-nuxt-module.html) to level up. How it works, and every upstream `trpc-nuxt` issue it answers, are on the [trpc-nuxt-module docs page](https://esposter.com/docs/trpc-nuxt-module).
80
+ We highly recommend you take a look at the [documentation](https://github.com/Esposter/Esposter/tree/main/openspec/specs/trpc-nuxt-module) to level up. It covers the design and the upstream `trpc-nuxt` issues this module answers.
81
81
 
82
82
  ### Key exports
83
83
 
@@ -0,0 +1,4 @@
1
+ import { serverFetch } from "nitro/app";
2
+ //#region src/models/TrpcServerFetch.d.ts
3
+ export type TrpcServerFetch = typeof serverFetch;
4
+ //#endregion
@@ -1,11 +1,23 @@
1
+ import { useTrpcServerFetch } from "./useTrpcServerFetch.js";
1
2
  import { useRequestEvent } from "nuxt/app";
2
3
  import { checkIsServer } from "@esposter/shared";
3
- import { fetchWithEvent } from "nitro/h3";
4
+ import { fetchWithEvent, getProxyRequestHeaders } from "nitro/h3";
4
5
  //#region src/runtime/client/services/getLinkFetch.ts
5
6
  const getLinkFetch = () => {
6
7
  if (checkIsServer()) {
7
8
  const event = useRequestEvent();
8
- if (event) return (url, options) => fetchWithEvent(event, url, options);
9
+ if (event?.app) return (url, options) => fetchWithEvent(event, url, options);
10
+ if (event) {
11
+ const serverFetchInProcess = useTrpcServerFetch();
12
+ return (url, options) => {
13
+ const headers = new Headers(getProxyRequestHeaders(event, { host: true }));
14
+ for (const [name, value] of new Headers(options?.headers)) headers.set(name, value);
15
+ return serverFetchInProcess(new URL(url, event.url), {
16
+ ...options,
17
+ headers
18
+ }, event.context);
19
+ };
20
+ }
9
21
  }
10
22
  return (input, init) => fetch(new URL(input, window.location.href), init);
11
23
  };
@@ -0,0 +1,4 @@
1
+ import { TrpcServerFetch } from "../../../models/TrpcServerFetch.js";
2
+ //#region src/runtime/client/services/useTrpcServerFetch.d.ts
3
+ export declare const useTrpcServerFetch: () => TrpcServerFetch;
4
+ //#endregion
@@ -0,0 +1,8 @@
1
+ //#region src/runtime/client/services/useTrpcServerFetch.ts
2
+ const useTrpcServerFetch = () => async (resource, init, context) => {
3
+ if (!import.meta.server) throw new TypeError("The in-process tRPC fetch exists on the server only");
4
+ const { serverFetch } = await import("nitro/app");
5
+ return serverFetch(resource, init, context);
6
+ };
7
+ //#endregion
8
+ export { useTrpcServerFetch };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "trpc-nuxt-module",
3
- "version": "4.1.2",
3
+ "version": "4.3.1",
4
4
  "description": "tRPC for Nuxt — a Nuxt module that registers your router's HTTP and WebSocket handlers, fetches through the request event during SSR, and decorates the typed client with useQuery, useMutation and useSubscription over useAsyncData.",
5
5
  "keywords": [
6
6
  "nitro",
@@ -74,41 +74,36 @@
74
74
  "scripts": {
75
75
  "bench": "vitest bench --run",
76
76
  "build": "tsdown",
77
- "format": "oxfmt",
78
- "format:check": "oxfmt --check",
79
77
  "lint": "eslint .",
80
78
  "lint:fix": "eslint --fix .",
81
79
  "test": "vitest",
82
80
  "typecheck": "tsc"
83
81
  },
84
82
  "dependencies": {
85
- "@esposter/shared": "4.1.2",
83
+ "@esposter/shared": "4.3.1",
86
84
  "@nuxt/kit": "npm:@nuxt/kit-nightly@5x",
87
85
  "@nuxt/schema": "npm:@nuxt/schema-nightly@5x",
88
86
  "ohash": "^2.0.12",
89
87
  "type-fest": "^5.10.0"
90
88
  },
91
89
  "devDependencies": {
92
- "@arethetypeswrong/core": "^0.18.5",
93
- "@esposter/configuration": "4.1.2",
94
- "@esposter/shared-node": "4.1.2",
90
+ "@esposter/configuration": "4.3.1",
91
+ "@esposter/shared-node": "4.3.1",
95
92
  "@nuxt/nitro-server": "npm:@nuxt/nitro-server-nightly@5x",
96
- "@nuxt/test-utils": "^4.3.3",
93
+ "@nuxt/test-utils": "^4.3.4",
97
94
  "@types/node": "^26.6.5",
98
- "happy-dom": "^21.0.1",
99
- "publint": "^0.3.25",
95
+ "happy-dom": "^21.0.4",
100
96
  "superjson": "^2.2.6",
101
97
  "tsdown": "^0.23.1",
102
- "vitest": "^5.0.4",
103
98
  "zod": "^4.6.7"
104
99
  },
105
100
  "peerDependencies": {
106
101
  "@trpc/client": "^11.19.0",
107
102
  "@trpc/server": "^11.19.0",
108
103
  "crossws": "^0.4.15",
109
- "nitro": "npm:nitro-nightly@latest",
104
+ "nitro": "npm:nitro-nightly@3.0.1-20261018-005730-bb9894fe",
110
105
  "nuxt": "npm:nuxt-nightly@5x",
111
106
  "vue": "^3.5.44"
112
107
  },
113
- "gitHead": "144e3f98570b015e3181bfbc6cb70d346ce826b5"
108
+ "gitHead": "777a39636b789c13af33ed13370246ccf6dbaf31"
114
109
  }