@trpc/next 11.0.0-next-beta.273 → 11.0.0-next-beta.274

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.
@@ -1,7 +1,7 @@
1
1
  {
2
- "bundleSize": 22012,
3
- "bundleOrigSize": 36230,
4
- "bundleReduction": 39.24,
2
+ "bundleSize": 23036,
3
+ "bundleOrigSize": 37220,
4
+ "bundleReduction": 38.11,
5
5
  "modules": [
6
6
  {
7
7
  "id": "/src/ssrPrepass.ts",
@@ -12,7 +12,7 @@
12
12
  ],
13
13
  "removedExports": [],
14
14
  "dependents": [],
15
- "percent": 23,
15
+ "percent": 21.97,
16
16
  "reduction": 13.51
17
17
  },
18
18
  {
@@ -26,9 +26,24 @@
26
26
  ],
27
27
  "removedExports": [],
28
28
  "dependents": [],
29
- "percent": 17.36,
29
+ "percent": 16.59,
30
30
  "reduction": 22.4
31
31
  },
32
+ {
33
+ "id": "/src/withTRPC.tsx",
34
+ "size": 3448,
35
+ "origSize": 6138,
36
+ "renderedExports": [
37
+ "withTRPC"
38
+ ],
39
+ "removedExports": [],
40
+ "dependents": [
41
+ "/src/index.ts",
42
+ "/src/createTRPCNext.tsx"
43
+ ],
44
+ "percent": 14.97,
45
+ "reduction": 43.83
46
+ },
32
47
  {
33
48
  "id": "/src/app-dir/create-action-hook.tsx",
34
49
  "size": 3436,
@@ -41,7 +56,7 @@
41
56
  "dependents": [
42
57
  "/src/app-dir/client.ts"
43
58
  ],
44
- "percent": 15.61,
59
+ "percent": 14.92,
45
60
  "reduction": 49.31
46
61
  },
47
62
  {
@@ -53,24 +68,9 @@
53
68
  ],
54
69
  "removedExports": [],
55
70
  "dependents": [],
56
- "percent": 11.68,
71
+ "percent": 11.16,
57
72
  "reduction": 15.54
58
73
  },
59
- {
60
- "id": "/src/withTRPC.tsx",
61
- "size": 2424,
62
- "origSize": 5148,
63
- "renderedExports": [
64
- "withTRPC"
65
- ],
66
- "removedExports": [],
67
- "dependents": [
68
- "/src/index.ts",
69
- "/src/createTRPCNext.tsx"
70
- ],
71
- "percent": 11.01,
72
- "reduction": 52.91
73
- },
74
74
  {
75
75
  "id": "/src/app-dir/client.ts",
76
76
  "size": 1279,
@@ -80,7 +80,7 @@
80
80
  ],
81
81
  "removedExports": [],
82
82
  "dependents": [],
83
- "percent": 5.81,
83
+ "percent": 5.55,
84
84
  "reduction": 32.47
85
85
  },
86
86
  {
@@ -92,7 +92,7 @@
92
92
  ],
93
93
  "removedExports": [],
94
94
  "dependents": [],
95
- "percent": 5.42,
95
+ "percent": 5.17,
96
96
  "reduction": 39.58
97
97
  },
98
98
  {
@@ -106,7 +106,7 @@
106
106
  "dependents": [
107
107
  "/src/index.ts"
108
108
  ],
109
- "percent": 4.87,
109
+ "percent": 4.66,
110
110
  "reduction": 59.52
111
111
  },
112
112
  {
@@ -120,7 +120,7 @@
120
120
  "dependents": [
121
121
  "/src/app-dir/server.ts"
122
122
  ],
123
- "percent": 3.72,
123
+ "percent": 3.55,
124
124
  "reduction": 0.97
125
125
  },
126
126
  {
@@ -140,7 +140,7 @@
140
140
  "/src/app-dir/links/nextHttp.ts",
141
141
  "/src/app-dir/create-action-hook.tsx"
142
142
  ],
143
- "percent": 1.52,
143
+ "percent": 1.45,
144
144
  "reduction": 89.11
145
145
  },
