@angular/router 0.1.0 → 2.0.0-rc.2

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 (190) hide show
  1. package/bundles/router.umd.js +1812 -0
  2. package/bundles/router.umd.min.js +2 -0
  3. package/esm/index.d.ts +15 -0
  4. package/esm/index.js +15 -0
  5. package/esm/index.js.map +1 -0
  6. package/esm/src/constants.d.ts +5 -0
  7. package/esm/src/constants.js +6 -0
  8. package/esm/src/constants.js.map +1 -0
  9. package/esm/src/constants.metadata.json +1 -0
  10. package/esm/src/core_private.d.ts +3 -0
  11. package/esm/src/core_private.js +4 -0
  12. package/esm/src/core_private.js.map +1 -0
  13. package/esm/src/core_private.metadata.json +1 -0
  14. package/esm/src/directives/router_directives.d.ts +21 -0
  15. package/esm/src/directives/router_directives.js +24 -0
  16. package/esm/src/directives/router_directives.js.map +1 -0
  17. package/esm/src/directives/router_directives.metadata.json +1 -0
  18. package/esm/src/directives/router_link.d.ts +49 -0
  19. package/esm/src/directives/router_link.js +68 -0
  20. package/esm/src/directives/router_link.js.map +1 -0
  21. package/esm/src/directives/router_link.metadata.json +1 -0
  22. package/esm/src/directives/router_outlet.d.ts +36 -0
  23. package/esm/src/directives/router_outlet.js +42 -0
  24. package/esm/src/directives/router_outlet.js.map +1 -0
  25. package/esm/src/directives/router_outlet.metadata.json +1 -0
  26. package/esm/src/facade/async.d.ts +90 -0
  27. package/esm/src/facade/async.js +137 -0
  28. package/esm/src/facade/async.js.map +1 -0
  29. package/esm/src/facade/base_wrapped_exception.d.ts +14 -0
  30. package/esm/src/facade/base_wrapped_exception.js +17 -0
  31. package/esm/src/facade/base_wrapped_exception.js.map +1 -0
  32. package/esm/src/facade/collection.d.ts +103 -0
  33. package/esm/src/facade/collection.js +343 -0
  34. package/esm/src/facade/collection.js.map +1 -0
  35. package/esm/src/facade/collection.metadata.json +1 -0
  36. package/esm/src/facade/exception_handler.d.ts +29 -0
  37. package/esm/src/facade/exception_handler.js +124 -0
  38. package/esm/src/facade/exception_handler.js.map +1 -0
  39. package/esm/src/facade/exceptions.d.ts +32 -0
  40. package/esm/src/facade/exceptions.js +42 -0
  41. package/esm/src/facade/exceptions.js.map +1 -0
  42. package/esm/src/facade/exceptions.metadata.json +1 -0
  43. package/esm/src/facade/lang.d.ts +158 -0
  44. package/esm/src/facade/lang.js +386 -0
  45. package/esm/src/facade/lang.js.map +1 -0
  46. package/esm/src/facade/lang.metadata.json +1 -0
  47. package/esm/src/facade/promise.d.ts +17 -0
  48. package/esm/src/facade/promise.js +41 -0
  49. package/esm/src/facade/promise.js.map +1 -0
  50. package/esm/src/interfaces.d.ts +23 -0
  51. package/esm/src/interfaces.js +1 -0
  52. package/esm/src/interfaces.js.map +1 -0
  53. package/esm/src/lifecycle_reflector.d.ts +1 -0
  54. package/esm/src/lifecycle_reflector.js +10 -0
  55. package/esm/src/lifecycle_reflector.js.map +1 -0
  56. package/esm/src/link.d.ts +2 -0
  57. package/esm/src/link.js +183 -0
  58. package/esm/src/link.js.map +1 -0
  59. package/esm/src/metadata/decorators.d.ts +16 -0
  60. package/esm/src/metadata/decorators.js +9 -0
  61. package/esm/src/metadata/decorators.js.map +1 -0
  62. package/esm/src/metadata/decorators.metadata.json +1 -0
  63. package/esm/src/metadata/metadata.d.ts +48 -0
  64. package/esm/src/metadata/metadata.js +48 -0
  65. package/esm/src/metadata/metadata.js.map +1 -0
  66. package/esm/src/recognize.d.ts +4 -0
  67. package/esm/src/recognize.js +164 -0
  68. package/esm/src/recognize.js.map +1 -0
  69. package/esm/src/router.d.ts +95 -0
  70. package/esm/src/router.js +243 -0
  71. package/esm/src/router.js.map +1 -0
  72. package/esm/src/router_providers.d.ts +23 -0
  73. package/esm/src/router_providers.js +26 -0
  74. package/esm/src/router_providers.js.map +1 -0
  75. package/esm/src/router_providers.metadata.json +1 -0
  76. package/esm/src/router_providers_common.d.ts +11 -0
  77. package/esm/src/router_providers_common.js +32 -0
  78. package/esm/src/router_providers_common.js.map +1 -0
  79. package/esm/src/router_providers_common.metadata.json +1 -0
  80. package/esm/src/router_url_serializer.d.ts +21 -0
  81. package/esm/src/router_url_serializer.js +164 -0
  82. package/esm/src/router_url_serializer.js.map +1 -0
  83. package/esm/src/segments.d.ts +51 -0
  84. package/esm/src/segments.js +137 -0
  85. package/esm/src/segments.js.map +1 -0
  86. package/esm/src/segments.metadata.json +1 -0
  87. package/esm/testing/router_testing_providers.d.ts +1 -0
  88. package/esm/testing/router_testing_providers.js +31 -0
  89. package/esm/testing/router_testing_providers.js.map +1 -0
  90. package/esm/testing/router_testing_providers.metadata.json +1 -0
  91. package/esm/testing.d.ts +1 -0
  92. package/esm/testing.js +2 -0
  93. package/esm/testing.js.map +1 -0
  94. package/index.d.ts +15 -0
  95. package/index.js +31 -0
  96. package/index.js.map +1 -0
  97. package/package.json +16 -1
  98. package/src/constants.d.ts +5 -0
  99. package/src/constants.js +7 -0
  100. package/src/constants.js.map +1 -0
  101. package/src/constants.metadata.json +1 -0
  102. package/src/core_private.d.ts +3 -0
  103. package/src/core_private.js +5 -0
  104. package/src/core_private.js.map +1 -0
  105. package/src/core_private.metadata.json +1 -0
  106. package/src/directives/router_directives.d.ts +21 -0
  107. package/src/directives/router_directives.js +25 -0
  108. package/src/directives/router_directives.js.map +1 -0
  109. package/src/directives/router_directives.metadata.json +1 -0
  110. package/src/directives/router_link.d.ts +49 -0
  111. package/src/directives/router_link.js +76 -0
  112. package/src/directives/router_link.js.map +1 -0
  113. package/src/directives/router_link.metadata.json +1 -0
  114. package/src/directives/router_outlet.d.ts +36 -0
  115. package/src/directives/router_outlet.js +53 -0
  116. package/src/directives/router_outlet.js.map +1 -0
  117. package/src/directives/router_outlet.metadata.json +1 -0
  118. package/src/facade/async.d.ts +90 -0
  119. package/src/facade/async.js +160 -0
  120. package/src/facade/async.js.map +1 -0
  121. package/src/facade/base_wrapped_exception.d.ts +14 -0
  122. package/src/facade/base_wrapped_exception.js +50 -0
  123. package/src/facade/base_wrapped_exception.js.map +1 -0
  124. package/src/facade/collection.d.ts +103 -0
  125. package/src/facade/collection.js +368 -0
  126. package/src/facade/collection.js.map +1 -0
  127. package/src/facade/collection.metadata.json +1 -0
  128. package/src/facade/exception_handler.d.ts +29 -0
  129. package/src/facade/exception_handler.js +133 -0
  130. package/src/facade/exception_handler.js.map +1 -0
  131. package/src/facade/exceptions.d.ts +32 -0
  132. package/src/facade/exceptions.js +82 -0
  133. package/src/facade/exceptions.js.map +1 -0
  134. package/src/facade/exceptions.metadata.json +1 -0
  135. package/src/facade/lang.d.ts +158 -0
  136. package/src/facade/lang.js +480 -0
  137. package/src/facade/lang.js.map +1 -0
  138. package/src/facade/lang.metadata.json +1 -0
  139. package/src/facade/promise.d.ts +17 -0
  140. package/src/facade/promise.js +49 -0
  141. package/src/facade/promise.js.map +1 -0
  142. package/src/interfaces.d.ts +23 -0
  143. package/src/interfaces.js +2 -0
  144. package/src/interfaces.js.map +1 -0
  145. package/src/lifecycle_reflector.d.ts +1 -0
  146. package/src/lifecycle_reflector.js +12 -0
  147. package/src/lifecycle_reflector.js.map +1 -0
  148. package/src/link.d.ts +2 -0
  149. package/src/link.js +189 -0
  150. package/src/link.js.map +1 -0
  151. package/src/metadata/decorators.d.ts +16 -0
  152. package/src/metadata/decorators.js +10 -0
  153. package/src/metadata/decorators.js.map +1 -0
  154. package/src/metadata/decorators.metadata.json +1 -0
  155. package/src/metadata/metadata.d.ts +48 -0
  156. package/src/metadata/metadata.js +66 -0
  157. package/src/metadata/metadata.js.map +1 -0
  158. package/src/recognize.d.ts +4 -0
  159. package/src/recognize.js +172 -0
  160. package/src/recognize.js.map +1 -0
  161. package/src/router.d.ts +95 -0
  162. package/src/router.js +276 -0
  163. package/src/router.js.map +1 -0
  164. package/src/router_providers.d.ts +23 -0
  165. package/src/router_providers.js +27 -0
  166. package/src/router_providers.js.map +1 -0
  167. package/src/router_providers.metadata.json +1 -0
  168. package/src/router_providers_common.d.ts +11 -0
  169. package/src/router_providers_common.js +35 -0
  170. package/src/router_providers_common.js.map +1 -0
  171. package/src/router_providers_common.metadata.json +1 -0
  172. package/src/router_url_serializer.d.ts +21 -0
  173. package/src/router_url_serializer.js +184 -0
  174. package/src/router_url_serializer.js.map +1 -0
  175. package/src/segments.d.ts +51 -0
  176. package/src/segments.js +181 -0
  177. package/src/segments.js.map +1 -0
  178. package/src/segments.metadata.json +1 -0
  179. package/testing/router_testing_providers.d.ts +1 -0
  180. package/testing/router_testing_providers.js +35 -0
  181. package/testing/router_testing_providers.js.map +1 -0
  182. package/testing/router_testing_providers.metadata.json +1 -0
  183. package/testing.d.ts +1 -0
  184. package/testing.js +6 -0
  185. package/testing.js.map +1 -0
  186. package/angular1/angular_1_router.js +0 -2922
  187. package/angular1/ng_route_shim.js +0 -349
  188. package/angular2/router.dev.js +0 -3107
  189. package/angular2/router.js +0 -3107
  190. package/angular2/router.min.js +0 -3
