@angular-wave/angular.ts 0.0.27 → 0.0.28

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.
Files changed (73) hide show
  1. package/README.md +1 -2
  2. package/dist/angular-ts.esm.js +1 -1
  3. package/dist/angular-ts.umd.js +1 -1
  4. package/e2e/unit.spec.ts +2 -1
  5. package/index.html +8 -9
  6. package/package.json +1 -1
  7. package/src/core/pubsub.js +329 -0
  8. package/src/router/hooks/core-resolvables.js +12 -11
  9. package/src/router/hooks/ignored-transition.js +1 -1
  10. package/src/router/hooks/lazy-load.js +40 -41
  11. package/src/router/hooks/redirect-to.js +32 -29
  12. package/src/router/hooks/update-globals.js +1 -1
  13. package/src/router/hooks/url.js +33 -24
  14. package/src/router/hooks/views.js +21 -20
  15. package/src/router/params/param-factory.js +17 -0
  16. package/src/router/router.js +74 -10
  17. package/src/router/state/state-queue-manager.js +5 -4
  18. package/src/router/state/state-registry.js +8 -5
  19. package/src/router/state/state-service.js +34 -29
  20. package/src/router/transition/hook-builder.js +2 -2
  21. package/src/router/transition/transition-hook.js +2 -1
  22. package/src/router/transition/transition-service.js +12 -18
  23. package/src/router/transition/transition.js +28 -25
  24. package/src/router/url/url-config.js +1 -49
  25. package/src/router/url/url-matcher-factory.js +10 -51
  26. package/src/router/url/url-router.js +27 -17
  27. package/src/router/url/url-rule.js +9 -13
  28. package/src/router/url/url-rules.js +3 -3
  29. package/src/router/url/url-service.js +22 -18
  30. package/src/router/view/view.js +3 -3
  31. package/src/shared/hof.js +1 -1
  32. package/test/angular.spec.js +1 -0
  33. package/test/aria/aria.spec.js +2 -1
  34. package/test/core/pubsub.spec.js +314 -0
  35. package/test/directive/bind.spec.js +2 -1
  36. package/test/directive/boolean.spec.js +4 -2
  37. package/test/directive/change.spec.js +1 -1
  38. package/test/directive/class.spec.js +1 -0
  39. package/test/directive/click.spec.js +2 -1
  40. package/test/directive/cloak.spec.js +1 -2
  41. package/test/directive/{constoller.spec.js → controller.spec.js} +1 -0
  42. package/test/directive/element-style.spec.js +1 -0
  43. package/test/directive/event.spec.js +1 -1
  44. package/test/directive/href.spec.js +2 -1
  45. package/test/directive/init.spec.js +1 -0
  46. package/test/directive/input.spec.js +200 -285
  47. package/test/directive/list.spec.js +2 -1
  48. package/test/directive/model.spec.js +1 -0
  49. package/test/directive/non-bindable.spec.js +2 -1
  50. package/test/directive/script.spec.js +1 -0
  51. package/test/directive/scrset.spec.js +2 -1
  52. package/test/directive/show-hide.spec.js +1 -0
  53. package/test/directive/src.spec.js +2 -1
  54. package/test/directive/style.spec.js +1 -0
  55. package/test/directive/switch.spec.js +2 -1
  56. package/test/directive/validators.spec.js +1 -1
  57. package/test/router/view-hook.spec.js +2 -2
  58. package/test/router/view-scroll.spec.js +1 -1
  59. package/test/router/view.spec.js +1 -1
  60. package/types/router/core/common/coreservices.d.ts +2 -3
  61. package/types/router/core/globals.d.ts +1 -4
  62. package/types/router/core/interface.d.ts +2 -8
  63. package/types/router/core/params/paramTypes.d.ts +0 -1
  64. package/types/router/core/router.d.ts +2 -3
  65. package/types/router/core/state/stateQueueManager.d.ts +1 -3
  66. package/types/router/core/state/stateRegistry.d.ts +0 -2
  67. package/types/router/core/state/stateService.d.ts +1 -2
  68. package/types/router/core/transition/interface.d.ts +3 -3
  69. package/types/router/core/transition/transitionService.d.ts +1 -2
  70. package/types/router/core/url/urlConfig.d.ts +1 -2
  71. package/types/router/core/url/urlRules.d.ts +1 -2
  72. package/types/router/core/url/urlService.d.ts +1 -2
  73. package/types/router/locationServices.d.ts +0 -1
