@tanstack/react-query-next-experimental 5.0.0-alpha.86 → 5.0.0-alpha.87
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/build/legacy/HydrationStreamProvider.cjs +116 -0
- package/build/legacy/HydrationStreamProvider.cjs.map +1 -0
- package/build/legacy/HydrationStreamProvider.d.cts +58 -0
- package/build/{lib → legacy}/HydrationStreamProvider.d.ts +5 -4
- package/build/legacy/HydrationStreamProvider.js +82 -0
- package/build/legacy/HydrationStreamProvider.js.map +1 -0
- package/build/legacy/ReactQueryStreamedHydration.cjs +84 -0
- package/build/legacy/ReactQueryStreamedHydration.cjs.map +1 -0
- package/build/legacy/ReactQueryStreamedHydration.d.cts +20 -0
- package/build/{lib → legacy}/ReactQueryStreamedHydration.d.ts +6 -4
- package/build/legacy/ReactQueryStreamedHydration.js +55 -0
- package/build/legacy/ReactQueryStreamedHydration.js.map +1 -0
- package/build/legacy/index.cjs +29 -0
- package/build/legacy/index.cjs.map +1 -0
- package/build/legacy/index.d.cts +4 -0
- package/build/legacy/index.d.ts +4 -0
- package/build/legacy/index.js +5 -0
- package/build/legacy/index.js.map +1 -0
- package/build/modern/HydrationStreamProvider.cjs +115 -0
- package/build/modern/HydrationStreamProvider.cjs.map +1 -0
- package/build/modern/HydrationStreamProvider.d.cts +58 -0
- package/build/modern/HydrationStreamProvider.d.ts +58 -0
- package/build/modern/HydrationStreamProvider.js +81 -0
- package/build/modern/HydrationStreamProvider.js.map +1 -0
- package/build/modern/ReactQueryStreamedHydration.cjs +82 -0
- package/build/modern/ReactQueryStreamedHydration.cjs.map +1 -0
- package/build/modern/ReactQueryStreamedHydration.d.cts +20 -0
- package/build/modern/ReactQueryStreamedHydration.d.ts +20 -0
- package/build/modern/ReactQueryStreamedHydration.js +53 -0
- package/build/modern/ReactQueryStreamedHydration.js.map +1 -0
- package/build/modern/index.cjs +29 -0
- package/build/modern/index.cjs.map +1 -0
- package/build/modern/index.d.cts +4 -0
- package/build/modern/index.d.ts +4 -0
- package/build/modern/index.js +5 -0
- package/build/modern/index.js.map +1 -0
- package/package.json +17 -15
- package/build/lib/HydrationStreamProvider.cjs +0 -120
- package/build/lib/HydrationStreamProvider.cjs.map +0 -1
- package/build/lib/HydrationStreamProvider.d.ts.map +0 -1
- package/build/lib/HydrationStreamProvider.js +0 -99
- package/build/lib/HydrationStreamProvider.js.map +0 -1
- package/build/lib/HydrationStreamProvider.legacy.cjs +0 -125
- package/build/lib/HydrationStreamProvider.legacy.cjs.map +0 -1
- package/build/lib/HydrationStreamProvider.legacy.js +0 -104
- package/build/lib/HydrationStreamProvider.legacy.js.map +0 -1
- package/build/lib/ReactQueryStreamedHydration.cjs +0 -89
- package/build/lib/ReactQueryStreamedHydration.cjs.map +0 -1
- package/build/lib/ReactQueryStreamedHydration.d.ts.map +0 -1
- package/build/lib/ReactQueryStreamedHydration.js +0 -68
- package/build/lib/ReactQueryStreamedHydration.js.map +0 -1
- package/build/lib/ReactQueryStreamedHydration.legacy.cjs +0 -91
- package/build/lib/ReactQueryStreamedHydration.legacy.cjs.map +0 -1
- package/build/lib/ReactQueryStreamedHydration.legacy.js +0 -70
- package/build/lib/ReactQueryStreamedHydration.legacy.js.map +0 -1
- package/build/lib/index.cjs +0 -8
- package/build/lib/index.cjs.map +0 -1
- package/build/lib/index.d.ts +0 -2
- package/build/lib/index.d.ts.map +0 -1
- package/build/lib/index.js +0 -2
- package/build/lib/index.js.map +0 -1
- package/build/lib/index.legacy.cjs +0 -8
- package/build/lib/index.legacy.cjs.map +0 -1
- package/build/lib/index.legacy.js +0 -2
- package/build/lib/index.legacy.js.map +0 -1
|
@@ -1,89 +0,0 @@
|
|
|
1
|
-
'use client';
|
|
2
|
-
'use strict';
|
|
3
|
-
|
|
4
|
-
var reactQuery = require('@tanstack/react-query');
|
|
5
|
-
var React = require('react');
|
|
6
|
-
var HydrationStreamProvider = require('./HydrationStreamProvider.cjs');
|
|
7
|
-
|
|
8
|
-
function _interopNamespaceDefault(e) {
|
|
9
|
-
var n = Object.create(null);
|
|
10
|
-
if (e) {
|
|
11
|
-
Object.keys(e).forEach(function (k) {
|
|
12
|
-
if (k !== 'default') {
|
|
13
|
-
var d = Object.getOwnPropertyDescriptor(e, k);
|
|
14
|
-
Object.defineProperty(n, k, d.get ? d : {
|
|
15
|
-
enumerable: true,
|
|
16
|
-
get: function () { return e[k]; }
|
|
17
|
-
});
|
|
18
|
-
}
|
|
19
|
-
});
|
|
20
|
-
}
|
|
21
|
-
n.default = e;
|
|
22
|
-
return Object.freeze(n);
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
var React__namespace = /*#__PURE__*/_interopNamespaceDefault(React);
|
|
26
|
-
|
|
27
|
-
const stream = HydrationStreamProvider.createHydrationStreamProvider();
|
|
28
|
-
|
|
29
|
-
/**
|
|
30
|
-
* This component is responsible for:
|
|
31
|
-
* - hydrating the query client on the server
|
|
32
|
-
* - dehydrating the query client on the server
|
|
33
|
-
*/
|
|
34
|
-
function ReactQueryStreamedHydration(props) {
|
|
35
|
-
const queryClient = reactQuery.useQueryClient(props.queryClient);
|
|
36
|
-
|
|
37
|
-
/**
|
|
38
|
-
* We need to track which queries were added/updated during the render
|
|
39
|
-
*/
|
|
40
|
-
const [trackedKeys] = React__namespace.useState(() => new Set());
|
|
41
|
-
|
|
42
|
-
// <server only>
|
|
43
|
-
if (typeof window === 'undefined') {
|
|
44
|
-
// Do we need to care about unsubscribing? I don't think so to be honest
|
|
45
|
-
queryClient.getQueryCache().subscribe(event => {
|
|
46
|
-
switch (event.type) {
|
|
47
|
-
case 'added':
|
|
48
|
-
case 'updated':
|
|
49
|
-
// console.log('tracking', event.query.queryHash, 'b/c of a', event.type)
|
|
50
|
-
trackedKeys.add(event.query.queryHash);
|
|
51
|
-
}
|
|
52
|
-
});
|
|
53
|
-
}
|
|
54
|
-
// </server only>
|
|
55
|
-
|
|
56
|
-
return /*#__PURE__*/React__namespace.createElement(stream.Provider, {
|
|
57
|
-
// Happens on server:
|
|
58
|
-
onFlush: () => {
|
|
59
|
-
/**
|
|
60
|
-
* Dehydrated state of the client where we only include the queries that were added/updated since the last flush
|
|
61
|
-
*/
|
|
62
|
-
const shouldDehydrate = props.options?.dehydrate?.shouldDehydrateQuery ?? reactQuery.defaultShouldDehydrateQuery;
|
|
63
|
-
const dehydratedState = reactQuery.dehydrate(queryClient, {
|
|
64
|
-
...props.options?.dehydrate,
|
|
65
|
-
shouldDehydrateQuery(query) {
|
|
66
|
-
return trackedKeys.has(query.queryHash) && shouldDehydrate(query);
|
|
67
|
-
}
|
|
68
|
-
});
|
|
69
|
-
trackedKeys.clear();
|
|
70
|
-
if (!dehydratedState.queries.length) {
|
|
71
|
-
return [];
|
|
72
|
-
}
|
|
73
|
-
return [dehydratedState];
|
|
74
|
-
}
|
|
75
|
-
// Happens in browser:
|
|
76
|
-
,
|
|
77
|
-
onEntries: entries => {
|
|
78
|
-
for (const hydratedState of entries) {
|
|
79
|
-
reactQuery.hydrate(queryClient, hydratedState, props.options?.hydrate);
|
|
80
|
-
}
|
|
81
|
-
}
|
|
82
|
-
// Handle BigInts etc using superjson
|
|
83
|
-
,
|
|
84
|
-
transformer: props.transformer
|
|
85
|
-
}, props.children);
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
exports.ReactQueryStreamedHydration = ReactQueryStreamedHydration;
|
|
89
|
-
//# sourceMappingURL=ReactQueryStreamedHydration.cjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ReactQueryStreamedHydration.cjs","sources":["../../src/ReactQueryStreamedHydration.tsx"],"sourcesContent":["'use client'\n\nimport {\n defaultShouldDehydrateQuery,\n dehydrate,\n hydrate,\n useQueryClient,\n} from '@tanstack/react-query'\nimport * as React from 'react'\nimport { createHydrationStreamProvider } from './HydrationStreamProvider'\nimport type { HydrationStreamProviderProps } from './HydrationStreamProvider'\nimport type {\n DehydrateOptions,\n DehydratedState,\n HydrateOptions,\n QueryClient,\n} from '@tanstack/react-query'\n\nconst stream = createHydrationStreamProvider<DehydratedState>()\n\n/**\n * This component is responsible for:\n * - hydrating the query client on the server\n * - dehydrating the query client on the server\n */\nexport function ReactQueryStreamedHydration(props: {\n children: React.ReactNode\n queryClient?: QueryClient\n options?: {\n hydrate?: HydrateOptions\n dehydrate?: DehydrateOptions\n }\n transformer?: HydrationStreamProviderProps<DehydratedState>['transformer']\n}) {\n const queryClient = useQueryClient(props.queryClient)\n\n /**\n * We need to track which queries were added/updated during the render\n */\n const [trackedKeys] = React.useState(() => new Set<string>())\n\n // <server only>\n if (typeof window === 'undefined') {\n // Do we need to care about unsubscribing? I don't think so to be honest\n queryClient.getQueryCache().subscribe((event) => {\n switch (event.type) {\n case 'added':\n case 'updated':\n // console.log('tracking', event.query.queryHash, 'b/c of a', event.type)\n trackedKeys.add(event.query.queryHash)\n }\n })\n }\n // </server only>\n\n return (\n <stream.Provider\n // Happens on server:\n onFlush={() => {\n /**\n * Dehydrated state of the client where we only include the queries that were added/updated since the last flush\n */\n const shouldDehydrate =\n props.options?.dehydrate?.shouldDehydrateQuery ??\n defaultShouldDehydrateQuery\n\n const dehydratedState = dehydrate(queryClient, {\n ...props.options?.dehydrate,\n shouldDehydrateQuery(query) {\n return trackedKeys.has(query.queryHash) && shouldDehydrate(query)\n },\n })\n trackedKeys.clear()\n\n if (!dehydratedState.queries.length) {\n return []\n }\n\n return [dehydratedState]\n }}\n // Happens in browser:\n onEntries={(entries) => {\n for (const hydratedState of entries) {\n hydrate(queryClient, hydratedState, props.options?.hydrate)\n }\n }}\n // Handle BigInts etc using superjson\n transformer={props.transformer}\n >\n {props.children}\n </stream.Provider>\n )\n}\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAkBA;;AAEA;AACA;AACA;AACA;AACA;AACO;AASL;;AAEA;AACF;AACA;AACE;;AAEA;AACA;AACE;;;AAGI;AACA;AACE;;AAEJ;AACF;AACF;AACA;;AAEA;AAEI;;AAEE;AACR;AACA;;AAKQ;AACE;;AAEE;AACF;AACF;;AAGA;AACE;AACF;;AAGF;AACA;AAAA;;AAEE;;AAEA;AACF;AACA;AAAA;;;AAMN;;"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ReactQueryStreamedHydration.d.ts","sourceRoot":"","sources":["../../src/ReactQueryStreamedHydration.tsx"],"names":[],"mappings":"AAQA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAE9B,OAAO,KAAK,EAAE,4BAA4B,EAAE,MAAM,2BAA2B,CAAA;AAC7E,OAAO,KAAK,EACV,gBAAgB,EAChB,eAAe,EACf,cAAc,EACd,WAAW,EACZ,MAAM,uBAAuB,CAAA;AAI9B;;;;GAIG;AACH,wBAAgB,2BAA2B,CAAC,KAAK,EAAE;IACjD,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAA;IACzB,WAAW,CAAC,EAAE,WAAW,CAAA;IACzB,OAAO,CAAC,EAAE;QACR,OAAO,CAAC,EAAE,cAAc,CAAA;QACxB,SAAS,CAAC,EAAE,gBAAgB,CAAA;KAC7B,CAAA;IACD,WAAW,CAAC,EAAE,4BAA4B,CAAC,eAAe,CAAC,CAAC,aAAa,CAAC,CAAA;CAC3E,qBA2DA"}
|
|
@@ -1,68 +0,0 @@
|
|
|
1
|
-
'use client';
|
|
2
|
-
import { useQueryClient, defaultShouldDehydrateQuery, dehydrate, hydrate } from '@tanstack/react-query';
|
|
3
|
-
import * as React from 'react';
|
|
4
|
-
import { createHydrationStreamProvider } from './HydrationStreamProvider.js';
|
|
5
|
-
|
|
6
|
-
const stream = createHydrationStreamProvider();
|
|
7
|
-
|
|
8
|
-
/**
|
|
9
|
-
* This component is responsible for:
|
|
10
|
-
* - hydrating the query client on the server
|
|
11
|
-
* - dehydrating the query client on the server
|
|
12
|
-
*/
|
|
13
|
-
function ReactQueryStreamedHydration(props) {
|
|
14
|
-
const queryClient = useQueryClient(props.queryClient);
|
|
15
|
-
|
|
16
|
-
/**
|
|
17
|
-
* We need to track which queries were added/updated during the render
|
|
18
|
-
*/
|
|
19
|
-
const [trackedKeys] = React.useState(() => new Set());
|
|
20
|
-
|
|
21
|
-
// <server only>
|
|
22
|
-
if (typeof window === 'undefined') {
|
|
23
|
-
// Do we need to care about unsubscribing? I don't think so to be honest
|
|
24
|
-
queryClient.getQueryCache().subscribe(event => {
|
|
25
|
-
switch (event.type) {
|
|
26
|
-
case 'added':
|
|
27
|
-
case 'updated':
|
|
28
|
-
// console.log('tracking', event.query.queryHash, 'b/c of a', event.type)
|
|
29
|
-
trackedKeys.add(event.query.queryHash);
|
|
30
|
-
}
|
|
31
|
-
});
|
|
32
|
-
}
|
|
33
|
-
// </server only>
|
|
34
|
-
|
|
35
|
-
return /*#__PURE__*/React.createElement(stream.Provider, {
|
|
36
|
-
// Happens on server:
|
|
37
|
-
onFlush: () => {
|
|
38
|
-
/**
|
|
39
|
-
* Dehydrated state of the client where we only include the queries that were added/updated since the last flush
|
|
40
|
-
*/
|
|
41
|
-
const shouldDehydrate = props.options?.dehydrate?.shouldDehydrateQuery ?? defaultShouldDehydrateQuery;
|
|
42
|
-
const dehydratedState = dehydrate(queryClient, {
|
|
43
|
-
...props.options?.dehydrate,
|
|
44
|
-
shouldDehydrateQuery(query) {
|
|
45
|
-
return trackedKeys.has(query.queryHash) && shouldDehydrate(query);
|
|
46
|
-
}
|
|
47
|
-
});
|
|
48
|
-
trackedKeys.clear();
|
|
49
|
-
if (!dehydratedState.queries.length) {
|
|
50
|
-
return [];
|
|
51
|
-
}
|
|
52
|
-
return [dehydratedState];
|
|
53
|
-
}
|
|
54
|
-
// Happens in browser:
|
|
55
|
-
,
|
|
56
|
-
onEntries: entries => {
|
|
57
|
-
for (const hydratedState of entries) {
|
|
58
|
-
hydrate(queryClient, hydratedState, props.options?.hydrate);
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
// Handle BigInts etc using superjson
|
|
62
|
-
,
|
|
63
|
-
transformer: props.transformer
|
|
64
|
-
}, props.children);
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
export { ReactQueryStreamedHydration };
|
|
68
|
-
//# sourceMappingURL=ReactQueryStreamedHydration.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ReactQueryStreamedHydration.js","sources":["../../src/ReactQueryStreamedHydration.tsx"],"sourcesContent":["'use client'\n\nimport {\n defaultShouldDehydrateQuery,\n dehydrate,\n hydrate,\n useQueryClient,\n} from '@tanstack/react-query'\nimport * as React from 'react'\nimport { createHydrationStreamProvider } from './HydrationStreamProvider'\nimport type { HydrationStreamProviderProps } from './HydrationStreamProvider'\nimport type {\n DehydrateOptions,\n DehydratedState,\n HydrateOptions,\n QueryClient,\n} from '@tanstack/react-query'\n\nconst stream = createHydrationStreamProvider<DehydratedState>()\n\n/**\n * This component is responsible for:\n * - hydrating the query client on the server\n * - dehydrating the query client on the server\n */\nexport function ReactQueryStreamedHydration(props: {\n children: React.ReactNode\n queryClient?: QueryClient\n options?: {\n hydrate?: HydrateOptions\n dehydrate?: DehydrateOptions\n }\n transformer?: HydrationStreamProviderProps<DehydratedState>['transformer']\n}) {\n const queryClient = useQueryClient(props.queryClient)\n\n /**\n * We need to track which queries were added/updated during the render\n */\n const [trackedKeys] = React.useState(() => new Set<string>())\n\n // <server only>\n if (typeof window === 'undefined') {\n // Do we need to care about unsubscribing? I don't think so to be honest\n queryClient.getQueryCache().subscribe((event) => {\n switch (event.type) {\n case 'added':\n case 'updated':\n // console.log('tracking', event.query.queryHash, 'b/c of a', event.type)\n trackedKeys.add(event.query.queryHash)\n }\n })\n }\n // </server only>\n\n return (\n <stream.Provider\n // Happens on server:\n onFlush={() => {\n /**\n * Dehydrated state of the client where we only include the queries that were added/updated since the last flush\n */\n const shouldDehydrate =\n props.options?.dehydrate?.shouldDehydrateQuery ??\n defaultShouldDehydrateQuery\n\n const dehydratedState = dehydrate(queryClient, {\n ...props.options?.dehydrate,\n shouldDehydrateQuery(query) {\n return trackedKeys.has(query.queryHash) && shouldDehydrate(query)\n },\n })\n trackedKeys.clear()\n\n if (!dehydratedState.queries.length) {\n return []\n }\n\n return [dehydratedState]\n }}\n // Happens in browser:\n onEntries={(entries) => {\n for (const hydratedState of entries) {\n hydrate(queryClient, hydratedState, props.options?.hydrate)\n }\n }}\n // Handle BigInts etc using superjson\n transformer={props.transformer}\n >\n {props.children}\n </stream.Provider>\n )\n}\n"],"names":[],"mappings":";;;;;AAkBA;;AAEA;AACA;AACA;AACA;AACA;AACO;AASL;;AAEA;AACF;AACA;AACE;;AAEA;AACA;AACE;;;AAGI;AACA;AACE;;AAEJ;AACF;AACF;AACA;;AAEA;AAEI;;AAEE;AACR;AACA;;AAKQ;AACE;;AAEE;AACF;AACF;;AAGA;AACE;AACF;;AAGF;AACA;AAAA;;AAEE;;AAEA;AACF;AACA;AAAA;;;AAMN;;"}
|
|
@@ -1,91 +0,0 @@
|
|
|
1
|
-
'use client';
|
|
2
|
-
'use strict';
|
|
3
|
-
|
|
4
|
-
var reactQuery = require('@tanstack/react-query');
|
|
5
|
-
var React = require('react');
|
|
6
|
-
var HydrationStreamProvider = require('./HydrationStreamProvider.legacy.cjs');
|
|
7
|
-
|
|
8
|
-
function _interopNamespaceDefault(e) {
|
|
9
|
-
var n = Object.create(null);
|
|
10
|
-
if (e) {
|
|
11
|
-
Object.keys(e).forEach(function (k) {
|
|
12
|
-
if (k !== 'default') {
|
|
13
|
-
var d = Object.getOwnPropertyDescriptor(e, k);
|
|
14
|
-
Object.defineProperty(n, k, d.get ? d : {
|
|
15
|
-
enumerable: true,
|
|
16
|
-
get: function () { return e[k]; }
|
|
17
|
-
});
|
|
18
|
-
}
|
|
19
|
-
});
|
|
20
|
-
}
|
|
21
|
-
n.default = e;
|
|
22
|
-
return Object.freeze(n);
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
var React__namespace = /*#__PURE__*/_interopNamespaceDefault(React);
|
|
26
|
-
|
|
27
|
-
const stream = HydrationStreamProvider.createHydrationStreamProvider();
|
|
28
|
-
|
|
29
|
-
/**
|
|
30
|
-
* This component is responsible for:
|
|
31
|
-
* - hydrating the query client on the server
|
|
32
|
-
* - dehydrating the query client on the server
|
|
33
|
-
*/
|
|
34
|
-
function ReactQueryStreamedHydration(props) {
|
|
35
|
-
const queryClient = reactQuery.useQueryClient(props.queryClient);
|
|
36
|
-
|
|
37
|
-
/**
|
|
38
|
-
* We need to track which queries were added/updated during the render
|
|
39
|
-
*/
|
|
40
|
-
const [trackedKeys] = React__namespace.useState(() => new Set());
|
|
41
|
-
|
|
42
|
-
// <server only>
|
|
43
|
-
if (typeof window === 'undefined') {
|
|
44
|
-
// Do we need to care about unsubscribing? I don't think so to be honest
|
|
45
|
-
queryClient.getQueryCache().subscribe(event => {
|
|
46
|
-
switch (event.type) {
|
|
47
|
-
case 'added':
|
|
48
|
-
case 'updated':
|
|
49
|
-
// console.log('tracking', event.query.queryHash, 'b/c of a', event.type)
|
|
50
|
-
trackedKeys.add(event.query.queryHash);
|
|
51
|
-
}
|
|
52
|
-
});
|
|
53
|
-
}
|
|
54
|
-
// </server only>
|
|
55
|
-
|
|
56
|
-
return /*#__PURE__*/React__namespace.createElement(stream.Provider, {
|
|
57
|
-
// Happens on server:
|
|
58
|
-
onFlush: () => {
|
|
59
|
-
var _props$options$dehydr, _props$options, _props$options$dehydr2, _props$options2;
|
|
60
|
-
/**
|
|
61
|
-
* Dehydrated state of the client where we only include the queries that were added/updated since the last flush
|
|
62
|
-
*/
|
|
63
|
-
const shouldDehydrate = (_props$options$dehydr = (_props$options = props.options) == null ? void 0 : (_props$options$dehydr2 = _props$options.dehydrate) == null ? void 0 : _props$options$dehydr2.shouldDehydrateQuery) != null ? _props$options$dehydr : reactQuery.defaultShouldDehydrateQuery;
|
|
64
|
-
const dehydratedState = reactQuery.dehydrate(queryClient, {
|
|
65
|
-
...((_props$options2 = props.options) == null ? void 0 : _props$options2.dehydrate),
|
|
66
|
-
shouldDehydrateQuery(query) {
|
|
67
|
-
return trackedKeys.has(query.queryHash) && shouldDehydrate(query);
|
|
68
|
-
}
|
|
69
|
-
});
|
|
70
|
-
trackedKeys.clear();
|
|
71
|
-
if (!dehydratedState.queries.length) {
|
|
72
|
-
return [];
|
|
73
|
-
}
|
|
74
|
-
return [dehydratedState];
|
|
75
|
-
}
|
|
76
|
-
// Happens in browser:
|
|
77
|
-
,
|
|
78
|
-
onEntries: entries => {
|
|
79
|
-
for (const hydratedState of entries) {
|
|
80
|
-
var _props$options3;
|
|
81
|
-
reactQuery.hydrate(queryClient, hydratedState, (_props$options3 = props.options) == null ? void 0 : _props$options3.hydrate);
|
|
82
|
-
}
|
|
83
|
-
}
|
|
84
|
-
// Handle BigInts etc using superjson
|
|
85
|
-
,
|
|
86
|
-
transformer: props.transformer
|
|
87
|
-
}, props.children);
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
exports.ReactQueryStreamedHydration = ReactQueryStreamedHydration;
|
|
91
|
-
//# sourceMappingURL=ReactQueryStreamedHydration.legacy.cjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ReactQueryStreamedHydration.legacy.cjs","sources":["../../src/ReactQueryStreamedHydration.tsx"],"sourcesContent":["'use client'\n\nimport {\n defaultShouldDehydrateQuery,\n dehydrate,\n hydrate,\n useQueryClient,\n} from '@tanstack/react-query'\nimport * as React from 'react'\nimport { createHydrationStreamProvider } from './HydrationStreamProvider'\nimport type { HydrationStreamProviderProps } from './HydrationStreamProvider'\nimport type {\n DehydrateOptions,\n DehydratedState,\n HydrateOptions,\n QueryClient,\n} from '@tanstack/react-query'\n\nconst stream = createHydrationStreamProvider<DehydratedState>()\n\n/**\n * This component is responsible for:\n * - hydrating the query client on the server\n * - dehydrating the query client on the server\n */\nexport function ReactQueryStreamedHydration(props: {\n children: React.ReactNode\n queryClient?: QueryClient\n options?: {\n hydrate?: HydrateOptions\n dehydrate?: DehydrateOptions\n }\n transformer?: HydrationStreamProviderProps<DehydratedState>['transformer']\n}) {\n const queryClient = useQueryClient(props.queryClient)\n\n /**\n * We need to track which queries were added/updated during the render\n */\n const [trackedKeys] = React.useState(() => new Set<string>())\n\n // <server only>\n if (typeof window === 'undefined') {\n // Do we need to care about unsubscribing? I don't think so to be honest\n queryClient.getQueryCache().subscribe((event) => {\n switch (event.type) {\n case 'added':\n case 'updated':\n // console.log('tracking', event.query.queryHash, 'b/c of a', event.type)\n trackedKeys.add(event.query.queryHash)\n }\n })\n }\n // </server only>\n\n return (\n <stream.Provider\n // Happens on server:\n onFlush={() => {\n /**\n * Dehydrated state of the client where we only include the queries that were added/updated since the last flush\n */\n const shouldDehydrate =\n props.options?.dehydrate?.shouldDehydrateQuery ??\n defaultShouldDehydrateQuery\n\n const dehydratedState = dehydrate(queryClient, {\n ...props.options?.dehydrate,\n shouldDehydrateQuery(query) {\n return trackedKeys.has(query.queryHash) && shouldDehydrate(query)\n },\n })\n trackedKeys.clear()\n\n if (!dehydratedState.queries.length) {\n return []\n }\n\n return [dehydratedState]\n }}\n // Happens in browser:\n onEntries={(entries) => {\n for (const hydratedState of entries) {\n hydrate(queryClient, hydratedState, props.options?.hydrate)\n }\n }}\n // Handle BigInts etc using superjson\n transformer={props.transformer}\n >\n {props.children}\n </stream.Provider>\n )\n}\n"],"names":["hydrate"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAkBA;;AAEA;AACA;AACA;AACA;AACA;AACO;AASL;;AAEA;AACF;AACA;AACE;;AAEA;AACA;AACE;;;AAGI;AACA;AACE;;AAEJ;AACF;AACF;AACA;;AAEA;AAEI;;AACe;AACb;AACR;AACA;;AAKQ;;;AAGI;AACF;AACF;;AAGA;AACE;AACF;;AAGF;AACA;AAAA;;AAEE;AAAqC;AACnCA;AACF;AACF;AACA;AAAA;;;AAMN;;"}
|
|
@@ -1,70 +0,0 @@
|
|
|
1
|
-
'use client';
|
|
2
|
-
import { useQueryClient, defaultShouldDehydrateQuery, dehydrate, hydrate } from '@tanstack/react-query';
|
|
3
|
-
import * as React from 'react';
|
|
4
|
-
import { createHydrationStreamProvider } from './HydrationStreamProvider.legacy.js';
|
|
5
|
-
|
|
6
|
-
const stream = createHydrationStreamProvider();
|
|
7
|
-
|
|
8
|
-
/**
|
|
9
|
-
* This component is responsible for:
|
|
10
|
-
* - hydrating the query client on the server
|
|
11
|
-
* - dehydrating the query client on the server
|
|
12
|
-
*/
|
|
13
|
-
function ReactQueryStreamedHydration(props) {
|
|
14
|
-
const queryClient = useQueryClient(props.queryClient);
|
|
15
|
-
|
|
16
|
-
/**
|
|
17
|
-
* We need to track which queries were added/updated during the render
|
|
18
|
-
*/
|
|
19
|
-
const [trackedKeys] = React.useState(() => new Set());
|
|
20
|
-
|
|
21
|
-
// <server only>
|
|
22
|
-
if (typeof window === 'undefined') {
|
|
23
|
-
// Do we need to care about unsubscribing? I don't think so to be honest
|
|
24
|
-
queryClient.getQueryCache().subscribe(event => {
|
|
25
|
-
switch (event.type) {
|
|
26
|
-
case 'added':
|
|
27
|
-
case 'updated':
|
|
28
|
-
// console.log('tracking', event.query.queryHash, 'b/c of a', event.type)
|
|
29
|
-
trackedKeys.add(event.query.queryHash);
|
|
30
|
-
}
|
|
31
|
-
});
|
|
32
|
-
}
|
|
33
|
-
// </server only>
|
|
34
|
-
|
|
35
|
-
return /*#__PURE__*/React.createElement(stream.Provider, {
|
|
36
|
-
// Happens on server:
|
|
37
|
-
onFlush: () => {
|
|
38
|
-
var _props$options$dehydr, _props$options, _props$options$dehydr2, _props$options2;
|
|
39
|
-
/**
|
|
40
|
-
* Dehydrated state of the client where we only include the queries that were added/updated since the last flush
|
|
41
|
-
*/
|
|
42
|
-
const shouldDehydrate = (_props$options$dehydr = (_props$options = props.options) == null ? void 0 : (_props$options$dehydr2 = _props$options.dehydrate) == null ? void 0 : _props$options$dehydr2.shouldDehydrateQuery) != null ? _props$options$dehydr : defaultShouldDehydrateQuery;
|
|
43
|
-
const dehydratedState = dehydrate(queryClient, {
|
|
44
|
-
...((_props$options2 = props.options) == null ? void 0 : _props$options2.dehydrate),
|
|
45
|
-
shouldDehydrateQuery(query) {
|
|
46
|
-
return trackedKeys.has(query.queryHash) && shouldDehydrate(query);
|
|
47
|
-
}
|
|
48
|
-
});
|
|
49
|
-
trackedKeys.clear();
|
|
50
|
-
if (!dehydratedState.queries.length) {
|
|
51
|
-
return [];
|
|
52
|
-
}
|
|
53
|
-
return [dehydratedState];
|
|
54
|
-
}
|
|
55
|
-
// Happens in browser:
|
|
56
|
-
,
|
|
57
|
-
onEntries: entries => {
|
|
58
|
-
for (const hydratedState of entries) {
|
|
59
|
-
var _props$options3;
|
|
60
|
-
hydrate(queryClient, hydratedState, (_props$options3 = props.options) == null ? void 0 : _props$options3.hydrate);
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
// Handle BigInts etc using superjson
|
|
64
|
-
,
|
|
65
|
-
transformer: props.transformer
|
|
66
|
-
}, props.children);
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
export { ReactQueryStreamedHydration };
|
|
70
|
-
//# sourceMappingURL=ReactQueryStreamedHydration.legacy.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ReactQueryStreamedHydration.legacy.js","sources":["../../src/ReactQueryStreamedHydration.tsx"],"sourcesContent":["'use client'\n\nimport {\n defaultShouldDehydrateQuery,\n dehydrate,\n hydrate,\n useQueryClient,\n} from '@tanstack/react-query'\nimport * as React from 'react'\nimport { createHydrationStreamProvider } from './HydrationStreamProvider'\nimport type { HydrationStreamProviderProps } from './HydrationStreamProvider'\nimport type {\n DehydrateOptions,\n DehydratedState,\n HydrateOptions,\n QueryClient,\n} from '@tanstack/react-query'\n\nconst stream = createHydrationStreamProvider<DehydratedState>()\n\n/**\n * This component is responsible for:\n * - hydrating the query client on the server\n * - dehydrating the query client on the server\n */\nexport function ReactQueryStreamedHydration(props: {\n children: React.ReactNode\n queryClient?: QueryClient\n options?: {\n hydrate?: HydrateOptions\n dehydrate?: DehydrateOptions\n }\n transformer?: HydrationStreamProviderProps<DehydratedState>['transformer']\n}) {\n const queryClient = useQueryClient(props.queryClient)\n\n /**\n * We need to track which queries were added/updated during the render\n */\n const [trackedKeys] = React.useState(() => new Set<string>())\n\n // <server only>\n if (typeof window === 'undefined') {\n // Do we need to care about unsubscribing? I don't think so to be honest\n queryClient.getQueryCache().subscribe((event) => {\n switch (event.type) {\n case 'added':\n case 'updated':\n // console.log('tracking', event.query.queryHash, 'b/c of a', event.type)\n trackedKeys.add(event.query.queryHash)\n }\n })\n }\n // </server only>\n\n return (\n <stream.Provider\n // Happens on server:\n onFlush={() => {\n /**\n * Dehydrated state of the client where we only include the queries that were added/updated since the last flush\n */\n const shouldDehydrate =\n props.options?.dehydrate?.shouldDehydrateQuery ??\n defaultShouldDehydrateQuery\n\n const dehydratedState = dehydrate(queryClient, {\n ...props.options?.dehydrate,\n shouldDehydrateQuery(query) {\n return trackedKeys.has(query.queryHash) && shouldDehydrate(query)\n },\n })\n trackedKeys.clear()\n\n if (!dehydratedState.queries.length) {\n return []\n }\n\n return [dehydratedState]\n }}\n // Happens in browser:\n onEntries={(entries) => {\n for (const hydratedState of entries) {\n hydrate(queryClient, hydratedState, props.options?.hydrate)\n }\n }}\n // Handle BigInts etc using superjson\n transformer={props.transformer}\n >\n {props.children}\n </stream.Provider>\n )\n}\n"],"names":["hydrate"],"mappings":";;;;;AAkBA;;AAEA;AACA;AACA;AACA;AACA;AACO;AASL;;AAEA;AACF;AACA;AACE;;AAEA;AACA;AACE;;;AAGI;AACA;AACE;;AAEJ;AACF;AACF;AACA;;AAEA;AAEI;;AACe;AACb;AACR;AACA;;AAKQ;;;AAGI;AACF;AACF;;AAGA;AACE;AACF;;AAGF;AACA;AAAA;;AAEE;AAAqC;AACnCA;AACF;AACF;AACA;AAAA;;;AAMN;;"}
|
package/build/lib/index.cjs
DELETED
package/build/lib/index.cjs.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;"}
|
package/build/lib/index.d.ts
DELETED
package/build/lib/index.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,2BAA2B,EAAE,MAAM,+BAA+B,CAAA"}
|
package/build/lib/index.js
DELETED
package/build/lib/index.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":""}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.legacy.cjs","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.legacy.js","sources":[],"sourcesContent":[],"names":[],"mappings":""}
|