@angular-wave/angular.ts 0.0.1

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 (231) hide show
  1. package/.eslintignore +1 -0
  2. package/.eslintrc.cjs +29 -0
  3. package/.github/workflows/playwright.yml +27 -0
  4. package/CHANGELOG.md +17974 -0
  5. package/CODE_OF_CONDUCT.md +3 -0
  6. package/CONTRIBUTING.md +246 -0
  7. package/DEVELOPERS.md +488 -0
  8. package/LICENSE +22 -0
  9. package/Makefile +31 -0
  10. package/README.md +115 -0
  11. package/RELEASE.md +98 -0
  12. package/SECURITY.md +16 -0
  13. package/TRIAGING.md +135 -0
  14. package/css/angular.css +22 -0
  15. package/dist/angular-ts.cjs.js +36843 -0
  16. package/dist/angular-ts.esm.js +36841 -0
  17. package/dist/angular-ts.umd.js +36848 -0
  18. package/dist/build/angular-animate.js +4272 -0
  19. package/dist/build/angular-aria.js +426 -0
  20. package/dist/build/angular-message-format.js +1072 -0
  21. package/dist/build/angular-messages.js +829 -0
  22. package/dist/build/angular-mocks.js +3757 -0
  23. package/dist/build/angular-parse-ext.js +1275 -0
  24. package/dist/build/angular-resource.js +911 -0
  25. package/dist/build/angular-route.js +1266 -0
  26. package/dist/build/angular-sanitize.js +891 -0
  27. package/dist/build/angular-touch.js +368 -0
  28. package/dist/build/angular.js +36600 -0
  29. package/e2e/unit.spec.ts +15 -0
  30. package/images/android-chrome-192x192.png +0 -0
  31. package/images/android-chrome-512x512.png +0 -0
  32. package/images/apple-touch-icon.png +0 -0
  33. package/images/favicon-16x16.png +0 -0
  34. package/images/favicon-32x32.png +0 -0
  35. package/images/favicon.ico +0 -0
  36. package/images/site.webmanifest +1 -0
  37. package/index.html +104 -0
  38. package/package.json +47 -0
  39. package/playwright.config.ts +78 -0
  40. package/public/circle.html +1 -0
  41. package/public/my_child_directive.html +1 -0
  42. package/public/my_directive.html +1 -0
  43. package/public/my_other_directive.html +1 -0
  44. package/public/test.html +1 -0
  45. package/rollup.config.js +31 -0
  46. package/src/animations/animateCache.js +55 -0
  47. package/src/animations/animateChildrenDirective.js +105 -0
  48. package/src/animations/animateCss.js +1139 -0
  49. package/src/animations/animateCssDriver.js +291 -0
  50. package/src/animations/animateJs.js +367 -0
  51. package/src/animations/animateJsDriver.js +67 -0
  52. package/src/animations/animateQueue.js +851 -0
  53. package/src/animations/animation.js +506 -0
  54. package/src/animations/module.js +779 -0
  55. package/src/animations/ngAnimateSwap.js +119 -0
  56. package/src/animations/rafScheduler.js +50 -0
  57. package/src/animations/shared.js +378 -0
  58. package/src/constants.js +20 -0
  59. package/src/core/animate.js +845 -0
  60. package/src/core/animateCss.js +73 -0
  61. package/src/core/animateRunner.js +195 -0
  62. package/src/core/attributes.js +199 -0
  63. package/src/core/cache.js +45 -0
  64. package/src/core/compile.js +4727 -0
  65. package/src/core/controller.js +225 -0
  66. package/src/core/exceptionHandler.js +63 -0
  67. package/src/core/filter.js +146 -0
  68. package/src/core/interpolate.js +442 -0
  69. package/src/core/interval.js +188 -0
  70. package/src/core/intervalFactory.js +57 -0
  71. package/src/core/location.js +1086 -0
  72. package/src/core/parser/parse.js +2562 -0
  73. package/src/core/parser/parse.md +13 -0
  74. package/src/core/q.js +746 -0
  75. package/src/core/rootScope.js +1596 -0
  76. package/src/core/sanitizeUri.js +85 -0
  77. package/src/core/sce.js +1161 -0
  78. package/src/core/taskTrackerFactory.js +125 -0
  79. package/src/core/timeout.js +121 -0
  80. package/src/core/urlUtils.js +187 -0
  81. package/src/core/utils.js +1349 -0
  82. package/src/directive/a.js +37 -0
  83. package/src/directive/attrs.js +283 -0
  84. package/src/directive/bind.js +51 -0
  85. package/src/directive/bind.md +142 -0
  86. package/src/directive/change.js +12 -0
  87. package/src/directive/change.md +25 -0
  88. package/src/directive/cloak.js +12 -0
  89. package/src/directive/cloak.md +24 -0
  90. package/src/directive/events.js +75 -0
  91. package/src/directive/events.md +166 -0
  92. package/src/directive/form.js +725 -0
  93. package/src/directive/init.js +15 -0
  94. package/src/directive/init.md +41 -0
  95. package/src/directive/input.js +1783 -0
  96. package/src/directive/list.js +46 -0
  97. package/src/directive/list.md +22 -0
  98. package/src/directive/ngClass.js +249 -0
  99. package/src/directive/ngController.js +64 -0
  100. package/src/directive/ngCsp.js +82 -0
  101. package/src/directive/ngIf.js +134 -0
  102. package/src/directive/ngInclude.js +217 -0
  103. package/src/directive/ngModel.js +1356 -0
  104. package/src/directive/ngModelOptions.js +509 -0
  105. package/src/directive/ngOptions.js +670 -0
  106. package/src/directive/ngRef.js +90 -0
  107. package/src/directive/ngRepeat.js +650 -0
  108. package/src/directive/ngShowHide.js +255 -0
  109. package/src/directive/ngSwitch.js +178 -0
  110. package/src/directive/ngTransclude.js +98 -0
  111. package/src/directive/non-bindable.js +11 -0
  112. package/src/directive/non-bindable.md +17 -0
  113. package/src/directive/script.js +30 -0
  114. package/src/directive/select.js +624 -0
  115. package/src/directive/style.js +25 -0
  116. package/src/directive/style.md +23 -0
  117. package/src/directive/validators.js +329 -0
  118. package/src/exts/aria.js +544 -0
  119. package/src/exts/messages.js +852 -0
  120. package/src/filters/filter.js +207 -0
  121. package/src/filters/filter.md +69 -0
  122. package/src/filters/filters.js +239 -0
  123. package/src/filters/json.md +16 -0
  124. package/src/filters/limit-to.js +43 -0
  125. package/src/filters/limit-to.md +19 -0
  126. package/src/filters/order-by.js +183 -0
  127. package/src/filters/order-by.md +83 -0
  128. package/src/index.js +13 -0
  129. package/src/injector.js +1034 -0
  130. package/src/jqLite.js +1117 -0
  131. package/src/loader.js +1320 -0
  132. package/src/public.js +215 -0
  133. package/src/routeToRegExp.js +41 -0
  134. package/src/services/anchorScroll.js +135 -0
  135. package/src/services/browser.js +321 -0
  136. package/src/services/cacheFactory.js +398 -0
  137. package/src/services/cookieReader.js +72 -0
  138. package/src/services/document.js +64 -0
  139. package/src/services/http.js +1537 -0
  140. package/src/services/httpBackend.js +206 -0
  141. package/src/services/log.js +160 -0
  142. package/src/services/templateRequest.js +139 -0
  143. package/test/angular.spec.js +2153 -0
  144. package/test/aria/aria.spec.js +1245 -0
  145. package/test/binding.spec.js +504 -0
  146. package/test/build-test.html +14 -0
  147. package/test/injector.spec.js +2327 -0
  148. package/test/jasmine/jasmine-5.1.2/boot0.js +65 -0
  149. package/test/jasmine/jasmine-5.1.2/boot1.js +133 -0
  150. package/test/jasmine/jasmine-5.1.2/jasmine-html.js +963 -0
  151. package/test/jasmine/jasmine-5.1.2/jasmine.css +320 -0
  152. package/test/jasmine/jasmine-5.1.2/jasmine.js +10824 -0
  153. package/test/jasmine/jasmine-5.1.2/jasmine_favicon.png +0 -0
  154. package/test/jasmine/jasmine-browser.json +17 -0
  155. package/test/jasmine/jasmine.json +9 -0
  156. package/test/jqlite.spec.js +2133 -0
  157. package/test/loader.spec.js +219 -0
  158. package/test/messages/messages.spec.js +1146 -0
  159. package/test/min-err.spec.js +174 -0
  160. package/test/mock-test.html +13 -0
  161. package/test/module-test.html +15 -0
  162. package/test/ng/anomate.spec.js +606 -0
  163. package/test/ng/cache-factor.spec.js +334 -0
  164. package/test/ng/compile.spec.js +17956 -0
  165. package/test/ng/controller-provider.spec.js +227 -0
  166. package/test/ng/cookie-reader.spec.js +98 -0
  167. package/test/ng/directive/a.spec.js +192 -0
  168. package/test/ng/directive/bind.spec.js +334 -0
  169. package/test/ng/directive/boolean.spec.js +136 -0
  170. package/test/ng/directive/change.spec.js +71 -0
  171. package/test/ng/directive/class.spec.js +858 -0
  172. package/test/ng/directive/click.spec.js +38 -0
  173. package/test/ng/directive/cloak.spec.js +44 -0
  174. package/test/ng/directive/constoller.spec.js +194 -0
  175. package/test/ng/directive/element-style.spec.js +92 -0
  176. package/test/ng/directive/event.spec.js +282 -0
  177. package/test/ng/directive/form.spec.js +1518 -0
  178. package/test/ng/directive/href.spec.js +143 -0
  179. package/test/ng/directive/if.spec.js +402 -0
  180. package/test/ng/directive/include.spec.js +828 -0
  181. package/test/ng/directive/init.spec.js +68 -0
  182. package/test/ng/directive/input.spec.js +3810 -0
  183. package/test/ng/directive/list.spec.js +170 -0
  184. package/test/ng/directive/model-options.spec.js +1008 -0
  185. package/test/ng/directive/model.spec.js +1905 -0
  186. package/test/ng/directive/non-bindable.spec.js +55 -0
  187. package/test/ng/directive/options.spec.js +3583 -0
  188. package/test/ng/directive/ref.spec.js +575 -0
  189. package/test/ng/directive/repeat.spec.js +1675 -0
  190. package/test/ng/directive/script.spec.js +52 -0
  191. package/test/ng/directive/scrset.spec.js +67 -0
  192. package/test/ng/directive/select.spec.js +2541 -0
  193. package/test/ng/directive/show-hide.spec.js +253 -0
  194. package/test/ng/directive/src.spec.js +157 -0
  195. package/test/ng/directive/style.spec.js +178 -0
  196. package/test/ng/directive/switch.spec.js +647 -0
  197. package/test/ng/directive/validators.spec.js +717 -0
  198. package/test/ng/document.spec.js +52 -0
  199. package/test/ng/filter/filter.spec.js +714 -0
  200. package/test/ng/filter/filters.spec.js +35 -0
  201. package/test/ng/filter/limit-to.spec.js +251 -0
  202. package/test/ng/filter/order-by.spec.js +891 -0
  203. package/test/ng/filter.spec.js +149 -0
  204. package/test/ng/http-backend.spec.js +398 -0
  205. package/test/ng/http.spec.js +4071 -0
  206. package/test/ng/interpolate.spec.js +642 -0
  207. package/test/ng/interval.spec.js +343 -0
  208. package/test/ng/location.spec.js +3488 -0
  209. package/test/ng/on.spec.js +229 -0
  210. package/test/ng/parse.spec.js +4655 -0
  211. package/test/ng/prop.spec.js +805 -0
  212. package/test/ng/q.spec.js +2904 -0
  213. package/test/ng/root-element.spec.js +16 -0
  214. package/test/ng/sanitize-uri.spec.js +249 -0
  215. package/test/ng/sce.spec.js +660 -0
  216. package/test/ng/scope.spec.js +3442 -0
  217. package/test/ng/template-request.spec.js +236 -0
  218. package/test/ng/timeout.spec.js +351 -0
  219. package/test/ng/url-utils.spec.js +156 -0
  220. package/test/ng/utils.spec.js +144 -0
  221. package/test/original-test.html +21 -0
  222. package/test/public.spec.js +34 -0
  223. package/test/sanitize/bing-html.spec.js +36 -0
  224. package/test/server/express.js +158 -0
  225. package/test/test-utils.js +11 -0
  226. package/tsconfig.json +17 -0
  227. package/types/angular.d.ts +138 -0
  228. package/types/global.d.ts +9 -0
  229. package/types/index.d.ts +2357 -0
  230. package/types/jqlite.d.ts +558 -0
  231. package/vite.config.js +14 -0
