@angular-wave/angular.ts 0.0.29 → 0.0.30
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/index.html +5 -6
- package/package.json +1 -1
- package/src/core/controller.js +3 -0
- package/src/directive/controller.js +0 -56
- package/src/directive/controller.md +46 -0
- package/src/router/common/trace.js +1 -1
- package/src/router/directives/state-directives.js +1 -1
- package/src/router/hooks/update-globals.js +1 -1
- package/src/router/injectables.js +8 -8
- package/src/router/resolve/resolve-context.js +1 -1
- package/src/router/router.js +1 -71
- package/src/router/services.js +2 -36
- package/src/router/state/state-object.js +1 -1
- package/src/router/state/state-registry.js +1 -1
- package/src/router/state/target-state.js +1 -1
- package/src/router/state/views.js +1 -1
- package/src/router/url/url-config.js +0 -2
- package/src/router/url/url-matcher-factory.js +0 -1
- package/src/router/url/url-matcher.js +0 -8
- package/src/router/url/url-service.js +6 -6
- package/src/router/view/view.js +2 -0
- package/src/shared/common.js +1 -1
- package/types/router/core/common/coreservices.d.ts +2 -2
- package/types/router/core/common/trace.d.ts +7 -7
- package/types/router/core/globals.d.ts +2 -1
- package/types/router/core/interface.d.ts +3 -10
- package/types/router/core/params/interface.d.ts +3 -3
- package/types/router/core/resolve/resolveContext.d.ts +4 -4
- package/types/router/core/router.d.ts +5 -51
- package/types/router/core/state/interface.d.ts +6 -6
- package/types/router/core/state/stateObject.d.ts +1 -1
- package/types/router/core/state/stateQueueManager.d.ts +2 -2
- package/types/router/core/state/stateRegistry.d.ts +4 -4
- package/types/router/core/state/stateService.d.ts +9 -9
- package/types/router/core/state/targetState.d.ts +1 -1
- package/types/router/core/transition/interface.d.ts +1 -1
- package/types/router/core/transition/transition.d.ts +12 -12
- package/types/router/core/transition/transitionService.d.ts +5 -5
- package/types/router/core/url/interface.d.ts +3 -3
- package/types/router/core/url/urlConfig.d.ts +3 -3
- package/types/router/core/url/urlMatcherFactory.d.ts +3 -3
- package/types/router/core/url/urlRouter.d.ts +2 -2
- package/types/router/core/url/urlRule.d.ts +6 -6
- package/types/router/core/url/urlRules.d.ts +6 -6
- package/types/router/core/url/urlService.d.ts +8 -8
- package/types/router/core/view/interface.d.ts +1 -1
- package/types/router/core/view/view.d.ts +15 -15
- package/types/router/directives/viewDirective.d.ts +4 -4
- package/types/router/interface.d.ts +4 -4
- package/types/router/locationServices.d.ts +3 -3
- package/types/router/services.d.ts +1 -1
- package/types/router/stateProvider.d.ts +2 -2
- package/types/router/viewScroll.d.ts +1 -1
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
package/src/core/controller.js
CHANGED
|
@@ -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
|
|
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
|
|
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
|
*/
|
|
@@ -61,7 +61,7 @@
|
|
|
61
61
|
*/
|
|
62
62
|
let $stateParams;
|
|
63
63
|
/**
|
|
64
|
-
* Global
|
|
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
|
|
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
|
|
77
|
-
* It has references to the other
|
|
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
|
|
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
|
|
88
|
-
* It has references to the other
|
|
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
|
|
196
|
+
* used to disable ng-router's scroll behavior.
|
|
197
197
|
*/
|
|
198
198
|
let $ngViewScrollProvider;
|
|
199
199
|
/**
|
|
@@ -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
|
-
*
|
|
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.
|
package/src/router/router.js
CHANGED
|
@@ -20,7 +20,7 @@ import { registerRedirectToHook } from "./hooks/redirect-to";
|
|
|
20
20
|
let routerId = 0;
|
|
21
21
|
|
|
22
22
|
/**
|
|
23
|
-
* An instance of
|
|
23
|
+
* An instance of ng-router.
|
|
24
24
|
* @class
|
|
25
25
|
*
|
|
26
26
|
* This object contains references to service APIs which define your application's routing behavior.
|
|
@@ -118,78 +118,8 @@ export class UIRouter {
|
|
|
118
118
|
|
|
119
119
|
this.transitionService._deregisterHookFns.activateViews =
|
|
120
120
|
registerActivateViews(this.transitionService, this.viewService);
|
|
121
|
-
|
|
122
|
-
/** @internal plugin instances are registered here */
|
|
123
|
-
this._plugins = {};
|
|
124
121
|
this.viewService._pluginapi._rootViewContext(this.stateRegistry.root());
|
|
125
122
|
this.globals.$current = this.stateRegistry.root();
|
|
126
123
|
this.globals.current = this.globals.$current.self;
|
|
127
124
|
}
|
|
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
125
|
}
|
package/src/router/services.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* # Angular 1 types
|
|
3
3
|
*
|
|
4
|
-
*
|
|
5
|
-
* The customizations to the core types for
|
|
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,12 +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
29
|
|
|
39
30
|
/**
|
|
40
31
|
* Applys ng1-specific path parameter encoding
|
|
@@ -135,28 +126,3 @@ export const getLocals = (ctx) => {
|
|
|
135
126
|
});
|
|
136
127
|
return tuples.reduce(applyPairs, {});
|
|
137
128
|
};
|
|
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
|
-
};
|
|
@@ -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
|
|
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
|
*
|
|
@@ -125,7 +125,7 @@ export class StateRegistry {
|
|
|
125
125
|
* Gets the implicit root state
|
|
126
126
|
*
|
|
127
127
|
* Gets the root of the state tree.
|
|
128
|
-
* The root state is implicitly created by
|
|
128
|
+
* The root state is implicitly created by ng-router.
|
|
129
129
|
* Note: this returns the internal [[StateObject]] representation, not a [[StateDeclaration]]
|
|
130
130
|
*
|
|
131
131
|
* @return the root [[StateObject]]
|
|
@@ -22,7 +22,7 @@ import { stringify } from "../../shared/strings";
|
|
|
22
22
|
* 3) and transition options
|
|
23
23
|
* 4) the registered state object (the [[StateDeclaration]])
|
|
24
24
|
*
|
|
25
|
-
* Many
|
|
25
|
+
* Many ng-router APIs such as [[StateService.go]] take a [[StateOrName]] argument which can
|
|
26
26
|
* either be a *state object* (a [[StateDeclaration]] or [[StateObject]]) or a *state name* (a string).
|
|
27
27
|
* The `TargetState` class normalizes those options.
|
|
28
28
|
*
|
|
@@ -11,7 +11,7 @@ export function getNg1ViewConfigFactory() {
|
|
|
11
11
|
let templateFactory = null;
|
|
12
12
|
return (path, view) => {
|
|
13
13
|
templateFactory =
|
|
14
|
-
templateFactory || services.$injector.get("$templateFactory");
|
|
14
|
+
templateFactory || services.$injector.get("$templateFactory"); // TODO: remove static injector
|
|
15
15
|
return [new Ng1ViewConfig(path, view, templateFactory)];
|
|
16
16
|
};
|
|
17
17
|
}
|
|
@@ -18,8 +18,6 @@ export class UrlConfig {
|
|
|
18
18
|
/** @type {ParamTypes} */
|
|
19
19
|
this.paramTypes = new ParamTypes();
|
|
20
20
|
/** @type {boolean} */
|
|
21
|
-
this._decodeParams = true;
|
|
22
|
-
/** @type {boolean} */
|
|
23
21
|
this._isCaseInsensitive = false;
|
|
24
22
|
/** @type {boolean} */
|
|
25
23
|
this._isStrictMode = true;
|
|
@@ -39,7 +39,6 @@ const defaultConfig = {
|
|
|
39
39
|
state: { params: {} },
|
|
40
40
|
strict: true,
|
|
41
41
|
caseInsensitive: true,
|
|
42
|
-
decodeParams: true,
|
|
43
42
|
};
|
|
44
43
|
/**
|
|
45
44
|
* Matches URLs against patterns.
|
|
@@ -313,13 +312,6 @@ export class UrlMatcher {
|
|
|
313
312
|
}
|
|
314
313
|
_getDecodedParamValue(value, param) {
|
|
315
314
|
if (isDefined(value)) {
|
|
316
|
-
if (this.config.decodeParams && !param.type.raw) {
|
|
317
|
-
if (Array.isArray(value)) {
|
|
318
|
-
value = value.map((paramValue) => decodeURIComponent(paramValue));
|
|
319
|
-
} else {
|
|
320
|
-
value = decodeURIComponent(value);
|
|
321
|
-
}
|
|
322
|
-
}
|
|
323
315
|
value = param.type.decode(value);
|
|
324
316
|
}
|
|
325
317
|
return param.value(value);
|
|
@@ -213,9 +213,9 @@ export class UrlService {
|
|
|
213
213
|
* Starts or stops listening for URL changes
|
|
214
214
|
*
|
|
215
215
|
* Call this sometime after calling [[deferIntercept]] to start monitoring the url.
|
|
216
|
-
* This causes
|
|
216
|
+
* This causes ng-router to start listening for changes to the URL, if it wasn't already listening.
|
|
217
217
|
*
|
|
218
|
-
* If called with `false`,
|
|
218
|
+
* If called with `false`, ng-router will stop listening (call listen(true) to start listening again).
|
|
219
219
|
*
|
|
220
220
|
* #### Example:
|
|
221
221
|
* ```js
|
|
@@ -243,15 +243,15 @@ export class UrlService {
|
|
|
243
243
|
/**
|
|
244
244
|
* Disables monitoring of the URL.
|
|
245
245
|
*
|
|
246
|
-
* Call this method before
|
|
247
|
-
* It will stop
|
|
246
|
+
* Call this method before ng-router has bootstrapped.
|
|
247
|
+
* It will stop ng-router from performing the initial url sync.
|
|
248
248
|
*
|
|
249
249
|
* This can be useful to perform some asynchronous initialization before the router starts.
|
|
250
|
-
* Once the initialization is complete, call [[listen]] to tell
|
|
250
|
+
* Once the initialization is complete, call [[listen]] to tell ng-router to start watching and synchronizing the URL.
|
|
251
251
|
*
|
|
252
252
|
* #### Example:
|
|
253
253
|
* ```js
|
|
254
|
-
* // Prevent
|
|
254
|
+
* // Prevent ng-router from automatically intercepting URL changes when it starts;
|
|
255
255
|
* urlService.deferIntercept();
|
|
256
256
|
*
|
|
257
257
|
* fetch('/states.json').then(resp => resp.json()).then(data => {
|
package/src/router/view/view.js
CHANGED
|
@@ -8,6 +8,7 @@ import {
|
|
|
8
8
|
import { curry, prop } from "../../shared/hof";
|
|
9
9
|
import { isString } from "../../shared/utils";
|
|
10
10
|
import { trace } from "../common/trace";
|
|
11
|
+
import { getNg1ViewConfigFactory } from "../state/views";
|
|
11
12
|
/**
|
|
12
13
|
* The View service
|
|
13
14
|
*
|
|
@@ -45,6 +46,7 @@ export class ViewService {
|
|
|
45
46
|
return () => removeFrom(this._listeners, listener);
|
|
46
47
|
},
|
|
47
48
|
};
|
|
49
|
+
this._pluginapi._viewConfigFactory("ng1", getNg1ViewConfigFactory());
|
|
48
50
|
}
|
|
49
51
|
|
|
50
52
|
/**
|
package/src/shared/common.js
CHANGED
|
@@ -39,7 +39,7 @@ export interface CoreServices {
|
|
|
39
39
|
* Implementors should pass these through to the underlying URL mechanism.
|
|
40
40
|
* The underlying URL mechanism might be browser APIs, framework APIs, or some 3rd party URL management library.
|
|
41
41
|
*
|
|
42
|
-
*
|
|
42
|
+
* Router Core includes three basic implementations:
|
|
43
43
|
*
|
|
44
44
|
* - [[PushStateLocationService]]
|
|
45
45
|
* - [[HashLocationService]]
|
|
@@ -61,7 +61,7 @@ export interface LocationServices {
|
|
|
61
61
|
* Implementors should pass these through to the underlying URL APIs.
|
|
62
62
|
* The underlying URL mechanism might be browser APIs, framework APIs, or some 3rd party URL management library.
|
|
63
63
|
*
|
|
64
|
-
*
|
|
64
|
+
* Router Core includes two basic implementations:
|
|
65
65
|
*
|
|
66
66
|
* - [[BrowserLocationConfig]]
|
|
67
67
|
* - [[MemoryLocationConfig]]
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Transition } from "../transition/transition";
|
|
2
2
|
import { ViewTuple } from "../view";
|
|
3
|
-
import {
|
|
3
|
+
import { ActiveNGView, ViewConfig, ViewContext } from "../view/interface";
|
|
4
4
|
import { Resolvable } from "../resolve/resolvable";
|
|
5
5
|
import { PathNode } from "../path/pathNode";
|
|
6
6
|
import { PolicyWhen } from "../resolve/interface";
|
|
@@ -24,12 +24,12 @@ declare enum Category {
|
|
|
24
24
|
RESOLVE = 0,
|
|
25
25
|
TRANSITION = 1,
|
|
26
26
|
HOOK = 2,
|
|
27
|
-
|
|
27
|
+
NGVIEW = 3,
|
|
28
28
|
VIEWCONFIG = 4,
|
|
29
29
|
}
|
|
30
30
|
export { Category };
|
|
31
31
|
/**
|
|
32
|
-
* Prints
|
|
32
|
+
* Prints Router Transition trace information to the console.
|
|
33
33
|
*/
|
|
34
34
|
export declare class Trace {
|
|
35
35
|
/** @internal */
|
|
@@ -101,17 +101,17 @@ export declare class Trace {
|
|
|
101
101
|
/** @internal called by ui-router code */
|
|
102
102
|
traceSuccess(finalState: StateObject, trans: Transition): void;
|
|
103
103
|
/** @internal called by ui-router code */
|
|
104
|
-
|
|
104
|
+
traceNGViewEvent(event: string, viewData: ActiveNGView, extra?: string): void;
|
|
105
105
|
/** @internal called by ui-router code */
|
|
106
|
-
|
|
106
|
+
traceNGViewConfigUpdated(viewData: ActiveNGView, context: ViewContext): void;
|
|
107
107
|
/** @internal called by ui-router code */
|
|
108
|
-
|
|
108
|
+
traceNGViewFill(viewData: ActiveNGView, html: string): void;
|
|
109
109
|
/** @internal called by ui-router code */
|
|
110
110
|
traceViewSync(pairs: ViewTuple[]): void;
|
|
111
111
|
/** @internal called by ui-router code */
|
|
112
112
|
traceViewServiceEvent(event: string, viewConfig: ViewConfig): void;
|
|
113
113
|
/** @internal called by ui-router code */
|
|
114
|
-
|
|
114
|
+
traceViewServiceNGViewEvent(event: string, viewData: ActiveNGView): void;
|
|
115
115
|
}
|
|
116
116
|
/**
|
|
117
117
|
* The [[Trace]] singleton
|
|
@@ -3,12 +3,13 @@ import { StateDeclaration } from "./state/interface";
|
|
|
3
3
|
import { StateObject } from "./state/stateObject";
|
|
4
4
|
import { Transition } from "./transition/transition";
|
|
5
5
|
import { Queue } from "./common/queue";
|
|
6
|
+
/**
|
|
6
7
|
* Global router state
|
|
7
8
|
*
|
|
8
9
|
* This is where we hold the global mutable state such as current state, current
|
|
9
10
|
* params, current transition, etc.
|
|
10
11
|
*/
|
|
11
|
-
export declare class
|
|
12
|
+
export declare class RouterGlobals {
|
|
12
13
|
/**
|
|
13
14
|
* Current parameter values
|
|
14
15
|
*
|