@angular-wave/angular.ts 0.0.23 → 0.0.24
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 +6 -8
- 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 +8 -8
- package/src/router/services.js +3 -3
- 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} +7 -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} +10 -10
- package/src/router/transition/transition.js +7 -8
- 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 -1
- package/src/router/url/{urlRule.js → url-rule.js} +4 -4
- package/src/router/url/{urlRules.js → url-rules.js} +3 -3
- package/src/router/url/{urlService.js → url-service.js} +6 -6
- 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/{locationServices.js → location-services.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
package/package.json
CHANGED
package/src/core/compile.js
CHANGED
|
@@ -6,7 +6,6 @@ import {
|
|
|
6
6
|
assertNotHasOwnProperty,
|
|
7
7
|
createMap,
|
|
8
8
|
forEach,
|
|
9
|
-
identity,
|
|
10
9
|
isDefined,
|
|
11
10
|
isFunction,
|
|
12
11
|
isObject,
|
|
@@ -969,7 +968,7 @@ export function $CompileProvider($provide, $$sanitizeUriProvider) {
|
|
|
969
968
|
const endSymbol = $interpolate.endSymbol();
|
|
970
969
|
const denormalizeTemplate =
|
|
971
970
|
startSymbol === "{{" && endSymbol === "}}"
|
|
972
|
-
?
|
|
971
|
+
? (x) => x
|
|
973
972
|
: function denormalizeTemplate(template) {
|
|
974
973
|
return template
|
|
975
974
|
.replace(/\{\{/g, startSymbol)
|
|
@@ -2902,7 +2901,7 @@ export function $CompileProvider($provide, $$sanitizeUriProvider) {
|
|
|
2902
2901
|
const nodeName = nodeName_(node);
|
|
2903
2902
|
const trustedContext = getTrustedPropContext(nodeName, propName);
|
|
2904
2903
|
|
|
2905
|
-
let sanitizer =
|
|
2904
|
+
let sanitizer = (x) => x;
|
|
2906
2905
|
// Sanitize img[srcset] + source[srcset] values.
|
|
2907
2906
|
if (
|
|
2908
2907
|
propName === "srcset" &&
|
package/src/core/parser/parse.js
CHANGED
|
@@ -2,7 +2,6 @@ import {
|
|
|
2
2
|
createMap,
|
|
3
3
|
csp,
|
|
4
4
|
forEach,
|
|
5
|
-
identity,
|
|
6
5
|
isDefined,
|
|
7
6
|
isFunction,
|
|
8
7
|
minErr,
|
|
@@ -2213,7 +2212,7 @@ export function $ParseProvider() {
|
|
|
2213
2212
|
var unwatch, lastValue;
|
|
2214
2213
|
|
|
2215
2214
|
var exp = parsedExpression.$$intercepted || parsedExpression;
|
|
2216
|
-
var post = parsedExpression.$$interceptor ||
|
|
2215
|
+
var post = parsedExpression.$$interceptor || ((x) => x);
|
|
2217
2216
|
|
|
2218
2217
|
var useInputs = parsedExpression.inputs && !exp.inputs;
|
|
2219
2218
|
|
|
@@ -2476,7 +2475,7 @@ export function oneTimeWatchDelegate(
|
|
|
2476
2475
|
let lastValue;
|
|
2477
2476
|
|
|
2478
2477
|
const exp = parsedExpression.$$intercepted || parsedExpression;
|
|
2479
|
-
const post = parsedExpression.$$interceptor ||
|
|
2478
|
+
const post = parsedExpression.$$interceptor || ((x) => x);
|
|
2480
2479
|
|
|
2481
2480
|
const useInputs = parsedExpression.inputs && !exp.inputs;
|
|
2482
2481
|
|
|
@@ -9,7 +9,6 @@ import {
|
|
|
9
9
|
forEach,
|
|
10
10
|
tail,
|
|
11
11
|
unnestR,
|
|
12
|
-
identity,
|
|
13
12
|
uniqR,
|
|
14
13
|
inArray,
|
|
15
14
|
removeFrom,
|
|
@@ -642,7 +641,7 @@ export let uiSrefActiveDirective = [
|
|
|
642
641
|
}
|
|
643
642
|
// Update route state
|
|
644
643
|
function update() {
|
|
645
|
-
const splitClasses = (str) => str.split(/\s/).filter(
|
|
644
|
+
const splitClasses = (str) => str.split(/\s/).filter(Boolean);
|
|
646
645
|
const getClasses = (stateList) =>
|
|
647
646
|
stateList
|
|
648
647
|
.map((x) => x.activeClass)
|
|
@@ -3,7 +3,7 @@ import { isDefined, isFunction, isString } from "../../shared/utils";
|
|
|
3
3
|
import { kebobString } from "../../shared/strings";
|
|
4
4
|
|
|
5
5
|
import { parse } from "../../shared/hof";
|
|
6
|
-
import { ResolveContext } from "../resolve/
|
|
6
|
+
import { ResolveContext } from "../resolve/resolve-context";
|
|
7
7
|
import { trace } from "../common/trace";
|
|
8
8
|
import { getLocals } from "../services";
|
|
9
9
|
import { Ng1ViewConfig } from "../state/views";
|
package/src/router/globals.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { isString, isFunction } from "../../shared/utils";
|
|
2
2
|
import { services } from "../common/coreservices";
|
|
3
|
-
import { TargetState } from "../state/
|
|
3
|
+
import { TargetState } from "../state/target-state";
|
|
4
4
|
/**
|
|
5
5
|
* A [[TransitionHookFn]] that redirects to a different state or params
|
|
6
6
|
*
|
package/src/router/index.js
CHANGED
|
@@ -6,16 +6,16 @@ import {
|
|
|
6
6
|
runBlock,
|
|
7
7
|
watchDigests,
|
|
8
8
|
} from "./services";
|
|
9
|
-
import { TemplateFactory } from "./
|
|
9
|
+
import { TemplateFactory } from "./template-factory";
|
|
10
10
|
import { trace } from "./common/trace";
|
|
11
|
-
import { $ViewScrollProvider } from "./
|
|
12
|
-
import { $IsStateFilter, $IncludedByStateFilter } from "./
|
|
11
|
+
import { $ViewScrollProvider } from "./view-scroll";
|
|
12
|
+
import { $IsStateFilter, $IncludedByStateFilter } from "./state-filters";
|
|
13
13
|
import {
|
|
14
14
|
uiSrefActiveDirective,
|
|
15
15
|
uiStateDirective,
|
|
16
16
|
uiSrefDirective,
|
|
17
|
-
} from "./directives/
|
|
18
|
-
import { uiView, $ViewDirectiveFill } from "./directives/
|
|
17
|
+
} from "./directives/state-directives";
|
|
18
|
+
import { uiView, $ViewDirectiveFill } from "./directives/view-directive";
|
|
19
19
|
|
|
20
20
|
export function initRouter() {
|
|
21
21
|
window.angular
|
|
@@ -28,9 +28,7 @@ export function initRouter() {
|
|
|
28
28
|
return router.urlMatcherFactory;
|
|
29
29
|
},
|
|
30
30
|
])
|
|
31
|
-
.provider("$templateFactory",
|
|
32
|
-
return new TemplateFactory();
|
|
33
|
-
})
|
|
31
|
+
.provider("$templateFactory", TemplateFactory)
|
|
34
32
|
.provider("$stateRegistry", getProviderFor("stateRegistry"))
|
|
35
33
|
.provider("$routerGlobals", getProviderFor("globals"))
|
|
36
34
|
.provider("$transitions", getProviderFor("transitionService"))
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
fromJson,
|
|
3
3
|
toJson,
|
|
4
|
-
identity,
|
|
5
4
|
equals,
|
|
6
5
|
inherit,
|
|
7
6
|
map,
|
|
@@ -11,7 +10,7 @@ import { isNullOrUndefined } from "../../shared/predicates";
|
|
|
11
10
|
import { isDefined } from "../../shared/utils";
|
|
12
11
|
import { is } from "../../shared/hof";
|
|
13
12
|
import { services } from "../common/coreservices";
|
|
14
|
-
import { ParamType } from "./
|
|
13
|
+
import { ParamType } from "./param-type";
|
|
15
14
|
/**
|
|
16
15
|
* A registry for parameter types.
|
|
17
16
|
*
|
|
@@ -153,8 +152,8 @@ function initDefaultTypes() {
|
|
|
153
152
|
}),
|
|
154
153
|
// does not encode/decode
|
|
155
154
|
any: makeDefaultType({
|
|
156
|
-
encode:
|
|
157
|
-
decode:
|
|
155
|
+
encode: (x) => x,
|
|
156
|
+
decode: (x) => x,
|
|
158
157
|
is: () => true,
|
|
159
158
|
equals: equals,
|
|
160
159
|
}),
|
|
@@ -3,7 +3,7 @@ import { prop } from "../../shared/hof";
|
|
|
3
3
|
import { isInjectable } from "../../shared/predicates";
|
|
4
4
|
import { isDefined, isUndefined, isString } from "../../shared/utils";
|
|
5
5
|
import { services } from "../common/coreservices";
|
|
6
|
-
import { ParamType } from "./
|
|
6
|
+
import { ParamType } from "./param-type";
|
|
7
7
|
const hasOwn = Object.prototype.hasOwnProperty;
|
|
8
8
|
const isShorthand = (cfg) =>
|
|
9
9
|
["value", "type", "squash", "array", "dynamic"].filter(hasOwn.bind(cfg || {}))
|
|
@@ -9,8 +9,8 @@ import {
|
|
|
9
9
|
arrayTuples,
|
|
10
10
|
} from "../../shared/common";
|
|
11
11
|
import { prop, propEq } from "../../shared/hof";
|
|
12
|
-
import { TargetState } from "../state/
|
|
13
|
-
import { PathNode } from "./
|
|
12
|
+
import { TargetState } from "../state/target-state";
|
|
13
|
+
import { PathNode } from "./path-node";
|
|
14
14
|
/**
|
|
15
15
|
* This class contains functions which convert TargetStates, Nodes and paths from one type to another.
|
|
16
16
|
*/
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { isFunction, isObject } from "../../shared/utils";
|
|
2
2
|
import { services } from "../common/coreservices";
|
|
3
3
|
import { trace } from "../common/trace";
|
|
4
4
|
import { stringify } from "../../shared/strings";
|
|
@@ -87,7 +87,7 @@ export class Resolvable {
|
|
|
87
87
|
const node = resolveContext.findNode(this);
|
|
88
88
|
const state = node && node.state;
|
|
89
89
|
const asyncPolicy = this.getPolicy(state).async;
|
|
90
|
-
const customAsyncPolicy = isFunction(asyncPolicy) ? asyncPolicy :
|
|
90
|
+
const customAsyncPolicy = isFunction(asyncPolicy) ? asyncPolicy : (x) => x;
|
|
91
91
|
// After the final value has been resolved, update the state of the Resolvable
|
|
92
92
|
const applyResolvedValue = (resolvedValue) => {
|
|
93
93
|
this.data = resolvedValue;
|
|
@@ -3,7 +3,7 @@ import { propEq, not } from "../../shared/hof";
|
|
|
3
3
|
import { trace } from "../common/trace";
|
|
4
4
|
import { services } from "../common/coreservices";
|
|
5
5
|
import { Resolvable } from "./resolvable";
|
|
6
|
-
import { PathUtils } from "../path/
|
|
6
|
+
import { PathUtils } from "../path/path-utils";
|
|
7
7
|
import { stringify } from "../../shared/strings";
|
|
8
8
|
import { isUndefined } from "../../shared/utils";
|
|
9
9
|
|
package/src/router/router.js
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import { UrlMatcherFactory } from "./url/
|
|
2
|
-
import { UrlRouter } from "./url/
|
|
3
|
-
import { TransitionService } from "./transition/
|
|
1
|
+
import { UrlMatcherFactory } from "./url/url-matcher-factory";
|
|
2
|
+
import { UrlRouter } from "./url/url-router";
|
|
3
|
+
import { TransitionService } from "./transition/transition-service";
|
|
4
4
|
import { ViewService } from "./view/view";
|
|
5
|
-
import { StateRegistry } from "./state/
|
|
6
|
-
import { StateService } from "./state/
|
|
5
|
+
import { StateRegistry } from "./state/state-registry";
|
|
6
|
+
import { StateService } from "./state/state-service";
|
|
7
7
|
import { UIRouterGlobals } from "./globals";
|
|
8
8
|
import { removeFrom } from "../shared/common";
|
|
9
9
|
import { isFunction } from "../shared/utils";
|
|
10
|
-
import { UrlService } from "./url/
|
|
10
|
+
import { UrlService } from "./url/url-service";
|
|
11
11
|
import { trace } from "./common/trace";
|
|
12
12
|
|
|
13
13
|
/**
|
|
@@ -26,11 +26,11 @@ export class UIRouter {
|
|
|
26
26
|
/**
|
|
27
27
|
* Creates a new `UIRouter` object
|
|
28
28
|
*
|
|
29
|
-
* @param {import('./
|
|
29
|
+
* @param {import('./location-services').Ng1LocationServices} locationService
|
|
30
30
|
*/
|
|
31
31
|
constructor(locationService) {
|
|
32
32
|
/**
|
|
33
|
-
* @type {import('./
|
|
33
|
+
* @type {import('./location-services').Ng1LocationServices}
|
|
34
34
|
*/
|
|
35
35
|
this.locationService = locationService;
|
|
36
36
|
/** @type {number} */ this.$id = routerId++;
|
package/src/router/services.js
CHANGED
|
@@ -15,9 +15,9 @@ import { trace } from "./common/trace";
|
|
|
15
15
|
import { UIRouter } from "./router";
|
|
16
16
|
import { ng1ViewsBuilder, getNg1ViewConfigFactory } from "./state/views";
|
|
17
17
|
|
|
18
|
-
import { StateProvider } from "./
|
|
19
|
-
import { Ng1LocationServices } from "./
|
|
20
|
-
import { ResolveContext } from "./resolve/
|
|
18
|
+
import { StateProvider } from "./state-provider";
|
|
19
|
+
import { Ng1LocationServices } from "./location-services";
|
|
20
|
+
import { ResolveContext } from "./resolve/resolve-context";
|
|
21
21
|
|
|
22
22
|
export let router = null;
|
|
23
23
|
$routerProvider.$inject = ["$locationProvider"];
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import {
|
|
2
2
|
applyPairs,
|
|
3
|
-
identity,
|
|
4
3
|
inherit,
|
|
5
4
|
mapObj,
|
|
6
5
|
omit,
|
|
@@ -201,12 +200,12 @@ export function resolvablesBuilder(state) {
|
|
|
201
200
|
],
|
|
202
201
|
[
|
|
203
202
|
prop("useExisting"),
|
|
204
|
-
(p) => new Resolvable(getToken(p),
|
|
203
|
+
(p) => new Resolvable(getToken(p), (x) => x, [p.useExisting], p.policy),
|
|
205
204
|
],
|
|
206
205
|
]);
|
|
207
206
|
// prettier-ignore
|
|
208
207
|
const tuple2Resolvable = pattern([
|
|
209
|
-
[pipe(prop('val'), isString), (tuple) => new Resolvable(tuple.token,
|
|
208
|
+
[pipe(prop('val'), isString), (tuple) => new Resolvable(tuple.token, ((x) => x), [tuple.val], tuple.policy)],
|
|
210
209
|
[pipe(prop('val'), Array.isArray), (tuple) => new Resolvable(tuple.token, tail(tuple.val), tuple.val.slice(0, -1), tuple.policy)],
|
|
211
210
|
[pipe(prop('val'), isFunction), (tuple) => new Resolvable(tuple.token, tuple.val, annotate(tuple.val), tuple.policy)],
|
|
212
211
|
]);
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { inArray } from "../../shared/common";
|
|
2
2
|
import { prop } from "../../shared/hof";
|
|
3
3
|
import { isString } from "../../shared/utils";
|
|
4
|
-
import { StateObject } from "./
|
|
4
|
+
import { StateObject } from "./state-object";
|
|
5
|
+
|
|
5
6
|
export class StateQueueManager {
|
|
6
7
|
constructor(router, states, builder, listeners) {
|
|
7
8
|
this.router = router;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { StateMatcher } from "./
|
|
2
|
-
import { StateBuilder } from "./
|
|
3
|
-
import { StateQueueManager } from "./
|
|
1
|
+
import { StateMatcher } from "./state-matcher";
|
|
2
|
+
import { StateBuilder } from "./state-builder";
|
|
3
|
+
import { StateQueueManager } from "./state-queue-manager";
|
|
4
4
|
import { removeFrom } from "../../shared/common";
|
|
5
5
|
import { propEq } from "../../shared/hof";
|
|
6
6
|
/**
|
|
@@ -9,15 +9,15 @@ import {
|
|
|
9
9
|
import { isDefined, isObject, isString } from "../../shared/utils";
|
|
10
10
|
import { Queue } from "../common/queue";
|
|
11
11
|
import { services } from "../common/coreservices";
|
|
12
|
-
import { PathUtils } from "../path/
|
|
13
|
-
import { PathNode } from "../path/
|
|
14
|
-
import { defaultTransOpts } from "../transition/
|
|
15
|
-
import { Rejection, RejectType } from "../transition/
|
|
16
|
-
import { TargetState } from "./
|
|
12
|
+
import { PathUtils } from "../path/path-utils";
|
|
13
|
+
import { PathNode } from "../path/path-node";
|
|
14
|
+
import { defaultTransOpts } from "../transition/transition-service";
|
|
15
|
+
import { Rejection, RejectType } from "../transition/reject-factory";
|
|
16
|
+
import { TargetState } from "./target-state";
|
|
17
17
|
import { Param } from "../params/param";
|
|
18
18
|
import { Glob } from "../common/glob";
|
|
19
|
-
import { ResolveContext } from "../resolve/
|
|
20
|
-
import { lazyLoadState } from "../hooks/
|
|
19
|
+
import { ResolveContext } from "../resolve/resolve-context";
|
|
20
|
+
import { lazyLoadState } from "../hooks/lazy-load";
|
|
21
21
|
import { not, val } from "../../shared/hof";
|
|
22
22
|
/**
|
|
23
23
|
* Provides services related to ui-router states.
|
|
@@ -4,7 +4,7 @@ import { isInjectable } from "../../shared/predicates";
|
|
|
4
4
|
import { services } from "../common/coreservices";
|
|
5
5
|
import { trace } from "../common/trace";
|
|
6
6
|
import { ViewService } from "../view/view";
|
|
7
|
-
import { ResolveContext } from "../resolve/
|
|
7
|
+
import { ResolveContext } from "../resolve/resolve-context";
|
|
8
8
|
import { Resolvable } from "../resolve/resolvable";
|
|
9
9
|
|
|
10
10
|
export function getNg1ViewConfigFactory() {
|
|
@@ -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,
|