vike 0.4.199-commit-ed4f15e → 0.4.200-commit-a317fa3
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/cjs/node/client/router.js +3 -1
- package/dist/cjs/node/plugin/plugins/importBuild/index.js +4 -4
- package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/transpileAndExecuteFile.js +4 -0
- package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getVirtualFilePageConfigValuesAll.js +1 -1
- package/dist/cjs/node/runtime/globalContext/loadImportBuild.js +1 -1
- package/dist/cjs/utils/PROJECT_VERSION.js +1 -1
- package/dist/esm/client/client-routing-runtime/history.d.ts +14 -3
- package/dist/esm/client/client-routing-runtime/history.js +59 -40
- package/dist/esm/client/client-routing-runtime/index.d.ts +1 -0
- package/dist/esm/client/client-routing-runtime/index.js +1 -0
- package/dist/esm/client/client-routing-runtime/initOnPopState.d.ts +10 -2
- package/dist/esm/client/client-routing-runtime/initOnPopState.js +30 -24
- package/dist/esm/client/client-routing-runtime/renderPageClientSide.d.ts +1 -2
- package/dist/esm/client/client-routing-runtime/renderPageClientSide.js +2 -4
- package/dist/esm/node/client/router.d.ts +2 -0
- package/dist/esm/node/client/router.js +2 -0
- package/dist/esm/node/plugin/plugins/importBuild/index.js +5 -5
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/transpileAndExecuteFile.js +5 -1
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVirtualFilePageConfigValuesAll.js +1 -1
- package/dist/esm/node/runtime/globalContext/loadImportBuild.js +2 -2
- package/dist/esm/utils/PROJECT_VERSION.d.ts +1 -1
- package/dist/esm/utils/PROJECT_VERSION.js +1 -1
- package/dist/esm/utils/projectInfo.d.ts +1 -1
- package/package.json +2 -2
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.prefetch = exports.reload = exports.navigate = void 0;
|
|
3
|
+
exports.onPopState = exports.prefetch = exports.reload = exports.navigate = void 0;
|
|
4
4
|
const assert_js_1 = require("../../utils/assert.js");
|
|
5
5
|
// `never` to ensure package.json#exports["./client/router"].types points to type defined by the client-side code
|
|
6
6
|
const navigate = (() => warnNoEffect('navigate'));
|
|
@@ -9,6 +9,8 @@ const reload = (() => warnNoEffect('reload'));
|
|
|
9
9
|
exports.reload = reload;
|
|
10
10
|
const prefetch = (() => warnNoEffect('prefetch'));
|
|
11
11
|
exports.prefetch = prefetch;
|
|
12
|
+
const onPopState = (() => { });
|
|
13
|
+
exports.onPopState = onPopState;
|
|
12
14
|
function warnNoEffect(caller) {
|
|
13
15
|
(0, assert_js_1.assertWarning)(false, `Calling ${caller}() on the server-side has no effect`, {
|
|
14
16
|
showStackTrace: true,
|
|
@@ -29,15 +29,15 @@ function importBuild() {
|
|
|
29
29
|
configVike = await (0, getConfigVike_js_1.getConfigVike)(config);
|
|
30
30
|
}
|
|
31
31
|
},
|
|
32
|
-
...(0, plugin_1.
|
|
33
|
-
|
|
34
|
-
return
|
|
32
|
+
...(0, plugin_1.serverProductionEntryPlugin)({
|
|
33
|
+
getServerProductionEntry: () => {
|
|
34
|
+
return getServerProductionEntryCode(config, configVike);
|
|
35
35
|
},
|
|
36
36
|
libraryName: 'Vike'
|
|
37
37
|
})
|
|
38
38
|
];
|
|
39
39
|
}
|
|
40
|
-
function
|
|
40
|
+
function getServerProductionEntryCode(config, configVike) {
|
|
41
41
|
const importPath = getImportPath(config);
|
|
42
42
|
const vikeManifest = (0, getVikeManifest_js_1.getVikeManifest)(configVike);
|
|
43
43
|
const importerCode = [
|
|
@@ -19,6 +19,8 @@ require("source-map-support/register.js");
|
|
|
19
19
|
const getFilePath_js_1 = require("../../../../shared/getFilePath.js");
|
|
20
20
|
(0, utils_js_1.assertIsNotProductionRuntime)();
|
|
21
21
|
const debug = (0, utils_js_1.createDebugger)('vike:pointer-imports');
|
|
22
|
+
console.log('esbuild version', esbuild_1.version);
|
|
23
|
+
console.log('require.resolve("vike-react/config")', require.resolve('vike-react/config'));
|
|
22
24
|
async function transpileAndExecuteFile(filePath, userRootDir, isConfigFile) {
|
|
23
25
|
const { filePathAbsoluteFilesystem, filePathToShowToUserResolved } = filePath;
|
|
24
26
|
const fileExtension = getFileExtension(filePathAbsoluteFilesystem);
|
|
@@ -98,6 +100,7 @@ async function transpileWithEsbuild(filePath, userRootDir, transformImports) {
|
|
|
98
100
|
setup(build) {
|
|
99
101
|
// https://github.com/brillout/esbuild-playground
|
|
100
102
|
build.onResolve({ filter: /.*/ }, async (args) => {
|
|
103
|
+
console.log('onResolve()', args);
|
|
101
104
|
if (args.kind !== 'import-statement')
|
|
102
105
|
return;
|
|
103
106
|
// Avoid infinite loop: https://github.com/evanw/esbuild/issues/3095#issuecomment-1546916366
|
|
@@ -107,6 +110,7 @@ async function transpileWithEsbuild(filePath, userRootDir, transformImports) {
|
|
|
107
110
|
const { path, ...opts } = args;
|
|
108
111
|
opts.pluginData = { [useEsbuildResolver]: true };
|
|
109
112
|
const resolved = await build.resolve(path, opts);
|
|
113
|
+
console.log('resolved', resolved);
|
|
110
114
|
if (resolved.errors.length > 0) {
|
|
111
115
|
/* We could do the following to let Node.js throw the error, but we don't because the error shown by esbuild is prettier: the Node.js error refers to the transpiled [build-f7i251e0iwnw]+config.ts.mjs whereas esbuild refers to the source +config.ts file.
|
|
112
116
|
pointerImports[args.path] = false
|
package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getVirtualFilePageConfigValuesAll.js
CHANGED
|
@@ -23,7 +23,7 @@ async function getVirtualFilePageConfigValuesAll(id, isDev, config) {
|
|
|
23
23
|
const { pageId, isForClientSide } = result;
|
|
24
24
|
const { pageConfigs } = await (0, getVikeConfig_js_1.getVikeConfig)(config, isDev, { tolerateInvalidConfig: true });
|
|
25
25
|
const pageConfig = pageConfigs.find((pageConfig) => pageConfig.pageId === pageId);
|
|
26
|
-
(0, utils_js_1.assert)(pageConfig);
|
|
26
|
+
(0, utils_js_1.assert)(pageConfig, { id, pageId });
|
|
27
27
|
const configVike = await (0, getConfigVike_js_1.getConfigVike)(config);
|
|
28
28
|
const code = getLoadConfigValuesAll(pageConfig, isForClientSide, pageId, configVike.includeAssetsImportedByServer, isDev);
|
|
29
29
|
(0, debug_js_1.debug)(id, isForClientSide ? 'CLIENT-SIDE' : 'SERVER-SIDE', code);
|
|
@@ -12,7 +12,7 @@ function setImportBuildGetters(getters) {
|
|
|
12
12
|
}
|
|
13
13
|
async function loadImportBuild(outDir) {
|
|
14
14
|
if (!buildGetters.getters) {
|
|
15
|
-
await (0, runtime_1.
|
|
15
|
+
await (0, runtime_1.importServerProductionEntry)({ outDir });
|
|
16
16
|
(0, utils_js_1.assert)(buildGetters.getters);
|
|
17
17
|
}
|
|
18
18
|
const [pageFiles, assetsManifest, pluginManifest] = await Promise.all([
|
|
@@ -1,4 +1,8 @@
|
|
|
1
|
-
export {
|
|
1
|
+
export { pushHistoryState };
|
|
2
|
+
export { onPopStateBegin };
|
|
3
|
+
export { saveScrollPosition };
|
|
4
|
+
export type { HistoryInfo };
|
|
5
|
+
export type { ScrollPosition };
|
|
2
6
|
type StateEnhanced = {
|
|
3
7
|
timestamp: number;
|
|
4
8
|
scrollPosition: null | ScrollPosition;
|
|
@@ -9,7 +13,14 @@ type ScrollPosition = {
|
|
|
9
13
|
x: number;
|
|
10
14
|
y: number;
|
|
11
15
|
};
|
|
12
|
-
declare function enhanceHistoryState(): void;
|
|
13
|
-
declare function getHistoryState(): StateEnhanced;
|
|
14
16
|
declare function saveScrollPosition(): void;
|
|
15
17
|
declare function pushHistoryState(url: string, overwriteLastHistoryEntry: boolean): void;
|
|
18
|
+
type HistoryInfo = {
|
|
19
|
+
url: `/${string}`;
|
|
20
|
+
state: StateEnhanced;
|
|
21
|
+
};
|
|
22
|
+
declare function onPopStateBegin(): {
|
|
23
|
+
isNewState: boolean;
|
|
24
|
+
previous: HistoryInfo;
|
|
25
|
+
current: HistoryInfo;
|
|
26
|
+
};
|
|
@@ -1,7 +1,9 @@
|
|
|
1
|
-
export {
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
export { pushHistoryState };
|
|
2
|
+
export { onPopStateBegin };
|
|
3
|
+
export { saveScrollPosition };
|
|
4
|
+
import { assert, assertUsage, getCurrentUrl, getGlobalObject, hasProp, isObject } from './utils.js';
|
|
4
5
|
init();
|
|
6
|
+
const globalObject = getGlobalObject('history.ts', { previous: getHistoryInfo() });
|
|
5
7
|
// `window.history.state === null` when:
|
|
6
8
|
// - The very first render
|
|
7
9
|
// - Click on `<a href="#some-hash" />`
|
|
@@ -38,11 +40,13 @@ function enhance(stateNotEnhanced) {
|
|
|
38
40
|
assert(isVikeEnhanced(stateVikeEnhanced));
|
|
39
41
|
return stateVikeEnhanced;
|
|
40
42
|
}
|
|
41
|
-
function
|
|
43
|
+
function getState() {
|
|
42
44
|
const state = getStateNotEnhanced();
|
|
43
|
-
//
|
|
44
|
-
// -
|
|
45
|
-
// -
|
|
45
|
+
// *Every* state added to the history needs to go through Vike.
|
|
46
|
+
// - Otherwise Vike's `popstate` listener won't work. (Because, for example, if globalObject.previous is outdated => isHashNavigation faulty => client-side navigation is wrongfully skipped.)
|
|
47
|
+
// - Therefore, we have to monkey patch history.pushState() and history.replaceState()
|
|
48
|
+
// - Therefore, we need the assert() below to ensure history.state has been enhanced by Vike
|
|
49
|
+
// - If users stumble upon this assert() then let's make it a assertUsage()
|
|
46
50
|
assert(isVikeEnhanced(state));
|
|
47
51
|
return state;
|
|
48
52
|
}
|
|
@@ -50,11 +54,6 @@ function getStateNotEnhanced() {
|
|
|
50
54
|
const state = window.history.state;
|
|
51
55
|
return state;
|
|
52
56
|
}
|
|
53
|
-
function getHistoryState() {
|
|
54
|
-
if (!initStateEnhanced)
|
|
55
|
-
enhanceHistoryState(); // avoid race condition
|
|
56
|
-
return getStateEnhanced();
|
|
57
|
-
}
|
|
58
57
|
function getScrollPosition() {
|
|
59
58
|
const scrollPosition = { x: window.scrollX, y: window.scrollY };
|
|
60
59
|
return scrollPosition;
|
|
@@ -64,48 +63,54 @@ function getTimestamp() {
|
|
|
64
63
|
}
|
|
65
64
|
function saveScrollPosition() {
|
|
66
65
|
const scrollPosition = getScrollPosition();
|
|
67
|
-
const state =
|
|
66
|
+
const state = getState();
|
|
68
67
|
replaceHistoryState({ ...state, scrollPosition });
|
|
69
68
|
}
|
|
70
69
|
function pushHistoryState(url, overwriteLastHistoryEntry) {
|
|
71
70
|
if (!overwriteLastHistoryEntry) {
|
|
72
|
-
const
|
|
73
|
-
|
|
74
|
-
timestamp,
|
|
71
|
+
const state = {
|
|
72
|
+
timestamp: getTimestamp(),
|
|
75
73
|
// I don't remember why I set it to `null`, maybe because setting it now would be too early? (Maybe there is a delay between renderPageClientSide() is finished and the browser updating the scroll position.) Anyways, it seems like autoSaveScrollPosition() is enough.
|
|
76
74
|
scrollPosition: null,
|
|
77
75
|
triggeredBy: 'vike',
|
|
78
76
|
_isVikeEnhanced: true
|
|
79
|
-
}
|
|
77
|
+
};
|
|
78
|
+
// Calling the monkey patched history.pushState() (and not the orignal) so that other tools (e.g. user tracking) can listen to Vike's pushState() calls.
|
|
79
|
+
// - https://github.com/vikejs/vike/issues/1582
|
|
80
|
+
window.history.pushState(state, '', url);
|
|
80
81
|
}
|
|
81
82
|
else {
|
|
82
|
-
replaceHistoryState(
|
|
83
|
+
replaceHistoryState(getState(), url);
|
|
83
84
|
}
|
|
84
85
|
}
|
|
85
86
|
function replaceHistoryState(state, url) {
|
|
86
87
|
const url_ = url ?? null; // Passing `undefined` chokes older Edge versions.
|
|
87
88
|
window.history.replaceState(state, '', url_);
|
|
88
89
|
}
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
90
|
+
// Monkey patch:
|
|
91
|
+
// - history.pushState()
|
|
92
|
+
// - history.replaceState()
|
|
93
|
+
function monkeyPatchHistoryAPI() {
|
|
94
|
+
;
|
|
95
|
+
['pushState', 'replaceState'].forEach((funcName) => {
|
|
96
|
+
const funcOriginal = window.history[funcName].bind(window.history);
|
|
97
|
+
window.history[funcName] = (stateOriginal = {}, ...rest) => {
|
|
98
|
+
assertUsage(stateOriginal === undefined || stateOriginal === null || isObject(stateOriginal), `history.${funcName}(state) argument state must be an object`);
|
|
99
|
+
const stateEnhanced = isVikeEnhanced(stateOriginal)
|
|
100
|
+
? stateOriginal
|
|
101
|
+
: {
|
|
102
|
+
_isVikeEnhanced: true,
|
|
103
|
+
scrollPosition: getScrollPosition(),
|
|
104
|
+
timestamp: getTimestamp(),
|
|
105
|
+
triggeredBy: 'user',
|
|
106
|
+
...stateOriginal
|
|
107
|
+
};
|
|
108
|
+
assert(isVikeEnhanced(stateEnhanced));
|
|
109
|
+
const ret = funcOriginal(stateEnhanced, ...rest);
|
|
110
|
+
globalObject.previous = getHistoryInfo();
|
|
111
|
+
return ret;
|
|
112
|
+
};
|
|
113
|
+
});
|
|
109
114
|
}
|
|
110
115
|
function isVikeEnhanced(state) {
|
|
111
116
|
const yes = isObject(state) && '_isVikeEnhanced' in state;
|
|
@@ -126,6 +131,20 @@ function assertStateVikeEnhanced(state) {
|
|
|
126
131
|
}
|
|
127
132
|
function init() {
|
|
128
133
|
enhanceHistoryState();
|
|
129
|
-
|
|
130
|
-
|
|
134
|
+
monkeyPatchHistoryAPI();
|
|
135
|
+
}
|
|
136
|
+
function getHistoryInfo() {
|
|
137
|
+
return {
|
|
138
|
+
url: getCurrentUrl(),
|
|
139
|
+
state: getState()
|
|
140
|
+
};
|
|
141
|
+
}
|
|
142
|
+
function onPopStateBegin() {
|
|
143
|
+
const { previous } = globalObject;
|
|
144
|
+
const isNewState = window.history.state === null;
|
|
145
|
+
if (isNewState)
|
|
146
|
+
enhanceHistoryState();
|
|
147
|
+
const current = getHistoryInfo();
|
|
148
|
+
globalObject.previous = current;
|
|
149
|
+
return { isNewState, previous, current };
|
|
131
150
|
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
export { navigate, reload } from './navigate.js';
|
|
2
2
|
export { prefetch } from './prefetch.js';
|
|
3
|
+
export { onPopState } from './initOnPopState.js';
|
|
3
4
|
export { PROJECT_VERSION as version } from './utils.js';
|
|
4
5
|
import type { PageContextBuiltInClientWithClientRouting } from '../../shared/types.js';
|
|
5
6
|
/** @deprecated
|
|
@@ -1,4 +1,12 @@
|
|
|
1
1
|
export { initOnPopState };
|
|
2
|
-
export {
|
|
2
|
+
export { onPopState };
|
|
3
|
+
import { type HistoryInfo } from './history.js';
|
|
3
4
|
declare function initOnPopState(): void;
|
|
4
|
-
|
|
5
|
+
type Listener = (arg: {
|
|
6
|
+
previous: HistoryInfo;
|
|
7
|
+
}) => void | boolean;
|
|
8
|
+
/** Control back-/forward navigation.
|
|
9
|
+
*
|
|
10
|
+
* https://vike.dev/onPopState
|
|
11
|
+
*/
|
|
12
|
+
declare function onPopState(listener: Listener): void;
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
export { initOnPopState };
|
|
2
|
-
export {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
2
|
+
export { onPopState };
|
|
3
|
+
import { assertWarning, getGlobalObject } from './utils.js';
|
|
4
|
+
import { onPopStateBegin } from './history.js';
|
|
5
5
|
import { renderPageClientSide } from './renderPageClientSide.js';
|
|
6
6
|
import { setScrollPosition } from './setScrollPosition.js';
|
|
7
|
-
const globalObject = getGlobalObject('initOnPopState.ts', {
|
|
7
|
+
const globalObject = getGlobalObject('initOnPopState.ts', { listeners: [] });
|
|
8
8
|
function initOnPopState() {
|
|
9
9
|
// - The popstate event is trigged upon:
|
|
10
10
|
// - Back-/forward navigation.
|
|
@@ -16,19 +16,14 @@ function initOnPopState() {
|
|
|
16
16
|
// - `location.hash = 'some-hash'`
|
|
17
17
|
// - The `event` argument of `window.addEventListener('popstate', (event) => /*...*/)` is useless: the History API doesn't provide the previous state (the popped state), see https://stackoverflow.com/questions/48055323/is-history-state-always-the-same-as-popstate-event-state
|
|
18
18
|
window.addEventListener('popstate', async () => {
|
|
19
|
-
const isNewState
|
|
20
|
-
if (isNewState)
|
|
21
|
-
enhanceHistoryState();
|
|
22
|
-
const { previous } = globalObject;
|
|
23
|
-
const current = getInfo();
|
|
24
|
-
globalObject.previous = current;
|
|
19
|
+
const { isNewState, previous, current } = onPopStateBegin();
|
|
25
20
|
const scrollTarget = current.state.scrollPosition || undefined;
|
|
26
|
-
const
|
|
27
|
-
const isHashNavigation = removeHash(current.url) === removeHash(previous.url);
|
|
28
|
-
// - `
|
|
21
|
+
const isUserPushStateNavigation = current.state.triggeredBy === 'user' || previous.state.triggeredBy === 'user';
|
|
22
|
+
const isHashNavigation = removeHash(current.url) === removeHash(previous.url) && current.url !== previous.url;
|
|
23
|
+
// - `isNewState === true` when:
|
|
29
24
|
// - Click on `<a href="#some-hash" />` (note that Vike's `initOnLinkClick()` handler skips hash links)
|
|
30
25
|
// - `location.hash = 'some-hash'`
|
|
31
|
-
// - `
|
|
26
|
+
// - `isNewState === false` when `popstate` was triggered by the user clicking on his browser's forward/backward history button.
|
|
32
27
|
const isHashNavigationNew = isHashNavigation && isNewState;
|
|
33
28
|
const isBackwardNavigation = !current.state.timestamp || !previous.state.timestamp ? null : current.state.timestamp < previous.state.timestamp;
|
|
34
29
|
// We have to scroll ourselves because we use `window.history.scrollRestoration = 'manual'`. So far this seems to work. Alternatives in case it doesn't work:
|
|
@@ -40,7 +35,7 @@ function initOnPopState() {
|
|
|
40
35
|
// - Alternative: we completely take over hash navigation and reproduce the browser's native behavior upon hash navigation.
|
|
41
36
|
// - By using the `hashchange` event.
|
|
42
37
|
// - Problem: conflict if user wants to override the browser's default behavior? E.g. for smooth scrolling, or when using hashes for saving states of some fancy animations.
|
|
43
|
-
if (isHashNavigation
|
|
38
|
+
if (isHashNavigation) {
|
|
44
39
|
if (!isHashNavigationNew) {
|
|
45
40
|
setScrollPosition(scrollTarget);
|
|
46
41
|
}
|
|
@@ -49,18 +44,29 @@ function initOnPopState() {
|
|
|
49
44
|
}
|
|
50
45
|
return;
|
|
51
46
|
}
|
|
52
|
-
|
|
47
|
+
let doNotRenderIfSamePage = isUserPushStateNavigation;
|
|
48
|
+
let abort;
|
|
49
|
+
globalObject.listeners.forEach((listener) => {
|
|
50
|
+
abort || (abort = listener({ previous }));
|
|
51
|
+
});
|
|
52
|
+
if (abort) {
|
|
53
|
+
return;
|
|
54
|
+
}
|
|
55
|
+
if (abort === false) {
|
|
56
|
+
doNotRenderIfSamePage = false;
|
|
57
|
+
}
|
|
58
|
+
await renderPageClientSide({ scrollTarget, isBackwardNavigation, doNotRenderIfSamePage });
|
|
53
59
|
});
|
|
54
60
|
}
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
61
|
+
// TODO/eventually: deprecate this onPopState(listener) function and let the user define +onPopState.js instead?
|
|
62
|
+
/** Control back-/forward navigation.
|
|
63
|
+
*
|
|
64
|
+
* https://vike.dev/onPopState
|
|
65
|
+
*/
|
|
66
|
+
function onPopState(listener) {
|
|
67
|
+
assertWarning(false, 'onPopState() is experimental', { onlyOnce: true });
|
|
68
|
+
globalObject.listeners.push(listener);
|
|
60
69
|
}
|
|
61
70
|
function removeHash(url) {
|
|
62
71
|
return url.split('#')[0];
|
|
63
72
|
}
|
|
64
|
-
function updateState() {
|
|
65
|
-
globalObject.previous = getInfo();
|
|
66
|
-
}
|
|
@@ -12,8 +12,7 @@ type RenderArgs = {
|
|
|
12
12
|
overwriteLastHistoryEntry?: boolean;
|
|
13
13
|
pageContextsFromRewrite?: PageContextFromRewrite[];
|
|
14
14
|
redirectCount?: number;
|
|
15
|
-
|
|
16
|
-
isUserLandPushStateNavigation?: boolean;
|
|
15
|
+
doNotRenderIfSamePage?: boolean;
|
|
17
16
|
isClientSideNavigation?: boolean;
|
|
18
17
|
};
|
|
19
18
|
declare function renderPageClientSide(renderArgs: RenderArgs): Promise<void>;
|
|
@@ -15,7 +15,6 @@ import { assertNoInfiniteAbortLoop, getPageContextFromAllRewrites, isAbortError,
|
|
|
15
15
|
import { route } from '../../shared/route/index.js';
|
|
16
16
|
import { isClientSideRoutable } from './isClientSideRoutable.js';
|
|
17
17
|
import { setScrollPosition } from './setScrollPosition.js';
|
|
18
|
-
import { updateState } from './initOnPopState.js';
|
|
19
18
|
import { browserNativeScrollRestoration_disable, setInitialRenderIsDone } from './scrollRestoration.js';
|
|
20
19
|
import { getErrorPageId } from '../../shared/error-page.js';
|
|
21
20
|
import { setPageContextCurrent } from './getPageContextCurrent.js';
|
|
@@ -30,7 +29,7 @@ const globalObject = getGlobalObject('renderPageClientSide.ts', (() => {
|
|
|
30
29
|
})());
|
|
31
30
|
const { firstRenderStartPromise } = globalObject;
|
|
32
31
|
async function renderPageClientSide(renderArgs) {
|
|
33
|
-
const { urlOriginal = getCurrentUrl(), overwriteLastHistoryEntry = false, isBackwardNavigation, pageContextsFromRewrite = [], redirectCount = 0,
|
|
32
|
+
const { urlOriginal = getCurrentUrl(), overwriteLastHistoryEntry = false, isBackwardNavigation, pageContextsFromRewrite = [], redirectCount = 0, doNotRenderIfSamePage, isClientSideNavigation = true } = renderArgs;
|
|
34
33
|
let { scrollTarget } = renderArgs;
|
|
35
34
|
const { previousPageContext } = globalObject;
|
|
36
35
|
addLinkPrefetchHandlers_unwatch();
|
|
@@ -120,7 +119,7 @@ async function renderPageClientSide(renderArgs) {
|
|
|
120
119
|
const isSamePage = pageContextFromRoute.pageId &&
|
|
121
120
|
previousPageContext?.pageId &&
|
|
122
121
|
pageContextFromRoute.pageId === previousPageContext.pageId;
|
|
123
|
-
if (
|
|
122
|
+
if (doNotRenderIfSamePage && isSamePage) {
|
|
124
123
|
// Skip's Vike's rendering; let the user handle the navigation
|
|
125
124
|
return;
|
|
126
125
|
}
|
|
@@ -477,7 +476,6 @@ function changeUrl(url, overwriteLastHistoryEntry) {
|
|
|
477
476
|
return;
|
|
478
477
|
browserNativeScrollRestoration_disable();
|
|
479
478
|
pushHistoryState(url, overwriteLastHistoryEntry);
|
|
480
|
-
updateState();
|
|
481
479
|
}
|
|
482
480
|
function handleErrorFetchingStaticAssets(err, pageContext, isFirstRender) {
|
|
483
481
|
if (!isErrorFetchingStaticAssets(err)) {
|
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
export { navigate };
|
|
2
2
|
export { reload };
|
|
3
3
|
export { prefetch };
|
|
4
|
+
export { onPopState };
|
|
4
5
|
import { assertWarning } from '../../utils/assert.js';
|
|
5
6
|
// `never` to ensure package.json#exports["./client/router"].types points to type defined by the client-side code
|
|
6
7
|
const navigate = (() => warnNoEffect('navigate'));
|
|
7
8
|
const reload = (() => warnNoEffect('reload'));
|
|
8
9
|
const prefetch = (() => warnNoEffect('prefetch'));
|
|
10
|
+
const onPopState = (() => { });
|
|
9
11
|
function warnNoEffect(caller) {
|
|
10
12
|
assertWarning(false, `Calling ${caller}() on the server-side has no effect`, {
|
|
11
13
|
showStackTrace: true,
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export { importBuild };
|
|
2
2
|
export { set_ASSETS_MAP };
|
|
3
|
-
import {
|
|
3
|
+
import { serverProductionEntryPlugin } from '@brillout/vite-plugin-server-entry/plugin';
|
|
4
4
|
import { assert, getOutDirs, toPosixPath } from '../../utils.js';
|
|
5
5
|
import path from 'path';
|
|
6
6
|
import { createRequire } from 'module';
|
|
@@ -24,15 +24,15 @@ function importBuild() {
|
|
|
24
24
|
configVike = await getConfigVike(config);
|
|
25
25
|
}
|
|
26
26
|
},
|
|
27
|
-
...
|
|
28
|
-
|
|
29
|
-
return
|
|
27
|
+
...serverProductionEntryPlugin({
|
|
28
|
+
getServerProductionEntry: () => {
|
|
29
|
+
return getServerProductionEntryCode(config, configVike);
|
|
30
30
|
},
|
|
31
31
|
libraryName: 'Vike'
|
|
32
32
|
})
|
|
33
33
|
];
|
|
34
34
|
}
|
|
35
|
-
function
|
|
35
|
+
function getServerProductionEntryCode(config, configVike) {
|
|
36
36
|
const importPath = getImportPath(config);
|
|
37
37
|
const vikeManifest = getVikeManifest(configVike);
|
|
38
38
|
const importerCode = [
|
|
@@ -2,7 +2,7 @@ export { transpileAndExecuteFile };
|
|
|
2
2
|
export { getConfigBuildErrorFormatted };
|
|
3
3
|
export { getConfigExecutionErrorIntroMsg };
|
|
4
4
|
export { isTemporaryBuildFile };
|
|
5
|
-
import { build, formatMessages } from 'esbuild';
|
|
5
|
+
import { build, formatMessages, version } from 'esbuild';
|
|
6
6
|
import fs from 'fs';
|
|
7
7
|
import path from 'path';
|
|
8
8
|
import pc from '@brillout/picocolors';
|
|
@@ -14,6 +14,8 @@ import 'source-map-support/register.js';
|
|
|
14
14
|
import { getFilePathAbsoluteUserRootDir } from '../../../../shared/getFilePath.js';
|
|
15
15
|
assertIsNotProductionRuntime();
|
|
16
16
|
const debug = createDebugger('vike:pointer-imports');
|
|
17
|
+
console.log('esbuild version', version);
|
|
18
|
+
console.log('require.resolve("vike-react/config")', require.resolve('vike-react/config'));
|
|
17
19
|
async function transpileAndExecuteFile(filePath, userRootDir, isConfigFile) {
|
|
18
20
|
const { filePathAbsoluteFilesystem, filePathToShowToUserResolved } = filePath;
|
|
19
21
|
const fileExtension = getFileExtension(filePathAbsoluteFilesystem);
|
|
@@ -93,6 +95,7 @@ async function transpileWithEsbuild(filePath, userRootDir, transformImports) {
|
|
|
93
95
|
setup(build) {
|
|
94
96
|
// https://github.com/brillout/esbuild-playground
|
|
95
97
|
build.onResolve({ filter: /.*/ }, async (args) => {
|
|
98
|
+
console.log('onResolve()', args);
|
|
96
99
|
if (args.kind !== 'import-statement')
|
|
97
100
|
return;
|
|
98
101
|
// Avoid infinite loop: https://github.com/evanw/esbuild/issues/3095#issuecomment-1546916366
|
|
@@ -102,6 +105,7 @@ async function transpileWithEsbuild(filePath, userRootDir, transformImports) {
|
|
|
102
105
|
const { path, ...opts } = args;
|
|
103
106
|
opts.pluginData = { [useEsbuildResolver]: true };
|
|
104
107
|
const resolved = await build.resolve(path, opts);
|
|
108
|
+
console.log('resolved', resolved);
|
|
105
109
|
if (resolved.errors.length > 0) {
|
|
106
110
|
/* We could do the following to let Node.js throw the error, but we don't because the error shown by esbuild is prettier: the Node.js error refers to the transpiled [build-f7i251e0iwnw]+config.ts.mjs whereas esbuild refers to the source +config.ts file.
|
|
107
111
|
pointerImports[args.path] = false
|
package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVirtualFilePageConfigValuesAll.js
CHANGED
|
@@ -21,7 +21,7 @@ async function getVirtualFilePageConfigValuesAll(id, isDev, config) {
|
|
|
21
21
|
const { pageId, isForClientSide } = result;
|
|
22
22
|
const { pageConfigs } = await getVikeConfig(config, isDev, { tolerateInvalidConfig: true });
|
|
23
23
|
const pageConfig = pageConfigs.find((pageConfig) => pageConfig.pageId === pageId);
|
|
24
|
-
assert(pageConfig);
|
|
24
|
+
assert(pageConfig, { id, pageId });
|
|
25
25
|
const configVike = await getConfigVike(config);
|
|
26
26
|
const code = getLoadConfigValuesAll(pageConfig, isForClientSide, pageId, configVike.includeAssetsImportedByServer, isDev);
|
|
27
27
|
debug(id, isForClientSide ? 'CLIENT-SIDE' : 'SERVER-SIDE', code);
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export { loadImportBuild };
|
|
2
2
|
export { setImportBuildGetters };
|
|
3
|
-
import {
|
|
3
|
+
import { importServerProductionEntry } from '@brillout/vite-plugin-server-entry/runtime';
|
|
4
4
|
import { assert } from '../utils.js';
|
|
5
5
|
const buildGetters = (globalThis.__vike_buildGetters = globalThis.__vike_buildGetters || {
|
|
6
6
|
getters: null
|
|
@@ -10,7 +10,7 @@ function setImportBuildGetters(getters) {
|
|
|
10
10
|
}
|
|
11
11
|
async function loadImportBuild(outDir) {
|
|
12
12
|
if (!buildGetters.getters) {
|
|
13
|
-
await
|
|
13
|
+
await importServerProductionEntry({ outDir });
|
|
14
14
|
assert(buildGetters.getters);
|
|
15
15
|
}
|
|
16
16
|
const [pageFiles, assetsManifest, pluginManifest] = await Promise.all([
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const PROJECT_VERSION: "0.4.
|
|
1
|
+
export declare const PROJECT_VERSION: "0.4.200-commit-a317fa3";
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// Automatically updated by @brillout/release-me
|
|
2
|
-
export const PROJECT_VERSION = '0.4.
|
|
2
|
+
export const PROJECT_VERSION = '0.4.200-commit-a317fa3';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "vike",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.200-commit-a317fa3",
|
|
4
4
|
"repository": "https://github.com/vikejs/vike",
|
|
5
5
|
"exports": {
|
|
6
6
|
"./server": {
|
|
@@ -125,7 +125,7 @@
|
|
|
125
125
|
"@brillout/json-serializer": "^0.5.13",
|
|
126
126
|
"@brillout/picocolors": "^1.0.15",
|
|
127
127
|
"@brillout/require-shim": "^0.1.2",
|
|
128
|
-
"@brillout/vite-plugin-server-entry": "^0.
|
|
128
|
+
"@brillout/vite-plugin-server-entry": "^0.5.0",
|
|
129
129
|
"acorn": "^8.0.0",
|
|
130
130
|
"cac": "^6.0.0",
|
|
131
131
|
"es-module-lexer": "^1.0.0",
|