@angular-wave/angular.ts 0.0.12 → 0.0.13
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/exts/messages.md +30 -30
- package/src/index.js +1 -0
- package/src/router/adapter/locationServices.js +3 -5
- package/src/router/adapter/services.js +10 -16
- package/src/router/core/common/common.js +1 -11
- package/src/router/core/hooks/coreResolvables.js +2 -2
- package/src/router/core/path/pathUtils.js +1 -2
- package/src/router/core/router.js +4 -2
- package/src/router/core/state/stateBuilder.js +2 -3
- package/src/router/core/state/stateMatcher.js +1 -2
- package/src/router/core/state/stateObject.js +5 -4
- package/src/router/core/state/stateQueueManager.js +1 -1
- package/src/router/core/transition/hookRegistry.js +3 -10
- package/src/router/core/transition/transitionService.js +2 -2
- package/src/router/router.js +18 -12
- package/test/module-test.html +6 -2
- package/test/module-test.js +0 -0
- package/src/router/adapter/urlRouterProvider.js +0 -196
- package/src/router/core/vanilla/baseLocationService.js +0 -31
- package/src/router/core/vanilla/browserLocationConfig.js +0 -42
- package/src/router/core/vanilla/hashLocationService.js +0 -19
- package/src/router/core/vanilla/injector.js +0 -98
- package/src/router/core/vanilla/interface.js +0 -1
- package/src/router/core/vanilla/memoryLocationConfig.js +0 -20
- package/src/router/core/vanilla/memoryLocationService.js +0 -13
- package/src/router/core/vanilla/plugins.js +0 -35
- package/src/router/core/vanilla/pushStateLocationService.js +0 -69
- package/src/router/core/vanilla/q.js +0 -54
- package/src/router/core/vanilla/utils.js +0 -63
package/package.json
CHANGED
package/src/exts/messages.md
CHANGED
|
@@ -518,33 +518,33 @@ _ {@link module:ngMessages Click here} to learn more about`ngMessages`and`ngMess
|
|
|
518
518
|
_ @param {string} ngMessageExp|whenExp an expression value corresponding to the message key.
|
|
519
519
|
_/
|
|
520
520
|
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
521
|
+
/**
|
|
522
|
+
* @ngdoc directive
|
|
523
|
+
* @name ngMessageDefault
|
|
524
|
+
* @restrict AE
|
|
525
|
+
* @scope
|
|
526
|
+
*
|
|
527
|
+
* @description
|
|
528
|
+
* `ngMessageDefault` is a directive with the purpose to show and hide a default message for
|
|
529
|
+
* {@link directive:ngMessages}, when none of provided messages matches.
|
|
530
|
+
*
|
|
531
|
+
* More information about using `ngMessageDefault` can be found in the
|
|
532
|
+
* {@link module:ngMessages `ngMessages` module documentation}.
|
|
533
|
+
*
|
|
534
|
+
* @usage
|
|
535
|
+
* ```html
|
|
536
|
+
* <!-- using attribute directives -->
|
|
537
|
+
* <ANY ng-messages="expression" role="alert">
|
|
538
|
+
* <ANY ng-message="stringValue">...</ANY>
|
|
539
|
+
* <ANY ng-message="stringValue1, stringValue2, ...">...</ANY>
|
|
540
|
+
* <ANY ng-message-default>...</ANY>
|
|
541
|
+
* </ANY>
|
|
542
|
+
*
|
|
543
|
+
* <!-- or by using element directives -->
|
|
544
|
+
* <ng-messages for="expression" role="alert">
|
|
545
|
+
* <ng-message when="stringValue">...</ng-message>
|
|
546
|
+
* <ng-message when="stringValue1, stringValue2, ...">...</ng-message>
|
|
547
|
+
* <ng-message-default>...</ng-message-default>
|
|
548
|
+
* </ng-messages>
|
|
549
|
+
*
|
|
550
|
+
*/
|
package/src/index.js
CHANGED
|
@@ -32,7 +32,6 @@ export class Ng1LocationServices {
|
|
|
32
32
|
.replace(/(~~|~2F)/g, (m) => ({ "~~": "~", "~2F": "/" })[m])
|
|
33
33
|
: x;
|
|
34
34
|
}
|
|
35
|
-
// eslint-disable-next-line @typescript-eslint/no-empty-function
|
|
36
35
|
dispose() {}
|
|
37
36
|
constructor($locationProvider) {
|
|
38
37
|
// .onChange() registry
|
|
@@ -48,7 +47,7 @@ export class Ng1LocationServices {
|
|
|
48
47
|
html5Mode() {
|
|
49
48
|
let html5Mode = this.$locationProvider.html5Mode();
|
|
50
49
|
html5Mode = isObject(html5Mode) ? html5Mode.enabled : html5Mode;
|
|
51
|
-
return html5Mode &&
|
|
50
|
+
return html5Mode && typeof history !== "undefined";
|
|
52
51
|
}
|
|
53
52
|
baseHref() {
|
|
54
53
|
return (
|
|
@@ -63,11 +62,10 @@ export class Ng1LocationServices {
|
|
|
63
62
|
if (state) this.$location.state(state);
|
|
64
63
|
return this.$location.url();
|
|
65
64
|
}
|
|
66
|
-
_runtimeServices($rootScope, $location, $
|
|
65
|
+
_runtimeServices($rootScope, $location, $browser) {
|
|
67
66
|
this.$location = $location;
|
|
68
|
-
this.$sniffer = $sniffer;
|
|
69
67
|
this.$browser = $browser;
|
|
70
|
-
this.$window =
|
|
68
|
+
this.$window = window;
|
|
71
69
|
// Bind $locationChangeSuccess to the listeners registered in LocationService.onChange
|
|
72
70
|
$rootScope.$on("$locationChangeSuccess", (evt) =>
|
|
73
71
|
this._urlListeners.forEach((fn) => fn(evt)),
|
|
@@ -21,7 +21,6 @@ import {
|
|
|
21
21
|
import { StateProvider } from "./stateProvider";
|
|
22
22
|
import { getStateHookBuilder } from "./statebuilders/onEnterExitRetain";
|
|
23
23
|
import { Ng1LocationServices } from "./locationServices";
|
|
24
|
-
import { UrlRouterProvider } from "./urlRouterProvider";
|
|
25
24
|
|
|
26
25
|
export let router = null;
|
|
27
26
|
$uiRouterProvider.$inject = ["$locationProvider"];
|
|
@@ -52,15 +51,9 @@ export function $uiRouterProvider($locationProvider) {
|
|
|
52
51
|
// backwards compat: also expose router instance as $uiRouterProvider.router
|
|
53
52
|
router["router"] = router;
|
|
54
53
|
router["$get"] = $get;
|
|
55
|
-
$get.$inject = ["$location", "$browser", "$
|
|
56
|
-
function $get($location, $browser, $
|
|
57
|
-
ng1LocationService._runtimeServices(
|
|
58
|
-
$rootScope,
|
|
59
|
-
$location,
|
|
60
|
-
$sniffer,
|
|
61
|
-
$browser,
|
|
62
|
-
$window,
|
|
63
|
-
);
|
|
54
|
+
$get.$inject = ["$location", "$browser", "$rootScope"];
|
|
55
|
+
function $get($location, $browser, $rootScope) {
|
|
56
|
+
ng1LocationService._runtimeServices($rootScope, $location, $browser);
|
|
64
57
|
delete router["router"];
|
|
65
58
|
delete router["$get"];
|
|
66
59
|
return router;
|
|
@@ -69,7 +62,7 @@ export function $uiRouterProvider($locationProvider) {
|
|
|
69
62
|
}
|
|
70
63
|
export const getProviderFor = (serviceName) => [
|
|
71
64
|
"$uiRouterProvider",
|
|
72
|
-
($urp)
|
|
65
|
+
function UrlServiceProvider($urp) {
|
|
73
66
|
const service = $urp.router[serviceName];
|
|
74
67
|
service["$get"] = () => service;
|
|
75
68
|
return service;
|
|
@@ -103,13 +96,14 @@ export function runBlock($injector, $q, $uiRouter) {
|
|
|
103
96
|
)),
|
|
104
97
|
);
|
|
105
98
|
}
|
|
106
|
-
|
|
107
|
-
export const getUrlRouterProvider = (uiRouter) =>
|
|
108
|
-
(uiRouter.urlRouterProvider = new UrlRouterProvider(uiRouter));
|
|
99
|
+
|
|
109
100
|
// $state service and $stateProvider
|
|
110
101
|
// $urlRouter service and $urlRouterProvider
|
|
111
|
-
export
|
|
112
|
-
|
|
102
|
+
export function getStateProvider() {
|
|
103
|
+
debugger;
|
|
104
|
+
return extend(router.stateProvider, { $get: () => router.stateService });
|
|
105
|
+
}
|
|
106
|
+
|
|
113
107
|
watchDigests.$inject = ["$rootScope"];
|
|
114
108
|
export function watchDigests($rootScope) {
|
|
115
109
|
$rootScope.$watch(function () {
|
|
@@ -226,17 +226,7 @@ export function map(collection, callback, target) {
|
|
|
226
226
|
forEach(collection, (item, i) => (target[i] = callback(item, i)));
|
|
227
227
|
return target;
|
|
228
228
|
}
|
|
229
|
-
|
|
230
|
-
* Given an object, return its enumerable property values
|
|
231
|
-
*
|
|
232
|
-
* @example
|
|
233
|
-
* ```
|
|
234
|
-
*
|
|
235
|
-
* let foo = { a: 1, b: 2, c: 3 }
|
|
236
|
-
* let vals = values(foo); // [ 1, 2, 3 ]
|
|
237
|
-
* ```
|
|
238
|
-
*/
|
|
239
|
-
export const values = (obj) => Object.keys(obj).map((key) => obj[key]);
|
|
229
|
+
|
|
240
230
|
/**
|
|
241
231
|
* Reduce function that returns true if all of the values are truthy.
|
|
242
232
|
*
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Transition } from "../transition/transition";
|
|
2
2
|
import { UIRouter } from "../router";
|
|
3
3
|
import { Resolvable } from "../resolve/resolvable";
|
|
4
|
-
import { inArray, uniqR, unnestR
|
|
4
|
+
import { inArray, uniqR, unnestR } from "../common/common";
|
|
5
5
|
function addCoreResolvables(trans) {
|
|
6
6
|
trans.addResolvable(Resolvable.fromData(UIRouter, trans.router), "");
|
|
7
7
|
trans.addResolvable(Resolvable.fromData(Transition, trans), "");
|
|
@@ -20,7 +20,7 @@ const isTransition = inArray(TRANSITION_TOKENS);
|
|
|
20
20
|
// This function removes resolves for '$transition$' and `Transition` from the treeChanges.
|
|
21
21
|
// Do not use this on current transitions, only on old ones.
|
|
22
22
|
export const treeChangesCleanup = (trans) => {
|
|
23
|
-
const nodes = values(trans.treeChanges())
|
|
23
|
+
const nodes = Object.values(trans.treeChanges())
|
|
24
24
|
.reduce(unnestR, [])
|
|
25
25
|
.reduce(uniqR, []);
|
|
26
26
|
// If the resolvable is a Transition, return a new resolvable with null data
|
|
@@ -5,7 +5,6 @@ import {
|
|
|
5
5
|
omit,
|
|
6
6
|
tail,
|
|
7
7
|
mergeR,
|
|
8
|
-
values,
|
|
9
8
|
unnestR,
|
|
10
9
|
inArray,
|
|
11
10
|
arrayTuples,
|
|
@@ -55,7 +54,7 @@ export class PathUtils {
|
|
|
55
54
|
path
|
|
56
55
|
.filter((node) => inArray(states, node.state))
|
|
57
56
|
.forEach((node) => {
|
|
58
|
-
const viewDecls = values(node.state.views || {});
|
|
57
|
+
const viewDecls = Object.values(node.state.views || {});
|
|
59
58
|
const subPath = PathUtils.subPath(path, (n) => n === node);
|
|
60
59
|
const viewConfigs = viewDecls.map((view) =>
|
|
61
60
|
$view.createViewConfig(subPath, view),
|
|
@@ -5,7 +5,7 @@ import { ViewService } from "./view/view";
|
|
|
5
5
|
import { StateRegistry } from "./state/stateRegistry";
|
|
6
6
|
import { StateService } from "./state/stateService";
|
|
7
7
|
import { UIRouterGlobals } from "./globals";
|
|
8
|
-
import {
|
|
8
|
+
import { removeFrom } from "./common/common";
|
|
9
9
|
import { isFunction } from "./common/predicates";
|
|
10
10
|
import { UrlService } from "./url/urlService";
|
|
11
11
|
import { trace } from "./common/trace";
|
|
@@ -196,6 +196,8 @@ export class UIRouter {
|
|
|
196
196
|
return (this._plugins[pluginInstance.name] = pluginInstance);
|
|
197
197
|
}
|
|
198
198
|
getPlugin(pluginName) {
|
|
199
|
-
return pluginName
|
|
199
|
+
return pluginName
|
|
200
|
+
? this._plugins[pluginName]
|
|
201
|
+
: Object.values(this._plugins);
|
|
200
202
|
}
|
|
201
203
|
}
|
|
@@ -7,7 +7,6 @@ import {
|
|
|
7
7
|
noop,
|
|
8
8
|
omit,
|
|
9
9
|
tail,
|
|
10
|
-
values,
|
|
11
10
|
copy,
|
|
12
11
|
} from "../common/common";
|
|
13
12
|
import { isArray, isDefined, isFunction, isString } from "../common/predicates";
|
|
@@ -75,7 +74,7 @@ const getParamsBuilder = (paramFactory) =>
|
|
|
75
74
|
paramFactory.fromConfig(id, null, state.self);
|
|
76
75
|
const urlParams =
|
|
77
76
|
(state.url && state.url.parameters({ inherit: false })) || [];
|
|
78
|
-
const nonUrlParams = values(
|
|
77
|
+
const nonUrlParams = Object.values(
|
|
79
78
|
mapObj(
|
|
80
79
|
omit(state.params || {}, urlParams.map(prop("id"))),
|
|
81
80
|
makeConfigParam,
|
|
@@ -292,7 +291,7 @@ export class StateBuilder {
|
|
|
292
291
|
return null;
|
|
293
292
|
}
|
|
294
293
|
for (const key in builders) {
|
|
295
|
-
if (!
|
|
294
|
+
if (!Object.prototype.hasOwnProperty.call(builders, key)) continue;
|
|
296
295
|
const chain = builders[key].reduce(
|
|
297
296
|
(parentFn, step) => (_state) => step(_state, parentFn),
|
|
298
297
|
noop,
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { isString } from "../common/predicates";
|
|
2
|
-
import { values } from "../common/common";
|
|
3
2
|
import { safeConsole } from "../common/safeConsole";
|
|
4
3
|
export class StateMatcher {
|
|
5
4
|
constructor(_states) {
|
|
@@ -22,7 +21,7 @@ export class StateMatcher {
|
|
|
22
21
|
) {
|
|
23
22
|
return state;
|
|
24
23
|
} else if (isStr && matchGlob) {
|
|
25
|
-
const _states = values(this._states);
|
|
24
|
+
const _states = Object.values(this._states);
|
|
26
25
|
const matches = _states.filter(
|
|
27
26
|
(_state) =>
|
|
28
27
|
_state.__stateObjectCache.nameGlob &&
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { defaults,
|
|
1
|
+
import { defaults, find, inherit } from "../common/common";
|
|
2
2
|
import { propEq } from "../common/hof";
|
|
3
3
|
import { Glob } from "../common/glob";
|
|
4
4
|
import { isObject, isFunction } from "../common/predicates";
|
|
@@ -83,10 +83,11 @@ export class StateObject {
|
|
|
83
83
|
const inherited =
|
|
84
84
|
(opts.inherit && this.parent && this.parent.parameters()) || [];
|
|
85
85
|
return inherited
|
|
86
|
-
.concat(values(this.params))
|
|
86
|
+
.concat(Object.values(this.params))
|
|
87
87
|
.filter(
|
|
88
88
|
(param) =>
|
|
89
|
-
!opts.matchingKeys ||
|
|
89
|
+
!opts.matchingKeys ||
|
|
90
|
+
Object.prototype.hasOwnProperty.call(opts.matchingKeys, param.id),
|
|
90
91
|
);
|
|
91
92
|
}
|
|
92
93
|
/**
|
|
@@ -99,7 +100,7 @@ export class StateObject {
|
|
|
99
100
|
parameter(id, opts = {}) {
|
|
100
101
|
return (
|
|
101
102
|
(this.url && this.url.parameter(id, opts)) ||
|
|
102
|
-
find(values(this.params), propEq("id", id)) ||
|
|
103
|
+
find(Object.values(this.params), propEq("id", id)) ||
|
|
103
104
|
(opts.inherit && this.parent && this.parent.parameter(id))
|
|
104
105
|
);
|
|
105
106
|
}
|
|
@@ -19,7 +19,7 @@ export class StateQueueManager {
|
|
|
19
19
|
const name = state.name;
|
|
20
20
|
if (!isString(name)) throw new Error("State must have a valid name");
|
|
21
21
|
if (
|
|
22
|
-
|
|
22
|
+
Object.prototype.hasOwnProperty.call(this.states, name) ||
|
|
23
23
|
inArray(queue.map(prop("name")), name)
|
|
24
24
|
)
|
|
25
25
|
throw new Error(`State '${name}' is already defined`);
|
|
@@ -1,11 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
extend,
|
|
3
|
-
removeFrom,
|
|
4
|
-
tail,
|
|
5
|
-
values,
|
|
6
|
-
identity,
|
|
7
|
-
mapObj,
|
|
8
|
-
} from "../common/common";
|
|
1
|
+
import { extend, removeFrom, tail, identity, mapObj } from "../common/common";
|
|
9
2
|
import { isString, isFunction } from "../common/predicates";
|
|
10
3
|
import { Glob } from "../common/glob";
|
|
11
4
|
import {
|
|
@@ -125,7 +118,7 @@ export class RegisteredHook {
|
|
|
125
118
|
this._getDefaultMatchCriteria(),
|
|
126
119
|
this.matchCriteria,
|
|
127
120
|
);
|
|
128
|
-
const paths = values(this.tranSvc._pluginapi._getPathTypes());
|
|
121
|
+
const paths = Object.values(this.tranSvc._pluginapi._getPathTypes());
|
|
129
122
|
return paths.reduce((mn, pathtype) => {
|
|
130
123
|
// STATE scope criteria matches against every node in the path.
|
|
131
124
|
// TRANSITION scope criteria matches against only the last node in the path
|
|
@@ -149,7 +142,7 @@ export class RegisteredHook {
|
|
|
149
142
|
matches(treeChanges, transition) {
|
|
150
143
|
const matches = this._getMatchingNodes(treeChanges, transition);
|
|
151
144
|
// Check if all the criteria matched the TreeChanges object
|
|
152
|
-
const allMatched = values(matches).every(identity);
|
|
145
|
+
const allMatched = Object.values(matches).every(identity);
|
|
153
146
|
return allMatched ? matches : null;
|
|
154
147
|
}
|
|
155
148
|
deregister() {
|
|
@@ -26,7 +26,7 @@ import { registerLazyLoadHook } from "../hooks/lazyLoad";
|
|
|
26
26
|
import { TransitionEventType } from "./transitionEventType";
|
|
27
27
|
import { TransitionHook } from "./transitionHook";
|
|
28
28
|
import { isDefined } from "../common/predicates";
|
|
29
|
-
import { removeFrom,
|
|
29
|
+
import { removeFrom, createProxyFunctions } from "../common/common";
|
|
30
30
|
import { val } from "../common/hof";
|
|
31
31
|
import { registerIgnoredTransitionHook } from "../hooks/ignoredTransition";
|
|
32
32
|
import { registerInvalidTransitionHook } from "../hooks/invalidTransition";
|
|
@@ -148,7 +148,7 @@ export class TransitionService {
|
|
|
148
148
|
* @internal
|
|
149
149
|
*/
|
|
150
150
|
dispose(router) {
|
|
151
|
-
values(this._registeredHooks).forEach((hooksArray) =>
|
|
151
|
+
Object.values(this._registeredHooks).forEach((hooksArray) =>
|
|
152
152
|
hooksArray.forEach((hook) => {
|
|
153
153
|
hook._deregistered = true;
|
|
154
154
|
removeFrom(hooksArray, hook);
|
package/src/router/router.js
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import {
|
|
2
2
|
$uiRouterProvider,
|
|
3
|
-
getUrlRouterProvider,
|
|
4
3
|
getProviderFor,
|
|
5
4
|
getStateProvider,
|
|
6
5
|
router,
|
|
@@ -14,12 +13,11 @@ export function initRouter() {
|
|
|
14
13
|
window.angular.module("ui.router.angular1", []);
|
|
15
14
|
const mod_init = window.angular.module("ui.router.init", ["ng"]);
|
|
16
15
|
const mod_util = window.angular.module("ui.router.util", ["ui.router.init"]);
|
|
17
|
-
const mod_rtr = window.angular.module("ui.router.router", ["ui.router.util"]);
|
|
18
16
|
const mod_state = window.angular.module("ui.router.state", [
|
|
19
|
-
"ui.router.router",
|
|
20
17
|
"ui.router.util",
|
|
21
18
|
"ui.router.angular1",
|
|
22
19
|
]);
|
|
20
|
+
|
|
23
21
|
const mod_main = window.angular.module("ui.router", [
|
|
24
22
|
"ui.router.init",
|
|
25
23
|
"ui.router.state",
|
|
@@ -27,26 +25,34 @@ export function initRouter() {
|
|
|
27
25
|
]);
|
|
28
26
|
|
|
29
27
|
mod_init.provider("$uiRouter", $uiRouterProvider);
|
|
30
|
-
mod_rtr.provider("$urlRouter", ["$uiRouterProvider", getUrlRouterProvider]);
|
|
31
28
|
mod_util.provider("$urlService", getProviderFor("urlService"));
|
|
32
29
|
mod_util.provider("$urlMatcherFactory", [
|
|
33
30
|
"$uiRouterProvider",
|
|
34
|
-
()
|
|
31
|
+
function RouterProvide() {
|
|
32
|
+
return router.urlMatcherFactory;
|
|
33
|
+
},
|
|
35
34
|
]);
|
|
36
|
-
mod_util.provider("$templateFactory", ()
|
|
35
|
+
mod_util.provider("$templateFactory", function () {
|
|
36
|
+
return new TemplateFactory();
|
|
37
|
+
});
|
|
37
38
|
mod_state.provider("$stateRegistry", getProviderFor("stateRegistry"));
|
|
38
39
|
mod_state.provider("$uiRouterGlobals", getProviderFor("globals"));
|
|
39
40
|
mod_state.provider("$transitions", getProviderFor("transitionService"));
|
|
40
41
|
mod_state.provider("$state", ["$uiRouterProvider", getStateProvider]);
|
|
41
42
|
mod_state.factory("$stateParams", [
|
|
42
43
|
"$uiRouter",
|
|
43
|
-
($uiRouter)
|
|
44
|
+
function StateParamse($uiRouter) {
|
|
45
|
+
return $uiRouter.globals.params;
|
|
46
|
+
},
|
|
44
47
|
]);
|
|
45
|
-
mod_main.factory("$view", ()
|
|
46
|
-
|
|
48
|
+
mod_main.factory("$view", function View() {
|
|
49
|
+
return router.viewService;
|
|
50
|
+
});
|
|
51
|
+
mod_main.service("$trace", function Trace() {
|
|
52
|
+
return trace;
|
|
53
|
+
});
|
|
47
54
|
mod_main.run(watchDigests);
|
|
48
|
-
mod_util.run(["$urlMatcherFactory", function (
|
|
49
|
-
mod_state.run(["$state", function (
|
|
50
|
-
mod_rtr.run(["$urlRouter", function ($urlRouter) {}]);
|
|
55
|
+
mod_util.run(["$urlMatcherFactory", function MatcherFac() {}]);
|
|
56
|
+
mod_state.run(["$state", function State() {}]);
|
|
51
57
|
mod_init.run(runBlock);
|
|
52
58
|
}
|
package/test/module-test.html
CHANGED
|
@@ -1,10 +1,14 @@
|
|
|
1
1
|
<!doctype html>
|
|
2
2
|
<html>
|
|
3
3
|
<head>
|
|
4
|
-
<script
|
|
4
|
+
<script>
|
|
5
|
+
document.addEventListener("DOMContentLoaded", () => {
|
|
6
|
+
window.angular.module("test", ["ui.router"]);
|
|
7
|
+
});
|
|
8
|
+
</script>
|
|
5
9
|
<script type="module" src="../src/index.js"></script>
|
|
6
10
|
</head>
|
|
7
|
-
<body ng-app>
|
|
11
|
+
<body ng-app="test">
|
|
8
12
|
<div ng-init='list = [{ name: "x" }, { name: "y" }, { name: "z" }]'>
|
|
9
13
|
<label>Name:</label>
|
|
10
14
|
<input type="text" ng-model="yourName" placeholder="Enter a name here" />
|
|
File without changes
|
|
@@ -1,196 +0,0 @@
|
|
|
1
|
-
/** @publicapi @module url */ /** */
|
|
2
|
-
|
|
3
|
-
import { BaseUrlRule } from "../core/url/urlRule";
|
|
4
|
-
import { isString, isFunction, isArray, identity } from "../../core/utils";
|
|
5
|
-
import { services } from "../core/common/coreservices";
|
|
6
|
-
|
|
7
|
-
/**
|
|
8
|
-
* Manages rules for client-side URL
|
|
9
|
-
*
|
|
10
|
-
* ### Deprecation warning:
|
|
11
|
-
* This class is now considered to be an internal API
|
|
12
|
-
* Use the [[UrlService]] instead.
|
|
13
|
-
* For configuring URL rules, use the [[UrlRulesApi]] which can be found as [[UrlService.rules]].
|
|
14
|
-
*
|
|
15
|
-
* This class manages the router rules for what to do when the URL changes.
|
|
16
|
-
*
|
|
17
|
-
* This provider remains for backwards compatibility.
|
|
18
|
-
*
|
|
19
|
-
* @internalapi
|
|
20
|
-
* @deprecated
|
|
21
|
-
*/
|
|
22
|
-
export class UrlRouterProvider {
|
|
23
|
-
static injectableHandler(router, handler) {
|
|
24
|
-
return (match) =>
|
|
25
|
-
services.$injector.invoke(handler, null, {
|
|
26
|
-
$match: match,
|
|
27
|
-
$stateParams: router.globals.params,
|
|
28
|
-
});
|
|
29
|
-
}
|
|
30
|
-
/** @hidden */
|
|
31
|
-
constructor(/** @hidden */ router) {
|
|
32
|
-
this.router = router;
|
|
33
|
-
}
|
|
34
|
-
/** @hidden */
|
|
35
|
-
$get() {
|
|
36
|
-
const urlService = this.router.urlService;
|
|
37
|
-
this.router.urlRouter.update(true);
|
|
38
|
-
if (!urlService.interceptDeferred) urlService.listen();
|
|
39
|
-
return this.router.urlRouter;
|
|
40
|
-
}
|
|
41
|
-
/**
|
|
42
|
-
* Registers a url handler function.
|
|
43
|
-
*
|
|
44
|
-
* Registers a low level url handler (a `rule`).
|
|
45
|
-
* A rule detects specific URL patterns and returns a redirect, or performs some action.
|
|
46
|
-
*
|
|
47
|
-
* If a rule returns a string, the URL is replaced with the string, and all rules are fired again.
|
|
48
|
-
*
|
|
49
|
-
* #### Example:
|
|
50
|
-
* ```js
|
|
51
|
-
* var app = angular.module('app', ['ui.router.router']);
|
|
52
|
-
*
|
|
53
|
-
* app.config(function ($urlRouterProvider) {
|
|
54
|
-
* // Here's an example of how you might allow case insensitive urls
|
|
55
|
-
* $urlRouterProvider.rule(function ($injector, $location) {
|
|
56
|
-
* var path = $location.path(),
|
|
57
|
-
* normalized = path.toLowerCase();
|
|
58
|
-
*
|
|
59
|
-
* if (path !== normalized) {
|
|
60
|
-
* return normalized;
|
|
61
|
-
* }
|
|
62
|
-
* });
|
|
63
|
-
* });
|
|
64
|
-
* ```
|
|
65
|
-
*
|
|
66
|
-
* @param ruleFn
|
|
67
|
-
* Handler function that takes `$injector` and `$location` services as arguments.
|
|
68
|
-
* You can use them to detect a url and return a different url as a string.
|
|
69
|
-
*
|
|
70
|
-
* @return [[UrlRouterProvider]] (`this`)
|
|
71
|
-
*/
|
|
72
|
-
rule(ruleFn) {
|
|
73
|
-
if (!isFunction(ruleFn)) throw new Error("'rule' must be a function");
|
|
74
|
-
const match = () => ruleFn(services.$injector, this.router.locationService);
|
|
75
|
-
const rule = new BaseUrlRule(match, identity);
|
|
76
|
-
this.router.urlService.rules.rule(rule);
|
|
77
|
-
return this;
|
|
78
|
-
}
|
|
79
|
-
/**
|
|
80
|
-
* Defines the path or behavior to use when no url can be matched.
|
|
81
|
-
*
|
|
82
|
-
* #### Example:
|
|
83
|
-
* ```js
|
|
84
|
-
* var app = angular.module('app', ['ui.router.router']);
|
|
85
|
-
*
|
|
86
|
-
* app.config(function ($urlRouterProvider) {
|
|
87
|
-
* // if the path doesn't match any of the urls you configured
|
|
88
|
-
* // otherwise will take care of routing the user to the
|
|
89
|
-
* // specified url
|
|
90
|
-
* $urlRouterProvider.otherwise('/index');
|
|
91
|
-
*
|
|
92
|
-
* // Example of using function rule as param
|
|
93
|
-
* $urlRouterProvider.otherwise(function ($injector, $location) {
|
|
94
|
-
* return '/a/valid/url';
|
|
95
|
-
* });
|
|
96
|
-
* });
|
|
97
|
-
* ```
|
|
98
|
-
*
|
|
99
|
-
* @param rule
|
|
100
|
-
* The url path you want to redirect to or a function rule that returns the url path or performs a `$state.go()`.
|
|
101
|
-
* The function version is passed two params: `$injector` and `$location` services, and should return a url string.
|
|
102
|
-
*
|
|
103
|
-
* @return {object} `$urlRouterProvider` - `$urlRouterProvider` instance
|
|
104
|
-
*/
|
|
105
|
-
otherwise(rule) {
|
|
106
|
-
const urlRules = this.router.urlService.rules;
|
|
107
|
-
if (isString(rule)) {
|
|
108
|
-
urlRules.otherwise(rule);
|
|
109
|
-
} else if (isFunction(rule)) {
|
|
110
|
-
urlRules.otherwise(() =>
|
|
111
|
-
rule(services.$injector, this.router.locationService),
|
|
112
|
-
);
|
|
113
|
-
} else {
|
|
114
|
-
throw new Error("'rule' must be a string or function");
|
|
115
|
-
}
|
|
116
|
-
return this;
|
|
117
|
-
}
|
|
118
|
-
/**
|
|
119
|
-
* Registers a handler for a given url matching.
|
|
120
|
-
*
|
|
121
|
-
* If the handler is a string, it is
|
|
122
|
-
* treated as a redirect, and is interpolated according to the syntax of match
|
|
123
|
-
* (i.e. like `String.replace()` for `RegExp`, or like a `UrlMatcher` pattern otherwise).
|
|
124
|
-
*
|
|
125
|
-
* If the handler is a function, it is injectable.
|
|
126
|
-
* It gets invoked if `$location` matches.
|
|
127
|
-
* You have the option of inject the match object as `$match`.
|
|
128
|
-
*
|
|
129
|
-
* The handler can return
|
|
130
|
-
*
|
|
131
|
-
* - **falsy** to indicate that the rule didn't match after all, then `$urlRouter`
|
|
132
|
-
* will continue trying to find another one that matches.
|
|
133
|
-
* - **string** which is treated as a redirect and passed to `$location.url()`
|
|
134
|
-
* - **void** or any **truthy** value tells `$urlRouter` that the url was handled.
|
|
135
|
-
*
|
|
136
|
-
* #### Example:
|
|
137
|
-
* ```js
|
|
138
|
-
* var app = angular.module('app', ['ui.router.router']);
|
|
139
|
-
*
|
|
140
|
-
* app.config(function ($urlRouterProvider) {
|
|
141
|
-
* $urlRouterProvider.when($state.url, function ($match, $stateParams) {
|
|
142
|
-
* if ($state.$current.navigable !== state ||
|
|
143
|
-
* !equalForKeys($match, $stateParams) {
|
|
144
|
-
* $state.transitionTo(state, $match, false);
|
|
145
|
-
* }
|
|
146
|
-
* });
|
|
147
|
-
* });
|
|
148
|
-
* ```
|
|
149
|
-
*
|
|
150
|
-
* @param what A pattern string to match, compiled as a [[UrlMatcher]].
|
|
151
|
-
* @param handler The path (or function that returns a path) that you want to redirect your user to.
|
|
152
|
-
* @param ruleCallback [optional] A callback that receives the `rule` registered with [[UrlMatcher.rule]]
|
|
153
|
-
*
|
|
154
|
-
* Note: the handler may also invoke arbitrary code, such as `$state.go()`
|
|
155
|
-
*/
|
|
156
|
-
when(what, handler) {
|
|
157
|
-
if (isArray(handler) || isFunction(handler)) {
|
|
158
|
-
handler = UrlRouterProvider.injectableHandler(this.router, handler);
|
|
159
|
-
}
|
|
160
|
-
this.router.urlService.rules.when(what, handler);
|
|
161
|
-
return this;
|
|
162
|
-
}
|
|
163
|
-
/**
|
|
164
|
-
* Disables monitoring of the URL.
|
|
165
|
-
*
|
|
166
|
-
* Call this method before UI-Router has bootstrapped.
|
|
167
|
-
* It will stop UI-Router from performing the initial url sync.
|
|
168
|
-
*
|
|
169
|
-
* This can be useful to perform some asynchronous initialization before the router starts.
|
|
170
|
-
* Once the initialization is complete, call [[listen]] to tell UI-Router to start watching and synchronizing the URL.
|
|
171
|
-
*
|
|
172
|
-
* #### Example:
|
|
173
|
-
* ```js
|
|
174
|
-
* var app = angular.module('app', ['ui.router']);
|
|
175
|
-
*
|
|
176
|
-
* app.config(function ($urlRouterProvider) {
|
|
177
|
-
* // Prevent $urlRouter from automatically intercepting URL changes;
|
|
178
|
-
* $urlRouterProvider.deferIntercept();
|
|
179
|
-
* })
|
|
180
|
-
*
|
|
181
|
-
* app.run(function (MyService, $urlRouter, $http) {
|
|
182
|
-
* $http.get("/stuff").then(function(resp) {
|
|
183
|
-
* MyService.doStuff(resp.data);
|
|
184
|
-
* $urlRouter.listen();
|
|
185
|
-
* $urlRouter.sync();
|
|
186
|
-
* });
|
|
187
|
-
* });
|
|
188
|
-
* ```
|
|
189
|
-
*
|
|
190
|
-
* @param defer Indicates whether to defer location change interception.
|
|
191
|
-
* Passing no parameter is equivalent to `true`.
|
|
192
|
-
*/
|
|
193
|
-
deferIntercept(defer) {
|
|
194
|
-
this.router.urlService.deferIntercept(defer);
|
|
195
|
-
}
|
|
196
|
-
}
|