@@ -1,349 +0,0 @@
1
- /** @license Copyright 2014-2016 Google, Inc. http://github.com/angular/angular/LICENSE */
2
- (function () {
3
-
4
- 'use strict';
5
-
6
- // keep a reference to compileProvider so we can register new component-directives
7
- // on-the-fly based on $routeProvider configuration
8
- // TODO: remove this– right now you can only bootstrap one Angular app with this hack
9
- var $compileProvider, $q, $injector;
10
-
11
- /**
12
- * This module loads services that mimic ngRoute's configuration, and includes
13
- * an anchor link directive that intercepts clicks to routing.
14
- *
15
- * This module is intended to be used as a stop-gap solution for projects upgrading from ngRoute.
16
- * It intentionally does not implement all features of ngRoute.
17
- */
18
- angular.module('ngRouteShim', [])
19
- .provider('$route', $RouteProvider)
20
- .config(['$compileProvider', function (compileProvider) {
21
- $compileProvider = compileProvider;
22
- }])
23
- .factory('$routeParams', $routeParamsFactory)
24
- .directive('a', anchorLinkDirective)
25
-
26
- // Connects the legacy $routeProvider config shim to Component Router's config.
27
- .run(['$route', '$router', function ($route, $router) {
28
- $route.$$subscribe(function (routeDefinition) {
29
- if (!angular.isArray(routeDefinition)) {
30
- routeDefinition = [routeDefinition];
31
- }
32
- $router.config(routeDefinition);
33
- });
34
- }]);
35
-
36
-
37
- /**
38
- * A shimmed out provider that provides the same API as ngRoute's $routeProvider, but uses these calls
39
- * to configure Component Router.
40
- */
41
- function $RouteProvider() {
42
-
43
- var routes = [];
44
- var subscriptionFn = null;
45
-
46
- var routeMap = {};
47
-
48
- // Stats for which routes are skipped
49
- var skipCount = 0;
50
- var successCount = 0;
51
- var allCount = 0;
52
-
53
- function consoleMetrics() {
54
- return '(' + skipCount + ' skipped / ' + successCount + ' success / ' + allCount + ' total)';
55
- }
56
-
57
-
58
- /**
59
- * @ngdoc method
60
- * @name $routeProvider#when
61
- *
62
- * @param {string} path Route path (matched against `$location.path`). If `$location.path`
63
- * contains redundant trailing slash or is missing one, the route will still match and the
64
- * `$location.path` will be updated to add or drop the trailing slash to exactly match the
65
- * route definition.
66
- *
67
- * @param {Object} route Mapping information to be assigned to `$route.current` on route
68
- * match.
69
- */
70
- this.when = function(path, route) {
71
- //copy original route object to preserve params inherited from proto chain
72
- var routeCopy = angular.copy(route);
73
-
74
- allCount++;
75
-
76
- if (angular.isDefined(routeCopy.reloadOnSearch)) {
77
- console.warn('Route for "' + path + '" uses "reloadOnSearch" which is not implemented.');
78
- }
79
- if (angular.isDefined(routeCopy.caseInsensitiveMatch)) {
80
- console.warn('Route for "' + path + '" uses "caseInsensitiveMatch" which is not implemented.');
81
- }
82
-
83
- // use new wildcard format
84
- path = reformatWildcardParams(path);
85
-
86
- if (path[path.length - 1] == '*') {
87
- skipCount++;
88
- console.warn('Route for "' + path + '" ignored because it ends with *. Skipping.', consoleMetrics());
89
- return this;
90
- }
91
-
92
- if (path.indexOf('?') > -1) {
93
- skipCount++;
94
- console.warn('Route for "' + path + '" ignored because it has optional parameters. Skipping.', consoleMetrics());
95
- return this;
96
- }
97
-
98
- if (typeof route.redirectTo == 'function') {
99
- skipCount++;
100
- console.warn('Route for "' + path + '" ignored because lazy redirecting to a function is not yet implemented. Skipping.', consoleMetrics());
101
- return this;
102
- }
103
-
104
-
105
- var routeDefinition = {
106
- path: path,
107
- data: routeCopy
108
- };
109
-
110
- routeMap[path] = routeCopy;
111
-
112
- if (route.redirectTo) {
113
- routeDefinition.redirectTo = [routeMap[route.redirectTo].name];
114
- } else {
115
- if (routeCopy.controller && !routeCopy.controllerAs) {
116
- console.warn('Route for "' + path + '" should use "controllerAs".');
117
- }
118
-
119
- var directiveName = routeObjToRouteName(routeCopy, path);
120
-
121
- if (!directiveName) {
122
- throw new Error('Could not determine a name for route "' + path + '".');
123
- }
124
-
125
- routeDefinition.component = directiveName;
126
- routeDefinition.name = route.name || upperCase(directiveName);
127
-
128
- var directiveController = routeCopy.controller;
129
-
130
- var directiveDefinition = {
131
- scope: false,
132
- controller: directiveController,
133
- controllerAs: routeCopy.controllerAs,
134
- templateUrl: routeCopy.templateUrl,
135
- template: routeCopy.template
136
- };
137
-
138
- var directiveFactory = function () {
139
- return directiveDefinition;
140
- };
141
-
142
- // if we have route resolve options, prepare a wrapper controller
143
- if (directiveController && routeCopy.resolve) {
144
- var originalController = directiveController;
145
- var resolvedLocals = {};
146
-
147
- directiveDefinition.controller = ['$injector', '$scope', function ($injector, $scope) {
148
- var locals = angular.extend({
149
- $scope: $scope
150
- }, resolvedLocals);
151
-
152
- var ctrl = $injector.instantiate(originalController, locals);
153
-
154
- if (routeCopy.controllerAs) {
155
- locals.$scope[routeCopy.controllerAs] = ctrl;
156
- }
157
-
158
- return ctrl;
159
- }];
160
-
161
- // we take care of controllerAs in the directive controller wrapper
162
- delete directiveDefinition.controllerAs;
163
-
164
- // we resolve the locals in a canActivate block
165
- directiveFactory.$canActivate = function() {
166
- var locals = angular.extend({}, routeCopy.resolve);
167
-
168
- angular.forEach(locals, function(value, key) {
169
- locals[key] = angular.isString(value) ?
170
- $injector.get(value) : $injector.invoke(value, null, null, key);
171
- });
172
-
173
- return $q.all(locals).then(function (locals) {
174
- resolvedLocals = locals;
175
- }).then(function () {
176
- return true;
177
- });
178
- };
179
- }
180
-
181
- // register the dynamically created directive
182
- $compileProvider.directive(directiveName, directiveFactory);
183
- }
184
- if (subscriptionFn) {
185
- subscriptionFn(routeDefinition);
186
- } else {
187
- routes.push(routeDefinition);
188
- }
189
- successCount++;
190
-
191
- return this;
192
- };
193
-
194
- this.otherwise = function(params) {
195
- if (typeof params === 'string') {
196
- params = {redirectTo: params};
197
- }
198
- this.when('/*rest', params);
199
- return this;
200
- };
201
-
202
-
203
- this.$get = ['$q', '$injector', function (q, injector) {
204
- $q = q;
205
- $injector = injector;
206
-
207
- var $route = {
208
- routes: routeMap,
209
-
210
- /**
211
- * @ngdoc method
212
- * @name $route#reload
213
- *
214
- * @description
215
- * Causes `$route` service to reload the current route even if
216
- * {@link ng.$location $location} hasn't changed.
217
- */
218
- reload: function() {
219
- throw new Error('Not implemented: $route.reload');
220
- },
221
-
222
- /**
223
- * @ngdoc method
224
- * @name $route#updateParams
225
- */
226
- updateParams: function(newParams) {
227
- throw new Error('Not implemented: $route.updateParams');
228
- },
229
-
230
- /**
231
- * Runs the given `fn` whenever new configs are added.
232
- * Only one subscription is allowed.
233
- * Passed `fn` is called synchronously.
234
- */
235
- $$subscribe: function(fn) {
236
- if (subscriptionFn) {
237
- throw new Error('only one subscription allowed');
238
- }
239
- subscriptionFn = fn;
240
- subscriptionFn(routes);
241
- routes = [];
242
- },
243
-
244
- /**
245
- * Runs a string with stats about many route configs were adapted, and how many were
246
- * dropped because they are incompatible.
247
- */
248
- $$getStats: consoleMetrics
249
- };
250
-
251
- return $route;
252
- }];
253
-
254
- }
255
-
256
- function $routeParamsFactory($router, $rootScope) {
257
- // the identity of this object cannot change
258
- var paramsObj = {};
259
-
260
- $rootScope.$on('$routeChangeSuccess', function () {
261
- var newParams = $router._currentInstruction && $router._currentInstruction.component.params;
262
-
263
- angular.forEach(paramsObj, function (val, name) {
264
- delete paramsObj[name];
265
- });
266
- angular.forEach(newParams, function (val, name) {
267
- paramsObj[name] = val;
268
- });
269
- });
270
-
271
- return paramsObj;
272
- }
273
-
274
- /**
275
- * Allows normal anchor links to kick off routing.
276
- */
277
- function anchorLinkDirective($router) {
278
- return {
279
- restrict: 'E',
280
- link: function (scope, element) {
281
- // If the linked element is not an anchor tag anymore, do nothing
282
- if (element[0].nodeName.toLowerCase() !== 'a') {
283
- return;
284
- }
285
-
286
- // SVGAElement does not use the href attribute, but rather the 'xlinkHref' attribute.
287
- var hrefAttrName = Object.prototype.toString.call(element.prop('href')) === '[object SVGAnimatedString]' ?
288
- 'xlink:href' : 'href';
289
-
290
- element.on('click', function (event) {
291
- if (event.which !== 1) {
292
- return;
293
- }
294
-
295
- var href = element.attr(hrefAttrName);
296
- if (href && $router.recognize(href)) {
297
- $router.navigateByUrl(href);
298
- event.preventDefault();
299
- }
300
- });
301
- }
302
- };
303
- }
304
-
305
- /**
306
- * Given a route object, attempts to find a unique directive name.
307
- *
308
- * @param route – route config object passed to $routeProvider.when
309
- * @param path – route configuration path
310
- * @returns {string|name} – a normalized (camelCase) directive name
311
- */
312
- function routeObjToRouteName(route, path) {
313
- var name = route.controllerAs;
314
-
315
- var controller = route.controller;
316
- if (!name && controller) {
317
- if (angular.isArray(controller)) {
318
- controller = controller[controller.length - 1];
319
- }
320
- name = controller.name;
321
- }
322
-
323
- if (!name) {
324
- var segments = path.split('/');
325
- name = segments[segments.length - 1];
326
- }
327
-
328
- if (name) {
329
- name = name + 'AutoCmp';
330
- }
331
-
332
- return name;
333
- }
334
-
335
- function upperCase(str) {
336
- return str.charAt(0).toUpperCase() + str.substr(1);
337
- }
338
-
339
- /*
340
- * Changes "/:foo*" to "/*foo"
341
- */
342
- var WILDCARD_PARAM_RE = new RegExp('\\/:([a-z0-9]+)\\*', 'gi');
343
- function reformatWildcardParams(path) {
344
- return path.replace(WILDCARD_PARAM_RE, function (m, m1) {
345
- return '/*' + m1;
346
- });
347
- }
348
-
349
- }());