@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.
package/src/loader.js CHANGED
@@ -1,29 +1,15 @@
1
1
  import {
2
2
  minErr,
3
- extend,
4
3
  forEach,
5
4
  getNgAttribute,
6
5
  isFunction,
7
6
  isObject,
8
7
  ngAttrPrefixes,
9
8
  isDefined,
10
- isDate,
11
- isElement,
12
- isNumber,
13
- isString,
14
- isUndefined,
15
- merge,
16
- bind,
17
- fromJson,
18
- toJson,
19
- identity,
20
- equals,
21
9
  assertNotHasOwnProperty,
22
- isBoolean,
23
- isValidObjectMaxDepth,
24
- minErrConfig,
10
+ errorHandlingConfig,
25
11
  } from "./shared/utils";
26
- import { JQLite, startingTag } from "./shared/jqlite/jqlite";
12
+ import { JQLite } from "./shared/jqlite/jqlite";
27
13
  import { createInjector } from "./injector";
28
14
  import { CACHE } from "./core/cache/cache";
29
15
 
@@ -34,14 +20,10 @@ export const VERSION = "[VI]{version}[/VI]";
34
20
 
35
21
  const ngMinErr = minErr("ng");
36
22
 
37
- /** @type {Object.<string, import('./types').Module>} */
38
- const moduleCache = {};
39
-
40
23
  /**
41
24
  * Configuration option for AngularTS bootstrap process.
42
25
  *
43
26
  * @typedef {Object} AngularBootstrapConfig
44
- * @property {boolean} debugInfoEnabled - Indicates whether debug information should be enabled. Setting this to `false` can improve performance but will disable some debugging features.
45
27
  * @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`.
46
28
  */
47
29
 
@@ -58,162 +40,107 @@ export class Angular {
58
40
  /** @type {string} */
59
41
  this.version = VERSION;
60
42
 
61
- // Utility methods kept for backwards purposes
62
- /** @type {bind} */
63
- this.bind = bind;
64
-
65
- /** @type {equals} */
66
- this.equals = equals;
67
-
68
43
  /** @type {typeof import('./shared/jqlite/jqlite').JQLite} */
69
44
  this.element = JQLite;
70
45
 
71
- /** @type {extend} */
72
- this.extend = extend;
73
-
74
- /** @type {forEach} */
75
- this.forEach = forEach;
76
-
77
- /** @type {fromJson} */
78
- this.fromJson = fromJson;
79
-
80
- /** @type {toJson} */
81
- this.toJson = toJson;
82
-
83
- /** @type {identity} */
84
- this.identity = identity;
85
-
86
- /** @type {isDate} */
87
- this.isDate = isDate;
88
-
89
- /** @type {isDefined} */
90
- this.isDefined = isDefined;
91
-
92
- /** @type {isElement} */
93
- this.isElement = isElement;
94
-
95
- /** @type {isFunction} */
96
- this.isFunction = isFunction;
97
-
98
- /** @type {isNumber} */
99
- this.isNumber = isNumber;
100
-
101
- /** @type {isObject} */
102
- this.isObject = isObject;
103
-
104
- /** @type {isString} */
105
- this.isString = isString;
106
-
107
- /** @type {isUndefined} */
108
- this.isUndefined = isUndefined;
109
-
110
- /** @type {merge} */
111
- this.merge = merge;
112
-
113
- /** @type {errorHandlingConfig} */
114
- this.errorHandlingConfig = errorHandlingConfig;
46
+ /** @type {!Array<string|any>} */
47
+ this.bootsrappedModules = [];
115
48
 
116
49
  /** @type {Function} */
117
50
  this.doBootstrap;
118
51
  }
119
52
 
120
53
  /**
121
- * @module angular
122
- * @function bootstrap
54
+ * Configure several aspects of error handling if used as a setter or return the
55
+ * current configuration if used as a getter.
56
+ *
57
+ * Omitted or undefined options will leave the corresponding configuration values unchanged.
58
+ *
59
+ * @param {import('./shared/utils').ErrorHandlingConfig} [config]
60
+ * @returns {import('./shared/utils').ErrorHandlingConfig}
61
+ */
62
+ errorHandlingConfig(config) {
63
+ return errorHandlingConfig(config);
64
+ }
123
65
 
