@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.
- package/README.md +1 -2
- package/dist/angular-ts.esm.js +1 -1
- package/dist/angular-ts.umd.js +1 -1
- package/e2e/unit.spec.ts +2 -1
- package/index.html +8 -9
- package/package.json +1 -1
- package/src/core/pubsub.js +329 -0
- package/src/router/hooks/core-resolvables.js +12 -11
- package/src/router/hooks/ignored-transition.js +1 -1
- package/src/router/hooks/lazy-load.js +40 -41
- package/src/router/hooks/redirect-to.js +32 -29
- package/src/router/hooks/update-globals.js +1 -1
- package/src/router/hooks/url.js +33 -24
- package/src/router/hooks/views.js +21 -20
- package/src/router/params/param-factory.js +17 -0
- package/src/router/router.js +74 -10
- package/src/router/state/state-queue-manager.js +5 -4
- package/src/router/state/state-registry.js +8 -5
- package/src/router/state/state-service.js +34 -29
- package/src/router/transition/hook-builder.js +2 -2
- package/src/router/transition/transition-hook.js +2 -1
- package/src/router/transition/transition-service.js +12 -18
- package/src/router/transition/transition.js +28 -25
- package/src/router/url/url-config.js +1 -49
- package/src/router/url/url-matcher-factory.js +10 -51
- package/src/router/url/url-router.js +27 -17
- package/src/router/url/url-rule.js +9 -13
- package/src/router/url/url-rules.js +3 -3
- package/src/router/url/url-service.js +22 -18
- package/src/router/view/view.js +3 -3
- package/src/shared/hof.js +1 -1
- package/test/angular.spec.js +1 -0
- package/test/aria/aria.spec.js +2 -1
- package/test/core/pubsub.spec.js +314 -0
- package/test/directive/bind.spec.js +2 -1
- package/test/directive/boolean.spec.js +4 -2
- package/test/directive/change.spec.js +1 -1
- package/test/directive/class.spec.js +1 -0
- package/test/directive/click.spec.js +2 -1
- package/test/directive/cloak.spec.js +1 -2
- package/test/directive/{constoller.spec.js → controller.spec.js} +1 -0
- package/test/directive/element-style.spec.js +1 -0
- package/test/directive/event.spec.js +1 -1
- package/test/directive/href.spec.js +2 -1
- package/test/directive/init.spec.js +1 -0
- package/test/directive/input.spec.js +200 -285
- package/test/directive/list.spec.js +2 -1
- package/test/directive/model.spec.js +1 -0
- package/test/directive/non-bindable.spec.js +2 -1
- package/test/directive/script.spec.js +1 -0
- package/test/directive/scrset.spec.js +2 -1
- package/test/directive/show-hide.spec.js +1 -0
- package/test/directive/src.spec.js +2 -1
- package/test/directive/style.spec.js +1 -0
- package/test/directive/switch.spec.js +2 -1
- package/test/directive/validators.spec.js +1 -1
- package/test/router/view-hook.spec.js +2 -2
- package/test/router/view-scroll.spec.js +1 -1
- package/test/router/view.spec.js +1 -1
- package/types/router/core/common/coreservices.d.ts +2 -3
- package/types/router/core/globals.d.ts +1 -4
- package/types/router/core/interface.d.ts +2 -8
- package/types/router/core/params/paramTypes.d.ts +0 -1
- package/types/router/core/router.d.ts +2 -3
- package/types/router/core/state/stateQueueManager.d.ts +1 -3
- package/types/router/core/state/stateRegistry.d.ts +0 -2
- package/types/router/core/state/stateService.d.ts +1 -2
- package/types/router/core/transition/interface.d.ts +3 -3
- package/types/router/core/transition/transitionService.d.ts +1 -2
- package/types/router/core/url/urlConfig.d.ts +1 -2
- package/types/router/core/url/urlRules.d.ts +1 -2
- package/types/router/core/url/urlService.d.ts +1 -2
- package/types/router/locationServices.d.ts +0 -1
|
@@ -35,20 +35,6 @@ const stateSelf = prop("self");
|
|
|
35
35
|
* It has information about all states being entered and exited as a result of the transition.
|
|
36
36
|
*/
|
|
37
37
|
export class Transition {
|
|
38
|
-
/**
|
|
39
|
-
* Creates the transition-level hook registration functions
|
|
40
|
-
* (which can then be used to register hooks)
|
|
41
|
-
*/
|
|
42
|
-
createTransitionHookRegFns() {
|
|
43
|
-
this.router.transitionService._pluginapi
|
|
44
|
-
._getEvents()
|
|
45
|
-
.filter((type) => type.hookPhase !== TransitionHookPhase.CREATE)
|
|
46
|
-
.forEach((type) => makeEvent(this, this.router.transitionService, type));
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
getHooks(hookName) {
|
|
50
|
-
return this._registeredHooks[hookName];
|
|
51
|
-
}
|
|
52
38
|
/**
|
|
53
39
|
* Creates a new Transition object.
|
|
54
40
|
*
|
|
@@ -59,10 +45,12 @@ export class Transition {
|
|
|
59
45
|
* @param fromPath The path of [[PathNode]]s from which the transition is leaving. The last node in the `fromPath`
|
|
60
46
|
* encapsulates the "from state".
|
|
61
47
|
* @param targetState The target state and parameters being transitioned to (also, the transition options)
|
|
62
|
-
* @param {import('../
|
|
48
|
+
* @param {import('../transition/transition-service').TransitionService} transitionService The [[TransitionService]] instance
|
|
63
49
|
* @internal
|
|
64
50
|
*/
|
|
65
|
-
constructor(fromPath, targetState,
|
|
51
|
+
constructor(fromPath, targetState, transitionService, globals) {
|
|
52
|
+
this.globals = globals;
|
|
53
|
+
this.transitionService = transitionService;
|
|
66
54
|
this._deferred = services.$q.defer();
|
|
67
55
|
/**
|
|
68
56
|
* This promise is resolved or rejected based on the outcome of the Transition.
|
|
@@ -76,8 +64,7 @@ export class Transition {
|
|
|
76
64
|
|
|
77
65
|
this._hookBuilder = new HookBuilder(this);
|
|
78
66
|
/** Checks if this transition is currently active/running. */
|
|
79
|
-
this.isActive = () => this.
|
|
80
|
-
this.router = router;
|
|
67
|
+
this.isActive = () => this.globals.transition === this;
|
|
81
68
|
this._targetState = targetState;
|
|
82
69
|
if (!targetState.valid()) {
|
|
83
70
|
throw new Error(targetState.error());
|
|
@@ -87,7 +74,7 @@ export class Transition {
|
|
|
87
74
|
{ current: val(this) },
|
|
88
75
|
targetState.options(),
|
|
89
76
|
);
|
|
90
|
-
this.$id =
|
|
77
|
+
this.$id = transitionService._transitionCount++;
|
|
91
78
|
const toPath = PathUtils.buildToPath(fromPath, targetState);
|
|
92
79
|
this._treeChanges = PathUtils.treeChanges(
|
|
93
80
|
fromPath,
|
|
@@ -99,12 +86,28 @@ export class Transition {
|
|
|
99
86
|
TransitionHookPhase.CREATE,
|
|
100
87
|
);
|
|
101
88
|
TransitionHook.invokeHooks(onCreateHooks, () => null);
|
|
102
|
-
this.applyViewConfigs(
|
|
89
|
+
this.applyViewConfigs();
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
/**
|
|
93
|
+
* Creates the transition-level hook registration functions
|
|
94
|
+
* (which can then be used to register hooks)
|
|
95
|
+
*/
|
|
96
|
+
createTransitionHookRegFns() {
|
|
97
|
+
this.transitionService._pluginapi
|
|
98
|
+
._getEvents()
|
|
99
|
+
.filter((type) => type.hookPhase !== TransitionHookPhase.CREATE)
|
|
100
|
+
.forEach((type) => makeEvent(this, this.transitionService, type));
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
getHooks(hookName) {
|
|
104
|
+
return this._registeredHooks[hookName];
|
|
103
105
|
}
|
|
104
|
-
|
|
106
|
+
|
|
107
|
+
applyViewConfigs() {
|
|
105
108
|
const enteringStates = this._treeChanges.entering.map((node) => node.state);
|
|
106
109
|
PathUtils.applyViewConfigs(
|
|
107
|
-
|
|
110
|
+
this.transitionService.$view,
|
|
108
111
|
this._treeChanges.to,
|
|
109
112
|
enteringStates,
|
|
110
113
|
);
|
|
@@ -475,7 +478,7 @@ export class Transition {
|
|
|
475
478
|
redirectOpts,
|
|
476
479
|
);
|
|
477
480
|
targetState = targetState.withOptions(newOptions, true);
|
|
478
|
-
const newTransition = this.
|
|
481
|
+
const newTransition = this.transitionService.create(
|
|
479
482
|
this._treeChanges.from,
|
|
480
483
|
targetState,
|
|
481
484
|
);
|
|
@@ -557,7 +560,7 @@ export class Transition {
|
|
|
557
560
|
}
|
|
558
561
|
|
|
559
562
|
_ignoredReason() {
|
|
560
|
-
const pending = this.
|
|
563
|
+
const pending = this.globals.transition;
|
|
561
564
|
const reloadState = this._options.reloadState;
|
|
562
565
|
const same = (pathA, pathB) => {
|
|
563
566
|
if (pathA.length !== pathB.length) return false;
|
|
@@ -619,7 +622,7 @@ export class Transition {
|
|
|
619
622
|
return TransitionHook.invokeHooks(allRunHooks, done);
|
|
620
623
|
};
|
|
621
624
|
const startTransition = () => {
|
|
622
|
-
const globals = this.
|
|
625
|
+
const globals = this.globals;
|
|
623
626
|
globals.lastStartedTransitionId = this.$id;
|
|
624
627
|
globals.transition = this;
|
|
625
628
|
globals.transitionHistory.enqueue(this);
|
|
@@ -14,12 +14,7 @@ import { isDefined, isString } from "../../shared/utils";
|
|
|
14
14
|
* This API is found at `router.urlService.config` (see: [[UIRouter.urlService]], [[URLService.config]])
|
|
15
15
|
*/
|
|
16
16
|
export class UrlConfig {
|
|
17
|
-
|
|
18
|
-
* @param {import('../router').UIRouter} router
|
|
19
|
-
*/
|
|
20
|
-
constructor(router) {
|
|
21
|
-
/** @type {import('../router').UIRouter} */
|
|
22
|
-
this.router = router;
|
|
17
|
+
constructor() {
|
|
23
18
|
/** @type {ParamTypes} */
|
|
24
19
|
this.paramTypes = new ParamTypes();
|
|
25
20
|
/** @type {boolean} */
|
|
@@ -30,49 +25,6 @@ export class UrlConfig {
|
|
|
30
25
|
this._isStrictMode = true;
|
|
31
26
|
/** @type {boolean} */
|
|
32
27
|
this._defaultSquashPolicy = false;
|
|
33
|
-
|
|
34
|
-
// Delegate these calls to the current LocationConfig implementation
|
|
35
|
-
/**
|
|
36
|
-
* Gets the base Href, e.g., `http://localhost/approot/`
|
|
37
|
-
*
|
|
38
|
-
* @return the application's base href
|
|
39
|
-
*/
|
|
40
|
-
this.baseHref = () => this.router.urlService.baseHref();
|
|
41
|
-
/**
|
|
42
|
-
* Gets or sets the hashPrefix
|
|
43
|
-
*
|
|
44
|
-
* This only applies when not running in [[html5Mode]] (pushstate mode)
|
|
45
|
-
*
|
|
46
|
-
* If the current url is `http://localhost/app#!/uirouter/path/#anchor`, it returns `!` which is the prefix for the "hashbang" portion.
|
|
47
|
-
*
|
|
48
|
-
* @return the hash prefix
|
|
49
|
-
*/
|
|
50
|
-
this.hashPrefix = (newprefix) =>
|
|
51
|
-
this.router.$locationProvider.hashPrefix(newprefix);
|
|
52
|
-
/**
|
|
53
|
-
* Gets the host, e.g., `localhost`
|
|
54
|
-
*
|
|
55
|
-
* @return {string} the protocol
|
|
56
|
-
*/
|
|
57
|
-
this.host = () => this.router.urlService.$location.host();
|
|
58
|
-
/**
|
|
59
|
-
* Returns true when running in pushstate mode
|
|
60
|
-
*
|
|
61
|
-
* @return {boolean} true when running in html5 mode (pushstate mode).
|
|
62
|
-
*/
|
|
63
|
-
this.html5Mode = () => this.router.urlService.html5Mode();
|
|
64
|
-
/**
|
|
65
|
-
* Gets the port, e.g., `80`
|
|
66
|
-
*
|
|
67
|
-
* @return {number} the port number
|
|
68
|
-
*/
|
|
69
|
-
this.port = () => this.router.urlService.$location.port();
|
|
70
|
-
/**
|
|
71
|
-
* Gets the protocol, e.g., `http`
|
|
72
|
-
*
|
|
73
|
-
* @return {string} the protocol
|
|
74
|
-
*/
|
|
75
|
-
this.protocol = () => this.router.urlService.$location.protocol();
|
|
76
28
|
}
|
|
77
29
|
/**
|
|
78
30
|
* Defines whether URL matching should be case sensitive (the default behavior), or not.
|
|
@@ -1,40 +1,7 @@
|
|
|
1
1
|
import { forEach, isDefined, isFunction, isObject } from "../../shared/utils";
|
|
2
2
|
import { UrlMatcher } from "./url-matcher";
|
|
3
|
-
import {
|
|
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(
|
|
47
|
-
this.
|
|
13
|
+
constructor(urlServiceConfig) {
|
|
14
|
+
this.urlServiceConfig = urlServiceConfig;
|
|
48
15
|
/** Creates a new [[Param]] for a given location (DefType) */
|
|
49
|
-
this.paramFactory = new ParamFactory(
|
|
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
|
-
|
|
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.
|
|
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.
|
|
72
|
+
const urlConfig = this.urlServiceConfig;
|
|
114
73
|
urlConfig.paramTypes.enqueue = false;
|
|
115
74
|
urlConfig.paramTypes._flushTypeQueue();
|
|
116
75
|
return this;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { stripLastPathElement } from "../../shared/strings";
|
|
2
|
-
|
|
2
|
+
|
|
3
3
|
function appendBasePath(url, isHtml5, absolute, baseHref) {
|
|
4
4
|
if (baseHref === "/") return url;
|
|
5
5
|
if (isHtml5) return stripLastPathElement(baseHref) + url;
|
|
@@ -16,16 +16,16 @@ function appendBasePath(url, isHtml5, absolute, baseHref) {
|
|
|
16
16
|
*/
|
|
17
17
|
export class UrlRouter {
|
|
18
18
|
/**
|
|
19
|
-
*
|
|
20
|
-
* @param {import('../router').UIRouter} router
|
|
19
|
+
* @param {angular.UrlService} urlService
|
|
21
20
|
*/
|
|
22
|
-
constructor(
|
|
23
|
-
this.
|
|
24
|
-
this.urlRuleFactory =
|
|
21
|
+
constructor(urlService, urlRuleFactory, $locationProvider) {
|
|
22
|
+
this.urlService = urlService;
|
|
23
|
+
this.urlRuleFactory = urlRuleFactory;
|
|
24
|
+
this.$locationProvider = $locationProvider;
|
|
25
25
|
}
|
|
26
|
-
|
|
26
|
+
|
|
27
27
|
update(read) {
|
|
28
|
-
const $url = this.
|
|
28
|
+
const $url = this.urlService;
|
|
29
29
|
if (read) {
|
|
30
30
|
this.location = $url.url();
|
|
31
31
|
return;
|
|
@@ -34,8 +34,6 @@ export class UrlRouter {
|
|
|
34
34
|
$url.url(this.location, true);
|
|
35
35
|
}
|
|
36
36
|
/**
|
|
37
|
-
* Internal API.
|
|
38
|
-
*
|
|
39
37
|
* Pushes a new location to the browser history.
|
|
40
38
|
*
|
|
41
39
|
* @internal
|
|
@@ -45,7 +43,7 @@ export class UrlRouter {
|
|
|
45
43
|
*/
|
|
46
44
|
push(urlMatcher, params, options) {
|
|
47
45
|
const replace = options && !!options.replace;
|
|
48
|
-
this.
|
|
46
|
+
this.urlService.url(urlMatcher.format(params || {}), replace);
|
|
49
47
|
}
|
|
50
48
|
/**
|
|
51
49
|
* Builds and returns a URL with interpolated parameters
|
|
@@ -70,18 +68,30 @@ export class UrlRouter {
|
|
|
70
68
|
let url = urlMatcher.format(params);
|
|
71
69
|
if (url == null) return null;
|
|
72
70
|
options = options || { absolute: false };
|
|
73
|
-
const cfg = this.
|
|
74
|
-
const isHtml5 =
|
|
71
|
+
const cfg = this.urlService.config;
|
|
72
|
+
const isHtml5 = this.urlService.html5Mode();
|
|
75
73
|
if (!isHtml5 && url !== null) {
|
|
76
|
-
url = "#" +
|
|
74
|
+
url = "#" + this.$locationProvider.hashPrefix() + url;
|
|
77
75
|
}
|
|
78
|
-
url = appendBasePath(
|
|
76
|
+
url = appendBasePath(
|
|
77
|
+
url,
|
|
78
|
+
isHtml5,
|
|
79
|
+
options.absolute,
|
|
80
|
+
this.urlService.baseHref(),
|
|
81
|
+
);
|
|
79
82
|
if (!options.absolute || !url) {
|
|
80
83
|
return url;
|
|
81
84
|
}
|
|
82
85
|
const slash = !isHtml5 && url ? "/" : "";
|
|
83
|
-
const cfgPort =
|
|
86
|
+
const cfgPort = this.urlService.$location.port();
|
|
84
87
|
const port = cfgPort === 80 || cfgPort === 443 ? "" : ":" + cfgPort;
|
|
85
|
-
return [
|
|
88
|
+
return [
|
|
89
|
+
cfg.protocol(),
|
|
90
|
+
"://",
|
|
91
|
+
this.urlService.$location.host(),
|
|
92
|
+
port,
|
|
93
|
+
slash,
|
|
94
|
+
url,
|
|
95
|
+
].join("");
|
|
86
96
|
}
|
|
87
97
|
}
|
|
@@ -13,12 +13,10 @@ import { StateObject } from "../state/state-object";
|
|
|
13
13
|
* - [[StateObject]]
|
|
14
14
|
*/
|
|
15
15
|
export class UrlRuleFactory {
|
|
16
|
-
constructor(
|
|
17
|
-
this.
|
|
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.
|
|
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,
|
|
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 =
|
|
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
|
|
65
|
+
* This API is found at `$urlService.rules` (see: [[UIRouter.urlService]], [[URLService.rules]])
|
|
66
66
|
*/
|
|
67
67
|
export class UrlRules {
|
|
68
|
-
constructor(
|
|
68
|
+
constructor(urlRuleFactory) {
|
|
69
69
|
this._sortFn = defaultRuleSortFn;
|
|
70
70
|
this._rules = [];
|
|
71
71
|
this._id = 0;
|
|
72
|
-
this.urlRuleFactory =
|
|
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(
|
|
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(
|
|
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(
|
|
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
|
|
187
|
+
const stateService = this.stateService;
|
|
192
188
|
const url = {
|
|
193
|
-
path:
|
|
194
|
-
search:
|
|
195
|
-
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) =>
|
|
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
|
-
|
|
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
|
|
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.
|
package/src/router/view/view.js
CHANGED
|
@@ -26,9 +26,9 @@ import { trace } from "../common/trace";
|
|
|
26
26
|
*/
|
|
27
27
|
export class ViewService {
|
|
28
28
|
/**
|
|
29
|
-
* @param {
|
|
29
|
+
* @param {number} $id
|
|
30
30
|
*/
|
|
31
|
-
constructor(
|
|
31
|
+
constructor($id) {
|
|
32
32
|
this._uiViews = [];
|
|
33
33
|
this._viewConfigs = [];
|
|
34
34
|
this._viewConfigFactories = {};
|
|
@@ -37,7 +37,7 @@ 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) => `${
|
|
40
|
+
find(this._uiViews, (view) => `${$id}.${view.id}` === id),
|
|
41
41
|
_registeredUIViews: () => this._uiViews,
|
|
42
42
|
_activeViewConfigs: () => this._viewConfigs,
|
|
43
43
|
_onSync: (listener) => {
|
package/src/shared/hof.js
CHANGED
package/test/angular.spec.js
CHANGED
package/test/aria/aria.spec.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { createInjector } from "../../src/injector";
|
|
2
2
|
import { publishExternalAPI } from "../../src/public";
|
|
3
|
-
import { dealoc } from "../../src/jqLite";
|
|
3
|
+
import { dealoc, jqLite } from "../../src/jqLite";
|
|
4
4
|
|
|
5
5
|
describe("$aria", () => {
|
|
6
6
|
let scope;
|
|
@@ -17,6 +17,7 @@ describe("$aria", () => {
|
|
|
17
17
|
|
|
18
18
|
afterEach(() => {
|
|
19
19
|
dealoc(element);
|
|
20
|
+
jqLite.CACHE.clear();
|
|
20
21
|
});
|
|
21
22
|
|
|
22
23
|
describe("with `ngAriaDisable`", () => {
|