@angular-wave/angular.ts 0.0.39 → 0.0.40
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/Makefile +2 -0
- package/README.md +1 -1
- package/dist/angular-ts.esm.js +2 -2
- package/dist/angular-ts.umd.js +2 -1
- package/package.json +1 -1
- package/rollup.config.js +10 -5
- package/src/angular.spec.js +25 -26
- package/src/animations/animate-css-driver.js +3 -3
- package/src/animations/animate-queue.js +7 -7
- package/src/animations/animation.js +2 -2
- package/src/animations/shared.js +6 -6
- package/src/binding.spec.js +7 -7
- package/src/core/animate/animate.js +5 -5
- package/src/core/animate/animate.spec.js +31 -31
- package/src/core/cache/cache-factory.html +18 -0
- package/src/core/cache/{cache-factor.test.js → cache-factory.test.js} +1 -1
- package/src/core/compile/compile.js +31 -25
- package/src/core/compile/compile.md +2 -2
- package/src/core/cookie-reader.spec.js +2 -2
- package/src/core/core.html +22 -0
- package/src/core/core.test.js +12 -0
- package/src/core/document.spec.js +4 -4
- package/src/core/exception-handler.js +30 -23
- package/src/core/interpolate/interpolate.js +7 -0
- package/src/core/{cache/cache-factor.html → location/location.html} +1 -1
- package/src/core/location/location.js +2 -2
- package/src/core/location/location.spec.js +17 -17
- package/src/core/location/location.test.js +12 -0
- package/src/core/on.spec.js +3 -3
- package/src/core/parser/parse.html +18 -0
- package/src/core/parser/parse.spec.js +1 -1
- package/src/core/parser/parse.test.js +12 -0
- package/src/core/prop.spec.js +3 -4
- package/src/core/pubsub/pubsub.html +18 -0
- package/src/core/pubsub/pubsub.spec.js +1 -1
- package/src/core/pubsub/pubsub.test.js +12 -0
- package/src/core/q/q.html +18 -0
- package/src/core/q/q.js +33 -0
- package/src/core/q/q.test.js +0 -0
- package/src/core/root-element.spec.js +4 -4
- package/src/core/sanitize/sanitize-uri.spec.js +1 -1
- package/src/core/sanitize/sanitize-uri.test.js +12 -0
- package/src/core/sanitize/sanitize.html +21 -0
- package/src/core/sce/sce.html +18 -0
- package/src/core/sce/sce.spec.js +2 -1
- package/src/core/sce/sce.test.js +12 -0
- package/src/core/scope/scope.html +18 -0
- package/src/core/scope/scope.js +1 -1
- package/src/core/scope/scope.spec.js +1 -1
- package/src/core/scope/scope.test.js +12 -0
- package/src/core/task-tracker-factory.js +9 -11
- package/src/core/timeout/timeout.html +18 -0
- package/src/core/timeout/timeout.js +9 -0
- package/src/core/timeout/timeout.spec.js +2 -2
- package/src/core/timeout/timout.test.js +12 -0
- package/src/core/url-utils/url-utils.html +18 -0
- package/src/core/url-utils/url-utils.spec.js +4 -2
- package/src/core/url-utils/url-utils.test.js +12 -0
- package/src/directive/attrs/attrs.spec.js +1 -2
- package/src/directive/attrs/boolean.spec.js +1 -2
- package/src/directive/attrs/element-style.spec.js +6 -7
- package/src/directive/attrs/src.spec.js +1 -2
- package/src/directive/bind/bind.spec.js +1 -2
- package/src/directive/class/class.spec.js +15 -16
- package/src/directive/cloak/cloak.spec.js +3 -4
- package/src/directive/controller/controller.spec.js +4 -5
- package/src/directive/events/click.spec.js +1 -2
- package/src/directive/events/event.spec.js +1 -1
- package/src/directive/events/events.js +7 -0
- package/src/directive/form/form.spec.js +17 -17
- package/src/directive/if/if.spec.js +2 -2
- package/src/directive/include/include.js +2 -2
- package/src/directive/include/include.spec.js +32 -32
- package/src/directive/init/init.spec.js +2 -3
- package/src/directive/input/input.spec.js +3 -3
- package/src/directive/list/list.spec.js +1 -2
- package/src/directive/model/model.js +13 -0
- package/src/directive/model/model.spec.js +4 -5
- package/src/directive/model-options/model-options.spec.js +3 -3
- package/src/directive/non-bindable/non-bindable.spec.js +1 -2
- package/src/directive/options/options.js +5 -5
- package/src/directive/options/options.spec.js +13 -13
- package/src/directive/ref/href.spec.js +1 -2
- package/src/directive/repeat/repeat.spec.js +12 -12
- package/src/directive/script/script.spec.js +2 -3
- package/src/directive/select/select.js +6 -6
- package/src/directive/select/select.spec.js +5 -5
- package/src/directive/show-hide/show-hide.spec.js +12 -13
- package/src/directive/style/style.spec.js +3 -4
- package/src/directive/switch/switch.spec.js +2 -3
- package/src/directive/validators/validators.spec.js +1 -1
- package/src/exts/aria/aria.spec.js +1 -2
- package/src/exts/messages/messages.spec.js +5 -5
- package/src/filters/filter.spec.js +5 -5
- package/src/filters/filters.html +21 -0
- package/src/filters/filters.spec.js +3 -3
- package/src/filters/filters.test.js +12 -0
- package/src/filters/limit-to.md +1 -1
- package/src/filters/limit-to.spec.js +4 -4
- package/src/filters/order-by.spec.js +2 -2
- package/src/index.js +186 -31
- package/src/loader.js +49 -11
- package/src/public.js +2 -3
- package/src/router/directives/state-directives.spec.js +90 -90
- package/src/router/directives/view-directive.js +2 -2
- package/src/router/directives/view-directive.spec.js +9 -9
- package/src/router/state/state.spec.js +2 -4
- package/src/router/template-factory.spec.js +2 -2
- package/src/router/transition/hook-registry.js +2 -2
- package/src/router/view/view.spec.js +1 -1
- package/src/services/browser.js +56 -39
- package/src/services/document.js +16 -13
- package/src/services/log.js +39 -43
- package/src/services/template-request.js +9 -0
- package/src/shared/common.js +0 -3
- package/src/shared/jqlite/jqlite.js +83 -89
- package/src/shared/jqlite/jqlite.spec.js +218 -222
- package/src/shared/strings.js +2 -2
- package/src/shared/test-utils.js +2 -2
- package/src/shared/utils.js +8 -11
- package/types/animations/shared.d.ts +1 -1
- package/types/core/exception-handler.d.ts +9 -42
- package/types/core/interpolate/interpolate.d.ts +1 -1
- package/types/core/q/q.d.ts +35 -1
- package/types/core/task-tracker-factory.d.ts +18 -11
- package/types/core/timeout/timeout.d.ts +10 -1
- package/types/directive/model/model.d.ts +28 -4
- package/types/index.d.ts +664 -79
- package/types/services/browser.d.ts +50 -20
- package/types/services/document.d.ts +13 -9
- package/types/services/log.d.ts +37 -34
- package/types/services/template-request.d.ts +1 -1
- package/types/shared/common.d.ts +0 -1
- package/types/shared/jqlite/jqlite.d.ts +6 -7
- package/types/shared/utils.d.ts +22 -22
- package/types-back/index.d.ts +1 -75
- /package/src/core/cache/{cache-factor.spec.js → cache-factory.spec.js} +0 -0
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
// }
|
|
7
7
|
// }
|
|
8
8
|
|
|
9
|
-
import { dealoc,
|
|
9
|
+
import { dealoc, JQLite } from "../../shared/jqlite/jqlite";
|
|
10
10
|
import { Angular } from "../../loader";
|
|
11
11
|
import { publishExternalAPI } from "../../public";
|
|
12
12
|
import { wait } from "../../shared/test-utils";
|
|
@@ -175,7 +175,7 @@ describe("ngView", () => {
|
|
|
175
175
|
$state = _$state_;
|
|
176
176
|
$q = _$q_;
|
|
177
177
|
$timeout = _$timeout_;
|
|
178
|
-
elem =
|
|
178
|
+
elem = JQLite("<div>");
|
|
179
179
|
$ngViewScroll = _$ngViewScroll_;
|
|
180
180
|
},
|
|
181
181
|
);
|
|
@@ -355,7 +355,7 @@ describe("ngView", () => {
|
|
|
355
355
|
ngViews = elem.find("ng-view");
|
|
356
356
|
|
|
357
357
|
while (index++ < ngViews.length) {
|
|
358
|
-
const ngView =
|
|
358
|
+
const ngView = JQLite(ngViews[index]);
|
|
359
359
|
if (ngView.text() === bState.template) target = ngView;
|
|
360
360
|
}
|
|
361
361
|
|
|
@@ -881,7 +881,7 @@ describe("UiView", () => {
|
|
|
881
881
|
$state = _$state_;
|
|
882
882
|
$q = _$q_;
|
|
883
883
|
$timeout = _$timeout_;
|
|
884
|
-
elem =
|
|
884
|
+
elem = JQLite("<div>");
|
|
885
885
|
$ngViewScroll = _$ngViewScroll_;
|
|
886
886
|
},
|
|
887
887
|
);
|
|
@@ -966,7 +966,7 @@ describe("ngView transclusion", () => {
|
|
|
966
966
|
scope = $rootScope.$new();
|
|
967
967
|
$compile = _$compile_;
|
|
968
968
|
$state = _$state_;
|
|
969
|
-
elem =
|
|
969
|
+
elem = JQLite("<div>");
|
|
970
970
|
},
|
|
971
971
|
);
|
|
972
972
|
});
|
|
@@ -1045,13 +1045,13 @@ describe("ngView controllers or onEnter handlers", () => {
|
|
|
1045
1045
|
scope = $rootScope.$new();
|
|
1046
1046
|
$compile = _$compile_;
|
|
1047
1047
|
$state = _$state_;
|
|
1048
|
-
elem =
|
|
1048
|
+
elem = JQLite("<div>");
|
|
1049
1049
|
},
|
|
1050
1050
|
);
|
|
1051
1051
|
});
|
|
1052
1052
|
|
|
1053
1053
|
it("should not go into an infinite loop when controller uses $state.go", async () => {
|
|
1054
|
-
el =
|
|
1054
|
+
el = JQLite("<div><ng-view></ng-view></div>");
|
|
1055
1055
|
template = $compile(el)($rootScope);
|
|
1056
1056
|
$rootScope.$digest();
|
|
1057
1057
|
|
|
@@ -1200,7 +1200,7 @@ describe("angular 1.5+ style .component()", () => {
|
|
|
1200
1200
|
$rootScope = _$rootScope_;
|
|
1201
1201
|
scope = $rootScope.$new();
|
|
1202
1202
|
log = "";
|
|
1203
|
-
el =
|
|
1203
|
+
el = JQLite("<div><ng-view></ng-view></div>");
|
|
1204
1204
|
svcs.$compile(el)(scope);
|
|
1205
1205
|
$templateCache = _$templateCache_;
|
|
1206
1206
|
},
|
|
@@ -1770,7 +1770,7 @@ describe("angular 1.5+ style .component()", () => {
|
|
|
1770
1770
|
},
|
|
1771
1771
|
};
|
|
1772
1772
|
|
|
1773
|
-
el =
|
|
1773
|
+
el = JQLite(
|
|
1774
1774
|
'<div><div ng-view="header"></div><div ng-view="content"</div>',
|
|
1775
1775
|
);
|
|
1776
1776
|
svcs.$compile(el)(scope);
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { dealoc,
|
|
1
|
+
import { dealoc, JQLite } from "../../shared/jqlite/jqlite";
|
|
2
2
|
import { Angular } from "../../loader";
|
|
3
3
|
import { publishExternalAPI } from "../../public";
|
|
4
4
|
import { isFunction } from "../../shared/utils";
|
|
@@ -6,8 +6,6 @@ import { wait } from "../../shared/test-utils";
|
|
|
6
6
|
|
|
7
7
|
describe("$state", () => {
|
|
8
8
|
let $injector, template, ctrlName, $provide, $compile, module, $stateRegistry;
|
|
9
|
-
|
|
10
|
-
/** @type {import("../../router/stateProvider").StateProvider} */
|
|
11
9
|
let $stateProvider;
|
|
12
10
|
|
|
13
11
|
function $get(what) {
|
|
@@ -101,7 +99,7 @@ describe("$state", () => {
|
|
|
101
99
|
describe("provider", () => {
|
|
102
100
|
beforeEach(() => {
|
|
103
101
|
dealoc(document.getElementById("dummy"));
|
|
104
|
-
|
|
102
|
+
// some tests are polluting the cache
|
|
105
103
|
window.angular = new Angular();
|
|
106
104
|
publishExternalAPI();
|
|
107
105
|
module = window.angular.module("defaultModule", ["ng.router"]);
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { dealoc,
|
|
1
|
+
import { dealoc, JQLite } from "../shared/jqlite/jqlite";
|
|
2
2
|
import { Angular } from "../loader";
|
|
3
3
|
import { publishExternalAPI } from "../public";
|
|
4
4
|
import { wait } from "../shared/test-utils";
|
|
@@ -124,7 +124,7 @@ describe("templateFactory", () => {
|
|
|
124
124
|
$compile = _$compile_;
|
|
125
125
|
},
|
|
126
126
|
);
|
|
127
|
-
el = $compile(
|
|
127
|
+
el = $compile(JQLite("<div><ng-view></ng-view></div>"))($scope.$new());
|
|
128
128
|
});
|
|
129
129
|
|
|
130
130
|
it("should not prefix the components dom element with anything", async () => {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { removeFrom, tail,
|
|
1
|
+
import { removeFrom, tail, mapObj } from "../../shared/common";
|
|
2
2
|
import { isString, isFunction } from "../../shared/utils";
|
|
3
3
|
import { Glob } from "../common/glob";
|
|
4
4
|
import { TransitionHookScope } from "./interface";
|
|
@@ -139,7 +139,7 @@ export class RegisteredHook {
|
|
|
139
139
|
matches(treeChanges, transition) {
|
|
140
140
|
const matches = this._getMatchingNodes(treeChanges, transition);
|
|
141
141
|
// Check if all the criteria matched the TreeChanges object
|
|
142
|
-
const allMatched = Object.values(matches).every(
|
|
142
|
+
const allMatched = Object.values(matches).every((x) => x);
|
|
143
143
|
return allMatched ? matches : null;
|
|
144
144
|
}
|
|
145
145
|
deregister() {
|
package/src/services/browser.js
CHANGED
|
@@ -1,34 +1,44 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { JQLite } from "../shared/jqlite/jqlite";
|
|
2
2
|
import { urlResolve } from "../core/url-utils/url-utils";
|
|
3
|
-
import {
|
|
3
|
+
import { isUndefined, equals } from "../shared/utils";
|
|
4
4
|
|
|
5
5
|
// This variable should be used *only* inside the cacheState function.
|
|
6
6
|
let lastCachedState = null;
|
|
7
7
|
|
|
8
|
+
/**
|
|
9
|
+
* Removes a trailing hash ('#') from the given URL if it exists.
|
|
10
|
+
*
|
|
11
|
+
* @param {string} url
|
|
12
|
+
* @returns {string}
|
|
13
|
+
*/
|
|
8
14
|
export function trimEmptyHash(url) {
|
|
9
15
|
return url.replace(/#$/, "");
|
|
10
16
|
}
|
|
11
17
|
|
|
18
|
+
/**
|
|
19
|
+
* @typedef {function(string, string|null): any} UrlChangeListener
|
|
20
|
+
*/
|
|
21
|
+
|
|
12
22
|
/**
|
|
13
23
|
* @name $browser
|
|
14
|
-
* @requires $log
|
|
15
24
|
* @description
|
|
16
25
|
* This object has two goals:
|
|
17
26
|
*
|
|
18
27
|
* - hide all the global state in the browser caused by the window object
|
|
19
28
|
* - abstract away all the browser specific features and inconsistencies
|
|
20
29
|
*
|
|
30
|
+
*
|
|
21
31
|
*/
|
|
22
32
|
|
|
23
33
|
/**
|
|
24
|
-
* @param {
|
|
34
|
+
* @param {import('../core/task-tracker-factory').TaskTracker} taskTracker
|
|
25
35
|
*/
|
|
26
|
-
export function Browser(
|
|
36
|
+
export function Browser(taskTracker) {
|
|
27
37
|
const self = this;
|
|
28
|
-
const { setTimeout } = window;
|
|
29
|
-
const { clearTimeout } = window;
|
|
30
38
|
const pendingDeferIds = {};
|
|
31
|
-
|
|
39
|
+
/** @type {Array<UrlChangeListener>} */
|
|
40
|
+
const urlChangeListeners = [];
|
|
41
|
+
let urlChangeInit = false;
|
|
32
42
|
|
|
33
43
|
/// ///////////////////////////////////////////////////////////
|
|
34
44
|
// Task-tracking API
|
|
@@ -48,11 +58,7 @@ export function Browser($log, $$taskTrackerFactory) {
|
|
|
48
58
|
let cachedState;
|
|
49
59
|
let lastHistoryState;
|
|
50
60
|
let lastBrowserUrl = window.location.href;
|
|
51
|
-
const baseElement =
|
|
52
|
-
let pendingLocation = null;
|
|
53
|
-
const getCurrentState = function getCurrentState() {
|
|
54
|
-
return history.state;
|
|
55
|
-
};
|
|
61
|
+
const baseElement = JQLite(Array.from(document.getElementsByTagName("base")));
|
|
56
62
|
|
|
57
63
|
cacheState();
|
|
58
64
|
|
|
@@ -73,7 +79,7 @@ export function Browser($log, $$taskTrackerFactory) {
|
|
|
73
79
|
* NOTE: this api is intended for use only by the `$location` service. Please use the
|
|
74
80
|
* {@link ng.$location $location service} to change url.
|
|
75
81
|
*
|
|
76
|
-
* @param {string} url New url (when used as setter)
|
|
82
|
+
* @param {string=} url New url (when used as setter)
|
|
77
83
|
* @param {boolean=} replace Should new url replace current history record?
|
|
78
84
|
* @param {object=} state State object to use with `pushState`/`replaceState`
|
|
79
85
|
*/
|
|
@@ -87,15 +93,13 @@ export function Browser($log, $$taskTrackerFactory) {
|
|
|
87
93
|
|
|
88
94
|
// setter
|
|
89
95
|
if (url) {
|
|
90
|
-
const sameState = lastHistoryState === state;
|
|
91
|
-
|
|
92
96
|
// Normalize the inputted URL
|
|
93
97
|
url = urlResolve(url).href;
|
|
94
98
|
|
|
95
99
|
// Don't change anything if previous and current URLs and states match. This also prevents
|
|
96
100
|
// IE<10 from getting into redirect loop when in LocationHashbangInHtml5Url mode.
|
|
97
101
|
// See https://github.com/angular/angular.js/commit/ffb2701
|
|
98
|
-
if (lastBrowserUrl === url &&
|
|
102
|
+
if (lastBrowserUrl === url && lastHistoryState === state) {
|
|
99
103
|
return self;
|
|
100
104
|
}
|
|
101
105
|
// const sameBase =
|
|
@@ -110,7 +114,7 @@ export function Browser($log, $$taskTrackerFactory) {
|
|
|
110
114
|
// - pendingLocation is needed as browsers don't allow to read out
|
|
111
115
|
// the new location.href if a reload happened or if there is a bug like in iOS 9 (see
|
|
112
116
|
// https://openradar.appspot.com/22186109).
|
|
113
|
-
return trimEmptyHash(
|
|
117
|
+
return trimEmptyHash(window.location.href);
|
|
114
118
|
};
|
|
115
119
|
|
|
116
120
|
/**
|
|
@@ -127,17 +131,13 @@ export function Browser($log, $$taskTrackerFactory) {
|
|
|
127
131
|
return cachedState;
|
|
128
132
|
};
|
|
129
133
|
|
|
130
|
-
const urlChangeListeners = [];
|
|
131
|
-
let urlChangeInit = false;
|
|
132
|
-
|
|
133
134
|
function cacheStateAndFireUrlChange() {
|
|
134
|
-
pendingLocation = null;
|
|
135
135
|
fireStateOrUrlChange();
|
|
136
136
|
}
|
|
137
137
|
|
|
138
138
|
function cacheState() {
|
|
139
139
|
// This should be the only place in $browser where `history.state` is read.
|
|
140
|
-
cachedState =
|
|
140
|
+
cachedState = history.state;
|
|
141
141
|
cachedState = isUndefined(cachedState) ? null : cachedState;
|
|
142
142
|
|
|
143
143
|
// Prevent callbacks fo fire twice if both hashchange & popstate were fired.
|
|
@@ -156,11 +156,10 @@ export function Browser($log, $$taskTrackerFactory) {
|
|
|
156
156
|
if (lastBrowserUrl === self.url() && prevLastHistoryState === cachedState) {
|
|
157
157
|
return;
|
|
158
158
|
}
|
|
159
|
-
|
|
160
|
-
lastBrowserUrl = self.url();
|
|
159
|
+
lastBrowserUrl = /** @type {string} */ (self.url());
|
|
161
160
|
lastHistoryState = cachedState;
|
|
162
|
-
forEach(
|
|
163
|
-
listener(
|
|
161
|
+
urlChangeListeners.forEach((listener) => {
|
|
162
|
+
listener(trimEmptyHash(window.location.href), cachedState);
|
|
164
163
|
});
|
|
165
164
|
}
|
|
166
165
|
|
|
@@ -182,8 +181,8 @@ export function Browser($log, $$taskTrackerFactory) {
|
|
|
182
181
|
* NOTE: this api is intended for use only by the $location service. Please use the
|
|
183
182
|
* {@link ng.$location $location service} to monitor url changes in AngularJS apps.
|
|
184
183
|
*
|
|
185
|
-
* @param {
|
|
186
|
-
* @return {
|
|
184
|
+
* @param {UrlChangeListener} callback Listener function to be called when url changes.
|
|
185
|
+
* @return {UrlChangeListener} Returns the registered listener fn - handy if the fn is anonymous.
|
|
187
186
|
*/
|
|
188
187
|
self.onUrlChange = function (callback) {
|
|
189
188
|
// TODO(vojta): refactor to use node's syntax for events
|
|
@@ -193,9 +192,9 @@ export function Browser($log, $$taskTrackerFactory) {
|
|
|
193
192
|
// changed by push/replaceState
|
|
194
193
|
|
|
195
194
|
// html5 history api - popstate event
|
|
196
|
-
|
|
195
|
+
JQLite(window).on("popstate", cacheStateAndFireUrlChange);
|
|
197
196
|
// hashchange event
|
|
198
|
-
|
|
197
|
+
JQLite(window).on("hashchange", cacheStateAndFireUrlChange);
|
|
199
198
|
|
|
200
199
|
urlChangeInit = true;
|
|
201
200
|
}
|
|
@@ -210,7 +209,7 @@ export function Browser($log, $$taskTrackerFactory) {
|
|
|
210
209
|
* NOTE: this api is intended for use only by $rootScope.
|
|
211
210
|
*/
|
|
212
211
|
self.$$applicationDestroyed = function () {
|
|
213
|
-
|
|
212
|
+
JQLite(window).off("hashchange popstate", cacheStateAndFireUrlChange);
|
|
214
213
|
};
|
|
215
214
|
|
|
216
215
|
/**
|
|
@@ -240,7 +239,7 @@ export function Browser($log, $$taskTrackerFactory) {
|
|
|
240
239
|
|
|
241
240
|
/**
|
|
242
241
|
* @name $browser#defer
|
|
243
|
-
* @param {function()} fn A function, who's execution should be deferred.
|
|
242
|
+
* @param {function():any} fn A function, who's execution should be deferred.
|
|
244
243
|
* @param {number=} [delay=0] Number of milliseconds to defer the function execution.
|
|
245
244
|
* @param {string=} [taskType=DEFAULT_TASK_TYPE] The type of task that is deferred.
|
|
246
245
|
* @returns {*} DeferId that can be used to cancel the task via `$browser.cancel()`.
|
|
@@ -260,7 +259,7 @@ export function Browser($log, $$taskTrackerFactory) {
|
|
|
260
259
|
taskType = taskType || taskTracker.DEFAULT_TASK_TYPE;
|
|
261
260
|
|
|
262
261
|
taskTracker.incTaskCount(taskType);
|
|
263
|
-
timeoutId = setTimeout(() => {
|
|
262
|
+
timeoutId = window.setTimeout(() => {
|
|
264
263
|
delete pendingDeferIds[timeoutId];
|
|
265
264
|
taskTracker.completeTask(fn, taskType);
|
|
266
265
|
}, delay);
|
|
@@ -275,7 +274,7 @@ export function Browser($log, $$taskTrackerFactory) {
|
|
|
275
274
|
* @description
|
|
276
275
|
* Cancels a deferred task identified with `deferId`.
|
|
277
276
|
*
|
|
278
|
-
* @param {
|
|
277
|
+
* @param {number} deferId Token returned by the `$browser.defer` function.
|
|
279
278
|
* @returns {boolean} Returns `true` if the task hasn't executed yet and was successfully
|
|
280
279
|
* canceled.
|
|
281
280
|
*/
|
|
@@ -283,7 +282,7 @@ export function Browser($log, $$taskTrackerFactory) {
|
|
|
283
282
|
if (Object.prototype.hasOwnProperty.call(pendingDeferIds, deferId)) {
|
|
284
283
|
const taskType = pendingDeferIds[deferId];
|
|
285
284
|
delete pendingDeferIds[deferId];
|
|
286
|
-
clearTimeout(deferId);
|
|
285
|
+
window.clearTimeout(deferId);
|
|
287
286
|
taskTracker.completeTask(() => {}, taskType);
|
|
288
287
|
return true;
|
|
289
288
|
}
|
|
@@ -291,12 +290,30 @@ export function Browser($log, $$taskTrackerFactory) {
|
|
|
291
290
|
};
|
|
292
291
|
}
|
|
293
292
|
|
|
293
|
+
/**
|
|
294
|
+
* @typedef {import('../index').angular.ServiceProvider} angular.BrowserProvider
|
|
295
|
+
* @description
|
|
296
|
+
* This object has two goals:
|
|
297
|
+
*
|
|
298
|
+
* - hide all the global state in the browser caused by the window object
|
|
299
|
+
* - abstract away all the browser specific features and inconsistencies
|
|
300
|
+
*
|
|
301
|
+
* Remove this in the future
|
|
302
|
+
*/
|
|
303
|
+
|
|
304
|
+
/**
|
|
305
|
+
* @constructor
|
|
306
|
+
* @this {angular.BrowserProvider}
|
|
307
|
+
*/
|
|
294
308
|
export function BrowserProvider() {
|
|
295
309
|
this.$get = [
|
|
296
|
-
"$log",
|
|
297
310
|
"$$taskTrackerFactory",
|
|
298
|
-
|
|
299
|
-
|
|
311
|
+
/**
|
|
312
|
+
* @param {import('../core/task-tracker-factory').TaskTracker} $$taskTrackerFactory
|
|
313
|
+
* @returns
|
|
314
|
+
*/
|
|
315
|
+
function ($$taskTrackerFactory) {
|
|
316
|
+
return new Browser($$taskTrackerFactory);
|
|
300
317
|
},
|
|
301
318
|
];
|
|
302
319
|
}
|
package/src/services/document.js
CHANGED
|
@@ -1,12 +1,9 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { JQLite } from "../shared/jqlite/jqlite";
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
|
-
* @
|
|
5
|
-
* @name $document
|
|
6
|
-
*
|
|
7
|
-
*
|
|
4
|
+
* @typedef {import('../index').angular.ServiceProvider} angular.DocumentProvider
|
|
8
5
|
* @description
|
|
9
|
-
* A {@link angular.element jQuery or
|
|
6
|
+
* A {@link angular.element jQuery or JQLite} wrapper for the browser's `window.document` object.
|
|
10
7
|
*
|
|
11
8
|
* @example
|
|
12
9
|
<example module="documentExample" name="document">
|
|
@@ -25,25 +22,31 @@ import { jqLite } from "../shared/jqlite/jqlite";
|
|
|
25
22
|
</file>
|
|
26
23
|
</example>
|
|
27
24
|
*/
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* @constructor
|
|
28
|
+
* @this {angular.DocumentProvider}
|
|
29
|
+
*/
|
|
28
30
|
export function $DocumentProvider() {
|
|
29
|
-
this.$get =
|
|
30
|
-
function () {
|
|
31
|
-
return jqLite(window.document);
|
|
32
|
-
},
|
|
33
|
-
];
|
|
31
|
+
this.$get = () => JQLite(window.document);
|
|
34
32
|
}
|
|
35
33
|
|
|
36
34
|
/**
|
|
37
35
|
* @private
|
|
38
36
|
*
|
|
39
|
-
|
|
37
|
+
* Listens for document visibility change and makes the current status accessible.
|
|
40
38
|
*/
|
|
41
39
|
export function $$IsDocumentHiddenProvider() {
|
|
42
40
|
this.$get = [
|
|
43
41
|
"$document",
|
|
44
42
|
"$rootScope",
|
|
43
|
+
/**
|
|
44
|
+
* @param {import("../shared/jqlite/jqlite").JQLite} $document
|
|
45
|
+
* @param {import("../core/scope/scope").Scope} $rootScope
|
|
46
|
+
* @returns
|
|
47
|
+
*/
|
|
45
48
|
function ($document, $rootScope) {
|
|
46
|
-
const doc = $document[0];
|
|
49
|
+
const doc = /** @type {typeof window.document} */ ($document[0]);
|
|
47
50
|
let hidden = doc && doc.hidden;
|
|
48
51
|
|
|
49
52
|
$document.on("visibilitychange", changeListener);
|
package/src/services/log.js
CHANGED
|
@@ -1,9 +1,44 @@
|
|
|
1
1
|
import { isError } from "../shared/utils";
|
|
2
2
|
|
|
3
|
+
///////////////////////////////////////////////////////////////////////////
|
|
4
|
+
// LogService
|
|
5
|
+
// see http://docs.angularjs.org/api/ng/service/$log
|
|
6
|
+
// see http://docs.angularjs.org/api/ng/provider/$logProvider
|
|
7
|
+
///////////////////////////////////////////////////////////////////////////
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* @typedef {(...args: any[]) => void} LogCall
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* @typedef {Object} angular.LogService
|
|
15
|
+
* @property {LogCall} debug - Log a debug messages
|
|
16
|
+
* @property {LogCall} error - Log a error message
|
|
17
|
+
* @property {LogCall} info - Log a info message
|
|
18
|
+
* @property {LogCall} log - Log a general message
|
|
19
|
+
* @property {LogCall} warn - Log a warning message
|
|
20
|
+
*/
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* @type {angular.LogService}
|
|
24
|
+
*/
|
|
25
|
+
export let LogService = {
|
|
26
|
+
debug: undefined,
|
|
27
|
+
error: undefined,
|
|
28
|
+
info: undefined,
|
|
29
|
+
log: undefined,
|
|
30
|
+
warn: undefined,
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* @typedef {import('../index').ServiceProvider} angular.LogProvider
|
|
35
|
+
* @property {function(): boolean} debugEnabled - Function to get the current debug state.
|
|
36
|
+
* @property {function(boolean): angular.LogProvider} debugEnabled - Function to enable or disable debug.
|
|
37
|
+
*/
|
|
38
|
+
|
|
3
39
|
/**
|
|
4
|
-
* @ngdoc provider
|
|
5
40
|
* @name $logProvider
|
|
6
|
-
* @type {
|
|
41
|
+
* @type {angular.LogProvider}
|
|
7
42
|
*
|
|
8
43
|
* @description
|
|
9
44
|
* Use the `$logProvider` to configure how the application logs messages
|
|
@@ -14,7 +49,6 @@ export class $LogProvider {
|
|
|
14
49
|
}
|
|
15
50
|
|
|
16
51
|
/**
|
|
17
|
-
* @ngdoc method
|
|
18
52
|
* @name $logProvider#debugEnabled
|
|
19
53
|
* @description
|
|
20
54
|
* @param {boolean=} flag enable or disable debug level messages
|
|
@@ -53,50 +87,11 @@ export class $LogProvider {
|
|
|
53
87
|
}
|
|
54
88
|
|
|
55
89
|
$get() {
|
|
56
|
-
|
|
57
|
-
/**
|
|
58
|
-
* @ngdoc method
|
|
59
|
-
* @name $log#log
|
|
60
|
-
*
|
|
61
|
-
* @description
|
|
62
|
-
* Write a log message
|
|
63
|
-
*/
|
|
90
|
+
LogService = {
|
|
64
91
|
log: this.consoleLog("log"),
|
|
65
|
-
|
|
66
|
-
/**
|
|
67
|
-
* @ngdoc method
|
|
68
|
-
* @name $log#info
|
|
69
|
-
*
|
|
70
|
-
* @description
|
|
71
|
-
* Write an information message
|
|
72
|
-
*/
|
|
73
92
|
info: this.consoleLog("info"),
|
|
74
|
-
|
|
75
|
-
/**
|
|
76
|
-
* @ngdoc method
|
|
77
|
-
* @name $log#warn
|
|
78
|
-
*
|
|
79
|
-
* @description
|
|
80
|
-
* Write a warning message
|
|
81
|
-
*/
|
|
82
93
|
warn: this.consoleLog("warn"),
|
|
83
|
-
|
|
84
|
-
/**
|
|
85
|
-
* @ngdoc method
|
|
86
|
-
* @name $log#error
|
|
87
|
-
*
|
|
88
|
-
* @description
|
|
89
|
-
* Write an error message
|
|
90
|
-
*/
|
|
91
94
|
error: this.consoleLog("error"),
|
|
92
|
-
|
|
93
|
-
/**
|
|
94
|
-
* @ngdoc method
|
|
95
|
-
* @name $log#debug
|
|
96
|
-
*
|
|
97
|
-
* @description
|
|
98
|
-
* Write a debug message
|
|
99
|
-
*/
|
|
100
95
|
debug: (() => {
|
|
101
96
|
const fn = this.consoleLog("debug");
|
|
102
97
|
return (...args) => {
|
|
@@ -106,5 +101,6 @@ export class $LogProvider {
|
|
|
106
101
|
};
|
|
107
102
|
})(),
|
|
108
103
|
};
|
|
104
|
+
return LogService;
|
|
109
105
|
}
|
|
110
106
|
}
|
|
@@ -72,6 +72,15 @@ export function TemplateRequestProvider() {
|
|
|
72
72
|
"$http",
|
|
73
73
|
"$q",
|
|
74
74
|
"$sce",
|
|
75
|
+
/**
|
|
76
|
+
*
|
|
77
|
+
* @param {import('../core/exception-handler').angular.ErrorHandler} $exceptionHandler
|
|
78
|
+
* @param {*} $templateCache
|
|
79
|
+
* @param {*} $http
|
|
80
|
+
* @param {*} $q
|
|
81
|
+
* @param {*} $sce
|
|
82
|
+
* @returns
|
|
83
|
+
*/
|
|
75
84
|
function ($exceptionHandler, $templateCache, $http, $q, $sce) {
|
|
76
85
|
function handleRequestFn(tpl, ignoreRequestError) {
|
|
77
86
|
handleRequestFn.totalPendingRequests++;
|
package/src/shared/common.js
CHANGED
|
@@ -15,9 +15,6 @@ export const fromJson = JSON.parse.bind(JSON);
|
|
|
15
15
|
export const toJson = JSON.stringify.bind(JSON);
|
|
16
16
|
export const forEach = _forEach;
|
|
17
17
|
export const equals = _equals;
|
|
18
|
-
export function identity(x) {
|
|
19
|
-
return x;
|
|
20
|
-
}
|
|
21
18
|
/**
|
|
22
19
|
* Builds proxy functions on the `to` object which pass through to the `from` object.
|
|
23
20
|
*
|