124
- * @description
125
- * Use this function to manually start up AngularJS application.
126
- *
127
- * For more information, see the {@link guide/bootstrap Bootstrap guide}.
128
- *
129
- * AngularJS will detect if it has been loaded into the browser more than once and only allow the
130
- * first loaded script to be bootstrapped and will report a warning to the browser console for
131
- * each of the subsequent scripts. This prevents strange results in applications, where otherwise
132
- * multiple instances of AngularJS try to work on the DOM.
133
- *
134
- * <div class="alert alert-warning">
135
- * **Note:** Protractor based end-to-end tests cannot use this function to bootstrap manually.
136
- * They must use {@link ng.directive:ngApp ngApp}.
137
- * </div>
138
- *
139
- * <div class="alert alert-warning">
140
- * **Note:** Do not bootstrap the app on an element with a directive that uses {@link ng.$compile#transclusion transclusion},
141
- * such as {@link ng.ngIf `ngIf`}, {@link ng.ngInclude `ngInclude`} and {@link ngRoute.ngView `ngView`}.
142
- * Doing this misplaces the app {@link ng.$rootElement `$rootElement`} and the app's {@link auto.$injector injector},
143
- * causing animations to stop working and making the injector inaccessible from outside the app.
144
- * </div>
145
- *
146
- * ```html
147
- * <!doctype html>
148
- * <html>
149
- * <body>
150
- * <div ng-controller="WelcomeController">
151
- * {{greeting}}
152
- * </div>
153
- *
154
- * <script src="angular.js"></script>
155
- * <script>
156
- * let app = angular.module('demo', [])
157
- * .controller('WelcomeController', function($scope) {
158
- * $scope.greeting = 'Welcome!';
159
- * });
160
- * angular.bootstrap(document, ['demo']);
161
- * </script>
162
- * </body>
163
- * </html>
164
- * ```
165
- *
166
- * @param {string | Element | Document} element DOM element which is the root of AngularJS application.
167
- * @param {Array<string | Function | any[]>=} modules an array of modules to load into the application.
168
- * Each item in the array should be the name of a predefined module or a (DI annotated)
169
- * function that will be invoked by the injector as a `config` block.
170
- * See: {@link angular.module modules}
171
- * @param {AngularBootstrapConfig} [config] an object for defining configuration options for the application. The
172
- * following keys are supported:
173
- *
174
- * * `strictDi` - disable automatic function annotation for the application. This is meant to
175
- * assist in finding bugs which break minified code. Defaults to `false`.
176
- *
177
- * @returns {any} InjectorService - Returns the newly created injector for this app.
178
- */
66
+ /**
67
+ * Use this function to manually start up AngularJS application.
68
+ *
69
+ * For more information, see the {@link guide/bootstrap Bootstrap guide}.
70
+ *
71
+ * AngularJS will detect if it has been loaded into the browser more than once and only allow the
72
+ * first loaded script to be bootstrapped and will report a warning to the browser console for
73
+ * each of the subsequent scripts. This prevents strange results in applications, where otherwise
74
+ * multiple instances of AngularJS try to work on the DOM.
75
+ *
76
+ * <div class="alert alert-warning">
77
+ * **Note:** Protractor based end-to-end tests cannot use this function to bootstrap manually.
78
+ * They must use {@link ng.directive:ngApp ngApp}.
79
+ * </div>
80
+ *
81
+ * <div class="alert alert-warning">
82
+ * **Note:** Do not bootstrap the app on an element with a directive that uses {@link ng.$compile#transclusion transclusion},
83
+ * such as {@link ng.ngIf `ngIf`}, {@link ng.ngInclude `ngInclude`} and {@link ngRoute.ngView `ngView`}.
84
+ * Doing this misplaces the app {@link ng.$rootElement `$rootElement`} and the app's {@link auto.$injector injector},
85
+ * causing animations to stop working and making the injector inaccessible from outside the app.
86
+ * </div>
87
+ *
88
+ * ```html
89
+ * <!doctype html>
90
+ * <html>
91
+ * <body>
92
+ * <div ng-controller="WelcomeController">
93
+ * {{greeting}}
94
+ * </div>
95
+ *
96
+ * <script src="angular.js"></script>
97
+ * <script>
98
+ * let app = angular.module('demo', [])
99
+ * .controller('WelcomeController', function($scope) {
100
+ * $scope.greeting = 'Welcome!';
101
+ * });
102
+ * angular.bootstrap(document, ['demo']);
103
+ * </script>
104
+ * </body>
105
+ * </html>
106
+ * ```
107
+ *
108
+ * @param {string | Element | Document} element DOM element which is the root of AngularJS application.
109
+ * @param {Array<String|any>} [modules] an array of modules to load into the application.
110
+ * Each item in the array should be the name of a predefined module or a (DI annotated)
111
+ * function that will be invoked by the injector as a `config` block.
112
+ * See: {@link angular.module modules}
113
+ * @param {AngularBootstrapConfig} [config] an object for defining configuration options for the application. The
114
+ * following keys are supported:
115
+ *
116
+ * * `strictDi` - disable automatic function annotation for the application. This is meant to
117
+ * assist in finding bugs which break minified code. Defaults to `false`.
118
+ *
119
+ * @returns {any} InjectorService - Returns the newly created injector for this app.
120
+ */
179
121
  bootstrap(element, modules, config) {
180
122
  config = config || {
181
- debugInfoEnabled: false,
182
123
  strictDi: false,
183
124
  };
184
125
 
185
126
  this.doBootstrap = function () {
186
- element = JQLite(element);
187
-
188
- if (element.injector()) {
189
- const tag =
190
- element[0] === window.document ? "document" : startingTag(element);
191
- // Encode angle brackets to prevent input from being sanitized to empty string #8683.
192
- throw ngMinErr(
193
- "btstrpd",
194
- "App already bootstrapped with this element '{0}'",
195
- tag.replace(/</, "&lt;").replace(/>/, "&gt;"),
196
- );
127
+ var jqLite = JQLite(element);
128
+
129
+ if (jqLite.injector()) {
130
+ throw ngMinErr("btstrpd", "App already bootstrapped");
131
+ }
132
+
133
+ if (Array.isArray(modules)) {
134
+ this.bootsrappedModules = modules;
197
135
  }
198
136
 
199
- this.bootsrappedModules = modules || [];
200
137
  this.bootsrappedModules.unshift([
201
138
  "$provide",
202
139
  ($provide) => {
203
- $provide.value("$rootElement", element);
140
+ $provide.value("$rootElement", jqLite);
204
141
  },
205
142
  ]);
206
143
 
207
- if (config.debugInfoEnabled) {
208
- // Pushing so that this overrides `debugInfoEnabled` setting defined in user's `modules`.
209
- this.bootsrappedModules.push([
210
- "$compileProvider",
211
- function ($compileProvider) {
212
- $compileProvider.debugInfoEnabled(true);
213
- },
214
- ]);
215
- }
216
-
217
144
  this.bootsrappedModules.unshift("ng");
218
145
 
219
146
  const injector = createInjector(this.bootsrappedModules, config.strictDi);
@@ -222,7 +149,14 @@ export class Angular {
222
149
  "$rootElement",
223
150
  "$compile",
224
151
  "$injector",
225
- function bootstrapApply(scope, el, compile, $injector) {
152
+ /**
153
+ *
154
+ * @param {*} scope
155
+ * @param {JQLite} el
156
+ * @param {*} compile
157
+ * @param {*} $injector
158
+ */
159
+ function (scope, el, compile, $injector) {
226
160
  scope.$apply(() => {
227
161
  el.data("$injector", $injector);
228
162
  compile(el)(scope);
@@ -232,36 +166,26 @@ export class Angular {
232
166
  return injector;
233
167
  };
234
168
 
235
- const NG_ENABLE_DEBUG_INFO = /^NG_ENABLE_DEBUG_INFO!/;
236
169
  const NG_DEFER_BOOTSTRAP = /^NG_DEFER_BOOTSTRAP!/;
237
170
 
238
- if (window && NG_ENABLE_DEBUG_INFO.test(window.name)) {
239
- config.debugInfoEnabled = true;
240
- window.name = window.name.replace(NG_ENABLE_DEBUG_INFO, "");
241
- }
242
-
243
171
  if (window && !NG_DEFER_BOOTSTRAP.test(window.name)) {
244
172
  return this.doBootstrap();
245
173
  }
246
174
 
247
175
  window.name = window.name.replace(NG_DEFER_BOOTSTRAP, "");
248
176
  this.resumeBootstrap = function (extraModules) {
249
- forEach(extraModules, function (module) {
250
- modules.push(module);
251
- });
177
+ if (Array.isArray(extraModules)) {
178
+ extraModules.forEach((module) => modules.push(module));
179
+ }
252
180
  return this.doBootstrap();
253
181
  };
254
-
255
- if (isFunction(this.resumeDeferredBootstrap)) {
256
- this.resumeDeferredBootstrap();
257
- }
258
182
  }
259
183
 
260
184
  /**
261
185
  *
262
186
  * @param {any[]} modules
263
187
  * @param {boolean?} strictDi
264
- * @returns {angular.auto.IInjectorService}
188
+ * @returns {import("./types").InjectorService}
265
189
  */
266
190
  injector(modules, strictDi) {
267
191
  return createInjector(modules, strictDi);
@@ -274,400 +198,6 @@ export class Angular {
274
198
  return this.doBootstrap();
275
199
  }
276
200
 
277
- /**
278
- *
279
- * The `angular.module` is a global place for creating, registering and retrieving AngularJS
280
- * modules.
281
- * All modules (AngularJS core or 3rd party) that should be available to an application must be
282
- * registered using this mechanism.
283
- *
284
- * Passing one argument retrieves an existing {@link import('./types').Module},
285
- * whereas passing more than one argument creates a new {@link import('./types').Module}
286
- *
287
- *
288
- * # Module
289
- *
290
- * A module is a collection of services, directives, controllers, filters, and configuration information.
291
- * `angular.module` is used to configure the {@link auto.$injector $injector}.
292
- *
293
- * ```js
294
- * // Create a new module
295
- * let myModule = angular.module('myModule', []);
296
- *
297
- * // register a new service
298
- * myModule.value('appName', 'MyCoolApp');
299
- *
300
- * // configure existing services inside initialization blocks.
301
- * myModule.config(['$locationProvider', function($locationProvider) {
302
- * // Configure existing providers
303
- * $locationProvider.hashPrefix('!');
304
- * }]);
305
- * ```
306
- *
307
- * Then you can create an injector and load your modules like this:
308
- *
309
- * ```js
310
- * let injector = angular.injector(['ng', 'myModule'])
311
- * ```
312
- *
313
- * However it's more likely that you'll just use
314
- * {@link ng.directive:ngApp ngApp} or
315
- * {@link angular.bootstrap} to simplify this process for you.
316
- *
317
- * @param {!string} name The name of the module to create or retrieve.
318
- * @param {!Array.<string>=} requires If specified then new module is being created. If
319
- * unspecified then the module is being retrieved for further configuration.
320
- * @param {Function=} configFn Optional configuration function for the module. Same as
321
- * {@link import('./types').Module#config Module#config()}.
322
- * @returns {import('./types').Module} new module with the {@link import('./types').Module} api.
323
- */
324
- module(name, requires, configFn) {
325
- const $injectorMinErr = minErr("$injector");
326
- let info = {};
327
-
328
- assertNotHasOwnProperty(name, "module");
329
- if (requires && Object.prototype.hasOwnProperty.call(moduleCache, name)) {
330
- moduleCache[name] = null;
331
- }
332
-
333
- function ensure(obj, name, factory) {
334
- return obj[name] || (obj[name] = factory());
335
- }
336
-
337
- return ensure(moduleCache, name, () => {
338
- if (!requires) {
339
- throw $injectorMinErr(
340
- "nomod",
341
- "Module '{0}' is not available! You either misspelled " +
342
- "the module name or forgot to load it. If registering a module ensure that you " +
343
- "specify the dependencies as the second argument.",
344
- name,
345
- );
346
- }
347
-
348
- /** @type {!Array.<Array.<*>>} */
349
- const invokeQueue = [];
350
-
351
- /** @type {!Array.<Function>} */
352
- const configBlocks = [];
353
-
354
- /** @type {!Array.<Function>} */
355
- const runBlocks = [];
356
-
357
- const config = invokeLater("$injector", "invoke", "push", configBlocks);
358
-
359
- /** @type {import('./types').Module} */
360
- const moduleInstance = {
361
- // Private state
362
-
363
- _invokeQueue: invokeQueue,
364
- _configBlocks: configBlocks,
365
- _runBlocks: runBlocks,
366
-
367
- /**
368
- * @ngdoc method
369
- * @name import('./types').Module#info
370
- * @module ng
371
- *
372
- * @param {Object=} value Information about the module
373
- * @returns {Object|import('./types').Module} The current info object for this module if called as a getter,
374
- * or `this` if called as a setter.
375
- *
376
- * @description
377
- * Read and write custom information about this module.
378
- * For example you could put the version of the module in here.
379
- *
380
- * ```js
381
- * angular.module('myModule', []).info({ version: '1.0.0' });
382
- * ```
383
- *
384
- * The version could then be read back out by accessing the module elsewhere:
385
- *
386
- * ```
387
- * let version = angular.module('myModule').info().version;
388
- * ```
389
- *
390
- * You can also retrieve this information during runtime via the
391
- * {@link $injector#modules `$injector.modules`} property:
392
- *
393
- * ```js
394
- * let version = $injector.modules['myModule'].info().version;
395
- * ```
396
- */
397
- info(value) {
398
- if (isDefined(value)) {
399
- if (!isObject(value))
400
- throw ngMinErr(
401
- "aobj",
402
- "Argument '{0}' must be an object",
403
- "value",
404
- );
405
- info = value;
406
- return this;
407
- }
408
- return info;
409
- },
410
-
411
- /**
412
- * @ngdoc property
413
- * @type import('./types').Module#requires
414
- * @module ng
415
- *
416
- * @description
417
- * Holds the list of modules which the injector will load before the current module is
418
- * loaded.
419
- */
420
- requires,
421
-
422
- /**
423
- * @ngdoc property
424
- * @name import('./types').Module#name
425
- * @module ng
426
- *
427
- * @description
428
- * Name of the module.
429
- */
430
- name,
431
-
432
- /**
433
- * @ngdoc method
434
- * @name import('./types').Module#provider
435
- * @module ng
436
- * @param {string} name service name
437
- * @param {Function} providerType Construction function for creating new instance of the
438
- * service.
439
- * @description
440
- * See {@link auto.$provide#provider $provide.provider()}.
441
- */
442
- provider: invokeLaterAndSetModuleName("$provide", "provider"),
443
-
444
- /**
445
- * @ngdoc method
446
- * @name import('./types').Module#factory
447
- * @module ng
448
- * @param {string} name service name
449
- * @param {Function} providerFunction Function for creating new instance of the service.
450
- * @description
451
- * See {@link auto.$provide#factory $provide.factory()}.
452
- */
453
- factory: invokeLaterAndSetModuleName("$provide", "factory"),
454
-
455
- /**
456
- * @ngdoc method
457
- * @name import('./types').Module#service
458
- * @module ng
459
- * @param {string} name service name
460
- * @param {Function} constructor A constructor function that will be instantiated.
461
- * @description
462
- * See {@link auto.$provide#service $provide.service()}.
463
- */
464
- service: invokeLaterAndSetModuleName("$provide", "service"),
465
-
466
- /**
467
- * @ngdoc method
468
- * @name import('./types').Module#value
469
- * @module ng
470
- * @param {string} name service name
471
- * @param {*} object Service instance object.
472
- * @description
473
- * See {@link auto.$provide#value $provide.value()}.
474
- */
475
- value: invokeLater("$provide", "value"),
476
-
477
- /**
478
- * @ngdoc method
479
- * @name import('./types').Module#constant
480
- * @module ng
481
- * @param {string} name constant name
482
- * @param {*} object Constant value.
483
- * @description
484
- * Because the constants are fixed, they get applied before other provide methods.
485
- * See {@link auto.$provide#constant $provide.constant()}.
486
- */
487
- constant: invokeLater("$provide", "constant", "unshift"),
488
-
489
- /**
490
- * @ngdoc method
491
- * @name import('./types').Module#decorator
492
- * @module ng
493
- * @param {string} name The name of the service to decorate.
494
- * @param {Function} decorFn This function will be invoked when the service needs to be
495
- * instantiated and should return the decorated service instance.
496
- * @description
497
- * See {@link auto.$provide#decorator $provide.decorator()}.
498
- */
499
- decorator: invokeLaterAndSetModuleName(
500
- "$provide",
501
- "decorator",
502
- configBlocks,
503
- ),
504
-
505
- /**
506
- * @ngdoc method
507
- * @name import('./types').Module#animation
508
- * @module ng
509
- * @param {string} name animation name
510
- * @param {Function} animationFactory Factory function for creating new instance of an
511
- * animation.
512
- * @description
513
- *
514
- * **NOTE**: animations take effect only if the **ngAnimate** module is loaded.
515
- *
516
- *
517
- * Defines an animation hook that can be later used with
518
- * {@link $animate $animate} service and directives that use this service.
519
- *
520
- * ```js
521
- * module.animation('.animation-name', function($inject1, $inject2) {
522
- * return {
523
- * eventName : function(element, done) {
524
- * //code to run the animation
525
- * //once complete, then run done()
526
- * return function cancellationFunction(element) {
527
- * //code to cancel the animation
528
- * }
529
- * }
530
- * }
531
- * })
532
- * ```
533
- *
534
- * See {@link ng.$animateProvider#register $animateProvider.register()} and
535
- * {@link ngAnimate ngAnimate module} for more information.
536
- */
537
- animation: invokeLaterAndSetModuleName("$animateProvider", "register"),
538
-
539
- /**
540
- * @ngdoc method
541
- * @name import('./types').Module#filter
542
- * @module ng
543
- * @param {string} name Filter name - this must be a valid AngularJS expression identifier
544
- * @param {Function} filterFactory Factory function for creating new instance of filter.
545
- * @description
546
- * See {@link ng.$filterProvider#register $filterProvider.register()}.
547
- *
548
- * <div class="alert alert-warning">
549
- * **Note:** Filter names must be valid AngularJS {@link expression} identifiers, such as `uppercase` or `orderBy`.
550
- * Names with special characters, such as hyphens and dots, are not allowed. If you wish to namespace
551
- * your filters, then you can use capitalization (`myappSubsectionFilterx`) or underscores
552
- * (`myapp_subsection_filterx`).
553
- * </div>
554
- */
555
- filter: invokeLaterAndSetModuleName("$filterProvider", "register"),
556
-
557
- /**
558
- * @ngdoc method
559
- * @name import('./types').Module#controller
560
- * @module ng
561
- * @param {string|Object} name Controller name, or an object map of controllers where the
562
- * keys are the names and the values are the constructors.
563
- * @param {Function} constructor Controller constructor function.
564
- * @description
565
- * See {@link ng.$controllerProvider#register $controllerProvider.register()}.
566
- */
567
- controller: invokeLaterAndSetModuleName(
568
- "$controllerProvider",
569
- "register",
570
- ),
571
-
572
- /**
573
- * @ngdoc method
574
- * @name import('./types').Module#directive
575
- * @module ng
576
- * @param {string|Object} name Directive name, or an object map of directives where the
577
- * keys are the names and the values are the factories.
578
- * @param {Function} directiveFactory Factory function for creating new instance of
579
- * directives.
580
- * @description
581
- * See {@link ng.$compileProvider#directive $compileProvider.directive()}.
582
- */
583
- directive: invokeLaterAndSetModuleName("$compileProvider", "directive"),
584
-
585
- /**
586
- * @ngdoc method
587
- * @name import('./types').Module#component
588
- * @module ng
589
- * @param {string|Object} name Name of the component in camelCase (i.e. `myComp` which will match `<my-comp>`),
590
- * or an object map of components where the keys are the names and the values are the component definition objects.
591
- * @param {Object} options Component definition object (a simplified
592
- * {@link ng.$compile#directive-definition-object directive definition object})
593
- *
594
- * @description
595
- * See {@link ng.$compileProvider#component $compileProvider.component()}.
596
- */
597
- component: invokeLaterAndSetModuleName("$compileProvider", "component"),
598
-
599
- /**
600
- * @ngdoc method
601
- * @name import('./types').Module#config
602
- * @module ng
603
- * @param {Function} configFn Execute this function on module load. Useful for service
604
- * configuration.
605
- * @description
606
- * Use this method to configure services by injecting their
607
- * {@link import('./types').Module#provider `providers`}, e.g. for adding routes to the
608
- * {@link ngRoute.$routeProvider $routeProvider}.
609
- *
610
- * Note that you can only inject {@link import('./types').Module#provider `providers`} and
611
- * {@link import('./types').Module#constant `constants`} into this function.
612
- *
613
- * For more about how to configure services, see
614
- * {@link providers#provider-recipe Provider Recipe}.
615
- */
616
- config,
617
-
618
- /**
619
- * @ngdoc method
620
- * @name import('./types').Module#run
621
- * @module ng
622
- * @param {Function} initializationFn Execute this function after injector creation.
623
- * Useful for application initialization.
624
- * @description
625
- * Use this method to register work which should be performed when the injector is done
626
- * loading all modules.
627
- */
628
- run(block) {
629
- runBlocks.push(block);
630
- return this;
631
- },
632
- };
633
-
634
- if (configFn) {
635
- config(configFn);
636
- }
637
-
638
- return moduleInstance;
639
-
640
- /**
641
- * @param {string} provider
642
- * @param {string} method
643
- * @param {String=} insertMethod
644
- * @returns {import('./types').Module}
645
- */
646
- function invokeLater(provider, method, insertMethod, queue) {
647
- if (!queue) queue = invokeQueue;
648
- return function () {
649
- queue[insertMethod || "push"]([provider, method, arguments]);
650
- return moduleInstance;
651
- };
652
- }
653
-
654
- /**
655
- * @param {string} provider
656
- * @param {string} method
657
- * @returns {import('./types').Module}
658
- */
659
- function invokeLaterAndSetModuleName(provider, method, queue) {
660
- if (!queue) queue = invokeQueue;
661
- return function (recipeName, factoryFunction) {
662
- if (factoryFunction && isFunction(factoryFunction))
663
- factoryFunction.$$moduleName = name;
664
- queue.push([provider, method, arguments]);
665
- return moduleInstance;
666
- };
667
- }
668
- });
669
- }
670
-
671
201
  /**
672
202
  * @module angular
673
203
  * @function reloadWithDebugInfo
@@ -827,6 +357,10 @@ export class Angular {
827
357
  </file>
828
358
  </example>
829
359
  */
360
+
361
+ /**
362
+ * @param {Element|Document} element
363
+ */
830
364
  export function angularInit(element) {
831
365
  let appElement;
832
366
  let module;
@@ -854,15 +388,7 @@ export function angularInit(element) {
854
388
  }
855
389
  });
856
390
  if (appElement) {
857
- // Angular init is called manually, so why is this check here
858
- // if (!confGlobal.isAutoBootstrapAllowed) {
859
- // window.console.error(
860
- // "AngularJS: disabling automatic bootstrap. <script> protocol indicates an extension, document.location.href does not match.",
861
- // );
862
- // return;
863
- // }
864
391
  config.strictDi = getNgAttribute(appElement, "strict-di") !== null;
865
- //TODO maybe angular should be initialized here?
866
392
  window["angular"].bootstrap(appElement, module ? [module] : [], config);
867
393
  }
868
394
  }
@@ -891,57 +417,6 @@ export function setupModuleLoader(window) {
891
417
  /** @type {Object.<string, import('./types').Module>} */
892
418
  const modules = {};
893
419
 
894
- /**
895
- * @ngdoc function
896
- * @name angular.module
897
- * @module ng
898
- * @description
899
- *
900
- * The `angular.module` is a global place for creating, registering and retrieving AngularJS
901
- * modules.
902
- * All modules (AngularJS core or 3rd party) that should be available to an application must be
903
- * registered using this mechanism.
904
- *
905
- * Passing one argument retrieves an existing {@link import('./types').Module},
906
- * whereas passing more than one argument creates a new {@link import('./types').Module}
907
- *
908
- *
909
- * # Module
910
- *
911
- * A module is a collection of services, directives, controllers, filters, and configuration information.
912
- * `angular.module` is used to configure the {@link auto.$injector $injector}.
913
- *
914
- * ```js
915
- * // Create a new module
916
- * let myModule = angular.module('myModule', []);
917
- *
918
- * // register a new service
919
- * myModule.value('appName', 'MyCoolApp');
920
- *
921
- * // configure existing services inside initialization blocks.
922
- * myModule.config(['$locationProvider', function($locationProvider) {
923
- * // Configure existing providers
924
- * $locationProvider.hashPrefix('!');
925
- * }]);
926
- * ```
927
- *
928
- * Then you can create an injector and load your modules like this:
929
- *
930
- * ```js
931
- * let injector = angular.injector(['ng', 'myModule'])
932
- * ```
933
- *
934
- * However it's more likely that you'll just use
935
- * {@link ng.directive:ngApp ngApp} or
936
- * {@link angular.bootstrap} to simplify this process for you.
937
- *
938
- * @param {!string} name The name of the module to create or retrieve.
939
- * @param {!Array.<string>=} requires If specified then new module is being created. If
940
- * unspecified then the module is being retrieved for further configuration.
941
- * @param {Function=} configFn Optional configuration function for the module. Same as
942
- * {@link import('./types').Module#config Module#config()}.
943
- * @returns {import('./types').Module} new module with the {@link import('./types').Module} api.
944
- */
945
420
  return function module(name, requires, configFn) {
946
421
  let info = {};
947
422
 
@@ -979,15 +454,13 @@ export function setupModuleLoader(window) {
979
454
  _runBlocks: runBlocks,
980
455
 
981
456
  /**
982
- * @ngdoc method
983
457
  * @name import('./types').Module#info
984
458
  * @module ng
985
459
  *
986
- * @param {Object=} info Information about the module
460
+ * @param {Object=} value Information about the module
987
461
  * @returns {Object|import('./types').Module} The current info object for this module if called as a getter,
988
462
  * or `this` if called as a setter.
989
463
  *
990
- * @description
991
464
  * Read and write custom information about this module.
992
465
  * For example you could put the version of the module in here.
993
466
  *
@@ -1027,7 +500,6 @@ export function setupModuleLoader(window) {
1027
500
  * @name import('./types').Module#requires
1028
501
  * @module ng
1029
502
  *
1030
- * @description
1031
503
  * Holds the list of modules which the injector will load before the current module is
1032
504
  * loaded.
1033
505
  */
@@ -1038,76 +510,57 @@ export function setupModuleLoader(window) {
1038
510
  * @name import('./types').Module#name
1039
511
  * @module ng
1040
512
  *
1041
- * @description
1042
513
  * Name of the module.
1043
514
  */
1044
515
  name,
1045
516
 
1046
517
  /**
1047
- * @ngdoc method
1048
518
  * @name import('./types').Module#provider
1049
- * @module ng
1050
519
  * @param {string} name service name
1051
520
  * @param {Function} providerType Construction function for creating new instance of the
1052
521
  * service.
1053
- * @description
1054
522
  * See {@link auto.$provide#provider $provide.provider()}.
1055
523
  */
1056
524
  provider: invokeLaterAndSetModuleName("$provide", "provider"),
1057
525
 
1058
526
  /**
1059
- * @ngdoc method
1060
527
  * @name import('./types').Module#factory
1061
- * @module ng
1062
528
  * @param {string} name service name
1063
529
  * @param {Function} providerFunction Function for creating new instance of the service.
1064
- * @description
1065
530
  * See {@link auto.$provide#factory $provide.factory()}.
1066
531
  */
1067
532
  factory: invokeLaterAndSetModuleName("$provide", "factory"),
1068
533
 
1069
534
  /**
1070
- * @ngdoc method
1071
535
  * @name import('./types').Module#service
1072
- * @module ng
1073
536
  * @param {string} name service name
1074
537
  * @param {Function} constructor A constructor function that will be instantiated.
1075
- * @description
1076
538
  * See {@link auto.$provide#service $provide.service()}.
1077
539
  */
1078
540
  service: invokeLaterAndSetModuleName("$provide", "service"),
1079
541
 
1080
542
  /**
1081
- * @ngdoc method
1082
543
  * @name import('./types').Module#value
1083
- * @module ng
1084
544
  * @param {string} name service name
1085
545
  * @param {*} object Service instance object.
1086
- * @description
1087
546
  * See {@link auto.$provide#value $provide.value()}.
1088
547
  */
1089
548
  value: invokeLater("$provide", "value"),
1090
549
 
1091
550
  /**
1092
- * @ngdoc method
1093
551
  * @name import('./types').Module#constant
1094
- * @module ng
1095
552
  * @param {string} name constant name
1096
553
  * @param {*} object Constant value.
1097
- * @description
1098
554
  * Because the constants are fixed, they get applied before other provide methods.
1099
555
  * See {@link auto.$provide#constant $provide.constant()}.
1100
556
  */
1101
557
  constant: invokeLater("$provide", "constant", "unshift"),
1102
558
 
1103
559
  /**
1104
- * @ngdoc method
1105
560
  * @name import('./types').Module#decorator
1106
- * @module ng
1107
561
  * @param {string} name The name of the service to decorate.
1108
562
  * @param {Function} decorFn This function will be invoked when the service needs to be
1109
563
  * instantiated and should return the decorated service instance.
1110
- * @description
1111
564
  * See {@link auto.$provide#decorator $provide.decorator()}.
1112
565
  */
1113
566
  decorator: invokeLaterAndSetModuleName(
@@ -1117,13 +570,10 @@ export function setupModuleLoader(window) {
1117
570
  ),
1118
571
 
1119
572
  /**
1120
- * @ngdoc method
1121
573
  * @name import('./types').Module#animation
1122
- * @module ng
1123
574
  * @param {string} name animation name
1124
575
  * @param {Function} animationFactory Factory function for creating new instance of an
1125
576
  * animation.
1126
- * @description
1127
577
  *
1128
578
  * **NOTE**: animations take effect only if the **ngAnimate** module is loaded.
1129
579
  *
@@ -1154,12 +604,9 @@ export function setupModuleLoader(window) {
1154
604
  ),
1155
605
 
1156
606
  /**
1157
- * @ngdoc method
1158
607
  * @name import('./types').Module#filter
1159
- * @module ng
1160
608
  * @param {string} name Filter name - this must be a valid AngularJS expression identifier
1161
609
  * @param {Function} filterFactory Factory function for creating new instance of filter.
1162
- * @description
1163
610
  * See {@link ng.$filterProvider#register $filterProvider.register()}.
1164
611
  *
1165
612
  * <div class="alert alert-warning">
@@ -1172,13 +619,10 @@ export function setupModuleLoader(window) {
1172
619
  filter: invokeLaterAndSetModuleName("$filterProvider", "register"),
1173
620
 
1174
621
  /**
1175
- * @ngdoc method
1176
622
  * @name import('./types').Module#controller
1177
- * @module ng
1178
623
  * @param {string|Object} name Controller name, or an object map of controllers where the
1179
624
  * keys are the names and the values are the constructors.
1180
625
  * @param {Function} constructor Controller constructor function.
1181
- * @description
1182
626
  * See {@link ng.$controllerProvider#register $controllerProvider.register()}.
1183
627
  */
1184
628
  controller: invokeLaterAndSetModuleName(
@@ -1187,14 +631,11 @@ export function setupModuleLoader(window) {
1187
631
  ),
1188
632
 
1189
633
  /**
1190
- * @ngdoc method
1191
634
  * @name import('./types').Module#directive
1192
- * @module ng
1193
635
  * @param {string|Object} name Directive name, or an object map of directives where the
1194
636
  * keys are the names and the values are the factories.
1195
637
  * @param {Function} directiveFactory Factory function for creating new instance of
1196
638
  * directives.
1197
- * @description
1198
639
  * See {@link ng.$compileProvider#directive $compileProvider.directive()}.
1199
640
  */
1200
641
  directive: invokeLaterAndSetModuleName(
@@ -1203,15 +644,12 @@ export function setupModuleLoader(window) {
1203
644
  ),
1204
645
 
1205
646
  /**
1206
- * @ngdoc method
1207
647
  * @name import('./types').Module#component
1208
- * @module ng
1209
648
  * @param {string|Object} name Name of the component in camelCase (i.e. `myComp` which will match `<my-comp>`),
1210
649
  * or an object map of components where the keys are the names and the values are the component definition objects.
1211
650
  * @param {Object} options Component definition object (a simplified
1212
651
  * {@link ng.$compile#directive-definition-object directive definition object})
1213
652
  *
1214
- * @description
1215
653
  * See {@link ng.$compileProvider#component $compileProvider.component()}.
1216
654
  */
1217
655
  component: invokeLaterAndSetModuleName(
@@ -1220,12 +658,9 @@ export function setupModuleLoader(window) {
1220
658
  ),
1221
659
 
1222
660
  /**
1223
- * @ngdoc method
1224
661
  * @name import('./types').Module#config
1225
- * @module ng
1226
662
  * @param {Function} configFn Execute this function on module load. Useful for service
1227
663
  * configuration.
1228
- * @description
1229
664
  * Use this method to configure services by injecting their
1230
665
  * {@link import('./types').Module#provider `providers`}, e.g. for adding routes to the
1231
666
  * {@link ngRoute.$routeProvider $routeProvider}.
@@ -1239,12 +674,9 @@ export function setupModuleLoader(window) {
1239
674
  config,
1240
675
 
1241
676
  /**
1242
- * @ngdoc method
1243
677
  * @name import('./types').Module#run
1244
- * @module ng
1245
- * @param {Function} initializationFn Execute this function after injector creation.
678
+ * @param {Function} block Execute this function after injector creation.
1246
679
  * Useful for application initialization.
1247
- * @description
1248
680
  * Use this method to register work which should be performed when the injector is done
1249
681
  * loading all modules.
1250
682
  */
@@ -1263,7 +695,8 @@ export function setupModuleLoader(window) {
1263
695
  /**
1264
696
  * @param {string} provider
1265
697
  * @param {string} method
1266
- * @param {String=} insertMethod
698
+ * @param {String=} [insertMethod]
699
+ * @param {Array<any>} [queue]
1267
700
  * @returns {import('./types').Module}
1268
701
  */
1269
702
  function invokeLater(provider, method, insertMethod, queue) {
@@ -1292,47 +725,3 @@ export function setupModuleLoader(window) {
1292
725
  };
1293
726
  });
1294
727
  }
1295
-
1296
- /**
1297
- * @ngdoc function
1298
- * @name angular.errorHandlingConfig
1299
- * @module ng
1300
- * @kind function
1301
- *
1302
- * @description
1303
- * Configure several aspects of error handling in AngularJS if used as a setter or return the
1304
- * current configuration if used as a getter. The following options are supported:
1305
- *
1306
- * - **objectMaxDepth**: The maximum depth to which objects are traversed when stringified for error messages.
1307
- *
1308
- * Omitted or undefined options will leave the corresponding configuration values unchanged.
1309
- *
1310
- * @param {Object=} config - The configuration object. May only contain the options that need to be
1311
- * updated. Supported keys:
1312
- *
1313
- * * `objectMaxDepth` **{Number}** - The max depth for stringifying objects. Setting to a
1314
- * non-positive or non-numeric value, removes the max depth limit.
1315
- * Default: 5
1316
- *
1317
- * * `urlErrorParamsEnabled` **{Boolean}** - Specifies whether the generated error url will
1318
- * contain the parameters of the thrown error. Disabling the parameters can be useful if the
1319
- * generated error url is very long.
1320
- *
1321
- * Default: true. When used without argument, it returns the current value.
1322
- */
1323
- export function errorHandlingConfig(config) {
1324
- if (isObject(config)) {
1325
- if (isDefined(config.objectMaxDepth)) {
1326
- minErrConfig.objectMaxDepth = isValidObjectMaxDepth(config.objectMaxDepth)
1327
- ? config.objectMaxDepth
1328
- : NaN;
1329
- }
1330
- if (
1331
- isDefined(config.urlErrorParamsEnabled) &&
1332
- isBoolean(config.urlErrorParamsEnabled)
1333
- ) {
1334
- minErrConfig.urlErrorParamsEnabled = config.urlErrorParamsEnabled;
1335
- }
1336
- }
1337
- return minErrConfig;
1338
- }