vike 0.4.199-commit-33e1230 → 0.4.199-commit-43cc34a

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.
@@ -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.199-commit-33e1230';
5
+ exports.PROJECT_VERSION = '0.4.199-commit-43cc34a';
@@ -3,7 +3,7 @@ export { updateState };
3
3
  export { onPopState };
4
4
  declare function initOnPopState(): void;
5
5
  type Listener = (arg: {
6
- previousState: ReturnType<typeof getState>;
6
+ previous: ReturnType<typeof getState>;
7
7
  }) => void | boolean;
8
8
  /** Control client-side navigation.
9
9
  *
@@ -12,7 +12,7 @@ type Listener = (arg: {
12
12
  declare function onPopState(listener: Listener): void;
13
13
  declare function getState(): {
14
14
  url: `/${string}`;
15
- historyState: {
15
+ state: {
16
16
  timestamp: number;
17
17
  scrollPosition: null | import("./history.js").ScrollPosition;
18
18
  triggeredBy: "user" | "vike" | "browser";
@@ -17,14 +17,14 @@ function initOnPopState() {
17
17
  // - `location.hash = 'some-hash'`
18
18
  // - The `event` argument of `window.addEventListener('popstate', (event) => /*...*/)` is useless: the History API doesn't provide the previous state (the popped state), see https://stackoverflow.com/questions/48055323/is-history-state-always-the-same-as-popstate-event-state
19
19
  window.addEventListener('popstate', async () => {
20
- const { previousState } = globalObject;
21
- const currentState = getState();
22
- globalObject.previousState = currentState;
23
- const scrollTarget = currentState.historyState?.scrollPosition || undefined;
24
- const isHashNavigation = removeHash(currentState.url) === removeHash(previousState.url);
25
- const isBackwardNavigation = !currentState.historyState?.timestamp || !previousState.historyState?.timestamp
20
+ const previous = globalObject.previousState;
21
+ const current = getState();
22
+ globalObject.previousState = current;
23
+ const scrollTarget = current.state?.scrollPosition || undefined;
24
+ const isHashNavigation = removeHash(current.url) === removeHash(previous.url);
25
+ const isBackwardNavigation = !current.state?.timestamp || !previous.state?.timestamp
26
26
  ? null
27
- : currentState.historyState.timestamp < previousState.historyState.timestamp;
27
+ : current.state.timestamp < previous.state.timestamp;
28
28
  // - `history.state === null` when:
29
29
  // - Click on `<a href="#some-hash" />` (note that Vike's `initOnLinkClick()` handler skips hash links)
30
30
  // - `location.hash = 'some-hash'`
@@ -53,7 +53,7 @@ function initOnPopState() {
53
53
  }
54
54
  let abort;
55
55
  globalObject.listeners.forEach((listener) => {
56
- abort || (abort = listener({ previousState }));
56
+ abort || (abort = listener({ previous }));
57
57
  });
58
58
  if (abort)
59
59
  return;
@@ -70,7 +70,7 @@ function onPopState(listener) {
70
70
  function getState() {
71
71
  return {
72
72
  url: getCurrentUrl(),
73
- historyState: getHistoryState()
73
+ state: getHistoryState()
74
74
  };
75
75
  }
76
76
  function removeHash(url) {
@@ -1 +1 @@
1
- export declare const PROJECT_VERSION: "0.4.199-commit-33e1230";
1
+ export declare const PROJECT_VERSION: "0.4.199-commit-43cc34a";
@@ -1,2 +1,2 @@
1
1
  // Automatically updated by @brillout/release-me
2
- export const PROJECT_VERSION = '0.4.199-commit-33e1230';
2
+ export const PROJECT_VERSION = '0.4.199-commit-43cc34a';
@@ -1,4 +1,4 @@
1
1
  export declare const projectInfo: {
2
2
  projectName: "Vike";
3
- projectVersion: "0.4.199-commit-33e1230";
3
+ projectVersion: "0.4.199-commit-43cc34a";
4
4
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vike",
3
- "version": "0.4.199-commit-33e1230",
3
+ "version": "0.4.199-commit-43cc34a",
4
4
  "repository": "https://github.com/vikejs/vike",
5
5
  "exports": {
6
6
  "./server": {