vike-lite 1.10.1 → 1.11.1
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/client/router.d.mts +3 -0
- package/dist/client/router.mjs +4 -1
- package/dist/index.d.mts +16 -6
- package/package.json +1 -1
package/dist/client/router.d.mts
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { PageContext } from "../index.mjs";
|
|
2
|
+
|
|
1
3
|
//#region src/client/router.d.ts
|
|
2
4
|
/**
|
|
3
5
|
* Change page programmatically on the client without reloading the browser.
|
|
@@ -6,6 +8,7 @@
|
|
|
6
8
|
*/
|
|
7
9
|
declare function navigate(url: string, options?: {
|
|
8
10
|
keepScrollPosition?: boolean;
|
|
11
|
+
pageContext?: Partial<PageContext>;
|
|
9
12
|
}): void;
|
|
10
13
|
declare const reload: () => Promise<void>;
|
|
11
14
|
//#endregion
|
package/dist/client/router.mjs
CHANGED
|
@@ -10,7 +10,10 @@ function navigate(url, options) {
|
|
|
10
10
|
let finalUrl = url;
|
|
11
11
|
if (finalUrl.startsWith("/")) finalUrl = (BASE_URL.endsWith("/") ? BASE_URL.slice(0, -1) : BASE_URL) + (finalUrl === "/" ? "" : finalUrl);
|
|
12
12
|
globalThis.history.pushState({ triggeredBy: "vike-lite" }, "", finalUrl);
|
|
13
|
-
globalThis.dispatchEvent(new CustomEvent("vike-navigate", { detail: {
|
|
13
|
+
globalThis.dispatchEvent(new CustomEvent("vike-navigate", { detail: {
|
|
14
|
+
keepScrollPosition: options?.keepScrollPosition,
|
|
15
|
+
pageContext: options?.pageContext
|
|
16
|
+
} }));
|
|
14
17
|
}
|
|
15
18
|
const reload = () => {
|
|
16
19
|
return new Promise((resolve) => {
|
package/dist/index.d.mts
CHANGED
|
@@ -1,16 +1,26 @@
|
|
|
1
1
|
//#region src/index.d.ts
|
|
2
|
-
type
|
|
2
|
+
type PageContextBase = {
|
|
3
3
|
routeParams: Record<string, string>;
|
|
4
4
|
urlOriginal: string;
|
|
5
5
|
urlPathname: string;
|
|
6
|
-
|
|
6
|
+
search: string;
|
|
7
7
|
title?: string;
|
|
8
|
-
nonce?: string;
|
|
9
8
|
is404?: boolean;
|
|
10
9
|
is500?: boolean;
|
|
11
10
|
errorMessage?: string;
|
|
12
11
|
};
|
|
13
|
-
type
|
|
14
|
-
|
|
12
|
+
type PageContext<Data = unknown> = PageContextBase & (unknown extends Data ? {
|
|
13
|
+
data?: Data;
|
|
14
|
+
} : {
|
|
15
|
+
data: Data;
|
|
16
|
+
});
|
|
17
|
+
type PageContextServer<Data = unknown> = PageContext<Data> & {
|
|
18
|
+
isClientSide: false;
|
|
19
|
+
nonce?: string;
|
|
20
|
+
};
|
|
21
|
+
type PageContextClient = PageContextBase & {
|
|
22
|
+
isClientSide: true;
|
|
23
|
+
isHydration?: boolean;
|
|
24
|
+
};
|
|
15
25
|
//#endregion
|
|
16
|
-
export {
|
|
26
|
+
export { PageContext, PageContextClient, PageContextServer };
|