146
146
  {
@@ -1 +1 @@
1
- {"version":3,"file":"withTRPC.d.ts","sourceRoot":"","sources":["../src/withTRPC.tsx"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,KAAK,EAAmB,WAAW,EAAE,MAAM,uBAAuB,CAAC;AAE1E,OAAO,KAAK,EAAE,uBAAuB,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAC;AAE/E,OAAO,EAEL,KAAK,kBAAkB,EACxB,MAAM,iCAAiC,CAAC;AACzC,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AACzD,OAAO,KAAK,EACV,sBAAsB,EACtB,gCAAgC,EACjC,MAAM,0BAA0B,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B,CAAC,OAAO,SAAS,SAAS,IACxD,eAAe,CAAC,OAAO,CAAC,GAAG;IACzB,GAAG,CAAC,EAAE,KAAK,CAAC;CACb,CAAC;AAEJ,MAAM,MAAM,gBAAgB,CAC1B,OAAO,SAAS,SAAS,EACzB,WAAW,SAAS,eAAe,GAAG,eAAe,IACnD;IACF,MAAM,EAAE,cAAc,CAAC,OAAO,CAAC,CAAC;IAChC,WAAW,EAAE,WAAW,CAAC;IACzB,UAAU,EAAE,iBAAiB,CAAC,OAAO,CAAC,CAAC;IACvC,QAAQ,EAAE,SAAS,CAAC;IACpB,UAAU,EAAE,WAAW,CAAC;CACzB,CAAC;AAEF,wBAAgB,QAAQ,CACtB,OAAO,SAAS,SAAS,EACzB,WAAW,SAAS,eAAe,GAAG,eAAe,EACrD,IAAI,EAAE,oBAAoB,CAAC,OAAO,CAAC,GAAG,kBAAkB,CAAC,OAAO,CAAC,eAO9C,kBAAkB,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC,KAAG,iBAAiB,CAgGxE"}
package/dist/withTRPC.js CHANGED
@@ -57,6 +57,25 @@ function withTRPC(opts) {
57
57
  AppOrPage,
58
58
  WithTRPC
59
59
  });
60
+ } else if (AppOrPage.getInitialProps) {
61
+ // Allow combining `getServerSideProps` and `getInitialProps`
62
+ WithTRPC.getInitialProps = async (appOrPageCtx)=>{
63
+ // Determine if we are wrapping an App component or a Page component.
64
+ const isApp = !!appOrPageCtx.Component;
65
+ // Run the wrapped component's getInitialProps function.
66
+ let pageProps = {};
67
+ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
68
+ const originalProps = await AppOrPage.getInitialProps(appOrPageCtx);
69
+ const originalPageProps = isApp ? originalProps.pageProps ?? {} : originalProps;
70
+ pageProps = {
71
+ ...originalPageProps,
72
+ ...pageProps
73
+ };
74
+ const getAppTreeProps = (props)=>isApp ? {
75
+ pageProps: props
76
+ } : props;
77
+ return getAppTreeProps(pageProps);
78
+ };
60
79
  }
61
80
  const displayName = AppOrPage.displayName ?? AppOrPage.name ?? 'Component';
62
81
  WithTRPC.displayName = `withTRPC(${displayName})`;
package/dist/withTRPC.mjs CHANGED
@@ -55,6 +55,25 @@ function withTRPC(opts) {
55
55
  AppOrPage,
56
56
  WithTRPC
57
57
  });
58
+ } else if (AppOrPage.getInitialProps) {
59
+ // Allow combining `getServerSideProps` and `getInitialProps`
60
+ WithTRPC.getInitialProps = async (appOrPageCtx)=>{
61
+ // Determine if we are wrapping an App component or a Page component.
62
+ const isApp = !!appOrPageCtx.Component;
63
+ // Run the wrapped component's getInitialProps function.
64
+ let pageProps = {};
65
+ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
66
+ const originalProps = await AppOrPage.getInitialProps(appOrPageCtx);
67
+ const originalPageProps = isApp ? originalProps.pageProps ?? {} : originalProps;
68
+ pageProps = {
69
+ ...originalPageProps,
70
+ ...pageProps
71
+ };
72
+ const getAppTreeProps = (props)=>isApp ? {
73
+ pageProps: props
74
+ } : props;
75
+ return getAppTreeProps(pageProps);
76
+ };
58
77
  }
59
78
  const displayName = AppOrPage.displayName ?? AppOrPage.name ?? 'Component';
