@angular-wave/angular.ts 0.0.66 → 0.0.68
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 +4 -4
- package/src/animations/animate-swap.js +3 -0
- package/src/core/compile/compile.js +3 -3
- package/src/core/controller/controller.js +0 -5
- package/src/core/di/injector.js +9 -12
- package/src/core/di/internal-injector.js +113 -60
- package/src/core/interval/interval-factory.js +8 -1
- package/src/core/interval/interval.js +30 -16
- package/src/core/location/location.js +473 -626
- package/src/core/location/location.md +114 -0
- package/src/core/location/location.spec.js +1 -76
- package/src/core/parser/parse.js +1 -12
- package/src/core/parser/parse.spec.js +96 -110
- package/src/core/q/q.js +63 -65
- package/src/core/sce/sce.js +1 -3
- package/src/core/scope/scope.js +2 -5
- package/src/core/timeout/timeout.js +110 -111
- package/src/core/url-utils/url-utils.js +5 -0
- package/src/directive/input/input.js +32 -726
- package/src/directive/input/input.md +706 -0
- package/src/directive/options/options.js +2 -156
- package/src/directive/options/options.md +179 -0
- package/src/directive/select/select.js +55 -126
- 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/exts/messages/messages.js +2 -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 +7 -3
- package/src/public.js +1 -7
- package/src/router/params/param.js +54 -54
- package/src/router/path/path-utils.js +1 -0
- package/src/router/state/state-builder.js +2 -4
- package/src/router/state/state-service.js +1 -1
- package/src/router/state-provider.js +1 -1
- package/src/router/template-factory.js +10 -10
- package/src/router/url/url-service.js +11 -4
- package/src/services/anchor-scroll.js +3 -5
- 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 +62 -587
- 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 +5 -70
- package/src/types.js +2 -4
- package/types/animations/animate-swap.d.ts +4 -7
- package/types/core/compile/compile.d.ts +6 -6
- package/types/core/controller/controller.d.ts +0 -5
- package/types/core/di/internal-injector.d.ts +73 -18
- package/types/core/exception-handler.d.ts +1 -1
- package/types/core/interval/interval-factory.d.ts +1 -1
- package/types/core/interval/interval.d.ts +4 -0
- package/types/core/location/location.d.ts +235 -166
- package/types/core/parser/parse.d.ts +1 -1
- package/types/core/q/q.d.ts +61 -40
- package/types/core/scope/scope.d.ts +5 -8
- package/types/core/timeout/timeout.d.ts +16 -26
- package/types/core/url-utils/url-utils.d.ts +4 -0
- 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/params/param.d.ts +11 -0
- package/types/router/state/state-builder.d.ts +1 -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 +15 -15
- package/types/router/url/url-service.d.ts +12 -12
- 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 +11 -11
- package/types/types.d.ts +1 -9
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "@angular-wave/angular.ts",
|
|
3
3
|
"description": "A modern, optimized and typesafe version of AngularJS",
|
|
4
4
|
"license": "MIT",
|
|
5
|
-
"version": "0.0.
|
|
5
|
+
"version": "0.0.68",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"main": "dist/angular-ts.esm.js",
|
|
8
8
|
"browser": "dist/angular-ts.umd.js",
|
|
@@ -14,10 +14,10 @@ export function $$AnimateJsProvider($animateProvider) {
|
|
|
14
14
|
"$injector",
|
|
15
15
|
"$$AnimateRunner",
|
|
16
16
|
/**
|
|
17
|
-
*
|
|
18
|
-
* @param {import("../core/di/internal-injector").InjectorService} $injector
|
|
19
|
-
* @param {*} $$AnimateRunner
|
|
20
|
-
* @returns
|
|
17
|
+
*
|
|
18
|
+
* @param {import("../core/di/internal-injector").InjectorService} $injector
|
|
19
|
+
* @param {*} $$AnimateRunner
|
|
20
|
+
* @returns
|
|
21
21
|
*/
|
|
22
22
|
function ($injector, $$AnimateRunner) {
|
|
23
23
|
const applyAnimationClasses = applyAnimationClassesFactory();
|
|
@@ -218,7 +218,7 @@ export function $CompileProvider($provide, $$sanitizeUriProvider) {
|
|
|
218
218
|
* are the factories.
|
|
219
219
|
* @param {Function|Array} directiveFactory An injectable directive factory function. See the
|
|
220
220
|
* {@link guide/directive directive guide} and the {@link $compile compile API} for more info.
|
|
221
|
-
* @returns {
|
|
221
|
+
* @returns {$CompileProvider} Self for chaining.
|
|
222
222
|
*/
|
|
223
223
|
this.directive = function registerDirective(name, directiveFactory) {
|
|
224
224
|
assertArg(name, "name");
|
|
@@ -442,7 +442,7 @@ export function $CompileProvider($provide, $$sanitizeUriProvider) {
|
|
|
442
442
|
* the absolute url is prefixed with `'unsafe:'` string and only then is it written into the DOM.
|
|
443
443
|
*
|
|
444
444
|
* @param {RegExp=} regexp New regexp to trust urls with.
|
|
445
|
-
* @returns {RegExp
|
|
445
|
+
* @returns {RegExp|$CompileProvider} Current RegExp if called without value or self for
|
|
446
446
|
* chaining otherwise.
|
|
447
447
|
*/
|
|
448
448
|
this.aHrefSanitizationTrustedUrlList = function (regexp) {
|
|
@@ -470,7 +470,7 @@ export function $CompileProvider($provide, $$sanitizeUriProvider) {
|
|
|
470
470
|
* the absolute url is prefixed with `'unsafe:'` string and only then is it written into the DOM.
|
|
471
471
|
*
|
|
472
472
|
* @param {RegExp=} regexp New regexp to trust urls with.
|
|
473
|
-
* @returns {RegExp
|
|
473
|
+
* @returns {RegExp|$CompileProvider} Current RegExp if called without value or self for
|
|
474
474
|
* chaining otherwise.
|
|
475
475
|
*/
|
|
476
476
|
this.imgSrcSanitizationTrustedUrlList = function (regexp) {
|
|
@@ -21,11 +21,6 @@ export function identifierForController(controller, ident) {
|
|
|
21
21
|
}
|
|
22
22
|
|
|
23
23
|
/**
|
|
24
|
-
* @ngdoc provider
|
|
25
|
-
* @name $controllerProvider
|
|
26
|
-
*
|
|
27
|
-
*
|
|
28
|
-
* @description
|
|
29
24
|
* The {@link ng.$controller $controller service} is used by AngularJS to create new
|
|
30
25
|
* controllers.
|
|
31
26
|
*
|
package/src/core/di/injector.js
CHANGED
|
@@ -51,22 +51,17 @@ export function createInjector(modulesToLoad, strictDi = false) {
|
|
|
51
51
|
strictDi,
|
|
52
52
|
));
|
|
53
53
|
|
|
54
|
-
const
|
|
55
|
-
const protoInstanceInjector = new InjectorService(
|
|
56
|
-
instanceCache,
|
|
57
|
-
strictDi,
|
|
58
|
-
providerInjector,
|
|
59
|
-
);
|
|
54
|
+
const protoInstanceInjector = new InjectorService(strictDi, providerInjector);
|
|
60
55
|
|
|
61
56
|
providerCache.$injectorProvider = {
|
|
62
57
|
// $injectionProvider return instance injector
|
|
63
58
|
$get: () => protoInstanceInjector,
|
|
64
59
|
};
|
|
60
|
+
|
|
65
61
|
let instanceInjector = protoInstanceInjector;
|
|
66
|
-
instanceInjector.modules = providerInjector.modules = {};
|
|
67
62
|
const runBlocks = loadModules(modulesToLoad);
|
|
68
63
|
instanceInjector = protoInstanceInjector.get(INJECTOR_LITERAL);
|
|
69
|
-
|
|
64
|
+
|
|
70
65
|
runBlocks.forEach((fn) => {
|
|
71
66
|
if (fn) instanceInjector.invoke(fn);
|
|
72
67
|
});
|
|
@@ -93,7 +88,9 @@ export function createInjector(modulesToLoad, strictDi = false) {
|
|
|
93
88
|
assertNotHasOwnProperty(name, "service");
|
|
94
89
|
let newProvider;
|
|
95
90
|
if (isFunction(provider) || Array.isArray(provider)) {
|
|
96
|
-
newProvider = providerInjector.instantiate(
|
|
91
|
+
newProvider = providerInjector.instantiate(
|
|
92
|
+
/** @type {Function} */ (provider),
|
|
93
|
+
);
|
|
97
94
|
} else {
|
|
98
95
|
newProvider = provider;
|
|
99
96
|
}
|
|
@@ -142,8 +139,8 @@ export function createInjector(modulesToLoad, strictDi = false) {
|
|
|
142
139
|
|
|
143
140
|
function constant(name, value) {
|
|
144
141
|
assertNotHasOwnProperty(name, "constant");
|
|
145
|
-
|
|
146
|
-
|
|
142
|
+
providerInjector.cache[name] = value;
|
|
143
|
+
protoInstanceInjector.cache[name] = value;
|
|
147
144
|
}
|
|
148
145
|
|
|
149
146
|
function decorator(serviceName, decorFn) {
|
|
@@ -178,7 +175,7 @@ export function createInjector(modulesToLoad, strictDi = false) {
|
|
|
178
175
|
try {
|
|
179
176
|
if (isString(module)) {
|
|
180
177
|
/** @type {import('./ng-module').NgModule} */
|
|
181
|
-
|
|
178
|
+
const moduleFn = window["angular"].module(module);
|
|
182
179
|
instanceInjector.modules[/** @type {string } */ (module)] = moduleFn;
|
|
183
180
|
runBlocks = runBlocks
|
|
184
181
|
.concat(loadModules(moduleFn.requires))
|
|
@@ -9,33 +9,26 @@ const STRIP_COMMENTS = /((\/\/.*$)|(\/\*[\s\S]*?\*\/))/gm;
|
|
|
9
9
|
const $injectorMinErr = minErr(INJECTOR_LITERAL);
|
|
10
10
|
|
|
11
11
|
const providerSuffix = "Provider";
|
|
12
|
-
const INSTANTIATING =
|
|
12
|
+
const INSTANTIATING = true;
|
|
13
13
|
|
|
14
|
-
|
|
14
|
+
class AbstractInjector {
|
|
15
15
|
/**
|
|
16
|
-
*
|
|
17
|
-
* @param {Object} cache
|
|
18
|
-
* @param {boolean} strictDi
|
|
16
|
+
* @param {boolean} strictDi - Indicates if strict dependency injection is enforced.
|
|
19
17
|
*/
|
|
20
|
-
constructor(
|
|
21
|
-
|
|
18
|
+
constructor(strictDi) {
|
|
19
|
+
/**
|
|
20
|
+
* @type {Object<String, Function>}
|
|
21
|
+
*/
|
|
22
|
+
this.cache = {};
|
|
23
|
+
/** @type {boolean} */
|
|
22
24
|
this.strictDi = strictDi;
|
|
23
25
|
this.path = [];
|
|
24
|
-
|
|
25
|
-
this.modules =
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
factory(caller) {
|
|
29
|
-
this.path.push(caller);
|
|
30
|
-
// prevents lookups to providers through get
|
|
31
|
-
throw $injectorMinErr(
|
|
32
|
-
"unpr",
|
|
33
|
-
"Unknown provider: {0}",
|
|
34
|
-
this.path.join(" <- "),
|
|
35
|
-
);
|
|
26
|
+
/** @type {Object.<string, import("../../types").Module>} */
|
|
27
|
+
this.modules = {};
|
|
36
28
|
}
|
|
37
29
|
|
|
38
30
|
/**
|
|
31
|
+
* Get a service by name.
|
|
39
32
|
*
|
|
40
33
|
* @param {String} serviceName
|
|
41
34
|
* @returns {any}
|
|
@@ -65,6 +58,14 @@ export class ProviderInjector {
|
|
|
65
58
|
return this.cache[serviceName];
|
|
66
59
|
}
|
|
67
60
|
|
|
61
|
+
/**
|
|
62
|
+
* Get the injection arguments for a function.
|
|
63
|
+
*
|
|
64
|
+
* @param {Function|Array} fn
|
|
65
|
+
* @param {Object} locals
|
|
66
|
+
* @param {String} serviceName
|
|
67
|
+
* @returns
|
|
68
|
+
*/
|
|
68
69
|
injectionArgs(fn, locals, serviceName) {
|
|
69
70
|
const args = [];
|
|
70
71
|
const $inject = annotate(fn, this.strictDi, serviceName);
|
|
@@ -87,81 +88,133 @@ export class ProviderInjector {
|
|
|
87
88
|
return args;
|
|
88
89
|
}
|
|
89
90
|
|
|
91
|
+
/**
|
|
92
|
+
* Invoke a function with optional context and locals.
|
|
93
|
+
*
|
|
94
|
+
* @param {Function|String|Array<any>} fn
|
|
95
|
+
* @param {*} [self]
|
|
96
|
+
* @param {Object} [locals]
|
|
97
|
+
* @param {String} [serviceName]
|
|
98
|
+
* @returns
|
|
99
|
+
*/
|
|
90
100
|
invoke(fn, self, locals, serviceName) {
|
|
91
101
|
if (typeof locals === "string") {
|
|
92
102
|
serviceName = locals;
|
|
93
103
|
locals = null;
|
|
94
104
|
}
|
|
95
105
|
|
|
96
|
-
const args = this.injectionArgs(
|
|
106
|
+
const args = this.injectionArgs(
|
|
107
|
+
/** @type {Function} */ (fn),
|
|
108
|
+
locals,
|
|
109
|
+
serviceName,
|
|
110
|
+
);
|
|
97
111
|
if (Array.isArray(fn)) {
|
|
98
112
|
fn = fn[fn.length - 1];
|
|
99
113
|
}
|
|
100
114
|
|
|
101
|
-
if (isClass(fn)) {
|
|
115
|
+
if (isClass(/** @type {String} */ (fn))) {
|
|
102
116
|
args.unshift(null);
|
|
103
117
|
return new (Function.prototype.bind.apply(fn, args))();
|
|
104
118
|
} else {
|
|
105
|
-
return fn.apply(self, args);
|
|
119
|
+
return /** @type {Function} */ (fn).apply(self, args);
|
|
106
120
|
}
|
|
107
121
|
}
|
|
108
122
|
|
|
109
|
-
|
|
110
|
-
|
|
123
|
+
/**
|
|
124
|
+
* Instantiate a type constructor with optional locals.
|
|
125
|
+
* @param {Function|Array} type
|
|
126
|
+
* @param {*} [locals]
|
|
127
|
+
* @param {String} [serviceName]
|
|
128
|
+
*/
|
|
129
|
+
instantiate(type, locals, serviceName) {
|
|
130
|
+
// Check if type is annotated and use just the given function at n-1 as parameter
|
|
111
131
|
// e.g. someModule.factory('greeter', ['$window', function(renamed$window) {}]);
|
|
112
|
-
const ctor = Array.isArray(
|
|
113
|
-
const args = this.injectionArgs(
|
|
132
|
+
const ctor = Array.isArray(type) ? type[type.length - 1] : type;
|
|
133
|
+
const args = this.injectionArgs(type, locals, serviceName);
|
|
114
134
|
// Empty object at position 0 is ignored for invocation with `new`, but required.
|
|
115
135
|
args.unshift(null);
|
|
116
136
|
return new (Function.prototype.bind.apply(ctor, args))();
|
|
117
137
|
}
|
|
118
138
|
|
|
119
139
|
/**
|
|
120
|
-
*
|
|
121
|
-
* @param {String} name
|
|
122
|
-
* @returns {boolean}
|
|
140
|
+
* @abstract
|
|
123
141
|
*/
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
142
|
+
loadNewModules() {}
|
|
143
|
+
|
|
144
|
+
/**
|
|
145
|
+
* @abstract
|
|
146
|
+
* @param {String} _serviceName
|
|
147
|
+
*/
|
|
148
|
+
factory(_serviceName) {
|
|
149
|
+
console.error(`Unhandled ${_serviceName}`);
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
/**
|
|
154
|
+
* Injector for providers
|
|
155
|
+
* @extends AbstractInjector
|
|
156
|
+
*/
|
|
157
|
+
export class ProviderInjector extends AbstractInjector {
|
|
158
|
+
/**
|
|
159
|
+
* @param {Object} cache
|
|
160
|
+
* @param {boolean} strictDi - Indicates if strict dependency injection is enforced.
|
|
161
|
+
*/
|
|
162
|
+
constructor(cache, strictDi) {
|
|
163
|
+
super(strictDi);
|
|
164
|
+
this.cache = cache;
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
/**
|
|
168
|
+
* Factory method for creating services.
|
|
169
|
+
* @param {String} caller - The name of the caller requesting the service.
|
|
170
|
+
* @throws {Error} If the provider is unknown.
|
|
171
|
+
*/
|
|
172
|
+
factory(caller) {
|
|
173
|
+
this.path.push(caller);
|
|
174
|
+
// prevents lookups to providers through get
|
|
175
|
+
throw $injectorMinErr(
|
|
176
|
+
"unpr",
|
|
177
|
+
"Unknown provider: {0}",
|
|
178
|
+
this.path.join(" <- "),
|
|
128
179
|
);
|
|
129
|
-
const hasCache = Object.prototype.hasOwnProperty.call(this.cache, name);
|
|
130
|
-
return hasProvider || hasCache;
|
|
131
180
|
}
|
|
132
181
|
}
|
|
133
182
|
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
constructor(cache, strictDi, providerInjector) {
|
|
147
|
-
super(cache, strictDi);
|
|
148
|
-
this.strictDi = strictDi;
|
|
183
|
+
/**
|
|
184
|
+
* Injector for factories and services
|
|
185
|
+
* @extends AbstractInjector
|
|
186
|
+
*/
|
|
187
|
+
export class InjectorService extends AbstractInjector {
|
|
188
|
+
/**
|
|
189
|
+
*
|
|
190
|
+
* @param {boolean} strictDi - Indicates if strict dependency injection is enforced.
|
|
191
|
+
* @param {ProviderInjector} providerInjector
|
|
192
|
+
*/
|
|
193
|
+
constructor(strictDi, providerInjector) {
|
|
194
|
+
super(strictDi);
|
|
149
195
|
this.providerInjector = providerInjector;
|
|
150
|
-
this.
|
|
151
|
-
this.modules = undefined;
|
|
196
|
+
this.modules = this.providerInjector.modules;
|
|
152
197
|
}
|
|
153
198
|
|
|
154
|
-
factory(serviceName
|
|
155
|
-
const provider = this.providerInjector.get(
|
|
156
|
-
serviceName + providerSuffix,
|
|
157
|
-
caller,
|
|
158
|
-
);
|
|
199
|
+
factory(serviceName) {
|
|
200
|
+
const provider = this.providerInjector.get(serviceName + providerSuffix);
|
|
159
201
|
const res = this.invoke(provider.$get, provider, undefined, serviceName);
|
|
160
202
|
return res;
|
|
161
203
|
}
|
|
162
204
|
|
|
163
|
-
|
|
164
|
-
|
|
205
|
+
/**
|
|
206
|
+
*
|
|
207
|
+
* @param {String} name
|
|
208
|
+
* @returns {boolean}
|
|
209
|
+
*/
|
|
210
|
+
has(name) {
|
|
211
|
+
const hasProvider = Object.prototype.hasOwnProperty.call(
|
|
212
|
+
this.providerInjector.cache,
|
|
213
|
+
name + providerSuffix,
|
|
214
|
+
);
|
|
215
|
+
const hasCache = Object.prototype.hasOwnProperty.call(this.cache, name);
|
|
216
|
+
return hasProvider || hasCache;
|
|
217
|
+
}
|
|
165
218
|
}
|
|
166
219
|
|
|
167
220
|
// Helpers
|
|
@@ -215,7 +268,7 @@ function annotate(fn, strictDi, name) {
|
|
|
215
268
|
}
|
|
216
269
|
argDecl = extractArgs(/** @type {String} */ (fn));
|
|
217
270
|
argDecl[1].split(FN_ARG_SPLIT).forEach(function (arg) {
|
|
218
|
-
arg.replace(FN_ARG, function (
|
|
271
|
+
arg.replace(FN_ARG, function (_all, _underscore, name) {
|
|
219
272
|
$inject.push(name);
|
|
220
273
|
});
|
|
221
274
|
});
|
|
@@ -6,7 +6,14 @@ export function $$IntervalFactoryProvider() {
|
|
|
6
6
|
"$q",
|
|
7
7
|
"$$q",
|
|
8
8
|
"$rootScope",
|
|
9
|
-
|
|
9
|
+
/**
|
|
10
|
+
*
|
|
11
|
+
* @param {import('../../services/browser').Browser} $browser
|
|
12
|
+
* @param {*} $q
|
|
13
|
+
* @param {*} $$q
|
|
14
|
+
* @param {import('../scope/scope').Scope} $rootScope
|
|
15
|
+
* @returns
|
|
16
|
+
*/
|
|
10
17
|
function ($browser, $q, $$q, $rootScope) {
|
|
11
18
|
return function intervalFactory(setIntervalFn, clearIntervalFn) {
|
|
12
19
|
return function intervalFn(fn, delay, count, invokeApply) {
|
|
@@ -3,32 +3,47 @@ import { minErr } from "../../shared/utils";
|
|
|
3
3
|
|
|
4
4
|
const $intervalMinErr = minErr("$interval");
|
|
5
5
|
|
|
6
|
+
/**
|
|
7
|
+
* @typedef {number} IntervalId
|
|
8
|
+
* Interval ID which uniquely identifies the interval and can be used to cancel it
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* @type {Map<IntervalId, import("../q/q").Deferred<any>>}
|
|
13
|
+
*/
|
|
14
|
+
const intervals = new Map();
|
|
15
|
+
|
|
6
16
|
export function $IntervalProvider() {
|
|
7
17
|
this.$get = [
|
|
8
18
|
"$$intervalFactory",
|
|
9
19
|
// TODO Add type
|
|
10
20
|
function ($$intervalFactory) {
|
|
11
|
-
|
|
12
|
-
|
|
21
|
+
/**
|
|
22
|
+
* @param {TimerHandler} tick
|
|
23
|
+
* @param {number} delay
|
|
24
|
+
* @param {import("../q/q").Deferred<any>} deferred
|
|
25
|
+
* @returns {IntervalId} - This method returns an interval ID which uniquely identifies the interval
|
|
26
|
+
*/
|
|
27
|
+
function setIntervalFn(tick, delay, deferred) {
|
|
13
28
|
const id = window.setInterval(tick, delay);
|
|
14
|
-
intervals
|
|
29
|
+
intervals.set(id, deferred);
|
|
15
30
|
return id;
|
|
16
|
-
}
|
|
17
|
-
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
/**s
|
|
34
|
+
* @param {IntervalId} id
|
|
35
|
+
*/
|
|
36
|
+
function clearIntervalFn(id) {
|
|
18
37
|
window.clearInterval(id);
|
|
19
|
-
delete
|
|
20
|
-
}
|
|
38
|
+
intervals.delete(id);
|
|
39
|
+
}
|
|
21
40
|
|
|
22
41
|
const interval = $$intervalFactory(setIntervalFn, clearIntervalFn);
|
|
23
42
|
|
|
24
43
|
/**
|
|
25
|
-
* @ngdoc method
|
|
26
|
-
* @name $interval#cancel
|
|
27
|
-
*
|
|
28
|
-
* @description
|
|
29
44
|
* Cancels a task associated with the `promise`.
|
|
30
45
|
*
|
|
31
|
-
* @param {
|
|
46
|
+
* @param {!import("../q/q").QPromise<any>} promise returned by the `$interval` function.
|
|
32
47
|
* @returns {boolean} Returns `true` if the task was successfully canceled.
|
|
33
48
|
*/
|
|
34
49
|
interval.cancel = function (promise) {
|
|
@@ -41,13 +56,12 @@ export function $IntervalProvider() {
|
|
|
41
56
|
);
|
|
42
57
|
}
|
|
43
58
|
|
|
44
|
-
if (
|
|
45
|
-
!Object.prototype.hasOwnProperty.call(intervals, promise.$$intervalId)
|
|
46
|
-
)
|
|
59
|
+
if (!intervals.has(promise.$$intervalId)) {
|
|
47
60
|
return false;
|
|
61
|
+
}
|
|
48
62
|
|
|
49
63
|
const id = promise.$$intervalId;
|
|
50
|
-
const deferred = intervals
|
|
64
|
+
const deferred = intervals.get(id);
|
|
51
65
|
|
|
52
66
|
// Interval cancels should not report an unhandled promise.
|
|
53
67
|
markQExceptionHandled(deferred.promise);
|