@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.
Files changed (85) hide show
  1. package/dist/angular-ts.esm.js +2 -2
  2. package/dist/angular-ts.umd.js +2 -2
  3. package/package.json +1 -1
  4. package/src/animations/animate-js.js +4 -4
  5. package/src/animations/animate-swap.js +3 -0
  6. package/src/core/compile/compile.js +3 -3
  7. package/src/core/controller/controller.js +0 -5
  8. package/src/core/di/injector.js +9 -12
  9. package/src/core/di/internal-injector.js +113 -60
  10. package/src/core/interval/interval-factory.js +8 -1
  11. package/src/core/interval/interval.js +30 -16
  12. package/src/core/location/location.js +473 -626
  13. package/src/core/location/location.md +114 -0
  14. package/src/core/location/location.spec.js +1 -76
  15. package/src/core/parser/parse.js +1 -12
  16. package/src/core/parser/parse.spec.js +96 -110
  17. package/src/core/q/q.js +63 -65
  18. package/src/core/sce/sce.js +1 -3
  19. package/src/core/scope/scope.js +2 -5
  20. package/src/core/timeout/timeout.js +110 -111
  21. package/src/core/url-utils/url-utils.js +5 -0
  22. package/src/directive/input/input.js +32 -726
  23. package/src/directive/input/input.md +706 -0
  24. package/src/directive/options/options.js +2 -156
  25. package/src/directive/options/options.md +179 -0
  26. package/src/directive/select/select.js +55 -126
  27. package/src/directive/select/select.md +74 -0
  28. package/src/directive/show-hide/show-hide.js +13 -224
  29. package/src/directive/show-hide/show-hide.md +257 -0
  30. package/src/exts/messages/messages.js +2 -0
  31. package/src/filters/limit-to.spec.js +1 -1
  32. package/src/filters/order-by.spec.js +1 -1
  33. package/src/index.js +6 -2
  34. package/src/loader.js +7 -3
  35. package/src/public.js +1 -7
  36. package/src/router/params/param.js +54 -54
  37. package/src/router/path/path-utils.js +1 -0
  38. package/src/router/state/state-builder.js +2 -4
  39. package/src/router/state/state-service.js +1 -1
  40. package/src/router/state-provider.js +1 -1
  41. package/src/router/template-factory.js +10 -10
  42. package/src/router/url/url-service.js +11 -4
  43. package/src/services/anchor-scroll.js +3 -5
  44. package/src/services/browser.js +2 -9
  45. package/src/services/cache-factory.js +0 -67
  46. package/src/services/cache-factory.md +75 -0
  47. package/src/services/cookie-reader.js +36 -55
  48. package/src/services/http/http.js +62 -587
  49. package/src/services/http/http.md +413 -0
  50. package/src/services/http-backend/http-backend.js +19 -44
  51. package/src/services/template-request.js +1 -9
  52. package/src/shared/jqlite/jqlite.js +5 -70
  53. package/src/types.js +2 -4
  54. package/types/animations/animate-swap.d.ts +4 -7
  55. package/types/core/compile/compile.d.ts +6 -6
  56. package/types/core/controller/controller.d.ts +0 -5
  57. package/types/core/di/internal-injector.d.ts +73 -18
  58. package/types/core/exception-handler.d.ts +1 -1
  59. package/types/core/interval/interval-factory.d.ts +1 -1
  60. package/types/core/interval/interval.d.ts +4 -0
  61. package/types/core/location/location.d.ts +235 -166
  62. package/types/core/parser/parse.d.ts +1 -1
  63. package/types/core/q/q.d.ts +61 -40
  64. package/types/core/scope/scope.d.ts +5 -8
  65. package/types/core/timeout/timeout.d.ts +16 -26
  66. package/types/core/url-utils/url-utils.d.ts +4 -0
  67. package/types/directive/input/input.d.ts +19 -124
  68. package/types/directive/select/select.d.ts +7 -74
  69. package/types/directive/show-hide/show-hide.d.ts +11 -224
  70. package/types/loader.d.ts +4 -4
  71. package/types/router/params/param.d.ts +11 -0
  72. package/types/router/state/state-builder.d.ts +1 -2
  73. package/types/router/state/state-service.d.ts +2 -2
  74. package/types/router/state-provider.d.ts +2 -2
  75. package/types/router/template-factory.d.ts +15 -15
  76. package/types/router/url/url-service.d.ts +12 -12
  77. package/types/services/anchor-scroll.d.ts +1 -1
  78. package/types/services/browser.d.ts +0 -10
  79. package/types/services/cache-factory.d.ts +0 -67
  80. package/types/services/cookie-reader.d.ts +2 -10
  81. package/types/services/http/http.d.ts +53 -61
  82. package/types/services/http-backend/http-backend.d.ts +8 -31
  83. package/types/services/template-request.d.ts +1 -9
  84. package/types/shared/jqlite/jqlite.d.ts +11 -11
  85. package/types/types.d.ts +1 -9
