@angular-wave/angular.ts 0.0.65 → 0.0.67
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 +2 -2
- package/dist/angular-ts.umd.js +2 -2
- package/package.json +1 -1
- package/src/animations/animate-js.js +6 -0
- package/src/animations/animate-swap.js +3 -0
- package/src/animations/animation.js +1 -1
- package/src/core/compile/compile.js +16 -4
- package/src/core/controller/controller.js +5 -5
- package/src/core/di/injector.js +133 -259
- package/src/core/di/injector.md +3 -3
- package/src/core/di/injector.spec.js +30 -24
- package/src/core/di/internal-injector.js +286 -0
- package/src/core/filter/filter.js +5 -0
- package/src/core/parser/parse.js +1 -12
- package/src/core/parser/parse.spec.js +96 -110
- package/src/core/sce/sce.js +6 -1
- package/src/core/timeout/timeout.js +110 -111
- package/src/directive/input/input.js +32 -726
- package/src/directive/input/input.md +706 -0
- package/src/directive/select/select.js +48 -122
- package/src/directive/select/select.md +74 -0
- package/src/directive/show-hide/show-hide.js +13 -224
- package/src/directive/show-hide/show-hide.md +257 -0
- package/src/filters/limit-to.spec.js +1 -1
- package/src/filters/order-by.spec.js +1 -1
- package/src/index.js +6 -2
- package/src/loader.js +8 -4
- package/src/public.js +1 -7
- package/src/router/services.js +9 -4
- package/src/router/state/state-builder.js +6 -7
- package/src/router/state/state-registry.js +5 -0
- package/src/router/state/state-service.js +1 -1
- package/src/router/state/views.js +2 -1
- package/src/router/state-provider.js +1 -1
- package/src/router/template-factory.js +15 -14
- package/src/router/url/url-service.js +4 -4
- package/src/services/anchor-scroll.js +2 -2
- package/src/services/browser.js +2 -9
- package/src/services/cache-factory.js +0 -67
- package/src/services/cache-factory.md +75 -0
- package/src/services/cookie-reader.js +36 -55
- package/src/services/http/http.js +73 -586
- package/src/services/http/http.md +413 -0
- package/src/services/http-backend/http-backend.js +19 -44
- package/src/services/template-request.js +1 -9
- package/src/shared/jqlite/jqlite.js +4 -69
- package/src/types.js +8 -12
- package/types/animations/animate-js.d.ts +1 -1
- package/types/animations/animate-swap.d.ts +4 -7
- package/types/animations/animation.d.ts +1 -1
- package/types/core/compile/compile.d.ts +7 -7
- package/types/core/controller/controller.d.ts +1 -6
- package/types/core/di/injector.d.ts +13 -7
- package/types/core/di/internal-injector.d.ts +91 -0
- package/types/core/exception-handler.d.ts +1 -1
- package/types/core/filter/filter.d.ts +1 -1
- package/types/core/parser/parse.d.ts +1 -1
- package/types/core/sce/sce.d.ts +1 -1
- package/types/core/timeout/timeout.d.ts +16 -26
- package/types/directive/input/input.d.ts +19 -124
- package/types/directive/select/select.d.ts +7 -74
- package/types/directive/show-hide/show-hide.d.ts +11 -224
- package/types/loader.d.ts +4 -4
- package/types/router/services.d.ts +8 -1
- package/types/router/state/state-builder.d.ts +1 -2
- package/types/router/state/state-registry.d.ts +2 -2
- package/types/router/state/state-service.d.ts +2 -2
- package/types/router/state-provider.d.ts +2 -2
- package/types/router/template-factory.d.ts +16 -16
- package/types/router/url/url-service.d.ts +4 -4
- package/types/services/anchor-scroll.d.ts +1 -1
- package/types/services/browser.d.ts +0 -10
- package/types/services/cache-factory.d.ts +0 -67
- package/types/services/cookie-reader.d.ts +2 -10
- package/types/services/http/http.d.ts +53 -61
- package/types/services/http-backend/http-backend.d.ts +8 -31
- package/types/services/template-request.d.ts +1 -9
- package/types/shared/jqlite/jqlite.d.ts +9 -9
- package/types/types.d.ts +5 -38
|
@@ -0,0 +1,257 @@
|
|
|
1
|
+
/\*\*
|
|
2
|
+
|
|
3
|
+
- @ngdoc directive
|
|
4
|
+
- @name ngShow
|
|
5
|
+
- @multiElement
|
|
6
|
+
-
|
|
7
|
+
- @description
|
|
8
|
+
- The `ngShow` directive shows or hides the given HTML element based on the expression provided to
|
|
9
|
+
- the `ngShow` attribute.
|
|
10
|
+
-
|
|
11
|
+
- The element is shown or hidden by removing or adding the `.ng-hide` CSS class onto the element.
|
|
12
|
+
- The `.ng-hide` CSS class is predefined in AngularJS and sets the display style to none (using an
|
|
13
|
+
- `!important` flag). For CSP mode please add `angular-csp.css` to your HTML file (see
|
|
14
|
+
- {@link ng.directive:ngCsp ngCsp}).
|
|
15
|
+
-
|
|
16
|
+
- ```html
|
|
17
|
+
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
- <!-- when $scope.myValue is truthy (element is visible) -->
|
|
21
|
+
- <div ng-show="myValue"></div>
|
|
22
|
+
-
|
|
23
|
+
- <!-- when $scope.myValue is falsy (element is hidden) -->
|
|
24
|
+
- <div ng-show="myValue" class="ng-hide"></div>
|
|
25
|
+
- ```
|
|
26
|
+
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
-
|
|
30
|
+
- When the `ngShow` expression evaluates to a falsy value then the `.ng-hide` CSS class is added
|
|
31
|
+
- to the class attribute on the element causing it to become hidden. When truthy, the `.ng-hide`
|
|
32
|
+
- CSS class is removed from the element causing the element not to appear hidden.
|
|
33
|
+
-
|
|
34
|
+
- ## Why is `!important` used?
|
|
35
|
+
-
|
|
36
|
+
- You may be wondering why `!important` is used for the `.ng-hide` CSS class. This is because the
|
|
37
|
+
- `.ng-hide` selector can be easily overridden by heavier selectors. For example, something as
|
|
38
|
+
- simple as changing the display style on a HTML list item would make hidden elements appear
|
|
39
|
+
- visible. This also becomes a bigger issue when dealing with CSS frameworks.
|
|
40
|
+
-
|
|
41
|
+
- By using `!important`, the show and hide behavior will work as expected despite any clash between
|
|
42
|
+
- CSS selector specificity (when `!important` isn't used with any conflicting styles). If a
|
|
43
|
+
- developer chooses to override the styling to change how to hide an element then it is just a
|
|
44
|
+
- matter of using `!important` in their own CSS code.
|
|
45
|
+
-
|
|
46
|
+
- ### Overriding `.ng-hide`
|
|
47
|
+
-
|
|
48
|
+
- By default, the `.ng-hide` class will style the element with `display: none !important`. If you
|
|
49
|
+
- wish to change the hide behavior with `ngShow`/`ngHide`, you can simply overwrite the styles for
|
|
50
|
+
- the `.ng-hide` CSS class. Note that the selector that needs to be used is actually
|
|
51
|
+
- `.ng-hide:not(.ng-hide-animate)` to cope with extra animation classes that can be added.
|
|
52
|
+
-
|
|
53
|
+
- ```css
|
|
54
|
+
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
- .ng-hide:not(.ng-hide-animate) {
|
|
58
|
+
- /\* These are just alternative ways of hiding an element \*/
|
|
59
|
+
- display: block!important;
|
|
60
|
+
- position: absolute;
|
|
61
|
+
- top: -9999px;
|
|
62
|
+
- left: -9999px;
|
|
63
|
+
- }
|
|
64
|
+
- ```
|
|
65
|
+
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
-
|
|
69
|
+
- By default you don't need to override anything in CSS and the animations will work around the
|
|
70
|
+
- display style.
|
|
71
|
+
-
|
|
72
|
+
- @animations
|
|
73
|
+
- | Animation | Occurs |
|
|
74
|
+
- |-----------------------------------------------------|---------------------------------------------------------------------------------------------------------------|
|
|
75
|
+
- | {@link $animate#addClass addClass} `.ng-hide` | After the `ngShow` expression evaluates to a non truthy value and just before the contents are set to hidden. |
|
|
76
|
+
- | {@link $animate#removeClass removeClass} `.ng-hide` | After the `ngShow` expression evaluates to a truthy value and just before contents are set to visible. |
|
|
77
|
+
-
|
|
78
|
+
- Animations in `ngShow`/`ngHide` work with the show and hide events that are triggered when the
|
|
79
|
+
- directive expression is true and false. This system works like the animation system present with
|
|
80
|
+
- `ngClass` except that you must also include the `!important` flag to override the display
|
|
81
|
+
- property so that the elements are not actually hidden during the animation.
|
|
82
|
+
-
|
|
83
|
+
- ```css
|
|
84
|
+
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
- /\* A working example can be found at the bottom of this page. \*/
|
|
88
|
+
- .my-element.ng-hide-add, .my-element.ng-hide-remove {
|
|
89
|
+
- transition: all 0.5s linear;
|
|
90
|
+
- }
|
|
91
|
+
-
|
|
92
|
+
- .my-element.ng-hide-add { ... }
|
|
93
|
+
- .my-element.ng-hide-add.ng-hide-add-active { ... }
|
|
94
|
+
- .my-element.ng-hide-remove { ... }
|
|
95
|
+
- .my-element.ng-hide-remove.ng-hide-remove-active { ... }
|
|
96
|
+
- ```
|
|
97
|
+
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
-
|
|
101
|
+
- Keep in mind that, as of AngularJS version 1.3, there is no need to change the display property
|
|
102
|
+
- to block during animation states - ngAnimate will automatically handle the style toggling for you.
|
|
103
|
+
-
|
|
104
|
+
- @element ANY
|
|
105
|
+
- @param {string} ngShow If the {@link guide/expression expression} is truthy/falsy then the
|
|
106
|
+
- element is shown/hidden respectively.
|
|
107
|
+
-
|
|
108
|
+
- @example
|
|
109
|
+
- A simple example, animating the element's opacity:
|
|
110
|
+
|
|
111
|
+
- <hr />
|
|
112
|
+
-
|
|
113
|
+
- @knownIssue
|
|
114
|
+
-
|
|
115
|
+
- ### Flickering when using ngShow to toggle between elements
|
|
116
|
+
-
|
|
117
|
+
- When using {@link ngShow} and / or {@link ngHide} to toggle between elements, it can
|
|
118
|
+
- happen that both the element to show and the element to hide are visible for a very short time.
|
|
119
|
+
-
|
|
120
|
+
- This usually happens when the {@link ngAnimate ngAnimate module} is included, but no actual animations
|
|
121
|
+
- are defined for {@link ngShow} / {@link ngHide}.
|
|
122
|
+
-
|
|
123
|
+
- There are several way to mitigate this problem:
|
|
124
|
+
-
|
|
125
|
+
- - {@link guide/animations#how-to-selectively-enable-disable-and-skip-animations Disable animations on the affected elements}.
|
|
126
|
+
- - Use {@link ngIf} or {@link ngSwitch} instead of {@link ngShow} / {@link ngHide}.
|
|
127
|
+
- - Use the special CSS selector `ng-hide.ng-hide-animate` to set `{display: none}` or similar on the affected elements.
|
|
128
|
+
- - Use `ng-class="{'ng-hide': expression}` instead of instead of {@link ngShow} / {@link ngHide}.
|
|
129
|
+
- - Define an animation on the affected elements.
|
|
130
|
+
\*/
|
|
131
|
+
|
|
132
|
+
/\*\*
|
|
133
|
+
|
|
134
|
+
- @ngdoc directive
|
|
135
|
+
- @name ngHide
|
|
136
|
+
- @multiElement
|
|
137
|
+
-
|
|
138
|
+
- @description
|
|
139
|
+
- The `ngHide` directive shows or hides the given HTML element based on the expression provided to
|
|
140
|
+
- the `ngHide` attribute.
|
|
141
|
+
-
|
|
142
|
+
- The element is shown or hidden by removing or adding the `.ng-hide` CSS class onto the element.
|
|
143
|
+
- The `.ng-hide` CSS class is predefined in AngularJS and sets the display style to none (using an
|
|
144
|
+
- `!important` flag). For CSP mode please add `angular-csp.css` to your HTML file (see
|
|
145
|
+
- {@link ng.directive:ngCsp ngCsp}).
|
|
146
|
+
-
|
|
147
|
+
- ```html
|
|
148
|
+
|
|
149
|
+
```
|
|
150
|
+
|
|
151
|
+
- <!-- when $scope.myValue is truthy (element is hidden) -->
|
|
152
|
+
- <div ng-hide="myValue" class="ng-hide"></div>
|
|
153
|
+
-
|
|
154
|
+
- <!-- when $scope.myValue is falsy (element is visible) -->
|
|
155
|
+
- <div ng-hide="myValue"></div>
|
|
156
|
+
- ```
|
|
157
|
+
|
|
158
|
+
```
|
|
159
|
+
|
|
160
|
+
-
|
|
161
|
+
- When the `ngHide` expression evaluates to a truthy value then the `.ng-hide` CSS class is added
|
|
162
|
+
- to the class attribute on the element causing it to become hidden. When falsy, the `.ng-hide`
|
|
163
|
+
- CSS class is removed from the element causing the element not to appear hidden.
|
|
164
|
+
-
|
|
165
|
+
- ## Why is `!important` used?
|
|
166
|
+
-
|
|
167
|
+
- You may be wondering why `!important` is used for the `.ng-hide` CSS class. This is because the
|
|
168
|
+
- `.ng-hide` selector can be easily overridden by heavier selectors. For example, something as
|
|
169
|
+
- simple as changing the display style on a HTML list item would make hidden elements appear
|
|
170
|
+
- visible. This also becomes a bigger issue when dealing with CSS frameworks.
|
|
171
|
+
-
|
|
172
|
+
- By using `!important`, the show and hide behavior will work as expected despite any clash between
|
|
173
|
+
- CSS selector specificity (when `!important` isn't used with any conflicting styles). If a
|
|
174
|
+
- developer chooses to override the styling to change how to hide an element then it is just a
|
|
175
|
+
- matter of using `!important` in their own CSS code.
|
|
176
|
+
-
|
|
177
|
+
- ### Overriding `.ng-hide`
|
|
178
|
+
-
|
|
179
|
+
- By default, the `.ng-hide` class will style the element with `display: none !important`. If you
|
|
180
|
+
- wish to change the hide behavior with `ngShow`/`ngHide`, you can simply overwrite the styles for
|
|
181
|
+
- the `.ng-hide` CSS class. Note that the selector that needs to be used is actually
|
|
182
|
+
- `.ng-hide:not(.ng-hide-animate)` to cope with extra animation classes that can be added.
|
|
183
|
+
-
|
|
184
|
+
- ```css
|
|
185
|
+
|
|
186
|
+
```
|
|
187
|
+
|
|
188
|
+
- .ng-hide:not(.ng-hide-animate) {
|
|
189
|
+
- /\* These are just alternative ways of hiding an element \*/
|
|
190
|
+
- display: block!important;
|
|
191
|
+
- position: absolute;
|
|
192
|
+
- top: -9999px;
|
|
193
|
+
- left: -9999px;
|
|
194
|
+
- }
|
|
195
|
+
- ```
|
|
196
|
+
|
|
197
|
+
```
|
|
198
|
+
|
|
199
|
+
-
|
|
200
|
+
- By default you don't need to override in CSS anything and the animations will work around the
|
|
201
|
+
- display style.
|
|
202
|
+
-
|
|
203
|
+
- @animations
|
|
204
|
+
- | Animation | Occurs |
|
|
205
|
+
- |-----------------------------------------------------|------------------------------------------------------------------------------------------------------------|
|
|
206
|
+
- | {@link $animate#addClass addClass} `.ng-hide` | After the `ngHide` expression evaluates to a truthy value and just before the contents are set to hidden. |
|
|
207
|
+
- | {@link $animate#removeClass removeClass} `.ng-hide` | After the `ngHide` expression evaluates to a non truthy value and just before contents are set to visible. |
|
|
208
|
+
-
|
|
209
|
+
- Animations in `ngShow`/`ngHide` work with the show and hide events that are triggered when the
|
|
210
|
+
- directive expression is true and false. This system works like the animation system present with
|
|
211
|
+
- `ngClass` except that you must also include the `!important` flag to override the display
|
|
212
|
+
- property so that the elements are not actually hidden during the animation.
|
|
213
|
+
-
|
|
214
|
+
- ```css
|
|
215
|
+
|
|
216
|
+
```
|
|
217
|
+
|
|
218
|
+
- /\* A working example can be found at the bottom of this page. \*/
|
|
219
|
+
- .my-element.ng-hide-add, .my-element.ng-hide-remove {
|
|
220
|
+
- transition: all 0.5s linear;
|
|
221
|
+
- }
|
|
222
|
+
-
|
|
223
|
+
- .my-element.ng-hide-add { ... }
|
|
224
|
+
- .my-element.ng-hide-add.ng-hide-add-active { ... }
|
|
225
|
+
- .my-element.ng-hide-remove { ... }
|
|
226
|
+
- .my-element.ng-hide-remove.ng-hide-remove-active { ... }
|
|
227
|
+
- ```
|
|
228
|
+
|
|
229
|
+
```
|
|
230
|
+
|
|
231
|
+
-
|
|
232
|
+
- Keep in mind that, as of AngularJS version 1.3, there is no need to change the display property
|
|
233
|
+
- to block during animation states - ngAnimate will automatically handle the style toggling for you.
|
|
234
|
+
-
|
|
235
|
+
- @element ANY
|
|
236
|
+
- @param {string} ngHide If the {@link guide/expression expression} is truthy/falsy then the
|
|
237
|
+
- element is hidden/shown respectively.
|
|
238
|
+
-
|
|
239
|
+
- @knownIssue
|
|
240
|
+
-
|
|
241
|
+
- ### Flickering when using ngHide to toggle between elements
|
|
242
|
+
-
|
|
243
|
+
- When using {@link ngShow} and / or {@link ngHide} to toggle between elements, it can
|
|
244
|
+
- happen that both the element to show and the element to hide are visible for a very short time.
|
|
245
|
+
-
|
|
246
|
+
- This usually happens when the {@link ngAnimate ngAnimate module} is included, but no actual animations
|
|
247
|
+
- are defined for {@link ngShow} / {@link ngHide}. Internet Explorer is affected more often than
|
|
248
|
+
- other browsers.
|
|
249
|
+
-
|
|
250
|
+
- There are several way to mitigate this problem:
|
|
251
|
+
-
|
|
252
|
+
- - {@link guide/animations#how-to-selectively-enable-disable-and-skip-animations Disable animations on the affected elements}.
|
|
253
|
+
- - Use {@link ngIf} or {@link ngSwitch} instead of {@link ngShow} / {@link ngHide}.
|
|
254
|
+
- - Use the special CSS selector `ng-hide.ng-hide-animate` to set `{display: none}` or similar on the affected elements.
|
|
255
|
+
- - Use `ng-class="{'ng-hide': expression}` instead of instead of {@link ngShow} / {@link ngHide}.
|
|
256
|
+
- - Define an animation on the affected elements.
|
|
257
|
+
\*/
|
package/src/index.js
CHANGED
|
@@ -3,6 +3,10 @@ import { Angular } from "./loader";
|
|
|
3
3
|
export const angular = new Angular();
|
|
4
4
|
window["angular"] = angular;
|
|
5
5
|
|
|
6
|
-
document.
|
|
6
|
+
if (document.readyState === "complete") {
|
|
7
7
|
angular.init(document);
|
|
8
|
-
}
|
|
8
|
+
} else {
|
|
9
|
+
document.addEventListener("DOMContentLoaded", () => {
|
|
10
|
+
angular.init(document);
|
|
11
|
+
});
|
|
12
|
+
}
|
package/src/loader.js
CHANGED
|
@@ -144,7 +144,7 @@ export class Angular {
|
|
|
144
144
|
* @param {*} scope
|
|
145
145
|
* @param {JQLite} el
|
|
146
146
|
* @param {*} compile
|
|
147
|
-
* @param {
|
|
147
|
+
* @param {import("./core/di/internal-injector").InjectorService} $injector
|
|
148
148
|
*/
|
|
149
149
|
function (scope, el, compile, $injector) {
|
|
150
150
|
scope.$apply(() => {
|
|
@@ -175,7 +175,7 @@ export class Angular {
|
|
|
175
175
|
*
|
|
176
176
|
* @param {any[]} modules
|
|
177
177
|
* @param {boolean?} strictDi
|
|
178
|
-
* @returns {import("./
|
|
178
|
+
* @returns {import("./core/di/internal-injector").InjectorService}
|
|
179
179
|
*/
|
|
180
180
|
injector(modules, strictDi) {
|
|
181
181
|
return createInjector(modules, strictDi);
|
|
@@ -267,7 +267,7 @@ export class Angular {
|
|
|
267
267
|
* @param {string} name The name of the module to create or retrieve.
|
|
268
268
|
* @param {Array.<string>} [requires] If specified then new module is being created. If
|
|
269
269
|
* unspecified then the module is being retrieved for further configuration.
|
|
270
|
-
* @param {Function} [configFn] Optional configuration function for the module. Same as
|
|
270
|
+
* @param {Array<any>|Function} [configFn] Optional configuration function for the module. Same as
|
|
271
271
|
* {@link import('./types').Module#config Module#config()}.
|
|
272
272
|
* @returns {NgModule} A newly registered module.
|
|
273
273
|
*/
|
|
@@ -284,7 +284,11 @@ export class Angular {
|
|
|
284
284
|
name,
|
|
285
285
|
);
|
|
286
286
|
}
|
|
287
|
-
const moduleInstance = new NgModule(
|
|
287
|
+
const moduleInstance = new NgModule(
|
|
288
|
+
name,
|
|
289
|
+
requires,
|
|
290
|
+
/** @type {Function} */ (configFn),
|
|
291
|
+
);
|
|
288
292
|
return moduleInstance;
|
|
289
293
|
});
|
|
290
294
|
}
|
package/src/public.js
CHANGED
|
@@ -59,7 +59,6 @@ import {
|
|
|
59
59
|
} from "./core/animate/animate";
|
|
60
60
|
import { BrowserProvider } from "./services/browser";
|
|
61
61
|
import { CoreAnimateCssProvider } from "./core/animate/animate-css";
|
|
62
|
-
import { CookieReaderProvider } from "./services/cookie-reader";
|
|
63
62
|
import {
|
|
64
63
|
AnimateAsyncRunFactoryProvider,
|
|
65
64
|
AnimateRunnerFactoryProvider,
|
|
@@ -79,10 +78,7 @@ import {
|
|
|
79
78
|
$HttpParamSerializerProvider,
|
|
80
79
|
$HttpParamSerializerJQLikeProvider,
|
|
81
80
|
} from "./services/http/http";
|
|
82
|
-
import {
|
|
83
|
-
$HttpBackendProvider,
|
|
84
|
-
$xhrFactoryProvider,
|
|
85
|
-
} from "./services/http-backend/http-backend";
|
|
81
|
+
import { $HttpBackendProvider } from "./services/http-backend/http-backend";
|
|
86
82
|
import { $LocationProvider } from "./core/location/location";
|
|
87
83
|
import { $LogProvider } from "./services/log";
|
|
88
84
|
import { $ParseProvider } from "./core/parser/parse";
|
|
@@ -192,7 +188,6 @@ export function publishExternalAPI(angular) {
|
|
|
192
188
|
$httpParamSerializer: $HttpParamSerializerProvider,
|
|
193
189
|
$httpParamSerializerJQLike: $HttpParamSerializerJQLikeProvider,
|
|
194
190
|
$httpBackend: $HttpBackendProvider,
|
|
195
|
-
$xhrFactory: $xhrFactoryProvider,
|
|
196
191
|
$location: $LocationProvider,
|
|
197
192
|
$log: $LogProvider,
|
|
198
193
|
$parse: $ParseProvider,
|
|
@@ -205,7 +200,6 @@ export function publishExternalAPI(angular) {
|
|
|
205
200
|
$templateCache: TemplateCacheProvider,
|
|
206
201
|
$templateRequest: TemplateRequestProvider,
|
|
207
202
|
$timeout: $TimeoutProvider,
|
|
208
|
-
$$cookieReader: CookieReaderProvider,
|
|
209
203
|
});
|
|
210
204
|
},
|
|
211
205
|
],
|
package/src/router/services.js
CHANGED
|
@@ -10,8 +10,16 @@
|
|
|
10
10
|
import { services } from "./common/coreservices";
|
|
11
11
|
import { unnestR } from "../shared/common";
|
|
12
12
|
import { trace } from "./common/trace";
|
|
13
|
+
import { annotate } from "../core/di/injector";
|
|
13
14
|
|
|
14
15
|
runBlock.$inject = ["$injector", "$q", "$stateRegistry", "$urlService"];
|
|
16
|
+
/**
|
|
17
|
+
*
|
|
18
|
+
* @param {import("../core/di/internal-injector").InjectorService} $injector
|
|
19
|
+
* @param {*} $q
|
|
20
|
+
* @param {*} $stateRegistry
|
|
21
|
+
* @param {*} $urlService
|
|
22
|
+
*/
|
|
15
23
|
export function runBlock($injector, $q, $stateRegistry, $urlService) {
|
|
16
24
|
services.$injector = $injector;
|
|
17
25
|
services.$q = $q;
|
|
@@ -32,10 +40,7 @@ export function runBlock($injector, $q, $stateRegistry, $urlService) {
|
|
|
32
40
|
.filter((x) => x.deps === "deferred")
|
|
33
41
|
.forEach(
|
|
34
42
|
(resolvable) =>
|
|
35
|
-
(resolvable.deps = $injector.
|
|
36
|
-
resolvable.resolveFn,
|
|
37
|
-
$injector.strictDi,
|
|
38
|
-
)),
|
|
43
|
+
(resolvable.deps = annotate(resolvable.resolveFn, $injector.strictDi)),
|
|
39
44
|
);
|
|
40
45
|
// Start listening for url changes
|
|
41
46
|
$urlService.listen();
|
|
@@ -11,14 +11,13 @@ import { stringify } from "../../shared/strings";
|
|
|
11
11
|
import { is, pattern, pipe, prop, val } from "../../shared/hof";
|
|
12
12
|
import { Resolvable } from "../resolve/resolvable";
|
|
13
13
|
import { services } from "../common/coreservices";
|
|
14
|
+
import { annotate } from "../../core/di/injector";
|
|
14
15
|
const parseUrl = (url) => {
|
|
15
16
|
if (!isString(url)) return false;
|
|
16
17
|
const root = url.charAt(0) === "^";
|
|
17
18
|
return { val: root ? url.substring(1) : url, root };
|
|
18
19
|
};
|
|
19
|
-
|
|
20
|
-
return state.name;
|
|
21
|
-
}
|
|
20
|
+
|
|
22
21
|
function selfBuilder(state) {
|
|
23
22
|
state.self.$$state = () => state;
|
|
24
23
|
return state.self;
|
|
@@ -145,14 +144,14 @@ export function resolvablesBuilder(state) {
|
|
|
145
144
|
policy: resolvePolicies[token],
|
|
146
145
|
}));
|
|
147
146
|
/** fetch DI annotations from a function or ng1-style array */
|
|
148
|
-
const
|
|
147
|
+
const annotateFn = (fn) => {
|
|
149
148
|
const $injector = services.$injector;
|
|
150
149
|
// ng1 doesn't have an $injector until runtime.
|
|
151
150
|
// If the $injector doesn't exist, use "deferred" literal as a
|
|
152
151
|
// marker indicating they should be annotated when runtime starts
|
|
153
152
|
return (
|
|
154
153
|
fn["$inject"] ||
|
|
155
|
-
($injector &&
|
|
154
|
+
($injector && annotate(fn, $injector.strictDi)) ||
|
|
156
155
|
"deferred"
|
|
157
156
|
);
|
|
158
157
|
};
|
|
@@ -207,7 +206,7 @@ export function resolvablesBuilder(state) {
|
|
|
207
206
|
const tuple2Resolvable = pattern([
|
|
208
207
|
[pipe(prop('val'), isString), (tuple) => new Resolvable(tuple.token, ((x) => x), [tuple.val], tuple.policy)],
|
|
209
208
|
[pipe(prop('val'), Array.isArray), (tuple) => new Resolvable(tuple.token, tail(tuple.val), tuple.val.slice(0, -1), tuple.policy)],
|
|
210
|
-
[pipe(prop('val'), isFunction), (tuple) => new Resolvable(tuple.token, tuple.val,
|
|
209
|
+
[pipe(prop('val'), isFunction), (tuple) => new Resolvable(tuple.token, tuple.val, annotateFn(tuple.val), tuple.policy)],
|
|
211
210
|
]);
|
|
212
211
|
// prettier-ignore
|
|
213
212
|
const item2Resolvable = pattern([
|
|
@@ -249,7 +248,7 @@ export class StateBuilder {
|
|
|
249
248
|
return matcher.find(self.parentName(state)) || root();
|
|
250
249
|
}
|
|
251
250
|
this.builders = {
|
|
252
|
-
name: [
|
|
251
|
+
name: [(state) => state.name],
|
|
253
252
|
self: [selfBuilder],
|
|
254
253
|
parent: [parentBuilder],
|
|
255
254
|
data: [dataBuilder],
|
|
@@ -50,6 +50,11 @@ export class StateRegistry {
|
|
|
50
50
|
|
|
51
51
|
$get = [
|
|
52
52
|
"$injector",
|
|
53
|
+
/**
|
|
54
|
+
*
|
|
55
|
+
* @param {import("../../core/di/internal-injector").InjectorService} $injector
|
|
56
|
+
* @returns
|
|
57
|
+
*/
|
|
53
58
|
($injector) => {
|
|
54
59
|
this.$injector = $injector;
|
|
55
60
|
this.builder.$injector = $injector;
|
|
@@ -5,6 +5,7 @@ import { services } from "../common/coreservices";
|
|
|
5
5
|
import { trace } from "../common/trace";
|
|
6
6
|
import { ResolveContext } from "../resolve/resolve-context";
|
|
7
7
|
import { Resolvable } from "../resolve/resolvable";
|
|
8
|
+
import { annotate } from "../../core/di/injector";
|
|
8
9
|
|
|
9
10
|
export function getNg1ViewConfigFactory() {
|
|
10
11
|
let templateFactory = null;
|
|
@@ -141,7 +142,7 @@ export class Ng1ViewConfig {
|
|
|
141
142
|
getController(context) {
|
|
142
143
|
const provider = this.viewDecl.controllerProvider;
|
|
143
144
|
if (!isInjectable(provider)) return this.viewDecl.controller;
|
|
144
|
-
const deps =
|
|
145
|
+
const deps = annotate(provider);
|
|
145
146
|
const providerFn = Array.isArray(provider) ? tail(provider) : provider;
|
|
146
147
|
const resolvable = new Resolvable("", providerFn, deps);
|
|
147
148
|
return resolvable.get(context);
|
|
@@ -3,6 +3,7 @@ import { services } from "./common/coreservices";
|
|
|
3
3
|
import { tail, unnestR } from "../shared/common";
|
|
4
4
|
import { Resolvable } from "./resolve/resolvable";
|
|
5
5
|
import { kebobString } from "../shared/strings";
|
|
6
|
+
import { annotate } from "../core/di/injector";
|
|
6
7
|
|
|
7
8
|
/**
|
|
8
9
|
* @typedef BindingTuple
|
|
@@ -26,11 +27,11 @@ export class TemplateFactory {
|
|
|
26
27
|
"$q",
|
|
27
28
|
"$injector",
|
|
28
29
|
/**
|
|
29
|
-
* @param {
|
|
30
|
-
* @param {
|
|
31
|
-
* @param {
|
|
32
|
-
* @param {
|
|
33
|
-
* @param {
|
|
30
|
+
* @param {any} $http
|
|
31
|
+
* @param {any} $templateCache
|
|
32
|
+
* @param {any} $templateRequest
|
|
33
|
+
* @param {any} $q
|
|
34
|
+
* @param {import("../core/di/internal-injector").InjectorService} $injector
|
|
34
35
|
* @returns
|
|
35
36
|
*/
|
|
36
37
|
($http, $templateCache, $templateRequest, $q, $injector) => {
|
|
@@ -58,9 +59,9 @@ export class TemplateFactory {
|
|
|
58
59
|
* The following properties are search in the specified order, and the first one
|
|
59
60
|
* that is defined is used to create the template:
|
|
60
61
|
*
|
|
61
|
-
* @param {
|
|
62
|
+
* @param {any} config
|
|
62
63
|
* @param {any} params Parameters to pass to the template function.
|
|
63
|
-
* @param {
|
|
64
|
+
* @param {import("./resolve/resolve-context").ResolveContext} context The resolve context associated with the template's view
|
|
64
65
|
*
|
|
65
66
|
* @return {string|object} The template html as a string, or a promise for
|
|
66
67
|
* that string,or `null` if no template is configured.
|
|
@@ -104,7 +105,7 @@ export class TemplateFactory {
|
|
|
104
105
|
* Creates a template from a string or a function returning a string.
|
|
105
106
|
*
|
|
106
107
|
* @param {string | Function} template html template as a string or function that returns an html template as a string.
|
|
107
|
-
* @param {
|
|
108
|
+
* @param {any} [params] Parameters to pass to the template function.
|
|
108
109
|
*
|
|
109
110
|
* @return {string|object} The template html as a string, or a promise for that
|
|
110
111
|
* string.
|
|
@@ -141,12 +142,12 @@ export class TemplateFactory {
|
|
|
141
142
|
*
|
|
142
143
|
* @param {import('../types').Injectable<any>} provider Function to invoke via `locals`
|
|
143
144
|
* @param {Function} injectFn a function used to invoke the template provider
|
|
144
|
-
* @param {
|
|
145
|
+
* @param {import("./resolve/resolve-context").ResolveContext} context
|
|
145
146
|
* @return {string|Promise.<string>} The template html as a string, or a promise
|
|
146
147
|
* for that string.
|
|
147
148
|
*/
|
|
148
149
|
fromProvider(provider, params, context) {
|
|
149
|
-
const deps =
|
|
150
|
+
const deps = annotate(provider);
|
|
150
151
|
const providerFn = Array.isArray(provider) ? tail(provider) : provider;
|
|
151
152
|
const resolvable = new Resolvable("", providerFn, deps);
|
|
152
153
|
return resolvable.get(context);
|
|
@@ -159,7 +160,7 @@ export class TemplateFactory {
|
|
|
159
160
|
* @return {string} The template html as a string: "<component-name input1='::$resolve.foo'></component-name>".
|
|
160
161
|
*/
|
|
161
162
|
fromComponentProvider(provider, params, context) {
|
|
162
|
-
const deps =
|
|
163
|
+
const deps = annotate(provider);
|
|
163
164
|
const providerFn = Array.isArray(provider) ? tail(provider) : provider;
|
|
164
165
|
const resolvable = new Resolvable("", providerFn, deps);
|
|
165
166
|
return resolvable.get(context);
|
|
@@ -172,8 +173,8 @@ export class TemplateFactory {
|
|
|
172
173
|
* It analyses the component's bindings, then constructs a template that instantiates the component.
|
|
173
174
|
* The template wires input and output bindings to resolves or from the parent component.
|
|
174
175
|
*
|
|
175
|
-
* @param {
|
|
176
|
-
* @param {
|
|
176
|
+
* @param {any} ngView {object} The parent ui-view (for binding outputs to callbacks)
|
|
177
|
+
* @param {import("./resolve/resolve-context").ResolveContext} context The ResolveContext (for binding outputs to callbacks returned from resolves)
|
|
177
178
|
* @param {string} component {string} Component's name in camel case.
|
|
178
179
|
* @param {any} [bindings] An object defining the component's bindings: {foo: '<'}
|
|
179
180
|
* @return {string} The template as a string: "<component-name input1='::$resolve.foo'></component-name>".
|
|
@@ -207,7 +208,7 @@ export class TemplateFactory {
|
|
|
207
208
|
if (type === "&") {
|
|
208
209
|
const res = context.getResolvable(resolveName);
|
|
209
210
|
const fn = res && res.data;
|
|
210
|
-
const args = (fn &&
|
|
211
|
+
const args = (fn && annotate(fn)) || [];
|
|
211
212
|
// account for array style injection, i.e., ['foo', function(foo) {}]
|
|
212
213
|
const arrayIdxStr = Array.isArray(fn) ? `[${fn.length - 1}]` : "";
|
|
213
214
|
return `${attrName}='$resolve.${resolveName}${arrayIdxStr}(${args.join(",")})'`;
|
|
@@ -159,11 +159,11 @@ export class UrlService {
|
|
|
159
159
|
* locationServices.url("/some/path?query=value#anchor", true);
|
|
160
160
|
* ```
|
|
161
161
|
*
|
|
162
|
-
* @param {string} newUrl The new value for the URL.
|
|
162
|
+
* @param {string} [newUrl] The new value for the URL.
|
|
163
163
|
* This url should reflect only the new internal [[path]], [[search]], and [[hash]] values.
|
|
164
164
|
* It should not include the protocol, site, port, or base path of an absolute HREF.
|
|
165
|
-
* @param {boolean} replace When true, replaces the current history entry (instead of appending it) with this new url
|
|
166
|
-
* @param {any} state The history's state object, i.e., pushState (if the LocationServices implementation supports it)
|
|
165
|
+
* @param {boolean} [replace] When true, replaces the current history entry (instead of appending it) with this new url
|
|
166
|
+
* @param {any} [state] The history's state object, i.e., pushState (if the LocationServices implementation supports it)
|
|
167
167
|
*
|
|
168
168
|
* @return the url (after potentially being processed)
|
|
169
169
|
*/
|
|
@@ -231,7 +231,7 @@ export class UrlService {
|
|
|
231
231
|
hash: this.hash(),
|
|
232
232
|
};
|
|
233
233
|
/**
|
|
234
|
-
* @type {
|
|
234
|
+
* @type {*}
|
|
235
235
|
*/
|
|
236
236
|
const best = this.match(url);
|
|
237
237
|
const applyResult = pattern([
|
|
@@ -18,8 +18,8 @@ export function AnchorScrollProvider() {
|
|
|
18
18
|
"$rootScope",
|
|
19
19
|
/**
|
|
20
20
|
*
|
|
21
|
-
* @param {
|
|
22
|
-
* @param {
|
|
21
|
+
* @param {*} $location
|
|
22
|
+
* @param {import('../core/scope/scope').Scope} $rootScope
|
|
23
23
|
* @returns
|
|
24
24
|
*/
|
|
25
25
|
function ($location, $rootScope) {
|
package/src/services/browser.js
CHANGED
|
@@ -291,8 +291,6 @@ export function Browser(taskTracker) {
|
|
|
291
291
|
}
|
|
292
292
|
|
|
293
293
|
/**
|
|
294
|
-
* @typedef {import('../types').ServiceProvider} angular.BrowserProvider
|
|
295
|
-
* @description
|
|
296
294
|
* This object has two goals:
|
|
297
295
|
*
|
|
298
296
|
* - hide all the global state in the browser caused by the window object
|
|
@@ -300,13 +298,8 @@ export function Browser(taskTracker) {
|
|
|
300
298
|
*
|
|
301
299
|
* Remove this in the future
|
|
302
300
|
*/
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
* @constructor
|
|
306
|
-
* @this {angular.BrowserProvider}
|
|
307
|
-
*/
|
|
308
|
-
export function BrowserProvider() {
|
|
309
|
-
this.$get = [
|
|
301
|
+
export class BrowserProvider {
|
|
302
|
+
$get = [
|
|
310
303
|
"$$taskTrackerFactory",
|
|
311
304
|
/**
|
|
312
305
|
* @param {import('../core/task-tracker-factory').TaskTracker} $$taskTrackerFactory
|