vike-solid-query 0.0.1-commit-f6af6c4 → 0.0.1-commit-483edf8
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/integration/+config.d.ts +8 -0
- package/dist/src/index.d.ts +29 -1
- package/dist/src/index.js +66 -1
- package/dist/src/server.js +47 -0
- package/package.json +26 -12
- package/dist/integration/index.d.ts +0 -2
- package/dist/integration/index.js +0 -2
- package/dist/src/QueryBoundary.d.ts +0 -26
- package/dist/src/QueryBoundary.jsx +0 -37
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { QueryClientConfig } from "@tanstack/solid-query";
|
|
1
2
|
import "vike-solid/config";
|
|
2
3
|
declare const _default: {
|
|
3
4
|
name: string;
|
|
@@ -22,3 +23,10 @@ declare const _default: {
|
|
|
22
23
|
};
|
|
23
24
|
};
|
|
24
25
|
export default _default;
|
|
26
|
+
declare global {
|
|
27
|
+
namespace Vike {
|
|
28
|
+
interface Config {
|
|
29
|
+
queryClientConfig?: QueryClientConfig;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
}
|
package/dist/src/index.d.ts
CHANGED
|
@@ -1 +1,29 @@
|
|
|
1
|
-
|
|
1
|
+
import { CreateQueryResult } from '@tanstack/solid-query';
|
|
2
|
+
import { JSX } from 'solid-js';
|
|
3
|
+
|
|
4
|
+
interface QueryBoundaryProps<T = unknown> {
|
|
5
|
+
query: CreateQueryResult<T, Error>;
|
|
6
|
+
/**
|
|
7
|
+
* Triggered when the data is initially loading.
|
|
8
|
+
*/
|
|
9
|
+
loadingFallback?: JSX.Element;
|
|
10
|
+
/**
|
|
11
|
+
* Triggered when fetching is complete, but the returned data was falsey.
|
|
12
|
+
*/
|
|
13
|
+
notFoundFallback?: JSX.Element;
|
|
14
|
+
/**
|
|
15
|
+
* Triggered when the query results in an error.
|
|
16
|
+
*/
|
|
17
|
+
errorFallback?: JSX.Element | ((err: any, reset: () => void) => JSX.Element);
|
|
18
|
+
/**
|
|
19
|
+
* Triggered when fetching is complete, and the returned data is not falsey.
|
|
20
|
+
*/
|
|
21
|
+
children: (data: Exclude<T, null | false | undefined>) => JSX.Element;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Convenience wrapper that handles suspense and errors for queries. Makes the results of query.data available to
|
|
25
|
+
* children (as a render prop) in a type-safe way.
|
|
26
|
+
*/
|
|
27
|
+
declare function QueryBoundary<T>(props: QueryBoundaryProps<T>): JSX.Element;
|
|
28
|
+
|
|
29
|
+
export { QueryBoundary, type QueryBoundaryProps };
|
package/dist/src/index.js
CHANGED
|
@@ -1 +1,66 @@
|
|
|
1
|
-
|
|
1
|
+
import { delegateEvents, createComponent, getNextElement, insert, runHydrationEvents, memo, template } from 'solid-js/web';
|
|
2
|
+
import { ErrorBoundary, Suspense, Switch, Match } from 'solid-js';
|
|
3
|
+
|
|
4
|
+
var _tmpl$ = /*#__PURE__*/template(`<div><div class=query-boundary-error></div><button>Retry`),
|
|
5
|
+
_tmpl$2 = /*#__PURE__*/template(`<div>Not Found,`),
|
|
6
|
+
_tmpl$3 = /*#__PURE__*/template(`<button>Refetch`);
|
|
7
|
+
/**
|
|
8
|
+
* Convenience wrapper that handles suspense and errors for queries. Makes the results of query.data available to
|
|
9
|
+
* children (as a render prop) in a type-safe way.
|
|
10
|
+
*/
|
|
11
|
+
function QueryBoundary(props) {
|
|
12
|
+
return createComponent(ErrorBoundary, {
|
|
13
|
+
get fallback() {
|
|
14
|
+
return props.errorFallback ? props.errorFallback : (err, reset) => (() => {
|
|
15
|
+
var _el$ = getNextElement(_tmpl$),
|
|
16
|
+
_el$2 = _el$.firstChild,
|
|
17
|
+
_el$3 = _el$2.nextSibling;
|
|
18
|
+
insert(_el$2, () => err.toString());
|
|
19
|
+
_el$3.$$click = async () => {
|
|
20
|
+
reset();
|
|
21
|
+
await props.query.refetch();
|
|
22
|
+
};
|
|
23
|
+
runHydrationEvents();
|
|
24
|
+
return _el$;
|
|
25
|
+
})();
|
|
26
|
+
},
|
|
27
|
+
get children() {
|
|
28
|
+
return createComponent(Suspense, {
|
|
29
|
+
get fallback() {
|
|
30
|
+
return props.loadingFallback;
|
|
31
|
+
},
|
|
32
|
+
get children() {
|
|
33
|
+
return createComponent(Switch, {
|
|
34
|
+
get children() {
|
|
35
|
+
return [createComponent(Match, {
|
|
36
|
+
get when() {
|
|
37
|
+
return !props.query.isFetching && !props.query.data;
|
|
38
|
+
},
|
|
39
|
+
get children() {
|
|
40
|
+
return memo(() => !!props.notFoundFallback)() ? props.notFoundFallback : [getNextElement(_tmpl$2), (() => {
|
|
41
|
+
var _el$5 = getNextElement(_tmpl$3);
|
|
42
|
+
_el$5.$$click = async () => {
|
|
43
|
+
await props.query.refetch();
|
|
44
|
+
};
|
|
45
|
+
runHydrationEvents();
|
|
46
|
+
return _el$5;
|
|
47
|
+
})()];
|
|
48
|
+
}
|
|
49
|
+
}), createComponent(Match, {
|
|
50
|
+
get when() {
|
|
51
|
+
return props.query.data;
|
|
52
|
+
},
|
|
53
|
+
get children() {
|
|
54
|
+
return props.children(props.query.data);
|
|
55
|
+
}
|
|
56
|
+
})];
|
|
57
|
+
}
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
delegateEvents(["click"]);
|
|
65
|
+
|
|
66
|
+
export { QueryBoundary };
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { createComponent, ssr, ssrHydrationKey, escape } from 'solid-js/web';
|
|
2
|
+
import { ErrorBoundary, Suspense, Switch, Match } from 'solid-js';
|
|
3
|
+
|
|
4
|
+
var _tmpl$ = ["<div", "><div class=\"query-boundary-error\">", "</div><button>Retry</button></div>"],
|
|
5
|
+
_tmpl$2 = ["<div", ">Not Found,</div>"],
|
|
6
|
+
_tmpl$3 = ["<button", ">Refetch</button>"];
|
|
7
|
+
/**
|
|
8
|
+
* Convenience wrapper that handles suspense and errors for queries. Makes the results of query.data available to
|
|
9
|
+
* children (as a render prop) in a type-safe way.
|
|
10
|
+
*/
|
|
11
|
+
function QueryBoundary(props) {
|
|
12
|
+
return createComponent(ErrorBoundary, {
|
|
13
|
+
get fallback() {
|
|
14
|
+
return props.errorFallback ? props.errorFallback : (err, reset) => ssr(_tmpl$, ssrHydrationKey(), escape(err.toString()));
|
|
15
|
+
},
|
|
16
|
+
get children() {
|
|
17
|
+
return createComponent(Suspense, {
|
|
18
|
+
get fallback() {
|
|
19
|
+
return props.loadingFallback;
|
|
20
|
+
},
|
|
21
|
+
get children() {
|
|
22
|
+
return createComponent(Switch, {
|
|
23
|
+
get children() {
|
|
24
|
+
return [createComponent(Match, {
|
|
25
|
+
get when() {
|
|
26
|
+
return !props.query.isFetching && !props.query.data;
|
|
27
|
+
},
|
|
28
|
+
get children() {
|
|
29
|
+
return props.notFoundFallback ? props.notFoundFallback : [ssr(_tmpl$2, ssrHydrationKey()), ssr(_tmpl$3, ssrHydrationKey())];
|
|
30
|
+
}
|
|
31
|
+
}), createComponent(Match, {
|
|
32
|
+
get when() {
|
|
33
|
+
return props.query.data;
|
|
34
|
+
},
|
|
35
|
+
get children() {
|
|
36
|
+
return props.children(props.query.data);
|
|
37
|
+
}
|
|
38
|
+
})];
|
|
39
|
+
}
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
export { QueryBoundary };
|
package/package.json
CHANGED
|
@@ -1,27 +1,41 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "vike-solid-query",
|
|
3
|
-
"version": "0.0.1-commit-
|
|
3
|
+
"version": "0.0.1-commit-483edf8",
|
|
4
4
|
"type": "module",
|
|
5
|
-
"main": "dist/src/
|
|
6
|
-
"typings": "dist/src/index.
|
|
5
|
+
"main": "./dist/src/server.js",
|
|
6
|
+
"typings": "dist/src/index.d.ts",
|
|
7
|
+
"module": "./dist/src/server.js",
|
|
8
|
+
"types": "./dist/src/index.d.ts",
|
|
9
|
+
"browser": {
|
|
10
|
+
"./dist/src/server.js": "./dist/src/index.js"
|
|
11
|
+
},
|
|
7
12
|
"exports": {
|
|
8
|
-
".":
|
|
13
|
+
".": {
|
|
14
|
+
"browser": "./dist/src/index.js",
|
|
15
|
+
"node": "./dist/src/server.js",
|
|
16
|
+
"default": "./dist/src/index.js",
|
|
17
|
+
"types": "./dist/src/index.d.ts"
|
|
18
|
+
},
|
|
9
19
|
"./config": "./dist/integration/+config.js",
|
|
10
|
-
"./__internal/integration/Wrapper": "./dist/integration/
|
|
20
|
+
"./__internal/integration/Wrapper": "./dist/integration/Wrapper.jsx"
|
|
11
21
|
},
|
|
12
22
|
"peerDependencies": {
|
|
13
23
|
"@tanstack/solid-query": ">=5.0.0",
|
|
14
24
|
"solid-js": "^1.8.7",
|
|
15
|
-
"vike-solid": "
|
|
25
|
+
"vike-solid": "0.7.4"
|
|
16
26
|
},
|
|
17
27
|
"devDependencies": {
|
|
18
|
-
"@brillout/release-me": "^0.4.
|
|
28
|
+
"@brillout/release-me": "^0.4.2",
|
|
29
|
+
"@rollup/plugin-babel": "^6.0.4",
|
|
30
|
+
"@rollup/plugin-node-resolve": "^15.2.4",
|
|
19
31
|
"@tanstack/solid-query": "^5.56.2",
|
|
20
32
|
"rimraf": "^6.0.1",
|
|
33
|
+
"rollup": "^4.22.4",
|
|
34
|
+
"rollup-plugin-dts": "^6.1.1",
|
|
21
35
|
"solid-js": "^1.8.22",
|
|
22
36
|
"typescript": "^5.6.2",
|
|
23
|
-
"vike": "^0.4.
|
|
24
|
-
"vike-solid": "
|
|
37
|
+
"vike": "^0.4.196",
|
|
38
|
+
"vike-solid": "0.7.5"
|
|
25
39
|
},
|
|
26
40
|
"typesVersions": {
|
|
27
41
|
"*": {
|
|
@@ -34,14 +48,14 @@
|
|
|
34
48
|
}
|
|
35
49
|
},
|
|
36
50
|
"files": [
|
|
37
|
-
"dist"
|
|
51
|
+
"dist/"
|
|
38
52
|
],
|
|
39
53
|
"repository": "github:vikejs/vike-solid",
|
|
40
54
|
"license": "MIT",
|
|
41
55
|
"scripts": {
|
|
42
|
-
"dev": "
|
|
56
|
+
"dev": "rollup -c rollup.config.js --watch",
|
|
43
57
|
"dev:typecheck": "tsc --noEmit --watch",
|
|
44
|
-
"build": "
|
|
58
|
+
"build": "rollup -c rollup.config.js && tsc",
|
|
45
59
|
"release": "LANG=en_US release-me patch",
|
|
46
60
|
"release:minor": "LANG=en_US release-me minor",
|
|
47
61
|
"release:commit": "LANG=en_US release-me commit"
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import type { CreateQueryResult } from "@tanstack/solid-query";
|
|
2
|
-
import type { JSX } from "solid-js";
|
|
3
|
-
export interface QueryBoundaryProps<T = unknown> {
|
|
4
|
-
query: CreateQueryResult<T, Error>;
|
|
5
|
-
/**
|
|
6
|
-
* Triggered when the data is initially loading.
|
|
7
|
-
*/
|
|
8
|
-
loadingFallback?: JSX.Element;
|
|
9
|
-
/**
|
|
10
|
-
* Triggered when fetching is complete, but the returned data was falsey.
|
|
11
|
-
*/
|
|
12
|
-
notFoundFallback?: JSX.Element;
|
|
13
|
-
/**
|
|
14
|
-
* Triggered when the query results in an error.
|
|
15
|
-
*/
|
|
16
|
-
errorFallback?: JSX.Element | ((err: any, reset: () => void) => JSX.Element);
|
|
17
|
-
/**
|
|
18
|
-
* Triggered when fetching is complete, and the returned data is not falsey.
|
|
19
|
-
*/
|
|
20
|
-
children: (data: Exclude<T, null | false | undefined>) => JSX.Element;
|
|
21
|
-
}
|
|
22
|
-
/**
|
|
23
|
-
* Convenience wrapper that handles suspense and errors for queries. Makes the results of query.data available to
|
|
24
|
-
* children (as a render prop) in a type-safe way.
|
|
25
|
-
*/
|
|
26
|
-
export declare function QueryBoundary<T>(props: QueryBoundaryProps<T>): JSX.Element;
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
import { ErrorBoundary, Match, Suspense, Switch } from "solid-js";
|
|
2
|
-
/**
|
|
3
|
-
* Convenience wrapper that handles suspense and errors for queries. Makes the results of query.data available to
|
|
4
|
-
* children (as a render prop) in a type-safe way.
|
|
5
|
-
*/
|
|
6
|
-
export function QueryBoundary(props) {
|
|
7
|
-
return (<ErrorBoundary fallback={props.errorFallback
|
|
8
|
-
? props.errorFallback
|
|
9
|
-
: (err, reset) => (<div>
|
|
10
|
-
<div class="query-boundary-error">{err.toString()}</div>
|
|
11
|
-
<button onClick={async () => {
|
|
12
|
-
reset();
|
|
13
|
-
await props.query.refetch();
|
|
14
|
-
}}>
|
|
15
|
-
Retry
|
|
16
|
-
</button>
|
|
17
|
-
</div>)}>
|
|
18
|
-
<Suspense fallback={props.loadingFallback}>
|
|
19
|
-
<Switch>
|
|
20
|
-
<Match when={!props.query.isFetching && !props.query.data}>
|
|
21
|
-
{props.notFoundFallback ? (props.notFoundFallback) : (<>
|
|
22
|
-
<div>Not Found,</div>
|
|
23
|
-
<button onClick={async () => {
|
|
24
|
-
await props.query.refetch();
|
|
25
|
-
}}>
|
|
26
|
-
Refetch
|
|
27
|
-
</button>
|
|
28
|
-
</>)}
|
|
29
|
-
</Match>
|
|
30
|
-
|
|
31
|
-
<Match when={props.query.data}>
|
|
32
|
-
{props.children(props.query.data)}
|
|
33
|
-
</Match>
|
|
34
|
-
</Switch>
|
|
35
|
-
</Suspense>
|
|
36
|
-
</ErrorBoundary>);
|
|
37
|
-
}
|