@trpc/server 11.0.0-rc.377 → 11.0.0-rc.383
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/adapters/next-app-dir/nextAppDirCaller.d.ts.map +1 -1
- package/dist/adapters/next-app-dir/rethrowNextErrors.d.ts.map +1 -1
- package/dist/adapters/next-app-dir/rethrowNextErrors.js +52 -6
- package/dist/adapters/next-app-dir/rethrowNextErrors.mjs +32 -5
- package/dist/bundle-analysis.json +73 -73
- package/dist/unstable-core-do-not-import/utils.d.ts.map +1 -1
- package/dist/unstable-core-do-not-import/utils.js +2 -1
- package/dist/unstable-core-do-not-import/utils.mjs +2 -1
- package/package.json +2 -2
- package/src/adapters/next-app-dir/nextAppDirCaller.ts +1 -0
- package/src/adapters/next-app-dir/rethrowNextErrors.ts +51 -9
- package/src/unstable-core-do-not-import/utils.ts +6 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"nextAppDirCaller.d.ts","sourceRoot":"","sources":["../../../src/adapters/next-app-dir/nextAppDirCaller.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,oBAAoB,CAAC;AAIhE,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,6CAA6C,CAAC;AAGvF,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,oDAAoD,CAAC;AAGzF,OAAO,KAAK,EACV,YAAY,EACZ,QAAQ,EACT,MAAM,yCAAyC,CAAC;AAKjD;;GAEG;AACH,wBAAgB,gBAAgB,CAAC,QAAQ,EAAE,KAAK,EAC9C,MAAM,EAAE,QAAQ,CACd;IACE;;OAEG;IACH,aAAa,CAAC,EAAE,CAAC,IAAI,EAAE;QAAE,IAAI,EAAE,KAAK,CAAA;KAAE,KAAK,MAAM,CAAC;IAClD;;;OAGG;IACH,iBAAiB,CAAC,EAAE,OAAO,CAAC;IAC5B;;OAEG;IACH,OAAO,CAAC,EAAE,CAAC,IAAI,EAAE,mBAAmB,CAAC,QAAQ,CAAC,KAAK,IAAI,CAAC;CACzD,GAAG,qBAAqB,CAAC,QAAQ,EAAE,MAAM,YAAY,CAAC,QAAQ,CAAC,CAAC,CAClE,GACA,cAAc,CAAC,QAAQ,CAAC,
|
|
1
|
+
{"version":3,"file":"nextAppDirCaller.d.ts","sourceRoot":"","sources":["../../../src/adapters/next-app-dir/nextAppDirCaller.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,oBAAoB,CAAC;AAIhE,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,6CAA6C,CAAC;AAGvF,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,oDAAoD,CAAC;AAGzF,OAAO,KAAK,EACV,YAAY,EACZ,QAAQ,EACT,MAAM,yCAAyC,CAAC;AAKjD;;GAEG;AACH,wBAAgB,gBAAgB,CAAC,QAAQ,EAAE,KAAK,EAC9C,MAAM,EAAE,QAAQ,CACd;IACE;;OAEG;IACH,aAAa,CAAC,EAAE,CAAC,IAAI,EAAE;QAAE,IAAI,EAAE,KAAK,CAAA;KAAE,KAAK,MAAM,CAAC;IAClD;;;OAGG;IACH,iBAAiB,CAAC,EAAE,OAAO,CAAC;IAC5B;;OAEG;IACH,OAAO,CAAC,EAAE,CAAC,IAAI,EAAE,mBAAmB,CAAC,QAAQ,CAAC,KAAK,IAAI,CAAC;CACzD,GAAG,qBAAqB,CAAC,QAAQ,EAAE,MAAM,YAAY,CAAC,QAAQ,CAAC,CAAC,CAClE,GACA,cAAc,CAAC,QAAQ,CAAC,CAyF1B"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rethrowNextErrors.d.ts","sourceRoot":"","sources":["../../../src/adapters/next-app-dir/rethrowNextErrors.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"rethrowNextErrors.d.ts","sourceRoot":"","sources":["../../../src/adapters/next-app-dir/rethrowNextErrors.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAyCpD;;GAEG;AACH,eAAO,MAAM,iBAAiB,UAAW,SAAS,SAqBjD,CAAC"}
|
|
@@ -1,21 +1,67 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
4
|
-
var redirect$1 = require('next/dist/client/components/redirect');
|
|
5
|
-
var navigation = require('next/navigation');
|
|
3
|
+
var nextNavigation = require('next/navigation.js');
|
|
6
4
|
var redirect = require('./redirect.js');
|
|
7
5
|
|
|
6
|
+
function _interopNamespaceDefault(e) {
|
|
7
|
+
var n = Object.create(null);
|
|
8
|
+
if (e) {
|
|
9
|
+
Object.keys(e).forEach(function (k) {
|
|
10
|
+
if (k !== 'default') {
|
|
11
|
+
var d = Object.getOwnPropertyDescriptor(e, k);
|
|
12
|
+
Object.defineProperty(n, k, d.get ? d : {
|
|
13
|
+
enumerable: true,
|
|
14
|
+
get: function () { return e[k]; }
|
|
15
|
+
});
|
|
16
|
+
}
|
|
17
|
+
});
|
|
18
|
+
}
|
|
19
|
+
n.default = e;
|
|
20
|
+
return Object.freeze(n);
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
var nextNavigation__namespace = /*#__PURE__*/_interopNamespaceDefault(nextNavigation);
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* @remarks The helpers from `next/dist/client/components/*` has been removed in Next.js 15.
|
|
27
|
+
* Inlining them here instead...
|
|
28
|
+
* @see https://github.com/vercel/next.js/blob/5ae286ffd664e5c76841ed64f6e2da85a0835922/packages/next/src/client/components/redirect.ts#L97-L123
|
|
29
|
+
*/ const REDIRECT_ERROR_CODE = 'NEXT_REDIRECT';
|
|
30
|
+
function isRedirectError(error) {
|
|
31
|
+
if (typeof error !== 'object' || error === null || !('digest' in error) || typeof error.digest !== 'string') {
|
|
32
|
+
return false;
|
|
33
|
+
}
|
|
34
|
+
const [errorCode, type, destination, status] = error.digest.split(';', 4);
|
|
35
|
+
const statusCode = Number(status);
|
|
36
|
+
return errorCode === REDIRECT_ERROR_CODE && (type === 'replace' || type === 'push') && typeof destination === 'string' && !isNaN(statusCode);
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* @remarks The helpers from `next/dist/client/components/*` has been removed in Next.js 15.
|
|
40
|
+
* Inlining them here instead...
|
|
41
|
+
* @see https://github.com/vercel/next.js/blob/5ae286ffd664e5c76841ed64f6e2da85a0835922/packages/next/src/client/components/not-found.ts#L33-L39
|
|
42
|
+
*/ const NOT_FOUND_ERROR_CODE = 'NEXT_NOT_FOUND';
|
|
43
|
+
function isNotFoundError(error) {
|
|
44
|
+
if (typeof error !== 'object' || error === null || !('digest' in error)) {
|
|
45
|
+
return false;
|
|
46
|
+
}
|
|
47
|
+
return error.digest === NOT_FOUND_ERROR_CODE;
|
|
48
|
+
}
|
|
8
49
|
/**
|
|
9
50
|
* Rethrow errors that should be handled by Next.js
|
|
10
51
|
*/ const rethrowNextErrors = (error)=>{
|
|
11
52
|
if (error.code === 'NOT_FOUND') {
|
|
12
|
-
|
|
53
|
+
nextNavigation__namespace.notFound();
|
|
13
54
|
}
|
|
14
55
|
if (error instanceof redirect.TRPCRedirectError) {
|
|
15
|
-
|
|
56
|
+
nextNavigation__namespace.redirect(...error.args);
|
|
16
57
|
}
|
|
17
58
|
const { cause } = error;
|
|
18
|
-
|
|
59
|
+
// Next.js 15 has `unstable_rethrow`. Use that if it exists.
|
|
60
|
+
if ('unstable_rethrow' in nextNavigation__namespace && typeof nextNavigation__namespace.unstable_rethrow === 'function') {
|
|
61
|
+
nextNavigation__namespace.unstable_rethrow(cause);
|
|
62
|
+
}
|
|
63
|
+
// Before Next.js 15, we have to check and rethrow the error manually.
|
|
64
|
+
if (isRedirectError(cause) || isNotFoundError(cause)) {
|
|
19
65
|
throw error.cause;
|
|
20
66
|
}
|
|
21
67
|
};
|
|
@@ -1,18 +1,45 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { isRedirectError } from 'next/dist/client/components/redirect';
|
|
3
|
-
import { notFound, redirect } from 'next/navigation';
|
|
1
|
+
import * as nextNavigation from 'next/navigation.js';
|
|
4
2
|
import { TRPCRedirectError } from './redirect.mjs';
|
|
5
3
|
|
|
4
|
+
/**
|
|
5
|
+
* @remarks The helpers from `next/dist/client/components/*` has been removed in Next.js 15.
|
|
6
|
+
* Inlining them here instead...
|
|
7
|
+
* @see https://github.com/vercel/next.js/blob/5ae286ffd664e5c76841ed64f6e2da85a0835922/packages/next/src/client/components/redirect.ts#L97-L123
|
|
8
|
+
*/ const REDIRECT_ERROR_CODE = 'NEXT_REDIRECT';
|
|
9
|
+
function isRedirectError(error) {
|
|
10
|
+
if (typeof error !== 'object' || error === null || !('digest' in error) || typeof error.digest !== 'string') {
|
|
11
|
+
return false;
|
|
12
|
+
}
|
|
13
|
+
const [errorCode, type, destination, status] = error.digest.split(';', 4);
|
|
14
|
+
const statusCode = Number(status);
|
|
15
|
+
return errorCode === REDIRECT_ERROR_CODE && (type === 'replace' || type === 'push') && typeof destination === 'string' && !isNaN(statusCode);
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* @remarks The helpers from `next/dist/client/components/*` has been removed in Next.js 15.
|
|
19
|
+
* Inlining them here instead...
|
|
20
|
+
* @see https://github.com/vercel/next.js/blob/5ae286ffd664e5c76841ed64f6e2da85a0835922/packages/next/src/client/components/not-found.ts#L33-L39
|
|
21
|
+
*/ const NOT_FOUND_ERROR_CODE = 'NEXT_NOT_FOUND';
|
|
22
|
+
function isNotFoundError(error) {
|
|
23
|
+
if (typeof error !== 'object' || error === null || !('digest' in error)) {
|
|
24
|
+
return false;
|
|
25
|
+
}
|
|
26
|
+
return error.digest === NOT_FOUND_ERROR_CODE;
|
|
27
|
+
}
|
|
6
28
|
/**
|
|
7
29
|
* Rethrow errors that should be handled by Next.js
|
|
8
30
|
*/ const rethrowNextErrors = (error)=>{
|
|
9
31
|
if (error.code === 'NOT_FOUND') {
|
|
10
|
-
notFound();
|
|
32
|
+
nextNavigation.notFound();
|
|
11
33
|
}
|
|
12
34
|
if (error instanceof TRPCRedirectError) {
|
|
13
|
-
redirect(...error.args);
|
|
35
|
+
nextNavigation.redirect(...error.args);
|
|
14
36
|
}
|
|
15
37
|
const { cause } = error;
|
|
38
|
+
// Next.js 15 has `unstable_rethrow`. Use that if it exists.
|
|
39
|
+
if ('unstable_rethrow' in nextNavigation && typeof nextNavigation.unstable_rethrow === 'function') {
|
|
40
|
+
nextNavigation.unstable_rethrow(cause);
|
|
41
|
+
}
|
|
42
|
+
// Before Next.js 15, we have to check and rethrow the error manually.
|
|
16
43
|
if (isRedirectError(cause) || isNotFoundError(cause)) {
|
|
17
44
|
throw error.cause;
|
|
18
45
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
|
-
"bundleSize":
|
|
3
|
-
"bundleOrigSize":
|
|
4
|
-
"bundleReduction":
|
|
2
|
+
"bundleSize": 104597,
|
|
3
|
+
"bundleOrigSize": 153347,
|
|
4
|
+
"bundleReduction": 31.79,
|
|
5
5
|
"modules": [
|
|
6
6
|
{
|
|
7
7
|
"id": "/src/unstable-core-do-not-import/stream/stream.ts",
|
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
"/src/unstable-core-do-not-import.ts",
|
|
18
18
|
"/src/unstable-core-do-not-import/http/resolveResponse.ts"
|
|
19
19
|
],
|
|
20
|
-
"percent":
|
|
20
|
+
"percent": 13.82,
|
|
21
21
|
"reduction": 9.37
|
|
22
22
|
},
|
|
23
23
|
{
|
|
@@ -32,7 +32,7 @@
|
|
|
32
32
|
"dependents": [
|
|
33
33
|
"/src/adapters/fastify/fastifyTRPCPlugin.ts"
|
|
34
34
|
],
|
|
35
|
-
"percent": 10.
|
|
35
|
+
"percent": 10.75,
|
|
36
36
|
"reduction": 0
|
|
37
37
|
},
|
|
38
38
|
{
|
|
@@ -46,7 +46,7 @@
|
|
|
46
46
|
"dependents": [
|
|
47
47
|
"/src/unstable-core-do-not-import.ts"
|
|
48
48
|
],
|
|
49
|
-
"percent": 10
|
|
49
|
+
"percent": 10,
|
|
50
50
|
"reduction": 4.19
|
|
51
51
|
},
|
|
52
52
|
{
|
|
@@ -61,7 +61,7 @@
|
|
|
61
61
|
"/src/unstable-core-do-not-import.ts",
|
|
62
62
|
"/src/unstable-core-do-not-import/initTRPC.ts"
|
|
63
63
|
],
|
|
64
|
-
"percent": 6.
|
|
64
|
+
"percent": 6.05,
|
|
65
65
|
"reduction": 59.52
|
|
66
66
|
},
|
|
67
67
|
{
|
|
@@ -80,7 +80,7 @@
|
|
|
80
80
|
"/src/unstable-core-do-not-import/http/resolveResponse.ts",
|
|
81
81
|
"/src/unstable-core-do-not-import/initTRPC.ts"
|
|
82
82
|
],
|
|
83
|
-
"percent": 5.
|
|
83
|
+
"percent": 5.72,
|
|
84
84
|
"reduction": 41.05
|
|
85
85
|
},
|
|
86
86
|
{
|
|
@@ -95,7 +95,7 @@
|
|
|
95
95
|
"/src/unstable-core-do-not-import.ts",
|
|
96
96
|
"/src/unstable-core-do-not-import/http/resolveResponse.ts"
|
|
97
97
|
],
|
|
98
|
-
"percent": 5.
|
|
98
|
+
"percent": 5.3,
|
|
99
99
|
"reduction": 0
|
|
100
100
|
},
|
|
101
101
|
{
|
|
@@ -109,13 +109,13 @@
|
|
|
109
109
|
"dependents": [
|
|
110
110
|
"/src/adapters/aws-lambda/index.ts"
|
|
111
111
|
],
|
|
112
|
-
"percent": 4.
|
|
112
|
+
"percent": 4.64,
|
|
113
113
|
"reduction": 13.62
|
|
114
114
|
},
|
|
115
115
|
{
|
|
116
116
|
"id": "/src/adapters/next-app-dir/nextAppDirCaller.ts",
|
|
117
117
|
"size": 3135,
|
|
118
|
-
"origSize":
|
|
118
|
+
"origSize": 4033,
|
|
119
119
|
"renderedExports": [
|
|
120
120
|
"nextAppDirCaller"
|
|
121
121
|
],
|
|
@@ -123,8 +123,8 @@
|
|
|
123
123
|
"dependents": [
|
|
124
124
|
"/src/adapters/next-app-dir.ts"
|
|
125
125
|
],
|
|
126
|
-
"percent": 3
|
|
127
|
-
"reduction": 22.
|
|
126
|
+
"percent": 3,
|
|
127
|
+
"reduction": 22.27
|
|
128
128
|
},
|
|
129
129
|
{
|
|
130
130
|
"id": "/src/observable/observable.ts",
|
|
@@ -140,7 +140,7 @@
|
|
|
140
140
|
"/src/observable/index.ts",
|
|
141
141
|
"/src/observable/operators.ts"
|
|
142
142
|
],
|
|
143
|
-
"percent":
|
|
143
|
+
"percent": 2.99,
|
|
144
144
|
"reduction": 0.67
|
|
145
145
|
},
|
|
146
146
|
{
|
|
@@ -156,7 +156,7 @@
|
|
|
156
156
|
"dependents": [
|
|
157
157
|
"/src/observable/index.ts"
|
|
158
158
|
],
|
|
159
|
-
"percent": 2.
|
|
159
|
+
"percent": 2.63,
|
|
160
160
|
"reduction": 0
|
|
161
161
|
},
|
|
162
162
|
{
|
|
@@ -176,7 +176,7 @@
|
|
|
176
176
|
"/src/unstable-core-do-not-import/router.ts",
|
|
177
177
|
"/src/unstable-core-do-not-import/initTRPC.ts"
|
|
178
178
|
],
|
|
179
|
-
"percent": 2.
|
|
179
|
+
"percent": 2.62,
|
|
180
180
|
"reduction": 45.94
|
|
181
181
|
},
|
|
182
182
|
{
|
|
@@ -190,7 +190,7 @@
|
|
|
190
190
|
"dependents": [
|
|
191
191
|
"/src/unstable-core-do-not-import.ts"
|
|
192
192
|
],
|
|
193
|
-
"percent": 2.
|
|
193
|
+
"percent": 2.59,
|
|
194
194
|
"reduction": 40.91
|
|
195
195
|
},
|
|
196
196
|
{
|
|
@@ -210,7 +210,7 @@
|
|
|
210
210
|
"/src/unstable-core-do-not-import/initTRPC.ts",
|
|
211
211
|
"/src/unstable-core-do-not-import/procedureBuilder.ts"
|
|
212
212
|
],
|
|
213
|
-
"percent": 2.
|
|
213
|
+
"percent": 2.51,
|
|
214
214
|
"reduction": 55.5
|
|
215
215
|
},
|
|
216
216
|
{
|
|
@@ -224,7 +224,7 @@
|
|
|
224
224
|
"dependents": [
|
|
225
225
|
"/src/adapters/fetch/index.ts"
|
|
226
226
|
],
|
|
227
|
-
"percent": 2.
|
|
227
|
+
"percent": 2.16,
|
|
228
228
|
"reduction": 2.17
|
|
229
229
|
},
|
|
230
230
|
{
|
|
@@ -239,9 +239,23 @@
|
|
|
239
239
|
"/src/adapters/node-http/index.ts",
|
|
240
240
|
"/src/adapters/node-http/nodeHTTPRequestHandler.ts"
|
|
241
241
|
],
|
|
242
|
-
"percent": 2.
|
|
242
|
+
"percent": 2.08,
|
|
243
243
|
"reduction": 14.12
|
|
244
244
|
},
|
|
245
|
+
{
|
|
246
|
+
"id": "/src/adapters/next-app-dir/rethrowNextErrors.ts",
|
|
247
|
+
"size": 2050,
|
|
248
|
+
"origSize": 2176,
|
|
249
|
+
"renderedExports": [
|
|
250
|
+
"rethrowNextErrors"
|
|
251
|
+
],
|
|
252
|
+
"removedExports": [],
|
|
253
|
+
"dependents": [
|
|
254
|
+
"/src/adapters/next-app-dir/nextAppDirCaller.ts"
|
|
255
|
+
],
|
|
256
|
+
"percent": 1.96,
|
|
257
|
+
"reduction": 5.79
|
|
258
|
+
},
|
|
245
259
|
{
|
|
246
260
|
"id": "/src/unstable-core-do-not-import/createProxy.ts",
|
|
247
261
|
"size": 2000,
|
|
@@ -255,7 +269,7 @@
|
|
|
255
269
|
"/src/unstable-core-do-not-import.ts",
|
|
256
270
|
"/src/unstable-core-do-not-import/router.ts"
|
|
257
271
|
],
|
|
258
|
-
"percent": 1.
|
|
272
|
+
"percent": 1.91,
|
|
259
273
|
"reduction": 0
|
|
260
274
|
},
|
|
261
275
|
{
|
|
@@ -276,7 +290,7 @@
|
|
|
276
290
|
"/src/unstable-core-do-not-import/http/contentType.ts",
|
|
277
291
|
"/src/unstable-core-do-not-import/procedureBuilder.ts"
|
|
278
292
|
],
|
|
279
|
-
"percent": 1.
|
|
293
|
+
"percent": 1.66,
|
|
280
294
|
"reduction": 19.47
|
|
281
295
|
},
|
|
282
296
|
{
|
|
@@ -290,7 +304,7 @@
|
|
|
290
304
|
"dependents": [
|
|
291
305
|
"/src/adapters/node-http/index.ts"
|
|
292
306
|
],
|
|
293
|
-
"percent": 1.
|
|
307
|
+
"percent": 1.65,
|
|
294
308
|
"reduction": 20.03
|
|
295
309
|
},
|
|
296
310
|
{
|
|
@@ -302,7 +316,7 @@
|
|
|
302
316
|
],
|
|
303
317
|
"removedExports": [],
|
|
304
318
|
"dependents": [],
|
|
305
|
-
"percent": 1.
|
|
319
|
+
"percent": 1.51,
|
|
306
320
|
"reduction": 21.04
|
|
307
321
|
},
|
|
308
322
|
{
|
|
@@ -314,7 +328,7 @@
|
|
|
314
328
|
],
|
|
315
329
|
"removedExports": [],
|
|
316
330
|
"dependents": [],
|
|
317
|
-
"percent": 1.
|
|
331
|
+
"percent": 1.48,
|
|
318
332
|
"reduction": 26.94
|
|
319
333
|
},
|
|
320
334
|
{
|
|
@@ -327,7 +341,7 @@
|
|
|
327
341
|
],
|
|
328
342
|
"removedExports": [],
|
|
329
343
|
"dependents": [],
|
|
330
|
-
"percent": 1.
|
|
344
|
+
"percent": 1.46,
|
|
331
345
|
"reduction": 27.6
|
|
332
346
|
},
|
|
333
347
|
{
|
|
@@ -341,7 +355,7 @@
|
|
|
341
355
|
"dependents": [
|
|
342
356
|
"/src/adapters/fastify/index.ts"
|
|
343
357
|
],
|
|
344
|
-
"percent": 1.
|
|
358
|
+
"percent": 1.43,
|
|
345
359
|
"reduction": 34.7
|
|
346
360
|
},
|
|
347
361
|
{
|
|
@@ -358,28 +372,13 @@
|
|
|
358
372
|
"/src/unstable-core-do-not-import/http/resolveResponse.ts",
|
|
359
373
|
"/src/unstable-core-do-not-import/error/getErrorShape.ts"
|
|
360
374
|
],
|
|
361
|
-
"percent": 1.
|
|
375
|
+
"percent": 1.21,
|
|
362
376
|
"reduction": 23.5
|
|
363
377
|
},
|
|
364
|
-
{
|
|
365
|
-
"id": "/src/adapters/fastify/fastifyRequestHandler.ts",
|
|
366
|
-
"size": 1132,
|
|
367
|
-
"origSize": 2160,
|
|
368
|
-
"renderedExports": [
|
|
369
|
-
"fastifyRequestHandler"
|
|
370
|
-
],
|
|
371
|
-
"removedExports": [],
|
|
372
|
-
"dependents": [
|
|
373
|
-
"/src/adapters/fastify/index.ts",
|
|
374
|
-
"/src/adapters/fastify/fastifyTRPCPlugin.ts"
|
|
375
|
-
],
|
|
376
|
-
"percent": 1.1,
|
|
377
|
-
"reduction": 47.59
|
|
378
|
-
},
|
|
379
378
|
{
|
|
380
379
|
"id": "/src/unstable-core-do-not-import/utils.ts",
|
|
381
|
-
"size":
|
|
382
|
-
"origSize":
|
|
380
|
+
"size": 1152,
|
|
381
|
+
"origSize": 1581,
|
|
383
382
|
"renderedExports": [
|
|
384
383
|
"unsetMarker",
|
|
385
384
|
"mergeWithoutOverrides",
|
|
@@ -401,8 +400,23 @@
|
|
|
401
400
|
"/src/unstable-core-do-not-import/procedureBuilder.ts",
|
|
402
401
|
"/src/unstable-core-do-not-import/stream/stream.ts"
|
|
403
402
|
],
|
|
404
|
-
"percent": 1.
|
|
405
|
-
"reduction":
|
|
403
|
+
"percent": 1.1,
|
|
404
|
+
"reduction": 27.13
|
|
405
|
+
},
|
|
406
|
+
{
|
|
407
|
+
"id": "/src/adapters/fastify/fastifyRequestHandler.ts",
|
|
408
|
+
"size": 1132,
|
|
409
|
+
"origSize": 2160,
|
|
410
|
+
"renderedExports": [
|
|
411
|
+
"fastifyRequestHandler"
|
|
412
|
+
],
|
|
413
|
+
"removedExports": [],
|
|
414
|
+
"dependents": [
|
|
415
|
+
"/src/adapters/fastify/index.ts",
|
|
416
|
+
"/src/adapters/fastify/fastifyTRPCPlugin.ts"
|
|
417
|
+
],
|
|
418
|
+
"percent": 1.08,
|
|
419
|
+
"reduction": 47.59
|
|
406
420
|
},
|
|
407
421
|
{
|
|
408
422
|
"id": "/src/unstable-core-do-not-import/parser.ts",
|
|
@@ -416,7 +430,7 @@
|
|
|
416
430
|
"/src/unstable-core-do-not-import.ts",
|
|
417
431
|
"/src/unstable-core-do-not-import/procedureBuilder.ts"
|
|
418
432
|
],
|
|
419
|
-
"percent": 0.
|
|
433
|
+
"percent": 0.95,
|
|
420
434
|
"reduction": 56.22
|
|
421
435
|
},
|
|
422
436
|
{
|
|
@@ -433,7 +447,7 @@
|
|
|
433
447
|
"/src/adapters/next-app-dir/nextAppDirCaller.ts",
|
|
434
448
|
"/src/adapters/next-app-dir/rethrowNextErrors.ts"
|
|
435
449
|
],
|
|
436
|
-
"percent": 0.
|
|
450
|
+
"percent": 0.94,
|
|
437
451
|
"reduction": 13.65
|
|
438
452
|
},
|
|
439
453
|
{
|
|
@@ -447,7 +461,7 @@
|
|
|
447
461
|
"dependents": [
|
|
448
462
|
"/src/adapters/next-app-dir/nextAppDirCaller.ts"
|
|
449
463
|
],
|
|
450
|
-
"percent": 0.
|
|
464
|
+
"percent": 0.78,
|
|
451
465
|
"reduction": 0.97
|
|
452
466
|
},
|
|
453
467
|
{
|
|
@@ -459,7 +473,7 @@
|
|
|
459
473
|
],
|
|
460
474
|
"removedExports": [],
|
|
461
475
|
"dependents": [],
|
|
462
|
-
"percent": 0.
|
|
476
|
+
"percent": 0.73,
|
|
463
477
|
"reduction": 66.9
|
|
464
478
|
},
|
|
465
479
|
{
|
|
@@ -473,7 +487,7 @@
|
|
|
473
487
|
"dependents": [
|
|
474
488
|
"/src/unstable-core-do-not-import.ts"
|
|
475
489
|
],
|
|
476
|
-
"percent": 0.
|
|
490
|
+
"percent": 0.64,
|
|
477
491
|
"reduction": 0.6
|
|
478
492
|
},
|
|
479
493
|
{
|
|
@@ -488,7 +502,7 @@
|
|
|
488
502
|
"/src/unstable-core-do-not-import.ts",
|
|
489
503
|
"/src/unstable-core-do-not-import/http/resolveResponse.ts"
|
|
490
504
|
],
|
|
491
|
-
"percent": 0.
|
|
505
|
+
"percent": 0.6,
|
|
492
506
|
"reduction": 43.49
|
|
493
507
|
},
|
|
494
508
|
{
|
|
@@ -501,23 +515,9 @@
|
|
|
501
515
|
],
|
|
502
516
|
"removedExports": [],
|
|
503
517
|
"dependents": [],
|
|
504
|
-
"percent": 0.
|
|
518
|
+
"percent": 0.5,
|
|
505
519
|
"reduction": 67.09
|
|
506
520
|
},
|
|
507
|
-
{
|
|
508
|
-
"id": "/src/adapters/next-app-dir/rethrowNextErrors.ts",
|
|
509
|
-
"size": 422,
|
|
510
|
-
"origSize": 704,
|
|
511
|
-
"renderedExports": [
|
|
512
|
-
"rethrowNextErrors"
|
|
513
|
-
],
|
|
514
|
-
"removedExports": [],
|
|
515
|
-
"dependents": [
|
|
516
|
-
"/src/adapters/next-app-dir/nextAppDirCaller.ts"
|
|
517
|
-
],
|
|
518
|
-
"percent": 0.41,
|
|
519
|
-
"reduction": 40.06
|
|
520
|
-
},
|
|
521
521
|
{
|
|
522
522
|
"id": "/src/unstable-core-do-not-import/rootConfig.ts",
|
|
523
523
|
"size": 343,
|
|
@@ -556,7 +556,7 @@
|
|
|
556
556
|
"dependents": [
|
|
557
557
|
"/src/unstable-core-do-not-import.ts"
|
|
558
558
|
],
|
|
559
|
-
"percent": 0.
|
|
559
|
+
"percent": 0.26,
|
|
560
560
|
"reduction": 68.45
|
|
561
561
|
},
|
|
562
562
|
{
|
|
@@ -653,9 +653,9 @@
|
|
|
653
653
|
"reduction": 100
|
|
654
654
|
},
|
|
655
655
|
{
|
|
656
|
-
"id": "/src/
|
|
656
|
+
"id": "/src/rpc.ts",
|
|
657
657
|
"size": 0,
|
|
658
|
-
"origSize":
|
|
658
|
+
"origSize": 36,
|
|
659
659
|
"renderedExports": [],
|
|
660
660
|
"removedExports": [],
|
|
661
661
|
"dependents": [],
|
|
@@ -663,9 +663,9 @@
|
|
|
663
663
|
"reduction": 100
|
|
664
664
|
},
|
|
665
665
|
{
|
|
666
|
-
"id": "/src/
|
|
666
|
+
"id": "/src/shared.ts",
|
|
667
667
|
"size": 0,
|
|
668
|
-
"origSize":
|
|
668
|
+
"origSize": 653,
|
|
669
669
|
"renderedExports": [],
|
|
670
670
|
"removedExports": [],
|
|
671
671
|
"dependents": [],
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/unstable-core-do-not-import/utils.ts"],"names":[],"mappings":"AAAA,gBAAgB;AAChB,eAAO,MAAM,WAAW,eAAwB,CAAC;AACjD,MAAM,MAAM,WAAW,GAAG,OAAO,WAAW,CAAC;AAE7C;;;GAGG;AACH,wBAAgB,qBAAqB,CAAC,KAAK,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EACzE,IAAI,EAAE,KAAK,EACX,GAAG,IAAI,EAAE,OAAO,CAAC,KAAK,CAAC,EAAE,GACxB,KAAK,CAYP;AAED;;;GAGG;AACH,wBAAgB,QAAQ,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAEzE;AAED,KAAK,KAAK,GAAG,CAAC,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,OAAO,CAAC,GAAG,MAAM,CAAC,MAAM,GAAG,EAAE,OAAO,CAAC,CAAC;AACxE,wBAAgB,UAAU,CAAC,EAAE,EAAE,OAAO,GAAG,EAAE,IAAI,KAAK,CAEnD;AAED;;;GAGG;AACH,wBAAgB,aAAa,CAAC,IAAI,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAChE,GAAG,EAAE,IAAI,GACR,IAAI,CAEN;
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/unstable-core-do-not-import/utils.ts"],"names":[],"mappings":"AAAA,gBAAgB;AAChB,eAAO,MAAM,WAAW,eAAwB,CAAC;AACjD,MAAM,MAAM,WAAW,GAAG,OAAO,WAAW,CAAC;AAE7C;;;GAGG;AACH,wBAAgB,qBAAqB,CAAC,KAAK,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EACzE,IAAI,EAAE,KAAK,EACX,GAAG,IAAI,EAAE,OAAO,CAAC,KAAK,CAAC,EAAE,GACxB,KAAK,CAYP;AAED;;;GAGG;AACH,wBAAgB,QAAQ,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAEzE;AAED,KAAK,KAAK,GAAG,CAAC,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,OAAO,CAAC,GAAG,MAAM,CAAC,MAAM,GAAG,EAAE,OAAO,CAAC,CAAC;AACxE,wBAAgB,UAAU,CAAC,EAAE,EAAE,OAAO,GAAG,EAAE,IAAI,KAAK,CAEnD;AAED;;;GAGG;AACH,wBAAgB,aAAa,CAAC,IAAI,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAChE,GAAG,EAAE,IAAI,GACR,IAAI,CAEN;AAKD,wBAAgB,eAAe,CAAC,MAAM,EACpC,KAAK,EAAE,OAAO,GACb,KAAK,IAAI,aAAa,CAAC,MAAM,CAAC,CAIhC"}
|
|
@@ -31,8 +31,9 @@ function isFunction(fn) {
|
|
|
31
31
|
*/ function omitPrototype(obj) {
|
|
32
32
|
return Object.assign(Object.create(null), obj);
|
|
33
33
|
}
|
|
34
|
+
const asyncIteratorsSupported = typeof Symbol === 'function' && !!Symbol.asyncIterator;
|
|
34
35
|
function isAsyncIterable(value) {
|
|
35
|
-
return isObject(value) && Symbol.asyncIterator in value;
|
|
36
|
+
return asyncIteratorsSupported && isObject(value) && Symbol.asyncIterator in value;
|
|
36
37
|
}
|
|
37
38
|
|
|
38
39
|
exports.isAsyncIterable = isAsyncIterable;
|
|
@@ -29,8 +29,9 @@ function isFunction(fn) {
|
|
|
29
29
|
*/ function omitPrototype(obj) {
|
|
30
30
|
return Object.assign(Object.create(null), obj);
|
|
31
31
|
}
|
|
32
|
+
const asyncIteratorsSupported = typeof Symbol === 'function' && !!Symbol.asyncIterator;
|
|
32
33
|
function isAsyncIterable(value) {
|
|
33
|
-
return isObject(value) && Symbol.asyncIterator in value;
|
|
34
|
+
return asyncIteratorsSupported && isObject(value) && Symbol.asyncIterator in value;
|
|
34
35
|
}
|
|
35
36
|
|
|
36
37
|
export { isAsyncIterable, isFunction, isObject, mergeWithoutOverrides, omitPrototype, unsetMarker };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@trpc/server",
|
|
3
|
-
"version": "11.0.0-rc.
|
|
3
|
+
"version": "11.0.0-rc.383+f8e40bff5",
|
|
4
4
|
"description": "The tRPC server library",
|
|
5
5
|
"author": "KATT",
|
|
6
6
|
"license": "MIT",
|
|
@@ -149,5 +149,5 @@
|
|
|
149
149
|
"funding": [
|
|
150
150
|
"https://trpc.io/sponsor"
|
|
151
151
|
],
|
|
152
|
-
"gitHead": "
|
|
152
|
+
"gitHead": "f8e40bff51b7efca762c8a2bad35492ec71e83a3"
|
|
153
153
|
}
|
|
@@ -46,6 +46,7 @@ export function nextAppDirCaller<TContext, TMeta>(
|
|
|
46
46
|
const createContext = async (): Promise<TContext> => {
|
|
47
47
|
return config?.createContext?.() ?? ({} as TContext);
|
|
48
48
|
};
|
|
49
|
+
|
|
49
50
|
return async (opts) => {
|
|
50
51
|
const path =
|
|
51
52
|
config.pathExtractor?.({ meta: opts._def.meta as TMeta }) ?? '';
|
|
@@ -1,24 +1,66 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { isRedirectError } from 'next/dist/client/components/redirect';
|
|
3
|
-
import {
|
|
4
|
-
notFound as __notFound,
|
|
5
|
-
redirect as __redirect,
|
|
6
|
-
} from 'next/navigation';
|
|
1
|
+
import * as nextNavigation from 'next/navigation.js';
|
|
7
2
|
import type { TRPCError } from '../../@trpc/server';
|
|
8
3
|
import { TRPCRedirectError } from './redirect';
|
|
9
4
|
|
|
10
5
|
/**
|
|
11
|
-
*
|
|
6
|
+
* @remarks The helpers from `next/dist/client/components/*` has been removed in Next.js 15.
|
|
7
|
+
* Inlining them here instead...
|
|
8
|
+
* @see https://github.com/vercel/next.js/blob/5ae286ffd664e5c76841ed64f6e2da85a0835922/packages/next/src/client/components/redirect.ts#L97-L123
|
|
9
|
+
*/
|
|
10
|
+
const REDIRECT_ERROR_CODE = 'NEXT_REDIRECT';
|
|
11
|
+
function isRedirectError(error: unknown) {
|
|
12
|
+
if (
|
|
13
|
+
typeof error !== 'object' ||
|
|
14
|
+
error === null ||
|
|
15
|
+
!('digest' in error) ||
|
|
16
|
+
typeof error.digest !== 'string'
|
|
17
|
+
) {
|
|
18
|
+
return false;
|
|
19
|
+
}
|
|
20
|
+
const [errorCode, type, destination, status] = error.digest.split(';', 4);
|
|
21
|
+
const statusCode = Number(status);
|
|
22
|
+
return (
|
|
23
|
+
errorCode === REDIRECT_ERROR_CODE &&
|
|
24
|
+
(type === 'replace' || type === 'push') &&
|
|
25
|
+
typeof destination === 'string' &&
|
|
26
|
+
!isNaN(statusCode)
|
|
27
|
+
);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* @remarks The helpers from `next/dist/client/components/*` has been removed in Next.js 15.
|
|
32
|
+
* Inlining them here instead...
|
|
33
|
+
* @see https://github.com/vercel/next.js/blob/5ae286ffd664e5c76841ed64f6e2da85a0835922/packages/next/src/client/components/not-found.ts#L33-L39
|
|
12
34
|
*/
|
|
35
|
+
const NOT_FOUND_ERROR_CODE = 'NEXT_NOT_FOUND';
|
|
36
|
+
function isNotFoundError(error: unknown) {
|
|
37
|
+
if (typeof error !== 'object' || error === null || !('digest' in error)) {
|
|
38
|
+
return false;
|
|
39
|
+
}
|
|
40
|
+
return error.digest === NOT_FOUND_ERROR_CODE;
|
|
41
|
+
}
|
|
13
42
|
|
|
43
|
+
/**
|
|
44
|
+
* Rethrow errors that should be handled by Next.js
|
|
45
|
+
*/
|
|
14
46
|
export const rethrowNextErrors = (error: TRPCError) => {
|
|
15
47
|
if (error.code === 'NOT_FOUND') {
|
|
16
|
-
|
|
48
|
+
nextNavigation.notFound();
|
|
17
49
|
}
|
|
18
50
|
if (error instanceof TRPCRedirectError) {
|
|
19
|
-
|
|
51
|
+
nextNavigation.redirect(...error.args);
|
|
20
52
|
}
|
|
21
53
|
const { cause } = error;
|
|
54
|
+
|
|
55
|
+
// Next.js 15 has `unstable_rethrow`. Use that if it exists.
|
|
56
|
+
if (
|
|
57
|
+
'unstable_rethrow' in nextNavigation &&
|
|
58
|
+
typeof nextNavigation.unstable_rethrow === 'function'
|
|
59
|
+
) {
|
|
60
|
+
nextNavigation.unstable_rethrow(cause);
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
// Before Next.js 15, we have to check and rethrow the error manually.
|
|
22
64
|
if (isRedirectError(cause) || isNotFoundError(cause)) {
|
|
23
65
|
throw error.cause;
|
|
24
66
|
}
|
|
@@ -46,8 +46,13 @@ export function omitPrototype<TObj extends Record<string, unknown>>(
|
|
|
46
46
|
return Object.assign(Object.create(null), obj);
|
|
47
47
|
}
|
|
48
48
|
|
|
49
|
+
const asyncIteratorsSupported =
|
|
50
|
+
typeof Symbol === 'function' && !!Symbol.asyncIterator;
|
|
51
|
+
|
|
49
52
|
export function isAsyncIterable<TValue>(
|
|
50
53
|
value: unknown,
|
|
51
54
|
): value is AsyncIterable<TValue> {
|
|
52
|
-
return
|
|
55
|
+
return (
|
|
56
|
+
asyncIteratorsSupported && isObject(value) && Symbol.asyncIterator in value
|
|
57
|
+
);
|
|
53
58
|
}
|