vike-solid 0.8.4 → 0.8.5
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 +8 -1
- package/dist/+config.js +7 -0
- package/dist/{Config-Qtn-iVoW.d.ts → Config-BOYe18lM.d.ts} +8 -1
- package/dist/components/ClientOnly.js +1 -0
- package/dist/components/Config/Config-client.d.ts +1 -1
- package/dist/components/Config/Config-client.js +1 -0
- package/dist/components/Config/Config-server.d.ts +1 -1
- package/dist/components/Config/Config-server.js +2 -1
- package/dist/components/Head/Head-server.js +2 -1
- package/dist/{configsClientSide-ByDxapiw.js → configsClientSide-DGn9Atty.js} +1 -1
- package/dist/{configsCumulative-VCpzeMWX.js → configsCumulative-DOGydCI5.js} +1 -1
- package/dist/hooks/useConfig/useConfig-client.d.ts +1 -1
- package/dist/hooks/useConfig/useConfig-client.js +1 -0
- package/dist/hooks/useConfig/useConfig-server.d.ts +1 -1
- package/dist/hooks/useConfig/useConfig-server.js +2 -1
- package/dist/hooks/useHydrated.js +1 -0
- package/dist/hooks/usePageContext.js +1 -0
- package/dist/integration/onRenderClient.js +7 -3
- package/dist/integration/onRenderHtml.js +18 -6
- package/package.json +1 -1
package/dist/+config.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ConfigEffect } from 'vike/types';
|
|
2
|
-
import './Config-
|
|
2
|
+
import './Config-BOYe18lM.js';
|
|
3
3
|
import { JSX } from 'solid-js';
|
|
4
4
|
|
|
5
5
|
declare function ssrEffect({ configDefinedAt, configValue }: Parameters<ConfigEffect>[0]): ReturnType<ConfigEffect>;
|
|
@@ -125,6 +125,13 @@ declare const _default: {
|
|
|
125
125
|
global: true;
|
|
126
126
|
cumulative: true;
|
|
127
127
|
};
|
|
128
|
+
rootAttributes: {
|
|
129
|
+
env: {
|
|
130
|
+
server: true;
|
|
131
|
+
};
|
|
132
|
+
global: true;
|
|
133
|
+
cumulative: true;
|
|
134
|
+
};
|
|
128
135
|
onAfterRenderClient: {
|
|
129
136
|
env: {
|
|
130
137
|
server: false;
|
package/dist/+config.js
CHANGED
|
@@ -135,6 +135,13 @@ var _config = {
|
|
|
135
135
|
global: true,
|
|
136
136
|
cumulative: true // for Vike extensions
|
|
137
137
|
},
|
|
138
|
+
rootAttributes: {
|
|
139
|
+
env: {
|
|
140
|
+
server: true
|
|
141
|
+
},
|
|
142
|
+
global: true,
|
|
143
|
+
cumulative: true // for Vike extensions
|
|
144
|
+
},
|
|
138
145
|
onAfterRenderClient: {
|
|
139
146
|
env: {
|
|
140
147
|
server: false,
|
|
@@ -117,6 +117,12 @@ declare global {
|
|
|
117
117
|
* https://vike.dev/bodyAttributes
|
|
118
118
|
*/
|
|
119
119
|
bodyAttributes?: TagAttributes | ((pageContext: PageContextServer) => TagAttributes | undefined);
|
|
120
|
+
/**
|
|
121
|
+
* Add tag attributes to the root element such as `<div id="root" role="none">`.
|
|
122
|
+
*
|
|
123
|
+
* https://vike.dev/rootAttributes
|
|
124
|
+
*/
|
|
125
|
+
rootAttributes?: TagAttributes | ((pageContext: PageContextServer) => TagAttributes | undefined);
|
|
120
126
|
/**
|
|
121
127
|
* If `true`, the page is rendered twice: on the server-side (to HTML) and on the client-side (hydration).
|
|
122
128
|
*
|
|
@@ -161,6 +167,7 @@ declare global {
|
|
|
161
167
|
Head?: Array<Head>;
|
|
162
168
|
bodyAttributes?: TagAttributes[];
|
|
163
169
|
htmlAttributes?: TagAttributes[];
|
|
170
|
+
rootAttributes?: TagAttributes[];
|
|
164
171
|
onAfterRenderClient?: Function[];
|
|
165
172
|
stream?: Exclude<Config["stream"], ImportString>[];
|
|
166
173
|
}
|
|
@@ -171,6 +178,6 @@ type Head = Component | JSX.Element;
|
|
|
171
178
|
type PickWithoutGetter<T, K extends keyof T> = {
|
|
172
179
|
[P in K]: Exclude<T[P], Function>;
|
|
173
180
|
};
|
|
174
|
-
type ConfigFromHook = PickWithoutGetter<Vike.Config, "Head" | "title" | "description" | "image" | "favicon" | "lang" | "viewport" | "bodyAttributes" | "htmlAttributes">;
|
|
181
|
+
type ConfigFromHook = PickWithoutGetter<Vike.Config, "Head" | "title" | "description" | "image" | "favicon" | "lang" | "viewport" | "bodyAttributes" | "htmlAttributes" | "rootAttributes">;
|
|
175
182
|
|
|
176
183
|
export type { ConfigFromHook as C };
|
|
@@ -2,6 +2,7 @@ import { createComponent } from 'solid-js/web';
|
|
|
2
2
|
import { Show, children } from 'solid-js';
|
|
3
3
|
import { useHydrated } from '../hooks/useHydrated.js';
|
|
4
4
|
import { usePageContext } from '../hooks/usePageContext.js';
|
|
5
|
+
import 'solid-js/store';
|
|
5
6
|
|
|
6
7
|
function assert(condition) {
|
|
7
8
|
if (condition) return;
|
|
@@ -2,8 +2,9 @@ import { useConfig } from '../../hooks/useConfig/useConfig-server.js';
|
|
|
2
2
|
import '../../hooks/usePageContext.js';
|
|
3
3
|
import 'solid-js/web';
|
|
4
4
|
import 'solid-js';
|
|
5
|
+
import 'solid-js/store';
|
|
5
6
|
import 'vike/getPageContext';
|
|
6
|
-
import '../../configsCumulative-
|
|
7
|
+
import '../../configsCumulative-DOGydCI5.js';
|
|
7
8
|
|
|
8
9
|
/**
|
|
9
10
|
* Set configurations inside Solid components.
|
|
@@ -2,8 +2,9 @@ import { useConfig } from '../../hooks/useConfig/useConfig-server.js';
|
|
|
2
2
|
import '../../hooks/usePageContext.js';
|
|
3
3
|
import 'solid-js/web';
|
|
4
4
|
import 'solid-js';
|
|
5
|
+
import 'solid-js/store';
|
|
5
6
|
import 'vike/getPageContext';
|
|
6
|
-
import '../../configsCumulative-
|
|
7
|
+
import '../../configsCumulative-DOGydCI5.js';
|
|
7
8
|
|
|
8
9
|
/**
|
|
9
10
|
* Add arbitrary `<head>` tags.
|
|
@@ -16,7 +16,7 @@ export function includes<Arr extends any[] | readonly any[]>(arr: Arr, el: unkno
|
|
|
16
16
|
}
|
|
17
17
|
*/
|
|
18
18
|
|
|
19
|
-
const configsCumulative = ["Head", "bodyAttributes", "htmlAttributes"];
|
|
19
|
+
const configsCumulative = ["Head", "bodyAttributes", "htmlAttributes", "rootAttributes"];
|
|
20
20
|
|
|
21
21
|
// Settings the client-side applies upon navigation, see applyHeadSettings(). The others are HTML-only.
|
|
22
22
|
const configsClientSide = ["title", "lang"];
|
|
@@ -9,6 +9,6 @@ export function includes<Arr extends any[] | readonly any[]>(arr: Arr, el: unkno
|
|
|
9
9
|
}
|
|
10
10
|
*/
|
|
11
11
|
|
|
12
|
-
const configsCumulative = ["Head", "bodyAttributes", "htmlAttributes"];
|
|
12
|
+
const configsCumulative = ["Head", "bodyAttributes", "htmlAttributes", "rootAttributes"];
|
|
13
13
|
|
|
14
14
|
export { configsCumulative as c, includes as i };
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { usePageContext } from '../usePageContext.js';
|
|
2
2
|
import { getPageContext } from 'vike/getPageContext';
|
|
3
|
-
import { i as includes, c as configsCumulative } from '../../configsCumulative-
|
|
3
|
+
import { i as includes, c as configsCumulative } from '../../configsCumulative-DOGydCI5.js';
|
|
4
4
|
import 'solid-js/web';
|
|
5
5
|
import 'solid-js';
|
|
6
|
+
import 'solid-js/store';
|
|
6
7
|
|
|
7
8
|
// https://stackoverflow.com/questions/52856496/typescript-object-keys-return-string
|
|
8
9
|
// https://github.com/sindresorhus/ts-extras/blob/main/source/object-keys.ts
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { createComponent } from 'solid-js/web';
|
|
2
2
|
import { createContext, useContext } from 'solid-js';
|
|
3
|
+
import 'solid-js/store';
|
|
3
4
|
|
|
4
5
|
function getGlobalObject(
|
|
5
6
|
// We use the filename as key; each `getGlobalObject()` call should live inside a file with a unique filename.
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { createComponent, memo, Dynamic, hydrate, render } from 'solid-js/web';
|
|
2
|
-
import { i as includes, c as configsCumulative } from '../configsCumulative-
|
|
2
|
+
import { i as includes, c as configsCumulative } from '../configsCumulative-DOGydCI5.js';
|
|
3
3
|
import { PageContextProvider, usePageContext } from '../hooks/usePageContext.js';
|
|
4
4
|
import { createComputed, createComponent as createComponent$1 } from 'solid-js';
|
|
5
5
|
import { createStore, reconcile } from 'solid-js/store';
|
|
@@ -22,9 +22,13 @@ function getHeadSetting(configName, pageContext) {
|
|
|
22
22
|
if (valFromUseConfig !== undefined) return valFromUseConfig;
|
|
23
23
|
return getCallable(valFromConfig);
|
|
24
24
|
} else {
|
|
25
|
+
// Sorted by increasing precedence: the values set by Vike extensions come first, then the app's values (the most
|
|
26
|
+
// specific one last), then the values set by useConfig(). Merging the list in order (e.g. with Object.assign())
|
|
27
|
+
// thus yields the value with the highest precedence.
|
|
25
28
|
return [
|
|
26
|
-
//
|
|
27
|
-
|
|
29
|
+
// pageContext.config[configName] is sorted by decreasing precedence (the most specific value first, the values set
|
|
30
|
+
// by Vike extensions last) => we reverse it. (We copy the list first: pageContext.config is shared.)
|
|
31
|
+
...[...(valFromConfig ?? [])].reverse().map(getCallable), ...(valFromUseConfig ?? [])];
|
|
28
32
|
}
|
|
29
33
|
}
|
|
30
34
|
|
|
@@ -2,7 +2,7 @@ import { createComponent, Dynamic, generateHydrationScript, renderToStringAsync,
|
|
|
2
2
|
import isBot from 'isbot-fast';
|
|
3
3
|
import { dangerouslySkipEscape, escapeInject, stampPipe } from 'vike/server';
|
|
4
4
|
import { PageContextProvider, usePageContext } from '../hooks/usePageContext.js';
|
|
5
|
-
import { i as includes, a as configsCumulative, o as objectKeys, c as configsClientSide } from '../configsClientSide-
|
|
5
|
+
import { i as includes, a as configsCumulative, o as objectKeys, c as configsClientSide } from '../configsClientSide-DGn9Atty.js';
|
|
6
6
|
import { createComputed, createComponent as createComponent$1 } from 'solid-js';
|
|
7
7
|
import { createStore, reconcile } from 'solid-js/store';
|
|
8
8
|
|
|
@@ -44,9 +44,13 @@ function getHeadSetting(configName, pageContext) {
|
|
|
44
44
|
if (valFromUseConfig !== undefined) return valFromUseConfig;
|
|
45
45
|
return getCallable(valFromConfig);
|
|
46
46
|
} else {
|
|
47
|
+
// Sorted by increasing precedence: the values set by Vike extensions come first, then the app's values (the most
|
|
48
|
+
// specific one last), then the values set by useConfig(). Merging the list in order (e.g. with Object.assign())
|
|
49
|
+
// thus yields the value with the highest precedence.
|
|
47
50
|
return [
|
|
48
|
-
//
|
|
49
|
-
|
|
51
|
+
// pageContext.config[configName] is sorted by decreasing precedence (the most specific value first, the values set
|
|
52
|
+
// by Vike extensions last) => we reverse it. (We copy the list first: pageContext.config is shared.)
|
|
53
|
+
...[...(valFromConfig ?? [])].reverse().map(getCallable), ...(valFromUseConfig ?? [])];
|
|
50
54
|
}
|
|
51
55
|
}
|
|
52
56
|
|
|
@@ -103,7 +107,8 @@ const onRenderHtml = async pageContext => {
|
|
|
103
107
|
const headHtml = getHeadHtml(pageContext);
|
|
104
108
|
const {
|
|
105
109
|
htmlAttributesString,
|
|
106
|
-
bodyAttributesString
|
|
110
|
+
bodyAttributesString,
|
|
111
|
+
rootAttributesString
|
|
107
112
|
} = getTagAttributes(pageContext);
|
|
108
113
|
|
|
109
114
|
// Keep only what the client-side applies upon navigation, and remove the rest (HTML-only and/or
|
|
@@ -117,7 +122,7 @@ const onRenderHtml = async pageContext => {
|
|
|
117
122
|
${dangerouslySkipEscape(generateHydrationScript())}
|
|
118
123
|
</head>
|
|
119
124
|
<body${dangerouslySkipEscape(bodyAttributesString)}>
|
|
120
|
-
<div
|
|
125
|
+
<div${dangerouslySkipEscape(rootAttributesString)}>${pageHtml}</div>
|
|
121
126
|
</body>
|
|
122
127
|
</html>`;
|
|
123
128
|
};
|
|
@@ -215,14 +220,21 @@ function getTagAttributes(pageContext) {
|
|
|
215
220
|
if (lang === undefined) lang = "en";
|
|
216
221
|
const bodyAttributes = mergeTagAttributesList(getHeadSetting("bodyAttributes", pageContext));
|
|
217
222
|
const htmlAttributes = mergeTagAttributesList(getHeadSetting("htmlAttributes", pageContext));
|
|
223
|
+
const rootAttributes = mergeTagAttributesList(getHeadSetting("rootAttributes", pageContext));
|
|
218
224
|
const bodyAttributesString = getTagAttributesString(bodyAttributes);
|
|
219
225
|
const htmlAttributesString = getTagAttributesString({
|
|
220
226
|
...htmlAttributes,
|
|
221
227
|
lang: lang ?? htmlAttributes.lang
|
|
222
228
|
});
|
|
229
|
+
// The root element's `id` is used by onRenderClient(): it's the user's responsibility not to override it.
|
|
230
|
+
const rootAttributesString = getTagAttributesString({
|
|
231
|
+
id: "root",
|
|
232
|
+
...rootAttributes
|
|
233
|
+
});
|
|
223
234
|
return {
|
|
224
235
|
htmlAttributesString,
|
|
225
|
-
bodyAttributesString
|
|
236
|
+
bodyAttributesString,
|
|
237
|
+
rootAttributesString
|
|
226
238
|
};
|
|
227
239
|
}
|
|
228
240
|
function mergeTagAttributesList(tagAttributesList = []) {
|