vike-react 0.6.23 → 0.6.25
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,5 +1,6 @@
|
|
|
1
|
-
<!-- WARNING: keep links absolute in this file so they work on NPM too -->
|
|
1
|
+
<!-- WARNING: keep links absolute in this file so they work on NPM too: https://www.npmjs.com/package/vike-react -->
|
|
2
2
|
|
|
3
3
|
[](https://www.npmjs.com/package/vike-react)
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
Docs: see [vike.dev/vike-react](https://vike.dev/vike-react)
|
|
6
|
+
Source code: [GitHub > vikejs/vike-react](https://github.com/vikejs/vike-react)
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const configsClientSide: readonly ["title", "lang"];
|
|
@@ -6,6 +6,7 @@ import { objectKeys } from '../../utils/objectKeys.js';
|
|
|
6
6
|
import { includes } from '../../utils/includes.js';
|
|
7
7
|
import { assert } from '../../utils/assert.js';
|
|
8
8
|
import { configsCumulative } from './configsCumulative.js';
|
|
9
|
+
import { configsClientSide } from './configsClientSide.js';
|
|
9
10
|
/**
|
|
10
11
|
* Set configurations inside components and Vike hooks.
|
|
11
12
|
*
|
|
@@ -31,13 +32,12 @@ function useConfig() {
|
|
|
31
32
|
}
|
|
32
33
|
};
|
|
33
34
|
}
|
|
34
|
-
const configsClientSide = ['title'];
|
|
35
35
|
function setPageContextConfigViaHook(config, pageContext) {
|
|
36
36
|
pageContext._configViaHook ?? (pageContext._configViaHook = {});
|
|
37
37
|
objectKeys(config).forEach((configName) => {
|
|
38
38
|
var _a;
|
|
39
39
|
// Skip HTML only configs which the client-side doesn't need, saving KBs sent to the client as well as avoiding serialization errors.
|
|
40
|
-
if (pageContext.isClientSideNavigation && !
|
|
40
|
+
if (pageContext.isClientSideNavigation && !includes(configsClientSide, configName))
|
|
41
41
|
return;
|
|
42
42
|
if (!includes(configsCumulative, configName)) {
|
|
43
43
|
// Overridable config
|
|
@@ -7,6 +7,9 @@ import { dangerouslySkipEscape, escapeInject } from 'vike/server';
|
|
|
7
7
|
import { VikeReactProviderPageContext } from '../hooks/usePageContext.js';
|
|
8
8
|
import { getHeadSetting } from './getHeadSetting.js';
|
|
9
9
|
import { getPageElement } from './getPageElement.js';
|
|
10
|
+
import { configsClientSide } from '../hooks/useConfig/configsClientSide.js';
|
|
11
|
+
import { objectKeys } from '../utils/objectKeys.js';
|
|
12
|
+
import { includes } from '../utils/includes.js';
|
|
10
13
|
import { isReactElement } from '../utils/isReactElement.js';
|
|
11
14
|
import { getTagAttributesString } from '../utils/getTagAttributesString.js';
|
|
12
15
|
import { assert } from '../utils/assert.js';
|
|
@@ -21,8 +24,9 @@ async function onRenderHtml(pageContext) {
|
|
|
21
24
|
const headHtml = getHeadHtml(pageContext);
|
|
22
25
|
const { headHtmlBegin, headHtmlEnd, bodyHtmlBegin, bodyHtmlEnd } = await getHtmlInjections(pageContext);
|
|
23
26
|
const { htmlAttributesString, bodyAttributesString } = getTagAttributes(pageContext);
|
|
24
|
-
//
|
|
25
|
-
|
|
27
|
+
// Keep only what the client-side applies upon navigation, and remove the rest (HTML-only and/or
|
|
28
|
+
// non-serializable values such as <Head> components). https://github.com/vikejs/vike-vue/issues/233
|
|
29
|
+
removeServerOnlyConfigViaHook(pageContext);
|
|
26
30
|
// pageContext.{pageHtmlString,pageHtmlStream} is set by renderPageToHtml() and can be overridden by user at onAfterRenderHtml()
|
|
27
31
|
let pageHtmlStringOrStream =
|
|
28
32
|
// Set to empty string if SSR is disabled
|
|
@@ -70,6 +74,18 @@ async function renderPageToHtml(pageContext) {
|
|
|
70
74
|
// https://github.com/vikejs/vike/discussions/1804#discussioncomment-10394481
|
|
71
75
|
await callCumulativeHooks(pageContext.config.onAfterRenderHtml, pageContext);
|
|
72
76
|
}
|
|
77
|
+
function removeServerOnlyConfigViaHook(pageContext) {
|
|
78
|
+
const configViaHook = pageContext._configViaHook;
|
|
79
|
+
if (!configViaHook)
|
|
80
|
+
return;
|
|
81
|
+
objectKeys(configViaHook).forEach((configName) => {
|
|
82
|
+
if (!includes(configsClientSide, configName))
|
|
83
|
+
delete configViaHook[configName];
|
|
84
|
+
});
|
|
85
|
+
// Remove it altogether if there isn't anything left, saving KBs sent to the client
|
|
86
|
+
if (objectKeys(configViaHook).length === 0)
|
|
87
|
+
delete pageContext._configViaHook;
|
|
88
|
+
}
|
|
73
89
|
function getHeadHtml(pageContext) {
|
|
74
90
|
pageContext._headAlreadySet = true;
|
|
75
91
|
const favicon = getHeadSetting('favicon', pageContext);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "vike-react",
|
|
3
|
-
"version": "0.6.
|
|
3
|
+
"version": "0.6.25",
|
|
4
4
|
"repository": "https://github.com/vikejs/vike-react",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"exports": {
|
|
@@ -31,7 +31,7 @@
|
|
|
31
31
|
"./__internal/integration/Loading": "./dist/integration/Loading.js"
|
|
32
32
|
},
|
|
33
33
|
"dependencies": {
|
|
34
|
-
"react-streaming": "^0.4.
|
|
34
|
+
"react-streaming": "^0.4.19"
|
|
35
35
|
},
|
|
36
36
|
"peerDependencies": {
|
|
37
37
|
"react": ">=19",
|