@trpc/next 10.0.0-alpha.3 → 10.0.0-alpha.7
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/index.js +6 -7
- package/dist/index.mjs +5 -6
- package/package.json +8 -8
- package/src/withTRPC.tsx +3 -3
package/dist/index.js
CHANGED
|
@@ -10,7 +10,6 @@ var _regeneratorRuntime = require('@babel/runtime/regenerator');
|
|
|
10
10
|
var react = require('@trpc/react');
|
|
11
11
|
var React = require('react');
|
|
12
12
|
var reactQuery = require('react-query');
|
|
13
|
-
var hydration = require('react-query/hydration');
|
|
14
13
|
var ssrPrepass = require('react-ssr-prepass');
|
|
15
14
|
|
|
16
15
|
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
@@ -84,7 +83,7 @@ function withTRPC(opts) {
|
|
|
84
83
|
ssrContext: ssrContext
|
|
85
84
|
}, /*#__PURE__*/React__default["default"].createElement(reactQuery.QueryClientProvider, {
|
|
86
85
|
client: queryClient
|
|
87
|
-
}, /*#__PURE__*/React__default["default"].createElement(
|
|
86
|
+
}, /*#__PURE__*/React__default["default"].createElement(reactQuery.Hydrate, {
|
|
88
87
|
state: hydratedState
|
|
89
88
|
}, /*#__PURE__*/React__default["default"].createElement(AppOrPage, props))));
|
|
90
89
|
};
|
|
@@ -92,7 +91,7 @@ function withTRPC(opts) {
|
|
|
92
91
|
if (AppOrPage.getInitialProps || opts.ssr) {
|
|
93
92
|
WithTRPC.getInitialProps = /*#__PURE__*/function () {
|
|
94
93
|
var _ref = _asyncToGenerator__default["default"]( /*#__PURE__*/_regeneratorRuntime__default["default"].mark(function _callee(appOrPageCtx) {
|
|
95
|
-
var _opts$responseMeta
|
|
94
|
+
var _opts$responseMeta;
|
|
96
95
|
|
|
97
96
|
var AppTree, isApp, ctx, pageProps, _originalProps$pagePr, originalProps, originalPageProps, getAppTreeProps, config, trpcClient, queryClient, trpcProp, prepassProps, dehydratedCache, dehydratedCacheWithErrors, appTreeProps, meta, _i, _Object$entries, _Object$entries$_i, key, value, _ctx$res;
|
|
98
97
|
|
|
@@ -182,7 +181,7 @@ function withTRPC(opts) {
|
|
|
182
181
|
break;
|
|
183
182
|
|
|
184
183
|
case 27:
|
|
185
|
-
dehydratedCache =
|
|
184
|
+
dehydratedCache = reactQuery.dehydrate(queryClient, {
|
|
186
185
|
shouldDehydrateQuery: function shouldDehydrateQuery() {
|
|
187
186
|
// makes sure errors are also dehydrated
|
|
188
187
|
return true;
|
|
@@ -196,16 +195,16 @@ function withTRPC(opts) {
|
|
|
196
195
|
|
|
197
196
|
pageProps.trpcState = opts.transformer ? opts.transformer.serialize(dehydratedCacheWithErrors) : dehydratedCacheWithErrors;
|
|
198
197
|
appTreeProps = getAppTreeProps(pageProps);
|
|
199
|
-
meta = (_opts$responseMeta =
|
|
198
|
+
meta = ((_opts$responseMeta = opts.responseMeta) === null || _opts$responseMeta === void 0 ? void 0 : _opts$responseMeta.call(opts, {
|
|
200
199
|
ctx: ctx,
|
|
201
200
|
clientErrors: [].concat(_toConsumableArray__default["default"](dehydratedCache.queries), _toConsumableArray__default["default"](dehydratedCache.mutations)).map(function (v) {
|
|
202
201
|
return v.state.error;
|
|
203
202
|
}).flatMap(function (err) {
|
|
204
203
|
return err instanceof Error && err.name === 'TRPCClientError' ? [err] : [];
|
|
205
204
|
})
|
|
206
|
-
}))
|
|
205
|
+
})) || {};
|
|
207
206
|
|
|
208
|
-
for (_i = 0, _Object$entries = Object.entries(meta); _i < _Object$entries.length; _i++) {
|
|
207
|
+
for (_i = 0, _Object$entries = Object.entries(meta.headers || {}); _i < _Object$entries.length; _i++) {
|
|
209
208
|
_Object$entries$_i = _slicedToArray__default["default"](_Object$entries[_i], 2), key = _Object$entries$_i[0], value = _Object$entries$_i[1];
|
|
210
209
|
|
|
211
210
|
if (typeof value === 'string') {
|
package/dist/index.mjs
CHANGED
|
@@ -5,8 +5,7 @@ import _defineProperty from '@babel/runtime/helpers/defineProperty';
|
|
|
5
5
|
import _regeneratorRuntime from '@babel/runtime/regenerator';
|
|
6
6
|
import { createReactQueryHooks, createTRPCClient } from '@trpc/react';
|
|
7
7
|
import React, { useState, createElement } from 'react';
|
|
8
|
-
import { QueryClient, QueryClientProvider } from 'react-query';
|
|
9
|
-
import { Hydrate, dehydrate } from 'react-query/hydration';
|
|
8
|
+
import { QueryClient, QueryClientProvider, Hydrate, dehydrate } from 'react-query';
|
|
10
9
|
import ssrPrepass from 'react-ssr-prepass';
|
|
11
10
|
|
|
12
11
|
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
@@ -78,7 +77,7 @@ function withTRPC(opts) {
|
|
|
78
77
|
if (AppOrPage.getInitialProps || opts.ssr) {
|
|
79
78
|
WithTRPC.getInitialProps = /*#__PURE__*/function () {
|
|
80
79
|
var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(appOrPageCtx) {
|
|
81
|
-
var _opts$responseMeta
|
|
80
|
+
var _opts$responseMeta;
|
|
82
81
|
|
|
83
82
|
var AppTree, isApp, ctx, pageProps, _originalProps$pagePr, originalProps, originalPageProps, getAppTreeProps, config, trpcClient, queryClient, trpcProp, prepassProps, dehydratedCache, dehydratedCacheWithErrors, appTreeProps, meta, _i, _Object$entries, _Object$entries$_i, key, value, _ctx$res;
|
|
84
83
|
|
|
@@ -182,16 +181,16 @@ function withTRPC(opts) {
|
|
|
182
181
|
|
|
183
182
|
pageProps.trpcState = opts.transformer ? opts.transformer.serialize(dehydratedCacheWithErrors) : dehydratedCacheWithErrors;
|
|
184
183
|
appTreeProps = getAppTreeProps(pageProps);
|
|
185
|
-
meta = (_opts$responseMeta =
|
|
184
|
+
meta = ((_opts$responseMeta = opts.responseMeta) === null || _opts$responseMeta === void 0 ? void 0 : _opts$responseMeta.call(opts, {
|
|
186
185
|
ctx: ctx,
|
|
187
186
|
clientErrors: [].concat(_toConsumableArray(dehydratedCache.queries), _toConsumableArray(dehydratedCache.mutations)).map(function (v) {
|
|
188
187
|
return v.state.error;
|
|
189
188
|
}).flatMap(function (err) {
|
|
190
189
|
return err instanceof Error && err.name === 'TRPCClientError' ? [err] : [];
|
|
191
190
|
})
|
|
192
|
-
}))
|
|
191
|
+
})) || {};
|
|
193
192
|
|
|
194
|
-
for (_i = 0, _Object$entries = Object.entries(meta); _i < _Object$entries.length; _i++) {
|
|
193
|
+
for (_i = 0, _Object$entries = Object.entries(meta.headers || {}); _i < _Object$entries.length; _i++) {
|
|
195
194
|
_Object$entries$_i = _slicedToArray(_Object$entries[_i], 2), key = _Object$entries$_i[0], value = _Object$entries$_i[1];
|
|
196
195
|
|
|
197
196
|
if (typeof value === 'string') {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@trpc/next",
|
|
3
|
-
"version": "10.0.0-alpha.
|
|
3
|
+
"version": "10.0.0-alpha.7",
|
|
4
4
|
"description": "tRPC Next lib",
|
|
5
5
|
"author": "KATT",
|
|
6
6
|
"license": "MIT",
|
|
@@ -34,9 +34,9 @@
|
|
|
34
34
|
}
|
|
35
35
|
},
|
|
36
36
|
"peerDependencies": {
|
|
37
|
-
"@trpc/client": "10.0.0-alpha.
|
|
38
|
-
"@trpc/react": "10.0.0-alpha.
|
|
39
|
-
"@trpc/server": "10.0.0-alpha.
|
|
37
|
+
"@trpc/client": "10.0.0-alpha.7",
|
|
38
|
+
"@trpc/react": "10.0.0-alpha.7",
|
|
39
|
+
"@trpc/server": "10.0.0-alpha.7",
|
|
40
40
|
"next": "*",
|
|
41
41
|
"react": ">=16.8.0",
|
|
42
42
|
"react-dom": ">=16.8.0",
|
|
@@ -47,9 +47,9 @@
|
|
|
47
47
|
"react-ssr-prepass": "^1.5.0"
|
|
48
48
|
},
|
|
49
49
|
"devDependencies": {
|
|
50
|
-
"@trpc/client": "10.0.0-alpha.
|
|
51
|
-
"@trpc/react": "10.0.0-alpha.
|
|
52
|
-
"@trpc/server": "10.0.0-alpha.
|
|
50
|
+
"@trpc/client": "10.0.0-alpha.7",
|
|
51
|
+
"@trpc/react": "10.0.0-alpha.7",
|
|
52
|
+
"@trpc/server": "10.0.0-alpha.7",
|
|
53
53
|
"@types/express": "^4.17.12",
|
|
54
54
|
"express": "^4.17.1",
|
|
55
55
|
"next": "^12.0.1",
|
|
@@ -61,5 +61,5 @@
|
|
|
61
61
|
"publishConfig": {
|
|
62
62
|
"access": "public"
|
|
63
63
|
},
|
|
64
|
-
"gitHead": "
|
|
64
|
+
"gitHead": "9ce78e41fc0e506172fc78a28f05d4c0b2047ef0"
|
|
65
65
|
}
|
package/src/withTRPC.tsx
CHANGED
|
@@ -21,7 +21,7 @@ import {
|
|
|
21
21
|
import type { CreateTRPCClientOptions } from '@trpc/client/src/internals/TRPCClient';
|
|
22
22
|
import React, { createElement, useState } from 'react';
|
|
23
23
|
import { QueryClient, QueryClientProvider } from 'react-query';
|
|
24
|
-
import { dehydrate, DehydratedState, Hydrate } from 'react-query
|
|
24
|
+
import { dehydrate, DehydratedState, Hydrate } from 'react-query';
|
|
25
25
|
import ssrPrepass from 'react-ssr-prepass';
|
|
26
26
|
|
|
27
27
|
type QueryClientConfig = ConstructorParameters<typeof QueryClient>[0];
|
|
@@ -230,9 +230,9 @@ export function withTRPC<TRouter extends AnyRouter>(
|
|
|
230
230
|
? [err as TRPCClientError<TRouter>]
|
|
231
231
|
: [],
|
|
232
232
|
),
|
|
233
|
-
})
|
|
233
|
+
}) || {};
|
|
234
234
|
|
|
235
|
-
for (const [key, value] of Object.entries(meta)) {
|
|
235
|
+
for (const [key, value] of Object.entries(meta.headers || {})) {
|
|
236
236
|
if (typeof value === 'string') {
|
|
237
237
|
ctx.res?.setHeader(key, value);
|
|
238
238
|
}
|