@ktjs/router 0.14.7 → 0.14.8

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.
@@ -463,7 +463,6 @@ var __ktjs_router__ = (function (exports) {
463
463
  };
464
464
  };
465
465
  // # register events
466
- // hash mode: listen to hashchange
467
466
  window.addEventListener('hashchange', () => {
468
467
  const hash = window.location.hash.slice(1);
469
468
  const [path] = hash.split('?');
@@ -508,10 +507,7 @@ var __ktjs_router__ = (function (exports) {
508
507
  executeAfterHooksSync(to, history[history.length - 2] ?? null);
509
508
  });
510
509
  // # initialize
511
- normalize(config.routes, '/');
512
- const { findByName, match } = createMatcher(routes);
513
- // Router instance
514
- return {
510
+ const instance = {
515
511
  get current() {
516
512
  return current;
517
513
  },
@@ -540,6 +536,13 @@ var __ktjs_router__ = (function (exports) {
540
536
  window.history.forward();
541
537
  },
542
538
  };
539
+ normalize(config.routes, '/');
540
+ const { findByName, match } = createMatcher(routes);
541
+ const currentHash = window.location.hash.slice(1);
542
+ if (currentHash) {
543
+ instance.push(currentHash);
544
+ }
545
+ return instance;
543
546
  };
544
547
 
545
548
  exports.KTRouter = KTRouter;
@@ -598,7 +598,6 @@ var __ktjs_router__ = (function (exports) {
598
598
  };
599
599
  };
600
600
  // # register events
601
- // hash mode: listen to hashchange
602
601
  window.addEventListener('hashchange', function () {
603
602
  var _a, _b;
604
603
  var hash = window.location.hash.slice(1);
@@ -644,10 +643,7 @@ var __ktjs_router__ = (function (exports) {
644
643
  executeAfterHooksSync(to, (_b = history[history.length - 2]) !== null && _b !== void 0 ? _b : null);
645
644
  });
646
645
  // # initialize
647
- normalize(config.routes, '/');
648
- var _g = createMatcher(routes), findByName = _g.findByName, match = _g.match;
649
- // Router instance
650
- return {
646
+ var instance = {
651
647
  get current() {
652
648
  return current;
653
649
  },
@@ -676,6 +672,13 @@ var __ktjs_router__ = (function (exports) {
676
672
  window.history.forward();
677
673
  },
678
674
  };
675
+ normalize(config.routes, '/');
676
+ var _g = createMatcher(routes), findByName = _g.findByName, match = _g.match;
677
+ var currentHash = window.location.hash.slice(1);
678
+ if (currentHash) {
679
+ instance.push(currentHash);
680
+ }
681
+ return instance;
679
682
  };
680
683
 
681
684
  exports.KTRouter = KTRouter;
package/dist/index.mjs CHANGED
@@ -460,7 +460,6 @@ const createRouter = (config) => {
460
460
  };
461
461
  };
462
462
  // # register events
463
- // hash mode: listen to hashchange
464
463
  window.addEventListener('hashchange', () => {
465
464
  const hash = window.location.hash.slice(1);
466
465
  const [path] = hash.split('?');
@@ -505,10 +504,7 @@ const createRouter = (config) => {
505
504
  executeAfterHooksSync(to, history[history.length - 2] ?? null);
506
505
  });
507
506
  // # initialize
508
- normalize(config.routes, '/');
509
- const { findByName, match } = createMatcher(routes);
510
- // Router instance
511
- return {
507
+ const instance = {
512
508
  get current() {
513
509
  return current;
514
510
  },
@@ -537,6 +533,13 @@ const createRouter = (config) => {
537
533
  window.history.forward();
538
534
  },
539
535
  };
536
+ normalize(config.routes, '/');
537
+ const { findByName, match } = createMatcher(routes);
538
+ const currentHash = window.location.hash.slice(1);
539
+ if (currentHash) {
540
+ instance.push(currentHash);
541
+ }
542
+ return instance;
540
543
  };
541
544
 
542
545
  export { KTRouter, createRouter };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ktjs/router",
3
- "version": "0.14.7",
3
+ "version": "0.14.8",
4
4
  "description": "Router for kt.js - client-side routing with navigation guards",
5
5
  "type": "module",
6
6
  "module": "./dist/index.mjs",