@angular-wave/angular.ts 0.0.10 → 0.0.12

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (92) hide show
  1. package/README.md +8 -15
  2. package/dist/angular-ts.esm.js +1 -1
  3. package/dist/angular-ts.umd.js +1 -1
  4. package/package.json +4 -1
  5. package/src/core/compile.js +0 -26
  6. package/src/exts/messages.md +30 -30
  7. package/src/public.js +2 -0
  8. package/src/router/adapter/directives/stateDirectives.js +695 -0
  9. package/src/router/adapter/directives/viewDirective.js +514 -0
  10. package/src/router/adapter/injectables.js +314 -0
  11. package/src/router/adapter/interface.js +1 -0
  12. package/src/router/adapter/locationServices.js +86 -0
  13. package/src/router/adapter/services.js +132 -0
  14. package/src/router/adapter/stateFilters.js +43 -0
  15. package/src/router/adapter/stateProvider.js +137 -0
  16. package/src/router/adapter/statebuilders/onEnterExitRetain.js +30 -0
  17. package/src/router/adapter/statebuilders/views.js +146 -0
  18. package/src/router/adapter/templateFactory.js +218 -0
  19. package/src/router/adapter/urlRouterProvider.js +196 -0
  20. package/src/router/adapter/viewScroll.js +31 -0
  21. package/src/router/core/common/common.js +506 -0
  22. package/src/router/core/common/coreservices.js +15 -0
  23. package/src/router/core/common/glob.js +75 -0
  24. package/src/router/core/common/hof.js +194 -0
  25. package/src/router/core/common/predicates.js +44 -0
  26. package/src/router/core/common/queue.js +41 -0
  27. package/src/router/core/common/safeConsole.js +38 -0
  28. package/src/router/core/common/strings.js +141 -0
  29. package/src/router/core/common/trace.js +232 -0
  30. package/src/router/core/globals.js +29 -0
  31. package/src/router/core/hooks/coreResolvables.js +33 -0
  32. package/src/router/core/hooks/ignoredTransition.js +25 -0
  33. package/src/router/core/hooks/invalidTransition.js +14 -0
  34. package/src/router/core/hooks/lazyLoad.js +102 -0
  35. package/src/router/core/hooks/onEnterExitRetain.js +55 -0
  36. package/src/router/core/hooks/redirectTo.js +36 -0
  37. package/src/router/core/hooks/resolve.js +57 -0
  38. package/src/router/core/hooks/updateGlobals.js +30 -0
  39. package/src/router/core/hooks/url.js +25 -0
  40. package/src/router/core/hooks/views.js +39 -0
  41. package/src/router/core/interface.js +3 -0
  42. package/src/router/core/params/README.md +8 -0
  43. package/src/router/core/params/param.js +232 -0
  44. package/src/router/core/params/paramType.js +139 -0
  45. package/src/router/core/params/paramTypes.js +163 -0
  46. package/src/router/core/params/stateParams.js +35 -0
  47. package/src/router/core/path/pathNode.js +77 -0
  48. package/src/router/core/path/pathUtils.js +200 -0
  49. package/src/router/core/resolve/interface.js +10 -0
  50. package/src/router/core/resolve/resolvable.js +124 -0
  51. package/src/router/core/resolve/resolveContext.js +211 -0
  52. package/src/router/core/router.js +201 -0
  53. package/src/router/core/state/README.md +21 -0
  54. package/src/router/core/state/stateBuilder.js +333 -0
  55. package/src/router/core/state/stateMatcher.js +66 -0
  56. package/src/router/core/state/stateObject.js +116 -0
  57. package/src/router/core/state/stateQueueManager.js +89 -0
  58. package/src/router/core/state/stateRegistry.js +175 -0
  59. package/src/router/core/state/stateService.js +592 -0
  60. package/src/router/core/state/targetState.js +159 -0
  61. package/src/router/core/transition/hookBuilder.js +127 -0
  62. package/src/router/core/transition/hookRegistry.js +182 -0
  63. package/src/router/core/transition/interface.js +14 -0
  64. package/src/router/core/transition/rejectFactory.js +122 -0
  65. package/src/router/core/transition/transition.js +739 -0
  66. package/src/router/core/transition/transitionEventType.js +27 -0
  67. package/src/router/core/transition/transitionHook.js +199 -0
  68. package/src/router/core/transition/transitionService.js +311 -0
  69. package/src/router/core/url/interface.js +1 -0
  70. package/src/router/core/url/urlConfig.js +165 -0
  71. package/src/router/core/url/urlMatcher.js +548 -0
  72. package/src/router/core/url/urlMatcherFactory.js +123 -0
  73. package/src/router/core/url/urlRouter.js +115 -0
  74. package/src/router/core/url/urlRule.js +202 -0
  75. package/src/router/core/url/urlRules.js +348 -0
  76. package/src/router/core/url/urlService.js +268 -0
  77. package/src/router/core/vanilla/baseLocationService.js +31 -0
  78. package/src/router/core/vanilla/browserLocationConfig.js +42 -0
  79. package/src/router/core/vanilla/hashLocationService.js +19 -0
  80. package/src/router/core/vanilla/injector.js +98 -0
  81. package/src/router/core/vanilla/interface.js +1 -0
  82. package/src/router/core/vanilla/memoryLocationConfig.js +20 -0
  83. package/src/router/core/vanilla/memoryLocationService.js +13 -0
  84. package/src/router/core/vanilla/plugins.js +35 -0
  85. package/src/router/core/vanilla/pushStateLocationService.js +69 -0
  86. package/src/router/core/vanilla/q.js +54 -0
  87. package/src/router/core/vanilla/utils.js +63 -0
  88. package/src/router/core/view/interface.js +1 -0
  89. package/src/router/core/view/view.js +312 -0
  90. package/src/router/router.js +52 -0
  91. package/test/ng/compile.spec.js +43 -61
  92. package/test/ng/directive/init.spec.js +1 -1
@@ -0,0 +1,196 @@
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
+ }
@@ -0,0 +1,31 @@
1
+ /** @publicapi @module ng1 */ /** */
2
+
3
+ /** @hidden */
4
+ function $ViewScrollProvider() {
5
+ let useAnchorScroll = false;
6
+ this.useAnchorScroll = function () {
7
+ useAnchorScroll = true;
8
+ };
9
+ this.$get = [
10
+ "$anchorScroll",
11
+ "$timeout",
12
+ function ($anchorScroll, $timeout) {
13
+ if (useAnchorScroll) {
14
+ return $anchorScroll;
15
+ }
16
+ return function ($element) {
17
+ return $timeout(
18
+ function () {
19
+ $element[0].scrollIntoView();
20
+ },
21
+ 0,
22
+ false,
23
+ );
24
+ };
25
+ },
26
+ ];
27
+ }
28
+
29
+ window.angular
30
+ .module("ui.router.state")
31
+ .provider("$uiViewScroll", $ViewScrollProvider);