package/src/core/q/q.js CHANGED
@@ -1,49 +1,43 @@
1
+ import {
2
+ forEach,
3
+ minErr,
4
+ isUndefined,
5
+ isFunction,
6
+ isObject,
7
+ isDefined,
8
+ isError,
9
+ toDebugString,
10
+ isPromiseLike,
11
+ } from "../../shared/utils";
12
+
1
13
  /**
2
14
  * @template T
3
- * @typedef {Object} angular.QPromise
15
+ * @typedef {Object} QPromise
4
16
  * @property {function(
5
17
  * ((value: T) => (PromiseLike<never>|PromiseLike<T>|T))|null,
6
18
  * ((reason: any) => (PromiseLike<never>|PromiseLike<T>|T))|null,
7
19
  * ((state: any) => any)
8
- * ): angular.QPromise<T|never>} then - Calls one of the success or error callbacks asynchronously as soon as the result is available.
20
+ * ): QPromise<T|never>} then - Calls one of the success or error callbacks asynchronously as soon as the result is available.
9
21
  * @property {function(
10
- * ((value: T) => (angular.QPromise<never>|angular.QPromise<T>|T))|null,
11
- * ((reason: any) => (angular.QPromise<never>|angular.QPromise<never>|never))|null,
22
+ * ((value: T) => (QPromise<never>|QPromise<T>|T))|null,
23
+ * ((reason: any) => (QPromise<never>|QPromise<never>|never))|null,
12
24
  * ((state: any) => any)
13
- * ): angular.QPromise<T|never>} then - Calls one of the success or error callbacks asynchronously as soon as the result is available.
14
- * @property {function(((reason: any) => (PromiseLike<never>|PromiseLike<T>|T))|null): angular.QPromise<T>|T} catch - Shorthand for promise.then(null, errorCallback).
15
- * @property {function(((reason: any) => (angular.QPromise<never>|angular.QPromise<T>|T))|null): angular.QPromise<T>|T} catch - Shorthand for promise.then(null, errorCallback).
16
- * @property {function(function(): void): angular.QPromise<T>} finally - Allows you to observe either the fulfillment or rejection of a promise, but to do so without modifying the final value.
25
+ * ): QPromise<T|never>} then - Calls one of the success or error callbacks asynchronously as soon as the result is available.
26
+ * @property {function(((reason: any) => (PromiseLike<never>|PromiseLike<T>|T))|null): QPromise<T>|T} catch - Shorthand for promise.then(null, errorCallback).
27
+ * @property {function(((reason: any) => (QPromise<never>|QPromise<T>|T))|null): QPromise<T>|T} catch - Shorthand for promise.then(null, errorCallback).
28
+ * @property {function(function(): void): QPromise<T>} finally - Allows you to observe either the fulfillment or rejection of a promise, but to do so without modifying the final value.
29
+ * @property {number} [$$intervalId] - Internal id set by the $interval service for callback notifications
17
30
  */
18
31
 
