vike 0.4.242 → 0.4.243-commit-6ce9ef3
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/client/runtime-client-routing/getGlobalContextClientInternal.d.ts +0 -3
- package/dist/esm/client/runtime-client-routing/getPageContextFromHooks.d.ts +12 -4
- package/dist/esm/client/runtime-client-routing/initOnLinkClick.js +3 -1
- package/dist/esm/client/runtime-client-routing/renderPageClientSide.d.ts +3 -1
- package/dist/esm/client/runtime-client-routing/skipLink.d.ts +2 -0
- package/dist/esm/client/runtime-client-routing/skipLink.js +10 -0
- package/dist/esm/client/runtime-server-routing/getGlobalContextClientInternal.d.ts +0 -3
- package/dist/esm/node/api/preview.js +9 -2
- package/dist/esm/node/runtime/globalContext.d.ts +2 -4
- 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 +0 -3
- package/dist/esm/node/vite/plugins/build/pluginBuildConfig.js +3 -16
- package/dist/esm/node/vite/shared/resolveVikeConfigInternal/configDefinitionsBuiltIn.js +4 -0
- package/dist/esm/node/vite/shared/resolveVikeConfigInternal.js +9 -4
- package/dist/esm/shared/getProxyForPublicUsage.d.ts +3 -0
- package/dist/esm/shared/getProxyForPublicUsage.js +24 -24
- 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/Config.d.ts +6 -1
- package/dist/esm/types/GlobalContext.d.ts +17 -0
- package/dist/esm/types/GlobalContext.js +1 -0
- package/dist/esm/types/PageContext.d.ts +4 -8
- package/dist/esm/types/index.d.ts +2 -1
- 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 +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
|
@@ -1,8 +1,5 @@
|
|
|
1
1
|
export { getGlobalContextClientInternal };
|
|
2
|
-
export type { GlobalContextClient };
|
|
3
2
|
export type { GlobalContextClientInternal };
|
|
4
|
-
import type { GlobalContextBasePublic } from '../../shared/createGlobalContextShared.js';
|
|
5
|
-
type GlobalContextClient = GlobalContextBasePublic & Pick<GlobalContextClientInternal, 'isClientSide'> & Vike.GlobalContext & Vike.GlobalContextClient & {};
|
|
6
3
|
type GlobalContextClientInternal = Awaited<ReturnType<typeof getGlobalContextClientInternal>>;
|
|
7
4
|
declare function getGlobalContextClientInternal(): Promise<{
|
|
8
5
|
_globalConfigPublic: {
|
|
@@ -117,6 +117,7 @@ declare function getPageContextFromHooks_isHydration(pageContext: PageContextSer
|
|
|
117
117
|
url: string;
|
|
118
118
|
pageExports: Record<string, unknown>;
|
|
119
119
|
isBaseMissing?: true;
|
|
120
|
+
ignoreWarning?: import("../../shared/getProxyForPublicUsage.js").IgnoreWarning;
|
|
120
121
|
}> & Pick<PageContextConfig & {
|
|
121
122
|
isPageContext: true;
|
|
122
123
|
Page: import("../../types/Config.js").Config["Page"];
|
|
@@ -138,6 +139,7 @@ declare function getPageContextFromHooks_isHydration(pageContext: PageContextSer
|
|
|
138
139
|
url: string;
|
|
139
140
|
pageExports: Record<string, unknown>;
|
|
140
141
|
isBaseMissing?: true;
|
|
142
|
+
ignoreWarning?: import("../../shared/getProxyForPublicUsage.js").IgnoreWarning;
|
|
141
143
|
}, "exports" | "pageId" | "pageExports" | "config" | "Page" | "data" | "source" | "sources" | "from" | "configEntries" | "exportsAll" | "routeParams" | "abortReason"> & {
|
|
142
144
|
isClientSide: true;
|
|
143
145
|
isPrerendering: false;
|
|
@@ -145,7 +147,7 @@ declare function getPageContextFromHooks_isHydration(pageContext: PageContextSer
|
|
|
145
147
|
isHydration: boolean;
|
|
146
148
|
isBackwardNavigation: boolean | null;
|
|
147
149
|
previousPageContext: import("../../types/PageContext.js").PageContextClient<unknown> | null;
|
|
148
|
-
globalContext: import("
|
|
150
|
+
globalContext: import("../../types/GlobalContext.js").GlobalContextClient;
|
|
149
151
|
} & {
|
|
150
152
|
urlOriginal: string;
|
|
151
153
|
} & {
|
|
@@ -182,6 +184,7 @@ declare function getPageContextFromHooks_isHydration(pageContext: PageContextSer
|
|
|
182
184
|
url: string;
|
|
183
185
|
pageExports: Record<string, unknown>;
|
|
184
186
|
isBaseMissing?: true;
|
|
187
|
+
ignoreWarning?: import("../../shared/getProxyForPublicUsage.js").IgnoreWarning;
|
|
185
188
|
}> & Pick<PageContextConfig & {
|
|
186
189
|
isPageContext: true;
|
|
187
190
|
Page: import("../../types/Config.js").Config["Page"];
|
|
@@ -203,6 +206,7 @@ declare function getPageContextFromHooks_isHydration(pageContext: PageContextSer
|
|
|
203
206
|
url: string;
|
|
204
207
|
pageExports: Record<string, unknown>;
|
|
205
208
|
isBaseMissing?: true;
|
|
209
|
+
ignoreWarning?: import("../../shared/getProxyForPublicUsage.js").IgnoreWarning;
|
|
206
210
|
}, "exports" | "pageId" | "pageExports" | "config" | "Page" | "data" | "source" | "sources" | "from" | "configEntries" | "exportsAll" | "routeParams" | "abortReason"> & {
|
|
207
211
|
isClientSide: true;
|
|
208
212
|
isPrerendering: false;
|
|
@@ -210,7 +214,7 @@ declare function getPageContextFromHooks_isHydration(pageContext: PageContextSer
|
|
|
210
214
|
isHydration: boolean;
|
|
211
215
|
isBackwardNavigation: boolean | null;
|
|
212
216
|
previousPageContext: import("../../types/PageContext.js").PageContextClient<unknown> | null;
|
|
213
|
-
globalContext: import("
|
|
217
|
+
globalContext: import("../../types/GlobalContext.js").GlobalContextClient;
|
|
214
218
|
} & {
|
|
215
219
|
urlOriginal: string;
|
|
216
220
|
} & {
|
|
@@ -338,6 +342,7 @@ declare function getPageContextFromClientHooks(pageContext: {
|
|
|
338
342
|
url: string;
|
|
339
343
|
pageExports: Record<string, unknown>;
|
|
340
344
|
isBaseMissing?: true;
|
|
345
|
+
ignoreWarning?: import("../../shared/getProxyForPublicUsage.js").IgnoreWarning;
|
|
341
346
|
}> & Pick<PageContextConfig & {
|
|
342
347
|
isPageContext: true;
|
|
343
348
|
Page: import("../../types/Config.js").Config["Page"];
|
|
@@ -359,6 +364,7 @@ declare function getPageContextFromClientHooks(pageContext: {
|
|
|
359
364
|
url: string;
|
|
360
365
|
pageExports: Record<string, unknown>;
|
|
361
366
|
isBaseMissing?: true;
|
|
367
|
+
ignoreWarning?: import("../../shared/getProxyForPublicUsage.js").IgnoreWarning;
|
|
362
368
|
}, "exports" | "pageId" | "pageExports" | "config" | "Page" | "data" | "source" | "sources" | "from" | "configEntries" | "exportsAll" | "routeParams" | "abortReason"> & {
|
|
363
369
|
isClientSide: true;
|
|
364
370
|
isPrerendering: false;
|
|
@@ -366,7 +372,7 @@ declare function getPageContextFromClientHooks(pageContext: {
|
|
|
366
372
|
isHydration: boolean;
|
|
367
373
|
isBackwardNavigation: boolean | null;
|
|
368
374
|
previousPageContext: import("../../types/PageContext.js").PageContextClient<unknown> | null;
|
|
369
|
-
globalContext: import("
|
|
375
|
+
globalContext: import("../../types/GlobalContext.js").GlobalContextClient;
|
|
370
376
|
} & {
|
|
371
377
|
urlOriginal: string;
|
|
372
378
|
} & {
|
|
@@ -401,6 +407,7 @@ declare function getPageContextFromClientHooks(pageContext: {
|
|
|
401
407
|
url: string;
|
|
402
408
|
pageExports: Record<string, unknown>;
|
|
403
409
|
isBaseMissing?: true;
|
|
410
|
+
ignoreWarning?: import("../../shared/getProxyForPublicUsage.js").IgnoreWarning;
|
|
404
411
|
}> & Pick<PageContextConfig & {
|
|
405
412
|
isPageContext: true;
|
|
406
413
|
Page: import("../../types/Config.js").Config["Page"];
|
|
@@ -422,6 +429,7 @@ declare function getPageContextFromClientHooks(pageContext: {
|
|
|
422
429
|
url: string;
|
|
423
430
|
pageExports: Record<string, unknown>;
|
|
424
431
|
isBaseMissing?: true;
|
|
432
|
+
ignoreWarning?: import("../../shared/getProxyForPublicUsage.js").IgnoreWarning;
|
|
425
433
|
}, "exports" | "pageId" | "pageExports" | "config" | "Page" | "data" | "source" | "sources" | "from" | "configEntries" | "exportsAll" | "routeParams" | "abortReason"> & {
|
|
426
434
|
isClientSide: true;
|
|
427
435
|
isPrerendering: false;
|
|
@@ -429,7 +437,7 @@ declare function getPageContextFromClientHooks(pageContext: {
|
|
|
429
437
|
isHydration: boolean;
|
|
430
438
|
isBackwardNavigation: boolean | null;
|
|
431
439
|
previousPageContext: import("../../types/PageContext.js").PageContextClient<unknown> | null;
|
|
432
|
-
globalContext: import("
|
|
440
|
+
globalContext: import("../../types/GlobalContext.js").GlobalContextClient;
|
|
433
441
|
} & {
|
|
434
442
|
urlOriginal: string;
|
|
435
443
|
} & {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export { initOnLinkClick };
|
|
2
|
-
import { isSameAsCurrentUrl, skipLink } from './skipLink.js';
|
|
2
|
+
import { isLinkIgnored, isSameAsCurrentUrl, skipLink } from './skipLink.js';
|
|
3
3
|
import { renderPageClientSide } from './renderPageClientSide.js';
|
|
4
4
|
import { scrollToHashOrTop } from './setScrollPosition.js';
|
|
5
5
|
function initOnLinkClick() {
|
|
@@ -14,6 +14,8 @@ async function onLinkClick(ev) {
|
|
|
14
14
|
const href = linkTag.getAttribute('href');
|
|
15
15
|
if (href === null)
|
|
16
16
|
return;
|
|
17
|
+
if (isLinkIgnored(linkTag))
|
|
18
|
+
return;
|
|
17
19
|
// Workaround for Firefox bug: clicking on a hash link that doesn't change the current URL causes Firefox to erroneously set `window.history.state = null` without firing any signal that we can detect.
|
|
18
20
|
// - https://github.com/vikejs/vike/issues/1962
|
|
19
21
|
// - https://github.com/sveltejs/kit/issues/8725
|
|
@@ -128,6 +128,7 @@ declare function getPageContextBegin(isForErrorPage: boolean, { urlOriginal, isB
|
|
|
128
128
|
url: string;
|
|
129
129
|
pageExports: Record<string, unknown>;
|
|
130
130
|
isBaseMissing?: true;
|
|
131
|
+
ignoreWarning?: import("../../shared/getProxyForPublicUsage.js").IgnoreWarning;
|
|
131
132
|
}> & Pick<PageContextConfig & {
|
|
132
133
|
isPageContext: true;
|
|
133
134
|
Page: import("../../types/Config.js").Config["Page"];
|
|
@@ -149,6 +150,7 @@ declare function getPageContextBegin(isForErrorPage: boolean, { urlOriginal, isB
|
|
|
149
150
|
url: string;
|
|
150
151
|
pageExports: Record<string, unknown>;
|
|
151
152
|
isBaseMissing?: true;
|
|
153
|
+
ignoreWarning?: import("../../shared/getProxyForPublicUsage.js").IgnoreWarning;
|
|
152
154
|
}, "exports" | "pageId" | "pageExports" | "config" | "Page" | "data" | "source" | "sources" | "from" | "configEntries" | "exportsAll" | "routeParams" | "abortReason"> & {
|
|
153
155
|
isClientSide: true;
|
|
154
156
|
isPrerendering: false;
|
|
@@ -156,7 +158,7 @@ declare function getPageContextBegin(isForErrorPage: boolean, { urlOriginal, isB
|
|
|
156
158
|
isHydration: boolean;
|
|
157
159
|
isBackwardNavigation: boolean | null;
|
|
158
160
|
previousPageContext: PageContextClient<unknown> | null;
|
|
159
|
-
globalContext: import("
|
|
161
|
+
globalContext: import("../../types/GlobalContext.js").GlobalContextClient;
|
|
160
162
|
} & {
|
|
161
163
|
urlOriginal: string;
|
|
162
164
|
} & {
|
|
@@ -1,4 +1,6 @@
|
|
|
1
|
+
// TODO: rename_full skipLink isLinkSkipped
|
|
1
2
|
export { skipLink };
|
|
3
|
+
export { isLinkIgnored };
|
|
2
4
|
export { isSameAsCurrentUrl };
|
|
3
5
|
import { normalizeClientSideUrl } from '../shared/normalizeClientSideUrl.js';
|
|
4
6
|
import { getBaseServer } from './getBaseServer.js';
|
|
@@ -11,6 +13,7 @@ function skipLink(linkTag) {
|
|
|
11
13
|
isUrlExternal(href) ||
|
|
12
14
|
isSamePageHashLink(href) ||
|
|
13
15
|
isNewTabLink(linkTag) ||
|
|
16
|
+
isLinkIgnored(linkTag) ||
|
|
14
17
|
!hasBaseServer(href) ||
|
|
15
18
|
// Purposely last because disableAutomaticLinkInterception will be removed in the next major release
|
|
16
19
|
!isVikeLink(linkTag));
|
|
@@ -22,18 +25,25 @@ function isVikeLink(linkTag) {
|
|
|
22
25
|
return true;
|
|
23
26
|
}
|
|
24
27
|
else {
|
|
28
|
+
// TODO: rename target attrVal
|
|
25
29
|
const target = linkTag.getAttribute('data-vike-link');
|
|
26
30
|
return target !== null && target !== 'false';
|
|
27
31
|
}
|
|
28
32
|
}
|
|
33
|
+
// TODO rename
|
|
29
34
|
function isNewTabLink(linkTag) {
|
|
30
35
|
const target = linkTag.getAttribute('target');
|
|
31
36
|
const rel = linkTag.getAttribute('rel');
|
|
32
37
|
return target === '_blank' || target === '_external' || rel === 'external' || linkTag.hasAttribute('download');
|
|
33
38
|
}
|
|
39
|
+
function isLinkIgnored(linkTag) {
|
|
40
|
+
return linkTag.getAttribute('data-vike') === 'false';
|
|
41
|
+
}
|
|
42
|
+
// TODO refactor both functions below?
|
|
34
43
|
function isSamePageHashLink(href) {
|
|
35
44
|
if (href.startsWith('#'))
|
|
36
45
|
return true;
|
|
46
|
+
// TODO: remove?
|
|
37
47
|
if (href.includes('#') &&
|
|
38
48
|
normalizeClientSideUrl(href, { withoutHash: true }) ===
|
|
39
49
|
normalizeClientSideUrl(window.location.href, { withoutHash: true })) {
|
|
@@ -1,8 +1,5 @@
|
|
|
1
1
|
export { getGlobalContextClientInternal };
|
|
2
|
-
export type { GlobalContextClientWithServerRouting };
|
|
3
2
|
export type { GlobalContextClientInternalWithServerRouting };
|
|
4
|
-
import type { GlobalContextBasePublic } from '../../shared/createGlobalContextShared.js';
|
|
5
|
-
type GlobalContextClientWithServerRouting = GlobalContextBasePublic & Pick<GlobalContextClientInternalWithServerRouting, 'isClientSide'> & Vike.GlobalContext & Vike.GlobalContextClient & {};
|
|
6
3
|
type GlobalContextClientInternalWithServerRouting = Awaited<ReturnType<typeof getGlobalContextClientInternal>>;
|
|
7
4
|
declare function getGlobalContextClientInternal(): Promise<{
|
|
8
5
|
_globalConfigPublic: {
|
|
@@ -3,9 +3,10 @@ import { prepareViteApiCall } from './prepareViteApiCall.js';
|
|
|
3
3
|
import { preview as previewVite } from 'vite';
|
|
4
4
|
import { importServerProductionIndex } from '@brillout/vite-plugin-server-entry/runtime';
|
|
5
5
|
import { getOutDirs } from '../vite/shared/getOutDirs.js';
|
|
6
|
-
import { assertWarning, onSetupPreview } from './utils.js';
|
|
6
|
+
import { assertUsage, assertWarning, onSetupPreview } from './utils.js';
|
|
7
7
|
import pc from '@brillout/picocolors';
|
|
8
8
|
import path from 'node:path';
|
|
9
|
+
import { getVikeConfigInternal } from '../vite/shared/resolveVikeConfigInternal.js';
|
|
9
10
|
/**
|
|
10
11
|
* Programmatically trigger `$ vike preview`
|
|
11
12
|
*
|
|
@@ -14,7 +15,12 @@ import path from 'node:path';
|
|
|
14
15
|
async function preview(options = {}) {
|
|
15
16
|
onSetupPreview();
|
|
16
17
|
const { viteConfigFromUserResolved, viteConfigResolved } = await prepareViteApiCall(options, 'preview');
|
|
17
|
-
|
|
18
|
+
const vikeConfig = await getVikeConfigInternal();
|
|
19
|
+
const cliPreview = vikeConfig.config.cli?.preview;
|
|
20
|
+
assertUsage(cliPreview !== false, `${pc.cyan('$ vike preview')} isn't supported`);
|
|
21
|
+
const useVite = cliPreview === 'vite' || (cliPreview === undefined && !viteConfigResolved.vitePluginServerEntry?.inject);
|
|
22
|
+
if (!useVite) {
|
|
23
|
+
// Dynamically import() server production entry dist/server/index.js
|
|
18
24
|
const outDir = getOutDirs(viteConfigResolved, undefined).outDirRoot;
|
|
19
25
|
const { outServerIndex } = await importServerProductionIndex({ outDir });
|
|
20
26
|
const outServerIndexRelative = path.relative(viteConfigResolved.root, outServerIndex);
|
|
@@ -24,6 +30,7 @@ async function preview(options = {}) {
|
|
|
24
30
|
};
|
|
25
31
|
}
|
|
26
32
|
else {
|
|
33
|
+
// Use Vite's preview server
|
|
27
34
|
const server = await previewVite(viteConfigFromUserResolved);
|
|
28
35
|
return {
|
|
29
36
|
viteServer: server,
|
|
@@ -20,17 +20,15 @@ export { updateUserFiles };
|
|
|
20
20
|
export { isRunnable };
|
|
21
21
|
export { vikeConfigErrorRecoverMsg };
|
|
22
22
|
export type { BuildInfo };
|
|
23
|
-
export type { GlobalContextServerInternal
|
|
24
|
-
export type { GlobalContextServer };
|
|
23
|
+
export type { GlobalContextServerInternal };
|
|
25
24
|
import type { ViteManifest } from '../../types/ViteManifest.js';
|
|
26
25
|
import type { ResolvedConfig, ViteDevServer } from 'vite';
|
|
27
26
|
import { type PageRoutes } from '../../shared/route/loadPageRoutes.js';
|
|
28
27
|
import type { ViteConfigRuntime } from '../vite/shared/getViteConfigRuntime.js';
|
|
29
|
-
import type { GlobalContext } from '../../types/
|
|
28
|
+
import type { GlobalContext } from '../../types/GlobalContext.js';
|
|
30
29
|
import type { Hook } from '../../shared/hooks/getHook.js';
|
|
31
30
|
import type { PrerenderContext } from '../../types/index.js';
|
|
32
31
|
declare const vikeConfigErrorRecoverMsg: "Vike config loaded";
|
|
33
|
-
type GlobalContextServer = Pick<GlobalContextServerInternal, 'assetsManifest' | 'config' | 'viteConfig' | 'viteConfigRuntime' | 'pages' | 'baseServer' | 'baseAssets' | 'isClientSide'> & Vike.GlobalContext & Vike.GlobalContextServer;
|
|
34
32
|
type GlobalContextServerInternal = Awaited<ReturnType<typeof createGlobalContext>>;
|
|
35
33
|
declare function getGlobalContextServerInternal(): Promise<{
|
|
36
34
|
globalContext: (Record<string, unknown> & {
|
|
@@ -3,14 +3,12 @@ export { handleAssetsManifest_getBuildConfig };
|
|
|
3
3
|
export { handleAssetsManifest_isFixEnabled };
|
|
4
4
|
export { handleAssetsManifest_assertUsageCssCodeSplit };
|
|
5
5
|
export { handleAssetsManifest_assertUsageCssTarget };
|
|
6
|
-
export {
|
|
7
|
-
export { handleAssetsManifest_workaroundCssTarget_part2 };
|
|
6
|
+
export { handleAssetsManifest_alignCssTarget };
|
|
8
7
|
import type { Environment, ResolvedConfig, Rollup } from 'vite';
|
|
9
8
|
type Bundle = Rollup.OutputBundle;
|
|
10
9
|
declare function handleAssetsManifest_isFixEnabled(): boolean;
|
|
11
10
|
declare function handleAssetsManifest_assertUsageCssCodeSplit(config: ResolvedConfig): void;
|
|
12
|
-
declare function
|
|
13
|
-
declare function handleAssetsManifest_workaroundCssTarget_part2(): void;
|
|
11
|
+
declare function handleAssetsManifest_alignCssTarget(config: ResolvedConfig): void;
|
|
14
12
|
declare function handleAssetsManifest_assertUsageCssTarget(config: ResolvedConfig, env: Environment): void;
|
|
15
13
|
declare function handleAssetsManifest_getBuildConfig(): Promise<{
|
|
16
14
|
readonly ssrEmitAssets: true | undefined;
|
|
@@ -3,8 +3,7 @@ export { handleAssetsManifest_getBuildConfig };
|
|
|
3
3
|
export { handleAssetsManifest_isFixEnabled };
|
|
4
4
|
export { handleAssetsManifest_assertUsageCssCodeSplit };
|
|
5
5
|
export { handleAssetsManifest_assertUsageCssTarget };
|
|
6
|
-
export {
|
|
7
|
-
export { handleAssetsManifest_workaroundCssTarget_part2 };
|
|
6
|
+
export { handleAssetsManifest_alignCssTarget };
|
|
8
7
|
import fs from 'node:fs/promises';
|
|
9
8
|
import fs_sync from 'node:fs';
|
|
10
9
|
import path from 'node:path';
|
|
@@ -20,7 +19,6 @@ import { set_macro_ASSETS_MANIFEST } from './pluginProdBuildEntry.js';
|
|
|
20
19
|
import { getManifestFilePathRelative } from '../../shared/getManifestFilePathRelative.js';
|
|
21
20
|
const globalObject = getGlobalObject('handleAssetsManifest.ts', {
|
|
22
21
|
assetsJsonFilePath: undefined,
|
|
23
|
-
cssTarget: '__VIKE__UNSET',
|
|
24
22
|
targetsAll: [],
|
|
25
23
|
configsAll: [],
|
|
26
24
|
});
|
|
@@ -221,15 +219,13 @@ function handleAssetsManifest_assertUsageCssCodeSplit(config) {
|
|
|
221
219
|
return;
|
|
222
220
|
assertWarning(config.build.cssCodeSplit, `${pc.cyan('build.cssCodeSplit')} shouldn't be set to ${pc.cyan('false')} (https://github.com/vikejs/vike/issues/1993)`, { onlyOnce: true });
|
|
223
221
|
}
|
|
224
|
-
function
|
|
222
|
+
function handleAssetsManifest_alignCssTarget(config) {
|
|
225
223
|
globalObject.configsAll.push(config);
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
assert(globalObject.cssTarget !== '__VIKE__UNSET');
|
|
232
|
-
globalObject.configsAll.forEach((c) => (c.build.cssTarget = globalObject.cssTarget));
|
|
224
|
+
const { cssTarget } = globalObject.configsAll
|
|
225
|
+
.filter((c) => !isViteServerSide_viteEnvOptional(c, undefined))
|
|
226
|
+
.at(-1).build;
|
|
227
|
+
assert(cssTarget);
|
|
228
|
+
globalObject.configsAll.forEach((c) => (c.build.cssTarget = cssTarget));
|
|
233
229
|
}
|
|
234
230
|
function handleAssetsManifest_assertUsageCssTarget(config, env) {
|
|
235
231
|
if (!handleAssetsManifest_isFixEnabled())
|
|
@@ -10,31 +10,18 @@ import { prependEntriesDir } from '../../../shared/prependEntriesDir.js';
|
|
|
10
10
|
import { getFilePathResolved } from '../../shared/getFilePath.js';
|
|
11
11
|
import { getConfigValueBuildTime } from '../../../../shared/page-configs/getConfigValueBuildTime.js';
|
|
12
12
|
import { isViteServerSide_viteEnvOptional } from '../../shared/isViteServerSide.js';
|
|
13
|
-
import { handleAssetsManifest_assertUsageCssCodeSplit, handleAssetsManifest_getBuildConfig,
|
|
13
|
+
import { handleAssetsManifest_assertUsageCssCodeSplit, handleAssetsManifest_getBuildConfig, handleAssetsManifest_alignCssTarget, } from './handleAssetsManifest.js';
|
|
14
14
|
import { resolveIncludeAssetsImportedByServer } from '../../../runtime/renderPage/getPageAssets/retrievePageAssetsProd.js';
|
|
15
15
|
function pluginBuildConfig() {
|
|
16
|
-
let config;
|
|
17
16
|
return [
|
|
18
|
-
{
|
|
19
|
-
name: 'vike:build:pluginBuildConfig:post1',
|
|
20
|
-
apply: 'build',
|
|
21
|
-
enforce: 'post',
|
|
22
|
-
configResolved: {
|
|
23
|
-
order: 'post',
|
|
24
|
-
handler(config_) {
|
|
25
|
-
config = config_;
|
|
26
|
-
handleAssetsManifest_workaroundCssTarget_part1(config);
|
|
27
|
-
},
|
|
28
|
-
},
|
|
29
|
-
},
|
|
30
17
|
{
|
|
31
18
|
name: 'vike:build:pluginBuildConfig:post2',
|
|
32
19
|
apply: 'build',
|
|
33
20
|
enforce: 'post',
|
|
34
21
|
configResolved: {
|
|
35
22
|
order: 'post',
|
|
36
|
-
async handler() {
|
|
37
|
-
|
|
23
|
+
async handler(config) {
|
|
24
|
+
handleAssetsManifest_alignCssTarget(config);
|
|
38
25
|
onSetupBuild();
|
|
39
26
|
assertRollupInput(config);
|
|
40
27
|
const entries = await getEntries(config);
|
|
@@ -196,6 +196,10 @@ const configDefinitionsBuiltIn = {
|
|
|
196
196
|
env: { client: true },
|
|
197
197
|
},
|
|
198
198
|
middleware: { env: { server: true }, cumulative: true, eager: true, global: true },
|
|
199
|
+
cli: {
|
|
200
|
+
env: { config: true },
|
|
201
|
+
global: true,
|
|
202
|
+
},
|
|
199
203
|
onPrerenderStart: {
|
|
200
204
|
env: { server: true, production: true },
|
|
201
205
|
eager: true,
|
|
@@ -740,10 +740,15 @@ function getConfigDefinitions(plusFilesRelevant, filter) {
|
|
|
740
740
|
});
|
|
741
741
|
objectEntries(meta).forEach(([configName, configDefinitionUserLand]) => {
|
|
742
742
|
if ('isDefinedByPeerDependency' in configDefinitionUserLand) {
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
743
|
+
/* vike-server@1.0.24 wrongfully sets `stream: { env: { config: true }, isDefinedByPeerDependency: true }`
|
|
744
|
+
assert(deepEqual(Object.keys(configDefinitionUserLand), ['isDefinedByPeerDependency']))
|
|
745
|
+
//*/
|
|
746
|
+
if (!configDefinitions[configName]) {
|
|
747
|
+
configDefinitions[configName] = {
|
|
748
|
+
env: { client: false, server: false, config: false },
|
|
749
|
+
};
|
|
750
|
+
}
|
|
751
|
+
return;
|
|
747
752
|
}
|
|
748
753
|
// User can override an existing config definition
|
|
749
754
|
configDefinitions[configName] = {
|
|
@@ -1,4 +1,7 @@
|
|
|
1
1
|
export { getProxyForPublicUsage };
|
|
2
|
+
export type { IgnoreWarning };
|
|
2
3
|
type Target = Record<string, unknown>;
|
|
3
4
|
type Fallback = (prop: string | symbol) => unknown;
|
|
4
5
|
declare function getProxyForPublicUsage<Obj extends Target>(obj: Obj, objName: 'pageContext' | 'globalContext' | 'prerenderContext' | 'vikeConfig', skipOnInternalProp?: true, fallback?: Fallback): Obj;
|
|
6
|
+
/** https://vike.dev/warning/internals */
|
|
7
|
+
type IgnoreWarning = (prop: string) => unknown;
|
|
@@ -10,25 +10,27 @@ import { NOT_SERIALIZABLE } from './NOT_SERIALIZABLE.js';
|
|
|
10
10
|
import { assert, assertUsage, assertWarning, getPropAccessNotation, isBrowser } from './utils.js';
|
|
11
11
|
function getProxyForPublicUsage(obj, objName, skipOnInternalProp, fallback) {
|
|
12
12
|
return new Proxy(obj, {
|
|
13
|
-
get:
|
|
13
|
+
get: (_, prop) => getProp(prop, obj, objName, skipOnInternalProp, fallback),
|
|
14
14
|
});
|
|
15
15
|
}
|
|
16
|
-
function
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
if (
|
|
16
|
+
function getProp(prop, obj, objName, skipOnInternalProp, fallback) {
|
|
17
|
+
const propStr = String(prop);
|
|
18
|
+
if (prop === '_isProxyObject')
|
|
19
|
+
return true;
|
|
20
|
+
if (!skipOnInternalProp) {
|
|
21
|
+
if (prop === 'ignoreWarning')
|
|
22
|
+
return (prop) => getProp(prop, obj, objName, true, fallback);
|
|
23
|
+
if (!globalThis.__VIKE__IS_CLIENT)
|
|
22
24
|
onInternalProp(propStr, objName);
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
25
|
+
}
|
|
26
|
+
if (fallback && !(prop in obj)) {
|
|
27
|
+
// Rudimentary flat pageContext implementation https://github.com/vikejs/vike/issues/1268
|
|
28
|
+
// Failed full-fledged implementation: https://github.com/vikejs/vike/pull/2458
|
|
29
|
+
return fallback(prop);
|
|
30
|
+
}
|
|
31
|
+
const val = obj[prop];
|
|
32
|
+
onNotSerializable(propStr, val, objName);
|
|
33
|
+
return val;
|
|
32
34
|
}
|
|
33
35
|
function onNotSerializable(propStr, val, objName) {
|
|
34
36
|
if (val !== NOT_SERIALIZABLE)
|
|
@@ -38,17 +40,15 @@ function onNotSerializable(propStr, val, objName) {
|
|
|
38
40
|
assertUsage(false, `Can't access ${objName}${propName} on the client side. Because it can't be serialized, see server logs.`);
|
|
39
41
|
}
|
|
40
42
|
function onInternalProp(propStr, objName) {
|
|
41
|
-
//
|
|
42
|
-
|
|
43
|
-
// - Where import.meta.CLIENT is defined by Vike
|
|
44
|
-
// - Using import.meta.env.CLIENT (note `.env.`) doesn't seem possible: https://github.com/brillout/playground_node_import.meta.env
|
|
45
|
-
// - If Rolldown Vite + Rolldowns always transpiles node_modules/ then we can simply use import.meta.env.SSR
|
|
46
|
-
if (isBrowser())
|
|
47
|
-
return;
|
|
43
|
+
// We must skip it on the client-side because of the reactivity mechanism of UI frameworks like Solid.
|
|
44
|
+
assert(!isBrowser());
|
|
48
45
|
// TO-DO/soon/proxy: remove this and only warn on built-in access instead
|
|
49
46
|
if (propStr === '_configFromHook')
|
|
50
47
|
return;
|
|
51
48
|
if (propStr.startsWith('_')) {
|
|
52
|
-
assertWarning(false, `Using internal ${objName}.${propStr}
|
|
49
|
+
assertWarning(false, `Using internal ${objName}.${propStr} — https://vike.dev/warning/internals`, {
|
|
50
|
+
onlyOnce: true,
|
|
51
|
+
showStackTrace: true,
|
|
52
|
+
});
|
|
53
53
|
}
|
|
54
54
|
}
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
export { modifyUrlSameOrigin };
|
|
2
2
|
// We don't move modifyUrlSameOrigin() to the modifyUrl.ts file because we plan to use modifyUrlSameOrigin() on the client-side:
|
|
3
3
|
// https://github.com/vikejs/vike/blob/c5a2de5e85262771f97851767c00ac35da69c64b/packages/vike/client/runtime-client-routing/navigate.ts#L4
|
|
4
|
-
import { createUrlFromComponents, isNotNullish_keyVal, parseUrl, objectFilter,
|
|
4
|
+
import { createUrlFromComponents, isNotNullish_keyVal, parseUrl, objectFilter, assertUsageUrlPathAbsolute, } from './utils.js';
|
|
5
5
|
function modifyUrlSameOrigin(url, modify) {
|
|
6
6
|
const urlParsed = parseUrl(url, '/');
|
|
7
7
|
// Pathname
|
|
8
8
|
const pathname = modify.pathname ?? urlParsed.pathnameOriginal;
|
|
9
|
-
|
|
9
|
+
assertUsageUrlPathAbsolute(pathname, 'modify.pathname');
|
|
10
10
|
// Search
|
|
11
11
|
let search = modify.search === null ? '' : !modify.search ? urlParsed.searchOriginal : resolveSearch(urlParsed, modify.search);
|
|
12
12
|
if (search === '?')
|
|
@@ -8,7 +8,7 @@ export { getPageContextFromAllRewrites };
|
|
|
8
8
|
export { AbortRender };
|
|
9
9
|
export { assertNoInfiniteAbortLoop };
|
|
10
10
|
import { isUserHookError } from '../hooks/execHook.js';
|
|
11
|
-
import { assert, assertInfo, assertUsage,
|
|
11
|
+
import { assert, assertInfo, assertUsage, assertUsageUrlPathAbsolute, assertUsageUrlRedirectTarget, assertWarning, checkType, hasProp, isBrowser, joinEnglish, objectAssign, truncateString, } from './utils.js';
|
|
12
12
|
import pc from '@brillout/picocolors';
|
|
13
13
|
/**
|
|
14
14
|
* Abort the rendering of the current page, and redirect the user to another URL instead.
|
|
@@ -66,7 +66,7 @@ function render_(urlOrStatusCode, abortReason, abortCall, abortCaller, pageConte
|
|
|
66
66
|
}
|
|
67
67
|
if (typeof urlOrStatusCode === 'string') {
|
|
68
68
|
const url = urlOrStatusCode;
|
|
69
|
-
|
|
69
|
+
assertUsageUrlPathAbsolute(url, getErrPrefix(abortCaller));
|
|
70
70
|
objectAssign(pageContextAbort, {
|
|
71
71
|
_urlRewrite: url,
|
|
72
72
|
});
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export { execHookOnBeforeRoute };
|
|
2
2
|
import { assertPageContextProvidedByUser } from '../assertPageContextProvidedByUser.js';
|
|
3
|
-
import { assertUsage, hasProp, isObjectWithKeys, objectAssign, assertWarning,
|
|
3
|
+
import { assertUsage, hasProp, isObjectWithKeys, objectAssign, assertWarning, assertUsageUrlAbsolute, joinEnglish, assert, } from './utils.js';
|
|
4
4
|
import { assertRouteParams, assertSyncRouting } from './resolveRouteFunction.js';
|
|
5
5
|
import pc from '@brillout/picocolors';
|
|
6
6
|
import { execHookDirectSync } from '../hooks/execHook.js';
|
|
@@ -65,8 +65,8 @@ async function getPageContextFromHook(onBeforeRouteHook, pageContext) {
|
|
|
65
65
|
delete hookReturn.pageContext.urlOriginal;
|
|
66
66
|
}
|
|
67
67
|
if (hasProp(hookReturn.pageContext, 'urlLogical')) {
|
|
68
|
-
|
|
69
|
-
// We
|
|
68
|
+
assertUsageUrlAbsolute(
|
|
69
|
+
// We type-cast instead of assertUsage() validation in order to save client-side KBs
|
|
70
70
|
hookReturn.pageContext.urlLogical, `${errPrefix} returned ${pc.cyan('{ pageContext: { urlLogical } }')} and ${pc.cyan('urlLogical')}`);
|
|
71
71
|
}
|
|
72
72
|
assertPageContextProvidedByUser(hookReturn.pageContext, {
|
|
@@ -42,7 +42,8 @@ import type { InjectFilterEntry } from './index.js';
|
|
|
42
42
|
import type { VikeVitePluginOptions } from '../node/vite/index.js';
|
|
43
43
|
import type { Vike } from './VikeNamespace.js';
|
|
44
44
|
import type { HooksTimeoutProvidedByUser } from '../shared/hooks/getHook.js';
|
|
45
|
-
import type {
|
|
45
|
+
import type { PageContextClient, PageContextServer } from './PageContext.js';
|
|
46
|
+
import type { GlobalContext } from './GlobalContext.js';
|
|
46
47
|
import type { InlineConfig } from 'vite';
|
|
47
48
|
import type { PassToClientPublic } from '../node/runtime/renderPage/html/serializeContext.js';
|
|
48
49
|
type HookNameOld = HookName | HookNameOldDesign;
|
|
@@ -512,6 +513,10 @@ type ConfigBuiltIn = {
|
|
|
512
513
|
keepScrollPosition?: KeepScrollPosition;
|
|
513
514
|
/** @experimental */
|
|
514
515
|
middleware?: Function;
|
|
516
|
+
/** @experimental */
|
|
517
|
+
cli?: {
|
|
518
|
+
preview?: boolean | 'vite';
|
|
519
|
+
};
|
|
515
520
|
};
|
|
516
521
|
type ConfigBuiltInResolved = {
|
|
517
522
|
passToClient?: string[][];
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
export type { GlobalContext };
|
|
2
|
+
export type { GlobalContextServer };
|
|
3
|
+
export type { GlobalContextClient };
|
|
4
|
+
export type { GlobalContextClientWithServerRouting };
|
|
5
|
+
import type { GlobalContextServerInternal } from '../node/runtime/globalContext.js';
|
|
6
|
+
import type { GlobalContextClientInternalWithServerRouting } from '../client/runtime-server-routing/getGlobalContextClientInternal.js';
|
|
7
|
+
import type { GlobalContextBasePublic } from '../shared/createGlobalContextShared.js';
|
|
8
|
+
import type { GlobalContextClientInternal } from '../client/runtime-client-routing/getGlobalContextClientInternal.js';
|
|
9
|
+
import type { IgnoreWarning } from '../shared/getProxyForPublicUsage.js';
|
|
10
|
+
type GlobalContext = GlobalContextServer | GlobalContextClient;
|
|
11
|
+
type GlobalContextServer = GlobalContextCommon & Pick<GlobalContextServerInternal, 'assetsManifest' | 'config' | 'viteConfig' | 'viteConfigRuntime' | 'pages' | 'baseServer' | 'baseAssets' | 'isClientSide'> & Vike.GlobalContext & Vike.GlobalContextServer;
|
|
12
|
+
type GlobalContextClient = GlobalContextCommon & GlobalContextBasePublic & Pick<GlobalContextClientInternal, 'isClientSide'> & Vike.GlobalContext & Vike.GlobalContextClient & {};
|
|
13
|
+
type GlobalContextClientWithServerRouting = GlobalContextCommon & GlobalContextBasePublic & Pick<GlobalContextClientInternalWithServerRouting, 'isClientSide'> & Vike.GlobalContext & Vike.GlobalContextClient & {};
|
|
14
|
+
type GlobalContextCommon = {
|
|
15
|
+
/** https://vike.dev/warning/internals */
|
|
16
|
+
ignoreWarning?: IgnoreWarning;
|
|
17
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -1,12 +1,8 @@
|
|
|
1
1
|
export type { PageContext };
|
|
2
2
|
export type { PageContextServer };
|
|
3
3
|
export type { PageContextClient };
|
|
4
|
-
export type { GlobalContext };
|
|
5
|
-
export type { GlobalContextServer };
|
|
6
|
-
export type { GlobalContextClient };
|
|
7
4
|
export type { PageContextWithServerRouting };
|
|
8
5
|
export type { PageContextClientWithServerRouting };
|
|
9
|
-
export type { GlobalContextClientWithServerRouting };
|
|
10
6
|
export type { PageContextInternalServer };
|
|
11
7
|
export type { PageContextInternalClient };
|
|
12
8
|
export type { PageContextInternalClient_ServerRouting };
|
|
@@ -18,13 +14,11 @@ import type { PageContextUrlInternal, PageContextUrlClient, PageContextUrlServer
|
|
|
18
14
|
import type { From, PageContextConfig, Source, Sources } from '../shared/page-configs/resolveVikeConfigPublic.js';
|
|
19
15
|
import type { Config } from './Config.js';
|
|
20
16
|
import type { AbortStatusCode } from '../shared/route/abort.js';
|
|
21
|
-
import type { GlobalContextServer } from '
|
|
22
|
-
import type {
|
|
23
|
-
import type { GlobalContextClientWithServerRouting } from '../client/runtime-server-routing/getGlobalContextClientInternal.js';
|
|
17
|
+
import type { GlobalContextClient, GlobalContextServer, GlobalContextClientWithServerRouting } from './GlobalContext.js';
|
|
18
|
+
import type { IgnoreWarning } from '../shared/getProxyForPublicUsage.js';
|
|
24
19
|
type PageContextServer<Data = unknown> = PageContextBuiltInServer<Data> & Vike.PageContext & Vike.PageContextServer;
|
|
25
20
|
type PageContext<Data = unknown> = PageContextClient<Data> | PageContextServer<Data>;
|
|
26
21
|
type PageContextClient<Data = unknown> = PageContextBuiltInClientWithClientRouting<Data> & Vike.PageContext & Vike.PageContextClient;
|
|
27
|
-
type GlobalContext = GlobalContextServer | GlobalContextClient;
|
|
28
22
|
type PageContextWithServerRouting<Data = unknown> = PageContextClientWithServerRouting<Data> | PageContextServer<Data>;
|
|
29
23
|
type PageContextClientWithServerRouting<Data = unknown> = PageContextBuiltInClientWithServerRouting<Data> & Vike.PageContext & Vike.PageContextClient;
|
|
30
24
|
type PageContextBuiltInCommon<Data> = PageContextConfig & {
|
|
@@ -134,6 +128,8 @@ type PageContextBuiltInCommon<Data> = PageContextConfig & {
|
|
|
134
128
|
* https://vike.dev/pageContext#isBaseMissing
|
|
135
129
|
*/
|
|
136
130
|
isBaseMissing?: true;
|
|
131
|
+
/** https://vike.dev/warning/internals */
|
|
132
|
+
ignoreWarning?: IgnoreWarning;
|
|
137
133
|
};
|
|
138
134
|
type PageContextBuiltInServer<Data> = PageContextBuiltInCommon<Data> & PageContextUrlServer & {
|
|
139
135
|
/**
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
export type { PageContext, PageContextServer, PageContextClient,
|
|
1
|
+
export type { PageContext, PageContextServer, PageContextClient, PageContextWithServerRouting, PageContextClientWithServerRouting, } from './PageContext.js';
|
|
2
|
+
export type { GlobalContext, GlobalContextServer, GlobalContextClient, GlobalContextClientWithServerRouting, } from './GlobalContext.js';
|
|
2
3
|
export type { PrerenderContextPublic as PrerenderContext } from '../node/prerender/runPrerender.js';
|
|
3
4
|
export type { PageContextBuiltInServer } from './PageContext.js';
|
|
4
5
|
export type { PageContextBuiltInClientWithClientRouting } from './PageContext.js';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const PROJECT_VERSION: "0.4.
|
|
1
|
+
export declare const PROJECT_VERSION: "0.4.243-commit-6ce9ef3";
|
|
@@ -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.243-commit-6ce9ef3';
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
export { parseUrl };
|
|
2
|
-
export {
|
|
2
|
+
export { assertUsageUrlAbsolute };
|
|
3
|
+
export { assertUsageUrlPathAbsolute };
|
|
3
4
|
export { assertUsageUrlRedirectTarget };
|
|
4
5
|
export { isUrl };
|
|
5
6
|
export { isUri };
|
|
@@ -52,5 +53,6 @@ declare function isUrlRedirectTarget(url: string): boolean;
|
|
|
52
53
|
declare function isUrlRelative(url: string): boolean;
|
|
53
54
|
declare function isUrlExternal(url: string): boolean;
|
|
54
55
|
declare function isUri(uri: string): boolean;
|
|
55
|
-
declare function
|
|
56
|
+
declare function assertUsageUrlAbsolute(url: string, errPrefix: string): void;
|
|
57
|
+
declare function assertUsageUrlPathAbsolute(url: string, errPrefix: string): void;
|
|
56
58
|
declare function assertUsageUrlRedirectTarget(url: string, errPrefix: string, isUnresolved?: true): void;
|
|
@@ -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.243-commit-6ce9ef3",
|
|
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"
|