@angular-wave/angular.ts 0.0.27 → 0.0.29

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 (103) 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 +6 -6
  6. package/package.json +1 -1
  7. package/src/core/pubsub.js +329 -0
  8. package/src/router/common/trace.js +6 -6
  9. package/src/router/directives/state-directives.js +74 -74
  10. package/src/router/directives/view-directive.js +21 -21
  11. package/src/router/hooks/core-resolvables.js +12 -11
  12. package/src/router/hooks/ignored-transition.js +1 -1
  13. package/src/router/hooks/lazy-load.js +40 -41
  14. package/src/router/hooks/redirect-to.js +32 -29
  15. package/src/router/hooks/update-globals.js +1 -1
  16. package/src/router/hooks/url.js +33 -24
  17. package/src/router/hooks/views.js +21 -20
  18. package/src/router/index.js +12 -12
  19. package/src/router/injectables.js +3 -3
  20. package/src/router/params/param-factory.js +17 -0
  21. package/src/router/router.js +75 -10
  22. package/src/router/services.js +4 -8
  23. package/src/router/state/state-builder.js +1 -0
  24. package/src/router/state/state-queue-manager.js +5 -4
  25. package/src/router/state/state-registry.js +63 -7
  26. package/src/router/state/state-service.js +47 -51
  27. package/src/router/state/views.js +4 -4
  28. package/src/router/state-filters.js +0 -2
  29. package/src/router/state-provider.js +0 -2
  30. package/src/router/template-factory.js +4 -4
  31. package/src/router/transition/hook-builder.js +2 -2
  32. package/src/router/transition/transition-hook.js +2 -1
  33. package/src/router/transition/transition-service.js +11 -18
  34. package/src/router/transition/transition.js +28 -25
  35. package/src/router/url/url-config.js +1 -49
  36. package/src/router/url/url-matcher-factory.js +10 -51
  37. package/src/router/url/url-router.js +31 -17
  38. package/src/router/url/url-rule.js +9 -13
  39. package/src/router/url/url-rules.js +3 -3
  40. package/src/router/url/url-service.js +22 -18
  41. package/src/router/view/view.js +67 -67
  42. package/src/services/browser.js +1 -5
  43. package/src/shared/hof.js +1 -1
  44. package/test/angular.spec.js +1 -0
  45. package/test/aria/aria.spec.js +2 -1
  46. package/test/core/pubsub.spec.js +387 -0
  47. package/test/directive/bind.spec.js +2 -1
  48. package/test/directive/boolean.spec.js +4 -2
  49. package/test/directive/change.spec.js +1 -1
  50. package/test/directive/class.spec.js +1 -0
  51. package/test/directive/click.spec.js +2 -1
  52. package/test/directive/cloak.spec.js +1 -2
  53. package/test/directive/{constoller.spec.js → controller.spec.js} +1 -0
  54. package/test/directive/element-style.spec.js +1 -0
  55. package/test/directive/event.spec.js +1 -1
  56. package/test/directive/href.spec.js +2 -1
  57. package/test/directive/init.spec.js +1 -0
  58. package/test/directive/input.spec.js +200 -285
  59. package/test/directive/list.spec.js +2 -1
  60. package/test/directive/model.spec.js +1 -0
  61. package/test/directive/non-bindable.spec.js +2 -1
  62. package/test/directive/script.spec.js +1 -0
  63. package/test/directive/scrset.spec.js +2 -1
  64. package/test/directive/show-hide.spec.js +1 -0
  65. package/test/directive/src.spec.js +2 -1
  66. package/test/directive/style.spec.js +1 -0
  67. package/test/directive/switch.spec.js +2 -1
  68. package/test/directive/validators.spec.js +1 -1
  69. package/test/module-test.html +5 -5
  70. package/test/original-test.html +3 -3
  71. package/test/router/services.spec.js +1 -1
  72. package/test/router/state-directives.spec.js +72 -80
  73. package/test/router/state-filter.spec.js +6 -4
  74. package/test/router/state.spec.js +15 -13
  75. package/test/router/template-factory.spec.js +4 -4
  76. package/test/router/url-matcher-factory.spec.js +2 -2
  77. package/test/router/view-directive.spec.js +165 -163
  78. package/test/router/view-hook.spec.js +4 -4
  79. package/test/router/view-scroll.spec.js +15 -15
  80. package/test/router/view.spec.js +3 -3
  81. package/types/router/core/common/coreservices.d.ts +2 -3
  82. package/types/router/core/globals.d.ts +1 -4
  83. package/types/router/core/interface.d.ts +2 -8
  84. package/types/router/core/params/paramTypes.d.ts +0 -1
  85. package/types/router/core/router.d.ts +2 -3
  86. package/types/router/core/state/interface.d.ts +6 -6
  87. package/types/router/core/state/stateQueueManager.d.ts +1 -3
  88. package/types/router/core/state/stateRegistry.d.ts +1 -2
  89. package/types/router/core/state/stateService.d.ts +5 -6
  90. package/types/router/core/transition/interface.d.ts +4 -4
  91. package/types/router/core/transition/transitionService.d.ts +1 -2
  92. package/types/router/core/url/urlConfig.d.ts +1 -2
  93. package/types/router/core/url/urlRules.d.ts +1 -2
  94. package/types/router/core/url/urlService.d.ts +1 -2
  95. package/types/router/core/view/interface.d.ts +2 -2
  96. package/types/router/core/view/view.d.ts +16 -16
  97. package/types/router/directives/viewDirective.d.ts +3 -3
  98. package/types/router/interface.d.ts +4 -4
  99. package/types/router/locationServices.d.ts +0 -1
  100. package/types/router/stateProvider.d.ts +3 -3
  101. package/types/router/statebuilders/views.d.ts +1 -1
  102. package/types/router/templateFactory.d.ts +2 -2
  103. package/types/router/viewScroll.d.ts +1 -1
