@angular-wave/angular.ts 0.0.23 → 0.0.25
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/angular-ts.esm.js +1 -1
- package/dist/angular-ts.umd.js +1 -1
- package/package.json +1 -1
- package/src/core/compile.js +2 -3
- package/src/core/parser/parse.js +2 -3
- package/src/router/directives/{stateDirectives.js → state-directives.js} +1 -2
- package/src/router/directives/{viewDirective.js → view-directive.js} +1 -1
- package/src/router/globals.js +1 -1
- package/src/router/hooks/{ignoredTransition.js → ignored-transition.js} +1 -1
- package/src/router/hooks/{redirectTo.js → redirect-to.js} +1 -1
- package/src/router/hooks/resolve.js +1 -1
- package/src/router/index.js +7 -9
- package/src/router/{locationServices.js → location-services.js} +3 -27
- package/src/router/params/{paramTypes.js → param-types.js} +3 -4
- package/src/router/params/param.js +1 -1
- package/src/router/path/{pathUtils.js → path-utils.js} +2 -2
- package/src/router/resolve/resolvable.js +2 -2
- package/src/router/resolve/{resolveContext.js → resolve-context.js} +1 -1
- package/src/router/router.js +11 -9
- package/src/router/services.js +25 -4
- package/src/router/state/{stateBuilder.js → state-builder.js} +2 -3
- package/src/router/state/{stateQueueManager.js → state-queue-manager.js} +2 -1
- package/src/router/state/{stateRegistry.js → state-registry.js} +3 -3
- package/src/router/state/{stateService.js → state-service.js} +8 -7
- package/src/router/state/views.js +1 -1
- package/src/router/{templateFactory.js → template-factory.js} +84 -48
- package/src/router/transition/{hookBuilder.js → hook-builder.js} +3 -3
- package/src/router/transition/{transitionEventType.js → transition-event-type.js} +1 -1
- package/src/router/transition/{transitionHook.js → transition-hook.js} +2 -2
- package/src/router/transition/{transitionService.js → transition-service.js} +12 -46
- package/src/router/transition/transition.js +8 -40
- package/src/router/url/{urlConfig.js → url-config.js} +1 -1
- package/src/router/url/{urlMatcherFactory.js → url-matcher-factory.js} +1 -1
- package/src/router/url/{urlMatcher.js → url-matcher.js} +0 -2
- package/src/router/url/{urlRouter.js → url-router.js} +1 -5
- package/src/router/url/{urlRule.js → url-rule.js} +4 -4
- package/src/router/url/{urlRules.js → url-rules.js} +3 -4
- package/src/router/url/{urlService.js → url-service.js} +10 -6
- package/src/router/view/view.js +1 -5
- package/src/shared/common.js +0 -2
- package/src/shared/strings.js +2 -2
- package/test/router/view.spec.js +5 -5
- package/test/test-utils.js +9 -0
- package/types/router/legacy/resolveService.d.ts +1 -1
- package/types/router/statebuilders/onEnterExitRetain.d.ts +1 -1
- package/types/router/statebuilders/views.d.ts +1 -2
- /package/src/router/hooks/{coreResolvables.js → core-resolvables.js} +0 -0
- /package/src/router/hooks/{invalidTransition.js → invalid-transition.js} +0 -0
- /package/src/router/hooks/{lazyLoad.js → lazy-load.js} +0 -0
- /package/src/router/hooks/{onEnterExitRetain.js → on-enter-exit-retain.js} +0 -0
- /package/src/router/hooks/{updateGlobals.js → update-globals.js} +0 -0
- /package/src/router/params/{paramType.js → param-type.js} +0 -0
- /package/src/router/params/{stateParams.js → state-params.js} +0 -0
- /package/src/router/path/{pathNode.js → path-node.js} +0 -0
- /package/src/router/state/{stateMatcher.js → state-matcher.js} +0 -0
- /package/src/router/state/{stateObject.js → state-object.js} +0 -0
- /package/src/router/state/{targetState.js → target-state.js} +0 -0
- /package/src/router/{stateFilters.js → state-filters.js} +0 -0
- /package/src/router/{stateProvider.js → state-provider.js} +0 -0
- /package/src/router/transition/{hookRegistry.js → hook-registry.js} +0 -0
- /package/src/router/transition/{rejectFactory.js → reject-factory.js} +0 -0
- /package/src/router/{viewScroll.js → view-scroll.js} +0 -0
|
@@ -1,29 +1,48 @@
|
|
|
1
|
-
/** @publicapi @module view */ /** */
|
|
2
1
|
import { isDefined, isFunction, isObject } from "../shared/utils";
|
|
3
2
|
import { services } from "./common/coreservices";
|
|
4
3
|
import { tail, unnestR } from "../shared/common";
|
|
5
4
|
import { Resolvable } from "./resolve/resolvable";
|
|
6
5
|
import { kebobString } from "../shared/strings";
|
|
7
6
|
|
|
7
|
+
/**
|
|
8
|
+
* @typedef BindingTuple
|
|
9
|
+
* @property {string} name
|
|
10
|
+
* @property {string} type
|
|
11
|
+
*/
|
|
12
|
+
|
|
8
13
|
/**
|
|
9
14
|
* Service which manages loading of templates from a ViewConfig.
|
|
10
15
|
*/
|
|
11
16
|
export class TemplateFactory {
|
|
12
17
|
constructor() {
|
|
18
|
+
/** @type {boolean} */
|
|
13
19
|
this._useHttp = false;
|
|
14
|
-
this.$get = [
|
|
15
|
-
"$http",
|
|
16
|
-
"$templateCache",
|
|
17
|
-
"$templateRequest",
|
|
18
|
-
($http, $templateCache, $templateRequest) => {
|
|
19
|
-
this.$templateRequest = $templateRequest;
|
|
20
|
-
this.$http = $http;
|
|
21
|
-
this.$templateCache = $templateCache;
|
|
22
|
-
return this;
|
|
23
|
-
},
|
|
24
|
-
];
|
|
25
20
|
}
|
|
26
21
|
|
|
22
|
+
$get = [
|
|
23
|
+
"$http",
|
|
24
|
+
"$templateCache",
|
|
25
|
+
"$templateRequest",
|
|
26
|
+
"$q",
|
|
27
|
+
"$injector",
|
|
28
|
+
/**
|
|
29
|
+
* @param {angular.IHttpService} $http
|
|
30
|
+
* @param {angular.ITemplateCacheService} $templateCache
|
|
31
|
+
* @param {angular.ITemplateRequestService} $templateRequest
|
|
32
|
+
* @param {angular.IQService} $q
|
|
33
|
+
* @param {angular.auto.IInjectorService} $injector
|
|
34
|
+
* @returns
|
|
35
|
+
*/
|
|
36
|
+
($http, $templateCache, $templateRequest, $q, $injector) => {
|
|
37
|
+
this.$templateRequest = $templateRequest;
|
|
38
|
+
this.$http = $http;
|
|
39
|
+
this.$templateCache = $templateCache;
|
|
40
|
+
this.$q = $q;
|
|
41
|
+
this.$injector = $injector;
|
|
42
|
+
return this;
|
|
43
|
+
},
|
|
44
|
+
];
|
|
45
|
+
|
|
27
46
|
/**
|
|
28
47
|
* Forces the provider to use $http service directly
|
|
29
48
|
* @param {boolean} value
|
|
@@ -39,8 +58,9 @@ export class TemplateFactory {
|
|
|
39
58
|
* The following properties are search in the specified order, and the first one
|
|
40
59
|
* that is defined is used to create the template:
|
|
41
60
|
*
|
|
42
|
-
* @param
|
|
43
|
-
* @param
|
|
61
|
+
* @param {angular.Ng1ViewDeclaration} config
|
|
62
|
+
* @param {any} params Parameters to pass to the template function.
|
|
63
|
+
* @param {angular.ResolveContext} context The resolve context associated with the template's view
|
|
44
64
|
*
|
|
45
65
|
* @return {string|object} The template html as a string, or a promise for
|
|
46
66
|
* that string,or `null` if no template is configured.
|
|
@@ -48,34 +68,43 @@ export class TemplateFactory {
|
|
|
48
68
|
fromConfig(config, params, context) {
|
|
49
69
|
const defaultTemplate = "<ui-view></ui-view>";
|
|
50
70
|
const asTemplate = (result) =>
|
|
51
|
-
|
|
71
|
+
this.$q.when(result).then((str) => ({ template: str }));
|
|
52
72
|
const asComponent = (result) =>
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
+
this.$q.when(result).then((str) => ({ component: str }));
|
|
74
|
+
|
|
75
|
+
const getConfigType = (config) => {
|
|
76
|
+
if (isDefined(config.template)) return "template";
|
|
77
|
+
if (isDefined(config.templateUrl)) return "templateUrl";
|
|
78
|
+
if (isDefined(config.templateProvider)) return "templateProvider";
|
|
79
|
+
if (isDefined(config.component)) return "component";
|
|
80
|
+
if (isDefined(config.componentProvider)) return "componentProvider";
|
|
81
|
+
return "default";
|
|
82
|
+
};
|
|
83
|
+
|
|
84
|
+
switch (getConfigType(config)) {
|
|
85
|
+
case "template":
|
|
86
|
+
return asTemplate(this.fromString(config.template, params));
|
|
87
|
+
case "templateUrl":
|
|
88
|
+
return asTemplate(this.fromUrl(config.templateUrl, params));
|
|
89
|
+
case "templateProvider":
|
|
90
|
+
return asTemplate(
|
|
91
|
+
this.fromProvider(config.templateProvider, params, context),
|
|
92
|
+
);
|
|
93
|
+
case "component":
|
|
94
|
+
return asComponent(config.component);
|
|
95
|
+
case "componentProvider":
|
|
96
|
+
return asComponent(
|
|
97
|
+
this.fromComponentProvider(config.componentProvider, params, context),
|
|
98
|
+
);
|
|
99
|
+
default:
|
|
100
|
+
return asTemplate(defaultTemplate);
|
|
101
|
+
}
|
|
73
102
|
}
|
|
74
103
|
/**
|
|
75
104
|
* Creates a template from a string or a function returning a string.
|
|
76
105
|
*
|
|
77
|
-
* @param template html template as a string or function that returns an html template as a string.
|
|
78
|
-
* @param params Parameters to pass to the template function.
|
|
106
|
+
* @param {string | Function} template html template as a string or function that returns an html template as a string.
|
|
107
|
+
* @param {angular.RawParams} [params] Parameters to pass to the template function.
|
|
79
108
|
*
|
|
80
109
|
* @return {string|object} The template html as a string, or a promise for that
|
|
81
110
|
* string.
|
|
@@ -110,13 +139,14 @@ export class TemplateFactory {
|
|
|
110
139
|
/**
|
|
111
140
|
* Creates a template by invoking an injectable provider function.
|
|
112
141
|
*
|
|
113
|
-
* @param provider Function to invoke via `locals`
|
|
142
|
+
* @param {angular.IInjectable} provider Function to invoke via `locals`
|
|
114
143
|
* @param {Function} injectFn a function used to invoke the template provider
|
|
144
|
+
* @param {angular.ResolveContext} context
|
|
115
145
|
* @return {string|Promise.<string>} The template html as a string, or a promise
|
|
116
146
|
* for that string.
|
|
117
147
|
*/
|
|
118
148
|
fromProvider(provider, params, context) {
|
|
119
|
-
const deps =
|
|
149
|
+
const deps = this.$injector.annotate(provider);
|
|
120
150
|
const providerFn = Array.isArray(provider) ? tail(provider) : provider;
|
|
121
151
|
const resolvable = new Resolvable("", providerFn, deps);
|
|
122
152
|
return resolvable.get(context);
|
|
@@ -124,12 +154,12 @@ export class TemplateFactory {
|
|
|
124
154
|
/**
|
|
125
155
|
* Creates a component's template by invoking an injectable provider function.
|
|
126
156
|
*
|
|
127
|
-
* @param provider Function to invoke via `locals`
|
|
157
|
+
* @param {angular.IInjectable} provider Function to invoke via `locals`
|
|
128
158
|
* @param {Function} injectFn a function used to invoke the template provider
|
|
129
159
|
* @return {string} The template html as a string: "<component-name input1='::$resolve.foo'></component-name>".
|
|
130
160
|
*/
|
|
131
161
|
fromComponentProvider(provider, params, context) {
|
|
132
|
-
const deps =
|
|
162
|
+
const deps = this.$injector.annotate(provider);
|
|
133
163
|
const providerFn = Array.isArray(provider) ? tail(provider) : provider;
|
|
134
164
|
const resolvable = new Resolvable("", providerFn, deps);
|
|
135
165
|
return resolvable.get(context);
|
|
@@ -142,10 +172,10 @@ export class TemplateFactory {
|
|
|
142
172
|
* It analyses the component's bindings, then constructs a template that instantiates the component.
|
|
143
173
|
* The template wires input and output bindings to resolves or from the parent component.
|
|
144
174
|
*
|
|
145
|
-
* @param uiView {object} The parent ui-view (for binding outputs to callbacks)
|
|
146
|
-
* @param context The ResolveContext (for binding outputs to callbacks returned from resolves)
|
|
147
|
-
* @param component {string} Component's name in camel case.
|
|
148
|
-
* @param bindings An object defining the component's bindings: {foo: '<'}
|
|
175
|
+
* @param {angular.IAugmentedJQuery} uiView {object} The parent ui-view (for binding outputs to callbacks)
|
|
176
|
+
* @param {angular.ResolveContext} context The ResolveContext (for binding outputs to callbacks returned from resolves)
|
|
177
|
+
* @param {string} component {string} Component's name in camel case.
|
|
178
|
+
* @param {any} [bindings] An object defining the component's bindings: {foo: '<'}
|
|
149
179
|
* @return {string} The template as a string: "<component-name input1='::$resolve.foo'></component-name>".
|
|
150
180
|
*/
|
|
151
181
|
makeComponentTemplate(uiView, context, component, bindings) {
|
|
@@ -157,7 +187,8 @@ export class TemplateFactory {
|
|
|
157
187
|
const kebobed = kebobString(camelCase);
|
|
158
188
|
return /^(x|data)-/.exec(kebobed) ? `x-${kebobed}` : kebobed;
|
|
159
189
|
};
|
|
160
|
-
|
|
190
|
+
|
|
191
|
+
const attributeTpl = /** @param {BindingTuple} input*/ (input) => {
|
|
161
192
|
const { name, type } = input;
|
|
162
193
|
const attrName = kebob(name);
|
|
163
194
|
// If the ui-view has an attribute which matches a binding on the routed component
|
|
@@ -176,7 +207,7 @@ export class TemplateFactory {
|
|
|
176
207
|
if (type === "&") {
|
|
177
208
|
const res = context.getResolvable(resolveName);
|
|
178
209
|
const fn = res && res.data;
|
|
179
|
-
const args = (fn &&
|
|
210
|
+
const args = (fn && this.$injector.annotate(fn)) || [];
|
|
180
211
|
// account for array style injection, i.e., ['foo', function(foo) {}]
|
|
181
212
|
const arrayIdxStr = Array.isArray(fn) ? `[${fn.length - 1}]` : "";
|
|
182
213
|
return `${attrName}='$resolve.${resolveName}${arrayIdxStr}(${args.join(",")})'`;
|
|
@@ -189,7 +220,12 @@ export class TemplateFactory {
|
|
|
189
220
|
return `<${kebobName} ${attrs}></${kebobName}>`;
|
|
190
221
|
}
|
|
191
222
|
}
|
|
192
|
-
|
|
223
|
+
|
|
224
|
+
/**
|
|
225
|
+
* Gets all the directive(s)' inputs ('@', '=', and '<') and outputs ('&')
|
|
226
|
+
* @param {string} name
|
|
227
|
+
* @returns
|
|
228
|
+
*/
|
|
193
229
|
function getComponentBindings(name) {
|
|
194
230
|
const cmpDefs = services.$injector.get(name + "Directive"); // could be multiple
|
|
195
231
|
if (!cmpDefs || !cmpDefs.length)
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { assertPredicate, unnestR
|
|
1
|
+
import { assertPredicate, unnestR } from "../../shared/common";
|
|
2
2
|
import { TransitionHookPhase, TransitionHookScope } from "./interface";
|
|
3
|
-
import { TransitionHook } from "./
|
|
3
|
+
import { TransitionHook } from "./transition-hook";
|
|
4
4
|
/**
|
|
5
5
|
* This class returns applicable TransitionHooks for a specific Transition instance.
|
|
6
6
|
*
|
|
@@ -24,7 +24,7 @@ export class HookBuilder {
|
|
|
24
24
|
._getEvents(phase)
|
|
25
25
|
.map((type) => this.buildHooks(type))
|
|
26
26
|
.reduce(unnestR, [])
|
|
27
|
-
.filter(
|
|
27
|
+
.filter(Boolean);
|
|
28
28
|
}
|
|
29
29
|
/**
|
|
30
30
|
* Returns an array of newly built TransitionHook objects.
|
|
@@ -5,8 +5,8 @@ import { isPromise } from "../../shared/predicates";
|
|
|
5
5
|
import { is, parse } from "../../shared/hof";
|
|
6
6
|
import { trace } from "../common/trace";
|
|
7
7
|
import { services } from "../common/coreservices";
|
|
8
|
-
import { Rejection } from "./
|
|
9
|
-
import { TargetState } from "../state/
|
|
8
|
+
import { Rejection } from "./reject-factory";
|
|
9
|
+
import { TargetState } from "../state/target-state";
|
|
10
10
|
const defaultOptions = {
|
|
11
11
|
current: () => {},
|
|
12
12
|
transition: null,
|
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
import { TransitionHookScope, TransitionHookPhase } from "./interface";
|
|
2
2
|
import { Transition } from "./transition";
|
|
3
|
-
import { makeEvent } from "./
|
|
3
|
+
import { makeEvent } from "./hook-registry";
|
|
4
4
|
import {
|
|
5
5
|
registerAddCoreResolvables,
|
|
6
6
|
treeChangesCleanup,
|
|
7
|
-
} from "../hooks/
|
|
8
|
-
import { registerRedirectToHook } from "../hooks/
|
|
7
|
+
} from "../hooks/core-resolvables";
|
|
8
|
+
import { registerRedirectToHook } from "../hooks/redirect-to";
|
|
9
9
|
import {
|
|
10
10
|
registerOnExitHook,
|
|
11
11
|
registerOnRetainHook,
|
|
12
12
|
registerOnEnterHook,
|
|
13
|
-
} from "../hooks/
|
|
13
|
+
} from "../hooks/on-enter-exit-retain";
|
|
14
14
|
import {
|
|
15
15
|
registerEagerResolvePath,
|
|
16
16
|
registerLazyResolveState,
|
|
@@ -20,16 +20,16 @@ import {
|
|
|
20
20
|
registerLoadEnteringViews,
|
|
21
21
|
registerActivateViews,
|
|
22
22
|
} from "../hooks/views";
|
|
23
|
-
import { registerUpdateGlobalState } from "../hooks/
|
|
23
|
+
import { registerUpdateGlobalState } from "../hooks/update-globals";
|
|
24
24
|
import { registerUpdateUrl } from "../hooks/url";
|
|
25
|
-
import { registerLazyLoadHook } from "../hooks/
|
|
26
|
-
import { TransitionEventType } from "./
|
|
27
|
-
import { TransitionHook } from "./
|
|
25
|
+
import { registerLazyLoadHook } from "../hooks/lazy-load";
|
|
26
|
+
import { TransitionEventType } from "./transition-event-type";
|
|
27
|
+
import { TransitionHook } from "./transition-hook";
|
|
28
28
|
import { isDefined } from "../../shared/utils";
|
|
29
29
|
import { removeFrom, createProxyFunctions } from "../../shared/common";
|
|
30
30
|
import { val } from "../../shared/hof";
|
|
31
|
-
import { registerIgnoredTransitionHook } from "../hooks/
|
|
32
|
-
import { registerInvalidTransitionHook } from "../hooks/
|
|
31
|
+
import { registerIgnoredTransitionHook } from "../hooks/ignored-transition";
|
|
32
|
+
import { registerInvalidTransitionHook } from "../hooks/invalid-transition";
|
|
33
33
|
/**
|
|
34
34
|
* The default [[Transition]] options.
|
|
35
35
|
*
|
|
@@ -109,46 +109,12 @@ export class TransitionService {
|
|
|
109
109
|
* @param options the registration options
|
|
110
110
|
* @returns a function which deregisters the hook.
|
|
111
111
|
*/
|
|
112
|
-
|
|
113
|
-
return;
|
|
114
|
-
}
|
|
115
|
-
/** @inheritdoc */
|
|
116
|
-
onBefore(criteria, callback, options) {
|
|
117
|
-
return;
|
|
118
|
-
}
|
|
119
|
-
/** @inheritdoc */
|
|
120
|
-
onStart(criteria, callback, options) {
|
|
121
|
-
return;
|
|
122
|
-
}
|
|
123
|
-
/** @inheritdoc */
|
|
124
|
-
onExit(criteria, callback, options) {
|
|
125
|
-
return;
|
|
126
|
-
}
|
|
127
|
-
/** @inheritdoc */
|
|
128
|
-
onRetain(criteria, callback, options) {
|
|
129
|
-
return;
|
|
130
|
-
}
|
|
131
|
-
/** @inheritdoc */
|
|
132
|
-
onEnter(criteria, callback, options) {
|
|
133
|
-
return;
|
|
134
|
-
}
|
|
135
|
-
/** @inheritdoc */
|
|
136
|
-
onFinish(criteria, callback, options) {
|
|
137
|
-
return;
|
|
138
|
-
}
|
|
139
|
-
/** @inheritdoc */
|
|
140
|
-
onSuccess(criteria, callback, options) {
|
|
141
|
-
return;
|
|
142
|
-
}
|
|
143
|
-
/** @inheritdoc */
|
|
144
|
-
onError(criteria, callback, options) {
|
|
145
|
-
return;
|
|
146
|
-
}
|
|
112
|
+
|
|
147
113
|
/**
|
|
148
114
|
* dispose
|
|
149
115
|
* @internal
|
|
150
116
|
*/
|
|
151
|
-
dispose(
|
|
117
|
+
dispose() {
|
|
152
118
|
Object.values(this._registeredHooks).forEach((hooksArray) =>
|
|
153
119
|
hooksArray.forEach((hook) => {
|
|
154
120
|
hook._deregistered = true;
|
|
@@ -9,7 +9,6 @@ import {
|
|
|
9
9
|
omit,
|
|
10
10
|
arrayTuples,
|
|
11
11
|
unnestR,
|
|
12
|
-
identity,
|
|
13
12
|
anyTrueR,
|
|
14
13
|
flattenR,
|
|
15
14
|
uniqR,
|
|
@@ -17,14 +16,14 @@ import {
|
|
|
17
16
|
import { isUndefined, isObject } from "../../shared/utils";
|
|
18
17
|
import { prop, propEq, val, not, is } from "../../shared/hof";
|
|
19
18
|
import { TransitionHookPhase } from "./interface"; // has or is using
|
|
20
|
-
import { TransitionHook } from "./
|
|
21
|
-
import { matchState, makeEvent } from "./
|
|
22
|
-
import { HookBuilder } from "./
|
|
23
|
-
import { PathUtils } from "../path/
|
|
19
|
+
import { TransitionHook } from "./transition-hook";
|
|
20
|
+
import { matchState, makeEvent } from "./hook-registry";
|
|
21
|
+
import { HookBuilder } from "./hook-builder";
|
|
22
|
+
import { PathUtils } from "../path/path-utils";
|
|
24
23
|
import { Param } from "../params/param";
|
|
25
24
|
import { Resolvable } from "../resolve/resolvable";
|
|
26
|
-
import { ResolveContext } from "../resolve/
|
|
27
|
-
import { Rejection } from "./
|
|
25
|
+
import { ResolveContext } from "../resolve/resolve-context";
|
|
26
|
+
import { Rejection } from "./reject-factory";
|
|
28
27
|
|
|
29
28
|
const stateSelf = prop("self");
|
|
30
29
|
/**
|
|
@@ -36,38 +35,7 @@ const stateSelf = prop("self");
|
|
|
36
35
|
* It has information about all states being entered and exited as a result of the transition.
|
|
37
36
|
*/
|
|
38
37
|
export class Transition {
|
|
39
|
-
|
|
40
|
-
return;
|
|
41
|
-
}
|
|
42
|
-
/** @inheritdoc */
|
|
43
|
-
onStart(criteria, callback, options) {
|
|
44
|
-
return;
|
|
45
|
-
}
|
|
46
|
-
/** @inheritdoc */
|
|
47
|
-
onExit(criteria, callback, options) {
|
|
48
|
-
return;
|
|
49
|
-
}
|
|
50
|
-
/** @inheritdoc */
|
|
51
|
-
onRetain(criteria, callback, options) {
|
|
52
|
-
return;
|
|
53
|
-
}
|
|
54
|
-
/** @inheritdoc */
|
|
55
|
-
onEnter(criteria, callback, options) {
|
|
56
|
-
return;
|
|
57
|
-
}
|
|
58
|
-
/** @inheritdoc */
|
|
59
|
-
onFinish(criteria, callback, options) {
|
|
60
|
-
return;
|
|
61
|
-
}
|
|
62
|
-
/** @inheritdoc */
|
|
63
|
-
onSuccess(criteria, callback, options) {
|
|
64
|
-
return;
|
|
65
|
-
}
|
|
66
|
-
/** @inheritdoc */
|
|
67
|
-
onError(criteria, callback, options) {
|
|
68
|
-
return;
|
|
69
|
-
}
|
|
70
|
-
/** @internal
|
|
38
|
+
/**
|
|
71
39
|
* Creates the transition-level hook registration functions
|
|
72
40
|
* (which can then be used to register hooks)
|
|
73
41
|
*/
|
|
@@ -466,7 +434,7 @@ export class Transition {
|
|
|
466
434
|
views(pathname = "entering", state) {
|
|
467
435
|
let path = this._treeChanges[pathname];
|
|
468
436
|
path = !state ? path : path.filter(propEq("state", state));
|
|
469
|
-
return path.map(prop("views")).
|
|
437
|
+
return path.map(prop("views")).reduce(unnestR, []);
|
|
470
438
|
}
|
|
471
439
|
treeChanges(pathname) {
|
|
472
440
|
return pathname ? this._treeChanges[pathname] : this._treeChanges;
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
map,
|
|
3
3
|
inherit,
|
|
4
|
-
identity,
|
|
5
4
|
unnest,
|
|
6
5
|
tail,
|
|
7
6
|
find,
|
|
@@ -530,7 +529,6 @@ export class UrlMatcher {
|
|
|
530
529
|
if (!param.raw) encoded = map(encoded, encodeURIComponent);
|
|
531
530
|
return encoded.map((val) => `${param.id}=${val}`);
|
|
532
531
|
})
|
|
533
|
-
.filter(identity)
|
|
534
532
|
.reduce(unnestR, [])
|
|
535
533
|
.join("&");
|
|
536
534
|
// Concat the pathstring with the queryString (if exists) and the hashString (if exists)
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { stripLastPathElement } from "../../shared/strings";
|
|
2
|
-
import { UrlRuleFactory } from "./
|
|
2
|
+
import { UrlRuleFactory } from "./url-rule";
|
|
3
3
|
function appendBasePath(url, isHtml5, absolute, baseHref) {
|
|
4
4
|
if (baseHref === "/") return url;
|
|
5
5
|
if (isHtml5) return stripLastPathElement(baseHref) + url;
|
|
@@ -84,8 +84,4 @@ export class UrlRouter {
|
|
|
84
84
|
const port = cfgPort === 80 || cfgPort === 443 ? "" : ":" + cfgPort;
|
|
85
85
|
return [cfg.protocol(), "://", cfg.host(), port, slash, url].join("");
|
|
86
86
|
}
|
|
87
|
-
/** @deprecated use [[UrlService.interceptDeferred]]*/
|
|
88
|
-
get interceptDeferred() {
|
|
89
|
-
return this.router.urlService.interceptDeferred;
|
|
90
|
-
}
|
|
91
87
|
}
|
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
import { UrlMatcher } from "./
|
|
1
|
+
import { UrlMatcher } from "./url-matcher";
|
|
2
2
|
import { isString, isFunction, isDefined } from "../../shared/utils";
|
|
3
|
-
import { identity } from "../../shared/common";
|
|
4
3
|
import { is, or, pattern } from "../../shared/hof";
|
|
5
|
-
import { StateObject } from "../state/
|
|
4
|
+
import { StateObject } from "../state/state-object";
|
|
6
5
|
/**
|
|
7
6
|
* Creates a [[UrlRule]]
|
|
8
7
|
*
|
|
@@ -17,6 +16,7 @@ export class UrlRuleFactory {
|
|
|
17
16
|
constructor(router) {
|
|
18
17
|
this.router = router;
|
|
19
18
|
}
|
|
19
|
+
|
|
20
20
|
compile(str) {
|
|
21
21
|
return this.router.urlMatcherFactory.compile(str);
|
|
22
22
|
}
|
|
@@ -208,6 +208,6 @@ export class BaseUrlRule {
|
|
|
208
208
|
this.type = "RAW";
|
|
209
209
|
this.$id = -1;
|
|
210
210
|
this.matchPriority = () => 0 - this.$id;
|
|
211
|
-
this.handler = handler ||
|
|
211
|
+
this.handler = handler || ((x) => x);
|
|
212
212
|
}
|
|
213
213
|
}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { TargetState } from "../state/
|
|
2
|
-
import { UrlMatcher } from "./
|
|
1
|
+
import { TargetState } from "../state/target-state";
|
|
2
|
+
import { UrlMatcher } from "./url-matcher";
|
|
3
3
|
import { is, val } from "../../shared/hof";
|
|
4
4
|
import { isDefined, isFunction, isString } from "../../shared/utils";
|
|
5
5
|
import { removeFrom } from "../../shared/common";
|
|
6
|
-
import { UrlRuleFactory } from "./
|
|
6
|
+
import { UrlRuleFactory } from "./url-rule";
|
|
7
7
|
const prioritySort = (a, b) => (b.priority || 0) - (a.priority || 0);
|
|
8
8
|
const typeSort = (a, b) => {
|
|
9
9
|
const weights = { STATE: 4, URLMATCHER: 4, REGEXP: 3, RAW: 2, OTHER: 1 };
|
|
@@ -66,7 +66,6 @@ function getHandlerFn(handler) {
|
|
|
66
66
|
*/
|
|
67
67
|
export class UrlRules {
|
|
68
68
|
constructor(router) {
|
|
69
|
-
this.router = router;
|
|
70
69
|
this._sortFn = defaultRuleSortFn;
|
|
71
70
|
this._rules = [];
|
|
72
71
|
this._id = 0;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { isString } from "../../shared/utils";
|
|
2
2
|
import { is, pattern } from "../../shared/hof";
|
|
3
|
-
import { UrlRules } from "./
|
|
4
|
-
import { UrlConfig } from "./
|
|
5
|
-
import { TargetState } from "../state/
|
|
3
|
+
import { UrlRules } from "./url-rules";
|
|
4
|
+
import { UrlConfig } from "./url-config";
|
|
5
|
+
import { TargetState } from "../state/target-state";
|
|
6
6
|
/**
|
|
7
7
|
* API for URL management
|
|
8
8
|
*/
|
|
@@ -16,17 +16,21 @@ export class UrlService {
|
|
|
16
16
|
* @type {import('../router').UIRouter}
|
|
17
17
|
*/
|
|
18
18
|
this.router = router;
|
|
19
|
+
|
|
20
|
+
/** @type {boolean} */
|
|
19
21
|
this.interceptDeferred = false;
|
|
20
22
|
/**
|
|
21
23
|
* The nested [[UrlRules]] API for managing URL rules and rewrites
|
|
22
24
|
*
|
|
23
25
|
* See: [[UrlRules]] for details
|
|
26
|
+
* @type {UrlRules}
|
|
24
27
|
*/
|
|
25
28
|
this.rules = new UrlRules(this.router);
|
|
26
29
|
/**
|
|
27
30
|
* The nested [[UrlConfig]] API to configure the URL and retrieve URL information
|
|
28
31
|
*
|
|
29
32
|
* See: [[UrlConfig]] for details
|
|
33
|
+
* @type {UrlConfig}
|
|
30
34
|
*/
|
|
31
35
|
this.config = new UrlConfig(this.router);
|
|
32
36
|
// Delegate these calls to the current LocationServices implementation
|
|
@@ -74,11 +78,11 @@ export class UrlService {
|
|
|
74
78
|
* locationServices.url("/some/path?query=value#anchor", true);
|
|
75
79
|
* ```
|
|
76
80
|
*
|
|
77
|
-
* @param newurl The new value for the URL.
|
|
81
|
+
* @param {string} newurl The new value for the URL.
|
|
78
82
|
* This url should reflect only the new internal [[path]], [[search]], and [[hash]] values.
|
|
79
83
|
* It should not include the protocol, site, port, or base path of an absolute HREF.
|
|
80
|
-
* @param replace When true, replaces the current history entry (instead of appending it) with this new url
|
|
81
|
-
* @param state The history's state object, i.e., pushState (if the LocationServices implementation supports it)
|
|
84
|
+
* @param {boolean} replace When true, replaces the current history entry (instead of appending it) with this new url
|
|
85
|
+
* @param {any} state The history's state object, i.e., pushState (if the LocationServices implementation supports it)
|
|
82
86
|
*
|
|
83
87
|
* @return the url (after potentially being processed)
|
|
84
88
|
*/
|
package/src/router/view/view.js
CHANGED
|
@@ -29,10 +29,6 @@ export class ViewService {
|
|
|
29
29
|
* @param {import('../router').UIRouter} router
|
|
30
30
|
*/
|
|
31
31
|
constructor(router) {
|
|
32
|
-
/**
|
|
33
|
-
* @type {import('../router').UIRouter}
|
|
34
|
-
*/
|
|
35
|
-
this.router = router;
|
|
36
32
|
this._uiViews = [];
|
|
37
33
|
this._viewConfigs = [];
|
|
38
34
|
this._viewConfigFactories = {};
|
|
@@ -41,7 +37,7 @@ export class ViewService {
|
|
|
41
37
|
_rootViewContext: this._rootViewContext.bind(this),
|
|
42
38
|
_viewConfigFactory: this._viewConfigFactory.bind(this),
|
|
43
39
|
_registeredUIView: (id) =>
|
|
44
|
-
find(this._uiViews, (view) => `${
|
|
40
|
+
find(this._uiViews, (view) => `${router.$id}.${view.id}` === id),
|
|
45
41
|
_registeredUIViews: () => this._uiViews,
|
|
46
42
|
_activeViewConfigs: () => this._viewConfigs,
|
|
47
43
|
_onSync: (listener) => {
|
package/src/shared/common.js
CHANGED
package/src/shared/strings.js
CHANGED
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
*/
|
|
8
8
|
import { isInjectable, isNull, isPromise } from "./predicates";
|
|
9
9
|
import { isUndefined, isFunction, isString, isObject } from "./utils";
|
|
10
|
-
import { Rejection } from "../router/transition/
|
|
10
|
+
import { Rejection } from "../router/transition/reject-factory";
|
|
11
11
|
import { identity, pushR, tail } from "./common";
|
|
12
12
|
import { pattern, val } from "./hof";
|
|
13
13
|
/**
|
|
@@ -112,7 +112,7 @@ export const trimHashVal = (str) => (str ? str.replace(/^#/, "") : "");
|
|
|
112
112
|
*/
|
|
113
113
|
export function splitOnDelim(delim) {
|
|
114
114
|
const re = new RegExp("(" + delim + ")", "g");
|
|
115
|
-
return (str) => str.split(re).filter(
|
|
115
|
+
return (str) => str.split(re).filter(Boolean);
|
|
116
116
|
}
|
|
117
117
|
/**
|
|
118
118
|
* Reduce fn that joins neighboring strings
|
package/test/router/view.spec.js
CHANGED
|
@@ -2,16 +2,16 @@ import { dealoc } from "../../src/jqLite";
|
|
|
2
2
|
import { Angular } from "../../src/loader";
|
|
3
3
|
import { publishExternalAPI } from "../../src/public";
|
|
4
4
|
import { curry } from "../../src/shared/hof";
|
|
5
|
-
import { StateMatcher } from "../../src/router/state/
|
|
6
|
-
import { StateBuilder } from "../../src/router/state/
|
|
7
|
-
import { StateObject } from "../../src/router/state/
|
|
5
|
+
import { StateMatcher } from "../../src/router/state/state-matcher";
|
|
6
|
+
import { StateBuilder } from "../../src/router/state/state-builder";
|
|
7
|
+
import { StateObject } from "../../src/router/state/state-object";
|
|
8
8
|
import { ViewService } from "../../src/router/view/view";
|
|
9
9
|
import {
|
|
10
10
|
ng1ViewsBuilder,
|
|
11
11
|
getNg1ViewConfigFactory,
|
|
12
12
|
} from "../../src/router/state/views";
|
|
13
|
-
import { PathNode } from "../../src/router/path/
|
|
14
|
-
import { PathUtils } from "../../src/router/path/
|
|
13
|
+
import { PathNode } from "../../src/router/path/path-node";
|
|
14
|
+
import { PathUtils } from "../../src/router/path/path-utils";
|
|
15
15
|
import { tail } from "../../src/shared/common";
|
|
16
16
|
import { wait } from "../test-utils";
|
|
17
17
|
|