vike-solid 0.8.2 → 0.8.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 CHANGED
@@ -1,2 +1,6 @@
1
- Docs: [vike.dev/vike-solid](https://vike.dev/vike-solid)
1
+ <!-- WARNING: keep links absolute in this file so they work on NPM too: https://www.npmjs.com/package/vike-solid -->
2
+
3
+ [![npm version](https://img.shields.io/npm/v/vike-solid)](https://www.npmjs.com/package/vike-solid)
4
+
5
+ Docs: see [vike.dev/vike-solid](https://vike.dev/vike-solid)
2
6
  Source code: [GitHub > vikejs/vike-solid](https://github.com/vikejs/vike-solid)
@@ -11,6 +11,9 @@ function objectKeys(obj) {
11
11
  return Object.keys(obj);
12
12
  }
13
13
 
14
+ // Settings the client-side applies upon navigation, see applyHeadSettings(). The others are HTML-only.
15
+ const configsClientSide = ["title", "lang"];
16
+
14
17
  /**
15
18
  * Set configurations inside components and Vike hooks.
16
19
  *
@@ -34,12 +37,11 @@ function useConfig() {
34
37
  }
35
38
  };
36
39
  }
37
- const configsClientSide = ["title"];
38
40
  function setPageContextConfigFromHook(config, pageContext) {
39
41
  pageContext._configFromHook ??= {};
40
42
  objectKeys(config).forEach(configName => {
41
43
  // Skip HTML only configs which the client-side doesn't need, saving KBs sent to the client as well as avoiding serialization errors.
42
- if (pageContext.isClientSideNavigation && !configsClientSide.includes(configName)) return;
44
+ if (pageContext.isClientSideNavigation && !includes(configsClientSide, configName)) return;
43
45
  if (!includes(configsCumulative, configName)) {
44
46
  // Overridable config
45
47
  const configValue = config[configName];
@@ -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, c as configsCumulative } from '../includes-B0OUVLz0.js';
5
+ import { i as includes, c as configsCumulative, o as objectKeys, a as configsClientSide } from '../objectKeys-DHdL2xFs.js';
6
6
  import { createComputed, createComponent as createComponent$1 } from 'solid-js';
7
7
  import { createStore, reconcile } from 'solid-js/store';
8
8
 
@@ -106,8 +106,9 @@ const onRenderHtml = async pageContext => {
106
106
  bodyAttributesString
107
107
  } = getTagAttributes(pageContext);
108
108
 
109
- // Not needed on the client-side, thus we remove it to save KBs sent to the client
110
- delete pageContext._configFromHook;
109
+ // Keep only what the client-side applies upon navigation, and remove the rest (HTML-only and/or
110
+ // non-serializable values such as <Head> components). https://github.com/vikejs/vike-vue/issues/233
111
+ removeServerOnlyConfigFromHook(pageContext);
111
112
  return escapeInject`<!DOCTYPE html>
112
113
  <html${dangerouslySkipEscape(htmlAttributesString)}>
113
114
  <head>
@@ -120,6 +121,15 @@ const onRenderHtml = async pageContext => {
120
121
  </body>
121
122
  </html>`;
122
123
  };
124
+ function removeServerOnlyConfigFromHook(pageContext) {
125
+ const configFromHook = pageContext._configFromHook;
126
+ if (!configFromHook) return;
127
+ objectKeys(configFromHook).forEach(configName => {
128
+ if (!includes(configsClientSide, configName)) delete configFromHook[configName];
129
+ });
130
+ // Remove it altogether if there isn't anything left, saving KBs sent to the client
131
+ if (objectKeys(configFromHook).length === 0) delete pageContext._configFromHook;
132
+ }
123
133
  async function getPageHtml(pageContext) {
124
134
  let pageHtml = "";
125
135
  const userAgent = pageContext.headers?.["user-agent"] ||
@@ -0,0 +1,24 @@
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
+ // Settings the client-side applies upon navigation, see applyHeadSettings(). The others are HTML-only.
15
+ const configsClientSide = ["title", "lang"];
16
+
17
+ // https://stackoverflow.com/questions/52856496/typescript-object-keys-return-string
18
+ // https://github.com/sindresorhus/ts-extras/blob/main/source/object-keys.ts
19
+ /** Same as Object.keys() but with type inference */
20
+ function objectKeys(obj) {
21
+ return Object.keys(obj);
22
+ }
23
+
24
+ export { configsClientSide as a, configsCumulative as c, includes as i, objectKeys as o };
package/package.json CHANGED
@@ -1,6 +1,7 @@
1
1
  {
2
2
  "name": "vike-solid",
3
- "version": "0.8.2",
3
+ "version": "0.8.3",
4
+ "repository": "https://github.com/vikejs/vike-solid",
4
5
  "type": "module",
5
6
  "dependencies": {
6
7
  "isbot-fast": "^1.2.0"
@@ -11,23 +12,23 @@
11
12
  "vite-plugin-solid": "^2.11.10"
12
13
  },
13
14
  "devDependencies": {
14
- "@babel/core": "^7.29.0",
15
- "@babel/preset-env": "^7.29.2",
16
- "@babel/preset-typescript": "^7.28.5",
17
- "@brillout/release-me": "^0.4.13",
18
- "@rollup/plugin-babel": "^7.0.0",
15
+ "@babel/core": "^7.29.7",
16
+ "@babel/preset-env": "^7.29.7",
17
+ "@babel/preset-typescript": "^7.29.7",
18
+ "@brillout/release-me": "^0.4.15",
19
+ "@rollup/plugin-babel": "^7.1.0",
19
20
  "@rollup/plugin-node-resolve": "^16.0.3",
20
21
  "@types/node": "^22.19.7",
21
22
  "babel-preset-solid": "^1.9.12",
22
- "bumpp": "^11.0.1",
23
- "rollup": "^4.60.1",
23
+ "bumpp": "^11.1.0",
24
+ "rollup": "^4.62.2",
24
25
  "rollup-plugin-dts": "^6.4.1",
25
- "solid-js": "^1.9.12",
26
+ "solid-js": "^1.9.13",
26
27
  "tslib": "^2.8.1",
27
- "typescript": "^5.9.3",
28
- "vike": "^0.4.255",
29
- "vite": "^7.3.1",
30
- "vite-plugin-solid": "^2.11.11"
28
+ "typescript": "^6.0.3",
29
+ "vike": "^0.4.259",
30
+ "vite": "^8.0.16",
31
+ "vite-plugin-solid": "^2.11.12"
31
32
  },
32
33
  "exports": {
33
34
  "./config": "./dist/+config.js",
@@ -99,8 +100,11 @@
99
100
  "dist/",
100
101
  "client.d.ts"
101
102
  ],
102
- "repository": "github:vikejs/vike-solid",
103
103
  "license": "MIT",
104
+ "keywords": [
105
+ "solid",
106
+ "solidjs"
107
+ ],
104
108
  "scripts": {
105
109
  "dev": "rollup -c rollup.config.js --watch",
106
110
  "dev:typecheck": "tsc --noEmit --watch",