@@ -1,40 +1,7 @@
1
1
  import { forEach, isDefined, isFunction, isObject } from "../../shared/utils";
2
2
  import { UrlMatcher } from "./url-matcher";
3
- import { DefType, Param } from "../params/param";
3
+ import { ParamFactory } from "../params/param-factory";
4
4
 
5
- export class ParamFactory {
6
- constructor(router) {
7
- this.router = router;
8
- }
9
-
10
- fromConfig(id, type, state) {
11
- return new Param(
12
- id,
13
- type,
14
- DefType.CONFIG,
15
- this.router.urlService.config,
16
- state,
17
- );
18
- }
19
- fromPath(id, type, state) {
20
- return new Param(
21
- id,
22
- type,
23
- DefType.PATH,
24
- this.router.urlService.config,
25
- state,
26
- );
27
- }
28
- fromSearch(id, type, state) {
29
- return new Param(
30
- id,
31
- type,
32
- DefType.SEARCH,
33
- this.router.urlService.config,
34
- state,
35
- );
36
- }
37
- }
38
5
  /**
39
6
  * Factory for [[UrlMatcher]] instances.
40
7
  *
@@ -43,28 +10,20 @@ export class ParamFactory {
43
10
  */
44
11
  export class UrlMatcherFactory {
45
12
  // TODO: move implementations to UrlConfig (urlService.config)
46
- constructor(router) {
47
- this.router = router;
13
+ constructor(urlServiceConfig) {
14
+ this.urlServiceConfig = urlServiceConfig;
48
15
  /** Creates a new [[Param]] for a given location (DefType) */
49
- this.paramFactory = new ParamFactory(this.router);
50
- // TODO: Check if removal of this will break anything, then remove these
51
- this.UrlMatcher = UrlMatcher;
52
- this.Param = Param;
16
+ this.paramFactory = new ParamFactory(urlServiceConfig);
53
17
  /** @deprecated use [[UrlConfig.caseInsensitive]] */
54
- this.caseInsensitive = (value) =>
55
- this.router.urlService.config.caseInsensitive(value);
18
+ this.caseInsensitive = (value) => urlServiceConfig.caseInsensitive(value);
56
19
  /** @deprecated use [[UrlConfig.defaultSquashPolicy]] */
57
20
  this.defaultSquashPolicy = (value) =>
58
- this.router.urlService.config.defaultSquashPolicy(value);
21
+ urlServiceConfig.defaultSquashPolicy(value);
59
22
  /** @deprecated use [[UrlConfig.strictMode]] */
60
- this.strictMode = (value) =>
61
- this.router.urlService.config.strictMode(value);
23
+ this.strictMode = (value) => urlServiceConfig.strictMode(value);
62
24
  /** @deprecated use [[UrlConfig.type]] */
63
25
  this.type = (name, definition, definitionFn) => {
64
- return (
65
- this.router.urlService.config.type(name, definition, definitionFn) ||
66
- this
67
- );
26
+ return urlServiceConfig.type(name, definition, definitionFn) || this;
68
27
  };
69
28
  }
70
29
  /**
@@ -75,7 +34,7 @@ export class UrlMatcherFactory {
75
34
  * @returns The UrlMatcher.
76
35
  */
77
36
  compile(pattern, config) {
78
- const urlConfig = this.router.urlService.config;
37
+ const urlConfig = this.urlServiceConfig;
79
38
  // backward-compatible support for config.params -> config.state.params
80
39
  const params = config && !config.state && config.params;
81
40
  config = params ? Object.assign({ state: { params } }, config) : config;
@@ -110,7 +69,7 @@ export class UrlMatcherFactory {
110
69
  }
111
70
 
112
71
  $get() {
113
- const urlConfig = this.router.urlService.config;
72
+ const urlConfig = this.urlServiceConfig;
114
73
  urlConfig.paramTypes.enqueue = false;
115
74
  urlConfig.paramTypes._flushTypeQueue();
116
75
  return this;
@@ -1,5 +1,6 @@
1
+ import { EventBus } from "../../core/pubsub";
1
2
  import { stripLastPathElement } from "../../shared/strings";
2
- import { UrlRuleFactory } from "./url-rule";
3
+
3
4
  function appendBasePath(url, isHtml5, absolute, baseHref) {
4
5
  if (baseHref === "/") return url;
5
6
  if (isHtml5) return stripLastPathElement(baseHref) + url;
@@ -16,16 +17,19 @@ function appendBasePath(url, isHtml5, absolute, baseHref) {
16
17
  */
17
18
  export class UrlRouter {
18
19
  /**
19
- *
20
- * @param {import('../router').UIRouter} router
20
+ * @param {angular.UrlService} urlService
21
21
  */
22
- constructor(router) {
23
- this.router = router;
24
- this.urlRuleFactory = new UrlRuleFactory(router);
22
+ constructor(urlService, urlRuleFactory, $locationProvider) {
23
+ this.urlService = urlService;
24
+ this.urlRuleFactory = urlRuleFactory;
25
+ this.$locationProvider = $locationProvider;
26
+ EventBus.subscribe("$urlRouter:update", () => {
27
+ this.update();
28
+ });
25
29
  }
26
- /** Internal API. */
30
+
27
31
  update(read) {
28
- const $url = this.router.urlService;
32
+ const $url = this.urlService;
29
33
  if (read) {
30
34
  this.location = $url.url();
31
35
  return;
@@ -34,8 +38,6 @@ export class UrlRouter {
34
38
  $url.url(this.location, true);
35
39
  }
36
40
  /**
37
- * Internal API.
38
- *
39
41
  * Pushes a new location to the browser history.
40
42
  *
41
43
  * @internal
@@ -45,7 +47,7 @@ export class UrlRouter {
45
47
  */
46
48
  push(urlMatcher, params, options) {
47
49
  const replace = options && !!options.replace;
48
- this.router.urlService.url(urlMatcher.format(params || {}), replace);
50
+ this.urlService.url(urlMatcher.format(params || {}), replace);
49
51
  }
50
52
  /**
51
53
  * Builds and returns a URL with interpolated parameters
@@ -70,18 +72,30 @@ export class UrlRouter {
70
72
  let url = urlMatcher.format(params);
71
73
  if (url == null) return null;
72
74
  options = options || { absolute: false };
73
- const cfg = this.router.urlService.config;
74
- const isHtml5 = cfg.html5Mode();
75
+ const cfg = this.urlService.config;
76
+ const isHtml5 = this.urlService.html5Mode();
75
77
  if (!isHtml5 && url !== null) {
76
- url = "#" + cfg.hashPrefix() + url;
78
+ url = "#" + this.$locationProvider.hashPrefix() + url;
77
79
  }
78
- url = appendBasePath(url, isHtml5, options.absolute, cfg.baseHref());
80
+ url = appendBasePath(
81
+ url,
82
+ isHtml5,
83
+ options.absolute,
84
+ this.urlService.baseHref(),
85
+ );
79
86
  if (!options.absolute || !url) {
80
87
  return url;
81
88
  }
82
89
  const slash = !isHtml5 && url ? "/" : "";
83
- const cfgPort = cfg.port();
90
+ const cfgPort = this.urlService.$location.port();
84
91
  const port = cfgPort === 80 || cfgPort === 443 ? "" : ":" + cfgPort;
85
- return [cfg.protocol(), "://", cfg.host(), port, slash, url].join("");
92
+ return [
93
+ cfg.protocol(),
94
+ "://",
95
+ this.urlService.$location.host(),
96
+ port,
97
+ slash,
98
+ url,
99
+ ].join("");
86
100
  }
87
101
  }
@@ -13,12 +13,10 @@ import { StateObject } from "../state/state-object";
13
13
  * - [[StateObject]]
14
14
  */
15
15
  export class UrlRuleFactory {
16
- constructor(router) {
17
- this.router = router;
18
- }
19
-
20
- compile(str) {
21
- return this.router.urlMatcherFactory.compile(str);
16
+ constructor(urlMatcherFactory, stateService, routerGlobals) {
17
+ this.urlMatcherFactory = urlMatcherFactory;
18
+ this.stateService = stateService;
19
+ this.routerGlobals = routerGlobals;
22
20
  }
23
21
 
24
22
  /**
@@ -30,11 +28,11 @@ export class UrlRuleFactory {
30
28
  create(what, handler) {
31
29
  const { isState, isStateDeclaration } = StateObject;
32
30
  const makeRule = pattern([
33
- [isString, (_what) => makeRule(this.compile(_what))],
31
+ [isString, (_what) => makeRule(this.urlMatcherFactory.compile(_what))],
34
32
  [is(UrlMatcher), (_what) => this.fromUrlMatcher(_what, handler)],
35
33
  [
36
34
  or(isState, isStateDeclaration),
37
- (_what) => this.fromState(_what, this.router),
35
+ (_what) => this.fromState(_what, this.stateService, this.routerGlobals),
38
36
  ],
39
37
  [is(RegExp), (_what) => this.fromRegExp(_what, handler)],
40
38
  [isFunction, (_what) => new BaseUrlRule(_what, handler)],
@@ -81,8 +79,7 @@ export class UrlRuleFactory {
81
79
  */
82
80
  fromUrlMatcher(urlMatcher, handler) {
83
81
  let _handler = handler;
84
- if (isString(handler))
85
- handler = this.router.urlMatcherFactory.compile(handler);
82
+ if (isString(handler)) handler = this.urlMatcherFactory.compile(handler);
86
83
  if (is(UrlMatcher)(handler)) _handler = (match) => handler.format(match);
87
84
  function matchUrlParamters(url) {
88
85
  const params = urlMatcher.exec(url.path, url.search, url.hash);
@@ -115,7 +112,7 @@ export class UrlRuleFactory {
115
112
  * // Starts a transition to 'foo' with params: { fooId: '123', barId: '456' }
116
113
  * ```
117
114
  */
118
- fromState(stateOrDecl, router) {
115
+ fromState(stateOrDecl, stateService, globals) {
119
116
  const state = StateObject.isStateDeclaration(stateOrDecl)
120
117
  ? stateOrDecl.$$state()
121
118
  : stateOrDecl;
@@ -127,8 +124,7 @@ export class UrlRuleFactory {
127
124
  * and the new URL are already identical
128
125
  */
129
126
  const handler = (match) => {
130
- const $state = router.stateService;
131
- const globals = router.globals;
127
+ const $state = stateService;
132
128
  if (
133
129
  $state.href(state, match) !==
134
130
  $state.href(globals.current, globals.params)
@@ -62,14 +62,14 @@ function getHandlerFn(handler) {
62
62
  *
63
63
  * The most commonly used methods are [[otherwise]] and [[when]].
64
64
  *
65
- * This API is found at `router.urlService.rules` (see: [[UIRouter.urlService]], [[URLService.rules]])
65
+ * This API is found at `$urlService.rules` (see: [[UIRouter.urlService]], [[URLService.rules]])
66
66
  */
67
67
  export class UrlRules {
68
- constructor(router) {
68
+ constructor(urlRuleFactory) {
69
69
  this._sortFn = defaultRuleSortFn;
70
70
  this._rules = [];
71
71
  this._id = 0;
72
- this.urlRuleFactory = new UrlRuleFactory(router);
72
+ this.urlRuleFactory = urlRuleFactory;
73
73
  }
74
74
 
75
75
  /**
@@ -4,20 +4,16 @@ import { UrlRules } from "./url-rules";
4
4
  import { UrlConfig } from "./url-config";
5
5
  import { TargetState } from "../state/target-state";
6
6
  import { removeFrom } from "../../shared/common";
7
+
7
8
  /**
8
9
  * API for URL management
9
10
  */
10
11
  export class UrlService {
11
12
  /**
12
- *
13
- * @param {import('../router').UIRouter} router
14
13
  * @param {angular.ILocationProvider} $locationProvider
15
14
  */
16
- constructor(router, $locationProvider) {
17
- /**
18
- * @type {import('../router').UIRouter}
19
- */
20
- this.router = router;
15
+ constructor($locationProvider, urlRuleFactory, stateService) {
16
+ this.stateService = stateService;
21
17
 
22
18
  this.$locationProvider = $locationProvider;
23
19
 
@@ -29,14 +25,14 @@ export class UrlService {
29
25
  * See: [[UrlRules]] for details
30
26
  * @type {UrlRules}
31
27
  */
32
- this.rules = new UrlRules(this.router);
28
+ this.rules = new UrlRules(urlRuleFactory);
33
29
  /**
34
30
  * The nested [[UrlConfig]] API to configure the URL and retrieve URL information
35
31
  *
36
32
  * See: [[UrlConfig]] for details
37
33
  * @type {UrlConfig}
38
34
  */
39
- this.config = new UrlConfig(this.router);
35
+ this.config = new UrlConfig();
40
36
 
41
37
  /**
42
38
  * Gets the path part of the current url
@@ -188,15 +184,18 @@ export class UrlService {
188
184
  */
189
185
  sync(evt) {
190
186
  if (evt && evt.defaultPrevented) return;
191
- const { urlService, stateService } = this.router;
187
+ const stateService = this.stateService;
192
188
  const url = {
193
- path: urlService.path(),
194
- search: urlService.search(),
195
- hash: urlService.hash(),
189
+ path: this.path(),
190
+ search: this.search(),
191
+ hash: this.hash(),
196
192
  };
193
+ /**
194
+ * @type {angular.MatchResult}
195
+ */
197
196
  const best = this.match(url);
198
197
  const applyResult = pattern([
199
- [isString, (newurl) => urlService.url(newurl, true)],
198
+ [isString, (newurl) => this.url(newurl, true)],
200
199
  [
201
200
  TargetState.isDef,
202
201
  (def) => stateService.go(def.state, def.params, def.options),
@@ -207,7 +206,8 @@ export class UrlService {
207
206
  stateService.go(target.state(), target.params(), target.options()),
208
207
  ],
209
208
  ]);
210
- applyResult(best && best.rule.handler(best.match, url, this.router));
209
+
210
+ applyResult(best && best.rule.handler(best.match, url));
211
211
  }
212
212
  /**
213
213
  * Starts or stops listening for URL changes
@@ -237,8 +237,7 @@ export class UrlService {
237
237
  delete this._stopListeningFn;
238
238
  } else {
239
239
  return (this._stopListeningFn =
240
- this._stopListeningFn ||
241
- this.router.urlService.onChange((evt) => this.sync(evt)));
240
+ this._stopListeningFn || this.onChange((evt) => this.sync(evt)));
242
241
  }
243
242
  }
244
243
  /**
@@ -274,13 +273,18 @@ export class UrlService {
274
273
  *
275
274
  * Given a URL (as a [[UrlParts]] object), check all rules and determine the best matching rule.
276
275
  * Return the result as a [[MatchResult]].
276
+ * @returns {angular.MatchResult}
277
277
  */
278
278
  match(url) {
279
279
  url = Object.assign({ path: "", search: {}, hash: "" }, url);
280
280
  const rules = this.rules.rules();
281
281
  // Checks a single rule. Returns { rule: rule, match: match, weight: weight } if it matched, or undefined
282
+ /**
283
+ *
284
+ * @param {import("./url-rule").BaseUrlRule} rule
285
+ */
282
286
  const checkRule = (rule) => {
283
- const match = rule.match(url, this.router);
287
+ const match = rule.match(url);
284
288
  return match && { match, rule, weight: rule.matchPriority(match) };
285
289
  };
286
290
  // The rules are pre-sorted.
@@ -26,10 +26,10 @@ import { trace } from "../common/trace";
26
26
  */
27
27
  export class ViewService {
28
28
  /**
29
- * @param {import('../router').UIRouter} router
29
+ * @param {number} $id
30
30
  */
31
- constructor(router) {
32
- this._uiViews = [];
31
+ constructor($id) {
32
+ this._ngViews = [];
33
33
  this._viewConfigs = [];
34
34
  this._viewConfigFactories = {};
35
35
  this._listeners = [];
@@ -37,8 +37,8 @@ export class ViewService {
37
37
  _rootViewContext: this._rootViewContext.bind(this),
38
38
  _viewConfigFactory: this._viewConfigFactory.bind(this),
39
39
  _registeredUIView: (id) =>
40
- find(this._uiViews, (view) => `${router.$id}.${view.id}` === id),
41
- _registeredUIViews: () => this._uiViews,
40
+ find(this._ngViews, (view) => `${$id}.${view.id}` === id),
41
+ _registeredUIViews: () => this._ngViews,
42
42
  _activeViewConfigs: () => this._viewConfigs,
43
43
  _onSync: (listener) => {
44
44
  this._listeners.push(listener);
@@ -51,45 +51,45 @@ export class ViewService {
51
51
  * Normalizes a view's name from a state.views configuration block.
52
52
  *
53
53
  * This should be used by a framework implementation to calculate the values for
54
- * [[_ViewDeclaration.$uiViewName]] and [[_ViewDeclaration.$uiViewContextAnchor]].
54
+ * [[_ViewDeclaration.$ngViewName]] and [[_ViewDeclaration.$ngViewContextAnchor]].
55
55
  *
56
56
  * @param context the context object (state declaration) that the view belongs to
57
57
  * @param rawViewName the name of the view, as declared in the [[StateDeclaration.views]]
58
58
  *
59
- * @returns the normalized uiViewName and uiViewContextAnchor that the view targets
59
+ * @returns the normalized ngViewName and ngViewContextAnchor that the view targets
60
60
  */
61
61
  static normalizeUIViewTarget(context, rawViewName = "") {
62
62
  // TODO: Validate incoming view name with a regexp to allow:
63
63
  // ex: "view.name@foo.bar" , "^.^.view.name" , "view.name@^.^" , "" ,
64
64
  // "@" , "$default@^" , "!$default.$default" , "!foo.bar"
65
65
  const viewAtContext = rawViewName.split("@");
66
- let uiViewName = viewAtContext[0] || "$default"; // default to unnamed view
67
- let uiViewContextAnchor = isString(viewAtContext[1])
66
+ let ngViewName = viewAtContext[0] || "$default"; // default to unnamed view
67
+ let ngViewContextAnchor = isString(viewAtContext[1])
68
68
  ? viewAtContext[1]
69
69
  : "^"; // default to parent context
70
70
  // Handle relative view-name sugar syntax.
71
71
  // Matches rawViewName "^.^.^.foo.bar" into array: ["^.^.^.foo.bar", "^.^.^", "foo.bar"],
72
- const relativeViewNameSugar = /^(\^(?:\.\^)*)\.(.*$)/.exec(uiViewName);
72
+ const relativeViewNameSugar = /^(\^(?:\.\^)*)\.(.*$)/.exec(ngViewName);
73
73
  if (relativeViewNameSugar) {
74
74
  // Clobbers existing contextAnchor (rawViewName validation will fix this)
75
- uiViewContextAnchor = relativeViewNameSugar[1]; // set anchor to "^.^.^"
76
- uiViewName = relativeViewNameSugar[2]; // set view-name to "foo.bar"
75
+ ngViewContextAnchor = relativeViewNameSugar[1]; // set anchor to "^.^.^"
76
+ ngViewName = relativeViewNameSugar[2]; // set view-name to "foo.bar"
77
77
  }
78
- if (uiViewName.charAt(0) === "!") {
79
- uiViewName = uiViewName.substr(1);
80
- uiViewContextAnchor = ""; // target absolutely from root
78
+ if (ngViewName.charAt(0) === "!") {
79
+ ngViewName = ngViewName.substr(1);
80
+ ngViewContextAnchor = ""; // target absolutely from root
81
81
  }
82
82
  // handle parent relative targeting "^.^.^"
83
83
  const relativeMatch = /^(\^(?:\.\^)*)$/;
84
- if (relativeMatch.exec(uiViewContextAnchor)) {
85
- const anchorState = uiViewContextAnchor
84
+ if (relativeMatch.exec(ngViewContextAnchor)) {
85
+ const anchorState = ngViewContextAnchor
86
86
  .split(".")
87
87
  .reduce((anchor, x) => anchor.parent, context);
88
- uiViewContextAnchor = anchorState.name;
89
- } else if (uiViewContextAnchor === ".") {
90
- uiViewContextAnchor = context.name;
88
+ ngViewContextAnchor = anchorState.name;
89
+ } else if (ngViewContextAnchor === ".") {
90
+ ngViewContextAnchor = context.name;
91
91
  }
92
- return { uiViewName, uiViewContextAnchor };
92
+ return { ngViewName, ngViewContextAnchor };
93
93
  }
94
94
 
95
95
  _rootViewContext(context) {
@@ -125,18 +125,18 @@ export class ViewService {
125
125
  this._viewConfigs.push(viewConfig);
126
126
  }
127
127
  sync() {
128
- const uiViewsByFqn = this._uiViews
128
+ const ngViewsByFqn = this._ngViews
129
129
  .map((uiv) => [uiv.fqn, uiv])
130
130
  .reduce(applyPairs, {});
131
- // Return a weighted depth value for a uiView.
131
+ // Return a weighted depth value for a ngView.
132
132
  // The depth is the nesting depth of ui-views (based on FQN; times 10,000)
133
- // plus the depth of the state that is populating the uiView
134
- function uiViewDepth(uiView) {
133
+ // plus the depth of the state that is populating the ngView
134
+ function ngViewDepth(ngView) {
135
135
  const stateDepth = (context) =>
136
136
  context && context.parent ? stateDepth(context.parent) + 1 : 1;
137
137
  return (
138
- uiView.fqn.split(".").length * 10000 +
139
- stateDepth(uiView.creationContext)
138
+ ngView.fqn.split(".").length * 10000 +
139
+ stateDepth(ngView.creationContext)
140
140
  );
141
141
  }
142
142
  // Return the ViewConfig's context's depth in the context tree.
@@ -151,34 +151,34 @@ export class ViewService {
151
151
  (depthFn, posNeg, left, right) =>
152
152
  posNeg * (depthFn(left) - depthFn(right)),
153
153
  );
154
- const matchingConfigPair = (uiView) => {
154
+ const matchingConfigPair = (ngView) => {
155
155
  const matchingConfigs = this._viewConfigs.filter(
156
- ViewService.matches(uiViewsByFqn, uiView),
156
+ ViewService.matches(ngViewsByFqn, ngView),
157
157
  );
158
158
  if (matchingConfigs.length > 1) {
159
159
  // This is OK. Child states can target a ui-view that the parent state also targets (the child wins)
160
160
  // Sort by depth and return the match from the deepest child
161
- // console.log(`Multiple matching view configs for ${uiView.fqn}`, matchingConfigs);
161
+ // console.log(`Multiple matching view configs for ${ngView.fqn}`, matchingConfigs);
162
162
  matchingConfigs.sort(depthCompare(viewConfigDepth, -1)); // descending
163
163
  }
164
- return { uiView, viewConfig: matchingConfigs[0] };
164
+ return { ngView, viewConfig: matchingConfigs[0] };
165
165
  };
166
166
  const configureUIView = (tuple) => {
167
167
  // If a parent ui-view is reconfigured, it could destroy child ui-views.
168
- // Before configuring a child ui-view, make sure it's still in the active uiViews array.
169
- if (this._uiViews.indexOf(tuple.uiView) !== -1)
170
- tuple.uiView.configUpdated(tuple.viewConfig);
168
+ // Before configuring a child ui-view, make sure it's still in the active ngViews array.
169
+ if (this._ngViews.indexOf(tuple.ngView) !== -1)
170
+ tuple.ngView.configUpdated(tuple.viewConfig);
171
171
  };
172
172
  // Sort views by FQN and state depth. Process uiviews nearest the root first.
173
- const uiViewTuples = this._uiViews
174
- .sort(depthCompare(uiViewDepth, 1))
173
+ const ngViewTuples = this._ngViews
174
+ .sort(depthCompare(ngViewDepth, 1))
175
175
  .map(matchingConfigPair);
176
- const matchedViewConfigs = uiViewTuples.map((tuple) => tuple.viewConfig);
176
+ const matchedViewConfigs = ngViewTuples.map((tuple) => tuple.viewConfig);
177
177
  const unmatchedConfigTuples = this._viewConfigs
178
178
  .filter((config) => !inArray(matchedViewConfigs, config))
179
- .map((viewConfig) => ({ uiView: undefined, viewConfig }));
180
- uiViewTuples.forEach(configureUIView);
181
- const allTuples = uiViewTuples.concat(unmatchedConfigTuples);
179
+ .map((viewConfig) => ({ ngView: undefined, viewConfig }));
180
+ ngViewTuples.forEach(configureUIView);
181
+ const allTuples = ngViewTuples.concat(unmatchedConfigTuples);
182
182
  this._listeners.forEach((cb) => cb(allTuples));
183
183
  trace.traceViewSync(allTuples);
184
184
  }
@@ -194,29 +194,29 @@ export class ViewService {
194
194
  * Note: There is no corresponding `deregisterUIView`.
195
195
  * A `ui-view` should hang on to the return value of `registerUIView` and invoke it to deregister itself.
196
196
  *
197
- * @param uiView The metadata for a UIView
197
+ * @param ngView The metadata for a UIView
198
198
  * @return a de-registration function used when the view is destroyed.
199
199
  */
200
- registerUIView(uiView) {
201
- trace.traceViewServiceUIViewEvent("-> Registering", uiView);
202
- const uiViews = this._uiViews;
200
+ registerUIView(ngView) {
201
+ trace.traceViewServiceUIViewEvent("-> Registering", ngView);
202
+ const ngViews = this._ngViews;
203
203
  const fqnAndTypeMatches = (uiv) =>
204
- uiv.fqn === uiView.fqn && uiv.$type === uiView.$type;
205
- if (uiViews.filter(fqnAndTypeMatches).length)
206
- trace.traceViewServiceUIViewEvent("!!!! duplicate uiView named:", uiView);
207
- uiViews.push(uiView);
204
+ uiv.fqn === ngView.fqn && uiv.$type === ngView.$type;
205
+ if (ngViews.filter(fqnAndTypeMatches).length)
206
+ trace.traceViewServiceUIViewEvent("!!!! duplicate ngView named:", ngView);
207
+ ngViews.push(ngView);
208
208
  this.sync();
209
209
  return () => {
210
- const idx = uiViews.indexOf(uiView);
210
+ const idx = ngViews.indexOf(ngView);
211
211
  if (idx === -1) {
212
212
  trace.traceViewServiceUIViewEvent(
213
- "Tried removing non-registered uiView",
214
- uiView,
213
+ "Tried removing non-registered ngView",
214
+ ngView,
215
215
  );
216
216
  return;
217
217
  }
218
- trace.traceViewServiceUIViewEvent("<- Deregistering", uiView);
219
- removeFrom(uiViews)(uiView);
218
+ trace.traceViewServiceUIViewEvent("<- Deregistering", ngView);
219
+ removeFrom(ngViews)(ngView);
220
220
  };
221
221
  }
222
222
  /**
@@ -225,7 +225,7 @@ export class ViewService {
225
225
  * @return {Array} Returns an array of fully-qualified view names.
226
226
  */
227
227
  available() {
228
- return this._uiViews.map(prop("fqn"));
228
+ return this._ngViews.map(prop("fqn"));
229
229
  }
230
230
  /**
231
231
  * Returns the list of views on the page containing loaded content.
@@ -233,7 +233,7 @@ export class ViewService {
233
233
  * @return {Array} Returns an array of fully-qualified view names.
234
234
  */
235
235
  active() {
236
- return this._uiViews.filter(prop("$config")).map(prop("name"));
236
+ return this._ngViews.filter(prop("$config")).map(prop("name"));
237
237
  }
238
238
  }
239
239
  /**
@@ -269,7 +269,7 @@ export class ViewService {
269
269
  * </ui-view>
270
270
  * </ui-view>
271
271
  *
272
- * uiViews: [
272
+ * ngViews: [
273
273
  * { fqn: "$default", creationContext: { name: "" } },
274
274
  * { fqn: "$default.foo", creationContext: { name: "A" } },
275
275
  * { fqn: "$default.foo.$default", creationContext: { name: "A.B" } }
@@ -278,10 +278,10 @@ export class ViewService {
278
278
  *
279
279
  * These four view configs all match the ui-view with the fqn: "$default.foo.$default.bar":
280
280
  *
281
- * - ViewConfig1: { uiViewName: "bar", uiViewContextAnchor: "A.B.C" }
282
- * - ViewConfig2: { uiViewName: "$default.bar", uiViewContextAnchor: "A.B" }
283
- * - ViewConfig3: { uiViewName: "foo.$default.bar", uiViewContextAnchor: "A" }
284
- * - ViewConfig4: { uiViewName: "$default.foo.$default.bar", uiViewContextAnchor: "" }
281
+ * - ViewConfig1: { ngViewName: "bar", ngViewContextAnchor: "A.B.C" }
282
+ * - ViewConfig2: { ngViewName: "$default.bar", ngViewContextAnchor: "A.B" }
283
+ * - ViewConfig3: { ngViewName: "foo.$default.bar", ngViewContextAnchor: "A" }
284
+ * - ViewConfig4: { ngViewName: "$default.foo.$default.bar", ngViewContextAnchor: "" }
285
285
  *
286
286
  * Using ViewConfig3 as an example, it matches the ui-view with fqn "$default.foo.$default.bar" because:
287
287
  * - The ViewConfig's segmented target name is: [ "foo", "$default", "bar" ]
@@ -293,13 +293,13 @@ export class ViewService {
293
293
  *
294
294
  * @internal
295
295
  */
296
- ViewService.matches = (uiViewsByFqn, uiView) => (viewConfig) => {
296
+ ViewService.matches = (ngViewsByFqn, ngView) => (viewConfig) => {
297
297
  // Don't supply an ng1 ui-view with an ng2 ViewConfig, etc
298
- if (uiView.$type !== viewConfig.viewDecl.$type) return false;
299
- // Split names apart from both viewConfig and uiView into segments
298
+ if (ngView.$type !== viewConfig.viewDecl.$type) return false;
299
+ // Split names apart from both viewConfig and ngView into segments
300
300
  const vc = viewConfig.viewDecl;
301
- const vcSegments = vc.$uiViewName.split(".");
302
- const uivSegments = uiView.fqn.split(".");
301
+ const vcSegments = vc.$ngViewName.split(".");
302
+ const uivSegments = ngView.fqn.split(".");
303
303
  // Check if the tails of the segment arrays match. ex, these arrays' tails match:
304
304
  // vc: ["foo", "bar"], uiv fqn: ["$default", "foo", "bar"]
305
305
  if (!equals(vcSegments, uivSegments.slice(0 - vcSegments.length)))
@@ -308,6 +308,6 @@ ViewService.matches = (uiViewsByFqn, uiView) => (viewConfig) => {
308
308
  // ["$default", "foo"].join(".") == "$default.foo", does the ui-view $default.foo context match?
309
309
  const negOffset = 1 - vcSegments.length || undefined;
310
310
  const fqnToFirstSegment = uivSegments.slice(0, negOffset).join(".");
311
- const uiViewContext = uiViewsByFqn[fqnToFirstSegment].creationContext;
312
- return vc.$uiViewContextAnchor === (uiViewContext && uiViewContext.name);
311
+ const ngViewContext = ngViewsByFqn[fqnToFirstSegment].creationContext;
312
+ return vc.$ngViewContextAnchor === (ngViewContext && ngViewContext.name);
313
313
  };
@@ -102,11 +102,7 @@ export function Browser($log, $$taskTrackerFactory) {
102
102
  // lastBrowserUrl && stripHash(lastBrowserUrl) === stripHash(url);
103
103
  lastBrowserUrl = url;
104
104
  lastHistoryState = state;
105
- // Don't use history API if only the hash changed
106
- // due to a bug in IE10/IE11 which leads
107
- // to not firing a `hashchange` nor `popstate` event
108
- // in some cases (see #9143).
109
- history[replace ? "replaceState" : "pushState"](state, "", url);
105
+ history.pushState(state, "", url);
110
106
  cacheState();
111
107
  return self;
112
108
  // getter
package/src/shared/hof.js CHANGED
@@ -77,7 +77,7 @@ export function compose() {
77
77
  * let piped = pipe(f,g,h);
78
78
  * then, piped is: h(g(f(x)))
79
79
  */
80
- export function pipe(...funcs) {
80
+ export function pipe() {
81
81
  return compose.apply(null, [].slice.call(arguments).reverse());
82
82
  }
83
83
  /**
@@ -48,6 +48,7 @@ describe("angular", () => {
48
48
 
49
49
  afterEach(() => {
50
50
  dealoc(element);
51
+ jqLite.CACHE.clear();
51
52
  });
52
53
 
53
54
  describe("case", () => {