@@ -1,25 +1,34 @@
1
- /**
2
- * A [[TransitionHookFn]] which updates the URL after a successful transition
3
- *
4
- * Registered using `transitionService.onSuccess({}, updateUrl);`
5
- */
6
- const updateUrl = (transition) => {
7
- const options = transition.options();
8
- const $state = transition.router.stateService;
9
- const $urlRouter = transition.router.urlRouter;
10
- // Dont update the url in these situations:
11
- // The transition was triggered by a URL sync (options.source === 'url')
12
- // The user doesn't want the url to update (options.location === false)
13
- // The destination state, and all parents have no navigable url
14
- if (
15
- options.source !== "url" &&
16
- options.location &&
17
- $state.$current.navigable
18
- ) {
19
- const urlOptions = { replace: options.location === "replace" };
20
- $urlRouter.push($state.$current.navigable.url, $state.params, urlOptions);
21
- }
22
- $urlRouter.update(true);
23
- };
24
- export const registerUpdateUrl = (transitionService) =>
1
+ export const registerUpdateUrl = (
2
+ transitionService,
3
+ stateService,
4
+ urlRouter,
5
+ ) => {
6
+ /**
7
+ * A [[TransitionHookFn]] which updates the URL after a successful transition
8
+ *
9
+ * Registered using `transitionService.onSuccess({}, updateUrl);`
10
+ */
11
+ const updateUrl = (transition) => {
12
+ const options = transition.options();
13
+ const $state = stateService;
14
+ const $urlRouter = urlRouter;
15
+ // Dont update the url in these situations:
16
+ // The transition was triggered by a URL sync (options.source === 'url')
17
+ // The user doesn't want the url to update (options.location === false)
18
+ // The destination state, and all parents have no navigable url
19
+ if (
20
+ options.source !== "url" &&
21
+ options.location &&
22
+ $state.$current.navigable
23
+ ) {
24
+ const urlOptions = { replace: options.location === "replace" };
25
+ $urlRouter.push(
26
+ $state.$current.navigable.url,
27
+ $state.globals.params,
28
+ urlOptions,
29
+ );
30
+ }
31
+ $urlRouter.update(true);
32
+ };
25
33
  transitionService.onSuccess({}, updateUrl, { priority: 9999 });
34
+ };
@@ -17,24 +17,25 @@ const loadEnteringViews = (transition) => {
17
17
  };
18
18
  export const registerLoadEnteringViews = (transitionService) =>
19
19
  transitionService.onFinish({}, loadEnteringViews);
