@trpc/server 11.0.0-rc.444 → 11.0.0-rc.445
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/bundle-analysis.json +48 -48
- package/dist/unstable-core-do-not-import/createProxy.d.ts +2 -2
- package/dist/unstable-core-do-not-import/createProxy.d.ts.map +1 -1
- package/dist/unstable-core-do-not-import/createProxy.js +15 -5
- package/dist/unstable-core-do-not-import/createProxy.mjs +15 -5
- package/dist/unstable-core-do-not-import/http/types.d.ts +1 -1
- package/dist/unstable-core-do-not-import/http/types.d.ts.map +1 -1
- package/package.json +2 -2
- package/src/unstable-core-do-not-import/createProxy.ts +18 -6
- package/src/unstable-core-do-not-import/http/types.ts +1 -1
- package/src/unstable-core-do-not-import/router.ts +1 -1
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
|
-
"bundleSize":
|
|
3
|
-
"bundleOrigSize":
|
|
4
|
-
"bundleReduction": 27.
|
|
2
|
+
"bundleSize": 129548,
|
|
3
|
+
"bundleOrigSize": 179141,
|
|
4
|
+
"bundleReduction": 27.68,
|
|
5
5
|
"modules": [
|
|
6
6
|
{
|
|
7
7
|
"id": "/src/unstable-core-do-not-import/http/resolveResponse.ts",
|
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
"dependents": [
|
|
15
15
|
"/src/unstable-core-do-not-import.ts"
|
|
16
16
|
],
|
|
17
|
-
"percent": 13.
|
|
17
|
+
"percent": 13.18,
|
|
18
18
|
"reduction": 0
|
|
19
19
|
},
|
|
20
20
|
{
|
|
@@ -31,7 +31,7 @@
|
|
|
31
31
|
"/src/unstable-core-do-not-import.ts",
|
|
32
32
|
"/src/unstable-core-do-not-import/http/resolveResponse.ts"
|
|
33
33
|
],
|
|
34
|
-
"percent": 12.
|
|
34
|
+
"percent": 12.1,
|
|
35
35
|
"reduction": 6.72
|
|
36
36
|
},
|
|
37
37
|
{
|
|
@@ -46,7 +46,7 @@
|
|
|
46
46
|
"dependents": [
|
|
47
47
|
"/src/adapters/fastify/fastifyTRPCPlugin.ts"
|
|
48
48
|
],
|
|
49
|
-
"percent": 11.
|
|
49
|
+
"percent": 11.02,
|
|
50
50
|
"reduction": 0
|
|
51
51
|
},
|
|
52
52
|
{
|
|
@@ -61,13 +61,13 @@
|
|
|
61
61
|
"/src/unstable-core-do-not-import.ts",
|
|
62
62
|
"/src/unstable-core-do-not-import/http/resolveResponse.ts"
|
|
63
63
|
],
|
|
64
|
-
"percent": 5.
|
|
64
|
+
"percent": 5.86,
|
|
65
65
|
"reduction": 0
|
|
66
66
|
},
|
|
67
67
|
{
|
|
68
68
|
"id": "/src/unstable-core-do-not-import/router.ts",
|
|
69
69
|
"size": 6381,
|
|
70
|
-
"origSize":
|
|
70
|
+
"origSize": 10595,
|
|
71
71
|
"renderedExports": [
|
|
72
72
|
"createRouterFactory",
|
|
73
73
|
"callProcedure",
|
|
@@ -79,8 +79,8 @@
|
|
|
79
79
|
"/src/unstable-core-do-not-import.ts",
|
|
80
80
|
"/src/unstable-core-do-not-import/initTRPC.ts"
|
|
81
81
|
],
|
|
82
|
-
"percent": 4.
|
|
83
|
-
"reduction": 39.
|
|
82
|
+
"percent": 4.93,
|
|
83
|
+
"reduction": 39.77
|
|
84
84
|
},
|
|
85
85
|
{
|
|
86
86
|
"id": "/src/unstable-core-do-not-import/procedureBuilder.ts",
|
|
@@ -94,7 +94,7 @@
|
|
|
94
94
|
"/src/unstable-core-do-not-import.ts",
|
|
95
95
|
"/src/unstable-core-do-not-import/initTRPC.ts"
|
|
96
96
|
],
|
|
97
|
-
"percent": 4.
|
|
97
|
+
"percent": 4.88,
|
|
98
98
|
"reduction": 60.06
|
|
99
99
|
},
|
|
100
100
|
{
|
|
@@ -113,7 +113,7 @@
|
|
|
113
113
|
"/src/unstable-core-do-not-import.ts",
|
|
114
114
|
"/src/unstable-core-do-not-import/http/resolveResponse.ts"
|
|
115
115
|
],
|
|
116
|
-
"percent": 4.
|
|
116
|
+
"percent": 4.35,
|
|
117
117
|
"reduction": 24.48
|
|
118
118
|
},
|
|
119
119
|
{
|
|
@@ -127,7 +127,7 @@
|
|
|
127
127
|
"dependents": [
|
|
128
128
|
"/src/adapters/aws-lambda/index.ts"
|
|
129
129
|
],
|
|
130
|
-
"percent": 4.
|
|
130
|
+
"percent": 4.18,
|
|
131
131
|
"reduction": 11.38
|
|
132
132
|
},
|
|
133
133
|
{
|
|
@@ -147,7 +147,7 @@
|
|
|
147
147
|
"/src/unstable-core-do-not-import/http/resolveResponse.ts",
|
|
148
148
|
"/src/observable/operators.ts"
|
|
149
149
|
],
|
|
150
|
-
"percent": 3.
|
|
150
|
+
"percent": 3.46,
|
|
151
151
|
"reduction": 0
|
|
152
152
|
},
|
|
153
153
|
{
|
|
@@ -161,7 +161,7 @@
|
|
|
161
161
|
"dependents": [
|
|
162
162
|
"/src/adapters/next-app-dir.ts"
|
|
163
163
|
],
|
|
164
|
-
"percent": 2.
|
|
164
|
+
"percent": 2.42,
|
|
165
165
|
"reduction": 22.27
|
|
166
166
|
},
|
|
167
167
|
{
|
|
@@ -225,7 +225,7 @@
|
|
|
225
225
|
"dependents": [
|
|
226
226
|
"/src/adapters/node-http/index.ts"
|
|
227
227
|
],
|
|
228
|
-
"percent": 2.
|
|
228
|
+
"percent": 2.07,
|
|
229
229
|
"reduction": 7.31
|
|
230
230
|
},
|
|
231
231
|
{
|
|
@@ -248,6 +248,22 @@
|
|
|
248
248
|
"percent": 2.03,
|
|
249
249
|
"reduction": 55.5
|
|
250
250
|
},
|
|
251
|
+
{
|
|
252
|
+
"id": "/src/unstable-core-do-not-import/createProxy.ts",
|
|
253
|
+
"size": 2329,
|
|
254
|
+
"origSize": 2262,
|
|
255
|
+
"renderedExports": [
|
|
256
|
+
"createRecursiveProxy",
|
|
257
|
+
"createFlatProxy"
|
|
258
|
+
],
|
|
259
|
+
"removedExports": [],
|
|
260
|
+
"dependents": [
|
|
261
|
+
"/src/unstable-core-do-not-import.ts",
|
|
262
|
+
"/src/unstable-core-do-not-import/router.ts"
|
|
263
|
+
],
|
|
264
|
+
"percent": 1.8,
|
|
265
|
+
"reduction": 0
|
|
266
|
+
},
|
|
251
267
|
{
|
|
252
268
|
"id": "/src/adapters/fetch/fetchRequestHandler.ts",
|
|
253
269
|
"size": 2255,
|
|
@@ -259,7 +275,7 @@
|
|
|
259
275
|
"dependents": [
|
|
260
276
|
"/src/adapters/fetch/index.ts"
|
|
261
277
|
],
|
|
262
|
-
"percent": 1.
|
|
278
|
+
"percent": 1.74,
|
|
263
279
|
"reduction": 2.17
|
|
264
280
|
},
|
|
265
281
|
{
|
|
@@ -274,7 +290,7 @@
|
|
|
274
290
|
"/src/adapters/node-http/index.ts",
|
|
275
291
|
"/src/adapters/node-http/nodeHTTPRequestHandler.ts"
|
|
276
292
|
],
|
|
277
|
-
"percent": 1.
|
|
293
|
+
"percent": 1.69,
|
|
278
294
|
"reduction": 13.79
|
|
279
295
|
},
|
|
280
296
|
{
|
|
@@ -288,25 +304,9 @@
|
|
|
288
304
|
"dependents": [
|
|
289
305
|
"/src/adapters/next-app-dir/nextAppDirCaller.ts"
|
|
290
306
|
],
|
|
291
|
-
"percent": 1.
|
|
307
|
+
"percent": 1.58,
|
|
292
308
|
"reduction": 5.79
|
|
293
309
|
},
|
|
294
|
-
{
|
|
295
|
-
"id": "/src/unstable-core-do-not-import/createProxy.ts",
|
|
296
|
-
"size": 1982,
|
|
297
|
-
"origSize": 1991,
|
|
298
|
-
"renderedExports": [
|
|
299
|
-
"createRecursiveProxy",
|
|
300
|
-
"createFlatProxy"
|
|
301
|
-
],
|
|
302
|
-
"removedExports": [],
|
|
303
|
-
"dependents": [
|
|
304
|
-
"/src/unstable-core-do-not-import.ts",
|
|
305
|
-
"/src/unstable-core-do-not-import/router.ts"
|
|
306
|
-
],
|
|
307
|
-
"percent": 1.53,
|
|
308
|
-
"reduction": 0.45
|
|
309
|
-
},
|
|
310
310
|
{
|
|
311
311
|
"id": "/src/unstable-core-do-not-import/error/TRPCError.ts",
|
|
312
312
|
"size": 1733,
|
|
@@ -396,7 +396,7 @@
|
|
|
396
396
|
"/src/unstable-core-do-not-import/http/resolveResponse.ts",
|
|
397
397
|
"/src/unstable-core-do-not-import/error/getErrorShape.ts"
|
|
398
398
|
],
|
|
399
|
-
"percent":
|
|
399
|
+
"percent": 0.99,
|
|
400
400
|
"reduction": 18.7
|
|
401
401
|
},
|
|
402
402
|
{
|
|
@@ -443,7 +443,7 @@
|
|
|
443
443
|
"/src/adapters/fastify/index.ts",
|
|
444
444
|
"/src/adapters/fastify/fastifyTRPCPlugin.ts"
|
|
445
445
|
],
|
|
446
|
-
"percent": 0.
|
|
446
|
+
"percent": 0.87,
|
|
447
447
|
"reduction": 47.59
|
|
448
448
|
},
|
|
449
449
|
{
|
|
@@ -548,7 +548,7 @@
|
|
|
548
548
|
"dependents": [
|
|
549
549
|
"/src/unstable-core-do-not-import.ts"
|
|
550
550
|
],
|
|
551
|
-
"percent": 0.
|
|
551
|
+
"percent": 0.51,
|
|
552
552
|
"reduction": 0.6
|
|
553
553
|
},
|
|
554
554
|
{
|
|
@@ -578,7 +578,7 @@
|
|
|
578
578
|
"/src/unstable-core-do-not-import/stream/sse.ts",
|
|
579
579
|
"/src/unstable-core-do-not-import/stream/jsonl.ts"
|
|
580
580
|
],
|
|
581
|
-
"percent": 0.
|
|
581
|
+
"percent": 0.44,
|
|
582
582
|
"reduction": 17.15
|
|
583
583
|
},
|
|
584
584
|
{
|
|
@@ -606,7 +606,7 @@
|
|
|
606
606
|
"/src/unstable-core-do-not-import.ts",
|
|
607
607
|
"/src/unstable-core-do-not-import/initTRPC.ts"
|
|
608
608
|
],
|
|
609
|
-
"percent": 0.
|
|
609
|
+
"percent": 0.26,
|
|
610
610
|
"reduction": 89.39
|
|
611
611
|
},
|
|
612
612
|
{
|
|
@@ -741,24 +741,24 @@
|
|
|
741
741
|
"reduction": 100
|
|
742
742
|
},
|
|
743
743
|
{
|
|
744
|
-
"id": "/src/
|
|
744
|
+
"id": "/src/shared.ts",
|
|
745
745
|
"size": 0,
|
|
746
|
-
"origSize":
|
|
746
|
+
"origSize": 653,
|
|
747
747
|
"renderedExports": [],
|
|
748
748
|
"removedExports": [],
|
|
749
|
-
"dependents": [
|
|
750
|
-
"/src/adapters/ws.ts"
|
|
751
|
-
],
|
|
749
|
+
"dependents": [],
|
|
752
750
|
"percent": 0,
|
|
753
751
|
"reduction": 100
|
|
754
752
|
},
|
|
755
753
|
{
|
|
756
|
-
"id": "/src/
|
|
754
|
+
"id": "/src/unstable-core-do-not-import.ts",
|
|
757
755
|
"size": 0,
|
|
758
|
-
"origSize":
|
|
756
|
+
"origSize": 2100,
|
|
759
757
|
"renderedExports": [],
|
|
760
758
|
"removedExports": [],
|
|
761
|
-
"dependents": [
|
|
759
|
+
"dependents": [
|
|
760
|
+
"/src/adapters/ws.ts"
|
|
761
|
+
],
|
|
762
762
|
"percent": 0,
|
|
763
763
|
"reduction": 100
|
|
764
764
|
},
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createProxy.d.ts","sourceRoot":"","sources":["../../src/unstable-core-do-not-import/createProxy.ts"],"names":[],"mappings":"AAAA,UAAU,oBAAoB;IAC5B,IAAI,EAAE,MAAM,EAAE,CAAC;
|
|
1
|
+
{"version":3,"file":"createProxy.d.ts","sourceRoot":"","sources":["../../src/unstable-core-do-not-import/createProxy.ts"],"names":[],"mappings":"AAAA,UAAU,oBAAoB;IAC5B,IAAI,EAAE,SAAS,MAAM,EAAE,CAAC;IACxB,IAAI,EAAE,SAAS,OAAO,EAAE,CAAC;CAC1B;AACD,KAAK,aAAa,GAAG,CAAC,IAAI,EAAE,oBAAoB,KAAK,OAAO,CAAC;AAqD7D;;;;GAIG;AACH,eAAO,MAAM,oBAAoB,GAAI,KAAK,sBAC9B,aAAa,KACtB,KAAqE,CAAC;AAEzE;;;;GAIG;AACH,eAAO,MAAM,eAAe,GAAI,KAAK,YACzB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,KAAK,KAAK,GAAG,KAC5C,KAWF,CAAC"}
|
|
@@ -1,10 +1,17 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
+
var _memo, _cacheKey;
|
|
3
4
|
const noop = ()=>{
|
|
4
5
|
// noop
|
|
5
6
|
};
|
|
6
|
-
|
|
7
|
-
|
|
7
|
+
const freezeIfAvailable = (obj)=>{
|
|
8
|
+
if (Object.freeze) {
|
|
9
|
+
Object.freeze(obj);
|
|
10
|
+
}
|
|
11
|
+
};
|
|
12
|
+
function createInnerProxy(callback, path, memo) {
|
|
13
|
+
const cacheKey = path.join('.');
|
|
14
|
+
(_memo = memo)[_cacheKey = cacheKey] ?? (_memo[_cacheKey] = new Proxy(noop, {
|
|
8
15
|
get (_obj, key) {
|
|
9
16
|
if (typeof key !== 'string' || key === 'then') {
|
|
10
17
|
// special case for if the proxy is accidentally treated
|
|
@@ -14,7 +21,7 @@ function createInnerProxy(callback, path, cache) {
|
|
|
14
21
|
return createInnerProxy(callback, [
|
|
15
22
|
...path,
|
|
16
23
|
key
|
|
17
|
-
]);
|
|
24
|
+
], memo);
|
|
18
25
|
},
|
|
19
26
|
apply (_1, _2, args) {
|
|
20
27
|
const lastOfPath = path[path.length - 1];
|
|
@@ -36,15 +43,18 @@ function createInnerProxy(callback, path, cache) {
|
|
|
36
43
|
path: path.slice(0, -1)
|
|
37
44
|
};
|
|
38
45
|
}
|
|
46
|
+
freezeIfAvailable(opts.args);
|
|
47
|
+
freezeIfAvailable(opts.path);
|
|
39
48
|
return callback(opts);
|
|
40
49
|
}
|
|
41
|
-
});
|
|
50
|
+
}));
|
|
51
|
+
return memo[cacheKey];
|
|
42
52
|
}
|
|
43
53
|
/**
|
|
44
54
|
* Creates a proxy that calls the callback with the path and arguments
|
|
45
55
|
*
|
|
46
56
|
* @internal
|
|
47
|
-
*/ const createRecursiveProxy = (callback)=>createInnerProxy(callback, []);
|
|
57
|
+
*/ const createRecursiveProxy = (callback)=>createInnerProxy(callback, [], Object.create(null));
|
|
48
58
|
/**
|
|
49
59
|
* Used in place of `new Proxy` where each handler will map 1 level deep to another value.
|
|
50
60
|
*
|
|
@@ -1,8 +1,15 @@
|
|
|
1
|
+
var _memo, _cacheKey;
|
|
1
2
|
const noop = ()=>{
|
|
2
3
|
// noop
|
|
3
4
|
};
|
|
4
|
-
|
|
5
|
-
|
|
5
|
+
const freezeIfAvailable = (obj)=>{
|
|
6
|
+
if (Object.freeze) {
|
|
7
|
+
Object.freeze(obj);
|
|
8
|
+
}
|
|
9
|
+
};
|
|
10
|
+
function createInnerProxy(callback, path, memo) {
|
|
11
|
+
const cacheKey = path.join('.');
|
|
12
|
+
(_memo = memo)[_cacheKey = cacheKey] ?? (_memo[_cacheKey] = new Proxy(noop, {
|
|
6
13
|
get (_obj, key) {
|
|
7
14
|
if (typeof key !== 'string' || key === 'then') {
|
|
8
15
|
// special case for if the proxy is accidentally treated
|
|
@@ -12,7 +19,7 @@ function createInnerProxy(callback, path, cache) {
|
|
|
12
19
|
return createInnerProxy(callback, [
|
|
13
20
|
...path,
|
|
14
21
|
key
|
|
15
|
-
]);
|
|
22
|
+
], memo);
|
|
16
23
|
},
|
|
17
24
|
apply (_1, _2, args) {
|
|
18
25
|
const lastOfPath = path[path.length - 1];
|
|
@@ -34,15 +41,18 @@ function createInnerProxy(callback, path, cache) {
|
|
|
34
41
|
path: path.slice(0, -1)
|
|
35
42
|
};
|
|
36
43
|
}
|
|
44
|
+
freezeIfAvailable(opts.args);
|
|
45
|
+
freezeIfAvailable(opts.path);
|
|
37
46
|
return callback(opts);
|
|
38
47
|
}
|
|
39
|
-
});
|
|
48
|
+
}));
|
|
49
|
+
return memo[cacheKey];
|
|
40
50
|
}
|
|
41
51
|
/**
|
|
42
52
|
* Creates a proxy that calls the callback with the path and arguments
|
|
43
53
|
*
|
|
44
54
|
* @internal
|
|
45
|
-
*/ const createRecursiveProxy = (callback)=>createInnerProxy(callback, []);
|
|
55
|
+
*/ const createRecursiveProxy = (callback)=>createInnerProxy(callback, [], Object.create(null));
|
|
46
56
|
/**
|
|
47
57
|
* Used in place of `new Proxy` where each handler will map 1 level deep to another value.
|
|
48
58
|
*
|
|
@@ -21,7 +21,7 @@ export type ResponseMetaFn<TRouter extends AnyRouter> = (opts: {
|
|
|
21
21
|
* The different tRPC paths requested
|
|
22
22
|
* @deprecated use `info` instead, this will be removed in v12
|
|
23
23
|
**/
|
|
24
|
-
paths: string[] | undefined;
|
|
24
|
+
paths: readonly string[] | undefined;
|
|
25
25
|
info: TRPCRequestInfo | undefined;
|
|
26
26
|
type: ProcedureType | 'unknown';
|
|
27
27
|
errors: TRPCError[];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/unstable-core-do-not-import/http/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AACpD,OAAO,KAAK,EACV,YAAY,EACZ,mBAAmB,EACnB,aAAa,EACd,MAAM,cAAc,CAAC;AACtB,OAAO,KAAK,EACV,SAAS,EACT,kBAAkB,EAClB,gBAAgB,EACjB,MAAM,WAAW,CAAC;AACnB,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,QAAQ,CAAC;AAC3C,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,UAAU,CAAC;AAErC;;GAEG;AACH,KAAK,WAAW,GAAG,IAAI,CAAC,MAAM,EAAE,GAAG,MAAM,CAAC,CAAC;AAE3C,MAAM,WAAW,YAAY;IAC3B,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,OAAO,CAAC,EAAE,OAAO,GAAG,WAAW,CAAC;CACjC;AAED;;GAEG;AACH,MAAM,MAAM,cAAc,CAAC,OAAO,SAAS,SAAS,IAAI,CAAC,IAAI,EAAE;IAC7D,IAAI,EAAE,YAAY,CAAC,OAAO,EAAE,gBAAgB,CAAC,OAAO,CAAC,CAAC,EAAE,CAAC;IACzD,GA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O,EAAE,QAAQ,CAAC,KAC7C,IAAI,CAAC;AAEV;;;GAGG;AACH,MAAM,WAAW,kBAAkB,CAAC,OAAO,SAAS,SAAS,EAAE,QAAQ;IACrE,OAAO,CAAC,EAAE,gBAAgB,CAAC,OAAO,EAAE,QAAQ,CAAC,CAAC;IAC9C;;OAEG;IACH,QAAQ,CAAC,EAAE;QACT;;WAEG;QACH,OAAO,EAAE,OAAO,CAAC;KAClB,CAAC;IACF,MAAM,EAAE,OAAO,CAAC;IAChB;;;OAGG;IACH,mBAAmB,CAAC,EAAE,OAAO,CAAC;IAC9B;;;OAGG;IACH,aAAa,CAAC,EAAE,OAAO,CAAC;CACzB"}
|
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.445+8cb82e3c8",
|
|
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": "8cb82e3c8f7d036ab5cdbf6dc769c23af7e56f6c"
|
|
153
153
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
interface ProxyCallbackOptions {
|
|
2
|
-
path: string[];
|
|
3
|
-
args: unknown[];
|
|
2
|
+
path: readonly string[];
|
|
3
|
+
args: readonly unknown[];
|
|
4
4
|
}
|
|
5
5
|
type ProxyCallback = (opts: ProxyCallbackOptions) => unknown;
|
|
6
6
|
|
|
@@ -8,19 +8,27 @@ const noop = () => {
|
|
|
8
8
|
// noop
|
|
9
9
|
};
|
|
10
10
|
|
|
11
|
+
const freezeIfAvailable = (obj: object) => {
|
|
12
|
+
if (Object.freeze) {
|
|
13
|
+
Object.freeze(obj);
|
|
14
|
+
}
|
|
15
|
+
};
|
|
16
|
+
|
|
11
17
|
function createInnerProxy(
|
|
12
18
|
callback: ProxyCallback,
|
|
13
|
-
path: string[],
|
|
14
|
-
|
|
19
|
+
path: readonly string[],
|
|
20
|
+
memo: Record<string, unknown>,
|
|
15
21
|
) {
|
|
16
|
-
|
|
22
|
+
const cacheKey = path.join('.');
|
|
23
|
+
|
|
24
|
+
memo[cacheKey] ??= new Proxy(noop, {
|
|
17
25
|
get(_obj, key) {
|
|
18
26
|
if (typeof key !== 'string' || key === 'then') {
|
|
19
27
|
// special case for if the proxy is accidentally treated
|
|
20
28
|
// like a PromiseLike (like in `Promise.resolve(proxy)`)
|
|
21
29
|
return undefined;
|
|
22
30
|
}
|
|
23
|
-
return createInnerProxy(callback, [...path, key],
|
|
31
|
+
return createInnerProxy(callback, [...path, key], memo);
|
|
24
32
|
},
|
|
25
33
|
apply(_1, _2, args) {
|
|
26
34
|
const lastOfPath = path[path.length - 1];
|
|
@@ -38,9 +46,13 @@ function createInnerProxy(
|
|
|
38
46
|
path: path.slice(0, -1),
|
|
39
47
|
};
|
|
40
48
|
}
|
|
49
|
+
freezeIfAvailable(opts.args);
|
|
50
|
+
freezeIfAvailable(opts.path);
|
|
41
51
|
return callback(opts);
|
|
42
52
|
},
|
|
43
53
|
});
|
|
54
|
+
|
|
55
|
+
return memo[cacheKey];
|
|
44
56
|
}
|
|
45
57
|
|
|
46
58
|
/**
|
|
@@ -32,7 +32,7 @@ export type ResponseMetaFn<TRouter extends AnyRouter> = (opts: {
|
|
|
32
32
|
* The different tRPC paths requested
|
|
33
33
|
* @deprecated use `info` instead, this will be removed in v12
|
|
34
34
|
**/
|
|
35
|
-
paths: string[] | undefined;
|
|
35
|
+
paths: readonly string[] | undefined;
|
|
36
36
|
info: TRPCRequestInfo | undefined;
|
|
37
37
|
type: ProcedureType | 'unknown';
|
|
38
38
|
errors: TRPCError[];
|
|
@@ -174,7 +174,7 @@ export function createRouterFactory<TRoot extends AnyRootTypes>(
|
|
|
174
174
|
|
|
175
175
|
const procedures: Record<string, AnyProcedure> = omitPrototype({});
|
|
176
176
|
|
|
177
|
-
function step(from: CreateRouterOptions, path: string[] = []) {
|
|
177
|
+
function step(from: CreateRouterOptions, path: readonly string[] = []) {
|
|
178
178
|
const aggregate: RouterRecord = omitPrototype({});
|
|
179
179
|
for (const [key, item] of Object.entries(from ?? {})) {
|
|
180
180
|
if (isRouter(item)) {
|