@dharmax/state-router 3.1.1 → 3.1.2

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/router.js CHANGED
@@ -59,7 +59,8 @@ class Router {
59
59
  const match = path.match(route.pattern);
60
60
  if (match) {
61
61
  match.shift(); // Remove the full match element
62
- route.handler.apply({}, match);
62
+ const queryParams = Object.fromEntries(new URLSearchParams(window.location.search));
63
+ route.handler.apply({ queryParams }, match);
63
64
  return true;
64
65
  }
65
66
  }
@@ -27,7 +27,7 @@ export declare class StateManager {
27
27
  * set current page state
28
28
  * @param state can be either just a state or a state and context (which can be sub-state, or anything else)
29
29
  */
30
- set state(state: ApplicationStateName | [ApplicationStateName, any]);
30
+ set state(state: ApplicationStateName | [ApplicationStateName, ...any]);
31
31
  /** attempts to restore state from current url. Currently, works only in hash mode */
32
32
  restoreState(defaultState: ApplicationStateName): void;
33
33
  /**
@@ -41,8 +41,10 @@ export class StateManager {
41
41
  * @param state can be either just a state or a state and context (which can be sub-state, or anything else)
42
42
  */
43
43
  set state(state) {
44
- if (Array.isArray(state))
45
- this.setState(state[0], state[1]);
44
+ if (Array.isArray(state)) {
45
+ const sName = state.shift();
46
+ this.setState(sName, state);
47
+ }
46
48
  else
47
49
  this.setState(state);
48
50
  }
@@ -100,10 +102,9 @@ export class StateManager {
100
102
  router.add(state.route, async (context) => {
101
103
  if (await this.setState(state.name, context)) {
102
104
  // @ts-ignore
103
- if (window.ga) {
104
- // @ts-ignore
105
- window.ga('send', 'pageview', `/${state.name}/${context || ''}`);
106
- }
105
+ window.pageChangeHandler && window.pageChangeHandler('send', 'pageview', `/${state.name}/${context || ''}`);
106
+ // @ts-ignore
107
+ window.ga && window.ga('send', 'pageview', `/${state.name}/${context || ''}`);
107
108
  }
108
109
  });
109
110
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dharmax/state-router",
3
- "version": "3.1.1",
3
+ "version": "3.1.2",
4
4
  "description": "A cute and tight router and application state controller",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",