20
- /**
21
- * A [[TransitionHookFn]] which activates the new views when a transition is successful.
22
- *
23
- * Registered using `transitionService.onSuccess({}, activateViews);`
24
- *
25
- * After a transition is complete, this hook deactivates the old views from the previous state,
26
- * and activates the new views from the destination state.
27
- *
28
- * See [[ViewService]]
29
- */
30
- const activateViews = (transition) => {
31
- const enteringViews = transition.views("entering");
32
- const exitingViews = transition.views("exiting");
33
- if (!enteringViews.length && !exitingViews.length) return;
34
- const $view = transition.router.viewService;
35
- exitingViews.forEach((vc) => $view.deactivateViewConfig(vc));
36
- enteringViews.forEach((vc) => $view.activateViewConfig(vc));
37
- $view.sync();
38
- };
39
- export const registerActivateViews = (transitionService) =>
20
+
21
+ export const registerActivateViews = (transitionService, viewService) => {
22
+ /**
23
+ * A [[TransitionHookFn]] which activates the new views when a transition is successful.
24
+ *
25
+ * Registered using `transitionService.onSuccess({}, activateViews);`
26
+ *
27
+ * After a transition is complete, this hook deactivates the old views from the previous state,
28
+ * and activates the new views from the destination state.
29
+ *
30
+ * See [[ViewService]]
31
+ */
32
+ const activateViews = (transition) => {
33
+ const enteringViews = transition.views("entering");
34
+ const exitingViews = transition.views("exiting");
35
+ if (!enteringViews.length && !exitingViews.length) return;
36
+ exitingViews.forEach((vc) => viewService.deactivateViewConfig(vc));
37
+ enteringViews.forEach((vc) => viewService.activateViewConfig(vc));
38
+ viewService.sync();
39
+ };
40
40
  transitionService.onSuccess({}, activateViews);
41
+ };
@@ -0,0 +1,17 @@
1
+ import { DefType, Param } from "../params/param";
2
+
3
+ export class ParamFactory {
4
+ constructor(urlServiceConfig) {
5
+ this.urlServiceConfig = urlServiceConfig;
6
+ }
7
+
8
+ fromConfig(id, type, state) {
9
+ return new Param(id, type, DefType.CONFIG, this.urlServiceConfig, state);
10
+ }
11
+ fromPath(id, type, state) {
12
+ return new Param(id, type, DefType.PATH, this.urlServiceConfig, state);
13
+ }
14
+ fromSearch(id, type, state) {
15
+ return new Param(id, type, DefType.SEARCH, this.urlServiceConfig, state);
16
+ }
17
+ }
@@ -7,6 +7,11 @@ import { StateService } from "./state/state-service";
7
7
  import { UIRouterGlobals } from "./globals";
8
8
  import { UrlService } from "./url/url-service";
9
9
  import { trace } from "./common/trace";
10
+ import { UrlRuleFactory } from "./url/url-rule";
11
+ import { registerLazyLoadHook } from "./hooks/lazy-load";
12
+ import { registerUpdateUrl } from "./hooks/url";
13
+ import { registerActivateViews } from "./hooks/views";
14
+ import { registerRedirectToHook } from "./hooks/redirect-to";
10
15
 
11
16
  /**
12
17
  * Router id tracker
@@ -27,33 +32,92 @@ export class UIRouter {
27
32
  * @param {angular.ILocationProvider} $locationProvider
28
33
  */
