vike-solid 0.7.1 → 0.7.3-commit-704e0a7
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/+config.d.ts +13 -6
- package/dist/+config.js +12 -5
- package/dist/{Config-CVJUysUv.d.ts → Config-DOVdsmM1.d.ts} +11 -3
- package/dist/applyHeadSettings-BwjKVYXB.js +11 -0
- package/dist/components/Config/Config-client.d.ts +2 -7
- package/dist/components/Config/Config-client.js +1 -5
- package/dist/components/Config/Config-server.d.ts +3 -3
- package/dist/components/Config/Config-server.js +2 -1
- package/dist/components/Head/Head-server.js +1 -0
- package/dist/hooks/useConfig/useConfig-client.d.ts +2 -7
- package/dist/hooks/useConfig/useConfig-client.js +7 -10
- package/dist/hooks/useConfig/useConfig-server.d.ts +4 -7
- package/dist/hooks/useConfig/useConfig-server.js +3 -14
- package/dist/includes-B0OUVLz0.js +14 -0
- package/dist/{renderer → integration}/onRenderClient.js +32 -30
- package/dist/{renderer → integration}/onRenderHtml.js +27 -22
- package/dist/vite-plugin-vike-solid.js +1 -1
- package/package.json +17 -16
package/dist/+config.d.ts
CHANGED
|
@@ -1,25 +1,25 @@
|
|
|
1
1
|
import { ConfigEffect } from 'vike/types';
|
|
2
|
+
import './Config-DOVdsmM1.js';
|
|
2
3
|
import { JSX } from 'solid-js';
|
|
3
|
-
import './Config-CVJUysUv.js';
|
|
4
4
|
|
|
5
5
|
declare function ssrEffect({ configDefinedAt, configValue }: Parameters<ConfigEffect>[0]): ReturnType<ConfigEffect>;
|
|
6
6
|
|
|
7
7
|
declare global {
|
|
8
8
|
namespace Vike {
|
|
9
9
|
interface PageContext {
|
|
10
|
-
/** The root
|
|
10
|
+
/** The root Solid component of the page */
|
|
11
11
|
Page?: () => JSX.Element;
|
|
12
12
|
}
|
|
13
13
|
}
|
|
14
14
|
}
|
|
15
15
|
|
|
16
|
-
declare const
|
|
16
|
+
declare const config: {
|
|
17
17
|
name: string;
|
|
18
18
|
require: {
|
|
19
19
|
vike: string;
|
|
20
20
|
};
|
|
21
|
-
onRenderHtml: "import:vike-solid/
|
|
22
|
-
onRenderClient: "import:vike-solid/
|
|
21
|
+
onRenderHtml: "import:vike-solid/__internal/integration/onRenderHtml:onRenderHtml";
|
|
22
|
+
onRenderClient: "import:vike-solid/__internal/integration/onRenderClient:onRenderClient";
|
|
23
23
|
clientRouting: true;
|
|
24
24
|
hydrationCanBeAborted: true;
|
|
25
25
|
passToClient: string[];
|
|
@@ -37,6 +37,13 @@ declare const _default: {
|
|
|
37
37
|
};
|
|
38
38
|
cumulative: true;
|
|
39
39
|
};
|
|
40
|
+
Wrapper: {
|
|
41
|
+
env: {
|
|
42
|
+
server: true;
|
|
43
|
+
client: true;
|
|
44
|
+
};
|
|
45
|
+
cumulative: true;
|
|
46
|
+
};
|
|
40
47
|
title: {
|
|
41
48
|
env: {
|
|
42
49
|
server: true;
|
|
@@ -105,4 +112,4 @@ declare const _default: {
|
|
|
105
112
|
};
|
|
106
113
|
};
|
|
107
114
|
|
|
108
|
-
export {
|
|
115
|
+
export { config };
|
package/dist/+config.js
CHANGED
|
@@ -19,15 +19,15 @@ function ssrEffect({
|
|
|
19
19
|
};
|
|
20
20
|
}
|
|
21
21
|
|
|
22
|
-
|
|
22
|
+
const config = {
|
|
23
23
|
name: "vike-solid",
|
|
24
24
|
require: {
|
|
25
|
-
vike: ">=0.4.
|
|
25
|
+
vike: ">=0.4.191"
|
|
26
26
|
},
|
|
27
27
|
// https://vike.dev/onRenderHtml
|
|
28
|
-
onRenderHtml: "import:vike-solid/
|
|
28
|
+
onRenderHtml: "import:vike-solid/__internal/integration/onRenderHtml:onRenderHtml",
|
|
29
29
|
// https://vike.dev/onRenderClient
|
|
30
|
-
onRenderClient: "import:vike-solid/
|
|
30
|
+
onRenderClient: "import:vike-solid/__internal/integration/onRenderClient:onRenderClient",
|
|
31
31
|
// https://vike.dev/clientRouting
|
|
32
32
|
clientRouting: true,
|
|
33
33
|
hydrationCanBeAborted: true,
|
|
@@ -47,6 +47,13 @@ var _config = {
|
|
|
47
47
|
},
|
|
48
48
|
cumulative: true
|
|
49
49
|
},
|
|
50
|
+
Wrapper: {
|
|
51
|
+
env: {
|
|
52
|
+
server: true,
|
|
53
|
+
client: true
|
|
54
|
+
},
|
|
55
|
+
cumulative: true
|
|
56
|
+
},
|
|
50
57
|
title: {
|
|
51
58
|
env: {
|
|
52
59
|
server: true,
|
|
@@ -115,4 +122,4 @@ var _config = {
|
|
|
115
122
|
}
|
|
116
123
|
};
|
|
117
124
|
|
|
118
|
-
export {
|
|
125
|
+
export { config };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
+
import { PageContextServer, PageContextClient, PageContext } from 'vike/types';
|
|
1
2
|
import { JSX, Component } from 'solid-js';
|
|
2
|
-
import { PageContext, PageContextServer, PageContextClient } from 'vike/types';
|
|
3
3
|
|
|
4
4
|
type TagAttributes = Record<string, string | number | boolean | undefined | null>;
|
|
5
5
|
|
|
@@ -28,6 +28,12 @@ declare global {
|
|
|
28
28
|
* https://vike.dev/Layout
|
|
29
29
|
*/
|
|
30
30
|
Layout?: Component;
|
|
31
|
+
/**
|
|
32
|
+
* A component wrapping the the root component `<Page>`.
|
|
33
|
+
*
|
|
34
|
+
* https://vike.dev/Wrapper
|
|
35
|
+
*/
|
|
36
|
+
Wrapper?: Component;
|
|
31
37
|
/**
|
|
32
38
|
* Set the page's tilte.
|
|
33
39
|
*
|
|
@@ -41,7 +47,7 @@ declare global {
|
|
|
41
47
|
*
|
|
42
48
|
* https://vike.dev/title
|
|
43
49
|
*/
|
|
44
|
-
title?: string | null | ((pageContext:
|
|
50
|
+
title?: string | null | ((pageContext: PageContext_) => string | null | undefined);
|
|
45
51
|
/**
|
|
46
52
|
* Set the page's description.
|
|
47
53
|
*
|
|
@@ -98,7 +104,7 @@ declare global {
|
|
|
98
104
|
*
|
|
99
105
|
* https://vike.dev/lang
|
|
100
106
|
*/
|
|
101
|
-
lang?: string | null | ((pageContext:
|
|
107
|
+
lang?: string | null | ((pageContext: PageContext_) => string | null | undefined);
|
|
102
108
|
/**
|
|
103
109
|
* Add tag attributes such as `<html class="dark">`.
|
|
104
110
|
*
|
|
@@ -140,6 +146,7 @@ declare global {
|
|
|
140
146
|
}
|
|
141
147
|
interface ConfigResolved {
|
|
142
148
|
Layout?: Array<Component>;
|
|
149
|
+
Wrapper?: Array<Component>;
|
|
143
150
|
Head?: Array<Head>;
|
|
144
151
|
bodyAttributes?: TagAttributes[];
|
|
145
152
|
htmlAttributes?: TagAttributes[];
|
|
@@ -147,6 +154,7 @@ declare global {
|
|
|
147
154
|
}
|
|
148
155
|
}
|
|
149
156
|
}
|
|
157
|
+
type PageContext_ = PageContext;
|
|
150
158
|
type Head = Component | JSX.Element;
|
|
151
159
|
type PickWithoutGetter<T, K extends keyof T> = {
|
|
152
160
|
[P in K]: Exclude<T[P], Function>;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
// - We skip if `undefined` as we shouldn't remove values set by the Head setting.
|
|
2
|
+
// - Setting a default prevents the previous value to be leaked: upon client-side navigation, the value set by the previous page won't be removed if the next page doesn't override it.
|
|
3
|
+
// - Most of the time, the user sets a default himself (i.e. a value defined at /pages/+config.js)
|
|
4
|
+
// - If he doesn't have a default then he can use `null` to opt into Vike's defaults
|
|
5
|
+
|
|
6
|
+
function applyHeadSettings(title, lang) {
|
|
7
|
+
if (title !== undefined) document.title = title || "";
|
|
8
|
+
if (lang !== undefined) document.documentElement.lang = lang || "en";
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export { applyHeadSettings as a };
|
|
@@ -1,12 +1,7 @@
|
|
|
1
|
-
import { C as ConfigFromHook } from '../../Config-
|
|
2
|
-
import 'solid-js';
|
|
1
|
+
import { C as ConfigFromHook } from '../../Config-DOVdsmM1.js';
|
|
3
2
|
import 'vike/types';
|
|
3
|
+
import 'solid-js';
|
|
4
4
|
|
|
5
|
-
/**
|
|
6
|
-
* Set configurations inside React components.
|
|
7
|
-
*
|
|
8
|
-
* https://vike.dev/useConfig
|
|
9
|
-
*/
|
|
10
5
|
declare function Config(props: ConfigFromHook): null;
|
|
11
6
|
|
|
12
7
|
export { Config };
|
|
@@ -3,12 +3,8 @@ import '../../hooks/usePageContext.js';
|
|
|
3
3
|
import 'solid-js/web';
|
|
4
4
|
import 'solid-js';
|
|
5
5
|
import 'vike/getPageContext';
|
|
6
|
+
import '../../applyHeadSettings-BwjKVYXB.js';
|
|
6
7
|
|
|
7
|
-
/**
|
|
8
|
-
* Set configurations inside React components.
|
|
9
|
-
*
|
|
10
|
-
* https://vike.dev/useConfig
|
|
11
|
-
*/
|
|
12
8
|
function Config(props) {
|
|
13
9
|
const config = useConfig();
|
|
14
10
|
config(props);
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { C as ConfigFromHook } from '../../Config-
|
|
2
|
-
import 'solid-js';
|
|
1
|
+
import { C as ConfigFromHook } from '../../Config-DOVdsmM1.js';
|
|
3
2
|
import 'vike/types';
|
|
3
|
+
import 'solid-js';
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
|
-
* Set configurations inside
|
|
6
|
+
* Set configurations inside Solid components.
|
|
7
7
|
*
|
|
8
8
|
* https://vike.dev/useConfig
|
|
9
9
|
*/
|
|
@@ -3,9 +3,10 @@ import '../../hooks/usePageContext.js';
|
|
|
3
3
|
import 'solid-js/web';
|
|
4
4
|
import 'solid-js';
|
|
5
5
|
import 'vike/getPageContext';
|
|
6
|
+
import '../../includes-B0OUVLz0.js';
|
|
6
7
|
|
|
7
8
|
/**
|
|
8
|
-
* Set configurations inside
|
|
9
|
+
* Set configurations inside Solid components.
|
|
9
10
|
*
|
|
10
11
|
* https://vike.dev/useConfig
|
|
11
12
|
*/
|
|
@@ -1,12 +1,7 @@
|
|
|
1
|
-
import { C as ConfigFromHook } from '../../Config-
|
|
2
|
-
import 'solid-js';
|
|
1
|
+
import { C as ConfigFromHook } from '../../Config-DOVdsmM1.js';
|
|
3
2
|
import 'vike/types';
|
|
3
|
+
import 'solid-js';
|
|
4
4
|
|
|
5
|
-
/**
|
|
6
|
-
* Set configurations inside React components and Vike hooks.
|
|
7
|
-
*
|
|
8
|
-
* https://vike.dev/useConfig
|
|
9
|
-
*/
|
|
10
5
|
declare function useConfig(): (config: ConfigFromHook) => void;
|
|
11
6
|
|
|
12
7
|
export { useConfig };
|
|
@@ -1,25 +1,21 @@
|
|
|
1
1
|
import { usePageContext } from '../usePageContext.js';
|
|
2
2
|
import { getPageContext } from 'vike/getPageContext';
|
|
3
|
+
import { a as applyHeadSettings } from '../../applyHeadSettings-BwjKVYXB.js';
|
|
3
4
|
import 'solid-js/web';
|
|
4
5
|
import 'solid-js';
|
|
5
6
|
|
|
6
|
-
/**
|
|
7
|
-
* Set configurations inside React components and Vike hooks.
|
|
8
|
-
*
|
|
9
|
-
* https://vike.dev/useConfig
|
|
10
|
-
*/
|
|
11
7
|
function useConfig() {
|
|
12
8
|
// Vike hook
|
|
13
9
|
let pageContext = getPageContext();
|
|
14
10
|
if (pageContext) return config => setPageContextConfigFromHook(config, pageContext);
|
|
15
11
|
|
|
16
|
-
//
|
|
12
|
+
// Component
|
|
17
13
|
pageContext = usePageContext();
|
|
18
14
|
return config => {
|
|
19
15
|
if (!("_headAlreadySet" in pageContext)) {
|
|
20
16
|
setPageContextConfigFromHook(config, pageContext);
|
|
21
17
|
} else {
|
|
22
|
-
|
|
18
|
+
applyHead(config);
|
|
23
19
|
}
|
|
24
20
|
};
|
|
25
21
|
}
|
|
@@ -27,11 +23,12 @@ function setPageContextConfigFromHook(config, pageContext) {
|
|
|
27
23
|
pageContext._configFromHook ??= {};
|
|
28
24
|
Object.assign(pageContext._configFromHook, config);
|
|
29
25
|
}
|
|
30
|
-
function
|
|
26
|
+
function applyHead(config) {
|
|
31
27
|
const {
|
|
32
|
-
title
|
|
28
|
+
title,
|
|
29
|
+
lang
|
|
33
30
|
} = config;
|
|
34
|
-
|
|
31
|
+
applyHeadSettings(title, lang);
|
|
35
32
|
}
|
|
36
33
|
|
|
37
34
|
export { useConfig };
|
|
@@ -1,15 +1,12 @@
|
|
|
1
|
-
import { C as ConfigFromHook } from '../../Config-
|
|
2
|
-
import 'solid-js';
|
|
1
|
+
import { C as ConfigFromHook } from '../../Config-DOVdsmM1.js';
|
|
3
2
|
import 'vike/types';
|
|
4
|
-
|
|
5
|
-
type ConfigFromHookCumulative = (typeof configsCumulative)[number];
|
|
3
|
+
import 'solid-js';
|
|
6
4
|
|
|
7
5
|
/**
|
|
8
|
-
* Set configurations inside
|
|
6
|
+
* Set configurations inside components and Vike hooks.
|
|
9
7
|
*
|
|
10
8
|
* https://vike.dev/useConfig
|
|
11
9
|
*/
|
|
12
10
|
declare function useConfig(): (config: ConfigFromHook) => void;
|
|
13
|
-
declare const configsCumulative: readonly ["Head", "bodyAttributes", "htmlAttributes"];
|
|
14
11
|
|
|
15
|
-
export {
|
|
12
|
+
export { useConfig };
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { usePageContext } from '../usePageContext.js';
|
|
2
2
|
import { getPageContext } from 'vike/getPageContext';
|
|
3
|
+
import { i as includes, c as configsCumulative } from '../../includes-B0OUVLz0.js';
|
|
3
4
|
import 'solid-js/web';
|
|
4
5
|
import 'solid-js';
|
|
5
6
|
|
|
@@ -10,19 +11,8 @@ function objectKeys(obj) {
|
|
|
10
11
|
return Object.keys(obj);
|
|
11
12
|
}
|
|
12
13
|
|
|
13
|
-
// https://stackoverflow.com/questions/56565528/typescript-const-assertions-how-to-use-array-prototype-includes/74213179#74213179
|
|
14
|
-
/** Same as Array.prototype.includes() but with type inference */
|
|
15
|
-
function includes(values, x) {
|
|
16
|
-
return values.includes(x);
|
|
17
|
-
}
|
|
18
|
-
/*
|
|
19
|
-
export function includes<Arr extends any[] | readonly any[]>(arr: Arr, el: unknown): el is Arr[number] {
|
|
20
|
-
return arr.includes(el as any)
|
|
21
|
-
}
|
|
22
|
-
*/
|
|
23
|
-
|
|
24
14
|
/**
|
|
25
|
-
* Set configurations inside
|
|
15
|
+
* Set configurations inside components and Vike hooks.
|
|
26
16
|
*
|
|
27
17
|
* https://vike.dev/useConfig
|
|
28
18
|
*/
|
|
@@ -31,7 +21,7 @@ function useConfig() {
|
|
|
31
21
|
let pageContext = getPageContext();
|
|
32
22
|
if (pageContext) return config => setPageContextConfigFromHook(config, pageContext);
|
|
33
23
|
|
|
34
|
-
//
|
|
24
|
+
// Component
|
|
35
25
|
pageContext = usePageContext();
|
|
36
26
|
return config => {
|
|
37
27
|
if (!pageContext._headAlreadySet) {
|
|
@@ -42,7 +32,6 @@ function useConfig() {
|
|
|
42
32
|
};
|
|
43
33
|
}
|
|
44
34
|
const configsClientSide = ["title"];
|
|
45
|
-
const configsCumulative = ["Head", "bodyAttributes", "htmlAttributes"];
|
|
46
35
|
function setPageContextConfigFromHook(config, pageContext) {
|
|
47
36
|
pageContext._configFromHook ??= {};
|
|
48
37
|
objectKeys(config).forEach(configName => {
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
const configsCumulative = ["Head", "bodyAttributes", "htmlAttributes"];
|
|
2
|
+
|
|
3
|
+
// https://stackoverflow.com/questions/56565528/typescript-const-assertions-how-to-use-array-prototype-includes/74213179#74213179
|
|
4
|
+
/** Same as Array.prototype.includes() but with type inference */
|
|
5
|
+
function includes(values, x) {
|
|
6
|
+
return values.includes(x);
|
|
7
|
+
}
|
|
8
|
+
/*
|
|
9
|
+
export function includes<Arr extends any[] | readonly any[]>(arr: Arr, el: unknown): el is Arr[number] {
|
|
10
|
+
return arr.includes(el as any)
|
|
11
|
+
}
|
|
12
|
+
*/
|
|
13
|
+
|
|
14
|
+
export { configsCumulative as c, includes as i };
|
|
@@ -1,27 +1,30 @@
|
|
|
1
1
|
import { createComponent, Dynamic, memo, hydrate, render } from 'solid-js/web';
|
|
2
|
+
import { i as includes, c as configsCumulative } from '../includes-B0OUVLz0.js';
|
|
2
3
|
import { PageContextProvider, usePageContext } from '../hooks/usePageContext.js';
|
|
3
4
|
import { createComputed, createComponent as createComponent$1 } from 'solid-js';
|
|
4
5
|
import { createStore, reconcile } from 'solid-js/store';
|
|
6
|
+
import { providePageContext } from 'vike/getPageContext';
|
|
7
|
+
import { a as applyHeadSettings } from '../applyHeadSettings-BwjKVYXB.js';
|
|
5
8
|
|
|
6
9
|
function isCallable(thing) {
|
|
7
10
|
return thing instanceof Function || typeof thing === "function";
|
|
8
11
|
}
|
|
9
12
|
|
|
10
|
-
// We use `any` instead of doing proper validation in order to save KBs sent to the client-side
|
|
13
|
+
// We use `any` instead of doing proper validation in order to save KBs sent to the client-side.
|
|
11
14
|
|
|
12
|
-
function getHeadSetting(
|
|
15
|
+
function getHeadSetting(configName, pageContext) {
|
|
13
16
|
// Set by useConfig()
|
|
14
|
-
|
|
15
|
-
const val = pageContext._configFromHook?.[headSetting];
|
|
16
|
-
if (val !== undefined) return val;
|
|
17
|
-
}
|
|
18
|
-
|
|
17
|
+
const valFromUseConfig = pageContext._configFromHook?.[configName];
|
|
19
18
|
// Set by +configName.js
|
|
20
|
-
const
|
|
21
|
-
|
|
22
|
-
|
|
19
|
+
const valFromConfig = pageContext.config[configName];
|
|
20
|
+
const getCallable = val => isCallable(val) ? val(pageContext) : val;
|
|
21
|
+
if (!includes(configsCumulative, configName)) {
|
|
22
|
+
if (valFromUseConfig !== undefined) return valFromUseConfig;
|
|
23
|
+
return getCallable(valFromConfig);
|
|
23
24
|
} else {
|
|
24
|
-
return
|
|
25
|
+
return [
|
|
26
|
+
//
|
|
27
|
+
...(valFromConfig ?? []).map(getCallable), ...(valFromUseConfig ?? [])];
|
|
25
28
|
}
|
|
26
29
|
}
|
|
27
30
|
|
|
@@ -29,7 +32,7 @@ function getPageElement(pageContext) {
|
|
|
29
32
|
const page = createComponent(PageContextProvider, {
|
|
30
33
|
pageContext: pageContext,
|
|
31
34
|
get children() {
|
|
32
|
-
return createComponent(
|
|
35
|
+
return createComponent(Wrapper, {
|
|
33
36
|
get children() {
|
|
34
37
|
return createComponent(Page, {});
|
|
35
38
|
}
|
|
@@ -38,23 +41,27 @@ function getPageElement(pageContext) {
|
|
|
38
41
|
});
|
|
39
42
|
return page;
|
|
40
43
|
}
|
|
41
|
-
function
|
|
44
|
+
function Wrapper(props) {
|
|
42
45
|
const pageContext = usePageContext();
|
|
43
|
-
const [
|
|
46
|
+
const [wrappers, setWrappers] = createStore([]);
|
|
44
47
|
createComputed(() => {
|
|
45
|
-
|
|
48
|
+
setWrappers(reconcile([
|
|
49
|
+
// Inner wrapping
|
|
50
|
+
...(pageContext.config.Layout || []),
|
|
51
|
+
// Outer wrapping
|
|
52
|
+
...(pageContext.config.Wrapper || [])]));
|
|
46
53
|
});
|
|
47
|
-
const
|
|
48
|
-
let item =
|
|
54
|
+
const renderWrappers = (i = 0) => {
|
|
55
|
+
let item = wrappers.at(-(i + 1));
|
|
49
56
|
if (!item) return props.children;
|
|
50
57
|
if (typeof item !== "function") item = Passthrough;
|
|
51
58
|
return createComponent$1(item, {
|
|
52
59
|
get children() {
|
|
53
|
-
return
|
|
60
|
+
return renderWrappers(i + 1);
|
|
54
61
|
}
|
|
55
62
|
});
|
|
56
63
|
};
|
|
57
|
-
return
|
|
64
|
+
return renderWrappers();
|
|
58
65
|
}
|
|
59
66
|
function Page() {
|
|
60
67
|
const pageContext = usePageContext();
|
|
@@ -72,6 +79,7 @@ async function callCumulativeHooks(values, pageContext) {
|
|
|
72
79
|
if (!values) return [];
|
|
73
80
|
const valuesPromises = values.map(val => {
|
|
74
81
|
if (typeof val === "function") {
|
|
82
|
+
providePageContext(pageContext);
|
|
75
83
|
// Hook
|
|
76
84
|
return val(pageContext);
|
|
77
85
|
} else {
|
|
@@ -88,6 +96,7 @@ const [pageContextStore, setPageContext] = createStore({});
|
|
|
88
96
|
let dispose;
|
|
89
97
|
let rendered = false;
|
|
90
98
|
const onRenderClient = async pageContext => {
|
|
99
|
+
pageContext._headAlreadySet = pageContext.isHydration;
|
|
91
100
|
if (!rendered) {
|
|
92
101
|
// Dispose to prevent duplicate pages when navigating.
|
|
93
102
|
if (dispose) dispose();
|
|
@@ -107,8 +116,8 @@ const onRenderClient = async pageContext => {
|
|
|
107
116
|
setPageContext(pageContext);
|
|
108
117
|
}
|
|
109
118
|
if (!pageContext.isHydration) {
|
|
110
|
-
|
|
111
|
-
|
|
119
|
+
pageContext._headAlreadySet = true;
|
|
120
|
+
applyHead(pageContext);
|
|
112
121
|
}
|
|
113
122
|
|
|
114
123
|
// Use cases:
|
|
@@ -116,17 +125,10 @@ const onRenderClient = async pageContext => {
|
|
|
116
125
|
// - Testing tools: https://github.com/vikejs/vike-react/issues/95
|
|
117
126
|
await callCumulativeHooks(pageContext.config.onAfterRenderClient, pageContext);
|
|
118
127
|
};
|
|
119
|
-
function
|
|
120
|
-
pageContext._headAlreadySet = true;
|
|
128
|
+
function applyHead(pageContext) {
|
|
121
129
|
const title = getHeadSetting("title", pageContext);
|
|
122
130
|
const lang = getHeadSetting("lang", pageContext);
|
|
123
|
-
|
|
124
|
-
// - We skip if `undefined` as we shouldn't remove values set by the Head setting.
|
|
125
|
-
// - Setting a default prevents the previous value to be leaked: upon client-side navigation, the value set by the previous page won't be removed if the next page doesn't override it.
|
|
126
|
-
// - Most of the time, the user sets a default himself (i.e. a value defined at /pages/+config.js)
|
|
127
|
-
// - If he doesn't have a default then he can use `null` to opt into Vike's defaults
|
|
128
|
-
if (title !== undefined) document.title = title || "";
|
|
129
|
-
if (lang !== undefined) document.documentElement.lang = lang || "en";
|
|
131
|
+
applyHeadSettings(title, lang);
|
|
130
132
|
}
|
|
131
133
|
|
|
132
134
|
export { onRenderClient };
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { createComponent, Dynamic, generateHydrationScript, renderToString, renderToStream } from 'solid-js/web';
|
|
2
2
|
import { escapeInject, dangerouslySkipEscape, stampPipe } from 'vike/server';
|
|
3
|
+
import { i as includes, c as configsCumulative } from '../includes-B0OUVLz0.js';
|
|
3
4
|
import { PageContextProvider, usePageContext } from '../hooks/usePageContext.js';
|
|
4
5
|
import { createComputed, createComponent as createComponent$1 } from 'solid-js';
|
|
5
6
|
import { createStore, reconcile } from 'solid-js/store';
|
|
@@ -8,21 +9,21 @@ function isCallable(thing) {
|
|
|
8
9
|
return thing instanceof Function || typeof thing === "function";
|
|
9
10
|
}
|
|
10
11
|
|
|
11
|
-
// We use `any` instead of doing proper validation in order to save KBs sent to the client-side
|
|
12
|
+
// We use `any` instead of doing proper validation in order to save KBs sent to the client-side.
|
|
12
13
|
|
|
13
|
-
function getHeadSetting(
|
|
14
|
+
function getHeadSetting(configName, pageContext) {
|
|
14
15
|
// Set by useConfig()
|
|
15
|
-
|
|
16
|
-
const val = pageContext._configFromHook?.[headSetting];
|
|
17
|
-
if (val !== undefined) return val;
|
|
18
|
-
}
|
|
19
|
-
|
|
16
|
+
const valFromUseConfig = pageContext._configFromHook?.[configName];
|
|
20
17
|
// Set by +configName.js
|
|
21
|
-
const
|
|
22
|
-
|
|
23
|
-
|
|
18
|
+
const valFromConfig = pageContext.config[configName];
|
|
19
|
+
const getCallable = val => isCallable(val) ? val(pageContext) : val;
|
|
20
|
+
if (!includes(configsCumulative, configName)) {
|
|
21
|
+
if (valFromUseConfig !== undefined) return valFromUseConfig;
|
|
22
|
+
return getCallable(valFromConfig);
|
|
24
23
|
} else {
|
|
25
|
-
return
|
|
24
|
+
return [
|
|
25
|
+
//
|
|
26
|
+
...(valFromConfig ?? []).map(getCallable), ...(valFromUseConfig ?? [])];
|
|
26
27
|
}
|
|
27
28
|
}
|
|
28
29
|
|
|
@@ -30,7 +31,7 @@ function getPageElement(pageContext) {
|
|
|
30
31
|
const page = createComponent(PageContextProvider, {
|
|
31
32
|
pageContext: pageContext,
|
|
32
33
|
get children() {
|
|
33
|
-
return createComponent(
|
|
34
|
+
return createComponent(Wrapper, {
|
|
34
35
|
get children() {
|
|
35
36
|
return createComponent(Page, {});
|
|
36
37
|
}
|
|
@@ -39,23 +40,27 @@ function getPageElement(pageContext) {
|
|
|
39
40
|
});
|
|
40
41
|
return page;
|
|
41
42
|
}
|
|
42
|
-
function
|
|
43
|
+
function Wrapper(props) {
|
|
43
44
|
const pageContext = usePageContext();
|
|
44
|
-
const [
|
|
45
|
+
const [wrappers, setWrappers] = createStore([]);
|
|
45
46
|
createComputed(() => {
|
|
46
|
-
|
|
47
|
+
setWrappers(reconcile([
|
|
48
|
+
// Inner wrapping
|
|
49
|
+
...(pageContext.config.Layout || []),
|
|
50
|
+
// Outer wrapping
|
|
51
|
+
...(pageContext.config.Wrapper || [])]));
|
|
47
52
|
});
|
|
48
|
-
const
|
|
49
|
-
let item =
|
|
53
|
+
const renderWrappers = (i = 0) => {
|
|
54
|
+
let item = wrappers.at(-(i + 1));
|
|
50
55
|
if (!item) return props.children;
|
|
51
56
|
if (typeof item !== "function") item = Passthrough;
|
|
52
57
|
return createComponent$1(item, {
|
|
53
58
|
get children() {
|
|
54
|
-
return
|
|
59
|
+
return renderWrappers(i + 1);
|
|
55
60
|
}
|
|
56
61
|
});
|
|
57
62
|
};
|
|
58
|
-
return
|
|
63
|
+
return renderWrappers();
|
|
59
64
|
}
|
|
60
65
|
function Page() {
|
|
61
66
|
const pageContext = usePageContext();
|
|
@@ -86,6 +91,9 @@ const onRenderHtml = async pageContext => {
|
|
|
86
91
|
htmlAttributesString,
|
|
87
92
|
bodyAttributesString
|
|
88
93
|
} = getTagAttributes(pageContext);
|
|
94
|
+
|
|
95
|
+
// Not needed on the client-side, thus we remove it to save KBs sent to the client
|
|
96
|
+
delete pageContext._configFromHook;
|
|
89
97
|
return escapeInject`<!DOCTYPE html>
|
|
90
98
|
<html${dangerouslySkipEscape(htmlAttributesString)}>
|
|
91
99
|
<head>
|
|
@@ -129,9 +137,6 @@ function getHeadHtml(pageContext) {
|
|
|
129
137
|
...(pageContext.config.Head ?? []),
|
|
130
138
|
// Added by useConfig()
|
|
131
139
|
...(pageContext._configFromHook?.Head ?? [])].filter(Head => Head !== null && Head !== undefined).map(Head => getHeadElementHtml(Head, pageContext)).join("\n"));
|
|
132
|
-
|
|
133
|
-
// Not needed on the client-side, thus we remove it to save KBs sent to the client
|
|
134
|
-
delete pageContext._configFromHook;
|
|
135
140
|
const headHtml = escapeInject`
|
|
136
141
|
${titleTags}
|
|
137
142
|
${viewportTag}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "vike-solid",
|
|
3
|
-
"version": "0.7.
|
|
3
|
+
"version": "0.7.3-commit-704e0a7",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"dev": "rollup -c rollup.config.js --watch",
|
|
@@ -15,25 +15,26 @@
|
|
|
15
15
|
},
|
|
16
16
|
"peerDependencies": {
|
|
17
17
|
"solid-js": "^1.8.7",
|
|
18
|
-
"
|
|
18
|
+
"vite": ">=5.0.0",
|
|
19
|
+
"vike": ">=0.4.191"
|
|
19
20
|
},
|
|
20
21
|
"devDependencies": {
|
|
21
|
-
"@babel/core": "^7.
|
|
22
|
-
"@babel/preset-env": "^7.
|
|
22
|
+
"@babel/core": "^7.25.2",
|
|
23
|
+
"@babel/preset-env": "^7.25.4",
|
|
23
24
|
"@babel/preset-typescript": "^7.24.7",
|
|
24
|
-
"@brillout/release-me": "^0.
|
|
25
|
+
"@brillout/release-me": "^0.4.0",
|
|
25
26
|
"@rollup/plugin-babel": "^6.0.4",
|
|
26
27
|
"@rollup/plugin-node-resolve": "^15.2.3",
|
|
27
|
-
"@types/node": "^
|
|
28
|
-
"babel-preset-solid": "^1.8.
|
|
29
|
-
"bumpp": "^9.
|
|
30
|
-
"rollup": "^4.
|
|
28
|
+
"@types/node": "^22.4.0",
|
|
29
|
+
"babel-preset-solid": "^1.8.19",
|
|
30
|
+
"bumpp": "^9.5.2",
|
|
31
|
+
"rollup": "^4.21.0",
|
|
31
32
|
"rollup-plugin-dts": "^6.1.1",
|
|
32
|
-
"solid-js": "^1.8.
|
|
33
|
-
"tslib": "^2.
|
|
34
|
-
"typescript": "^5.5.
|
|
35
|
-
"vike": "^0.4.
|
|
36
|
-
"vite": "^5.4.
|
|
33
|
+
"solid-js": "^1.8.21",
|
|
34
|
+
"tslib": "^2.7.0",
|
|
35
|
+
"typescript": "^5.5.4",
|
|
36
|
+
"vike": "^0.4.193",
|
|
37
|
+
"vite": "^5.4.2"
|
|
37
38
|
},
|
|
38
39
|
"exports": {
|
|
39
40
|
"./config": "./dist/+config.js",
|
|
@@ -53,8 +54,8 @@
|
|
|
53
54
|
"default": "./dist/components/Head/Head-server.js"
|
|
54
55
|
},
|
|
55
56
|
"./clientOnly": "./dist/helpers/clientOnly.js",
|
|
56
|
-
"./
|
|
57
|
-
"./
|
|
57
|
+
"./__internal/integration/onRenderHtml": "./dist/integration/onRenderHtml.js",
|
|
58
|
+
"./__internal/integration/onRenderClient": "./dist/integration/onRenderClient.js",
|
|
58
59
|
"./client": {
|
|
59
60
|
"types": "./client.d.ts"
|
|
60
61
|
}
|