@angular-wave/angular.ts 0.0.61 → 0.0.63

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.
@@ -117,7 +117,7 @@ export class StateProvider {
117
117
  * let result = {},
118
118
  * views = parent(state);
119
119
  *
120
- * angular.forEach(views, function (config, name) {
120
+ * forEach(views, function (config, name) {
121
121
  * let autoName = (state.name + '.' + name).replace('.', '/');
122
122
  * config.templateUrl = config.templateUrl || '/partials/' + autoName + '.html';
123
123
  * result[name] = config;
@@ -2,6 +2,7 @@ import { dealoc } from "../../shared/jqlite/jqlite";
2
2
  import { Angular } from "../../loader";
3
3
  import { publishExternalAPI } from "../../public";
4
4
  import { map, find } from "../../shared/common";
5
+ import { forEach } from "../../shared/utils";
5
6
 
6
7
  describe("UrlMatcher", () => {
7
8
  let $url;
@@ -245,7 +246,7 @@ describe("UrlMatcher", () => {
245
246
  "/url/someword/child/childParam",
246
247
  };
247
248
 
248
- angular.forEach(shouldPass, function (url, route) {
249
+ forEach(shouldPass, function (url, route) {
249
250
  expect($url.compile(route).exec(url, {})).toEqual({
250
251
  childParam: "childParam",
251
252
  matchedParam: "someword",
@@ -261,7 +262,7 @@ describe("UrlMatcher", () => {
261
262
  "/url/someword/child/childParam",
262
263
  };
263
264
 
264
- angular.forEach(shouldThrow, function (url, route) {
265
+ forEach(shouldThrow, function (url, route) {
265
266
  expect(() => {
266
267
  $url.compile(route).exec(url, {});
267
268
  }).toThrowError("Unbalanced capture group in route '" + route + "'");
@@ -274,7 +275,7 @@ describe("UrlMatcher", () => {
274
275
  "/url/someword/child/childParam",
275
276
  };
276
277
 
277
- angular.forEach(shouldPass, function (url, route) {
278
+ forEach(shouldPass, function (url, route) {
278
279
  expect(() => {
279
280
  $url.compile(route).exec(url, {});
280
281
  }).not.toThrow();
@@ -16,11 +16,6 @@ import {
16
16
  import { CACHE, EXPANDO } from "../../core/cache/cache";
17
17
 
18
18
  /**
19
- * @name angular.element
20
- * @module ng
21
- * @kind function
22
- *
23
- * @description
24
19
  * Wraps a raw DOM element or HTML string as a [jQuery](http://jquery.com) element. Regardless of the presence of jQuery, `angular.element`
25
20
  * delegates to AngularJS's built-in subset of jQuery, called "jQuery lite" or **jqLite**.
26
21
  *
@@ -80,12 +75,6 @@ import { CACHE, EXPANDO } from "../../core/cache/cache";
80
75
  * Requires {@link guide/production#disabling-debug-data Debug Data} to be enabled.
81
76
  * - `inheritedData()` - same as `data()`, but walks up the DOM until a value is found or the top
82
77
  * parent element is reached.
83
- *
84
- * @knownIssue You cannot spy on `angular.element` if you are using Jasmine version 1.x. See
85
- * https://github.com/angular/angular.js/issues/14251 for more information.
86
- *
87
- * @param {string|Element} element HTML string or Element to be wrapped into jQuery.
88
- * @returns {JQLite} jQuery object.
89
78
  */
90
79
 
91
80
  /** @type {number} */
@@ -135,7 +124,7 @@ const BOOLEAN_ELEMENTS = {};
135
124
  * JQLite both a function and an array-like data structure for manipulation of DOM, linking elements to expando cache,
136
125
  * and execution of chain functions.
137
126
  *
138
- * @param {string|Element|Comment|Document|Window|JQLite|ArrayLike<Element>|(() => void)} element
127
+ * @param {string|Node|JQLite|ArrayLike<Element>|(() => void)} element
139
128
  * @returns {JQLite}
140
129
  */
141
130
  export function JQLite(element) {
@@ -553,15 +542,7 @@ JQLite.prototype.replaceWith = function (arg1) {
553
542
  });
554
543
  };
555
544
  for (let i = 0; i < this.length; i++) {
556
- if (isUndefined(value)) {
557
- value = fn(this[i], arg1);
558
- if (isDefined(value)) {
559
- // any function which returns a value needs to be wrapped
560
- value = JQLite(value);
561
- }
562
- } else {
563
- addNodes(value, fn(this[i], arg1));
564
- }
545
+ addNodes(value, fn(this[i], arg1));
565
546
  }
566
547
  return isDefined(value) ? value : this;
567
548
  };
@@ -893,6 +874,7 @@ function elementAcceptsData(node) {
893
874
  * @returns {DocumentFragment}
894
875
  */
895
876
  export function buildFragment(html) {
877
+ /** @type {HTMLDivElement} */
896
878
  let tmp;
897
879
  let tag;
898
880
  let wrap;
@@ -905,6 +887,7 @@ export function buildFragment(html) {
905
887
  nodes.push(document.createTextNode(html));
906
888
  } else {
907
889
  // Convert html into DOM nodes
890
+
908
891
  tmp = tempFragment.appendChild(document.createElement("div"));
909
892
  tag = (TAG_NAME_REGEXP.exec(html) || ["", ""])[1].toLowerCase();
910
893
 
@@ -914,13 +897,13 @@ export function buildFragment(html) {
914
897
  i = wrap.length;
915
898
  while (--i > -1) {
916
899
  tmp.appendChild(window.document.createElement(wrap[i]));
917
- tmp = tmp.firstChild;
900
+ tmp = /** @type {HTMLDivElement} */ (tmp.firstChild);
918
901
  }
919
902
  tmp.innerHTML = html;
920
903
 
921
904
  nodes = concat(nodes, tmp.childNodes);
922
905
 
923
- tmp = tempFragment.firstChild;
906
+ tmp = /** @type {HTMLDivElement} */ (tempFragment.firstChild);
924
907
  tmp.textContent = "";
925
908
  }
926
909
 
@@ -1021,7 +1004,7 @@ export function getOrSetCacheData(element, key, value) {
1021
1004
  /**
1022
1005
  * Adds nodes or elements to the root array-like object.
1023
1006
  *
1024
- * @param {Array} root - The array-like object to which elements will be added.
1007
+ * @param {JQLite} root - The array-like object to which elements will be added.
1025
1008
  * @param {(Node|Array|NodeList|Object)} elements - The elements to add to the root. This can be a single DOM node, an array-like object (such as an Array or NodeList), or any other object.
1026
1009
  */
1027
1010
  function addNodes(root, elements) {
@@ -1054,7 +1037,7 @@ function getController(element, name) {
1054
1037
 
1055
1038
  /**
1056
1039
  *
1057
- * @param {Element} element
1040
+ * @param {Node} element
1058
1041
  * @param {string|string[]} name
1059
1042
  * @param {any} [value]
1060
1043
  * @returns
@@ -1064,13 +1047,20 @@ function getInheritedData(element, name, value) {
1064
1047
  // this makes $(document).scope() possible
1065
1048
  if (element.nodeType === Node.DOCUMENT_NODE) {
1066
1049
  // TODO Fix types
1067
- element = element.documentElement;
1050
+ element = /** @type {Document} */ (element).documentElement;
1068
1051
  }
1069
1052
  const names = Array.isArray(name) ? name : [name];
1070
1053
 
1071
1054
  while (element) {
1072
1055
  for (let i = 0, ii = names.length; i < ii; i++) {
1073
- if (isDefined((value = getOrSetCacheData(element, names[i]))))
1056
+ if (
1057
+ isDefined(
1058
+ (value = getOrSetCacheData(
1059
+ /** @type {Element} */ (element),
1060
+ names[i],
1061
+ )),
1062
+ )
1063
+ )
1074
1064
  return value;
1075
1065
  }
1076
1066
 
@@ -1079,7 +1069,8 @@ function getInheritedData(element, name, value) {
1079
1069
  // to lookup parent controllers.
1080
1070
  element =
1081
1071
  element.parentNode ||
1082
- (element.nodeType === Node.DOCUMENT_FRAGMENT_NODE && element.host);
1072
+ (element.nodeType === Node.DOCUMENT_FRAGMENT_NODE &&
1073
+ /** @type {ShadowRoot} */ (element).host);
1083
1074
  }
1084
1075
  }
1085
1076
 
@@ -1193,7 +1184,7 @@ function specialMouseHandlerWrapper(target, event, handler) {
1193
1184
  export function startingTag(elementStr) {
1194
1185
  const clone = JQLite(elementStr)[0].cloneNode(true);
1195
1186
  const element = JQLite(clone).empty();
1196
- var elemHtml = JQLite("<div></div>").append(element).html();
1187
+ var elemHtml = JQLite("<div></div>").append(element[0]).html();
1197
1188
  try {
1198
1189
  return element[0].nodeType === Node.TEXT_NODE
1199
1190
  ? lowercase(elemHtml)
@@ -0,0 +1,62 @@
1
+ /\*\*
2
+
3
+ - Wraps a raw DOM element or HTML string as a [jQuery](http://jquery.com) element. Regardless of the presence of jQuery, `angular.element`
4
+ - delegates to AngularJS's built-in subset of jQuery, called "jQuery lite" or **jqLite**.
5
+ -
6
+ - JQLite is a tiny, API-compatible subset of jQuery that allows
7
+ - AngularJS to manipulate the DOM in a cross-browser compatible way. JQLite implements only the most
8
+ - commonly needed functionality with the goal of having a very small footprint.
9
+ -
10
+ - <div class="alert alert-info">**Note:** All element references in AngularJS are always wrapped with
11
+ - JQLite (such as the element argument in a directive's compile / link function). They are never raw DOM references.</div>
12
+ -
13
+ - <div class="alert alert-warning">**Note:** Keep in mind that this function will not find elements
14
+ - by tag name / CSS selector. For lookups by tag name, try instead `angular.element(document).find(...)`
15
+ - or `$document.find()`, or use the standard DOM APIs, e.g. `document.querySelectorAll()`.</div>
16
+ -
17
+ - ## AngularJS's JQLite
18
+ - JQLite provides only the following jQuery methods:
19
+ -
20
+ - - [`after()`](http://api.jquery.com/after/)
21
+ - - [`append()`](http://api.jquery.com/append/) - Contrary to jQuery, this doesn't clone elements
22
+ - so will not work correctly when invoked on a JQLite object containing more than one DOM node
23
+ - - [`attr()`](http://api.jquery.com/attr/) - Does not support functions as parameters
24
+ - - [`children()`](http://api.jquery.com/children/) - Does not support selectors
25
+ - - [`data()`](http://api.jquery.com/data/)
26
+ - - [`empty()`](http://api.jquery.com/empty/)
27
+ - - [`eq()`](http://api.jquery.com/eq/)
28
+ - - [`html()`](http://api.jquery.com/html/)
29
+ - - [`on()`](http://api.jquery.com/on/) - Does not support namespaces, selectors or eventData
30
+ - - [`off()`](http://api.jquery.com/off/) - Does not support namespaces, selectors or event object as parameter
31
+ - - [`parent()`](http://api.jquery.com/parent/) - Does not support selectors
32
+ - - [`prepend()`](http://api.jquery.com/prepend/)
33
+ - - [`remove()`](http://api.jquery.com/remove/)
34
+ - - [`removeData()`](http://api.jquery.com/removeData/)
35
+ - - [`replaceWith()`](http://api.jquery.com/replaceWith/)
36
+ - - [`text()`](http://api.jquery.com/text/)
37
+ - - [`val()`](http://api.jquery.com/val/)
38
+ -
39
+ - ## jQuery/jqLite Extras
40
+ - AngularJS also provides the following additional methods and events to both jQuery and JQLite:
41
+ -
42
+ - ### Events
43
+ - - `$destroy` - AngularJS intercepts all JQLite/jQuery's DOM destruction apis and fires this event
44
+ - on all DOM nodes being removed. This can be used to clean up any 3rd party bindings to the DOM
45
+ - element before it is removed.
46
+ -
47
+ - ### Methods
48
+ - - `controller(name)` - retrieves the controller of the current element or its parent. By default
49
+ - retrieves controller associated with the `ngController` directive. If `name` is provided as
50
+ - camelCase directive name, then the controller for this directive will be retrieved (e.g.
51
+ - `'ngModel'`).
52
+ - - `injector()` - retrieves the injector of the current element or its parent.
53
+ - - `scope()` - retrieves the {@link ng.$rootScope.Scope scope} of the current
54
+ - element or its parent. Requires {@link guide/production#disabling-debug-data Debug Data} to
55
+ - be enabled.
56
+ - - `isolateScope()` - retrieves an isolate {@link ng.$rootScope.Scope scope} if one is attached directly to the
57
+ - current element. This getter should be used only on elements that contain a directive which starts a new isolate
58
+ - scope. Calling `scope()` on this element always returns the original non-isolate scope.
59
+ - Requires {@link guide/production#disabling-debug-data Debug Data} to be enabled.
60
+ - - `inheritedData()` - same as `data()`, but walks up the DOM until a value is found or the top
61
+ - parent element is reached.
62
+ \*/
@@ -1,5 +1,4 @@
1
- import { minErr, isDefined, toDebugString } from "./utils";
2
- import { errorHandlingConfig } from "../loader";
1
+ import { minErr, isDefined, toDebugString, errorHandlingConfig } from "./utils";
3
2
 
4
3
  describe("errors", () => {
5
4
  afterEach(() => {});
@@ -307,7 +307,7 @@ export function snakeCase(name, separator) {
307
307
  ```js
308
308
  let values = {name: 'misko', gender: 'male'};
309
309
  let log = [];
310
- angular.forEach(values, function(value, key) {
310
+ forEach(values, function(value, key) {
311
311
  this.push(key + ': ' + value);
312
312
  }, log);
313
313
  expect(log).toEqual(['name: misko', 'gender: male']);
@@ -496,15 +496,6 @@ export function inherit(parent, extra) {
496
496
  return extend(Object.create(parent), extra);
497
497
  }
498
498
 
499
- /**
500
- *
501
- * @param {*} value to be returned.
502
- * @returns {*} the value passed in.
503
- */
504
- export function identity(value) {
505
- return value;
506
- }
507
-
508
499
  /**
509
500
  * @param {*} value
510
501
  * @returns {() => *}
@@ -1110,7 +1101,41 @@ export function assertArgFn(arg, name, acceptArrayAnnotation) {
1110
1101
  return arg;
1111
1102
  }
1112
1103
 
1113
- export const minErrConfig = {};
1104
+ /**
1105
+ * @typedef {Object} ErrorHandlingConfig
1106
+ * Error configuration object. May only contain the options that need to be updated.
1107
+ * @property {number=} objectMaxDepth - The max depth for stringifying objects. Setting to a
1108
+ * non-positive or non-numeric value removes the max depth limit. Default: 5.
1109
+ * @property {boolean=} urlErrorParamsEnabled - Specifies whether the generated error URL will
1110
+ * contain the parameters of the thrown error. Default: true. When used without argument, it returns the current value.
1111
+ */
1112
+
1113
+ /** @type {ErrorHandlingConfig} */
1114
+ const minErrConfig = {
1115
+ objectMaxDepth: 5,
1116
+ urlErrorParamsEnabled: true,
1117
+ };
1118
+
1119
+ /**
1120
+ * @param {ErrorHandlingConfig} [config]
1121
+ * @returns {ErrorHandlingConfig}
1122
+ */
1123
+ export function errorHandlingConfig(config) {
1124
+ if (isObject(config)) {
1125
+ if (isDefined(config.objectMaxDepth)) {
1126
+ minErrConfig.objectMaxDepth = isValidObjectMaxDepth(config.objectMaxDepth)
1127
+ ? config.objectMaxDepth
1128
+ : NaN;
1129
+ }
1130
+ if (
1131
+ isDefined(config.urlErrorParamsEnabled) &&
1132
+ isBoolean(config.urlErrorParamsEnabled)
1133
+ ) {
1134
+ minErrConfig.urlErrorParamsEnabled = config.urlErrorParamsEnabled;
1135
+ }
1136
+ }
1137
+ return minErrConfig;
1138
+ }
1114
1139
 
1115
1140
  /**
1116
1141
  * This object provides a utility for producing rich Error messages within
@@ -1167,7 +1192,7 @@ export function minErr(module) {
1167
1192
 
1168
1193
  message += `\n${url}${module ? `${module}/` : ""}${code}`;
1169
1194
 
1170
- if (minErrConfig.urlErrorParamsEnabled) {
1195
+ if (errorHandlingConfig().urlErrorParamsEnabled) {
1171
1196
  for (
1172
1197
  i = 0, paramPrefix = "?";
1173
1198
  i < templateArgs.length;
package/src/types.js CHANGED
@@ -1,7 +1,6 @@
1
1
  /**
2
2
  * @typedef {Object} BootstrapConfig
3
3
  * @description Configuration option for AngularTS bootstrap process.
4
- * @property {boolean} debugInfoEnabled - Indicates whether debug information should be enabled. Setting this to `false` can improve performance but will disable some debugging features.
5
4
  * @property {boolean} [strictDi] - Disable automatic function annotation for the application. This is meant to assist in finding bugs which break minified code. Defaults to `false`.
6
5
  */
7
6
 
@@ -451,9 +450,9 @@
451
450
  * @property {function(string, string=): any} get - Get a service by name.
452
451
  * @property {function(Function, any?): any} instantiate - Instantiate a type constructor with optional locals.
453
452
  * @property {function(Injectable<Function | ((...args: any[]) => any)>, any=, any=): any} invoke - Invoke a function with optional context and locals.
454
- * @property {function(Array<Module | string | Injectable<(...args: any[]) => void>>): void} loadNewModules - Add and load new modules to the injector.
455
- * @property {Object.<string, Module>} modules - A map of all the modules loaded into the injector.
456
- * @property {boolean} strictDi - Indicates if strict dependency injection is enforced.
453
+ * @property {function(Array<Module | string | Injectable<(...args: any[]) => void>>): void} [loadNewModules] - Add and load new modules to the injector.
454
+ * @property {Object.<string, Module>} [modules] - A map of all the modules loaded into the injector.
455
+ * @property {boolean} [strictDi] - Indicates if strict dependency injection is enforced.
457
456
  */
458
457
 
459
458
  export {};
@@ -4,8 +4,9 @@ export class $$AnimateCssDriverProvider {
4
4
  /**
5
5
  * @returns {Function}
6
6
  */
7
- $get: (string | (($animateCss: any, $$AnimateRunner: typeof import("../core/animate/animate-runner").AnimateRunner, $rootElement: any) => (animationDetails: any) => any))[];
7
+ $get: (string | (($animateCss: any, $$AnimateRunner: typeof import("../core/animate/animate-runner").AnimateRunner, $rootElement: JQLite) => (animationDetails: any) => any))[];
8
8
  }
9
9
  export namespace $$AnimateCssDriverProvider {
10
10
  let $inject: string[];
11
11
  }
12
+ import { JQLite } from "../shared/jqlite/jqlite";
@@ -6,7 +6,7 @@ export class $$AnimateQueueProvider {
6
6
  cancel: any[];
7
7
  join: any[];
8
8
  };
9
- $get: (string | (($rootScope: any, $rootElement: any, $$animation: any, $$AnimateRunner: any, $templateRequest: any) => {
9
+ $get: (string | (($rootScope: any, $rootElement: JQLite, $$animation: any, $$AnimateRunner: any, $templateRequest: any) => {
10
10
  on(event: any, container: any, callback: any): void;
11
11
  off(event: any, container: any, callback: any, ...args: any[]): void;
12
12
  pin(element: any, parentElement: any): void;
@@ -17,3 +17,4 @@ export class $$AnimateQueueProvider {
17
17
  export namespace $$AnimateQueueProvider {
18
18
  let $inject: string[];
19
19
  }
20
+ import { JQLite } from "../shared/jqlite/jqlite";
@@ -147,7 +147,6 @@ export class $CompileProvider {
147
147
  * chaining otherwise.
148
148
  */
149
149
  imgSrcSanitizationTrustedUrlList: (regexp?: RegExp | undefined) => RegExp | ng.ICompileProvider;
150
- debugInfoEnabled: (enabled: any) => boolean | this;
151
150
  strictComponentBindingsEnabled: (enabled: any) => boolean | this;
152
151
  /**
153
152
  * @ngdoc method
@@ -204,6 +204,7 @@ export class $LocationProvider {
204
204
  * @param {string=} newState New history state object
205
205
  * @param {string=} oldState History state object that was before it was changed.
206
206
  */
207
- $get: (string | (($rootScope: any, $browser: any, $rootElement: any) => LocationHtml5Url | LocationHashbangUrl))[];
207
+ $get: (string | (($rootScope: any, $browser: any, $rootElement: JQLite) => LocationHtml5Url | LocationHashbangUrl))[];
208
208
  }
209
209
  export const PATH_MATCH: RegExp;
210
+ import { JQLite } from "../../shared/jqlite/jqlite";
package/types/index.d.ts CHANGED
@@ -1 +1,5 @@
1
- export {};
1
+ /**
2
+ * @type {Angular}
3
+ */
4
+ export const angular: Angular;
5
+ import { Angular } from "./loader";
@@ -1,10 +1,10 @@
1
- export function createInjector(modulesToLoad: any, strictDi: any): {
2
- invoke: (fn: any, self: any, locals: any, serviceName: any) => any;
3
- instantiate: (Type: any, locals: any, serviceName: any) => any;
4
- get: (serviceName: any, caller: any) => any;
5
- annotate: typeof annotate;
6
- has: (name: any) => any;
7
- };
1
+ /**
2
+ *
3
+ * @param {*} modulesToLoad
4
+ * @param {*} strictDi
5
+ * @returns {import("./types").InjectorService}
6
+ */
7
+ export function createInjector(modulesToLoad: any, strictDi: any): import("./types").InjectorService;
8
8
  export namespace createInjector {
9
9
  export { annotate as $$annotate };
10
10
  }