wooks 0.4.10 → 0.4.11

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/index.cjs CHANGED
@@ -17,8 +17,11 @@ function getDefaultLogger(topic) {
17
17
 
18
18
  class Wooks {
19
19
  constructor(opts) {
20
- this.router = new router.ProstoRouter(Object.assign({ silent: true }, ((opts === null || opts === void 0 ? void 0 : opts.router) || {})));
21
- this.logger = (opts === null || opts === void 0 ? void 0 : opts.logger) || getDefaultLogger('wooks');
20
+ this.router = new router.ProstoRouter({
21
+ silent: true,
22
+ ...(opts?.router || {}),
23
+ });
24
+ this.logger = opts?.logger || getDefaultLogger('wooks');
22
25
  }
23
26
  getRouter() {
24
27
  return this.router;
@@ -36,13 +39,12 @@ class Wooks {
36
39
  return {};
37
40
  }
38
41
  lookup(method, path) {
39
- var _a, _b, _c, _d;
40
42
  const found = this.getRouter().lookup(method, path || '');
41
- eventCore.useEventContext().store('routeParams').value = ((_a = found === null || found === void 0 ? void 0 : found.ctx) === null || _a === void 0 ? void 0 : _a.params) || {};
43
+ eventCore.useEventContext().store('routeParams').value = found?.ctx?.params || {};
42
44
  return {
43
- handlers: ((_b = found === null || found === void 0 ? void 0 : found.route) === null || _b === void 0 ? void 0 : _b.handlers) || null,
44
- segments: ((_c = found === null || found === void 0 ? void 0 : found.route) === null || _c === void 0 ? void 0 : _c.segments) || null,
45
- firstStatic: ((_d = found === null || found === void 0 ? void 0 : found.route) === null || _d === void 0 ? void 0 : _d.firstStatic) || null,
45
+ handlers: found?.route?.handlers || null,
46
+ segments: found?.route?.segments || null,
47
+ firstStatic: found?.route?.firstStatic || null,
46
48
  };
47
49
  }
48
50
  on(method, path, handler) {
@@ -91,7 +93,13 @@ class WooksAdapterBase {
91
93
  return this.getWooks().getLoggerOptions();
92
94
  }
93
95
  mergeEventOptions(opts) {
94
- return Object.assign(Object.assign({}, (opts || {})), { eventLogger: Object.assign(Object.assign({}, this.getLoggerOptions()), ((opts === null || opts === void 0 ? void 0 : opts.eventLogger) || {})) });
96
+ return {
97
+ ...(opts || {}),
98
+ eventLogger: {
99
+ ...this.getLoggerOptions(),
100
+ ...(opts?.eventLogger || {}),
101
+ },
102
+ };
95
103
  }
96
104
  on(method, path, handler) {
97
105
  return this.wooks.on(method, path, handler);
package/dist/index.mjs CHANGED
@@ -16,8 +16,11 @@ function getDefaultLogger(topic) {
16
16
 
17
17
  class Wooks {
18
18
  constructor(opts) {
19
- this.router = new ProstoRouter(Object.assign({ silent: true }, ((opts === null || opts === void 0 ? void 0 : opts.router) || {})));
20
- this.logger = (opts === null || opts === void 0 ? void 0 : opts.logger) || getDefaultLogger('wooks');
19
+ this.router = new ProstoRouter({
20
+ silent: true,
21
+ ...(opts?.router || {}),
22
+ });
23
+ this.logger = opts?.logger || getDefaultLogger('wooks');
21
24
  }
22
25
  getRouter() {
23
26
  return this.router;
@@ -35,13 +38,12 @@ class Wooks {
35
38
  return {};
36
39
  }
37
40
  lookup(method, path) {
38
- var _a, _b, _c, _d;
39
41
  const found = this.getRouter().lookup(method, path || '');
40
- useEventContext().store('routeParams').value = ((_a = found === null || found === void 0 ? void 0 : found.ctx) === null || _a === void 0 ? void 0 : _a.params) || {};
42
+ useEventContext().store('routeParams').value = found?.ctx?.params || {};
41
43
  return {
42
- handlers: ((_b = found === null || found === void 0 ? void 0 : found.route) === null || _b === void 0 ? void 0 : _b.handlers) || null,
43
- segments: ((_c = found === null || found === void 0 ? void 0 : found.route) === null || _c === void 0 ? void 0 : _c.segments) || null,
44
- firstStatic: ((_d = found === null || found === void 0 ? void 0 : found.route) === null || _d === void 0 ? void 0 : _d.firstStatic) || null,
44
+ handlers: found?.route?.handlers || null,
45
+ segments: found?.route?.segments || null,
46
+ firstStatic: found?.route?.firstStatic || null,
45
47
  };
46
48
  }
47
49
  on(method, path, handler) {
@@ -90,7 +92,13 @@ class WooksAdapterBase {
90
92
  return this.getWooks().getLoggerOptions();
91
93
  }
92
94
  mergeEventOptions(opts) {
93
- return Object.assign(Object.assign({}, (opts || {})), { eventLogger: Object.assign(Object.assign({}, this.getLoggerOptions()), ((opts === null || opts === void 0 ? void 0 : opts.eventLogger) || {})) });
95
+ return {
96
+ ...(opts || {}),
97
+ eventLogger: {
98
+ ...this.getLoggerOptions(),
99
+ ...(opts?.eventLogger || {}),
100
+ },
101
+ };
94
102
  }
95
103
  on(method, path, handler) {
96
104
  return this.wooks.on(method, path, handler);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "wooks",
3
- "version": "0.4.10",
3
+ "version": "0.4.11",
4
4
  "description": "wooks",
5
5
  "main": "dist/index.cjs",
6
6
  "module": "dist/index.mjs",
@@ -33,7 +33,7 @@
33
33
  "dependencies": {
34
34
  "@prostojs/router": "^0.2.1",
35
35
  "@prostojs/logger": "^0.3.7",
36
- "@wooksjs/event-core": "0.4.10"
36
+ "@wooksjs/event-core": "0.4.11"
37
37
  },
38
38
  "homepage": "https://github.com/wooksjs/wooksjs/tree/main/packages/wooks#readme"
39
39
  }