vike 0.4.198 → 0.4.199

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.
@@ -22,6 +22,9 @@ function fileEnv() {
22
22
  return;
23
23
  if (skip(id))
24
24
  return;
25
+ // For `.vue` files: https://github.com/vikejs/vike/issues/1912#issuecomment-2394981475
26
+ if (id.endsWith('?direct'))
27
+ id = id.slice(0, -1 * '?direct'.length);
25
28
  const moduleInfo = viteDevServer.moduleGraph.getModuleById(id);
26
29
  (0, utils_js_1.assert)(moduleInfo);
27
30
  const importers = Array.from(moduleInfo.importers)
@@ -2,4 +2,4 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.PROJECT_VERSION = void 0;
4
4
  // Automatically updated by @brillout/release-me
5
- exports.PROJECT_VERSION = '0.4.198';
5
+ exports.PROJECT_VERSION = '0.4.199';
@@ -28,9 +28,8 @@ declare function populatePageContextPrefetchCache(pageContext: PageContextForPre
28
28
  *
29
29
  * @param url - The URL of the page you want to prefetch.
30
30
  */
31
- declare function prefetch(url: string, options?: {
31
+ declare function prefetch(url: string, options_?: {
32
32
  pageContext?: boolean;
33
- staticAssets?: boolean;
34
33
  }): Promise<void>;
35
34
  declare function addLinkPrefetchHandlers(): void;
36
35
  declare function initLinkPrefetchHandlers(): void;
@@ -93,7 +93,18 @@ function getResultMaxAge() {
93
93
  *
94
94
  * @param url - The URL of the page you want to prefetch.
95
95
  */
96
- async function prefetch(url, options) {
96
+ async function prefetch(url,
97
+ /* TODO/pageContext-prefetch
98
+ options?: {
99
+ pageContext?: boolean
100
+ staticAssets?: boolean
101
+ }
102
+ */
103
+ options_) {
104
+ const options = {
105
+ staticAssets: true,
106
+ pageContext: options_?.pageContext ?? false
107
+ };
97
108
  assertUsage(checkIfClientRouting(), 'prefetch() only works with Client Routing, see https://vike.dev/prefetch', {
98
109
  showStackTrace: true
99
110
  });
@@ -115,6 +126,7 @@ async function prefetch(url, options) {
115
126
  })(),
116
127
  (async () => {
117
128
  if (options?.pageContext !== false) {
129
+ assertUsage(isBrilloutDocpress(), "prefetching pageContext isn't supported yet");
118
130
  const resultMaxAge = typeof options?.pageContext === 'number' ? options.pageContext : null;
119
131
  await prefetchPageContextFromServerHooks(pageContextLink, resultMaxAge);
120
132
  }
@@ -183,8 +195,14 @@ async function prefetchOnEvent(linkTag, event) {
183
195
  prefetchSettings = getPrefetchSettings(pageContextCurrent, linkTag);
184
196
  }
185
197
  else {
186
- // TODO/pageContext-prefetch: remove this dirty hack used by @brillout/docpress and, instead, use Vike's default if pageContextCurrent isn't defined yet.
187
- prefetchSettings = { staticAssets: 'hover', pageContext: Infinity };
198
+ if (isBrilloutDocpress()) {
199
+ // TODO/pageContext-prefetch: remove this dirty hack used by @brillout/docpress and, instead, use Vike's default if pageContextCurrent isn't defined yet.
200
+ prefetchSettings = { staticAssets: 'hover', pageContext: Infinity };
201
+ }
202
+ else {
203
+ // TODO/pageContext-prefetch: consider pageContextLink
204
+ return;
205
+ }
188
206
  }
189
207
  // Check again in case DOM was manipulated since last check
190
208
  if (skipLink(linkTag))
@@ -35,10 +35,6 @@ async function renderPageClientSide(renderArgs) {
35
35
  const { previousPageContext } = globalObject;
36
36
  addLinkPrefetchHandlers_unwatch();
37
37
  const { isRenderOutdated, setHydrationCanBeAborted, isFirstRender } = getIsRenderOutdated();
38
- // Note that pageContext.isHydration isn't equivalent to isFirstRender
39
- // - Thus pageContext.isHydration isn't equivalent to !pageContext.isClientSideNavigation
40
- // - `pageContext.isHydration === !isFirstRender && !isErrorPage`
41
- assert(isClientSideNavigation === !isFirstRender);
42
38
  assertNoInfiniteAbortLoop(pageContextsFromRewrite.length, redirectCount);
43
39
  if (globalObject.clientRoutingIsDisabled) {
44
40
  redirectHard(urlOriginal);
@@ -17,6 +17,9 @@ function fileEnv() {
17
17
  return;
18
18
  if (skip(id))
19
19
  return;
20
+ // For `.vue` files: https://github.com/vikejs/vike/issues/1912#issuecomment-2394981475
21
+ if (id.endsWith('?direct'))
22
+ id = id.slice(0, -1 * '?direct'.length);
20
23
  const moduleInfo = viteDevServer.moduleGraph.getModuleById(id);
21
24
  assert(moduleInfo);
22
25
  const importers = Array.from(moduleInfo.importers)
@@ -34,6 +34,7 @@ export type { KeepScrollPosition };
34
34
  import type { PrefetchSetting, PrefetchStaticAssets } from '../../client/client-routing-runtime/prefetch/PrefetchSetting.js';
35
35
  import type { ConfigDefinition } from '../../node/plugin/plugins/importUserCode/v1-design/getVikeConfig/configDefinitionsBuiltIn.js';
36
36
  import type { DocumentHtml } from '../../node/runtime/html/renderHtml.js';
37
+ import type { InjectFilterEntry } from '../../types/index.js';
37
38
  import type { ConfigVikeUserProvided } from '../ConfigVike.js';
38
39
  import type { Vike, VikePackages } from '../VikeNamespace.js';
39
40
  import type { HooksTimeoutProvidedByUser } from '../hooks/getHook.js';
@@ -190,17 +191,16 @@ type OnRenderClientSync = (pageContext: PageContextClient) => void;
190
191
  *
191
192
  * https://vike.dev/onRenderHtml
192
193
  */
193
- type OnRenderHtmlAsync = (pageContext: PageContextServer) => Promise<DocumentHtml | {
194
- documentHtml: DocumentHtml;
195
- pageContext: OnRenderHtmlPageContextReturn | (() => Promise<OnRenderHtmlPageContextReturn> | OnRenderHtmlPageContextReturn);
196
- }>;
194
+ type OnRenderHtmlAsync = (pageContext: PageContextServer) => Promise<OnRenderHtmlReturn>;
197
195
  /** Hook called when page is rendered to HTML on the server-side.
198
196
  *
199
197
  * https://vike.dev/onRenderHtml
200
198
  */
201
- type OnRenderHtmlSync = (pageContext: PageContextServer) => DocumentHtml | {
202
- documentHtml: DocumentHtml;
203
- pageContext: OnRenderHtmlPageContextReturn | (() => Promise<OnRenderHtmlPageContextReturn> | OnRenderHtmlPageContextReturn);
199
+ type OnRenderHtmlSync = (pageContext: PageContextServer) => OnRenderHtmlReturn;
200
+ type OnRenderHtmlReturn = DocumentHtml | {
201
+ injectFilter?: (assets: InjectFilterEntry[]) => void;
202
+ documentHtml?: DocumentHtml;
203
+ pageContext?: OnRenderHtmlPageContextReturn | (() => Promise<OnRenderHtmlPageContextReturn> | OnRenderHtmlPageContextReturn);
204
204
  };
205
205
  type OnRenderHtmlPageContextReturn = Partial<Vike.PageContext & {
206
206
  /** See https://vike.dev/streaming */
@@ -1 +1 @@
1
- export declare const PROJECT_VERSION: "0.4.198";
1
+ export declare const PROJECT_VERSION: "0.4.199";
@@ -1,2 +1,2 @@
1
1
  // Automatically updated by @brillout/release-me
2
- export const PROJECT_VERSION = '0.4.198';
2
+ export const PROJECT_VERSION = '0.4.199';
@@ -1,4 +1,4 @@
1
1
  export declare const projectInfo: {
2
2
  projectName: "Vike";
3
- projectVersion: "0.4.198";
3
+ projectVersion: "0.4.199";
4
4
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vike",
3
- "version": "0.4.198",
3
+ "version": "0.4.199",
4
4
  "repository": "https://github.com/vikejs/vike",
5
5
  "exports": {
6
6
  "./server": {