@ktjs/router 0.7.3 → 0.13.0

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/README.md CHANGED
@@ -2,10 +2,14 @@
2
2
 
3
3
  <img src="https://raw.githubusercontent.com/baendlorel/kt.js/dev/.assets/ktjs-0.0.1.svg" alt="KT.js Logo" width="150"/>
4
4
 
5
- > 📦 Part of [KT.js](https://raw.githubusercontent.com/baendlorel/kt.js/dev/README.md) - A simple and easy-to-use web framework that never re-renders.
5
+ [![npm version](https://img.shields.io/npm/v/@ktjs/router.svg)](https://www.npmjs.com/package/@ktjs/router)
6
+
7
+ > 📦 Part of [KT.js](https://github.com/baendlorel/kt.js) - A simple and easy-to-use web framework that never re-renders.
6
8
 
7
9
  Client-side router with navigation guards for KT.js.
8
10
 
11
+ **Current Version:** 0.13.0
12
+
9
13
  ## Overview
10
14
 
11
15
  `@ktjs/router` is a lightweight, hash-based client-side router with powerful navigation guards and async/sync auto-adaptation. It provides all the essential routing features you need without the bloat.
@@ -268,9 +268,9 @@ var __ktjs_router__ = (function (exports) {
268
268
  const to = {
269
269
  path: targetPath,
270
270
  name: matched.route.name,
271
- params: { ...matched.params, ...(options.params || {}) },
272
- query: options.query || {},
273
- meta: matched.route.meta || {},
271
+ params: { ...matched.params, ...(options.params ?? {}) },
272
+ query: options.query ?? {},
273
+ meta: matched.route.meta ?? {},
274
274
  matched: matched.result,
275
275
  };
276
276
  return {
@@ -303,7 +303,7 @@ var __ktjs_router__ = (function (exports) {
303
303
  current = to;
304
304
  history.push(to);
305
305
  // Execute after hooks
306
- executeAfterHooksSync(to, history[history.length - 2] || null);
306
+ executeAfterHooksSync(to, history[history.length - 2] ?? null);
307
307
  return true;
308
308
  }
309
309
  catch (error) {
@@ -330,7 +330,7 @@ var __ktjs_router__ = (function (exports) {
330
330
  else {
331
331
  window.history.pushState({ path: to.path }, '', url);
332
332
  }
333
- executeAfterHooks(to, history[history.length - 2] || null);
333
+ executeAfterHooks(to, history[history.length - 2] ?? null);
334
334
  return true;
335
335
  }
336
336
  catch (error) {
@@ -327,7 +327,7 @@ var __ktjs_router__ = (function (exports) {
327
327
  });
328
328
  }); };
329
329
  var navigatePrepare = function (options) {
330
- var _a, _b, _c;
330
+ var _a, _b, _c, _d, _e, _f;
331
331
  // Resolve target route
332
332
  var targetPath;
333
333
  var targetRoute;
@@ -361,19 +361,20 @@ var __ktjs_router__ = (function (exports) {
361
361
  var to = {
362
362
  path: targetPath,
363
363
  name: matched.route.name,
364
- params: __assign(__assign({}, matched.params), (options.params || {})),
365
- query: options.query || {},
366
- meta: matched.route.meta || {},
364
+ params: __assign(__assign({}, matched.params), ((_b = options.params) !== null && _b !== void 0 ? _b : {})),
365
+ query: (_c = options.query) !== null && _c !== void 0 ? _c : {},
366
+ meta: (_d = matched.route.meta) !== null && _d !== void 0 ? _d : {},
367
367
  matched: matched.result,
368
368
  };
369
369
  return {
370
- guardLevel: (_b = options.guardLevel) !== null && _b !== void 0 ? _b : 15 /* GuardLevel.Default */,
371
- replace: (_c = options.replace) !== null && _c !== void 0 ? _c : false,
370
+ guardLevel: (_e = options.guardLevel) !== null && _e !== void 0 ? _e : 15 /* GuardLevel.Default */,
371
+ replace: (_f = options.replace) !== null && _f !== void 0 ? _f : false,
372
372
  to: to,
373
373
  fullPath: fullPath,
374
374
  };
375
375
  };
376
376
  var navigateSync = function (options) {
377
+ var _a;
377
378
  try {
378
379
  var prep = navigatePrepare(options);
379
380
  if (!prep) {
@@ -396,7 +397,7 @@ var __ktjs_router__ = (function (exports) {
396
397
  current = to;
397
398
  history.push(to);
398
399
  // Execute after hooks
399
- executeAfterHooksSync(to, history[history.length - 2] || null);
400
+ executeAfterHooksSync(to, (_a = history[history.length - 2]) !== null && _a !== void 0 ? _a : null);
400
401
  return true;
401
402
  }
402
403
  catch (error) {
@@ -406,10 +407,11 @@ var __ktjs_router__ = (function (exports) {
406
407
  };
407
408
  var navigateAsync = function (options) { return __awaiter(void 0, void 0, void 0, function () {
408
409
  var prep, guardLevel, replace, to, fullPath, passed, url, error_2;
409
- return __generator(this, function (_a) {
410
- switch (_a.label) {
410
+ var _a;
411
+ return __generator(this, function (_b) {
412
+ switch (_b.label) {
411
413
  case 0:
412
- _a.trys.push([0, 2, , 3]);
414
+ _b.trys.push([0, 2, , 3]);
413
415
  prep = navigatePrepare(options);
414
416
  if (!prep) {
415
417
  return [2 /*return*/, false];
@@ -417,7 +419,7 @@ var __ktjs_router__ = (function (exports) {
417
419
  guardLevel = prep.guardLevel, replace = prep.replace, to = prep.to, fullPath = prep.fullPath;
418
420
  return [4 /*yield*/, executeGuards(to, current, guardLevel)];
419
421
  case 1:
420
- passed = _a.sent();
422
+ passed = _b.sent();
421
423
  if (!passed) {
422
424
  return [2 /*return*/, false];
423
425
  }
@@ -428,10 +430,10 @@ var __ktjs_router__ = (function (exports) {
428
430
  else {
429
431
  window.history.pushState({ path: to.path }, '', url);
430
432
  }
431
- executeAfterHooks(to, history[history.length - 2] || null);
433
+ executeAfterHooks(to, (_a = history[history.length - 2]) !== null && _a !== void 0 ? _a : null);
432
434
  return [2 /*return*/, true];
433
435
  case 2:
434
- error_2 = _a.sent();
436
+ error_2 = _b.sent();
435
437
  onError(error_2);
436
438
  return [2 /*return*/, false];
437
439
  case 3: return [2 /*return*/];
package/dist/index.mjs CHANGED
@@ -265,9 +265,9 @@ const createRouter = (config) => {
265
265
  const to = {
266
266
  path: targetPath,
267
267
  name: matched.route.name,
268
- params: { ...matched.params, ...(options.params || {}) },
269
- query: options.query || {},
270
- meta: matched.route.meta || {},
268
+ params: { ...matched.params, ...(options.params ?? {}) },
269
+ query: options.query ?? {},
270
+ meta: matched.route.meta ?? {},
271
271
  matched: matched.result,
272
272
  };
273
273
  return {
@@ -300,7 +300,7 @@ const createRouter = (config) => {
300
300
  current = to;
301
301
  history.push(to);
302
302
  // Execute after hooks
303
- executeAfterHooksSync(to, history[history.length - 2] || null);
303
+ executeAfterHooksSync(to, history[history.length - 2] ?? null);
304
304
  return true;
305
305
  }
306
306
  catch (error) {
@@ -327,7 +327,7 @@ const createRouter = (config) => {
327
327
  else {
328
328
  window.history.pushState({ path: to.path }, '', url);
329
329
  }
330
- executeAfterHooks(to, history[history.length - 2] || null);
330
+ executeAfterHooks(to, history[history.length - 2] ?? null);
331
331
  return true;
332
332
  }
333
333
  catch (error) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ktjs/router",
3
- "version": "0.7.3",
3
+ "version": "0.13.0",
4
4
  "description": "Router for kt.js - client-side routing with navigation guards",
5
5
  "type": "module",
6
6
  "module": "./dist/index.mjs",
@@ -31,7 +31,7 @@
31
31
  "directory": "packages/router"
32
32
  },
33
33
  "dependencies": {
34
- "@ktjs/core": "0.7.3"
34
+ "@ktjs/core": "0.13.0"
35
35
  },
36
36
  "scripts": {
37
37
  "build": "rollup -c rollup.config.mjs",