@tanstack/solid-query-devtools 5.0.0-rc.9
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/LICENSE +21 -0
- package/build/chunk/NZRUORJU.jsx +78 -0
- package/build/chunk/PEJHNLUR.js +71 -0
- package/build/dev.cjs +97 -0
- package/build/dev.js +8 -0
- package/build/dev.jsx +12 -0
- package/build/devtools/3S5YMJYB.jsx +8 -0
- package/build/devtools/AEMLXMNO.js +1 -0
- package/build/index.cjs +97 -0
- package/build/index.d.cts +35 -0
- package/build/index.d.ts +35 -0
- package/build/index.js +8 -0
- package/build/index.jsx +12 -0
- package/package.json +61 -0
- package/src/devtools.tsx +129 -0
- package/src/index.tsx +9 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2021-present Tanner Linsley
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
// src/devtools.tsx
|
|
2
|
+
import {
|
|
3
|
+
createEffect,
|
|
4
|
+
createMemo,
|
|
5
|
+
createSignal,
|
|
6
|
+
onCleanup,
|
|
7
|
+
onMount,
|
|
8
|
+
sharedConfig,
|
|
9
|
+
splitProps,
|
|
10
|
+
untrack
|
|
11
|
+
} from "solid-js";
|
|
12
|
+
import { onlineManager, useQueryClient } from "@tanstack/solid-query";
|
|
13
|
+
import { isServer } from "solid-js/web";
|
|
14
|
+
import { TanstackQueryDevtools } from "@tanstack/query-devtools";
|
|
15
|
+
function SolidQueryDevtools(props) {
|
|
16
|
+
const queryClient = useQueryClient();
|
|
17
|
+
const client = createMemo(() => props.client || queryClient);
|
|
18
|
+
let ref;
|
|
19
|
+
const devtools = new TanstackQueryDevtools({
|
|
20
|
+
client: client(),
|
|
21
|
+
queryFlavor: "Solid Query",
|
|
22
|
+
version: "5",
|
|
23
|
+
onlineManager,
|
|
24
|
+
buttonPosition: props.buttonPosition,
|
|
25
|
+
position: props.position,
|
|
26
|
+
initialIsOpen: props.initialIsOpen,
|
|
27
|
+
errorTypes: props.errorTypes
|
|
28
|
+
});
|
|
29
|
+
createEffect(() => {
|
|
30
|
+
devtools.setClient(client());
|
|
31
|
+
});
|
|
32
|
+
createEffect(() => {
|
|
33
|
+
const buttonPos = props.buttonPosition;
|
|
34
|
+
if (buttonPos) {
|
|
35
|
+
devtools.setButtonPosition(buttonPos);
|
|
36
|
+
}
|
|
37
|
+
});
|
|
38
|
+
createEffect(() => {
|
|
39
|
+
const pos = props.position;
|
|
40
|
+
if (pos) {
|
|
41
|
+
devtools.setPosition(pos);
|
|
42
|
+
}
|
|
43
|
+
});
|
|
44
|
+
createEffect(() => {
|
|
45
|
+
devtools.setInitialIsOpen(props.initialIsOpen || false);
|
|
46
|
+
});
|
|
47
|
+
createEffect(() => {
|
|
48
|
+
devtools.setErrorTypes(props.errorTypes || []);
|
|
49
|
+
});
|
|
50
|
+
onMount(() => {
|
|
51
|
+
devtools.mount(ref);
|
|
52
|
+
onCleanup(() => devtools.unmount());
|
|
53
|
+
});
|
|
54
|
+
return <div class="tsqd-parent-container" ref={ref} />;
|
|
55
|
+
}
|
|
56
|
+
function clientOnly(fn) {
|
|
57
|
+
if (isServer)
|
|
58
|
+
return (props) => props.fallback;
|
|
59
|
+
const [comp, setComp] = createSignal();
|
|
60
|
+
fn().then((m) => setComp(() => m.default));
|
|
61
|
+
return (props) => {
|
|
62
|
+
let Comp;
|
|
63
|
+
let m;
|
|
64
|
+
const [, rest] = splitProps(props, ["fallback"]);
|
|
65
|
+
if ((Comp = comp()) && !sharedConfig.context)
|
|
66
|
+
return Comp(rest);
|
|
67
|
+
const [mounted, setMounted] = createSignal(!sharedConfig.context);
|
|
68
|
+
onMount(() => setMounted(true));
|
|
69
|
+
return createMemo(
|
|
70
|
+
() => (Comp = comp(), m = mounted(), untrack(() => Comp && m ? Comp(rest) : props.fallback))
|
|
71
|
+
);
|
|
72
|
+
};
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
export {
|
|
76
|
+
SolidQueryDevtools,
|
|
77
|
+
clientOnly
|
|
78
|
+
};
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import { use, isServer, template } from 'solid-js/web';
|
|
2
|
+
import { createMemo, createEffect, onMount, onCleanup, createSignal, splitProps, sharedConfig, untrack } from 'solid-js';
|
|
3
|
+
import { useQueryClient, onlineManager } from '@tanstack/solid-query';
|
|
4
|
+
import { TanstackQueryDevtools } from '@tanstack/query-devtools';
|
|
5
|
+
|
|
6
|
+
// src/devtools.tsx
|
|
7
|
+
var _tmpl$ = /* @__PURE__ */ template(`<div class="tsqd-parent-container">`);
|
|
8
|
+
function SolidQueryDevtools(props) {
|
|
9
|
+
const queryClient = useQueryClient();
|
|
10
|
+
const client = createMemo(() => props.client || queryClient);
|
|
11
|
+
let ref;
|
|
12
|
+
const devtools = new TanstackQueryDevtools({
|
|
13
|
+
client: client(),
|
|
14
|
+
queryFlavor: "Solid Query",
|
|
15
|
+
version: "5",
|
|
16
|
+
onlineManager,
|
|
17
|
+
buttonPosition: props.buttonPosition,
|
|
18
|
+
position: props.position,
|
|
19
|
+
initialIsOpen: props.initialIsOpen,
|
|
20
|
+
errorTypes: props.errorTypes
|
|
21
|
+
});
|
|
22
|
+
createEffect(() => {
|
|
23
|
+
devtools.setClient(client());
|
|
24
|
+
});
|
|
25
|
+
createEffect(() => {
|
|
26
|
+
const buttonPos = props.buttonPosition;
|
|
27
|
+
if (buttonPos) {
|
|
28
|
+
devtools.setButtonPosition(buttonPos);
|
|
29
|
+
}
|
|
30
|
+
});
|
|
31
|
+
createEffect(() => {
|
|
32
|
+
const pos = props.position;
|
|
33
|
+
if (pos) {
|
|
34
|
+
devtools.setPosition(pos);
|
|
35
|
+
}
|
|
36
|
+
});
|
|
37
|
+
createEffect(() => {
|
|
38
|
+
devtools.setInitialIsOpen(props.initialIsOpen || false);
|
|
39
|
+
});
|
|
40
|
+
createEffect(() => {
|
|
41
|
+
devtools.setErrorTypes(props.errorTypes || []);
|
|
42
|
+
});
|
|
43
|
+
onMount(() => {
|
|
44
|
+
devtools.mount(ref);
|
|
45
|
+
onCleanup(() => devtools.unmount());
|
|
46
|
+
});
|
|
47
|
+
return (() => {
|
|
48
|
+
const _el$ = _tmpl$();
|
|
49
|
+
const _ref$ = ref;
|
|
50
|
+
typeof _ref$ === "function" ? use(_ref$, _el$) : ref = _el$;
|
|
51
|
+
return _el$;
|
|
52
|
+
})();
|
|
53
|
+
}
|
|
54
|
+
function clientOnly(fn) {
|
|
55
|
+
if (isServer)
|
|
56
|
+
return (props) => props.fallback;
|
|
57
|
+
const [comp, setComp] = createSignal();
|
|
58
|
+
fn().then((m) => setComp(() => m.default));
|
|
59
|
+
return (props) => {
|
|
60
|
+
let Comp;
|
|
61
|
+
let m;
|
|
62
|
+
const [, rest] = splitProps(props, ["fallback"]);
|
|
63
|
+
if ((Comp = comp()) && !sharedConfig.context)
|
|
64
|
+
return Comp(rest);
|
|
65
|
+
const [mounted, setMounted] = createSignal(!sharedConfig.context);
|
|
66
|
+
onMount(() => setMounted(true));
|
|
67
|
+
return createMemo(() => (Comp = comp(), m = mounted(), untrack(() => Comp && m ? Comp(rest) : props.fallback)));
|
|
68
|
+
};
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
export { SolidQueryDevtools, clientOnly };
|
package/build/dev.cjs
ADDED
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var web = require('solid-js/web');
|
|
4
|
+
var solidJs = require('solid-js');
|
|
5
|
+
var solidQuery = require('@tanstack/solid-query');
|
|
6
|
+
var queryDevtools = require('@tanstack/query-devtools');
|
|
7
|
+
|
|
8
|
+
var __defProp = Object.defineProperty;
|
|
9
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
10
|
+
var __esm = (fn, res) => function __init() {
|
|
11
|
+
return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
|
|
12
|
+
};
|
|
13
|
+
var __export = (target, all) => {
|
|
14
|
+
for (var name in all)
|
|
15
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
// src/devtools.tsx
|
|
19
|
+
var devtools_exports = {};
|
|
20
|
+
__export(devtools_exports, {
|
|
21
|
+
clientOnly: () => clientOnly,
|
|
22
|
+
default: () => SolidQueryDevtools
|
|
23
|
+
});
|
|
24
|
+
function SolidQueryDevtools(props) {
|
|
25
|
+
const queryClient = solidQuery.useQueryClient();
|
|
26
|
+
const client = solidJs.createMemo(() => props.client || queryClient);
|
|
27
|
+
let ref;
|
|
28
|
+
const devtools = new queryDevtools.TanstackQueryDevtools({
|
|
29
|
+
client: client(),
|
|
30
|
+
queryFlavor: "Solid Query",
|
|
31
|
+
version: "5",
|
|
32
|
+
onlineManager: solidQuery.onlineManager,
|
|
33
|
+
buttonPosition: props.buttonPosition,
|
|
34
|
+
position: props.position,
|
|
35
|
+
initialIsOpen: props.initialIsOpen,
|
|
36
|
+
errorTypes: props.errorTypes
|
|
37
|
+
});
|
|
38
|
+
solidJs.createEffect(() => {
|
|
39
|
+
devtools.setClient(client());
|
|
40
|
+
});
|
|
41
|
+
solidJs.createEffect(() => {
|
|
42
|
+
const buttonPos = props.buttonPosition;
|
|
43
|
+
if (buttonPos) {
|
|
44
|
+
devtools.setButtonPosition(buttonPos);
|
|
45
|
+
}
|
|
46
|
+
});
|
|
47
|
+
solidJs.createEffect(() => {
|
|
48
|
+
const pos = props.position;
|
|
49
|
+
if (pos) {
|
|
50
|
+
devtools.setPosition(pos);
|
|
51
|
+
}
|
|
52
|
+
});
|
|
53
|
+
solidJs.createEffect(() => {
|
|
54
|
+
devtools.setInitialIsOpen(props.initialIsOpen || false);
|
|
55
|
+
});
|
|
56
|
+
solidJs.createEffect(() => {
|
|
57
|
+
devtools.setErrorTypes(props.errorTypes || []);
|
|
58
|
+
});
|
|
59
|
+
solidJs.onMount(() => {
|
|
60
|
+
devtools.mount(ref);
|
|
61
|
+
solidJs.onCleanup(() => devtools.unmount());
|
|
62
|
+
});
|
|
63
|
+
return (() => {
|
|
64
|
+
const _el$ = _tmpl$();
|
|
65
|
+
const _ref$ = ref;
|
|
66
|
+
typeof _ref$ === "function" ? web.use(_ref$, _el$) : ref = _el$;
|
|
67
|
+
return _el$;
|
|
68
|
+
})();
|
|
69
|
+
}
|
|
70
|
+
function clientOnly(fn) {
|
|
71
|
+
if (web.isServer)
|
|
72
|
+
return (props) => props.fallback;
|
|
73
|
+
const [comp, setComp] = solidJs.createSignal();
|
|
74
|
+
fn().then((m) => setComp(() => m.default));
|
|
75
|
+
return (props) => {
|
|
76
|
+
let Comp;
|
|
77
|
+
let m;
|
|
78
|
+
const [, rest] = solidJs.splitProps(props, ["fallback"]);
|
|
79
|
+
if ((Comp = comp()) && !solidJs.sharedConfig.context)
|
|
80
|
+
return Comp(rest);
|
|
81
|
+
const [mounted, setMounted] = solidJs.createSignal(!solidJs.sharedConfig.context);
|
|
82
|
+
solidJs.onMount(() => setMounted(true));
|
|
83
|
+
return solidJs.createMemo(() => (Comp = comp(), m = mounted(), solidJs.untrack(() => Comp && m ? Comp(rest) : props.fallback)));
|
|
84
|
+
};
|
|
85
|
+
}
|
|
86
|
+
var _tmpl$;
|
|
87
|
+
var init_devtools = __esm({
|
|
88
|
+
"src/devtools.tsx"() {
|
|
89
|
+
_tmpl$ = /* @__PURE__ */ web.template(`<div class="tsqd-parent-container">`);
|
|
90
|
+
}
|
|
91
|
+
});
|
|
92
|
+
|
|
93
|
+
// src/index.tsx
|
|
94
|
+
init_devtools();
|
|
95
|
+
exports.SolidQueryDevtools = web.isDev ? clientOnly(() => Promise.resolve().then(() => (init_devtools(), devtools_exports))) : function() {
|
|
96
|
+
return null;
|
|
97
|
+
};
|
package/build/dev.js
ADDED
package/build/dev.jsx
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import {
|
|
2
|
+
clientOnly
|
|
3
|
+
} from "./chunk/NZRUORJU.jsx";
|
|
4
|
+
|
|
5
|
+
// src/index.tsx
|
|
6
|
+
import { isDev } from "solid-js/web";
|
|
7
|
+
var SolidQueryDevtools = isDev ? clientOnly(() => import("./devtools/3S5YMJYB.jsx")) : function() {
|
|
8
|
+
return null;
|
|
9
|
+
};
|
|
10
|
+
export {
|
|
11
|
+
SolidQueryDevtools
|
|
12
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { clientOnly, SolidQueryDevtools as default } from '../chunk/PEJHNLUR.js';
|
package/build/index.cjs
ADDED
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var web = require('solid-js/web');
|
|
4
|
+
var solidJs = require('solid-js');
|
|
5
|
+
var solidQuery = require('@tanstack/solid-query');
|
|
6
|
+
var queryDevtools = require('@tanstack/query-devtools');
|
|
7
|
+
|
|
8
|
+
var __defProp = Object.defineProperty;
|
|
9
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
10
|
+
var __esm = (fn, res) => function __init() {
|
|
11
|
+
return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
|
|
12
|
+
};
|
|
13
|
+
var __export = (target, all) => {
|
|
14
|
+
for (var name in all)
|
|
15
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
// src/devtools.tsx
|
|
19
|
+
var devtools_exports = {};
|
|
20
|
+
__export(devtools_exports, {
|
|
21
|
+
clientOnly: () => clientOnly,
|
|
22
|
+
default: () => SolidQueryDevtools
|
|
23
|
+
});
|
|
24
|
+
function SolidQueryDevtools(props) {
|
|
25
|
+
const queryClient = solidQuery.useQueryClient();
|
|
26
|
+
const client = solidJs.createMemo(() => props.client || queryClient);
|
|
27
|
+
let ref;
|
|
28
|
+
const devtools = new queryDevtools.TanstackQueryDevtools({
|
|
29
|
+
client: client(),
|
|
30
|
+
queryFlavor: "Solid Query",
|
|
31
|
+
version: "5",
|
|
32
|
+
onlineManager: solidQuery.onlineManager,
|
|
33
|
+
buttonPosition: props.buttonPosition,
|
|
34
|
+
position: props.position,
|
|
35
|
+
initialIsOpen: props.initialIsOpen,
|
|
36
|
+
errorTypes: props.errorTypes
|
|
37
|
+
});
|
|
38
|
+
solidJs.createEffect(() => {
|
|
39
|
+
devtools.setClient(client());
|
|
40
|
+
});
|
|
41
|
+
solidJs.createEffect(() => {
|
|
42
|
+
const buttonPos = props.buttonPosition;
|
|
43
|
+
if (buttonPos) {
|
|
44
|
+
devtools.setButtonPosition(buttonPos);
|
|
45
|
+
}
|
|
46
|
+
});
|
|
47
|
+
solidJs.createEffect(() => {
|
|
48
|
+
const pos = props.position;
|
|
49
|
+
if (pos) {
|
|
50
|
+
devtools.setPosition(pos);
|
|
51
|
+
}
|
|
52
|
+
});
|
|
53
|
+
solidJs.createEffect(() => {
|
|
54
|
+
devtools.setInitialIsOpen(props.initialIsOpen || false);
|
|
55
|
+
});
|
|
56
|
+
solidJs.createEffect(() => {
|
|
57
|
+
devtools.setErrorTypes(props.errorTypes || []);
|
|
58
|
+
});
|
|
59
|
+
solidJs.onMount(() => {
|
|
60
|
+
devtools.mount(ref);
|
|
61
|
+
solidJs.onCleanup(() => devtools.unmount());
|
|
62
|
+
});
|
|
63
|
+
return (() => {
|
|
64
|
+
const _el$ = _tmpl$();
|
|
65
|
+
const _ref$ = ref;
|
|
66
|
+
typeof _ref$ === "function" ? web.use(_ref$, _el$) : ref = _el$;
|
|
67
|
+
return _el$;
|
|
68
|
+
})();
|
|
69
|
+
}
|
|
70
|
+
function clientOnly(fn) {
|
|
71
|
+
if (web.isServer)
|
|
72
|
+
return (props) => props.fallback;
|
|
73
|
+
const [comp, setComp] = solidJs.createSignal();
|
|
74
|
+
fn().then((m) => setComp(() => m.default));
|
|
75
|
+
return (props) => {
|
|
76
|
+
let Comp;
|
|
77
|
+
let m;
|
|
78
|
+
const [, rest] = solidJs.splitProps(props, ["fallback"]);
|
|
79
|
+
if ((Comp = comp()) && !solidJs.sharedConfig.context)
|
|
80
|
+
return Comp(rest);
|
|
81
|
+
const [mounted, setMounted] = solidJs.createSignal(!solidJs.sharedConfig.context);
|
|
82
|
+
solidJs.onMount(() => setMounted(true));
|
|
83
|
+
return solidJs.createMemo(() => (Comp = comp(), m = mounted(), solidJs.untrack(() => Comp && m ? Comp(rest) : props.fallback)));
|
|
84
|
+
};
|
|
85
|
+
}
|
|
86
|
+
var _tmpl$;
|
|
87
|
+
var init_devtools = __esm({
|
|
88
|
+
"src/devtools.tsx"() {
|
|
89
|
+
_tmpl$ = /* @__PURE__ */ web.template(`<div class="tsqd-parent-container">`);
|
|
90
|
+
}
|
|
91
|
+
});
|
|
92
|
+
|
|
93
|
+
// src/index.tsx
|
|
94
|
+
init_devtools();
|
|
95
|
+
exports.SolidQueryDevtools = web.isDev ? clientOnly(() => Promise.resolve().then(() => (init_devtools(), devtools_exports))) : function() {
|
|
96
|
+
return null;
|
|
97
|
+
};
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { DevtoolsButtonPosition, DevtoolsPosition, DevToolsErrorType } from '@tanstack/query-devtools';
|
|
2
|
+
import { QueryClient } from '@tanstack/solid-query';
|
|
3
|
+
import { JSX } from 'solid-js';
|
|
4
|
+
|
|
5
|
+
interface DevtoolsOptions {
|
|
6
|
+
/**
|
|
7
|
+
* Set this true if you want the dev tools to default to being open
|
|
8
|
+
*/
|
|
9
|
+
initialIsOpen?: boolean;
|
|
10
|
+
/**
|
|
11
|
+
* The position of the React Query logo to open and close the devtools panel.
|
|
12
|
+
* 'top-left' | 'top-right' | 'bottom-left' | 'bottom-right'
|
|
13
|
+
* Defaults to 'bottom-left'.
|
|
14
|
+
*/
|
|
15
|
+
buttonPosition?: DevtoolsButtonPosition;
|
|
16
|
+
/**
|
|
17
|
+
* The position of the React Query devtools panel.
|
|
18
|
+
* 'top' | 'bottom' | 'left' | 'right'
|
|
19
|
+
* Defaults to 'bottom'.
|
|
20
|
+
*/
|
|
21
|
+
position?: DevtoolsPosition;
|
|
22
|
+
/**
|
|
23
|
+
* Custom instance of QueryClient
|
|
24
|
+
*/
|
|
25
|
+
client?: QueryClient;
|
|
26
|
+
/**
|
|
27
|
+
* Use this so you can define custom errors that can be shown in the devtools.
|
|
28
|
+
*/
|
|
29
|
+
errorTypes?: Array<DevToolsErrorType>;
|
|
30
|
+
}
|
|
31
|
+
declare function SolidQueryDevtools$1(props: DevtoolsOptions): JSX.Element;
|
|
32
|
+
|
|
33
|
+
declare const SolidQueryDevtools: typeof SolidQueryDevtools$1;
|
|
34
|
+
|
|
35
|
+
export { SolidQueryDevtools };
|
package/build/index.d.ts
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { DevtoolsButtonPosition, DevtoolsPosition, DevToolsErrorType } from '@tanstack/query-devtools';
|
|
2
|
+
import { QueryClient } from '@tanstack/solid-query';
|
|
3
|
+
import { JSX } from 'solid-js';
|
|
4
|
+
|
|
5
|
+
interface DevtoolsOptions {
|
|
6
|
+
/**
|
|
7
|
+
* Set this true if you want the dev tools to default to being open
|
|
8
|
+
*/
|
|
9
|
+
initialIsOpen?: boolean;
|
|
10
|
+
/**
|
|
11
|
+
* The position of the React Query logo to open and close the devtools panel.
|
|
12
|
+
* 'top-left' | 'top-right' | 'bottom-left' | 'bottom-right'
|
|
13
|
+
* Defaults to 'bottom-left'.
|
|
14
|
+
*/
|
|
15
|
+
buttonPosition?: DevtoolsButtonPosition;
|
|
16
|
+
/**
|
|
17
|
+
* The position of the React Query devtools panel.
|
|
18
|
+
* 'top' | 'bottom' | 'left' | 'right'
|
|
19
|
+
* Defaults to 'bottom'.
|
|
20
|
+
*/
|
|
21
|
+
position?: DevtoolsPosition;
|
|
22
|
+
/**
|
|
23
|
+
* Custom instance of QueryClient
|
|
24
|
+
*/
|
|
25
|
+
client?: QueryClient;
|
|
26
|
+
/**
|
|
27
|
+
* Use this so you can define custom errors that can be shown in the devtools.
|
|
28
|
+
*/
|
|
29
|
+
errorTypes?: Array<DevToolsErrorType>;
|
|
30
|
+
}
|
|
31
|
+
declare function SolidQueryDevtools$1(props: DevtoolsOptions): JSX.Element;
|
|
32
|
+
|
|
33
|
+
declare const SolidQueryDevtools: typeof SolidQueryDevtools$1;
|
|
34
|
+
|
|
35
|
+
export { SolidQueryDevtools };
|
package/build/index.js
ADDED
package/build/index.jsx
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import {
|
|
2
|
+
clientOnly
|
|
3
|
+
} from "./chunk/NZRUORJU.jsx";
|
|
4
|
+
|
|
5
|
+
// src/index.tsx
|
|
6
|
+
import { isDev } from "solid-js/web";
|
|
7
|
+
var SolidQueryDevtools = isDev ? clientOnly(() => import("./devtools/3S5YMJYB.jsx")) : function() {
|
|
8
|
+
return null;
|
|
9
|
+
};
|
|
10
|
+
export {
|
|
11
|
+
SolidQueryDevtools
|
|
12
|
+
};
|
package/package.json
ADDED
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@tanstack/solid-query-devtools",
|
|
3
|
+
"version": "5.0.0-rc.9",
|
|
4
|
+
"description": "Developer tools to interact with and visualize the TanStack/solid-query Query cache",
|
|
5
|
+
"author": "tannerlinsley",
|
|
6
|
+
"license": "MIT",
|
|
7
|
+
"repository": "tanstack/query",
|
|
8
|
+
"homepage": "https://tanstack.com/query",
|
|
9
|
+
"funding": {
|
|
10
|
+
"type": "github",
|
|
11
|
+
"url": "https://github.com/sponsors/tannerlinsley"
|
|
12
|
+
},
|
|
13
|
+
"type": "module",
|
|
14
|
+
"main": "./build/index.cjs",
|
|
15
|
+
"module": "./build/index.js",
|
|
16
|
+
"types": "./build/index.d.ts",
|
|
17
|
+
"browser": {},
|
|
18
|
+
"exports": {
|
|
19
|
+
"solid": {
|
|
20
|
+
"development": "./build/dev.jsx",
|
|
21
|
+
"import": "./build/index.jsx"
|
|
22
|
+
},
|
|
23
|
+
"development": {
|
|
24
|
+
"import": {
|
|
25
|
+
"types": "./build/index.d.ts",
|
|
26
|
+
"default": "./build/dev.js"
|
|
27
|
+
},
|
|
28
|
+
"require": "./build/dev.cjs"
|
|
29
|
+
},
|
|
30
|
+
"import": {
|
|
31
|
+
"types": "./build/index.d.ts",
|
|
32
|
+
"default": "./build/index.js"
|
|
33
|
+
},
|
|
34
|
+
"require": "./build/index.cjs"
|
|
35
|
+
},
|
|
36
|
+
"files": [
|
|
37
|
+
"build",
|
|
38
|
+
"src"
|
|
39
|
+
],
|
|
40
|
+
"dependencies": {
|
|
41
|
+
"@tanstack/query-devtools": "5.0.0-rc.9"
|
|
42
|
+
},
|
|
43
|
+
"peerDependencies": {
|
|
44
|
+
"solid-js": "^1.7.8",
|
|
45
|
+
"@tanstack/solid-query": "^5.0.0-rc.8"
|
|
46
|
+
},
|
|
47
|
+
"devDependencies": {
|
|
48
|
+
"solid-js": "^1.7.8",
|
|
49
|
+
"tsup-preset-solid": "^2.0.1",
|
|
50
|
+
"vite-plugin-solid": "^2.7.0",
|
|
51
|
+
"@tanstack/solid-query": "^5.0.0-rc.8"
|
|
52
|
+
},
|
|
53
|
+
"scripts": {
|
|
54
|
+
"clean": "rimraf ./build && rimraf ./coverage",
|
|
55
|
+
"test:eslint": "eslint --ext .ts,.tsx ./src",
|
|
56
|
+
"test:types": "tsc",
|
|
57
|
+
"test:build": "publint --strict",
|
|
58
|
+
"build": "tsup",
|
|
59
|
+
"build:dev": "tsup --watch"
|
|
60
|
+
}
|
|
61
|
+
}
|
package/src/devtools.tsx
ADDED
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
import {
|
|
2
|
+
createEffect,
|
|
3
|
+
createMemo,
|
|
4
|
+
createSignal,
|
|
5
|
+
onCleanup,
|
|
6
|
+
onMount,
|
|
7
|
+
sharedConfig,
|
|
8
|
+
splitProps,
|
|
9
|
+
untrack,
|
|
10
|
+
} from 'solid-js'
|
|
11
|
+
import { onlineManager, useQueryClient } from '@tanstack/solid-query'
|
|
12
|
+
import { isServer } from 'solid-js/web'
|
|
13
|
+
import { TanstackQueryDevtools } from '@tanstack/query-devtools'
|
|
14
|
+
import type {
|
|
15
|
+
DevToolsErrorType,
|
|
16
|
+
DevtoolsButtonPosition,
|
|
17
|
+
DevtoolsPosition,
|
|
18
|
+
} from '@tanstack/query-devtools'
|
|
19
|
+
import type { QueryClient } from '@tanstack/solid-query'
|
|
20
|
+
import type { Component, ComponentProps, JSX } from 'solid-js'
|
|
21
|
+
|
|
22
|
+
export interface DevtoolsOptions {
|
|
23
|
+
/**
|
|
24
|
+
* Set this true if you want the dev tools to default to being open
|
|
25
|
+
*/
|
|
26
|
+
initialIsOpen?: boolean
|
|
27
|
+
/**
|
|
28
|
+
* The position of the React Query logo to open and close the devtools panel.
|
|
29
|
+
* 'top-left' | 'top-right' | 'bottom-left' | 'bottom-right'
|
|
30
|
+
* Defaults to 'bottom-left'.
|
|
31
|
+
*/
|
|
32
|
+
buttonPosition?: DevtoolsButtonPosition
|
|
33
|
+
/**
|
|
34
|
+
* The position of the React Query devtools panel.
|
|
35
|
+
* 'top' | 'bottom' | 'left' | 'right'
|
|
36
|
+
* Defaults to 'bottom'.
|
|
37
|
+
*/
|
|
38
|
+
position?: DevtoolsPosition
|
|
39
|
+
/**
|
|
40
|
+
* Custom instance of QueryClient
|
|
41
|
+
*/
|
|
42
|
+
client?: QueryClient
|
|
43
|
+
/**
|
|
44
|
+
* Use this so you can define custom errors that can be shown in the devtools.
|
|
45
|
+
*/
|
|
46
|
+
errorTypes?: Array<DevToolsErrorType>
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
export default function SolidQueryDevtools(props: DevtoolsOptions) {
|
|
50
|
+
const queryClient = useQueryClient()
|
|
51
|
+
const client = createMemo(() => props.client || queryClient)
|
|
52
|
+
let ref!: HTMLDivElement
|
|
53
|
+
const devtools = new TanstackQueryDevtools({
|
|
54
|
+
client: client(),
|
|
55
|
+
queryFlavor: 'Solid Query',
|
|
56
|
+
version: '5',
|
|
57
|
+
onlineManager,
|
|
58
|
+
buttonPosition: props.buttonPosition,
|
|
59
|
+
position: props.position,
|
|
60
|
+
initialIsOpen: props.initialIsOpen,
|
|
61
|
+
errorTypes: props.errorTypes,
|
|
62
|
+
})
|
|
63
|
+
|
|
64
|
+
createEffect(() => {
|
|
65
|
+
devtools.setClient(client())
|
|
66
|
+
})
|
|
67
|
+
|
|
68
|
+
createEffect(() => {
|
|
69
|
+
const buttonPos = props.buttonPosition
|
|
70
|
+
if (buttonPos) {
|
|
71
|
+
devtools.setButtonPosition(buttonPos)
|
|
72
|
+
}
|
|
73
|
+
})
|
|
74
|
+
|
|
75
|
+
createEffect(() => {
|
|
76
|
+
const pos = props.position
|
|
77
|
+
if (pos) {
|
|
78
|
+
devtools.setPosition(pos)
|
|
79
|
+
}
|
|
80
|
+
})
|
|
81
|
+
|
|
82
|
+
createEffect(() => {
|
|
83
|
+
devtools.setInitialIsOpen(props.initialIsOpen || false)
|
|
84
|
+
})
|
|
85
|
+
|
|
86
|
+
createEffect(() => {
|
|
87
|
+
devtools.setErrorTypes(props.errorTypes || [])
|
|
88
|
+
})
|
|
89
|
+
|
|
90
|
+
onMount(() => {
|
|
91
|
+
devtools.mount(ref)
|
|
92
|
+
onCleanup(() => devtools.unmount())
|
|
93
|
+
})
|
|
94
|
+
|
|
95
|
+
return <div class="tsqd-parent-container" ref={ref}></div>
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
/*
|
|
99
|
+
This function has been taken from solid-start's codebase
|
|
100
|
+
This allows the devtools to be loaded only on the client and bypasses any server side rendering
|
|
101
|
+
https://github.com/solidjs/solid-start/blob/2967fc2db3f0df826f061020231dbdafdfa0746b/packages/start/islands/clientOnly.tsx
|
|
102
|
+
*/
|
|
103
|
+
export function clientOnly<T extends Component<any>>(
|
|
104
|
+
fn: () => Promise<{
|
|
105
|
+
default: T
|
|
106
|
+
}>,
|
|
107
|
+
) {
|
|
108
|
+
if (isServer)
|
|
109
|
+
return (props: ComponentProps<T> & { fallback?: JSX.Element }) =>
|
|
110
|
+
props.fallback
|
|
111
|
+
|
|
112
|
+
const [comp, setComp] = createSignal<T>()
|
|
113
|
+
fn().then((m) => setComp(() => m.default))
|
|
114
|
+
return (props: ComponentProps<T>) => {
|
|
115
|
+
let Comp: T | undefined
|
|
116
|
+
let m: boolean
|
|
117
|
+
const [, rest] = splitProps(props, ['fallback'])
|
|
118
|
+
if ((Comp = comp()) && !sharedConfig.context) return Comp(rest)
|
|
119
|
+
const [mounted, setMounted] = createSignal(!sharedConfig.context)
|
|
120
|
+
onMount(() => setMounted(true))
|
|
121
|
+
return createMemo(
|
|
122
|
+
() => (
|
|
123
|
+
(Comp = comp()),
|
|
124
|
+
(m = mounted()),
|
|
125
|
+
untrack(() => (Comp && m ? Comp(rest) : props.fallback))
|
|
126
|
+
),
|
|
127
|
+
)
|
|
128
|
+
}
|
|
129
|
+
}
|
package/src/index.tsx
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { isDev } from 'solid-js/web'
|
|
2
|
+
import { clientOnly } from './devtools'
|
|
3
|
+
import type SolidQueryDevtoolsComp from './devtools'
|
|
4
|
+
|
|
5
|
+
export const SolidQueryDevtools: typeof SolidQueryDevtoolsComp = isDev
|
|
6
|
+
? clientOnly(() => import('./devtools'))
|
|
7
|
+
: function () {
|
|
8
|
+
return null
|
|
9
|
+
}
|