29
34
  constructor($locationProvider) {
30
- /** @type {number} */ this.$id = routerId++;
35
+ /** @type {number} */
36
+ this.$id = routerId++;
31
37
 
32
38
  /** Enable/disable tracing to the javascript console */
33
39
  this.trace = trace;
34
40
  this.$locationProvider = $locationProvider;
41
+
35
42
  /** Provides services related to ui-view synchronization */
36
- this.viewService = new ViewService(this);
43
+ this.viewService = new ViewService(routerId);
44
+
37
45
  /** @type {UIRouterGlobals} An object that contains global router state, such as the current state and params */
38
46
  this.globals = new UIRouterGlobals();
47
+
39
48
  /** @type {TransitionService} A service that exposes global Transition Hooks */
40
- this.transitionService = new TransitionService(this);
49
+ this.transitionService = new TransitionService(
50
+ this,
51
+ this.globals,
52
+ this.viewService,
53
+ );
54
+
55
+ /** @type {StateService} Provides services related to states */
56
+ this.stateService = new StateService(
57
+ this, // access to StateRegistry and UrlRouter
58
+ this.globals,
59
+ this.transitionService,
60
+ );
61
+ /** Provides services related to the URL */
62
+ let urlRuleFactory = new UrlRuleFactory(
63
+ this.urlMatcherFactory,
64
+ this.stateService,
65
+ this.globals,
66
+ );
67
+
68
+ /**
69
+ * @type {angular.UrlService}
70
+ */
71
+ this.urlService = new UrlService(
72
+ $locationProvider,
73
+ urlRuleFactory,
74
+ this.stateService,
75
+ );
76
+
41
77
  /**
42
78
  * Deprecated for public use. Use [[urlService]] instead.
43
79
  * @deprecated Use [[urlService]] instead
44
80
  */
45
- this.urlMatcherFactory = new UrlMatcherFactory(this);
81
+ this.urlMatcherFactory = new UrlMatcherFactory(this.urlService.config);
82
+
46
83
  /**
47
84
  * Deprecated for public use. Use [[urlService]] instead.
48
85
  * @deprecated Use [[urlService]] instead
49
86
  */
50
- this.urlRouter = new UrlRouter(this);
51
- /** Provides services related to the URL */
52
- this.urlService = new UrlService(this, $locationProvider);
87
+ this.urlRouter = new UrlRouter(
88
+ this.urlService,
89
+ urlRuleFactory,
90
+ $locationProvider,
91
+ );
92
+
53
93
  /** Provides a registry for states, and related registration services */
54
- this.stateRegistry = new StateRegistry(this);
55
- /** Provides services related to states */
56
- this.stateService = new StateService(this);
94
+ this.stateRegistry = new StateRegistry(
95
+ this.urlMatcherFactory,
96
+ this.urlService.rules,
97
+ );
98
+
99
+ // Lazy load state trees
100
+ this.transitionService._deregisterHookFns.lazyLoad = registerLazyLoadHook(
101
+ this.transitionService,
102
+ this.stateService,
103
+ this.urlService,
104
+ this.stateRegistry,
105
+ );
106
+
107
+ // After globals.current is updated at priority: 10000
108
+ this.transitionService._deregisterHookFns.updateUrl = registerUpdateUrl(
109
+ this.transitionService,
110
+ this.stateService,
111
+ this.urlRouter,
112
+ );
113
+
114
+ // Wire up redirectTo hook
115
+ this.transitionService._deregisterHookFns.redirectTo =
116
+ registerRedirectToHook(this.transitionService, this.stateService);
117
+
118
+ this.transitionService._deregisterHookFns.activateViews =
119
+ registerActivateViews(this.transitionService, this.viewService);
120
+
57
121
  /** @internal plugin instances are registered here */
58
122
  this._plugins = {};
59
123
  this.viewService._pluginapi._rootViewContext(this.stateRegistry.root());
@@ -4,8 +4,9 @@ import { isString } from "../../shared/utils";
4
4
  import { StateObject } from "./state-object";
5
5
 
6
6
  export class StateQueueManager {
7
- constructor(router, states, builder, listeners) {
8
- this.router = router;
7
+ constructor(stateRegistry, urlServiceRules, states, builder, listeners) {
8
+ this.stateRegistry = stateRegistry;
9
+ this.urlServiceRules = urlServiceRules;
9
10
  this.states = states;
10
11
  this.builder = builder;
11
12
  this.listeners = listeners;
@@ -55,7 +56,7 @@ export class StateQueueManager {
55
56
  const existingFutureState = getState(name + ".**");
56
57
  if (existingFutureState) {
57
58
  // Remove future state of the same name
58
- this.router.stateRegistry.deregister(existingFutureState);
59
+ this.stateRegistry.deregister(existingFutureState);
59
60
  }
60
61
  states[name] = state;
61
62
  this.attachRoute(state);
@@ -81,7 +82,7 @@ export class StateQueueManager {
81
82
  }
82
83
  attachRoute(state) {
83
84
  if (state.abstract || !state.url) return;
84
- const rulesApi = this.router.urlService.rules;
85
+ const rulesApi = this.urlServiceRules;
85
86
  rulesApi.rule(rulesApi.urlRuleFactory.create(state));
86
87
  }
87
88
  }
@@ -9,15 +9,16 @@ import { propEq } from "../../shared/hof";
9
9
  * This API is found at `router.stateRegistry` ([[UIRouter.stateRegistry]])
10
10
  */
11
11
  export class StateRegistry {
12
- constructor(router) {
13
- this.router = router;
12
+ constructor(urlMatcherFactory, urlServiceRules) {
14
13
  this.states = {};
14
+ this.urlServiceRules = urlServiceRules;
15
15
 
16
16
  this.listeners = [];
17
17
  this.matcher = new StateMatcher(this.states);
18
- this.builder = new StateBuilder(this.matcher, router.urlMatcherFactory);
18
+ this.builder = new StateBuilder(this.matcher, urlMatcherFactory);
19
19
  this.stateQueue = new StateQueueManager(
20
- router,
20
+ this,
21
+ urlServiceRules,
21
22
  this.states,
22
23
  this.builder,
23
24
  this.listeners,
@@ -114,7 +115,7 @@ export class StateRegistry {
114
115
  const children = getChildren([state]);
115
116
  const deregistered = [state].concat(children).reverse();
116
117
  deregistered.forEach((_state) => {
117
- const rulesApi = this.router.urlService.rules;
118
+ const rulesApi = this.urlServiceRules;
118
119
  // Remove URL rule
119
120
  rulesApi
120
121
  .rules()
@@ -147,12 +148,14 @@ export class StateRegistry {
147
148
  );
148
149
  return deregisteredStates;
149
150
  }
151
+
150
152
  get(stateOrName, base) {
151
153
  if (arguments.length === 0)
152
154
  return Object.keys(this.states).map((name) => this.states[name].self);
153
155
  const found = this.matcher.find(stateOrName, base);
154
156
  return (found && found.self) || null;
155
157
  }
158
+
156
159
  /**
157
160
  * Registers a [[BuilderFunction]] for a specific [[StateObject]] property (e.g., `parent`, `url`, or `path`).
158
161
  * More than one BuilderFunction can be registered for a given property.
@@ -19,27 +19,21 @@ import { Glob } from "../common/glob";
19
19
  import { ResolveContext } from "../resolve/resolve-context";
20
20
  import { lazyLoadState } from "../hooks/lazy-load";
21
21
  import { not, val } from "../../shared/hof";
22
+ import { EventBus } from "../../core/pubsub";
23
+
22
24
  /**
23
25
  * Provides services related to ui-router states.
24
26
  *
25
27
  * This API is located at `router.stateService` ([[UIRouter.stateService]])
26
28
  */
27
29
  export class StateService {
28
- /**
29
- * The [[Transition]] currently in progress (or null)
30
- *
31
- * @deprecated This is a passthrough through to [[UIRouterGlobals.transition]]
32
- */
33
- get transition() {
34
- return this.router.globals.transition;
35
- }
36
30
  /**
37
31
  * The latest successful state parameters
38
32
  *
39
33
  * @deprecated This is a passthrough through to [[UIRouterGlobals.params]]
40
34
  */
41
35
  get params() {
42
- return this.router.globals.params;
36
+ return this.globals.params;
43
37
  }
44
38
  /**
45
39
  * The current [[StateDeclaration]]
@@ -47,7 +41,7 @@ export class StateService {
47
41
  * @deprecated This is a passthrough through to [[UIRouterGlobals.current]]
48
42
  */
49
43
  get current() {
50
- return this.router.globals.current;
44
+ return this.globals.current;
51
45
  }
52
46
  /**
53
47
  * The current [[StateObject]] (an internal API)
@@ -55,13 +49,14 @@ export class StateService {
55
49
  * @deprecated This is a passthrough through to [[UIRouterGlobals.$current]]
56
50
  */
57
51
  get $current() {
58
- return this.router.globals.$current;
52
+ return this.globals.$current;
59
53
  }
60
54
 
61
- constructor(router) {
62
- /** @private */
55
+ // Needs access to urlRouter, stateRegistry
56
+ constructor(router, globals, transitionService) {
63
57
  this.router = router;
64
-
58
+ this.globals = globals;
59
+ this.transitionService = transitionService;
65
60
  this.invalidCallbacks = [];
66
61
 
67
62
  this._defaultErrorHandler = function $defaultErrorHandler($error$) {
@@ -83,6 +78,10 @@ export class StateService {
83
78
  val(this),
84
79
  boundFns,
85
80
  );
81
+
82
+ EventBus.subscribe("$stateService:defaultErrorHandler", (err) =>
83
+ this.defaultErrorHandler()(err),
84
+ );
86
85
  }
87
86
 
88
87
  /**
@@ -101,7 +100,7 @@ export class StateService {
101
100
  this.router.stateRegistry,
102
101
  fromPath,
103
102
  );
104
- const globals = this.router.globals;
103
+ const globals = this.globals;
105
104
  const latestThing = () => globals.transitionHistory.peekTail();
106
105
  const latest = latestThing();
107
106
  const callbackQueue = new Queue(this.invalidCallbacks.slice());
@@ -217,7 +216,7 @@ export class StateService {
217
216
  * @returns A promise representing the state of the new transition. See [[StateService.go]]
218
217
  */
219
218
  reload(reloadState) {
220
- return this.transitionTo(this.current, this.params, {
219
+ return this.transitionTo(this.globals.current, this.globals.params, {
221
220
  reload: isDefined(reloadState) ? reloadState : true,
222
221
  inherit: false,
223
222
  notify: false,
@@ -297,7 +296,7 @@ export class StateService {
297
296
  }
298
297
 
299
298
  getCurrentPath() {
300
- const globals = this.router.globals;
299
+ const globals = this.globals;
301
300
  const latestSuccess = globals.successfulTransitions.peekTail();
302
301
  const rootPath = () => [new PathNode(this.router.stateRegistry.root())];
303
302
  return latestSuccess ? latestSuccess.treeChanges().to : rootPath();
@@ -326,10 +325,8 @@ export class StateService {
326
325
  * @returns A promise representing the state of the new transition. See [[go]]
327
326
  */
328
327
  transitionTo(to, toParams = {}, options = {}) {
329
- const router = this.router;
330
- const globals = router.globals;
331
328
  options = defaults(options, defaultTransOpts);
332
- const getCurrent = () => globals.transition;
329
+ const getCurrent = () => this.globals.transition;
333
330
  options = Object.assign(options, { current: getCurrent });
334
331
  const ref = this.target(to, toParams, options);
335
332
  const currentPath = this.getCurrentPath();
@@ -351,11 +348,11 @@ export class StateService {
351
348
  */
352
349
  const rejectedTransitionHandler = (trans) => (error) => {
353
350
  if (error instanceof Rejection) {
354
- const isLatest = router.globals.lastStartedTransitionId <= trans.$id;
351
+ const isLatest = this.globals.lastStartedTransitionId <= trans.$id;
355
352
  if (error.type === RejectType.IGNORED) {
356
- isLatest && router.urlRouter.update();
353
+ isLatest && this.router.urlRouter.update();
357
354
  // Consider ignored `Transition.run()` as a successful `transitionTo`
358
- return services.$q.when(globals.current);
355
+ return services.$q.when(this.globals.current);
359
356
  }
360
357
  const detail = error.detail;
361
358
  if (
@@ -369,7 +366,7 @@ export class StateService {
369
366
  return redirect.run().catch(rejectedTransitionHandler(redirect));
370
367
  }
371
368
  if (error.type === RejectType.ABORTED) {
372
- isLatest && router.urlRouter.update();
369
+ isLatest && this.router.urlRouter.update();
373
370
  return services.$q.reject(error);
374
371
  }
375
372
  }
@@ -377,7 +374,7 @@ export class StateService {
377
374
  errorHandler(error);
378
375
  return services.$q.reject(error);
379
376
  };
380
- const transition = this.router.transitionService.create(currentPath, ref);
377
+ const transition = this.transitionService.create(currentPath, ref);
381
378
  const transitionToPromise = transition
382
379
  .run()
383
380
  .catch(rejectedTransitionHandler(transition));
@@ -426,7 +423,11 @@ export class StateService {
426
423
  if (this.$current !== state) return false;
427
424
  if (!params) return true;
428
425
  const schema = state.parameters({ inherit: true, matchingKeys: params });
429
- return Param.equals(schema, Param.values(schema, params), this.params);
426
+ return Param.equals(
427
+ schema,
428
+ Param.values(schema, params),
429
+ this.globals.params,
430
+ );
430
431
  }
431
432
  /**
432
433
  * Checks if the current state *includes* the provided state
@@ -482,7 +483,11 @@ export class StateService {
482
483
  if (!isDefined(include[state.name])) return false;
483
484
  if (!params) return true;
484
485
  const schema = state.parameters({ inherit: true, matchingKeys: params });
485
- return Param.equals(schema, Param.values(schema, params), this.params);
486
+ return Param.equals(
487
+ schema,
488
+ Param.values(schema, params),
489
+ this.globals.params,
490
+ );
486
491
  }
487
492
  /**
488
493
  * Generates a URL for a state and parameters
@@ -515,7 +520,7 @@ export class StateService {
515
520
  );
516
521
  if (!isDefined(state)) return null;
517
522
  if (options.inherit)
518
- params = this.params.$inherit(params, this.$current, state);
523
+ params = this.globals.params.$inherit(params, this.$current, state);
519
524
  const nav = state && options.lossy ? state.navigable : state;
520
525
  if (!nav || nav.url === undefined || nav.url === null) {
521
526
  return null;
@@ -578,7 +583,7 @@ export class StateService {
578
583
  currentPath,
579
584
  );
580
585
  transition =
581
- transition || this.router.transitionService.create(currentPath, target);
586
+ transition || this.transitionService.create(currentPath, target);
582
587
  return lazyLoadState(transition, state);
583
588
  }
584
589
  }
@@ -19,7 +19,7 @@ export class HookBuilder {
19
19
  this.transition = transition;
20
20
  }
21
21
  buildHooksForPhase(phase) {
22
- const $transitions = this.transition.router.transitionService;
22
+ const $transitions = this.transition.transitionService;
23
23
  return $transitions._pluginapi
24
24
  ._getEvents(phase)
25
25
  .map((type) => this.buildHooks(type))
@@ -96,7 +96,7 @@ export class HookBuilder {
96
96
  getMatchingHooks(hookType, treeChanges, transition) {
97
97
  const isCreate = hookType.hookPhase === TransitionHookPhase.CREATE;
98
98
  // Instance and Global hook registries
99
- const $transitions = this.transition.router.transitionService;
99
+ const $transitions = this.transition.transitionService;
100
100
  const registries = isCreate
101
101
  ? [$transitions]
102
102
  : [this.transition, $transitions];
@@ -7,6 +7,7 @@ import { trace } from "../common/trace";
7
7
  import { services } from "../common/coreservices";
8
8
  import { Rejection } from "./reject-factory";
9
9
  import { TargetState } from "../state/target-state";
10
+ import { EventBus } from "../../core/pubsub";
10
11
  const defaultOptions = {
11
12
  current: () => {},
12
13
  transition: null,
@@ -79,7 +80,7 @@ export class TransitionHook {
79
80
  this.type = registeredHook.eventType;
80
81
  }
81
82
  logError(err) {
82
- this.transition.router.stateService.defaultErrorHandler()(err);
83
+ EventBus.publish("$stateService:defaultErrorHandler", err);
83
84
  }
84
85
  invokeHook() {
85
86
  const hook = this.registeredHook;
@@ -5,7 +5,6 @@ import {
5
5
  registerAddCoreResolvables,
6
6
  treeChangesCleanup,
7
7
  } from "../hooks/core-resolvables";
8
- import { registerRedirectToHook } from "../hooks/redirect-to";
9
8
  import {
10
9
  registerOnExitHook,
11
10
  registerOnRetainHook,
@@ -16,17 +15,14 @@ import {
16
15
  registerLazyResolveState,
17
16
  registerResolveRemaining,
18
17
  } from "../hooks/resolve";
19
- import {
20
- registerLoadEnteringViews,
21
- registerActivateViews,
22
- } from "../hooks/views";
18
+ import { registerLoadEnteringViews } from "../hooks/views";
23
19
  import { registerUpdateGlobalState } from "../hooks/update-globals";
24
- import { registerUpdateUrl } from "../hooks/url";
20
+
25
21
  import { registerLazyLoadHook } from "../hooks/lazy-load";
26
22
  import { TransitionEventType } from "./transition-event-type";
27
23
  import { TransitionHook } from "./transition-hook";
28
24
  import { isDefined } from "../../shared/utils";
29
- import { removeFrom, createProxyFunctions } from "../../shared/common";
25
+ import { createProxyFunctions } from "../../shared/common";
30
26
  import { val } from "../../shared/hof";
31
27
  import { registerIgnoredTransitionHook } from "../hooks/ignored-transition";
32
28
  import { registerInvalidTransitionHook } from "../hooks/invalid-transition";
@@ -61,9 +57,9 @@ export let defaultTransOpts = {
61
57
  */
62
58
  export class TransitionService {
63
59
  /**
64
- * @param {import('../router').UIRouter} _router
60
+ * @param {import('../router').UIRouter} router
65
61
  */
66
- constructor(_router) {
62
+ constructor(router, globals, viewService) {
67
63
  this._transitionCount = 0;
68
64
  /** The transition hook types, such as `onEnter`, `onStart`, etc */
69
65
  this._eventTypes = [];
@@ -71,8 +67,9 @@ export class TransitionService {
71
67
  this._registeredHooks = {};
72
68
  /** The paths on a criteria object */
73
69
  this._criteriaPaths = {};
74
- this._router = _router;
75
- this.$view = _router.viewService;
70
+ this.router = router;
71
+ this.globals = globals;
72
+ this.$view = viewService;
76
73
  this._deregisterHookFns = {};
77
74
  this._pluginapi = createProxyFunctions(val(this), {}, val(this), [
78
75
  "_definePathType",
@@ -84,7 +81,7 @@ export class TransitionService {
84
81
  this._defineCorePaths();
85
82
  this._defineCoreEvents();
86
83
  this._registerCoreTransitionHooks();
87
- _router.globals.successfulTransitions.onEvict(treeChangesCleanup);
84
+ globals.successfulTransitions.onEvict(treeChangesCleanup);
88
85
  }
89
86
  /**
90
87
  * Registers a [[TransitionHookFn]], called *while a transition is being constructed*.
@@ -122,7 +119,7 @@ export class TransitionService {
122
119
  * @returns a Transition
123
120
  */
124
121
  create(fromPath, targetState) {
125
- return new Transition(fromPath, targetState, this._router);
122
+ return new Transition(fromPath, targetState, this, this.globals);
126
123
  }
127
124
 
128
125
  _defineCoreEvents() {
@@ -242,8 +239,7 @@ export class TransitionService {
242
239
  fns.addCoreResolves = registerAddCoreResolvables(this);
243
240
  fns.ignored = registerIgnoredTransitionHook(this);
244
241
  fns.invalid = registerInvalidTransitionHook(this);
245
- // Wire up redirectTo hook
246
- fns.redirectTo = registerRedirectToHook(this);
242
+
247
243
  // Wire up onExit/Retain/Enter state hooks
248
244
  fns.onExit = registerOnExitHook(this);
249
245
  fns.onRetain = registerOnRetainHook(this);
@@ -254,11 +250,9 @@ export class TransitionService {
254
250
  fns.resolveAll = registerResolveRemaining(this);
255
251
  // Wire up the View management hooks
256
252
  fns.loadViews = registerLoadEnteringViews(this);
257
- fns.activateViews = registerActivateViews(this);
253
+
258
254
  // Updates global state after a transition
259
255
  fns.updateGlobals = registerUpdateGlobalState(this);
260
- // After globals.current is updated at priority: 10000
261
- fns.updateUrl = registerUpdateUrl(this);
262
256
  // Lazy load state trees
263
257
  fns.lazyLoad = registerLazyLoadHook(this);
264
258
  }