vike 0.4.197-commit-9330153 → 0.4.197-commit-1251ed9
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/plugin/plugins/importUserCode/v1-design/getVikeConfig.js +16 -7
- package/dist/cjs/utils/PROJECT_VERSION.js +1 -1
- package/dist/cjs/utils/parseUrl.js +2 -10
- package/dist/esm/client/client-routing-runtime/navigate.js +3 -2
- package/dist/esm/client/client-routing-runtime/normalizeUrlArgument.d.ts +2 -0
- package/dist/esm/client/client-routing-runtime/normalizeUrlArgument.js +14 -0
- package/dist/esm/client/client-routing-runtime/prefetch.js +7 -5
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig.js +16 -7
- package/dist/esm/utils/PROJECT_VERSION.d.ts +1 -1
- package/dist/esm/utils/PROJECT_VERSION.js +1 -1
- package/dist/esm/utils/parseUrl.d.ts +2 -2
- package/dist/esm/utils/parseUrl.js +2 -10
- package/dist/esm/utils/projectInfo.d.ts +1 -1
- package/package.json +1 -1
|
@@ -838,6 +838,9 @@ function assertNoUnexpectedPlusSign(filePath: string, fileName: string) {
|
|
|
838
838
|
}
|
|
839
839
|
*/
|
|
840
840
|
function handleUnknownConfig(configName, configNames, filePathToShowToUser) {
|
|
841
|
+
const configNameColored = picocolors_1.default.cyan(configName);
|
|
842
|
+
let errMsg = `${filePathToShowToUser} sets an unknown config ${configNameColored}.`;
|
|
843
|
+
// vike-{react,vue,solid} hint
|
|
841
844
|
{
|
|
842
845
|
const ui = ['vike-react', 'vike-vue', 'vike-solid'];
|
|
843
846
|
const knownVikeExntensionConfigs = {
|
|
@@ -854,14 +857,16 @@ function handleUnknownConfig(configName, configNames, filePathToShowToUser) {
|
|
|
854
857
|
if (configName in knownVikeExntensionConfigs) {
|
|
855
858
|
const requiredVikeExtension = knownVikeExntensionConfigs[configName];
|
|
856
859
|
(0, utils_js_1.assertUsage)(false, [
|
|
857
|
-
|
|
858
|
-
`
|
|
859
|
-
|
|
860
|
-
|
|
860
|
+
errMsg,
|
|
861
|
+
`If you want to use the configuration documented at https://vike.dev/${configName} then make sure to install the Vike extension ${requiredVikeExtension
|
|
862
|
+
.map((e) => picocolors_1.default.bold(e))
|
|
863
|
+
.join('/')}.`,
|
|
864
|
+
`Also make sure it applies to ${filePathToShowToUser} (see https://vike.dev/extends#inheritance).`,
|
|
865
|
+
`Alternatively, if you don't want to use the aforementioned Vike extension, define it yourself by using ${picocolors_1.default.cyan('meta')} (https://vike.dev/meta).`
|
|
861
866
|
].join(' '));
|
|
862
867
|
}
|
|
863
868
|
}
|
|
864
|
-
|
|
869
|
+
// Similarity hint
|
|
865
870
|
let configNameSimilar = null;
|
|
866
871
|
if (configName === 'page') {
|
|
867
872
|
configNameSimilar = 'Page';
|
|
@@ -871,11 +876,15 @@ function handleUnknownConfig(configName, configNames, filePathToShowToUser) {
|
|
|
871
876
|
}
|
|
872
877
|
if (configNameSimilar) {
|
|
873
878
|
(0, utils_js_1.assert)(configNameSimilar !== configName);
|
|
874
|
-
errMsg +=
|
|
879
|
+
errMsg += ` Did you mean to set ${picocolors_1.default.cyan(configNameSimilar)} instead?`;
|
|
875
880
|
if (configName === 'page') {
|
|
876
|
-
errMsg += ` (The name of the config ${picocolors_1.default.cyan('Page')} starts with a capital letter ${picocolors_1.default.cyan('P')} because it
|
|
881
|
+
errMsg += ` (The name of the config ${picocolors_1.default.cyan('Page')} starts with a capital letter ${picocolors_1.default.cyan('P')} because it defines a UI component: a ubiquitous JavaScript convention is that the name of UI components start with a capital letter.)`;
|
|
877
882
|
}
|
|
878
883
|
}
|
|
884
|
+
// `meta` hint
|
|
885
|
+
if (!configNameSimilar) {
|
|
886
|
+
errMsg += ` Make sure to define ${configNameColored} by using ${picocolors_1.default.cyan('meta')} (https://vike.dev/meta), and also make sure the meta configuration applies to ${filePathToShowToUser} (see https://vike.dev/config#inheritance).`;
|
|
887
|
+
}
|
|
879
888
|
(0, utils_js_1.assertUsage)(false, errMsg);
|
|
880
889
|
}
|
|
881
890
|
function determineRouteFilesystem(locationId, configValueSources) {
|
|
@@ -7,12 +7,12 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
7
7
|
};
|
|
8
8
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
9
|
exports.parseUrl = parseUrl;
|
|
10
|
-
exports.assertUsageUrlPathname = assertUsageUrlPathname;
|
|
11
10
|
exports.assertUsageUrlPathnameAbsolute = assertUsageUrlPathnameAbsolute;
|
|
12
11
|
exports.assertUsageUrlRedirectTarget = assertUsageUrlRedirectTarget;
|
|
13
12
|
exports.isUrl = isUrl;
|
|
14
13
|
exports.isUri = isUri;
|
|
15
14
|
exports.isUrlRedirectTarget = isUrlRedirectTarget;
|
|
15
|
+
exports.isUrlPathnameRelative = isUrlPathnameRelative;
|
|
16
16
|
exports.isUrlExternal = isUrlExternal;
|
|
17
17
|
exports.isBaseServer = isBaseServer;
|
|
18
18
|
exports.assertUrlComponents = assertUrlComponents;
|
|
@@ -297,16 +297,13 @@ function isUri(uri) {
|
|
|
297
297
|
const { protocol } = parseProtocol(uri);
|
|
298
298
|
return !!protocol && !isUrlProtocol(uri);
|
|
299
299
|
}
|
|
300
|
-
function assertUsageUrlPathname(url, errPrefix) {
|
|
301
|
-
assertUsageUrl(url, errPrefix, { allowRelative: true });
|
|
302
|
-
}
|
|
303
300
|
function assertUsageUrlPathnameAbsolute(url, errPrefix) {
|
|
304
301
|
assertUsageUrl(url, errPrefix);
|
|
305
302
|
}
|
|
306
303
|
function assertUsageUrlRedirectTarget(url, errPrefix, isUnresolved) {
|
|
307
304
|
assertUsageUrl(url, errPrefix, { isRedirectTarget: isUnresolved ? 'unresolved' : true });
|
|
308
305
|
}
|
|
309
|
-
function assertUsageUrl(url, errPrefix, {
|
|
306
|
+
function assertUsageUrl(url, errPrefix, { isRedirectTarget } = {}) {
|
|
310
307
|
if (url.startsWith('/'))
|
|
311
308
|
return;
|
|
312
309
|
let errMsg = `${errPrefix} is ${picocolors_1.default.string(url)} but it should start with ${picocolors_1.default.string('/')}`;
|
|
@@ -320,10 +317,5 @@ function assertUsageUrl(url, errPrefix, { allowRelative, isRedirectTarget } = {}
|
|
|
320
317
|
errMsg += `, or be ${picocolors_1.default.string('*')}`;
|
|
321
318
|
}
|
|
322
319
|
}
|
|
323
|
-
if (allowRelative) {
|
|
324
|
-
if (isUrlPathnameRelative(url))
|
|
325
|
-
return;
|
|
326
|
-
errMsg += ', or be a relative URL';
|
|
327
|
-
}
|
|
328
320
|
(0, assert_js_1.assertUsage)(false, errMsg);
|
|
329
321
|
}
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
export { navigate };
|
|
2
2
|
export { reload };
|
|
3
|
+
import { normalizeUrlArgument } from './normalizeUrlArgument.js';
|
|
3
4
|
import { firstRenderStartPromise, renderPageClientSide } from './renderPageClientSide.js';
|
|
4
|
-
import { assertClientRouting,
|
|
5
|
+
import { assertClientRouting, getCurrentUrl } from './utils.js';
|
|
5
6
|
assertClientRouting();
|
|
6
7
|
/** Programmatically navigate to a new page.
|
|
7
8
|
*
|
|
@@ -12,7 +13,7 @@ assertClientRouting();
|
|
|
12
13
|
* @param overwriteLastHistoryEntry - Don't create a new entry in the browser's history, instead let the new URL replace the current URL. (This effectively removes the current URL from the browser history).
|
|
13
14
|
*/
|
|
14
15
|
async function navigate(url, { keepScrollPosition = false, overwriteLastHistoryEntry = false } = {}) {
|
|
15
|
-
|
|
16
|
+
normalizeUrlArgument(url, 'navigate');
|
|
16
17
|
// If `hydrationCanBeAborted === false` (e.g. Vue) then we can apply navigate() only after hydration is done
|
|
17
18
|
await firstRenderStartPromise;
|
|
18
19
|
const scrollTarget = { preserveScroll: keepScrollPosition };
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export { normalizeUrlArgument };
|
|
2
|
+
import { assertUsage, isUrl, isUrlPathnameRelative } from './utils.js';
|
|
3
|
+
function normalizeUrlArgument(url, fnName) {
|
|
4
|
+
// Succinct error message to save client-side KBs
|
|
5
|
+
const errMsg = `[${fnName}(url)] Invalid URL ${url}`;
|
|
6
|
+
assertUsage(isUrl(url), errMsg);
|
|
7
|
+
if (url.startsWith(location.origin)) {
|
|
8
|
+
url = url.slice(location.origin.length);
|
|
9
|
+
}
|
|
10
|
+
assertUsage(url.startsWith('/') || isUrlPathnameRelative(url),
|
|
11
|
+
// `errMsg` used the original `url` value
|
|
12
|
+
errMsg);
|
|
13
|
+
return url;
|
|
14
|
+
}
|
|
@@ -5,7 +5,7 @@ export { populatePageContextPrefetchCache };
|
|
|
5
5
|
export { addLinkPrefetchHandlers };
|
|
6
6
|
export { addLinkPrefetchHandlers_watch };
|
|
7
7
|
export { addLinkPrefetchHandlers_unwatch };
|
|
8
|
-
import { assert, assertClientRouting, assertUsage,
|
|
8
|
+
import { assert, assertClientRouting, assertUsage, assertWarning, checkIfClientRouting, getGlobalObject, hasProp, objectAssign } from './utils.js';
|
|
9
9
|
import { isErrorFetchingStaticAssets, loadUserFilesClientSide } from '../shared/loadUserFilesClientSide.js';
|
|
10
10
|
import { skipLink } from './skipLink.js';
|
|
11
11
|
import { disableClientRouting } from './renderPageClientSide.js';
|
|
@@ -17,6 +17,7 @@ import { getPageContextFromServerHooks } from './getPageContextFromHooks.js';
|
|
|
17
17
|
import { getPageContextCurrent } from './getPageContextCurrent.js';
|
|
18
18
|
import { PAGE_CONTEXT_MAX_AGE_DEFAULT, getPrefetchSettings } from './prefetch/getPrefetchSettings.js';
|
|
19
19
|
import pc from '@brillout/picocolors';
|
|
20
|
+
import { normalizeUrlArgument } from './normalizeUrlArgument.js';
|
|
20
21
|
assertClientRouting();
|
|
21
22
|
const globalObject = getGlobalObject('prefetch.ts', {
|
|
22
23
|
linkPrefetchHandlerAdded: new WeakSet(),
|
|
@@ -96,11 +97,10 @@ async function prefetch(url, options) {
|
|
|
96
97
|
assertUsage(checkIfClientRouting(), 'prefetch() only works with Client Routing, see https://vike.dev/prefetch', {
|
|
97
98
|
showStackTrace: true
|
|
98
99
|
});
|
|
99
|
-
|
|
100
|
-
assertUsageUrlPathname(url, errPrefix);
|
|
100
|
+
url = normalizeUrlArgument(url, 'prefetch');
|
|
101
101
|
const pageContextLink = await getPageContextLink(url);
|
|
102
102
|
if (!pageContextLink?.pageId) {
|
|
103
|
-
assertWarning(false,
|
|
103
|
+
assertWarning(false, `[prefetch(url)] ${pc.string(url)} ${noRouteMatch}`, {
|
|
104
104
|
showStackTrace: true,
|
|
105
105
|
onlyOnce: false
|
|
106
106
|
});
|
|
@@ -187,8 +187,10 @@ async function prefetchOnEvent(linkTag, event) {
|
|
|
187
187
|
// TODO/pageContext-prefetch: remove this dirty hack used by @brillout/docpress and, instead, use Vike's default if pageContextCurrent isn't defined yet.
|
|
188
188
|
prefetchSettings = { staticAssets: 'hover', pageContext: Infinity };
|
|
189
189
|
}
|
|
190
|
+
// Check again in case DOM was manipulated since last check
|
|
191
|
+
if (skipLink(linkTag))
|
|
192
|
+
return;
|
|
190
193
|
const urlOfLink = linkTag.getAttribute('href');
|
|
191
|
-
assert(urlOfLink);
|
|
192
194
|
const pageContextLink = await getPageContextLink(urlOfLink);
|
|
193
195
|
if (!pageContextLink?.pageId)
|
|
194
196
|
return;
|
|
@@ -832,6 +832,9 @@ function assertNoUnexpectedPlusSign(filePath: string, fileName: string) {
|
|
|
832
832
|
}
|
|
833
833
|
*/
|
|
834
834
|
function handleUnknownConfig(configName, configNames, filePathToShowToUser) {
|
|
835
|
+
const configNameColored = pc.cyan(configName);
|
|
836
|
+
let errMsg = `${filePathToShowToUser} sets an unknown config ${configNameColored}.`;
|
|
837
|
+
// vike-{react,vue,solid} hint
|
|
835
838
|
{
|
|
836
839
|
const ui = ['vike-react', 'vike-vue', 'vike-solid'];
|
|
837
840
|
const knownVikeExntensionConfigs = {
|
|
@@ -848,14 +851,16 @@ function handleUnknownConfig(configName, configNames, filePathToShowToUser) {
|
|
|
848
851
|
if (configName in knownVikeExntensionConfigs) {
|
|
849
852
|
const requiredVikeExtension = knownVikeExntensionConfigs[configName];
|
|
850
853
|
assertUsage(false, [
|
|
851
|
-
|
|
852
|
-
`
|
|
853
|
-
|
|
854
|
-
|
|
854
|
+
errMsg,
|
|
855
|
+
`If you want to use the configuration documented at https://vike.dev/${configName} then make sure to install the Vike extension ${requiredVikeExtension
|
|
856
|
+
.map((e) => pc.bold(e))
|
|
857
|
+
.join('/')}.`,
|
|
858
|
+
`Also make sure it applies to ${filePathToShowToUser} (see https://vike.dev/extends#inheritance).`,
|
|
859
|
+
`Alternatively, if you don't want to use the aforementioned Vike extension, define it yourself by using ${pc.cyan('meta')} (https://vike.dev/meta).`
|
|
855
860
|
].join(' '));
|
|
856
861
|
}
|
|
857
862
|
}
|
|
858
|
-
|
|
863
|
+
// Similarity hint
|
|
859
864
|
let configNameSimilar = null;
|
|
860
865
|
if (configName === 'page') {
|
|
861
866
|
configNameSimilar = 'Page';
|
|
@@ -865,11 +870,15 @@ function handleUnknownConfig(configName, configNames, filePathToShowToUser) {
|
|
|
865
870
|
}
|
|
866
871
|
if (configNameSimilar) {
|
|
867
872
|
assert(configNameSimilar !== configName);
|
|
868
|
-
errMsg +=
|
|
873
|
+
errMsg += ` Did you mean to set ${pc.cyan(configNameSimilar)} instead?`;
|
|
869
874
|
if (configName === 'page') {
|
|
870
|
-
errMsg += ` (The name of the config ${pc.cyan('Page')} starts with a capital letter ${pc.cyan('P')} because it
|
|
875
|
+
errMsg += ` (The name of the config ${pc.cyan('Page')} starts with a capital letter ${pc.cyan('P')} because it defines a UI component: a ubiquitous JavaScript convention is that the name of UI components start with a capital letter.)`;
|
|
871
876
|
}
|
|
872
877
|
}
|
|
878
|
+
// `meta` hint
|
|
879
|
+
if (!configNameSimilar) {
|
|
880
|
+
errMsg += ` Make sure to define ${configNameColored} by using ${pc.cyan('meta')} (https://vike.dev/meta), and also make sure the meta configuration applies to ${filePathToShowToUser} (see https://vike.dev/config#inheritance).`;
|
|
881
|
+
}
|
|
873
882
|
assertUsage(false, errMsg);
|
|
874
883
|
}
|
|
875
884
|
function determineRouteFilesystem(locationId, configValueSources) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const PROJECT_VERSION: "0.4.197-commit-
|
|
1
|
+
export declare const PROJECT_VERSION: "0.4.197-commit-1251ed9";
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// Automatically updated by @brillout/release-me
|
|
2
|
-
export const PROJECT_VERSION = '0.4.197-commit-
|
|
2
|
+
export const PROJECT_VERSION = '0.4.197-commit-1251ed9';
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
export { parseUrl };
|
|
2
|
-
export { assertUsageUrlPathname };
|
|
3
2
|
export { assertUsageUrlPathnameAbsolute };
|
|
4
3
|
export { assertUsageUrlRedirectTarget };
|
|
5
4
|
export { isUrl };
|
|
6
5
|
export { isUri };
|
|
7
6
|
export { isUrlRedirectTarget };
|
|
7
|
+
export { isUrlPathnameRelative };
|
|
8
8
|
export { isUrlExternal };
|
|
9
9
|
export { isBaseServer };
|
|
10
10
|
export { assertUrlComponents };
|
|
@@ -50,8 +50,8 @@ declare function assertUrlComponents(url: string, origin: string | null, pathnam
|
|
|
50
50
|
declare function createUrlFromComponents(origin: string | null, pathname: string, search: string | null, hash: string | null): string;
|
|
51
51
|
declare function isUrl(url: string): boolean;
|
|
52
52
|
declare function isUrlRedirectTarget(url: string): boolean;
|
|
53
|
+
declare function isUrlPathnameRelative(url: string): boolean;
|
|
53
54
|
declare function isUrlExternal(url: string): boolean;
|
|
54
55
|
declare function isUri(uri: string): boolean;
|
|
55
|
-
declare function assertUsageUrlPathname(url: string, errPrefix: string): void;
|
|
56
56
|
declare function assertUsageUrlPathnameAbsolute(url: string, errPrefix: string): void;
|
|
57
57
|
declare function assertUsageUrlRedirectTarget(url: string, errPrefix: string, isUnresolved?: true): void;
|
|
@@ -3,12 +3,12 @@
|
|
|
3
3
|
// - It doesn't support the tauri:// protocol
|
|
4
4
|
// Unit tests at ./parseUrl.spec.ts
|
|
5
5
|
export { parseUrl };
|
|
6
|
-
export { assertUsageUrlPathname };
|
|
7
6
|
export { assertUsageUrlPathnameAbsolute };
|
|
8
7
|
export { assertUsageUrlRedirectTarget };
|
|
9
8
|
export { isUrl };
|
|
10
9
|
export { isUri };
|
|
11
10
|
export { isUrlRedirectTarget };
|
|
11
|
+
export { isUrlPathnameRelative };
|
|
12
12
|
export { isUrlExternal };
|
|
13
13
|
export { isBaseServer };
|
|
14
14
|
export { assertUrlComponents };
|
|
@@ -293,16 +293,13 @@ function isUri(uri) {
|
|
|
293
293
|
const { protocol } = parseProtocol(uri);
|
|
294
294
|
return !!protocol && !isUrlProtocol(uri);
|
|
295
295
|
}
|
|
296
|
-
function assertUsageUrlPathname(url, errPrefix) {
|
|
297
|
-
assertUsageUrl(url, errPrefix, { allowRelative: true });
|
|
298
|
-
}
|
|
299
296
|
function assertUsageUrlPathnameAbsolute(url, errPrefix) {
|
|
300
297
|
assertUsageUrl(url, errPrefix);
|
|
301
298
|
}
|
|
302
299
|
function assertUsageUrlRedirectTarget(url, errPrefix, isUnresolved) {
|
|
303
300
|
assertUsageUrl(url, errPrefix, { isRedirectTarget: isUnresolved ? 'unresolved' : true });
|
|
304
301
|
}
|
|
305
|
-
function assertUsageUrl(url, errPrefix, {
|
|
302
|
+
function assertUsageUrl(url, errPrefix, { isRedirectTarget } = {}) {
|
|
306
303
|
if (url.startsWith('/'))
|
|
307
304
|
return;
|
|
308
305
|
let errMsg = `${errPrefix} is ${pc.string(url)} but it should start with ${pc.string('/')}`;
|
|
@@ -316,10 +313,5 @@ function assertUsageUrl(url, errPrefix, { allowRelative, isRedirectTarget } = {}
|
|
|
316
313
|
errMsg += `, or be ${pc.string('*')}`;
|
|
317
314
|
}
|
|
318
315
|
}
|
|
319
|
-
if (allowRelative) {
|
|
320
|
-
if (isUrlPathnameRelative(url))
|
|
321
|
-
return;
|
|
322
|
-
errMsg += ', or be a relative URL';
|
|
323
|
-
}
|
|
324
316
|
assertUsage(false, errMsg);
|
|
325
317
|
}
|