19
32
  /**
20
33
  *@template T
21
- * @typedef {Object} angular.Deferred
22
- * @property {function(T|angular.QPromise<T>): void} resolve - Resolves the promise with a value or another promise.
34
+ * @typedef {Object} Deferred
35
+ * @property {function(T|QPromise<T>): void} resolve - Resolves the promise with a value or another promise.
23
36
  * @property {function(any): void} reject - Rejects the promise with a reason.
24
37
  * @property {function(any): void} notify - Provides a progress notification.
25
- * @property {angular.QPromise<T>} promise - The promise associated with this deferred object.
38
+ * @property {QPromise<T>} promise - The promise associated with this deferred object.
26
39
  */
27
40
 
28
- import {
29
- forEach,
30
- minErr,
31
- isUndefined,
32
- isFunction,
33
- isObject,
34
- isDefined,
35
- isError,
36
- toDebugString,
37
- isPromiseLike,
38
- } from "../../shared/utils";
39
-
40
- /**
41
- * @ngdoc provider
42
- * @name $qProvider
43
- *
44
- *
45
- * @description
46
- */
47
41
  export function $QProvider() {
48
42
  let errorOnUnhandledRejections = true;
49
43
  this.$get = [
@@ -51,14 +45,16 @@ export function $QProvider() {
51
45
  "$exceptionHandler",
52
46
  /**
53
47
  *
54
- * @param {*} $rootScope
48
+ * @param {import('../scope/scope').Scope} $rootScope
55
49
  * @param {import('../exception-handler').ErrorHandler} $exceptionHandler
56
50
  * @returns
57
51
  */
58
52
  function ($rootScope, $exceptionHandler) {
59
53
  return qFactory(
60
54
  (callback) => {
61
- $rootScope.$evalAsync(callback);
55
+ $rootScope.$evalAsync(
56
+ /** @type {function(function):any} */ (callback),
57
+ );
62
58
  },
63
59
  $exceptionHandler,
64
60
  errorOnUnhandledRejections,
@@ -129,11 +125,6 @@ function qFactory(nextTick, exceptionHandler, errorOnUnhandledRejections) {
129
125
  const checkQueue = [];
130
126
 
131
127
  /**
132
- * @ngdoc method
133
- * @name ng.$q#defer
134
- * @kind function
135
- *
136
- * @description
137
128
  * Creates a `Deferred` object which represents a task which will finish in the future.
138
129
  *
139
130
  * @returns {Deferred} Returns a new instance of deferred.
@@ -156,38 +147,45 @@ function qFactory(nextTick, exceptionHandler, errorOnUnhandledRejections) {
156
147
  };
157
148
  }
158
149
 
159
- function QPromise() {
160
- this.$$state = { status: 0 };
161
- }
162
-
163
- QPromise.prototype.then = function (onFulfilled, onRejected, progressBack) {
164
- if (
165
- isUndefined(onFulfilled) &&
166
- isUndefined(onRejected) &&
167
- isUndefined(progressBack)
168
- ) {
169
- return this;
150
+ class QPromise {
151
+ constructor() {
152
+ this.$$state = { status: 0 };
170
153
  }
171
- const result = new QPromise();
172
-
173
- this.$$state.pending = this.$$state.pending || [];
174
- this.$$state.pending.push([result, onFulfilled, onRejected, progressBack]);
175
- if (this.$$state.status > 0) scheduleProcessQueue(this.$$state);
176
154
 
177
- return result;
178
- };
155
+ then(onFulfilled, onRejected, progressBack) {
156
+ if (
157
+ isUndefined(onFulfilled) &&
158
+ isUndefined(onRejected) &&
159
+ isUndefined(progressBack)
160
+ ) {
161
+ return this;
162
+ }
163
+ const result = new QPromise();
164
+
165
+ this.$$state.pending = this.$$state.pending || [];
166
+ this.$$state.pending.push([
167
+ result,
168
+ onFulfilled,
169
+ onRejected,
170
+ progressBack,
171
+ ]);
172
+ if (this.$$state.status > 0) scheduleProcessQueue(this.$$state);
173
+
174
+ return result;
175
+ }
179
176
 
180
- QPromise.prototype.catch = function (callback) {
181
- return this.then(null, callback);
182
- };
177
+ catch(callback) {
178
+ return this.then(null, callback);
179
+ }
183
180
 
184
- QPromise.prototype.finally = function (callback, progressBack) {
185
- return this.then(
186
- (value) => handleCallback(value, resolve, callback),
187
- (error) => handleCallback(error, reject, callback),
188
- progressBack,
189
- );
190
- };
181
+ finally(callback, progressBack) {
182
+ return this.then(
183
+ (value) => handleCallback(value, resolve, callback),
184
+ (error) => handleCallback(error, reject, callback),
185
+ progressBack,
186
+ );
187
+ }
188
+ }
191
189
 
192
190
  function processQueue(state) {
193
191
  let fn;
@@ -46,9 +46,7 @@ export const SCE_CONTEXTS = {
46
46
  // http://docs.closure-library.googlecode.com/git/local_closure_goog_string_string.js.source.html#line1021
47
47
  // Prereq: s is a string.
48
48
  export function escapeForRegexp(s) {
49
- return s
50
- .replace(/([-()[\]{}+?*.$^|,:#<!\\])/g, "\\$1")
51
- .replace(/\x08/g, "\\x08");
49
+ return s.replace(/([-()[\]{}+?*.$^|,:#<!\\])/g, "\\$1");
52
50
  }
53
51
 
54
52
  export function adjustMatcher(matcher) {
@@ -392,7 +392,7 @@ export class Scope {
392
392
  *
393
393
  * - `string`: Evaluated as {@link guide/expression expression}
394
394
  * - `function(scope)`: called with current `scope` as a parameter.
395
- * @param {WatchListener} listener
395
+ * @param {WatchListener} [listener]
396
396
  * @param {boolean=} [objectEquality=false] Compare for object equality using {@link angular.equals} instead of
397
397
  * comparing for reference equality.
398
398
  * @returns {function()} Returns a deregistration function for this listener.
@@ -1155,7 +1155,7 @@ export class Scope {
1155
1155
  * will be scheduled. However, it is encouraged to always call code that changes the model
1156
1156
  * from within an `$apply` call. That includes code evaluated via `$evalAsync`.
1157
1157
  *
1158
- * @param {(string|function())=} expr An AngularTS expression to be executed.
1158
+ * @param {(string|function(any):any)=} expr An AngularTS expression to be executed.
1159
1159
  *
1160
1160
  * - `string`: execute using the rules as defined in {@link guide/expression expression}.
1161
1161
  * - `function(scope)`: execute the function with the current `scope` parameter.
@@ -1187,9 +1187,6 @@ export class Scope {
1187
1187
  return id;
1188
1188
  }
1189
1189
 
1190
- /**
1191
- * @private
1192
- */
1193
1190
  $$postDigest(fn) {
1194
1191
  $$postDigestQueue.push(fn);
1195
1192
  }
@@ -3,128 +3,127 @@ import { isDefined, isFunction, minErr, sliceArgs } from "../../shared/utils";
3
3
 
4
4
  const $timeoutMinErr = minErr("$timeout");
5
5
 
6
- /**
7
- *
8
- * @param {*} $rootScope
9
- * @param {*} $browser
10
- * @param {*} $q
11
- * @param {*} $$q
12
- * @param {import('../exception-handler').ErrorHandler} $exceptionHandler
13
- * @returns
14
- */
15
- export function $timeout($rootScope, $browser, $q, $$q, $exceptionHandler) {
16
- const deferreds = {};
17
-
18
- /**
19
- * @ngdoc service
20
- * @name $timeout
21
- *
22
- * @description
23
- * AngularJS's wrapper for `window.setTimeout`. The `fn` function is wrapped into a try/catch
24
- * block and delegates any exceptions to
25
- * {@link ng.$exceptionHandler $exceptionHandler} service.
26
- *
27
- * The return value of calling `$timeout` is a promise, which will be resolved when
28
- * the delay has passed and the timeout function, if provided, is executed.
29
- *
30
- * To cancel a timeout request, call `$timeout.cancel(promise)`.
31
- *
32
- * In tests you can use {@link ngMock.$timeout `$timeout.flush()`} to
33
- * synchronously flush the queue of deferred functions.
34
- *
35
- * If you only want a promise that will be resolved after some specified delay
36
- * then you can call `$timeout` without the `fn` function.
37
- *
38
- * @param {function()=} fn A function, whose execution should be delayed.
39
- * @param {number=} [delay=0] Delay in milliseconds.
40
- * @param {boolean=} [invokeApply=true] If set to `false` skips model dirty checking, otherwise
41
- * will invoke `fn` within the {@link ng.$rootScope.Scope#$apply $apply} block.
42
- * @param {...*=} Pass additional parameters to the executed function.
43
- * @returns {Promise} Promise that will be resolved when the timeout is reached. The promise
44
- * will be resolved with the return value of the `fn` function.
45
- *
46
- */
47
- function timeout(fn, delay, invokeApply) {
48
- if (!isFunction(fn)) {
49
- invokeApply = delay;
50
- delay = fn;
51
- fn = () => {};
52
- }
53
-
54
- const args = sliceArgs(arguments, 3);
55
- const skipApply = isDefined(invokeApply) && !invokeApply;
56
- const deferred = (skipApply ? $$q : $q).defer();
57
- const { promise } = deferred;
58
- let timeoutId;
6
+ export function $TimeoutProvider() {
7
+ this.$get = [
8
+ "$rootScope",
9
+ "$browser",
10
+ "$q",
11
+ "$$q",
12
+ "$exceptionHandler",
13
+ /**
14
+ *
15
+ * @param {import('../scope/scope').Scope} $rootScope
16
+ * @param {import('../../services/browser').Browser} $browser
17
+ * @param {*} $q
18
+ * @param {*} $$q
19
+ * @param {import('../exception-handler').ErrorHandler} $exceptionHandler
20
+ * @returns
21
+ */
22
+ function ($rootScope, $browser, $q, $$q, $exceptionHandler) {
23
+ const deferreds = {};
59
24
 
60
- timeoutId = $browser.defer(
61
- () => {
62
- try {
63
- deferred.resolve(fn.apply(null, args));
64
- } catch (e) {
65
- deferred.reject(e);
66
- $exceptionHandler(e);
67
- } finally {
68
- delete deferreds[promise.$$timeoutId];
25
+ /**
26
+ * @ngdoc service
27
+ * @name $timeout
28
+ *
29
+ * @description
30
+ * AngularJS's wrapper for `window.setTimeout`. The `fn` function is wrapped into a try/catch
31
+ * block and delegates any exceptions to
32
+ * {@link ng.$exceptionHandler $exceptionHandler} service.
33
+ *
34
+ * The return value of calling `$timeout` is a promise, which will be resolved when
35
+ * the delay has passed and the timeout function, if provided, is executed.
36
+ *
37
+ * To cancel a timeout request, call `$timeout.cancel(promise)`.
38
+ *
39
+ * In tests you can use {@link ngMock.$timeout `$timeout.flush()`} to
40
+ * synchronously flush the queue of deferred functions.
41
+ *
42
+ * If you only want a promise that will be resolved after some specified delay
43
+ * then you can call `$timeout` without the `fn` function.
44
+ *
45
+ * @param {function()=} fn A function, whose execution should be delayed.
46
+ * @param {number=} [delay=0] Delay in milliseconds.
47
+ * @param {boolean=} [invokeApply=true] If set to `false` skips model dirty checking, otherwise
48
+ * will invoke `fn` within the {@link ng.$rootScope.Scope#$apply $apply} block.
49
+ * @returns {Promise} Promise that will be resolved when the timeout is reached. The promise
50
+ * will be resolved with the return value of the `fn` function.
51
+ *
52
+ */
53
+ function timeout(fn, delay, invokeApply = true) {
54
+ if (!isFunction(fn)) {
55
+ invokeApply = delay;
56
+ delay = fn;
57
+ fn = () => {};
69
58
  }
70
59
 
71
- if (!skipApply) $rootScope.$apply();
72
- },
73
- delay,
74
- "$timeout",
75
- );
60
+ const args = sliceArgs(arguments, 3);
61
+ const skipApply = isDefined(invokeApply) && !invokeApply;
62
+ const deferred = (skipApply ? $$q : $q).defer();
63
+ const { promise } = deferred;
64
+ let timeoutId;
76
65
 
77
- promise.$$timeoutId = timeoutId;
78
- deferreds[timeoutId] = deferred;
66
+ timeoutId = $browser.defer(
67
+ () => {
68
+ try {
69
+ deferred.resolve(fn.apply(null, args));
70
+ } catch (e) {
71
+ deferred.reject(e);
72
+ $exceptionHandler(e);
73
+ } finally {
74
+ delete deferreds[promise.$$timeoutId];
75
+ }
79
76
 
80
- return promise;
81
- }
77
+ if (!skipApply) $rootScope.$apply();
78
+ },
79
+ delay,
80
+ "$timeout",
81
+ );
82
82
 
83
- /**
84
- * @ngdoc method
85
- * @name $timeout#cancel
86
- *
87
- * @description
88
- * Cancels a task associated with the `promise`. As a result of this, the promise will be
89
- * resolved with a rejection.
90
- *
91
- * @param {Promise=} promise Promise returned by the `$timeout` function.
92
- * @returns {boolean} Returns `true` if the task hasn't executed yet and was successfully
93
- * canceled.
94
- */
95
- timeout.cancel = function (promise) {
96
- if (!promise) return false;
83
+ promise.$$timeoutId = timeoutId;
84
+ deferreds[timeoutId] = deferred;
97
85
 
98
- if (!Object.prototype.hasOwnProperty.call(promise, "$$timeoutId")) {
99
- throw $timeoutMinErr(
100
- "badprom",
101
- "`$timeout.cancel()` called with a promise that was not generated by `$timeout()`.",
102
- );
103
- }
86
+ return promise;
87
+ }
104
88
 
105
- if (!Object.prototype.hasOwnProperty.call(deferreds, promise.$$timeoutId))
106
- return false;
107
- const id = promise.$$timeoutId;
108
- const deferred = deferreds[id];
89
+ /**
90
+ * @ngdoc method
91
+ * @name $timeout#cancel
92
+ *
93
+ * @description
94
+ * Cancels a task associated with the `promise`. As a result of this, the promise will be
95
+ * resolved with a rejection.
96
+ *
97
+ * @param {Promise=} promise Promise returned by the `$timeout` function.
98
+ * @returns {boolean} Returns `true` if the task hasn't executed yet and was successfully
99
+ * canceled.
100
+ */
101
+ timeout.cancel = function (promise) {
102
+ if (!promise) return false;
109
103
 
110
- // Timeout cancels should not report an unhandled promise.
111
- markQExceptionHandled(deferred.promise);
112
- deferred.reject("canceled");
113
- delete deferreds[id];
104
+ if (!Object.prototype.hasOwnProperty.call(promise, "$$timeoutId")) {
105
+ throw $timeoutMinErr(
106
+ "badprom",
107
+ "`$timeout.cancel()` called with a promise that was not generated by `$timeout()`.",
108
+ );
109
+ }
114
110
 
115
- return $browser.cancel(id);
116
- };
111
+ if (
112
+ !Object.prototype.hasOwnProperty.call(deferreds, promise.$$timeoutId)
113
+ )
114
+ return false;
115
+ const id = promise.$$timeoutId;
116
+ const deferred = deferreds[id];
117
117
 
118
- return timeout;
119
- }
118
+ // Timeout cancels should not report an unhandled promise.
119
+ markQExceptionHandled(deferred.promise);
120
+ deferred.reject("canceled");
121
+ delete deferreds[id];
120
122
 
121
- export function $TimeoutProvider() {
122
- this.$get = [
123
- "$rootScope",
124
- "$browser",
125
- "$q",
126
- "$$q",
127
- "$exceptionHandler",
128
- $timeout,
123
+ return $browser.cancel(id);
124
+ };
125
+
126
+ return timeout;
127
+ },
129
128
  ];
130
129
  }
@@ -1,5 +1,10 @@
1
1
  import { isString } from "../../shared/utils";
2
2
 
3
+ /**
4
+ * HTTP protocol
5
+ * @typedef {"http"|"https"} HttpProtocol
6
+ */
7
+
3
8
  // service.
4
9
  const urlParsingNode = window.document.createElement("a");
5
10
  const originUrl = urlResolve(window.location.href);