vike 0.4.241 → 0.4.242-commit-4a9fae0
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/esm/node/api/build.js +6 -6
- package/dist/esm/node/api/dev.js +2 -2
- package/dist/esm/node/api/prepareViteApiCall.d.ts +2 -9
- package/dist/esm/node/api/prepareViteApiCall.js +4 -156
- package/dist/esm/node/api/prerender.js +2 -2
- package/dist/esm/node/api/preview.js +2 -2
- package/dist/esm/node/api/resolveViteConfigFromUser.d.ts +20 -0
- package/dist/esm/node/api/resolveViteConfigFromUser.js +207 -0
- package/dist/esm/node/prerender/runPrerenderEntry.js +4 -4
- package/dist/esm/node/runtime/logErrorServer.js +8 -1
- package/dist/esm/node/runtime-dev/createDevMiddleware.js +2 -2
- package/dist/esm/node/vite/index.d.ts +1 -1
- package/dist/esm/node/vite/index.js +52 -21
- package/dist/esm/node/vite/plugins/build/handleAssetsManifest.d.ts +2 -4
- package/dist/esm/node/vite/plugins/build/handleAssetsManifest.js +7 -11
- package/dist/esm/node/vite/plugins/build/pluginBuildApp.js +6 -9
- package/dist/esm/node/vite/plugins/build/pluginBuildConfig.js +3 -16
- package/dist/esm/node/vite/plugins/pluginCommon.d.ts +1 -1
- package/dist/esm/node/vite/plugins/pluginCommon.js +9 -7
- package/dist/esm/node/vite/plugins/pluginReplaceConstantsGlobalThis.d.ts +1 -0
- package/dist/esm/node/vite/plugins/pluginViteConfigVikeExtensions.d.ts +3 -0
- package/dist/esm/node/vite/plugins/pluginViteConfigVikeExtensions.js +32 -0
- package/dist/esm/node/vite/shared/isViteCli.d.ts +13 -0
- package/dist/esm/node/vite/shared/isViteCli.js +143 -0
- package/dist/esm/node/vite/shared/resolveVikeConfigInternal/transpileAndExecuteFile.js +11 -2
- package/dist/esm/node/vite/shared/resolveVikeConfigInternal.d.ts +2 -0
- package/dist/esm/node/vite/shared/resolveVikeConfigInternal.js +4 -0
- package/dist/esm/node/vite/utils.d.ts +1 -0
- package/dist/esm/node/vite/utils.js +1 -0
- package/dist/esm/shared/modifyUrlSameOrigin.js +2 -2
- package/dist/esm/shared/route/abort.js +2 -2
- package/dist/esm/shared/route/execHookOnBeforeRoute.js +3 -3
- package/dist/esm/types/index.d.ts +1 -0
- package/dist/esm/utils/PROJECT_VERSION.d.ts +1 -1
- package/dist/esm/utils/PROJECT_VERSION.js +1 -1
- package/dist/esm/utils/isExactlyOneTruthy.d.ts +1 -0
- package/dist/esm/utils/isExactlyOneTruthy.js +4 -0
- package/dist/esm/utils/parseUrl.d.ts +4 -2
- package/dist/esm/utils/parseUrl.js +32 -25
- package/dist/esm/utils/unique.d.ts +1 -2
- package/dist/esm/utils/unique.js +1 -2
- package/package.json +2 -2
- package/dist/esm/node/vite/shared/isViteCliCall.d.ts +0 -10
- package/dist/esm/node/vite/shared/isViteCliCall.js +0 -81
|
@@ -3,7 +3,8 @@
|
|
|
3
3
|
// - It doesn't support the tauri:// protocol
|
|
4
4
|
// Unit tests at ./parseUrl.spec.ts
|
|
5
5
|
export { parseUrl };
|
|
6
|
-
export {
|
|
6
|
+
export { assertUsageUrlAbsolute };
|
|
7
|
+
export { assertUsageUrlPathAbsolute };
|
|
7
8
|
export { assertUsageUrlRedirectTarget };
|
|
8
9
|
export { isUrl };
|
|
9
10
|
export { isUri };
|
|
@@ -53,6 +54,10 @@ function parseUrl(url, baseServer) {
|
|
|
53
54
|
const { hostname, port } = parseHost(host, url);
|
|
54
55
|
// decode after setting href
|
|
55
56
|
pathname = decodePathname(pathname);
|
|
57
|
+
/* Should it be `pathname` or `pathnameOriginal`? https://github.com/vikejs/vike/pull/2770
|
|
58
|
+
// pageContext.urlParsed.path
|
|
59
|
+
const path = pathname + (searchOriginal || '') + (hashOriginal || '')
|
|
60
|
+
*/
|
|
56
61
|
assert(pathname.startsWith('/'));
|
|
57
62
|
return {
|
|
58
63
|
href,
|
|
@@ -135,7 +140,7 @@ function getBaseURI() {
|
|
|
135
140
|
return baseURI;
|
|
136
141
|
}
|
|
137
142
|
function parseOrigin(url) {
|
|
138
|
-
if (!
|
|
143
|
+
if (!isUrlWithWebProtocol(url)) {
|
|
139
144
|
return { pathname: url, origin: null, protocol: null };
|
|
140
145
|
}
|
|
141
146
|
else {
|
|
@@ -181,7 +186,7 @@ function parseProtocol(uri) {
|
|
|
181
186
|
}
|
|
182
187
|
return { protocol, uriWithoutProtocol };
|
|
183
188
|
}
|
|
184
|
-
function
|
|
189
|
+
function isWebUrlProtocol(protocol) {
|
|
185
190
|
// Is there an alternative to having a blocklist?
|
|
186
191
|
// - If the blocklist becomes too big, maybe use a allowlist instead ['tauri://', 'file://', 'capacitor://', 'http://', 'https://']
|
|
187
192
|
const blocklist = [
|
|
@@ -264,10 +269,16 @@ function createUrlFromComponents(origin, pathname, search, hash) {
|
|
|
264
269
|
}
|
|
265
270
|
function isUrl(url) {
|
|
266
271
|
// parseUrl() works with these URLs
|
|
267
|
-
return
|
|
272
|
+
return isUrlAbsolute(url) || isUrlRelative(url);
|
|
268
273
|
}
|
|
269
274
|
function isUrlRedirectTarget(url) {
|
|
270
|
-
return url
|
|
275
|
+
return isUrlAbsolute(url) || isUri(url);
|
|
276
|
+
}
|
|
277
|
+
function isUrlAbsolute(url) {
|
|
278
|
+
return isUrlPathAbsolute(url) || isUrlWithWebProtocol(url);
|
|
279
|
+
}
|
|
280
|
+
function isUrlPathAbsolute(url) {
|
|
281
|
+
return url.startsWith('/');
|
|
271
282
|
}
|
|
272
283
|
function isUrlRelative(url) {
|
|
273
284
|
return ['.', '?', '#'].some((c) => url.startsWith(c)) || url === '';
|
|
@@ -288,9 +299,9 @@ URL with protocol.
|
|
|
288
299
|
[Electron (`file://`)](https://github.com/vikejs/vike/issues/1557)
|
|
289
300
|
[Capacitor](https://github.com/vikejs/vike/issues/1706)
|
|
290
301
|
*/
|
|
291
|
-
function
|
|
302
|
+
function isUrlWithWebProtocol(url) {
|
|
292
303
|
const { protocol } = parseProtocol(url);
|
|
293
|
-
return !!protocol &&
|
|
304
|
+
return !!protocol && isWebUrlProtocol(protocol);
|
|
294
305
|
}
|
|
295
306
|
/*
|
|
296
307
|
URIs that aren't URLs.
|
|
@@ -308,27 +319,23 @@ We need to treat URIs differently than URLs.
|
|
|
308
319
|
*/
|
|
309
320
|
function isUri(uri) {
|
|
310
321
|
const { protocol } = parseProtocol(uri);
|
|
311
|
-
return !!protocol && !
|
|
322
|
+
return !!protocol && !isWebUrlProtocol(protocol);
|
|
323
|
+
}
|
|
324
|
+
function assertUsageUrlAbsolute(url, errPrefix) {
|
|
325
|
+
assertUsage(isUrlAbsolute(url), getErrMsg(url, errPrefix, true));
|
|
312
326
|
}
|
|
313
|
-
function
|
|
314
|
-
|
|
327
|
+
function assertUsageUrlPathAbsolute(url, errPrefix) {
|
|
328
|
+
assertUsage(isUrlPathAbsolute(url), getErrMsg(url, errPrefix));
|
|
315
329
|
}
|
|
316
330
|
function assertUsageUrlRedirectTarget(url, errPrefix, isUnresolved) {
|
|
317
|
-
|
|
331
|
+
const errMsg = getErrMsg(url, errPrefix, true, isUnresolved);
|
|
332
|
+
assertUsage(isUrlRedirectTarget(url) || (isUnresolved && url === '*'), errMsg);
|
|
318
333
|
}
|
|
319
|
-
function
|
|
320
|
-
if (url.startsWith('/'))
|
|
321
|
-
return;
|
|
334
|
+
function getErrMsg(url, errPrefix, allowProtocol, allowUri) {
|
|
322
335
|
let errMsg = `${errPrefix} is ${pc.string(url)} but it should start with ${pc.string('/')}`;
|
|
323
|
-
if (
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
errMsg +=
|
|
327
|
-
|
|
328
|
-
if (url === '*')
|
|
329
|
-
return;
|
|
330
|
-
errMsg += `, or be ${pc.string('*')}`;
|
|
331
|
-
}
|
|
332
|
-
}
|
|
333
|
-
assertUsage(false, errMsg);
|
|
336
|
+
if (allowProtocol)
|
|
337
|
+
errMsg += ` or a protocol (e.g. ${pc.string('http://')})`;
|
|
338
|
+
if (allowUri)
|
|
339
|
+
errMsg += `, or be ${pc.string('*')}`;
|
|
340
|
+
return errMsg;
|
|
334
341
|
}
|
|
@@ -1,2 +1 @@
|
|
|
1
|
-
export
|
|
2
|
-
declare function unique<T>(arr: T[]): T[];
|
|
1
|
+
export declare function unique<T>(arr: T[]): T[];
|
package/dist/esm/utils/unique.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "vike",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.242-commit-4a9fae0",
|
|
4
4
|
"repository": "https://github.com/vikejs/vike",
|
|
5
5
|
"exports": {
|
|
6
6
|
"./server": {
|
|
@@ -245,7 +245,7 @@
|
|
|
245
245
|
"@types/picomatch": "^3.0.2",
|
|
246
246
|
"@types/semver": "^7.5.8",
|
|
247
247
|
"@types/source-map-support": "^0.5.10",
|
|
248
|
-
"react-streaming": "^0.4.
|
|
248
|
+
"react-streaming": "^0.4.10",
|
|
249
249
|
"rimraf": "^5.0.5",
|
|
250
250
|
"typescript": "^5.9.2",
|
|
251
251
|
"vite": "^7.1.5"
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
export { isViteCliCall };
|
|
2
|
-
export { getViteConfigFromCli };
|
|
3
|
-
declare function isViteCliCall(): boolean;
|
|
4
|
-
type ConfigFromCli = {
|
|
5
|
-
root: undefined | string;
|
|
6
|
-
configFile: undefined | string;
|
|
7
|
-
} & Record<string, unknown> & {
|
|
8
|
-
build: Record<string, unknown>;
|
|
9
|
-
};
|
|
10
|
-
declare function getViteConfigFromCli(): null | ConfigFromCli;
|
|
@@ -1,81 +0,0 @@
|
|
|
1
|
-
export { isViteCliCall };
|
|
2
|
-
export { getViteConfigFromCli };
|
|
3
|
-
import { assert, isObject, toPosixPath } from '../utils.js';
|
|
4
|
-
import { cac } from 'cac';
|
|
5
|
-
function isViteCliCall() {
|
|
6
|
-
let execPath = process.argv[1];
|
|
7
|
-
assert(execPath);
|
|
8
|
-
execPath = toPosixPath(execPath);
|
|
9
|
-
return (
|
|
10
|
-
// pnpm
|
|
11
|
-
execPath.endsWith('/bin/vite.js') ||
|
|
12
|
-
// npm & yarn
|
|
13
|
-
execPath.endsWith('/.bin/vite') ||
|
|
14
|
-
// Global install
|
|
15
|
-
execPath.endsWith('/bin/vite'));
|
|
16
|
-
}
|
|
17
|
-
function getViteConfigFromCli() {
|
|
18
|
-
if (!isViteCliCall())
|
|
19
|
-
return null;
|
|
20
|
-
// Copied and adapted from https://github.com/vitejs/vite/blob/8d0a9c1ab8ddd26973509ca230b29604e872e2cd/packages/vite/src/node/cli.ts#L137-L197
|
|
21
|
-
const cli = cac('vike:vite-simulation');
|
|
22
|
-
const desc = 'FAKE_CLI';
|
|
23
|
-
cli
|
|
24
|
-
.option('-c, --config <file>', desc)
|
|
25
|
-
.option('--base <path>', desc)
|
|
26
|
-
.option('-l, --logLevel <level>', desc)
|
|
27
|
-
.option('--clearScreen', desc)
|
|
28
|
-
.option('-d, --debug [feat]', desc)
|
|
29
|
-
.option('-f, --filter <filter>', desc)
|
|
30
|
-
.option('-m, --mode <mode>', desc);
|
|
31
|
-
cli
|
|
32
|
-
.command('build [root]', desc)
|
|
33
|
-
.option('--target <target>', desc)
|
|
34
|
-
.option('--outDir <dir>', desc)
|
|
35
|
-
.option('--assetsDir <dir>', desc)
|
|
36
|
-
.option('--assetsInlineLimit <number>', desc)
|
|
37
|
-
.option('--ssr [entry]', desc)
|
|
38
|
-
.option('--sourcemap', desc)
|
|
39
|
-
.option('--minify [minifier]', desc)
|
|
40
|
-
.option('--manifest [name]', desc)
|
|
41
|
-
.option('--ssrManifest [name]', desc)
|
|
42
|
-
.option('--force', desc)
|
|
43
|
-
.option('--emptyOutDir', desc)
|
|
44
|
-
.option('-w, --watch', desc)
|
|
45
|
-
.action((root, options) => {
|
|
46
|
-
assert(isObject(options));
|
|
47
|
-
const buildOptions = cleanOptions(options);
|
|
48
|
-
assert(root === undefined || typeof root === 'string');
|
|
49
|
-
assert(options.config === undefined || typeof options.config === 'string');
|
|
50
|
-
configFromCli = {
|
|
51
|
-
root,
|
|
52
|
-
base: options.base,
|
|
53
|
-
mode: options.mode,
|
|
54
|
-
configFile: options.config,
|
|
55
|
-
logLevel: options.logLevel,
|
|
56
|
-
clearScreen: options.clearScreen,
|
|
57
|
-
optimizeDeps: { force: options.force },
|
|
58
|
-
build: buildOptions,
|
|
59
|
-
};
|
|
60
|
-
});
|
|
61
|
-
let configFromCli = null;
|
|
62
|
-
cli.parse();
|
|
63
|
-
return configFromCli;
|
|
64
|
-
function cleanOptions(options) {
|
|
65
|
-
const ret = { ...options };
|
|
66
|
-
delete ret['--'];
|
|
67
|
-
delete ret.c;
|
|
68
|
-
delete ret.config;
|
|
69
|
-
delete ret.base;
|
|
70
|
-
delete ret.l;
|
|
71
|
-
delete ret.logLevel;
|
|
72
|
-
delete ret.clearScreen;
|
|
73
|
-
delete ret.d;
|
|
74
|
-
delete ret.debug;
|
|
75
|
-
delete ret.f;
|
|
76
|
-
delete ret.filter;
|
|
77
|
-
delete ret.m;
|
|
78
|
-
delete ret.mode;
|
|
79
|
-
return ret;
|
|
80
|
-
}
|
|
81
|
-
}
|