@@ -0,0 +1,1034 @@
1
+ import {
2
+ assertArgFn,
3
+ minErr,
4
+ forEach,
5
+ isArray,
6
+ isFunction,
7
+ isString,
8
+ createMap,
9
+ isBoolean,
10
+ isUndefined,
11
+ assertArg,
12
+ valueFn,
13
+ assertNotHasOwnProperty,
14
+ reverseParams,
15
+ isObject,
16
+ isDefined,
17
+ } from "./core/utils";
18
+
19
+ /**
20
+ * @ngdoc function
21
+ * @module ng
22
+ * @name angular.injector
23
+ * @kind function
24
+ *
25
+ * @description
26
+ * Creates an injector object that can be used for retrieving services as well as for
27
+ * dependency injection (see {@link guide/di dependency injection}).
28
+ *
29
+ * @param {Array.<string|Function>} modules A list of module functions or their aliases. See
30
+ * {@link angular.module}. The `ng` module must be explicitly added.
31
+ * @param {boolean=} [strictDi=false] Whether the injector should be in strict mode, which
32
+ * disallows argument name annotation inference.
33
+ * @returns {injector} Injector object. See {@link auto.$injector $injector}.
34
+ *
35
+ * @example
36
+ * Typical usage
37
+ * ```js
38
+ * // create an injector
39
+ * var $injector = angular.injector(['ng']);
40
+ *
41
+ * // use the injector to kick off your application
42
+ * // use the type inference to auto inject arguments, or use implicit injection
43
+ * $injector.invoke(function($rootScope, $compile, $document) {
44
+ * $compile($document)($rootScope);
45
+ * $rootScope.$digest();
46
+ * });
47
+ * ```
48
+ *
49
+ * Sometimes you want to get access to the injector of a currently running AngularJS app
50
+ * from outside AngularJS. Perhaps, you want to inject and compile some markup after the
51
+ * application has been bootstrapped. You can do this using the extra `injector()` added
52
+ * to JQuery/jqLite elements. See {@link angular.element}.
53
+ *
54
+ * *This is fairly rare but could be the case if a third party library is injecting the
55
+ * markup.*
56
+ *
57
+ * In the following example a new block of HTML containing a `ng-controller`
58
+ * directive is added to the end of the document body by JQuery. We then compile and link
59
+ * it into the current AngularJS scope.
60
+ *
61
+ * ```js
62
+ * var $div = $('<div ng-controller="MyCtrl">{{content.label}}</div>');
63
+ * $(document.body).append($div);
64
+ *
65
+ * angular.element(document).injector().invoke(function($compile) {
66
+ * var scope = angular.element($div).scope();
67
+ * $compile($div)(scope);
68
+ * });
69
+ * ```
70
+ */
71
+
72
+ /**
73
+ * @ngdoc module
74
+ * @name auto
75
+ * @installation
76
+ * @description
77
+ *
78
+ * Implicit module which gets automatically added to each {@link auto.$injector $injector}.
79
+ */
80
+
81
+ var ARROW_ARG = /^([^(]+?)=>/;
82
+ var FN_ARGS = /^[^(]*\(\s*([^)]*)\)/m;
83
+ var FN_ARG_SPLIT = /,/;
84
+ var FN_ARG = /^\s*(_?)(\S+?)\1\s*$/;
85
+ var STRIP_COMMENTS = /((\/\/.*$)|(\/\*[\s\S]*?\*\/))/gm;
86
+ var $injectorMinErr = minErr("$injector");
87
+
88
+ function stringifyFn(fn) {
89
+ return Function.prototype.toString.call(fn);
90
+ }
91
+
92
+ function extractArgs(fn) {
93
+ var fnText = stringifyFn(fn).replace(STRIP_COMMENTS, ""),
94
+ args = fnText.match(ARROW_ARG) || fnText.match(FN_ARGS);
95
+ return args;
96
+ }
97
+
98
+ function anonFn(fn) {
99
+ // For anonymous functions, showing at the very least the function signature can help in
100
+ // debugging.
101
+ var args = extractArgs(fn);
102
+ if (args) {
103
+ return "function(" + (args[1] || "").replace(/[\s\r\n]+/, " ") + ")";
104
+ }
105
+ return "fn";
106
+ }
107
+
108
+ function annotate(fn, strictDi, name) {
109
+ var $inject, argDecl, last;
110
+
111
+ if (typeof fn === "function") {
112
+ if (!($inject = fn.$inject)) {
113
+ $inject = [];
114
+ if (fn.length) {
115
+ if (strictDi) {
116
+ if (!isString(name) || !name) {
117
+ name = fn.name || anonFn(fn);
118
+ }
119
+ throw $injectorMinErr(
120
+ "strictdi",
121
+ "{0} is not using explicit annotation and cannot be invoked in strict mode",
122
+ name,
123
+ );
124
+ }
125
+ argDecl = extractArgs(fn);
126
+ forEach(argDecl[1].split(FN_ARG_SPLIT), function (arg) {
127
+ arg.replace(FN_ARG, function (all, underscore, name) {
128
+ $inject.push(name);
129
+ });
130
+ });
131
+ }
132
+ fn.$inject = $inject;
133
+ }
134
+ } else if (isArray(fn)) {
135
+ last = fn.length - 1;
136
+ assertArgFn(fn[last], "fn");
137
+ $inject = fn.slice(0, last);
138
+ } else {
139
+ assertArgFn(fn, "fn", true);
140
+ }
141
+ return $inject;
142
+ }
143
+
144
+ ///////////////////////////////////////
145
+
146
+ /**
147
+ * @ngdoc service
148
+ * @name $injector
149
+ *
150
+ * @description
151
+ *
152
+ * `$injector` is used to retrieve object instances as defined by
153
+ * {@link auto.$provide provider}, instantiate types, invoke methods,
154
+ * and load modules.
155
+ *
156
+ * The following always holds true:
157
+ *
158
+ * ```js
159
+ * var $injector = angular.injector();
160
+ * expect($injector.get('$injector')).toBe($injector);
161
+ * expect($injector.invoke(function($injector) {
162
+ * return $injector;
163
+ * })).toBe($injector);
164
+ * ```
165
+ *
166
+ * ## Injection Function Annotation
167
+ *
168
+ * JavaScript does not have annotations, and annotations are needed for dependency injection. The
169
+ * following are all valid ways of annotating function with injection arguments and are equivalent.
170
+ *
171
+ * ```js
172
+ * // inferred (only works if code not minified/obfuscated)
173
+ * $injector.invoke(function(serviceA){});
174
+ *
175
+ * // annotated
176
+ * function explicit(serviceA) {};
177
+ * explicit.$inject = ['serviceA'];
178
+ * $injector.invoke(explicit);
179
+ *
180
+ * // inline
181
+ * $injector.invoke(['serviceA', function(serviceA){}]);
182
+ * ```
183
+ *
184
+ * ### Inference
185
+ *
186
+ * In JavaScript calling `toString()` on a function returns the function definition. The definition
187
+ * can then be parsed and the function arguments can be extracted. This method of discovering
188
+ * annotations is disallowed when the injector is in strict mode.
189
+ * *NOTE:* This does not work with minification, and obfuscation tools since these tools change the
190
+ * argument names.
191
+ *
192
+ * ### `$inject` Annotation
193
+ * By adding an `$inject` property onto a function the injection parameters can be specified.
194
+ *
195
+ * ### Inline
196
+ * As an array of injection names, where the last item in the array is the function to call.
197
+ */
198
+
199
+ /**
200
+ * @ngdoc property
201
+ * @name $injector#modules
202
+ * @type {Object}
203
+ * @description
204
+ * A hash containing all the modules that have been loaded into the
205
+ * $injector.
206
+ *
207
+ * You can use this property to find out information about a module via the
208
+ * {@link angular.Module#info `myModule.info(...)`} method.
209
+ *
210
+ * For example:
211
+ *
212
+ * ```
213
+ * var info = $injector.modules['ngAnimate'].info();
214
+ * ```
215
+ *
216
+ * **Do not use this property to attempt to modify the modules after the application
217
+ * has been bootstrapped.**
218
+ */
219
+
220
+ /**
221
+ * @ngdoc method
222
+ * @name $injector#get
223
+ *
224
+ * @description
225
+ * Return an instance of the service.
226
+ *
227
+ * @param {string} name The name of the instance to retrieve.
228
+ * @param {string=} caller An optional string to provide the origin of the function call for error messages.
229
+ * @return {*} The instance.
230
+ */
231
+
232
+ /**
233
+ * @ngdoc method
234
+ * @name $injector#invoke
235
+ *
236
+ * @description
237
+ * Invoke the method and supply the method arguments from the `$injector`.
238
+ *
239
+ * @param {Function|Array.<string|Function>} fn The injectable function to invoke. Function parameters are
240
+ * injected according to the {@link guide/di $inject Annotation} rules.
241
+ * @param {Object=} self The `this` for the invoked method.
242
+ * @param {Object=} locals Optional object. If preset then any argument names are read from this
243
+ * object first, before the `$injector` is consulted.
244
+ * @returns {*} the value returned by the invoked `fn` function.
245
+ */
246
+
247
+ /**
248
+ * @ngdoc method
249
+ * @name $injector#has
250
+ *
251
+ * @description
252
+ * Allows the user to query if the particular service exists.
253
+ *
254
+ * @param {string} name Name of the service to query.
255
+ * @returns {boolean} `true` if injector has given service.
256
+ */
257
+
258
+ /**
259
+ * @ngdoc method
260
+ * @name $injector#instantiate
261
+ * @description
262
+ * Create a new instance of JS type. The method takes a constructor function, invokes the new
263
+ * operator, and supplies all of the arguments to the constructor function as specified by the
264
+ * constructor annotation.
265
+ *
266
+ * @param {Function} Type Annotated constructor function.
267
+ * @param {Object=} locals Optional object. If preset then any argument names are read from this
268
+ * object first, before the `$injector` is consulted.
269
+ * @returns {Object} new instance of `Type`.
270
+ */
271
+
272
+ /**
273
+ * @ngdoc method
274
+ * @name $injector#annotate
275
+ *
276
+ * @description
277
+ * Returns an array of service names which the function is requesting for injection. This API is
278
+ * used by the injector to determine which services need to be injected into the function when the
279
+ * function is invoked. There are three ways in which the function can be annotated with the needed
280
+ * dependencies.
281
+ *
282
+ * #### Argument names
283
+ *
284
+ * The simplest form is to extract the dependencies from the arguments of the function. This is done
285
+ * by converting the function into a string using `toString()` method and extracting the argument
286
+ * names.
287
+ * ```js
288
+ * // Given
289
+ * function MyController($scope, $route) {
290
+ * // ...
291
+ * }
292
+ *
293
+ * // Then
294
+ * expect(injector.annotate(MyController)).toEqual(['$scope', '$route']);
295
+ * ```
296
+ *
297
+ * You can disallow this method by using strict injection mode.
298
+ *
299
+ * This method does not work with code minification / obfuscation. For this reason the following
300
+ * annotation strategies are supported.
301
+ *
302
+ * #### The `$inject` property
303
+ *
304
+ * If a function has an `$inject` property and its value is an array of strings, then the strings
305
+ * represent names of services to be injected into the function.
306
+ * ```js
307
+ * // Given
308
+ * var MyController = function(obfuscatedScope, obfuscatedRoute) {
309
+ * // ...
310
+ * }
311
+ * // Define function dependencies
312
+ * MyController['$inject'] = ['$scope', '$route'];
313
+ *
314
+ * // Then
315
+ * expect(injector.annotate(MyController)).toEqual(['$scope', '$route']);
316
+ * ```
317
+ *
318
+ * #### The array notation
319
+ *
320
+ * It is often desirable to inline Injected functions and that's when setting the `$inject` property
321
+ * is very inconvenient. In these situations using the array notation to specify the dependencies in
322
+ * a way that survives minification is a better choice:
323
+ *
324
+ * ```js
325
+ * // We wish to write this (not minification / obfuscation safe)
326
+ * injector.invoke(function($compile, $rootScope) {
327
+ * // ...
328
+ * });
329
+ *
330
+ * // We are forced to write break inlining
331
+ * var tmpFn = function(obfuscatedCompile, obfuscatedRootScope) {
332
+ * // ...
333
+ * };
334
+ * tmpFn.$inject = ['$compile', '$rootScope'];
335
+ * injector.invoke(tmpFn);
336
+ *
337
+ * // To better support inline function the inline annotation is supported
338
+ * injector.invoke(['$compile', '$rootScope', function(obfCompile, obfRootScope) {
339
+ * // ...
340
+ * }]);
341
+ *
342
+ * // Therefore
343
+ * expect(injector.annotate(
344
+ * ['$compile', '$rootScope', function(obfus_$compile, obfus_$rootScope) {}])
345
+ * ).toEqual(['$compile', '$rootScope']);
346
+ * ```
347
+ *
348
+ * @param {Function|Array.<string|Function>} fn Function for which dependent service names need to
349
+ * be retrieved as described above.
350
+ *
351
+ * @param {boolean=} [strictDi=false] Disallow argument name annotation inference.
352
+ *
353
+ * @returns {Array.<string>} The names of the services which the function requires.
354
+ */
355
+ /**
356
+ * @ngdoc method
357
+ * @name $injector#loadNewModules
358
+ *
359
+ * @description
360
+ *
361
+ * Add the specified modules to the current injector.
362
+ *
363
+ * This method will add each of the injectables to the injector and execute all of the config and run
364
+ * blocks for each module passed to the method.
365
+ *
366
+ * If a module has already been loaded into the injector then it will not be loaded again.
367
+ *
368
+ * * The application developer is responsible for loading the code containing the modules; and for
369
+ * ensuring that lazy scripts are not downloaded and executed more often that desired.
370
+ * * Previously compiled HTML will not be affected by newly loaded directives, filters and components.
371
+ * * Modules cannot be unloaded.
372
+ *
373
+ * You can use {@link $injector#modules `$injector.modules`} to check whether a module has been loaded
374
+ * into the injector, which may indicate whether the script has been executed already.
375
+ *
376
+ * @example
377
+ * Here is an example of loading a bundle of modules, with a utility method called `getScript`:
378
+ *
379
+ * ```javascript
380
+ * app.factory('loadModule', function($injector) {
381
+ * return function loadModule(moduleName, bundleUrl) {
382
+ * return getScript(bundleUrl).then(function() { $injector.loadNewModules([moduleName]); });
383
+ * };
384
+ * })
385
+ * ```
386
+ *
387
+ * @param {Array<String|Function|Array>=} mods an array of modules to load into the application.
388
+ * Each item in the array should be the name of a predefined module or a (DI annotated)
389
+ * function that will be invoked by the injector as a `config` block.
390
+ * See: {@link angular.module modules}
391
+ */
392
+
393
+ /**
394
+ * @ngdoc service
395
+ * @name $provide
396
+ *
397
+ * @description
398
+ *
399
+ * The {@link auto.$provide $provide} service has a number of methods for registering components
400
+ * with the {@link auto.$injector $injector}. Many of these functions are also exposed on
401
+ * {@link angular.Module}.
402
+ *
403
+ * An AngularJS **service** is a singleton object created by a **service factory**. These **service
404
+ * factories** are functions which, in turn, are created by a **service provider**.
405
+ * The **service providers** are constructor functions. When instantiated they must contain a
406
+ * property called `$get`, which holds the **service factory** function.
407
+ *
408
+ * When you request a service, the {@link auto.$injector $injector} is responsible for finding the
409
+ * correct **service provider**, instantiating it and then calling its `$get` **service factory**
410
+ * function to get the instance of the **service**.
411
+ *
412
+ * Often services have no configuration options and there is no need to add methods to the service
413
+ * provider. The provider will be no more than a constructor function with a `$get` property. For
414
+ * these cases the {@link auto.$provide $provide} service has additional helper methods to register
415
+ * services without specifying a provider.
416
+ *
417
+ * * {@link auto.$provide#provider provider(name, provider)} - registers a **service provider** with the
418
+ * {@link auto.$injector $injector}
419
+ * * {@link auto.$provide#constant constant(name, obj)} - registers a value/object that can be accessed by
420
+ * providers and services.
421
+ * * {@link auto.$provide#value value(name, obj)} - registers a value/object that can only be accessed by
422
+ * services, not providers.
423
+ * * {@link auto.$provide#factory factory(name, fn)} - registers a service **factory function**
424
+ * that will be wrapped in a **service provider** object, whose `$get` property will contain the
425
+ * given factory function.
426
+ * * {@link auto.$provide#service service(name, Fn)} - registers a **constructor function**
427
+ * that will be wrapped in a **service provider** object, whose `$get` property will instantiate
428
+ * a new object using the given constructor function.
429
+ * * {@link auto.$provide#decorator decorator(name, decorFn)} - registers a **decorator function** that
430
+ * will be able to modify or replace the implementation of another service.
431
+ *
432
+ * See the individual methods for more information and examples.
433
+ */
434
+
435
+ /**
436
+ * @ngdoc method
437
+ * @name $provide#provider
438
+ * @description
439
+ *
440
+ * Register a **provider function** with the {@link auto.$injector $injector}. Provider functions
441
+ * are constructor functions, whose instances are responsible for "providing" a factory for a
442
+ * service.
443
+ *
444
+ * Service provider names start with the name of the service they provide followed by `Provider`.
445
+ * For example, the {@link ng.$log $log} service has a provider called
446
+ * {@link ng.$logProvider $logProvider}.
447
+ *
448
+ * Service provider objects can have additional methods which allow configuration of the provider
449
+ * and its service. Importantly, you can configure what kind of service is created by the `$get`
450
+ * method, or how that service will act. For example, the {@link ng.$logProvider $logProvider} has a
451
+ * method {@link ng.$logProvider#debugEnabled debugEnabled}
452
+ * which lets you specify whether the {@link ng.$log $log} service will log debug messages to the
453
+ * console or not.
454
+ *
455
+ * It is possible to inject other providers into the provider function,
456
+ * but the injected provider must have been defined before the one that requires it.
457
+ *
458
+ * @param {string} name The name of the instance. NOTE: the provider will be available under `name +
459
+ 'Provider'` key.
460
+ * @param {(Object|function())} provider If the provider is:
461
+ *
462
+ * - `Object`: then it should have a `$get` method. The `$get` method will be invoked using
463
+ * {@link auto.$injector#invoke $injector.invoke()} when an instance needs to be created.
464
+ * - `Constructor`: a new instance of the provider will be created using
465
+ * {@link auto.$injector#instantiate $injector.instantiate()}, then treated as `object`.
466
+ *
467
+ * @returns {Object} registered provider instance
468
+
469
+ * @example
470
+ *
471
+ * The following example shows how to create a simple event tracking service and register it using
472
+ * {@link auto.$provide#provider $provide.provider()}.
473
+ *
474
+ * ```js
475
+ * // Define the eventTracker provider
476
+ * function EventTrackerProvider() {
477
+ * var trackingUrl = '/track';
478
+ *
479
+ * // A provider method for configuring where the tracked events should been saved
480
+ * this.setTrackingUrl = function(url) {
481
+ * trackingUrl = url;
482
+ * };
483
+ *
484
+ * // The service factory function
485
+ * this.$get = ['$http', function($http) {
486
+ * var trackedEvents = {};
487
+ * return {
488
+ * // Call this to track an event
489
+ * event: function(event) {
490
+ * var count = trackedEvents[event] || 0;
491
+ * count += 1;
492
+ * trackedEvents[event] = count;
493
+ * return count;
494
+ * },
495
+ * // Call this to save the tracked events to the trackingUrl
496
+ * save: function() {
497
+ * $http.post(trackingUrl, trackedEvents);
498
+ * }
499
+ * };
500
+ * }];
501
+ * }
502
+ *
503
+ * describe('eventTracker', function() {
504
+ * var postSpy;
505
+ *
506
+ * beforeEach(module(function($provide) {
507
+ * // Register the eventTracker provider
508
+ * $provide.provider('eventTracker', EventTrackerProvider);
509
+ * }));
510
+ *
511
+ * beforeEach(module(function(eventTrackerProvider) {
512
+ * // Configure eventTracker provider
513
+ * eventTrackerProvider.setTrackingUrl('/custom-track');
514
+ * }));
515
+ *
516
+ * it('tracks events', inject(function(eventTracker) {
517
+ * expect(eventTracker.event('login')).toEqual(1);
518
+ * expect(eventTracker.event('login')).toEqual(2);
519
+ * }));
520
+ *
521
+ * it('saves to the tracking url', inject(function(eventTracker, $http) {
522
+ * postSpy = spyOn($http, 'post');
523
+ * eventTracker.event('login');
524
+ * eventTracker.save();
525
+ * expect(postSpy).toHaveBeenCalled();
526
+ * expect(postSpy.mostRecentCall.args[0]).not.toEqual('/track');
527
+ * expect(postSpy.mostRecentCall.args[0]).toEqual('/custom-track');
528
+ * expect(postSpy.mostRecentCall.args[1]).toEqual({ 'login': 1 });
529
+ * }));
530
+ * });
531
+ * ```
532
+ */
533
+
534
+ /**
535
+ * @ngdoc method
536
+ * @name $provide#factory
537
+ * @description
538
+ *
539
+ * Register a **service factory**, which will be called to return the service instance.
540
+ * This is short for registering a service where its provider consists of only a `$get` property,
541
+ * which is the given service factory function.
542
+ * You should use {@link auto.$provide#factory $provide.factory(getFn)} if you do not need to
543
+ * configure your service in a provider.
544
+ *
545
+ * @param {string} name The name of the instance.
546
+ * @param {Function|Array.<string|Function>} $getFn The injectable $getFn for the instance creation.
547
+ * Internally this is a short hand for `$provide.provider(name, {$get: $getFn})`.
548
+ * @returns {Object} registered provider instance
549
+ *
550
+ * @example
551
+ * Here is an example of registering a service
552
+ * ```js
553
+ * $provide.factory('ping', ['$http', function($http) {
554
+ * return function ping() {
555
+ * return $http.send('/ping');
556
+ * };
557
+ * }]);
558
+ * ```
559
+ * You would then inject and use this service like this:
560
+ * ```js
561
+ * someModule.controller('Ctrl', ['ping', function(ping) {
562
+ * ping();
563
+ * }]);
564
+ * ```
565
+ */
566
+
567
+ /**
568
+ * @ngdoc method
569
+ * @name $provide#service
570
+ * @description
571
+ *
572
+ * Register a **service constructor**, which will be invoked with `new` to create the service
573
+ * instance.
574
+ * This is short for registering a service where its provider's `$get` property is a factory
575
+ * function that returns an instance instantiated by the injector from the service constructor
576
+ * function.
577
+ *
578
+ * Internally it looks a bit like this:
579
+ *
580
+ * ```
581
+ * {
582
+ * $get: function() {
583
+ * return $injector.instantiate(constructor);
584
+ * }
585
+ * }
586
+ * ```
587
+ *
588
+ *
589
+ * You should use {@link auto.$provide#service $provide.service(class)} if you define your service
590
+ * as a type/class.
591
+ *
592
+ * @param {string} name The name of the instance.
593
+ * @param {Function|Array.<string|Function>} constructor An injectable class (constructor function)
594
+ * that will be instantiated.
595
+ * @returns {Object} registered provider instance
596
+ *
597
+ * @example
598
+ * Here is an example of registering a service using
599
+ * {@link auto.$provide#service $provide.service(class)}.
600
+ * ```js
601
+ * var Ping = function($http) {
602
+ * this.$http = $http;
603
+ * };
604
+ *
605
+ * Ping.$inject = ['$http'];
606
+ *
607
+ * Ping.prototype.send = function() {
608
+ * return this.$http.get('/ping');
609
+ * };
610
+ * $provide.service('ping', Ping);
611
+ * ```
612
+ * You would then inject and use this service like this:
613
+ * ```js
614
+ * someModule.controller('Ctrl', ['ping', function(ping) {
615
+ * ping.send();
616
+ * }]);
617
+ * ```
618
+ */
619
+
620
+ /**
621
+ * @ngdoc method
622
+ * @name $provide#value
623
+ * @description
624
+ *
625
+ * Register a **value service** with the {@link auto.$injector $injector}, such as a string, a
626
+ * number, an array, an object or a function. This is short for registering a service where its
627
+ * provider's `$get` property is a factory function that takes no arguments and returns the **value
628
+ * service**. That also means it is not possible to inject other services into a value service.
629
+ *
630
+ * Value services are similar to constant services, except that they cannot be injected into a
631
+ * module configuration function (see {@link angular.Module#config}) but they can be overridden by
632
+ * an AngularJS {@link auto.$provide#decorator decorator}.
633
+ *
634
+ * @param {string} name The name of the instance.
635
+ * @param {*} value The value.
636
+ * @returns {Object} registered provider instance
637
+ *
638
+ * @example
639
+ * Here are some examples of creating value services.
640
+ * ```js
641
+ * $provide.value('ADMIN_USER', 'admin');
642
+ *
643
+ * $provide.value('RoleLookup', { admin: 0, writer: 1, reader: 2 });
644
+ *
645
+ * $provide.value('halfOf', function(value) {
646
+ * return value / 2;
647
+ * });
648
+ * ```
649
+ */
650
+
651
+ /**
652
+ * @ngdoc method
653
+ * @name $provide#constant
654
+ * @description
655
+ *
656
+ * Register a **constant service** with the {@link auto.$injector $injector}, such as a string,
657
+ * a number, an array, an object or a function. Like the {@link auto.$provide#value value}, it is not
658
+ * possible to inject other services into a constant.
659
+ *
660
+ * But unlike {@link auto.$provide#value value}, a constant can be
661
+ * injected into a module configuration function (see {@link angular.Module#config}) and it cannot
662
+ * be overridden by an AngularJS {@link auto.$provide#decorator decorator}.
663
+ *
664
+ * @param {string} name The name of the constant.
665
+ * @param {*} value The constant value.
666
+ * @returns {Object} registered instance
667
+ *
668
+ * @example
669
+ * Here a some examples of creating constants:
670
+ * ```js
671
+ * $provide.constant('SHARD_HEIGHT', 306);
672
+ *
673
+ * $provide.constant('MY_COLOURS', ['red', 'blue', 'grey']);
674
+ *
675
+ * $provide.constant('double', function(value) {
676
+ * return value * 2;
677
+ * });
678
+ * ```
679
+ */
680
+
681
+ /**
682
+ * @ngdoc method
683
+ * @name $provide#decorator
684
+ * @description
685
+ *
686
+ * Register a **decorator function** with the {@link auto.$injector $injector}. A decorator function
687
+ * intercepts the creation of a service, allowing it to override or modify the behavior of the
688
+ * service. The return value of the decorator function may be the original service, or a new service
689
+ * that replaces (or wraps and delegates to) the original service.
690
+ *
691
+ * You can find out more about using decorators in the {@link guide/decorators} guide.
692
+ *
693
+ * @param {string} name The name of the service to decorate.
694
+ * @param {Function|Array.<string|Function>} decorator This function will be invoked when the service needs to be
695
+ * provided and should return the decorated service instance. The function is called using
696
+ * the {@link auto.$injector#invoke injector.invoke} method and is therefore fully injectable.
697
+ * Local injection arguments:
698
+ *
699
+ * * `$delegate` - The original service instance, which can be replaced, monkey patched, configured,
700
+ * decorated or delegated to.
701
+ *
702
+ * @example
703
+ * Here we decorate the {@link ng.$log $log} service to convert warnings to errors by intercepting
704
+ * calls to {@link ng.$log#error $log.warn()}.
705
+ * ```js
706
+ * $provide.decorator('$log', ['$delegate', function($delegate) {
707
+ * $delegate.warn = $delegate.error;
708
+ * return $delegate;
709
+ * }]);
710
+ * ```
711
+ */
712
+ const providerSuffix = "Provider";
713
+ const INSTANTIATING = {};
714
+ export function createInjector(modulesToLoad, strictDi) {
715
+ if (isDefined(strictDi) && !isBoolean(strictDi)) {
716
+ throw $injectorMinErr("strictDi must be boolean");
717
+ }
718
+ strictDi = !!strictDi;
719
+
720
+ const path = [];
721
+ const loadedModules = new Map();
722
+ const providerCache = {
723
+ $provide: {
724
+ provider: supportObject(provider),
725
+ factory: supportObject(factory),
726
+ service: supportObject(service),
727
+ value: supportObject(value),
728
+ constant: supportObject(constant),
729
+ decorator,
730
+ },
731
+ };
732
+
733
+ const providerInjector = (providerCache.$injector = createInternalInjector(
734
+ providerCache,
735
+ function (serviceName, caller) {
736
+ if (isString(caller)) {
737
+ path.push(caller);
738
+ }
739
+ throw $injectorMinErr("unpr", "Unknown provider: {0}", path.join(" <- "));
740
+ },
741
+ ));
742
+ const instanceCache = {};
743
+
744
+ let protoInstanceInjector = createInternalInjector(
745
+ instanceCache,
746
+ (serviceName, caller) => {
747
+ const provider = providerInjector.get(
748
+ serviceName + providerSuffix,
749
+ caller,
750
+ );
751
+ return instanceInjector.invoke(
752
+ provider.$get,
753
+ provider,
754
+ undefined,
755
+ serviceName,
756
+ );
757
+ },
758
+ );
759
+
760
+ providerCache["$injector" + providerSuffix] = {
761
+ $get: valueFn(protoInstanceInjector),
762
+ };
763
+ let instanceInjector = protoInstanceInjector;
764
+ instanceInjector.modules = providerInjector.modules = createMap();
765
+ var runBlocks = loadModules(modulesToLoad);
766
+ instanceInjector = protoInstanceInjector.get("$injector");
767
+ instanceInjector.strictDi = strictDi;
768
+ runBlocks.forEach((fn) => {
769
+ if (fn) instanceInjector.invoke(fn);
770
+ });
771
+
772
+ instanceInjector.loadNewModules = function (mods) {
773
+ loadModules(mods).forEach((fn) => {
774
+ if (fn) instanceInjector.invoke(fn);
775
+ });
776
+ };
777
+
778
+ return instanceInjector;
779
+
780
+ ////////////////////////////////////
781
+ // $provider
782
+ ////////////////////////////////////
783
+
784
+ function supportObject(delegate) {
785
+ return function (key, value) {
786
+ if (isObject(key)) {
787
+ forEach(key, reverseParams(delegate));
788
+ } else {
789
+ return delegate(key, value);
790
+ }
791
+ };
792
+ }
793
+
794
+ function provider(name, provider_) {
795
+ assertNotHasOwnProperty(name, "service");
796
+ if (isFunction(provider_) || isArray(provider_)) {
797
+ provider_ = providerInjector.instantiate(provider_);
798
+ }
799
+ if (!provider_.$get) {
800
+ throw $injectorMinErr(
801
+ "pget",
802
+ "Provider '{0}' must define $get factory method.",
803
+ name,
804
+ );
805
+ }
806
+ return (providerCache[name + providerSuffix] = provider_);
807
+ }
808
+
809
+ function enforceReturnValue(name, factory) {
810
+ return function enforcedReturnValue() {
811
+ const result = instanceInjector.invoke(factory, this);
812
+ if (isUndefined(result)) {
813
+ throw $injectorMinErr(
814
+ "undef",
815
+ "Provider '{0}' must return a value from $get factory method.",
816
+ name,
817
+ );
818
+ }
819
+ return result;
820
+ };
821
+ }
822
+
823
+ function factory(name, factoryFn, enforce) {
824
+ return provider(name, {
825
+ $get: enforce !== false ? enforceReturnValue(name, factoryFn) : factoryFn,
826
+ });
827
+ }
828
+
829
+ function service(name, constructor) {
830
+ return factory(name, [
831
+ "$injector",
832
+ function ($injector) {
833
+ return $injector.instantiate(constructor);
834
+ },
835
+ ]);
836
+ }
837
+
838
+ function value(name, val) {
839
+ return factory(name, valueFn(val), false);
840
+ }
841
+
842
+ function constant(name, value) {
843
+ assertNotHasOwnProperty(name, "constant");
844
+ providerCache[name] = value;
845
+ instanceCache[name] = value;
846
+ }
847
+
848
+ function decorator(serviceName, decorFn) {
849
+ const origProvider = providerInjector.get(serviceName + providerSuffix);
850
+ const orig$get = origProvider.$get;
851
+
852
+ origProvider.$get = function () {
853
+ const origInstance = instanceInjector.invoke(orig$get, origProvider);
854
+ return instanceInjector.invoke(decorFn, null, {
855
+ $delegate: origInstance,
856
+ });
857
+ };
858
+ }
859
+
860
+ ////////////////////////////////////
861
+ // Module Loading
862
+ ////////////////////////////////////
863
+ function loadModules(modulesToLoad) {
864
+ assertArg(
865
+ isUndefined(modulesToLoad) || isArray(modulesToLoad),
866
+ "modulesToLoad",
867
+ "not an array",
868
+ );
869
+ let runBlocks = [];
870
+ let moduleFn;
871
+ forEach(modulesToLoad, (module) => {
872
+ if (loadedModules.get(module)) return;
873
+ loadedModules.set(module, true);
874
+
875
+ function runInvokeQueue(queue) {
876
+ queue.forEach((invokeArgs) => {
877
+ const provider = providerInjector.get(invokeArgs[0]);
878
+ provider[invokeArgs[1]].apply(provider, invokeArgs[2]);
879
+ });
880
+ }
881
+
882
+ try {
883
+ if (isString(module)) {
884
+ moduleFn = window.angular.module(module);
885
+ instanceInjector.modules[module] = moduleFn;
886
+ runBlocks = runBlocks
887
+ .concat(loadModules(moduleFn.requires))
888
+ // @ts-ignore
889
+ .concat(moduleFn._runBlocks);
890
+ // @ts-ignore
891
+ runInvokeQueue(moduleFn._invokeQueue);
892
+ // @ts-ignore
893
+ runInvokeQueue(moduleFn._configBlocks);
894
+ } else if (isFunction(module)) {
895
+ runBlocks.push(providerInjector.invoke(module));
896
+ } else if (isArray(module)) {
897
+ runBlocks.push(providerInjector.invoke(module));
898
+ } else {
899
+ assertArgFn(module, "module");
900
+ }
901
+ } catch (e) {
902
+ if (isArray(module)) {
903
+ module = module[module.length - 1];
904
+ }
905
+ if (e.message && e.stack && e.stack.indexOf(e.message) === -1) {
906
+ // Safari & FF's stack traces don't contain error.message content
907
+ // unlike those of Chrome and IE
908
+ // So if stack doesn't contain message, we create a new string that contains both.
909
+ // Since error.stack is read-only in Safari, I'm overriding e and not e.stack here.
910
+ // eslint-disable-next-line no-ex-assign
911
+ e = `${e.message}\n${e.stack}`;
912
+ }
913
+ throw $injectorMinErr(
914
+ "modulerr",
915
+ "Failed to instantiate module {0} due to:\n{1}",
916
+ module,
917
+ e.stack || e.message || e,
918
+ );
919
+ }
920
+ });
921
+ return runBlocks;
922
+ }
923
+
924
+ ////////////////////////////////////
925
+ // internal Injector
926
+ ////////////////////////////////////
927
+
928
+ function createInternalInjector(cache, factory) {
929
+ function get(serviceName, caller) {
930
+ if (Object.prototype.hasOwnProperty.call(cache, serviceName)) {
931
+ if (cache[serviceName] === INSTANTIATING) {
932
+ throw $injectorMinErr(
933
+ "cdep",
934
+ "Circular dependency found: {0}",
935
+ `${serviceName} <- ${path.join(" <- ")}`,
936
+ );
937
+ }
938
+ return cache[serviceName];
939
+ }
940
+ try {
941
+ path.unshift(serviceName);
942
+ cache[serviceName] = INSTANTIATING;
943
+ cache[serviceName] = factory(serviceName, caller);
944
+ return cache[serviceName];
945
+ } catch (err) {
946
+ if (cache[serviceName] === INSTANTIATING) {
947
+ delete cache[serviceName];
948
+ }
949
+ throw err;
950
+ } finally {
951
+ path.shift();
952
+ }
953
+ }
954
+
955
+ function injectionArgs(fn, locals, serviceName) {
956
+ const args = [];
957
+ const $inject = annotate(fn, strictDi, serviceName);
958
+
959
+ for (let i = 0, { length } = $inject; i < length; i++) {
960
+ const key = $inject[i];
961
+ if (typeof key !== "string") {
962
+ throw $injectorMinErr(
963
+ "itkn",
964
+ "Incorrect injection token! Expected service name as string, got {0}",
965
+ key,
966
+ );
967
+ }
968
+ args.push(
969
+ locals && Object.prototype.hasOwnProperty.call(locals, key)
970
+ ? locals[key]
971
+ : get(key, serviceName),
972
+ );
973
+ }
974
+ return args;
975
+ }
976
+
977
+ function isClass(func) {
978
+ let result = func.$$ngIsClass;
979
+ if (!isBoolean(result)) {
980
+ result = func.$$ngIsClass = /^class\b/.test(stringifyFn(func));
981
+ }
982
+ return result;
983
+ }
984
+
985
+ function invoke(fn, self, locals, serviceName) {
986
+ if (typeof locals === "string") {
987
+ serviceName = locals;
988
+ locals = null;
989
+ }
990
+
991
+ const args = injectionArgs(fn, locals, serviceName);
992
+ if (isArray(fn)) {
993
+ fn = fn[fn.length - 1];
994
+ }
995
+
996
+ if (!isClass(fn)) {
997
+ // http://jsperf.com/angularjs-invoke-apply-vs-switch
998
+ // #5388
999
+ return fn.apply(self, args);
1000
+ }
1001
+ args.unshift(null);
1002
+ return new (Function.prototype.bind.apply(fn, args))();
1003
+ }
1004
+
1005
+ function instantiate(Type, locals, serviceName) {
1006
+ // Check if Type is annotated and use just the given function at n-1 as parameter
1007
+ // e.g. someModule.factory('greeter', ['$window', function(renamed$window) {}]);
1008
+ const ctor = isArray(Type) ? Type[Type.length - 1] : Type;
1009
+ const args = injectionArgs(Type, locals, serviceName);
1010
+ // Empty object at position 0 is ignored for invocation with `new`, but required.
1011
+ args.unshift(null);
1012
+ return new (Function.prototype.bind.apply(ctor, args))();
1013
+ }
1014
+
1015
+ function has(name) {
1016
+ const hasProvider = Object.prototype.hasOwnProperty.call(
1017
+ providerCache,
1018
+ name + providerSuffix,
1019
+ );
1020
+ const hasCache = Object.prototype.hasOwnProperty.call(cache, name);
1021
+ return hasProvider || hasCache;
1022
+ }
1023
+
1024
+ return {
1025
+ invoke,
1026
+ instantiate,
1027
+ get,
1028
+ annotate,
1029
+ has,
1030
+ };
1031
+ }
1032
+ }
1033
+
1034
+ createInjector.$$annotate = annotate;