60
79
  WithTRPC.displayName = `withTRPC(${displayName})`;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@trpc/next",
3
- "version": "11.0.0-next-beta.273+6d0bde8bd",
3
+ "version": "11.0.0-next-beta.274+bc5196e28",
4
4
  "description": "The tRPC Next.js library",
5
5
  "author": "KATT",
6
6
  "license": "MIT",
@@ -73,9 +73,9 @@
73
73
  ],
74
74
  "peerDependencies": {
75
75
  "@tanstack/react-query": "^5.0.0",
76
- "@trpc/client": "11.0.0-next-beta.273+6d0bde8bd",
77
- "@trpc/react-query": "11.0.0-next-beta.273+6d0bde8bd",
78
- "@trpc/server": "11.0.0-next-beta.273+6d0bde8bd",
76
+ "@trpc/client": "11.0.0-next-beta.274+bc5196e28",
77
+ "@trpc/react-query": "11.0.0-next-beta.274+bc5196e28",
78
+ "@trpc/server": "11.0.0-next-beta.274+bc5196e28",
79
79
  "next": "*",
80
80
  "react": ">=16.8.0",
81
81
  "react-dom": ">=16.8.0"
@@ -90,9 +90,9 @@
90
90
  },
91
91
  "devDependencies": {
92
92
  "@tanstack/react-query": "^5.0.0",
93
- "@trpc/client": "11.0.0-next-beta.273+6d0bde8bd",
94
- "@trpc/react-query": "11.0.0-next-beta.273+6d0bde8bd",
95
- "@trpc/server": "11.0.0-next-beta.273+6d0bde8bd",
93
+ "@trpc/client": "11.0.0-next-beta.274+bc5196e28",
94
+ "@trpc/react-query": "11.0.0-next-beta.274+bc5196e28",
95
+ "@trpc/server": "11.0.0-next-beta.274+bc5196e28",
96
96
  "@types/express": "^4.17.17",
97
97
  "@types/node": "^20.10.0",
98
98
  "@types/react": "^18.2.33",
@@ -112,5 +112,5 @@
112
112
  "funding": [
113
113
  "https://trpc.io/sponsor"
114
114
  ],
115
- "gitHead": "6d0bde8bd52863fff477328819ed8564c54df160"
115
+ "gitHead": "bc5196e28b43de58d58c4d3ca76ab45aa96f30e4"
116
116
  }
package/src/withTRPC.tsx CHANGED
@@ -18,10 +18,12 @@ import type {
18
18
  import { createRootHooks, getQueryClient } from '@trpc/react-query/shared';
19
19
  import type {
20
20
  AnyRouter,
21
+ Dict,
21
22
  inferClientTypes,
22
23
  ResponseMeta,
23
24
  } from '@trpc/server/unstable-core-do-not-import';
24
25
  import type {
26
+ AppContextType,
25
27
  AppPropsType,
26
28
  NextComponentType,
27
29
  NextPageContext,
@@ -154,6 +156,32 @@ export function withTRPC<
154
156
  AppOrPage,
155
157
  WithTRPC,
156
158
  });
159
+ } else if (AppOrPage.getInitialProps) {
160
+ // Allow combining `getServerSideProps` and `getInitialProps`
161
+
162
+ WithTRPC.getInitialProps = async (appOrPageCtx: AppContextType) => {
163
+ // Determine if we are wrapping an App component or a Page component.
164
+ const isApp = !!appOrPageCtx.Component;
165
+
166
+ // Run the wrapped component's getInitialProps function.
167
+ let pageProps: Dict<unknown> = {};
168
+ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
169
+ const originalProps = await AppOrPage.getInitialProps!(
170
+ appOrPageCtx as any,
171
+ );
172
+ const originalPageProps = isApp
173
+ ? originalProps.pageProps ?? {}
174
+ : originalProps;
175
+
176
+ pageProps = {
177
+ ...originalPageProps,
178
+ ...pageProps,
179
+ };
180
+ const getAppTreeProps = (props: Dict<unknown>) =>
181
+ isApp ? { pageProps: props } : props;
182
+
183
+ return getAppTreeProps(pageProps);
184
+ };
157
185
  }
158
186
 
159
187
  const displayName = AppOrPage.displayName ?? AppOrPage.name ?? 'Component';