@trpc/next 10.0.0-proxy-alpha.69 → 10.0.0-proxy-alpha.72
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 +2 -2
- package/dist/{setupNext.d.ts → createTRPCNext.d.ts} +2 -2
- package/dist/createTRPCNext.d.ts.map +1 -0
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -3
- package/dist/index.mjs +4 -4
- package/package.json +8 -8
- package/src/{setupNext.tsx → createTRPCNext.tsx} +4 -4
- package/src/index.ts +1 -1
- package/dist/setupNext.d.ts.map +0 -1
package/README.md
CHANGED
|
@@ -36,11 +36,11 @@ pnpm add @trpc/next@next @trpc/react@next @tanstack/react-query
|
|
|
36
36
|
Setup tRPC in `utils/trpc.ts`.
|
|
37
37
|
|
|
38
38
|
```ts
|
|
39
|
-
import {
|
|
39
|
+
import { createTRPCNext } from '@trpc/next';
|
|
40
40
|
// Import the router type from your server file
|
|
41
41
|
import type { AppRouter } from '../pages/api/[trpc].ts';
|
|
42
42
|
|
|
43
|
-
export const trpc =
|
|
43
|
+
export const trpc = createTRPCNext<AppRouter>({
|
|
44
44
|
config() {
|
|
45
45
|
return {
|
|
46
46
|
url: 'http://localhost:3000/api/trpc',
|
|
@@ -2,8 +2,8 @@ import { DecoratedProcedureRecord, DecoratedProcedureUtilsRecord } from '@trpc/r
|
|
|
2
2
|
import { AnyRouter } from '@trpc/server';
|
|
3
3
|
import { NextPageContext } from 'next/types';
|
|
4
4
|
import { WithTRPCNoSSROptions, WithTRPCSSROptions } from './withTRPC';
|
|
5
|
-
export declare function
|
|
5
|
+
export declare function createTRPCNext<TRouter extends AnyRouter, TSSRContext extends NextPageContext = NextPageContext>(opts: WithTRPCNoSSROptions<TRouter> | WithTRPCSSROptions<TRouter>): {
|
|
6
6
|
useContext(): DecoratedProcedureUtilsRecord<TRouter>;
|
|
7
7
|
withTRPC: (AppOrPage: import("next/types").NextComponentType<any, any, any>) => import("next/types").NextComponentType<NextPageContext, {}, {}>;
|
|
8
8
|
} & DecoratedProcedureRecord<TRouter["_def"]["record"], "">;
|
|
9
|
-
//# sourceMappingURL=
|
|
9
|
+
//# sourceMappingURL=createTRPCNext.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"createTRPCNext.d.ts","sourceRoot":"","sources":["../src/createTRPCNext.tsx"],"names":[],"mappings":"AAAA,OAAO,EACL,wBAAwB,EACxB,6BAA6B,EAI9B,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AACzC,OAAO,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAE7C,OAAO,EAAE,oBAAoB,EAAE,kBAAkB,EAAY,MAAM,YAAY,CAAC;AAEhF,wBAAgB,cAAc,CAC5B,OAAO,SAAS,SAAS,EACzB,WAAW,SAAS,eAAe,GAAG,eAAe,EACrD,IAAI,EAAE,oBAAoB,CAAC,OAAO,CAAC,GAAG,kBAAkB,CAAC,OAAO,CAAC;kBAoCjD,8BAA8B,OAAO,CAAC;;4DAGvD"}
|
package/dist/index.d.ts
CHANGED
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAC;AAC3B,cAAc,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAC;AAC3B,cAAc,kBAAkB,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -184,8 +184,8 @@ function withTRPC(opts) {
|
|
|
184
184
|
};
|
|
185
185
|
}
|
|
186
186
|
|
|
187
|
-
function
|
|
188
|
-
const hooks =
|
|
187
|
+
function createTRPCNext(opts) {
|
|
188
|
+
const hooks = shared.createHooksInternal();
|
|
189
189
|
// TODO: maybe set TSSRContext to `never` when using `WithTRPCNoSSROptions`
|
|
190
190
|
const _withTRPC = withTRPC(opts);
|
|
191
191
|
const proxy = new Proxy(()=>{
|
|
@@ -215,5 +215,5 @@ function setupTRPC(opts) {
|
|
|
215
215
|
return proxy;
|
|
216
216
|
}
|
|
217
217
|
|
|
218
|
-
exports.
|
|
218
|
+
exports.createTRPCNext = createTRPCNext;
|
|
219
219
|
exports.withTRPC = withTRPC;
|
package/dist/index.mjs
CHANGED
|
@@ -2,7 +2,7 @@ import { QueryClient, QueryClientProvider, Hydrate, dehydrate } from '@tanstack/
|
|
|
2
2
|
import { createReactQueryHooks, createTRPCClient } from '@trpc/react';
|
|
3
3
|
import React, { useState, createElement, useMemo } from 'react';
|
|
4
4
|
import ssrPrepass from 'react-ssr-prepass';
|
|
5
|
-
import { createReactQueryUtilsProxy, createReactProxyDecoration } from '@trpc/react/shared';
|
|
5
|
+
import { createHooksInternal, createReactQueryUtilsProxy, createReactProxyDecoration } from '@trpc/react/shared';
|
|
6
6
|
|
|
7
7
|
function extends_() {
|
|
8
8
|
extends_ = Object.assign || function (target) {
|
|
@@ -175,8 +175,8 @@ function withTRPC(opts) {
|
|
|
175
175
|
};
|
|
176
176
|
}
|
|
177
177
|
|
|
178
|
-
function
|
|
179
|
-
const hooks =
|
|
178
|
+
function createTRPCNext(opts) {
|
|
179
|
+
const hooks = createHooksInternal();
|
|
180
180
|
// TODO: maybe set TSSRContext to `never` when using `WithTRPCNoSSROptions`
|
|
181
181
|
const _withTRPC = withTRPC(opts);
|
|
182
182
|
const proxy = new Proxy(()=>{
|
|
@@ -206,4 +206,4 @@ function setupTRPC(opts) {
|
|
|
206
206
|
return proxy;
|
|
207
207
|
}
|
|
208
208
|
|
|
209
|
-
export {
|
|
209
|
+
export { createTRPCNext, withTRPC };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@trpc/next",
|
|
3
|
-
"version": "10.0.0-proxy-alpha.
|
|
3
|
+
"version": "10.0.0-proxy-alpha.72",
|
|
4
4
|
"description": "tRPC Next lib",
|
|
5
5
|
"author": "KATT",
|
|
6
6
|
"license": "MIT",
|
|
@@ -36,9 +36,9 @@
|
|
|
36
36
|
},
|
|
37
37
|
"peerDependencies": {
|
|
38
38
|
"@tanstack/react-query": "^4.0.10",
|
|
39
|
-
"@trpc/client": "10.0.0-proxy-alpha.
|
|
40
|
-
"@trpc/react": "10.0.0-proxy-alpha.
|
|
41
|
-
"@trpc/server": "10.0.0-proxy-alpha.
|
|
39
|
+
"@trpc/client": "10.0.0-proxy-alpha.72",
|
|
40
|
+
"@trpc/react": "10.0.0-proxy-alpha.72",
|
|
41
|
+
"@trpc/server": "10.0.0-proxy-alpha.72",
|
|
42
42
|
"next": "*",
|
|
43
43
|
"react": ">=16.8.0",
|
|
44
44
|
"react-dom": ">=16.8.0"
|
|
@@ -48,9 +48,9 @@
|
|
|
48
48
|
},
|
|
49
49
|
"devDependencies": {
|
|
50
50
|
"@tanstack/react-query": "^4.0.10",
|
|
51
|
-
"@trpc/client": "10.0.0-proxy-alpha.
|
|
52
|
-
"@trpc/react": "10.0.0-proxy-alpha.
|
|
53
|
-
"@trpc/server": "10.0.0-proxy-alpha.
|
|
51
|
+
"@trpc/client": "10.0.0-proxy-alpha.72",
|
|
52
|
+
"@trpc/react": "10.0.0-proxy-alpha.72",
|
|
53
|
+
"@trpc/server": "10.0.0-proxy-alpha.72",
|
|
54
54
|
"@types/express": "^4.17.12",
|
|
55
55
|
"express": "^4.17.1",
|
|
56
56
|
"next": "^12.1.6",
|
|
@@ -61,5 +61,5 @@
|
|
|
61
61
|
"publishConfig": {
|
|
62
62
|
"access": "public"
|
|
63
63
|
},
|
|
64
|
-
"gitHead": "
|
|
64
|
+
"gitHead": "211511c11992741a1a3a48cc424ebd5870757146"
|
|
65
65
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { createReactQueryHooks } from '@trpc/react';
|
|
2
1
|
import {
|
|
3
2
|
DecoratedProcedureRecord,
|
|
4
3
|
DecoratedProcedureUtilsRecord,
|
|
4
|
+
createHooksInternal,
|
|
5
5
|
createReactProxyDecoration,
|
|
6
6
|
createReactQueryUtilsProxy,
|
|
7
7
|
} from '@trpc/react/shared';
|
|
@@ -10,11 +10,11 @@ import { NextPageContext } from 'next/types';
|
|
|
10
10
|
import { useMemo } from 'react';
|
|
11
11
|
import { WithTRPCNoSSROptions, WithTRPCSSROptions, withTRPC } from './withTRPC';
|
|
12
12
|
|
|
13
|
-
export function
|
|
13
|
+
export function createTRPCNext<
|
|
14
14
|
TRouter extends AnyRouter,
|
|
15
15
|
TSSRContext extends NextPageContext = NextPageContext,
|
|
16
16
|
>(opts: WithTRPCNoSSROptions<TRouter> | WithTRPCSSROptions<TRouter>) {
|
|
17
|
-
const hooks =
|
|
17
|
+
const hooks = createHooksInternal<TRouter, TSSRContext>();
|
|
18
18
|
|
|
19
19
|
// TODO: maybe set TSSRContext to `never` when using `WithTRPCNoSSROptions`
|
|
20
20
|
const _withTRPC = withTRPC<TRouter, TSSRContext>(opts);
|
|
@@ -30,7 +30,7 @@ export function setupTRPC<
|
|
|
30
30
|
const context = hooks.useContext();
|
|
31
31
|
// create a stable reference of the utils context
|
|
32
32
|
return useMemo(() => {
|
|
33
|
-
return createReactQueryUtilsProxy
|
|
33
|
+
return (createReactQueryUtilsProxy as any)(context);
|
|
34
34
|
}, [context]);
|
|
35
35
|
};
|
|
36
36
|
}
|
package/src/index.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
export * from './withTRPC';
|
|
2
|
-
export * from './
|
|
2
|
+
export * from './createTRPCNext';
|
package/dist/setupNext.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"setupNext.d.ts","sourceRoot":"","sources":["../src/setupNext.tsx"],"names":[],"mappings":"AACA,OAAO,EACL,wBAAwB,EACxB,6BAA6B,EAG9B,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AACzC,OAAO,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAE7C,OAAO,EAAE,oBAAoB,EAAE,kBAAkB,EAAY,MAAM,YAAY,CAAC;AAEhF,wBAAgB,SAAS,CACvB,OAAO,SAAS,SAAS,EACzB,WAAW,SAAS,eAAe,GAAG,eAAe,EACrD,IAAI,EAAE,oBAAoB,CAAC,OAAO,CAAC,GAAG,kBAAkB,CAAC,OAAO,CAAC;kBAoCjD,8BAA8B,OAAO,CAAC;;4DAGvD"}
|