vike-solid 0.4.2 → 0.4.3
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/README.md +2 -2
- package/dist/components/ClientOnly.d.ts +14 -2
- package/dist/components/ClientOnly.js +27 -3
- package/dist/main.js +1 -1
- package/package.json +12 -12
package/README.md
CHANGED
|
@@ -21,7 +21,7 @@ SolidJS integration for Vike, see [vike.dev/solid](https://vike.dev/solid).
|
|
|
21
21
|
|
|
22
22
|
## Scaffold new app
|
|
23
23
|
|
|
24
|
-
Use [Bati](https://batijs.
|
|
24
|
+
Use [Bati](https://batijs.dev/) to scaffold a Vike app using `vike-solid`.
|
|
25
25
|
|
|
26
26
|
## Add to existing app
|
|
27
27
|
|
|
@@ -54,7 +54,7 @@ export default {
|
|
|
54
54
|
3. Extend your existing Vike config files with `vike-solid`:
|
|
55
55
|
|
|
56
56
|
```diff
|
|
57
|
-
// /pages/+config.
|
|
57
|
+
// /pages/+config.js
|
|
58
58
|
|
|
59
59
|
+import vikeSolid from 'vike-solid/config'
|
|
60
60
|
+
|
|
@@ -1,5 +1,8 @@
|
|
|
1
|
-
import { Component, JSX } from 'solid-js';
|
|
1
|
+
import { Component, JSX, ComponentProps } from 'solid-js';
|
|
2
2
|
|
|
3
|
+
/**
|
|
4
|
+
* @deprecated Replaced by {@link clientOnly}
|
|
5
|
+
*/
|
|
3
6
|
declare function ClientOnly<T>(props: {
|
|
4
7
|
load: () => Promise<{
|
|
5
8
|
default: Component<T>;
|
|
@@ -7,5 +10,14 @@ declare function ClientOnly<T>(props: {
|
|
|
7
10
|
children: (Component: Component<T>) => JSX.Element;
|
|
8
11
|
fallback: JSX.Element;
|
|
9
12
|
}): JSX.Element;
|
|
13
|
+
/**
|
|
14
|
+
* Same as `clientOnly` from solid-start
|
|
15
|
+
* @see {@link https://docs.solidjs.com/solid-start/reference/client/client-only}
|
|
16
|
+
*/
|
|
17
|
+
declare function clientOnly<T extends Component<any>>(fn: () => Promise<{
|
|
18
|
+
default: T;
|
|
19
|
+
}>): (props: ComponentProps<T> & {
|
|
20
|
+
fallback?: JSX.Element;
|
|
21
|
+
}) => any;
|
|
10
22
|
|
|
11
|
-
export { ClientOnly };
|
|
23
|
+
export { ClientOnly, clientOnly };
|
|
@@ -1,10 +1,14 @@
|
|
|
1
|
-
import { createComponent, Dynamic, ssr, ssrHydrationKey } from 'solid-js/web';
|
|
2
|
-
import { createSignal, createEffect, Suspense, lazy } from 'solid-js';
|
|
1
|
+
import { createComponent, Dynamic, isServer, ssr, ssrHydrationKey } from 'solid-js/web';
|
|
2
|
+
import { createSignal, createEffect, Suspense, splitProps, sharedConfig, onMount, createMemo, untrack, lazy } from 'solid-js';
|
|
3
3
|
|
|
4
4
|
var _tmpl$ = ["<p", ">Error loading component.</p>"];
|
|
5
5
|
function ClientOnlyError() {
|
|
6
6
|
return ssr(_tmpl$, ssrHydrationKey());
|
|
7
7
|
}
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* @deprecated Replaced by {@link clientOnly}
|
|
11
|
+
*/
|
|
8
12
|
function ClientOnly(props) {
|
|
9
13
|
const [getComponent, setComponent] = createSignal(undefined);
|
|
10
14
|
createEffect(() => {
|
|
@@ -37,4 +41,24 @@ function ClientOnly(props) {
|
|
|
37
41
|
});
|
|
38
42
|
}
|
|
39
43
|
|
|
40
|
-
|
|
44
|
+
// Copied from https://github.com/solidjs/solid-start/blob/2d75d5fedfd11f739b03ca34decf23865868ac09/packages/start/src/shared/clientOnly.tsx#L7
|
|
45
|
+
/**
|
|
46
|
+
* Same as `clientOnly` from solid-start
|
|
47
|
+
* @see {@link https://docs.solidjs.com/solid-start/reference/client/client-only}
|
|
48
|
+
*/
|
|
49
|
+
function clientOnly(fn) {
|
|
50
|
+
if (isServer) return props => props.fallback;
|
|
51
|
+
const [comp, setComp] = createSignal();
|
|
52
|
+
fn().then(m => setComp(() => m.default));
|
|
53
|
+
return props => {
|
|
54
|
+
let Comp;
|
|
55
|
+
let m;
|
|
56
|
+
const [, rest] = splitProps(props, ["fallback"]);
|
|
57
|
+
if ((Comp = comp()) && !sharedConfig.context) return Comp(rest);
|
|
58
|
+
const [mounted, setMounted] = createSignal(!sharedConfig.context);
|
|
59
|
+
onMount(() => setMounted(true));
|
|
60
|
+
return createMemo(() => (Comp = comp(), m = mounted(), untrack(() => Comp && m ? Comp(rest) : props.fallback)));
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
export { ClientOnly, clientOnly };
|
package/dist/main.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
export { config } from './+config.js';
|
|
2
2
|
|
|
3
3
|
// TODO/next-major-release: remove this file/export
|
|
4
|
-
console.warn("[vike-solid][warning][deprecation] Replace `import vikeVue from 'vike-solid'` with `import vikeSolid from 'vike-solid/config'` (typically in your /pages/+config.
|
|
4
|
+
console.warn("[vike-solid][warning][deprecation] Replace `import vikeVue from 'vike-solid'` with `import vikeSolid from 'vike-solid/config'` (typically in your /pages/+config.js)");
|
package/package.json
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "vike-solid",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.3",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"dependencies": {
|
|
6
|
-
"vite-plugin-solid": "^2.10.
|
|
6
|
+
"vite-plugin-solid": "^2.10.2"
|
|
7
7
|
},
|
|
8
8
|
"peerDependencies": {
|
|
9
9
|
"solid-js": "^1.8.7",
|
|
@@ -11,21 +11,21 @@
|
|
|
11
11
|
"vite": "^4.4 || ^5.0.2"
|
|
12
12
|
},
|
|
13
13
|
"devDependencies": {
|
|
14
|
-
"@babel/core": "^7.
|
|
15
|
-
"@babel/preset-env": "^7.
|
|
16
|
-
"@babel/preset-typescript": "^7.
|
|
14
|
+
"@babel/core": "^7.24.3",
|
|
15
|
+
"@babel/preset-env": "^7.24.3",
|
|
16
|
+
"@babel/preset-typescript": "^7.24.1",
|
|
17
17
|
"@rollup/plugin-babel": "^6.0.4",
|
|
18
18
|
"@rollup/plugin-node-resolve": "^15.2.3",
|
|
19
19
|
"@types/node": "^18.17.4",
|
|
20
|
-
"babel-preset-solid": "^1.8.
|
|
21
|
-
"bumpp": "^9.
|
|
22
|
-
"rollup": "^4.
|
|
20
|
+
"babel-preset-solid": "^1.8.16",
|
|
21
|
+
"bumpp": "^9.4.0",
|
|
22
|
+
"rollup": "^4.13.2",
|
|
23
23
|
"rollup-plugin-dts": "^6.1.0",
|
|
24
|
-
"solid-js": "^1.8.
|
|
24
|
+
"solid-js": "^1.8.16",
|
|
25
25
|
"tslib": "^2.6.2",
|
|
26
|
-
"typescript": "^5.
|
|
27
|
-
"vike": "^0.4.
|
|
28
|
-
"vite": "^5.
|
|
26
|
+
"typescript": "^5.4.3",
|
|
27
|
+
"vike": "^0.4.168",
|
|
28
|
+
"vite": "^5.2.7"
|
|
29
29
|
},
|
|
30
30
|
"exports": {
|
|
31
31
|
".": "./dist/main.js",
|