@angular-wave/angular.ts 0.0.29 → 0.0.31

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 (63) hide show
  1. package/dist/angular-ts.esm.js +1 -1
  2. package/dist/angular-ts.umd.js +1 -1
  3. package/index.html +5 -6
  4. package/package.json +1 -1
  5. package/src/core/controller.js +3 -0
  6. package/src/directive/controller.js +0 -56
  7. package/src/directive/controller.md +46 -0
  8. package/src/router/common/trace.js +1 -1
  9. package/src/router/directives/state-directives.js +1 -1
  10. package/src/router/hooks/update-globals.js +1 -1
  11. package/src/router/hooks/url.js +4 -4
  12. package/src/router/index.js +0 -6
  13. package/src/router/injectables.js +9 -60
  14. package/src/router/resolve/resolve-context.js +1 -1
  15. package/src/router/router.js +3 -95
  16. package/src/router/services.js +2 -58
  17. package/src/router/state/state-builder.js +7 -6
  18. package/src/router/state/state-object.js +1 -1
  19. package/src/router/state/state-registry.js +6 -5
  20. package/src/router/state/state-service.js +4 -5
  21. package/src/router/state/target-state.js +1 -1
  22. package/src/router/state/views.js +1 -1
  23. package/src/router/url/url-config.js +25 -2
  24. package/src/router/url/url-matcher.js +0 -8
  25. package/src/router/url/url-service.js +138 -8
  26. package/src/router/view/view.js +3 -1
  27. package/src/shared/common.js +2 -2
  28. package/test/router/services.spec.js +8 -17
  29. package/test/router/{url-matcher-factory.spec.js → url-service.spec.js} +126 -130
  30. package/test/router/view.spec.js +4 -11
  31. package/types/router/core/common/coreservices.d.ts +2 -2
  32. package/types/router/core/common/trace.d.ts +7 -7
  33. package/types/router/core/globals.d.ts +2 -1
  34. package/types/router/core/interface.d.ts +3 -10
  35. package/types/router/core/params/interface.d.ts +5 -5
  36. package/types/router/core/resolve/resolveContext.d.ts +4 -4
  37. package/types/router/core/router.d.ts +5 -51
  38. package/types/router/core/state/interface.d.ts +6 -6
  39. package/types/router/core/state/stateObject.d.ts +1 -1
  40. package/types/router/core/state/stateQueueManager.d.ts +2 -2
  41. package/types/router/core/state/stateRegistry.d.ts +4 -4
  42. package/types/router/core/state/stateService.d.ts +9 -9
  43. package/types/router/core/state/targetState.d.ts +1 -1
  44. package/types/router/core/transition/interface.d.ts +1 -1
  45. package/types/router/core/transition/transition.d.ts +12 -12
  46. package/types/router/core/transition/transitionService.d.ts +5 -5
  47. package/types/router/core/url/interface.d.ts +3 -3
  48. package/types/router/core/url/urlConfig.d.ts +3 -3
  49. package/types/router/core/url/urlMatcherFactory.d.ts +4 -4
  50. package/types/router/core/url/urlRouter.d.ts +2 -2
  51. package/types/router/core/url/urlRule.d.ts +6 -6
  52. package/types/router/core/url/urlRules.d.ts +6 -6
  53. package/types/router/core/url/urlService.d.ts +8 -8
  54. package/types/router/core/view/interface.d.ts +1 -1
  55. package/types/router/core/view/view.d.ts +15 -15
  56. package/types/router/directives/viewDirective.d.ts +4 -4
  57. package/types/router/interface.d.ts +4 -4
  58. package/types/router/locationServices.d.ts +3 -3
  59. package/types/router/services.d.ts +1 -1
  60. package/types/router/stateProvider.d.ts +2 -2
  61. package/types/router/viewScroll.d.ts +1 -1
  62. package/src/router/url/url-matcher-factory.js +0 -77
  63. package/src/router/url/url-router.js +0 -101
package/index.html CHANGED
@@ -16,7 +16,7 @@
16
16
 
17
17
  <!-- <script src="dist/angular-ts.umd.js"></script> -->
18
18
  <!-- include spec files here... -->
