@octanejs/tanstack-query 0.1.9 → 0.1.10
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/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@octanejs/tanstack-query",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.10",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"engines": {
|
|
@@ -40,16 +40,16 @@
|
|
|
40
40
|
"@tanstack/query-core": "^5.0.0"
|
|
41
41
|
},
|
|
42
42
|
"peerDependencies": {
|
|
43
|
-
"octane": "0.1.
|
|
43
|
+
"octane": "0.1.11"
|
|
44
44
|
},
|
|
45
45
|
"devDependencies": {
|
|
46
46
|
"@tanstack/react-query": "^5.0.0",
|
|
47
|
-
"@tsrx/react": "^0.2.
|
|
47
|
+
"@tsrx/react": "^0.2.44",
|
|
48
48
|
"esbuild": "^0.28.1",
|
|
49
49
|
"react": "^19.2.0",
|
|
50
50
|
"react-dom": "^19.2.0",
|
|
51
51
|
"vitest": "^4.1.9",
|
|
52
|
-
"octane": "0.1.
|
|
52
|
+
"octane": "0.1.11"
|
|
53
53
|
},
|
|
54
54
|
"scripts": {
|
|
55
55
|
"test": "vitest run"
|
|
@@ -14,8 +14,17 @@
|
|
|
14
14
|
import { useRef, useMemo, useEffect } from 'octane';
|
|
15
15
|
import { hydrate } from '@tanstack/query-core';
|
|
16
16
|
import { resolveClient } from './context.ts';
|
|
17
|
+
import type { OctaneNode } from 'octane';
|
|
18
|
+
import type { DehydratedState, HydrateOptions, QueryClient } from '@tanstack/query-core';
|
|
17
19
|
|
|
18
|
-
|
|
20
|
+
type HydrationBoundaryProps = {
|
|
21
|
+
state?: unknown;
|
|
22
|
+
options?: HydrateOptions;
|
|
23
|
+
queryClient?: QueryClient;
|
|
24
|
+
children?: OctaneNode;
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
export function HydrationBoundary(props: HydrationBoundaryProps) @{
|
|
19
28
|
const client = resolveClient(props.queryClient);
|
|
20
29
|
const state = props.state;
|
|
21
30
|
|
|
@@ -29,7 +38,7 @@ export function HydrationBoundary(props) @{
|
|
|
29
38
|
const hydrationQueue = useMemo(() => {
|
|
30
39
|
if (state && typeof state === 'object') {
|
|
31
40
|
const queryCache = client.getQueryCache();
|
|
32
|
-
const queries = state.queries || [];
|
|
41
|
+
const queries = (state as DehydratedState).queries || [];
|
|
33
42
|
|
|
34
43
|
const newQueries = [];
|
|
35
44
|
const existingQueries = [];
|
|
@@ -1,11 +1,18 @@
|
|
|
1
1
|
import { useEffect } from 'octane';
|
|
2
2
|
import { QueryClientContext } from './context.ts';
|
|
3
|
+
import type { OctaneNode } from 'octane';
|
|
4
|
+
import type { QueryClient } from '@tanstack/query-core';
|
|
5
|
+
|
|
6
|
+
type QueryClientProviderProps = {
|
|
7
|
+
client: QueryClient;
|
|
8
|
+
children?: OctaneNode;
|
|
9
|
+
};
|
|
3
10
|
|
|
4
11
|
// QueryClientProvider — provides the QueryClient via context and mounts/unmounts
|
|
5
12
|
// it with the component. It's authored in .tsrx because it's a COMPONENT that
|
|
6
13
|
// renders a context Provider with children + a mount effect, which only the
|
|
7
14
|
// octane compiler can emit (the binding's hooks stay plain TS).
|
|
8
|
-
export function QueryClientProvider(props) @{
|
|
15
|
+
export function QueryClientProvider(props: QueryClientProviderProps) @{
|
|
9
16
|
useEffect(() => {
|
|
10
17
|
props.client.mount();
|
|
11
18
|
return () => {
|
|
@@ -1,5 +1,10 @@
|
|
|
1
1
|
import { useState, isChildrenBlock } from 'octane';
|
|
2
2
|
import { QueryErrorResetBoundaryContext, createValue } from './errorResetBoundary.ts';
|
|
3
|
+
import type { OctaneNode } from 'octane';
|
|
4
|
+
|
|
5
|
+
type QueryErrorResetBoundaryProps = {
|
|
6
|
+
children?: OctaneNode | ((value: ReturnType<typeof createValue>) => OctaneNode);
|
|
7
|
+
};
|
|
3
8
|
|
|
4
9
|
// QueryErrorResetBoundary — provides a fresh reset coordinator to its subtree.
|
|
5
10
|
// Place it above an error boundary; call `.reset()` from the boundary's retry so
|
|
@@ -9,7 +14,7 @@ import { QueryErrorResetBoundaryContext, createValue } from './errorResetBoundar
|
|
|
9
14
|
// </QueryErrorResetBoundary>` (react-query QueryErrorResetBoundary.tsx renders
|
|
10
15
|
// `typeof children === 'function' ? children(value) : children`; octane
|
|
11
16
|
// additionally excludes compiled children-blocks via isChildrenBlock).
|
|
12
|
-
export function QueryErrorResetBoundary(props) @{
|
|
17
|
+
export function QueryErrorResetBoundary(props: QueryErrorResetBoundaryProps) @{
|
|
13
18
|
const [value] = useState(() => createValue());
|
|
14
19
|
const resolved =
|
|
15
20
|
typeof props.children === 'function' && !isChildrenBlock(props.children)
|