@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/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.66",
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();
@@ -1,4 +1,7 @@
1
1
  ngAnimateSwapDirective.$inject = ["$animate"];
2
+ /**
3
+ * @returns {import('../types').Directive}
4
+ */
2
5
  export function ngAnimateSwapDirective($animate) {
3
6
  return {
4
7
  restrict: "A",
@@ -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 {ng.ICompileProvider} Self for chaining.
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|ng.ICompileProvider} Current RegExp if called without value or self for
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|ng.ICompileProvider} Current RegExp if called without value or self for
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
  *
@@ -51,22 +51,17 @@ export function createInjector(modulesToLoad, strictDi = false) {
51
51
  strictDi,
52
52
  ));
53
53
 
54
- const instanceCache = {};
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
- instanceInjector.strictDi = strictDi;
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(provider);
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
- providerCache[name] = value;
146
- instanceCache[name] = value;
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
- let moduleFn = window["angular"].module(module);
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 = "INSTANTIATING";
12
+ const INSTANTIATING = true;
13
13
 
14
- export class ProviderInjector {
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(cache, strictDi) {
21
- this.cache = cache;
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
- this.providerCache = cache;
25
- this.modules = undefined;
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(fn, locals, serviceName);
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
- instantiate(Type, locals, serviceName) {
110
- // Check if Type is annotated and use just the given function at n-1 as parameter
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(Type) ? Type[Type.length - 1] : Type;
113
- const args = this.injectionArgs(Type, locals, serviceName);
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
- has(name) {
125
- const hasProvider = Object.prototype.hasOwnProperty.call(
126
- this.providerCache,
127
- name + providerSuffix,
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
- // * @typedef {Object} LegacyInjectorService
136
- // * @property {function(Function, boolean=): string[]} annotate - Annotate a function or an array of inline annotations.
137
- // * @property {function(string, string=): any} get - Get a service by name.
138
- // * @property {function(Function, any?): any} instantiate - Instantiate a type constructor with optional locals.
139
- // * @property {function(import("../../types").Injectable<Function | ((...args: any[]) => any)>, any=, any=): any} invoke - Invoke a function with optional context and locals.
140
- // * @property {function(Array<import("../../types").Module | string | import("../../types").Injectable<(...args: any[]) => void>>): void} [loadNewModules] - Add and load new modules to the injector.
141
- // * @property {Object.<string, import("../../types").Module>} [modules] - A map of all the modules loaded into the injector.
142
- // * @property {boolean} [strictDi] - Indicates if strict dependency injection is enforced.
143
- // */
144
-
145
- export class InjectorService extends ProviderInjector {
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.providerCache = providerInjector.cache;
151
- this.modules = undefined;
196
+ this.modules = this.providerInjector.modules;
152
197
  }
153
198
 
154
- factory(serviceName, caller) {
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
- // Gets overridden
164
- loadNewModules() {}
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 (all, underscore, name) {
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
- // TODO Add types
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
- const intervals = {};
12
- const setIntervalFn = function (tick, delay, deferred) {
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[id] = deferred;
29
+ intervals.set(id, deferred);
15
30
  return id;
16
- };
17
- const clearIntervalFn = function (id) {
31
+ }
32
+
33
+ /**s
34
+ * @param {IntervalId} id
35
+ */
36
+ function clearIntervalFn(id) {
18
37
  window.clearInterval(id);
19
- delete intervals[id];
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 {Promise=} promise returned by the `$interval` function.
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[id];
64
+ const deferred = intervals.get(id);
51
65
 
52
66
  // Interval cancels should not report an unhandled promise.
53
67
  markQExceptionHandled(deferred.promise);