19
-
19
+
20
20
  <script type="module" src="test/directive/boolean.spec.js"></script>
21
21
  <script type="module" src="test/directive/form.spec.js"></script>
22
22
  <script type="module" src="test/directive/input.spec.js"></script>
@@ -26,7 +26,7 @@
26
26
  <script type="module" src="test/directive/click.spec.js"></script>
27
27
  <script type="module" src="test/directive/cloak.spec.js"></script>
28
28
  <script type="module" src="test/directive/controller.spec.js"></script>
29
- <script type="module" src="test/directive/event.spec.js"></script>
29
+ <!-- <script type="module" src="test/directive/event.spec.js"></script>
30
30
  <script type="module" src="test/directive/href.spec.js"></script>
31
31
  <script type="module" src="test/directive/if.spec.js"></script>
32
32
  <script type="module" src="test/directive/include.spec.js"></script>
@@ -70,7 +70,6 @@
70
70
  <script type="module" src="test/core/on.spec.js"></script>
71
71
  <script type="module" src="test/core/prop.spec.js"></script>
72
72
  <script type="module" src="test/core/parse.spec.js"></script>
73
- <script type="module" src="test/core/pubsub.spec.js"></script>
74
73
  <script type="module" src="test/core/q.spec.js"></script>
75
74
  <script type="module" src="test/core/root-element.spec.js"></script>
76
75
 
@@ -96,8 +95,8 @@
96
95
  <script type="module" src="test/shared/common.spec.js"></script>
97
96
  <script type="module" src="test/shared/hof.spec.js"></script>
98
97
  <script type="module" src="test/shared/strings.spec.js"></script>
99
- <script type="module" src="test/shared/utils.spec.js"></script>
100
-
98
+ <script type="module" src="test/shared/utils.spec.js"></script>-->
99
+ <!-- <script type="module" src="test/core/pubsub.spec.js"></script>-->
101
100
  <script type="module" src="test/router/glob.spec.js"></script>
102
101
  <script type="module" src="test/router/services.spec.js"></script>
103
102
  <script type="module" src="test/router/state-directives.spec.js"></script>
@@ -108,7 +107,7 @@
108
107
  <script type="module" src="test/router/view-directive.spec.js"></script>
109
108
  <script type="module" src="test/router/view-hook.spec.js"></script>
110
109
  <script type="module" src="test/router/view-scroll.spec.js"></script>
111
- <script type="module" src="test/router/view.spec.js"></script>
110
+ <script type="module" src="test/router/view.spec.js"></script>
112
111
 
113
112
 
114
113
  <!-- <script type="module" src="test/core/interval.spec.js"></script>
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@angular-wave/angular.ts",
3
3
  "license": "MIT",
4
- "version": "0.0.29",
4
+ "version": "0.0.31",
5
5
  "type": "module",
6
6
  "main": "dist/angular-ts.esm.js",
7
7
  "browser": "dist/angular-ts.umd.js",
