@angular-wave/angular.ts 0.1.3 → 0.1.4
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/angular.spec.js +0 -1
- package/src/animations/animate-css.html +1 -7
- package/src/animations/animate-css.js +4 -9
- package/src/core/compile/compile.js +1 -1
- package/src/core/location/location.js +3 -5
- package/src/core/task-tracker-factory.js +94 -78
- package/src/router/common/coreservices.js +1 -2
- package/src/router/resolve/resolve-context.js +3 -5
- package/src/router/state/state-service.js +1 -0
- package/src/services/anchor-scroll.js +9 -7
- package/src/services/browser.js +146 -194
- package/src/services/http/http.spec.js +1 -0
- package/src/services/http-backend/http-backend.js +3 -4
- package/src/shared/hof.js +0 -14
- package/types/core/task-tracker-factory.d.ts +44 -33
- package/types/loader.d.ts +1 -1
- package/types/router/url/url-service.d.ts +2 -2
- package/types/services/browser.d.ts +41 -103
- package/types/services/http-backend/http-backend.d.ts +1 -2
- package/types/shared/predicates.d.ts +1 -1
package/src/services/browser.js
CHANGED
|
@@ -1,9 +1,6 @@
|
|
|
1
1
|
import { JQLite } from "../shared/jqlite/jqlite";
|
|
2
2
|
import { urlResolve } from "../core/url-utils/url-utils";
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
// This variable should be used *only* inside the cacheState function.
|
|
6
|
-
let lastCachedState = null;
|
|
3
|
+
import { equals } from "../shared/utils";
|
|
7
4
|
|
|
8
5
|
/**
|
|
9
6
|
* Removes a trailing hash ('#') from the given URL if it exists.
|
|
@@ -20,266 +17,223 @@ export function trimEmptyHash(url) {
|
|
|
20
17
|
*/
|
|
21
18
|
|
|
22
19
|
/**
|
|
23
|
-
* @name $browser
|
|
24
|
-
* @description
|
|
25
20
|
* This object has two goals:
|
|
26
21
|
*
|
|
27
22
|
* - hide all the global state in the browser caused by the window object
|
|
28
23
|
* - abstract away all the browser specific features and inconsistencies
|
|
29
|
-
*
|
|
30
|
-
*
|
|
31
|
-
*/
|
|
32
|
-
|
|
33
|
-
/**
|
|
34
|
-
* @param {import('../core/task-tracker-factory').TaskTracker} taskTracker
|
|
35
24
|
*/
|
|
36
|
-
export
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
25
|
+
export class Browser {
|
|
26
|
+
/**
|
|
27
|
+
* @param {import('../core/task-tracker-factory').TaskTracker} taskTracker
|
|
28
|
+
*/
|
|
29
|
+
constructor(taskTracker) {
|
|
30
|
+
/**
|
|
31
|
+
* @type {import('../core/task-tracker-factory').TaskTracker} taskTracker
|
|
32
|
+
*/
|
|
33
|
+
this.taskTracker = taskTracker;
|
|
34
|
+
this.pendingDeferIds = {};
|
|
35
|
+
/** @type {Array<UrlChangeListener>} */
|
|
36
|
+
this.urlChangeListeners = [];
|
|
37
|
+
this.urlChangeInit = false;
|
|
38
|
+
|
|
39
|
+
/** @type {any} */
|
|
40
|
+
this.cachedState = null;
|
|
41
|
+
/** @type {any} */
|
|
42
|
+
this.lastHistoryState = null;
|
|
43
|
+
/** @type {string} */
|
|
44
|
+
this.lastBrowserUrl = window.location.href;
|
|
45
|
+
/** @type {JQLite} */
|
|
46
|
+
this.baseElement = JQLite(
|
|
47
|
+
Array.from(document.getElementsByTagName("base")),
|
|
48
|
+
);
|
|
49
|
+
|
|
50
|
+
// Task-tracking API
|
|
51
|
+
this.$$completeOutstandingRequest =
|
|
52
|
+
this.taskTracker.completeTask.bind(taskTracker);
|
|
53
|
+
this.$$incOutstandingRequestCount =
|
|
54
|
+
this.taskTracker.incTaskCount.bind(taskTracker);
|
|
55
|
+
this.notifyWhenNoOutstandingRequests =
|
|
56
|
+
this.taskTracker.notifyWhenNoPendingTasks.bind(taskTracker);
|
|
57
|
+
|
|
58
|
+
this.cacheState();
|
|
59
|
+
}
|
|
53
60
|
|
|
54
61
|
/// ///////////////////////////////////////////////////////////
|
|
55
62
|
// URL API
|
|
56
63
|
/// ///////////////////////////////////////////////////////////
|
|
57
64
|
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
let lastBrowserUrl = window.location.href;
|
|
61
|
-
const baseElement = JQLite(Array.from(document.getElementsByTagName("base")));
|
|
62
|
-
|
|
63
|
-
cacheState();
|
|
64
|
-
|
|
65
|
-
/**
|
|
66
|
-
* @name $browser#url
|
|
67
|
-
*
|
|
68
|
-
* @description
|
|
69
|
-
* GETTER:
|
|
70
|
-
* Without any argument, this method just returns current value of `location.href` (with a
|
|
71
|
-
* trailing `#` stripped of if the hash is empty).
|
|
72
|
-
*
|
|
73
|
-
* SETTER:
|
|
74
|
-
* With at least one argument, this method sets url to new value.
|
|
75
|
-
* If html5 history api supported, `pushState`/`replaceState` is used, otherwise
|
|
76
|
-
* `location.href`/`location.replace` is used.
|
|
77
|
-
* Returns its own instance to allow chaining.
|
|
78
|
-
*
|
|
79
|
-
* NOTE: this api is intended for use only by the `$location` service. Please use the
|
|
80
|
-
* {@link ng.$location $location service} to change url.
|
|
81
|
-
*
|
|
82
|
-
* @param {string=} url New url (when used as setter)
|
|
83
|
-
* @param {boolean=} replace Should new url replace current history record?
|
|
84
|
-
* @param {object=} state State object to use with `pushState`/`replaceState`
|
|
85
|
-
*/
|
|
86
|
-
self.url = function (url, replace, state) {
|
|
87
|
-
// In modern browsers `history.state` is `null` by default; treating it separately
|
|
88
|
-
// from `undefined` would cause `$browser.url('/foo')` to change `history.state`
|
|
89
|
-
// to undefined via `pushState`. Instead, let's change `undefined` to `null` here.
|
|
90
|
-
if (isUndefined(state)) {
|
|
65
|
+
url(url, state) {
|
|
66
|
+
if (state === undefined) {
|
|
91
67
|
state = null;
|
|
92
68
|
}
|
|
93
69
|
|
|
94
70
|
// setter
|
|
95
71
|
if (url) {
|
|
96
|
-
// Normalize the inputted URL
|
|
97
72
|
url = urlResolve(url).href;
|
|
98
73
|
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
// See https://github.com/angular/angular.js/commit/ffb2701
|
|
102
|
-
if (lastBrowserUrl === url && lastHistoryState === state) {
|
|
103
|
-
return self;
|
|
74
|
+
if (this.lastBrowserUrl === url && this.lastHistoryState === state) {
|
|
75
|
+
return this;
|
|
104
76
|
}
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
lastHistoryState = state;
|
|
77
|
+
|
|
78
|
+
this.lastBrowserUrl = url;
|
|
79
|
+
this.lastHistoryState = state;
|
|
109
80
|
history.pushState(state, "", url);
|
|
110
|
-
cacheState();
|
|
111
|
-
return
|
|
112
|
-
// getter
|
|
81
|
+
this.cacheState();
|
|
82
|
+
return this;
|
|
113
83
|
}
|
|
114
|
-
|
|
115
|
-
//
|
|
116
|
-
// https://openradar.appspot.com/22186109).
|
|
84
|
+
|
|
85
|
+
// getter
|
|
117
86
|
return trimEmptyHash(window.location.href);
|
|
118
|
-
}
|
|
87
|
+
}
|
|
119
88
|
|
|
120
89
|
/**
|
|
121
|
-
*
|
|
90
|
+
* Returns the cached state.
|
|
122
91
|
*
|
|
123
|
-
* @
|
|
124
|
-
* This method is a getter.
|
|
125
|
-
*
|
|
126
|
-
* Return history.state or null if history.state is undefined.
|
|
127
|
-
*
|
|
128
|
-
* @returns {object} state
|
|
92
|
+
* @returns {any} The cached state.
|
|
129
93
|
*/
|
|
130
|
-
|
|
131
|
-
return cachedState;
|
|
132
|
-
}
|
|
94
|
+
state() {
|
|
95
|
+
return this.cachedState;
|
|
96
|
+
}
|
|
133
97
|
|
|
134
|
-
|
|
135
|
-
|
|
98
|
+
/**
|
|
99
|
+
* Caches the current state and fires the URL change event.
|
|
100
|
+
*
|
|
101
|
+
* @private
|
|
102
|
+
*/
|
|
103
|
+
cacheStateAndFireUrlChange() {
|
|
104
|
+
this.fireStateOrUrlChange();
|
|
136
105
|
}
|
|
137
106
|
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
107
|
+
/**
|
|
108
|
+
* Caches the current state.
|
|
109
|
+
*
|
|
110
|
+
* @private
|
|
111
|
+
*/
|
|
112
|
+
cacheState() {
|
|
113
|
+
this.cachedState = history.state;
|
|
114
|
+
this.cachedState = this.cachedState === undefined ? null : this.cachedState;
|
|
142
115
|
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
cachedState = lastCachedState;
|
|
116
|
+
if (equals(this.cachedState, this.lastCachedState)) {
|
|
117
|
+
this.cachedState = this.lastCachedState;
|
|
146
118
|
}
|
|
147
119
|
|
|
148
|
-
lastCachedState = cachedState;
|
|
149
|
-
lastHistoryState = cachedState;
|
|
120
|
+
this.lastCachedState = this.cachedState;
|
|
121
|
+
this.lastHistoryState = this.cachedState;
|
|
150
122
|
}
|
|
151
123
|
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
124
|
+
/**
|
|
125
|
+
* Fires the state or URL change event.
|
|
126
|
+
*
|
|
127
|
+
* @private
|
|
128
|
+
*/
|
|
129
|
+
fireStateOrUrlChange() {
|
|
130
|
+
const prevLastHistoryState = this.lastHistoryState;
|
|
131
|
+
this.cacheState();
|
|
132
|
+
|
|
133
|
+
if (
|
|
134
|
+
this.lastBrowserUrl === this.url() &&
|
|
135
|
+
prevLastHistoryState === this.cachedState
|
|
136
|
+
) {
|
|
157
137
|
return;
|
|
158
138
|
}
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
139
|
+
|
|
140
|
+
this.lastBrowserUrl = /** @type {string} */ (this.url());
|
|
141
|
+
this.lastHistoryState = this.cachedState;
|
|
142
|
+
this.urlChangeListeners.forEach((listener) => {
|
|
143
|
+
listener(trimEmptyHash(window.location.href), this.cachedState);
|
|
163
144
|
});
|
|
164
145
|
}
|
|
165
146
|
|
|
166
147
|
/**
|
|
167
|
-
*
|
|
168
|
-
*
|
|
169
|
-
* It's only called when the url is changed from outside of AngularJS:
|
|
170
|
-
* - user types different url into address bar
|
|
171
|
-
* - user clicks on history (forward/back) button
|
|
172
|
-
* - user clicks on a link
|
|
173
|
-
*
|
|
174
|
-
* It's not called when url is changed by $browser.url() method
|
|
175
|
-
*
|
|
176
|
-
* The listener gets called with new url as parameter.
|
|
177
|
-
*
|
|
178
|
-
* NOTE: this api is intended for use only by the $location service. Please use the
|
|
179
|
-
* {@link ng.$location $location service} to monitor url changes in AngularJS apps.
|
|
148
|
+
* Registers a callback to be called when the URL changes.
|
|
180
149
|
*
|
|
181
|
-
* @param {UrlChangeListener} callback
|
|
182
|
-
* @
|
|
150
|
+
* @param {UrlChangeListener} callback - The callback function to register.
|
|
151
|
+
* @returns {UrlChangeListener} The registered callback function.
|
|
183
152
|
*/
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
urlChangeInit = true;
|
|
153
|
+
onUrlChange(callback) {
|
|
154
|
+
if (!this.urlChangeInit) {
|
|
155
|
+
window.addEventListener(
|
|
156
|
+
"popstate",
|
|
157
|
+
this.cacheStateAndFireUrlChange.bind(this),
|
|
158
|
+
);
|
|
159
|
+
window.addEventListener(
|
|
160
|
+
"hashchange",
|
|
161
|
+
this.cacheStateAndFireUrlChange.bind(this),
|
|
162
|
+
);
|
|
163
|
+
|
|
164
|
+
this.urlChangeInit = true;
|
|
197
165
|
}
|
|
198
166
|
|
|
199
|
-
urlChangeListeners.push(callback);
|
|
167
|
+
this.urlChangeListeners.push(callback);
|
|
200
168
|
return callback;
|
|
201
|
-
}
|
|
169
|
+
}
|
|
202
170
|
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
171
|
+
$$applicationDestroyed() {
|
|
172
|
+
window.removeEventListener(
|
|
173
|
+
"popstate",
|
|
174
|
+
this.cacheStateAndFireUrlChange.bind(this),
|
|
175
|
+
);
|
|
176
|
+
window.removeEventListener(
|
|
177
|
+
"hashchange",
|
|
178
|
+
this.cacheStateAndFireUrlChange.bind(this),
|
|
179
|
+
);
|
|
180
|
+
}
|
|
211
181
|
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
* as hashchange/popstate events fire in async.
|
|
216
|
-
*/
|
|
217
|
-
self.$$checkUrlChange = fireStateOrUrlChange;
|
|
182
|
+
$$checkUrlChange() {
|
|
183
|
+
this.fireStateOrUrlChange();
|
|
184
|
+
}
|
|
218
185
|
|
|
219
186
|
/// ///////////////////////////////////////////////////////////
|
|
220
187
|
// Misc API
|
|
221
188
|
/// ///////////////////////////////////////////////////////////
|
|
222
189
|
|
|
223
190
|
/**
|
|
224
|
-
* Returns
|
|
225
|
-
* (always relative - without domain)
|
|
191
|
+
* Returns the base href of the document.
|
|
226
192
|
*
|
|
227
|
-
* @returns {string} The
|
|
193
|
+
* @returns {string} The base href.
|
|
228
194
|
*/
|
|
229
|
-
|
|
230
|
-
const href = baseElement.attr("href");
|
|
195
|
+
baseHref() {
|
|
196
|
+
const href = this.baseElement.attr("href");
|
|
231
197
|
return href ? href.replace(/^(https?:)?\/\/[^/]*/, "") : "";
|
|
232
|
-
}
|
|
198
|
+
}
|
|
233
199
|
|
|
234
200
|
/**
|
|
235
|
-
*
|
|
236
|
-
* @param {number=} [delay=0] Number of milliseconds to defer the function execution.
|
|
237
|
-
* @param {string=} [taskType=DEFAULT_TASK_TYPE] The type of task that is deferred.
|
|
238
|
-
* @returns {number} DeferId that can be used to cancel the task via `$browser.cancel()`.
|
|
239
|
-
*
|
|
240
|
-
* Executes a fn asynchronously via `setTimeout(fn, delay)`.
|
|
241
|
-
*
|
|
242
|
-
* Unlike when calling `setTimeout` directly, in test this function is mocked and instead of using
|
|
243
|
-
* `setTimeout` in tests, the fns are queued in an array, which can be programmatically flushed
|
|
244
|
-
* via `$browser.defer.flush()`.
|
|
201
|
+
* Defers a function to be executed after a delay.
|
|
245
202
|
*
|
|
203
|
+
* @param {function(): any} fn - The function to defer.
|
|
204
|
+
* @param {number} [delay=0] - The delay in milliseconds before executing the function.
|
|
205
|
+
* @param {string} [taskType=this.taskTracker.DEFAULT_TASK_TYPE] - The type of task to track.
|
|
206
|
+
* @returns {number} The timeout ID associated with the deferred function.
|
|
246
207
|
*/
|
|
247
|
-
|
|
208
|
+
defer(fn, delay = 0, taskType = this.taskTracker.DEFAULT_TASK_TYPE) {
|
|
248
209
|
let timeoutId;
|
|
249
210
|
|
|
250
|
-
|
|
251
|
-
taskType = taskType || taskTracker.DEFAULT_TASK_TYPE;
|
|
252
|
-
|
|
253
|
-
taskTracker.incTaskCount(taskType);
|
|
211
|
+
this.taskTracker.incTaskCount(taskType);
|
|
254
212
|
timeoutId = window.setTimeout(() => {
|
|
255
|
-
delete pendingDeferIds[timeoutId];
|
|
256
|
-
taskTracker.completeTask(fn, taskType);
|
|
213
|
+
delete this.pendingDeferIds[timeoutId];
|
|
214
|
+
this.taskTracker.completeTask(fn, taskType);
|
|
257
215
|
}, delay);
|
|
258
|
-
pendingDeferIds[timeoutId] = taskType;
|
|
216
|
+
this.pendingDeferIds[timeoutId] = taskType;
|
|
259
217
|
|
|
260
218
|
return timeoutId;
|
|
261
|
-
}
|
|
219
|
+
}
|
|
262
220
|
|
|
263
221
|
/**
|
|
264
|
-
*
|
|
265
|
-
*
|
|
266
|
-
* @description
|
|
267
|
-
* Cancels a deferred task identified with `deferId`.
|
|
222
|
+
* Cancels a deferred function.
|
|
268
223
|
*
|
|
269
|
-
* @param {number} deferId
|
|
270
|
-
* @returns {boolean}
|
|
271
|
-
* canceled.
|
|
224
|
+
* @param {number} deferId - The ID of the deferred function to cancel.
|
|
225
|
+
* @returns {boolean} True if the function was successfully canceled, false otherwise.
|
|
272
226
|
*/
|
|
273
|
-
|
|
274
|
-
if (Object.prototype.hasOwnProperty.call(pendingDeferIds, deferId)) {
|
|
275
|
-
const taskType = pendingDeferIds[deferId];
|
|
276
|
-
delete pendingDeferIds[deferId];
|
|
227
|
+
cancel(deferId) {
|
|
228
|
+
if (Object.prototype.hasOwnProperty.call(this.pendingDeferIds, deferId)) {
|
|
229
|
+
const taskType = this.pendingDeferIds[deferId];
|
|
230
|
+
delete this.pendingDeferIds[deferId];
|
|
277
231
|
window.clearTimeout(deferId);
|
|
278
|
-
taskTracker.completeTask(() => {}, taskType);
|
|
232
|
+
this.taskTracker.completeTask(() => {}, taskType);
|
|
279
233
|
return true;
|
|
280
234
|
}
|
|
281
235
|
return false;
|
|
282
|
-
}
|
|
236
|
+
}
|
|
283
237
|
}
|
|
284
238
|
|
|
285
239
|
/**
|
|
@@ -297,8 +251,6 @@ export class BrowserProvider {
|
|
|
297
251
|
* @param {import('../core/task-tracker-factory').TaskTracker} $$taskTrackerFactory
|
|
298
252
|
* @returns
|
|
299
253
|
*/
|
|
300
|
-
|
|
301
|
-
return new Browser($$taskTrackerFactory);
|
|
302
|
-
},
|
|
254
|
+
($$taskTrackerFactory) => new Browser($$taskTrackerFactory),
|
|
303
255
|
];
|
|
304
256
|
}
|
|
@@ -22,17 +22,16 @@ export function $HttpBackendProvider() {
|
|
|
22
22
|
* @returns
|
|
23
23
|
*/
|
|
24
24
|
function ($browser) {
|
|
25
|
-
return createHttpBackend($browser
|
|
25
|
+
return createHttpBackend($browser);
|
|
26
26
|
},
|
|
27
27
|
];
|
|
28
28
|
}
|
|
29
29
|
|
|
30
30
|
/**
|
|
31
31
|
* @param {import('../browser').Browser} $browser
|
|
32
|
-
* @param {*} $browserDefer
|
|
33
32
|
* @returns
|
|
34
33
|
*/
|
|
35
|
-
export function createHttpBackend($browser
|
|
34
|
+
export function createHttpBackend($browser) {
|
|
36
35
|
// TODO(vojta): fix the signature
|
|
37
36
|
return function (
|
|
38
37
|
method,
|
|
@@ -146,7 +145,7 @@ export function createHttpBackend($browser, $browserDefer) {
|
|
|
146
145
|
// xhr.abort() abort (The xhr object is normally inaccessible, but
|
|
147
146
|
// can be exposed with the xhrFactory)
|
|
148
147
|
if (timeout > 0) {
|
|
149
|
-
var timeoutId = $
|
|
148
|
+
var timeoutId = $browser.defer(() => {
|
|
150
149
|
timeoutRequest("timeout");
|
|
151
150
|
}, timeout);
|
|
152
151
|
} else if (isPromiseLike(timeout)) {
|
package/src/shared/hof.js
CHANGED
|
@@ -1,10 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Higher order functions
|
|
3
|
-
*
|
|
4
|
-
* These utility functions are exported, but are subject to change without notice.
|
|
5
|
-
*
|
|
6
|
-
* @packageDocumentation
|
|
7
|
-
*/
|
|
8
1
|
/**
|
|
9
2
|
* Returns a new function for [Partial Application](https://en.wikipedia.org/wiki/Partial_application) of the original function.
|
|
10
3
|
*
|
|
@@ -105,13 +98,6 @@ export const propEq = curry((name, _val, obj) => obj && obj[name] === _val);
|
|
|
105
98
|
*/
|
|
106
99
|
export const parse = (name) => pipe.apply(null, name.split(".").map(prop));
|
|
107
100
|
|
|
108
|
-
/**
|
|
109
|
-
* Given two functions that return truthy or falsey values, returns a function that returns truthy
|
|
110
|
-
* if both functions return truthy for the given arguments
|
|
111
|
-
*/
|
|
112
|
-
export function and(fn1, fn2) {
|
|
113
|
-
return (...args) => fn1.apply(null, args) && fn2.apply(null, args);
|
|
114
|
-
}
|
|
115
101
|
/**
|
|
116
102
|
* Given two functions that return truthy or falsey values, returns a function that returns truthy
|
|
117
103
|
* if at least one of the functions returns truthy for the given arguments
|
|
@@ -1,57 +1,68 @@
|
|
|
1
|
-
export function $$TaskTrackerFactoryProvider(): void;
|
|
2
1
|
export class $$TaskTrackerFactoryProvider {
|
|
3
2
|
$get: (string | ((log: import("../services/log").LogService) => TaskTracker))[];
|
|
4
3
|
}
|
|
5
4
|
/**
|
|
6
|
-
*
|
|
5
|
+
* A factory function to create `TaskTracker` instances.
|
|
7
6
|
*
|
|
8
|
-
*
|
|
9
|
-
* @description
|
|
10
|
-
* A function to create `TaskTracker` instances.
|
|
11
|
-
*
|
|
12
|
-
* A `TaskTracker` can keep track of pending tasks (grouped by type) and can notify interested
|
|
7
|
+
* A `TaskTracker` tracks pending tasks (grouped by type) and notifies interested
|
|
13
8
|
* parties when all pending tasks (or tasks of a specific type) have been completed.
|
|
14
|
-
* @param {import('../services/log').LogService} log
|
|
15
9
|
*/
|
|
16
|
-
export function TaskTracker(log: import("../services/log").LogService): void;
|
|
17
10
|
export class TaskTracker {
|
|
18
11
|
/**
|
|
19
|
-
*
|
|
20
|
-
*
|
|
21
|
-
* @name $$taskTrackerFactory
|
|
22
|
-
* @description
|
|
23
|
-
* A function to create `TaskTracker` instances.
|
|
24
|
-
*
|
|
25
|
-
* A `TaskTracker` can keep track of pending tasks (grouped by type) and can notify interested
|
|
26
|
-
* parties when all pending tasks (or tasks of a specific type) have been completed.
|
|
27
|
-
* @param {import('../services/log').LogService} log
|
|
12
|
+
* @param {import('../services/log').LogService} log - The logging service.
|
|
28
13
|
*/
|
|
29
14
|
constructor(log: import("../services/log").LogService);
|
|
15
|
+
/** @private */
|
|
16
|
+
private log;
|
|
17
|
+
/** @private */
|
|
18
|
+
private taskCounts;
|
|
19
|
+
/** @private */
|
|
20
|
+
private taskCallbacks;
|
|
21
|
+
/**
|
|
22
|
+
* Special task types used for tracking all tasks and default tasks.
|
|
23
|
+
* @type {string}
|
|
24
|
+
*/
|
|
30
25
|
ALL_TASKS_TYPE: string;
|
|
26
|
+
/**
|
|
27
|
+
* Default task type.
|
|
28
|
+
* @type {string}
|
|
29
|
+
*/
|
|
31
30
|
DEFAULT_TASK_TYPE: string;
|
|
32
31
|
/**
|
|
33
|
-
*
|
|
34
|
-
* If the counter reaches 0, all corresponding
|
|
32
|
+
* Completes a task and decrements the associated task counter.
|
|
33
|
+
* If the counter reaches 0, all corresponding callbacks are executed.
|
|
34
|
+
*
|
|
35
|
+
* @param {Function} fn - The function to execute when completing the task.
|
|
36
|
+
* @param {string} [taskType=this.DEFAULT_TASK_TYPE] - The type of task being completed.
|
|
37
|
+
*/
|
|
38
|
+
completeTask(fn: Function, taskType?: string): void;
|
|
39
|
+
/**
|
|
40
|
+
* Increments the task count for the specified task type.
|
|
35
41
|
*
|
|
36
|
-
* @param {
|
|
37
|
-
* @param {string=} [taskType=DEFAULT_TASK_TYPE] - The type of task that is being completed.
|
|
42
|
+
* @param {string} [taskType=this.DEFAULT_TASK_TYPE] - The type of task whose count will be increased.
|
|
38
43
|
*/
|
|
39
|
-
|
|
44
|
+
incTaskCount(taskType?: string): void;
|
|
40
45
|
/**
|
|
41
|
-
*
|
|
42
|
-
* specified
|
|
46
|
+
* Registers a callback to be executed when all pending tasks of the specified type are completed.
|
|
47
|
+
* If there are no pending tasks of the specified type, the callback is executed immediately.
|
|
43
48
|
*
|
|
44
|
-
* @param {
|
|
49
|
+
* @param {Function} callback - The function to execute when no pending tasks remain.
|
|
50
|
+
* @param {string} [taskType=this.ALL_TASKS_TYPE] - The type of tasks to wait for completion.
|
|
45
51
|
*/
|
|
46
|
-
|
|
52
|
+
notifyWhenNoPendingTasks(callback: Function, taskType?: string): void;
|
|
47
53
|
/**
|
|
48
|
-
*
|
|
54
|
+
* Retrieves and removes the last registered callback from the queue.
|
|
49
55
|
*
|
|
50
|
-
*
|
|
51
|
-
*
|
|
56
|
+
* @private
|
|
57
|
+
* @returns {Function|undefined} The last callback function or undefined if none exist.
|
|
58
|
+
*/
|
|
59
|
+
private getLastCallback;
|
|
60
|
+
/**
|
|
61
|
+
* Retrieves and removes the last registered callback for the specified task type.
|
|
52
62
|
*
|
|
53
|
-
* @
|
|
54
|
-
* @param {string
|
|
63
|
+
* @private
|
|
64
|
+
* @param {string} taskType - The type of task for which the callback was registered.
|
|
65
|
+
* @returns {Function|undefined} The last callback function for the task type, or undefined if none exist.
|
|
55
66
|
*/
|
|
56
|
-
|
|
67
|
+
private getLastCallbackForType;
|
|
57
68
|
}
|
package/types/loader.d.ts
CHANGED
|
@@ -74,7 +74,6 @@ export class Angular {
|
|
|
74
74
|
* @returns {any} InjectorService - Returns the newly created injector for this app.
|
|
75
75
|
*/
|
|
76
76
|
bootstrap(element: string | Element | Document, modules?: Array<string | any>, config?: AngularBootstrapConfig): any;
|
|
77
|
-
resumeBootstrap(extraModules: any): any;
|
|
78
77
|
/**
|
|
79
78
|
*
|
|
80
79
|
* @param {any[]} modules
|
|
@@ -82,6 +81,7 @@ export class Angular {
|
|
|
82
81
|
* @returns {import("./core/di/internal-injector").InjectorService}
|
|
83
82
|
*/
|
|
84
83
|
injector(modules: any[], strictDi: boolean | null): import("./core/di/internal-injector").InjectorService;
|
|
84
|
+
resumeBootstrap(extraModules: any): any;
|
|
85
85
|
/**
|
|
86
86
|
* @param {Element|Document} element
|
|
87
87
|
*/
|
|
@@ -58,8 +58,8 @@ export class UrlService {
|
|
|
58
58
|
_urlListeners: any[];
|
|
59
59
|
$get: (string | (($location: import("../../core/location/location").Location, $browser: import("../../services/browser").Browser, $rootScope: import("../../core/scope/scope").Scope) => this))[];
|
|
60
60
|
html5Mode(): boolean;
|
|
61
|
-
baseHref():
|
|
62
|
-
_baseHref:
|
|
61
|
+
baseHref(): any;
|
|
62
|
+
_baseHref: any;
|
|
63
63
|
/**
|
|
64
64
|
* Gets the current url, or updates the url
|
|
65
65
|
*
|