@@ -98,7 +98,10 @@ export function $ControllerProvider() {
98
98
  // param `ident` --- An optional label which overrides the label parsed from the controller
99
99
  // expression, if any.
100
100
  let instance;
101
+
102
+ /** @type { RegExpMatchArray | null} */
101
103
  let match;
104
+
102
105
  let constructor;
103
106
  let identifier;
104
107
  later = later === true;
@@ -1,59 +1,3 @@
1
- /**
2
- * @ngdoc directive
3
- * @name ngController
4
- *
5
- * @description
6
- * The `ngController` directive attaches a controller class to the view. This is a key aspect of how angular
7
- * supports the principles behind the Model-View-Controller design pattern.
8
- *
9
- * MVC components in angular:
10
- *
11
- * * Model — Models are the properties of a scope; scopes are attached to the DOM where scope properties
12
- * are accessed through bindings.
13
- * * View — The template (HTML with data bindings) that is rendered into the View.
14
- * * Controller — The `ngController` directive specifies a Controller class; the class contains business
15
- * logic behind the application to decorate the scope with functions and values
16
- *
17
- * Note that you can also attach controllers to the DOM by declaring it in a route definition
18
- * via the {@link ngRoute.$route $route} service. A common mistake is to declare the controller
19
- * again using `ng-controller` in the template itself. This will cause the controller to be attached
20
- * and executed twice.
21
- *
22
- * @element ANY
23
- * @scope
24
- * @priority 500
25
- * @param {String} ngController Name of a constructor function registered with the current
26
- * {@link ng.$controllerProvider $controllerProvider} or an {@link guide/expression expression}
27
- * that on the current scope evaluates to a constructor function.
28
- *
29
- * The controller instance can be published into a scope property by specifying
30
- * `ng-controller="as propertyName"`.
31
- *
32
- * @example
33
- * Here is a simple form for editing user contact information. Adding, removing, clearing, and
34
- * greeting are methods declared on the controller (see source tab). These methods can
35
- * easily be called from the AngularJS markup. Any changes to the data are automatically reflected
36
- * in the View without the need for a manual update.
37
- *
38
- * Two different declaration styles are included below:
39
- *
40
- * * one binds methods and properties directly onto the controller using `this`:
41
- * `ng-controller="SettingsController1 as settings"`
42
- * * one injects `$scope` into the controller:
43
- * `ng-controller="SettingsController2"`
44
- *
45
- * The second option is more common in the AngularJS community, and is generally used in boilerplates
46
- * and in this guide. However, there are advantages to binding properties directly to the controller
47
- * and avoiding scope.
48
- *
49
- * * Using `controller as` makes it obvious which controller you are accessing in the template when
50
- * multiple controllers apply to an element.
51
- * * If you are writing your controllers as classes you have easier access to the properties and
52
- * methods, which will appear on the scope, from inside the controller code.
53
- * * Since there is always a `.` in the bindings, you don't have to worry about prototypal
54
- * inheritance masking primitives.
55
- *
56
- */
57
1
  export const ngControllerDirective = [
58
2
  () => ({
59
3
  restrict: "A",
@@ -0,0 +1,46 @@
1
+ # ngController Directive
2
+
3
+ ## Description
4
+
5
+ The `ngController` directive attaches a controller class to the view. This is a key aspect of how Angular supports the principles behind the Model-View-Controller design pattern.
6
+
7
+ ### MVC components in Angular:
8
+
9
+ - **Model**: Models are the properties of a scope; scopes are attached to the DOM where scope properties are accessed through bindings.
10
+ - **View**: The template (HTML with data bindings) that is rendered into the View.
11
+ - **Controller**: The `ngController` directive specifies a Controller class; the class contains business logic behind the application to decorate the scope with functions and values.
12
+
13
+ Note that you can also attach controllers to the DOM by declaring it in a route definition via the [$route](https://docs.angularjs.org/api/ngRoute/service/$route) service. A common mistake is to declare the controller again using `ng-controller` in the template itself. This will cause the controller to be attached and executed twice.
14
+
15
+ ## Element
16
+
17
+ `ANY`
18
+
19
+ ## Scope
20
+
21
+ Yes
22
+
23
+ ## Priority
24
+
25
+ 500
26
+
27
+ ## Parameter
28
+
29
+ - **ngController**: Name of a constructor function registered with the current [$controllerProvider](https://docs.angularjs.org/api/ng/provider/$controllerProvider) or an [expression](https://docs.angularjs.org/guide/expression) that on the current scope evaluates to a constructor function.
30
+
31
+ The controller instance can be published into a scope property by specifying `ng-controller="as propertyName"`.
32
+
33
+ ## Example
34
+
35
+ Here is a simple form for editing user contact information. Adding, removing, clearing, and greeting are methods declared on the controller (see source tab). These methods can easily be called from the AngularJS markup. Any changes to the data are automatically reflected in the View without the need for a manual update.
36
+
37
+ Two different declaration styles are included below:
38
+
39
+ - One binds methods and properties directly onto the controller using `this`: `ng-controller="SettingsController1 as settings"`
40
+ - One injects `$scope` into the controller: `ng-controller="SettingsController2"`
41
+
42
+ The second option is more common in the AngularJS community and is generally used in boilerplates and in this guide. However, there are advantages to binding properties directly to the controller and avoiding scope.
43
+
44
+ - Using `controller as` makes it obvious which controller you are accessing in the template when multiple controllers apply to an element.
45
+ - If you are writing your controllers as classes you have easier access to the properties and methods, which will appear on the scope, from inside the controller code.
46
+ - Since there is always a `.` in the bindings, you don't have to worry about prototypal inheritance masking primitives.
@@ -81,7 +81,7 @@ const _tid = parse("$id");
81
81
  const _rid = parse("router.$id");
82
82
  const transLbl = (trans) => `Transition #${_tid(trans)}-${_rid(trans)}`;
83
83
  /**
84
- * Prints UI-Router Transition trace information to the console.
84
+ * Prints ng-router Transition trace information to the console.
85
85
  */
86
86
  export class Trace {
87
87
  constructor() {
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * # Angular 1 Directives
3
3
  *
4
- * These are the directives included in UI-Router for Angular 1.
4
+ * These are the directives included in ng-router for Angular 1.
5
5
  * These directives are used in templates to create viewports and link/navigate to states.
6
6
  *
7
7
  */
@@ -1,6 +1,6 @@
1
1
  import { copy } from "../../shared/common";
2
2
  /**
3
- * A [[TransitionHookFn]] which updates global UI-Router state
3
+ * A [[TransitionHookFn]] which updates global ng-router state
4
4
  *
5
5
  * Registered using `transitionService.onBefore({}, updateGlobalState);`
6
6
  *
@@ -1,7 +1,7 @@
1
1
  export const registerUpdateUrl = (
2
2
  transitionService,
3
3
  stateService,
4
- urlRouter,
4
+ urlService,
5
5
  ) => {
6
6
  /**
7
7
  * A [[TransitionHookFn]] which updates the URL after a successful transition
@@ -11,7 +11,7 @@ export const registerUpdateUrl = (
11
11
  const updateUrl = (transition) => {
12
12
  const options = transition.options();
13
13
  const $state = stateService;
14
- const $urlRouter = urlRouter;
14
+
15
15
  // Dont update the url in these situations:
16
16
  // The transition was triggered by a URL sync (options.source === 'url')
17
17
  // The user doesn't want the url to update (options.location === false)
@@ -22,13 +22,13 @@ export const registerUpdateUrl = (
22
22
  $state.$current.navigable
23
23
  ) {
24
24
  const urlOptions = { replace: options.location === "replace" };
25
- $urlRouter.push(
25
+ urlService.push(
26
26
  $state.$current.navigable.url,
27
27
  $state.globals.params,
28
28
  urlOptions,
29
29
  );
30
30
  }
31
- $urlRouter.update(true);
31
+ urlService.update(true);
32
32
  };
33
33
  transitionService.onSuccess({}, updateUrl, { priority: 9999 });
34
34
  };
@@ -22,12 +22,6 @@ export function initRouter() {
22
22
  .module("ng.router", ["ng"])
23
23
  .provider("$router", $routerProvider)
24
24
  .provider("$urlService", getProviderFor("urlService"))
25
- .provider("$urlMatcherFactory", [
26
- "$routerProvider",
27
- function RouterProvide() {
28
- return router.urlMatcherFactory;
29
- },
30
- ])
31
25
  .provider("$templateFactory", TemplateFactory)
32
26
  .provider("$stateRegistry", getProviderFor("stateRegistry"))
33
27
  .provider("$routerGlobals", getProviderFor("globals"))
@@ -61,7 +61,7 @@
61
61
  */
62
62
  let $stateParams;
63
63
  /**
64
- * Global UI-Router variables
64
+ * Global ng-router variables
65
65
  *
66
66
  * The router global state as a **Service Object** (injectable during runtime).
67
67
  *
@@ -69,23 +69,23 @@ let $stateParams;
69
69
  */
70
70
  let $routerGlobals;
71
71
  /**
72
- * The UI-Router instance
72
+ * The ng-router instance
73
73
  *
74
74
  * The [[UIRouter]] singleton (the router instance) as a **Service Object** (injectable during runtime).
75
75
  *
76
- * This object is the UI-Router singleton instance, created by angular dependency injection during application bootstrap.
77
- * It has references to the other UI-Router services
76
+ * This object is the ng-router singleton instance, created by angular dependency injection during application bootstrap.
77
+ * It has references to the other ng-router services
78
78
  *
79
79
  * #### Note: This object is also exposed as [[$routerProvider]] for injection during angular config time.
80
80
  */
81
81
  let $router;
82
82
  /**
83
- * The UI-Router instance
83
+ * The ng-router instance
84
84
  *
85
85
  * The [[UIRouter]] singleton (the router instance) as a **Provider Object** (injectable during config phase).
86
86
  *
87
- * This object is the UI-Router singleton instance, created by angular dependency injection during application bootstrap.
88
- * It has references to the other UI-Router services
87
+ * This object is the ng-router singleton instance, created by angular dependency injection during application bootstrap.
88
+ * It has references to the other ng-router services
89
89
  *
90
90
  * #### Note: This object is also exposed as [[$router]] for injection during runtime.
91
91
  */
@@ -193,7 +193,7 @@ let $stateRegistryProvider;
193
193
  * The [[UIViewScrollProvider]] as a **Provider Object** (injectable during config time).
194
194
  *
195
195
  * This angular service exposes the [[UIViewScrollProvider]] singleton and is
196
- * used to disable UI-Router's scroll behavior.
196
+ * used to disable ng-router's scroll behavior.
197
197
  */
198
198
  let $ngViewScrollProvider;
199
199
  /**
@@ -259,56 +259,5 @@ let $urlServiceProvider;
259
259
  * ##### Note: This service can also be injected during the config phase as [[$urlServiceProvider]].
260
260
  */
261
261
  let $urlService;
262
- /**
263
- * The URL Router Provider
264
- *
265
- * ### Deprecation warning: This object is now considered internal. Use [[$urlServiceProvider]] instead.
266
- *
267
- * The [[UrlRouter]] singleton as a **Provider Object** (injectable during config time).
268
- *
269
- * #### Note: This object is also exposed as [[$urlRouter]] for injection during runtime.
270
- *
271
- * @deprecated
272
- */
273
- let $urlRouterProvider;
274
- /**
275
- * The Url Router
276
- *
277
- * ### Deprecation warning: This object is now considered internal. Use [[$urlService]] instead.
278
- *
279
- * The [[UrlRouter]] singleton as a **Service Object** (injectable during runtime).
280
- *
281
- * #### Note: This object is also exposed as [[$urlRouterProvider]] for injection during angular config time.
282
- *
283
- * @deprecated
284
- */
285
- let $urlRouter;
286
- /**
287
- * The URL Matcher Factory
288
- *
289
- * ### Deprecation warning: This object is now considered internal. Use [[$urlService]] instead.
290
- *
291
- * The [[UrlMatcherFactory]] singleton as a **Service Object** (injectable during runtime).
292
- *
293
- * This service is used to set url mapping options, define custom parameter types, and create [[UrlMatcher]] objects.
294
- *
295
- * #### Note: This object is also exposed as [[$urlMatcherFactoryProvider]] for injection during angular config time.
296
- *
297
- * @deprecated
298
- */
299
- let $urlMatcherFactory;
300
- /**
301
- * The URL Matcher Factory
302
- *
303
- * ### Deprecation warning: This object is now considered internal. Use [[$urlService]] instead.
304
- *
305
- * The [[UrlMatcherFactory]] singleton as a **Provider Object** (injectable during config time).
306
- *
307
- * This service is used to set url mapping options, define custom parameter types, and create [[UrlMatcher]] objects.
308
- *
309
- * #### Note: This object is also exposed as [[$urlMatcherFactory]] for injection during runtime.
310
- *
311
- * @deprecated
312
- */
313
- let $urlMatcherFactoryProvider;
262
+
314
263
  export {};
@@ -26,7 +26,7 @@ export const NATIVE_INJECTOR_TOKEN = "Native Injector";
26
26
  /**
27
27
  * Encapsulates Dependency Injection for a path of nodes
28
28
  *
29
- * UI-Router states are organized as a tree.
29
+ * ng-router states are organized as a tree.
30
30
  * A nested state has a path of ancestors to the root of the tree.
31
31
  * When a state is being activated, each element in the path is wrapped as a [[PathNode]].
32
32
  * A `PathNode` is a stateful object that holds things like parameters and resolvables for the state being activated.
@@ -1,5 +1,3 @@
1
- import { UrlMatcherFactory } from "./url/url-matcher-factory";
2
- import { UrlRouter } from "./url/url-router";
3
1
  import { TransitionService } from "./transition/transition-service";
4
2
  import { ViewService } from "./view/view";
5
3
  import { StateRegistry } from "./state/state-registry";
@@ -20,7 +18,7 @@ import { registerRedirectToHook } from "./hooks/redirect-to";
20
18
  let routerId = 0;
21
19
 
22
20
  /**
23
- * An instance of UI-Router.
21
+ * An instance of ng-router.
24
22
  * @class
25
23
  *
26
24
  * This object contains references to service APIs which define your application's routing behavior.
@@ -70,31 +68,11 @@ export class UIRouter {
70
68
  this.stateService,
71
69
  );
72
70
 
73
- /**
74
- * Deprecated for public use. Use [[urlService]] instead.
75
- * @deprecated Use [[urlService]] instead
76
- */
77
- this.urlMatcherFactory = new UrlMatcherFactory(this.urlService.config);
78
-
79
- /**
80
- * Deprecated for public use. Use [[urlService]] instead.
81
- * @deprecated Use [[urlService]] instead
82
- */
83
- this.urlRouter = new UrlRouter(
84
- this.urlService,
85
- urlRuleFactory,
86
- $locationProvider,
87
- );
88
-
89
71
  /** Provides a registry for states, and related registration services */
90
- this.stateRegistry = new StateRegistry(
91
- this.urlMatcherFactory,
92
- this.urlService.rules,
93
- );
72
+ this.stateRegistry = new StateRegistry(this.urlService);
94
73
 
95
74
  // Manual wiring ideally we would want to do this at runtime
96
75
  this.stateService.stateRegistry = this.stateRegistry;
97
- this.stateService.urlRouter = this.urlRouter;
98
76
  this.stateService.urlService = this.urlService; // <-- NOTE: circular dependency
99
77
 
100
78
  // Lazy load state trees
@@ -109,7 +87,7 @@ export class UIRouter {
109
87
  this.transitionService._deregisterHookFns.updateUrl = registerUpdateUrl(
110
88
  this.transitionService,
111
89
  this.stateService,
112
- this.urlRouter,
90
+ this.urlService,
113
91
  );
114
92
 
115
93
  // Wire up redirectTo hook
@@ -118,78 +96,8 @@ export class UIRouter {
118
96
 
119
97
  this.transitionService._deregisterHookFns.activateViews =
120
98
  registerActivateViews(this.transitionService, this.viewService);
121
-
122
- /** @internal plugin instances are registered here */
123
- this._plugins = {};
124
99
  this.viewService._pluginapi._rootViewContext(this.stateRegistry.root());
125
100
  this.globals.$current = this.stateRegistry.root();
126
101
  this.globals.current = this.globals.$current.self;
127
102
  }
128
-
129
- /**
130
- * Adds a plugin to UI-Router
131
- *
132
- * This method adds a UI-Router Plugin.
133
- * A plugin can enhance or change UI-Router behavior using any public API.
134
- *
135
- * #### Example:
136
- * ```js
137
- * import { MyCoolPlugin } from "ui-router-cool-plugin";
138
- *
139
- * var plugin = router.addPlugin(MyCoolPlugin);
140
- * ```
141
- *
142
- * ### Plugin authoring
143
- *
144
- * A plugin is simply a class (or constructor function) which accepts a [[UIRouter]] instance and (optionally) an options object.
145
- *
146
- * The plugin can implement its functionality using any of the public APIs of [[UIRouter]].
147
- * For example, it may configure router options or add a Transition Hook.
148
- *
149
- * The plugin can then be published as a separate module.
150
- *
151
- * #### Example:
152
- * ```js
153
- * export class MyAuthPlugin implements UIRouterPlugin {
154
- * constructor(router: UIRouter, options: any) {
155
- * this.name = "MyAuthPlugin";
156
- * let $transitions = router.transitionService;
157
- * let $state = router.stateService;
158
- *
159
- * let authCriteria = {
160
- * to: (state) => state.data && state.data.requiresAuth
161
- * };
162
- *
163
- * function authHook(transition: Transition) {
164
- * let authService = transition.injector().get('AuthService');
165
- * if (!authService.isAuthenticated()) {
166
- * return $state.target('login');
167
- * }
168
- * }
169
- *
170
- * $transitions.onStart(authCriteria, authHook);
171
- * }
172
- * }
173
- * ```
174
- *
175
- * @param plugin one of:
176
- * - a plugin class which implements [[UIRouterPlugin]]
177
- * - a constructor function for a [[UIRouterPlugin]] which accepts a [[UIRouter]] instance
178
- * - a factory function which accepts a [[UIRouter]] instance and returns a [[UIRouterPlugin]] instance
179
- * @param options options to pass to the plugin class/factory
180
- * @returns the registered plugin instance
181
- */
182
- plugin(plugin, options = {}) {
183
- const pluginInstance = new plugin(this, options);
184
- if (!pluginInstance.name)
185
- throw new Error(
186
- "Required property `name` missing on plugin: " + pluginInstance,
187
- );
188
- return (this._plugins[pluginInstance.name] = pluginInstance);
189
- }
190
- getPlugin(pluginName) {
191
- return pluginName
192
- ? this._plugins[pluginName]
193
- : Object.values(this._plugins);
194
- }
195
103
  }
@@ -1,8 +1,8 @@
1
1
  /**
2
2
  * # Angular 1 types
3
3
  *
4
- * UI-Router core provides various Typescript types which you can use for code completion and validating parameter values, etc.
5
- * The customizations to the core types for Angular UI-Router are documented here.
4
+ * ng-router core provides various Typescript types which you can use for code completion and validating parameter values, etc.
5
+ * The customizations to the core types for ng-router are documented here.
6
6
  *
7
7
  * The optional [[$resolve]] service is also documented here.
8
8
  *
@@ -13,10 +13,7 @@ import { applyPairs, unnestR } from "../shared/common";
13
13
  import { isString } from "../shared/utils";
14
14
  import { trace } from "./common/trace";
15
15
  import { UIRouter } from "./router";
16
- import { getNg1ViewConfigFactory } from "./state/views";
17
-
18
16
  import { StateProvider } from "./state-provider";
19
- import { ResolveContext } from "./resolve/resolve-context";
20
17
 
21
18
  /** @type {angular.UIRouter}} */
22
19
  export let router = null;
@@ -29,33 +26,6 @@ export function $routerProvider($locationProvider) {
29
26
  router.stateRegistry,
30
27
  router.stateService,
31
28
  );
32
- router.viewService._pluginapi._viewConfigFactory(
33
- "ng1",
34
- getNg1ViewConfigFactory(),
35
- );
36
- // Disable decoding of params by UrlMatcherFactory because $location already handles this
37
- router.urlService.config._decodeParams = false;
38
-
39
- /**
40
- * Applys ng1-specific path parameter encoding
41
- *
42
- * The Angular 1 `$location` service is a bit weird.
43
- * It doesn't allow slashes to be encoded/decoded bi-directionally.
44
- *
45
- * See the writeup at https://github.com/angular-ui/ui-router/issues/2598
46
- *
47
- * This code patches the `path` parameter type so it encoded/decodes slashes as ~2F
48
- *
49
- */
50
- const pathType = router.urlMatcherFactory.type("path");
51
- pathType.encode = (x) =>
52
- x != null
53
- ? x.toString().replace(/(~|\/)/g, (m) => ({ "~": "~~", "/": "~2F" })[m])
54
- : x;
55
- pathType.decode = (x) =>
56
- x != null
57
- ? x.toString().replace(/(~~|~2F)/g, (m) => ({ "~~": "~", "~2F": "/" })[m])
58
- : x;
59
29
 
60
30
  // backwards compat: also expose router instance as $routerProvider.router
61
31
  router["router"] = router;
@@ -108,7 +78,6 @@ export function runBlock($injector, $q, $router) {
108
78
  }
109
79
 
110
80
  // $state service and $stateProvider
111
- // $urlRouter service and $urlRouterProvider
112
81
  export function getStateProvider() {
113
82
  return Object.assign(router.stateProvider, {
114
83
  $get: () => router.stateService,
@@ -135,28 +104,3 @@ export const getLocals = (ctx) => {
135
104
  });
136
105
  return tuples.reduce(applyPairs, {});
137
106
  };
138
-
139
- /**
140
- * This is a [[StateBuilder.builder]] function for angular1 `onEnter`, `onExit`,
141
- * `onRetain` callback hooks on a [[Ng1StateDeclaration]].
142
- *
143
- * When the [[StateBuilder]] builds a [[StateObject]] object from a raw [[StateDeclaration]], this builder
144
- * ensures that those hooks are injectable for @uirouter/angularjs (ng1).
145
- *
146
- * @internalapi
147
- */
148
- const getStateHookBuilder = (hookName) =>
149
- function stateHookBuilder(stateObject) {
150
- const hook = stateObject[hookName];
151
- const pathname = hookName === "onExit" ? "from" : "to";
152
- function decoratedNg1Hook(trans, state) {
153
- const resolveContext = new ResolveContext(trans.treeChanges(pathname));
154
- const subContext = resolveContext.subContext(state.$$state());
155
- const locals = Object.assign(getLocals(subContext), {
156
- $state$: state,
157
- $transition$: trans,
158
- });
159
- return services.$injector.invoke(hook, this, locals);
160
- }
161
- return hook ? decoratedNg1Hook : undefined;
162
- };
@@ -29,7 +29,7 @@ function dataBuilder(state) {
29
29
  }
30
30
  return state.data;
31
31
  }
32
- const getUrlBuilder = ($urlMatcherFactoryProvider, root) =>
32
+ const getUrlBuilder = ($urlService, root) =>
33
33
  function urlBuilder(stateObject) {
34
34
  let stateDec = stateObject.self;
35
35
  // For future states, i.e., states whose name ends with `.**`,
@@ -49,9 +49,9 @@ const getUrlBuilder = ($urlMatcherFactoryProvider, root) =>
49
49
  const parsed = parseUrl(stateDec.url);
50
50
  const url = !parsed
51
51
  ? stateDec.url
52
- : $urlMatcherFactoryProvider.compile(parsed.val, { state: stateDec });
52
+ : $urlService.compile(parsed.val, { state: stateDec });
53
53
  if (!url) return null;
54
- if (!$urlMatcherFactoryProvider.isMatcher(url))
54
+ if (!$urlService.isMatcher(url))
55
55
  throw new Error(`Invalid url '${url}' in state '${stateObject}'`);
56
56
  return parsed && parsed.root
57
57
  ? url
@@ -238,7 +238,7 @@ export function resolvablesBuilder(state) {
238
238
  * using the [[builder]] method.
239
239
  */
240
240
  export class StateBuilder {
241
- constructor(matcher, urlMatcherFactory) {
241
+ constructor(matcher, urlService) {
242
242
  this.matcher = matcher;
243
243
  this.$injector = undefined;
244
244
  const self = this;
@@ -254,10 +254,11 @@ export class StateBuilder {
254
254
  parent: [parentBuilder],
255
255
  data: [dataBuilder],
256
256
  // Build a URLMatcher if necessary, either via a relative or absolute URL
257
- url: [getUrlBuilder(urlMatcherFactory, root)],
257
+ url: [getUrlBuilder(urlService, root)],
258
258
  // Keep track of the closest ancestor state that has a URL (i.e. is navigable)
259
259
  navigable: [getNavigableBuilder(isRoot)],
260
- params: [getParamsBuilder(urlMatcherFactory.paramFactory)],
260
+ // TODO
261
+ params: [getParamsBuilder(urlService.paramFactory)],
261
262
  // Each framework-specific ui-router implementation should define its own `views` builder
262
263
  // e.g., src/ng1/statebuilders/views.ts
263
264
  views: [],
@@ -3,7 +3,7 @@ import { propEq } from "../../shared/hof";
3
3
  import { Glob } from "../common/glob";
4
4
  import { isFunction, isObject } from "../../shared/utils";
5
5
  /**
6
- * Internal representation of a UI-Router state.
6
+ * Internal representation of a ng-router state.
7
7
  *
8
8
  * Instances of this class are created when a [[StateDeclaration]] is registered with the [[StateRegistry]].
9
9
  *