@angular-wave/angular.ts 0.0.64 → 0.0.66

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 (113) hide show
  1. package/dist/angular-ts.esm.js +2 -2
  2. package/dist/angular-ts.umd.js +2 -2
  3. package/package.json +1 -1
  4. package/public/jasmine/jasmine-5.1.2/jasmine-html.js +0 -1
  5. package/src/angular.spec.js +1 -1
  6. package/src/animations/animate-js.js +6 -0
  7. package/src/animations/animation.js +1 -1
  8. package/src/binding.spec.js +1 -1
  9. package/src/core/animate/animate.spec.js +1 -1
  10. package/src/core/cache/cache-factory.spec.js +1 -1
  11. package/src/core/compile/compile.js +13 -1
  12. package/src/core/compile/compile.spec.js +2 -3
  13. package/src/core/controller/controller.js +5 -0
  14. package/src/core/controller/controller.spec.js +1 -1
  15. package/src/core/cookie-reader.spec.js +1 -1
  16. package/src/core/di/injector.html +18 -0
  17. package/src/core/di/injector.js +299 -0
  18. package/src/{injector.md → core/di/injector.md} +3 -3
  19. package/src/{injector.spec.js → core/di/injector.spec.js} +49 -30
  20. package/src/core/di/injector.test.js +12 -0
  21. package/src/core/di/internal-injector.js +233 -0
  22. package/src/core/di/ng-module.html +18 -0
  23. package/src/core/{ng-module.js → di/ng-module.js} +64 -29
  24. package/src/core/di/ng-module.spec.js +269 -0
  25. package/src/core/di/ng-module.test.js +12 -0
  26. package/src/core/filter/filter.js +5 -0
  27. package/src/core/filter/filter.spec.js +1 -1
  28. package/src/core/interpolate/interpolate.spec.js +1 -1
  29. package/src/core/interval/interval.spec.js +1 -1
  30. package/src/core/location/location.spec.js +1 -1
  31. package/src/core/on.spec.js +1 -1
  32. package/src/core/parser/lexer.spec.js +1 -1
  33. package/src/core/parser/parse.spec.js +1 -1
  34. package/src/core/prop.spec.js +1 -1
  35. package/src/core/q/q.spec.js +1 -4
  36. package/src/core/q/q.test.js +12 -0
  37. package/src/core/sce/sce.js +6 -1
  38. package/src/core/sce/sce.spec.js +1 -1
  39. package/src/core/scope/scope.js +0 -1
  40. package/src/core/scope/scope.spec.js +1 -1
  41. package/src/core/timeout/timeout.spec.js +1 -1
  42. package/src/directive/attrs/attrs.spec.js +2 -2
  43. package/src/directive/attrs/boolean.spec.js +1 -1
  44. package/src/directive/attrs/element-style.spec.js +1 -1
  45. package/src/directive/attrs/src.spec.js +2 -2
  46. package/src/directive/bind/bind.spec.js +2 -2
  47. package/src/directive/bind/bing-html.spec.js +1 -1
  48. package/src/directive/change/change.spec.js +1 -1
  49. package/src/directive/class/class.spec.js +1 -1
  50. package/src/directive/cloak/cloak.spec.js +1 -1
  51. package/src/directive/controller/controller.spec.js +1 -1
  52. package/src/directive/events/click.spec.js +2 -2
  53. package/src/directive/events/event.spec.js +1 -1
  54. package/src/directive/form/form.spec.js +1 -1
  55. package/src/directive/if/if.spec.js +1 -1
  56. package/src/directive/include/include.spec.js +1 -1
  57. package/src/directive/init/init.spec.js +1 -1
  58. package/src/directive/input/input.spec.js +1 -2
  59. package/src/directive/list/list.spec.js +2 -2
  60. package/src/directive/model/model.spec.js +1 -1
  61. package/src/directive/model-options/model-options.spec.js +1 -1
  62. package/src/directive/non-bindable/non-bindable.spec.js +2 -2
  63. package/src/directive/options/options.spec.js +1 -1
  64. package/src/directive/ref/href.spec.js +1 -1
  65. package/src/directive/ref/ref.spec.js +1 -1
  66. package/src/directive/repeat/repeat.spec.js +1 -1
  67. package/src/directive/script/script.spec.js +1 -1
  68. package/src/directive/select/select.spec.js +1 -1
  69. package/src/directive/show-hide/show-hide.spec.js +1 -1
  70. package/src/directive/style/style.spec.js +1 -1
  71. package/src/directive/switch/switch.spec.js +1 -1
  72. package/src/directive/validators/validators.spec.js +1 -1
  73. package/src/exts/aria/aria.spec.js +1 -1
  74. package/src/exts/messages/messages.spec.js +1 -1
  75. package/src/filters/filter.spec.js +1 -1
  76. package/src/filters/filters.spec.js +1 -1
  77. package/src/filters/limit-to.spec.js +1 -1
  78. package/src/filters/order-by.spec.js +1 -1
  79. package/src/loader.js +7 -7
  80. package/src/loader.spec.js +4 -19
  81. package/src/public.spec.js +1 -1
  82. package/src/router/services.js +9 -4
  83. package/src/router/state/state-builder.js +4 -3
  84. package/src/router/state/state-registry.js +5 -0
  85. package/src/router/state/views.js +2 -1
  86. package/src/router/template-factory.js +5 -4
  87. package/src/services/http/http.js +12 -0
  88. package/src/services/http/http.spec.js +1 -1
  89. package/src/services/http/template-request.spec.js +1 -1
  90. package/src/services/http-backend/http-backend.spec.js +1 -1
  91. package/src/shared/jqlite/jqlite.js +0 -2
  92. package/src/shared/jqlite/jqlite.spec.js +1 -1
  93. package/src/shared/utils.js +10 -1
  94. package/src/src.html +0 -1
  95. package/src/types.js +9 -11
  96. package/types/animations/animate-js.d.ts +1 -1
  97. package/types/animations/animation.d.ts +1 -1
  98. package/types/core/compile/compile.d.ts +1 -1
  99. package/types/core/controller/controller.d.ts +1 -1
  100. package/types/core/di/injector.d.ts +18 -0
  101. package/types/core/di/internal-injector.d.ts +36 -0
  102. package/types/core/{ng-module.d.ts → di/ng-module.d.ts} +30 -8
  103. package/types/core/filter/filter.d.ts +1 -1
  104. package/types/core/sce/sce.d.ts +1 -1
  105. package/types/loader.d.ts +5 -5
  106. package/types/router/services.d.ts +8 -1
  107. package/types/router/state/state-registry.d.ts +2 -2
  108. package/types/router/template-factory.d.ts +2 -2
  109. package/types/services/http/http.d.ts +1 -1
  110. package/types/shared/utils.d.ts +7 -1
  111. package/types/types.d.ts +7 -32
  112. package/src/injector.js +0 -409
  113. package/types/injector.d.ts +0 -12
@@ -2,7 +2,7 @@ export function $FilterProvider($provide: any): void;
2
2
  export class $FilterProvider {
3
3
  constructor($provide: any);
4
4
  register: (name: any, factory: any) => any;
5
- $get: (string | (($injector: any) => (name: any) => any))[];
5
+ $get: (string | (($injector: import("../../core/di/internal-injector").InjectorService) => (name: any) => any))[];
6
6
  }
7
7
  export namespace $FilterProvider {
8
8
  let $inject: string[];
@@ -150,7 +150,7 @@ export class $SceDelegateProvider {
150
150
  * array (i.e. there is no `bannedResourceUrlList`.)
151
151
  */
152
152
  bannedResourceUrlList: (value: any, ...args: any[]) => any[];
153
- $get: (string | (($injector: any, $$sanitizeUri: any) => {
153
+ $get: (string | (($injector: import("../../core/di/internal-injector").InjectorService, $$sanitizeUri: any) => {
154
154
  trustAs: (type: string, trustedValue: any) => any;
155
155
  getTrusted: (type: string, maybeTrusted: any) => any;
156
156
  valueOf: (maybeTrusted: any) => any;
package/types/loader.d.ts CHANGED
@@ -126,14 +126,14 @@ export class Angular {
126
126
  * {@link ng.directive:ngApp ngApp} or
127
127
  * {@link angular.bootstrap} to simplify this process for you.
128
128
  *
129
- * @param {!string} name The name of the module to create or retrieve.
130
- * @param {!Array.<string>=} requires If specified then new module is being created. If
129
+ * @param {string} name The name of the module to create or retrieve.
130
+ * @param {Array.<string>} [requires] If specified then new module is being created. If
131
131
  * unspecified then the module is being retrieved for further configuration.
132
- * @param {Function=} configFn Optional configuration function for the module. Same as
132
+ * @param {Function} [configFn] Optional configuration function for the module. Same as
133
133
  * {@link import('./types').Module#config Module#config()}.
134
134
  * @returns {NgModule} A newly registered module.
135
135
  */
136
- module(name: string, requires?: Array<string> | undefined, configFn?: Function | undefined): NgModule;
136
+ module(name: string, requires?: Array<string>, configFn?: Function): NgModule;
137
137
  }
138
138
  /**
139
139
  * Configuration option for AngularTS bootstrap process.
@@ -144,4 +144,4 @@ export type AngularBootstrapConfig = {
144
144
  */
145
145
  strictDi?: boolean;
146
146
  };
147
- import { NgModule } from "./core/ng-module";
147
+ import { NgModule } from "./core/di/ng-module";
@@ -1,4 +1,11 @@
1
- export function runBlock($injector: any, $q: any, $stateRegistry: any, $urlService: any): void;
1
+ /**
2
+ *
3
+ * @param {import("../core/di/internal-injector").InjectorService} $injector
4
+ * @param {*} $q
5
+ * @param {*} $stateRegistry
6
+ * @param {*} $urlService
7
+ */
8
+ export function runBlock($injector: import("../core/di/internal-injector").InjectorService, $q: any, $stateRegistry: any, $urlService: any): void;
2
9
  export namespace runBlock {
3
10
  let $inject: string[];
4
11
  }
@@ -9,12 +9,12 @@ export class StateRegistry {
9
9
  states: {};
10
10
  urlService: any;
11
11
  urlServiceRules: any;
12
- $injector: any;
12
+ $injector: import("../../core/di/internal-injector").InjectorService;
13
13
  listeners: any[];
14
14
  matcher: StateMatcher;
15
15
  builder: StateBuilder;
16
16
  stateQueue: StateQueueManager;
17
- $get: (string | (($injector: any) => this))[];
17
+ $get: (string | (($injector: import("../../core/di/internal-injector").InjectorService) => this))[];
18
18
  /**
19
19
  * This is a [[StateBuilder.builder]] function for angular1 `onEnter`, `onExit`,
20
20
  * `onRetain` callback hooks on a [[Ng1StateDeclaration]].
@@ -9,12 +9,12 @@
9
9
  export class TemplateFactory {
10
10
  /** @type {boolean} */
11
11
  _useHttp: boolean;
12
- $get: (string | (($http: angular.IHttpService, $templateCache: angular.ITemplateCacheService, $templateRequest: angular.ITemplateRequestService, $q: angular.IQService, $injector: angular.auto.IInjectorService) => this))[];
12
+ $get: (string | (($http: angular.IHttpService, $templateCache: angular.ITemplateCacheService, $templateRequest: angular.ITemplateRequestService, $q: angular.IQService, $injector: import("../core/di/internal-injector").InjectorService) => this))[];
13
13
  $templateRequest: angular.ITemplateRequestService;
14
14
  $http: angular.IHttpService;
15
15
  $templateCache: angular.ITemplateCacheService;
16
16
  $q: angular.IQService;
17
- $injector: angular.auto.IInjectorService;
17
+ $injector: import("../core/di/internal-injector").InjectorService;
18
18
  /**
19
19
  * Forces the provider to use $http service directly
20
20
  * @param {boolean} value
@@ -113,7 +113,7 @@ export class $HttpProvider {
113
113
  useApplyAsync: (value?: boolean | undefined) => boolean | any;
114
114
  interceptors: any[];
115
115
  xsrfTrustedOrigins: any[];
116
- $get: (string | (($browser: any, $httpBackend: any, $$cookieReader: any, $cacheFactory: any, $rootScope: any, $q: any, $injector: any, $sce: any) => {
116
+ $get: (string | (($browser: any, $httpBackend: any, $$cookieReader: any, $cacheFactory: any, $rootScope: any, $q: any, $injector: import("../../core/di/internal-injector").InjectorService, $sce: any) => {
117
117
  (requestConfig: any): HttpPromise;
118
118
  pendingRequests: any[];
119
119
  /**
@@ -486,7 +486,13 @@ export function getNgAttribute(element: any, ngAttr: any): any;
486
486
  */
487
487
  export function shallowCopy(src: any, dst: any): any;
488
488
  /**
489
- * throw error if the argument is falsy.
489
+ * Throw error if the argument is false
490
+ * @param {boolean} argument
491
+ * @param {string} errorMsg
492
+ */
493
+ export function assert(argument: boolean, errorMsg?: string): void;
494
+ /**
495
+ * Throw error if the argument is falsy.
490
496
  */
491
497
  export function assertArg(arg: any, name: any, reason: any): any;
492
498
  export function assertArgFn(arg: any, name: any, acceptArrayAnnotation: any): any;
package/types/types.d.ts CHANGED
@@ -1,5 +1,12 @@
1
1
  export type BootstrapConfig = any;
2
2
  export type Injectable<T_1> = Function | Array<string | Function>;
3
+ export type Annotated = {
4
+ /**
5
+ * *
6
+ */
7
+ $inject: Array<string>;
8
+ };
9
+ export type AnnotatedFunction = Function & Annotated & Array<any>;
3
10
  export type ComponentOptions = any;
4
11
  export type ControllerConstructor = Function;
5
12
  export type OnChangesObject = any;
@@ -409,35 +416,3 @@ export type ModelValidators = {
409
416
  export type AsyncModelValidators = {
410
417
  [x: string]: (arg0: any, arg1: any) => Promise<any>;
411
418
  };
412
- export type InjectorService = {
413
- /**
414
- * - Annotate a function or an array of inline annotations.
415
- */
416
- annotate: (arg0: Function, arg1: boolean | undefined) => string[];
417
- /**
418
- * - Get a service by name.
419
- */
420
- get: (arg0: string, arg1: string | undefined) => any;
421
- /**
422
- * - Instantiate a type constructor with optional locals.
423
- */
424
- instantiate: (arg0: Function, arg1: any | null) => any;
425
- /**
426
- * - Invoke a function with optional context and locals.
427
- */
428
- invoke: (arg0: Injectable<Function | ((...args: any[]) => any)>, arg1: any | undefined, arg2: any | undefined) => any;
429
- /**
430
- * - Add and load new modules to the injector.
431
- */
432
- loadNewModules?: (arg0: Array<Module | string | Injectable<(...args: any[]) => void>>) => void;
433
- /**
434
- * - A map of all the modules loaded into the injector.
435
- */
436
- modules?: {
437
- [x: string]: Module;
438
- };
439
- /**
440
- * - Indicates if strict dependency injection is enforced.
441
- */
442
- strictDi?: boolean;
443
- };
package/src/injector.js DELETED
@@ -1,409 +0,0 @@
1
- import {
2
- assertArgFn,
3
- minErr,
4
- forEach,
5
- isFunction,
6
- isString,
7
- isBoolean,
8
- isUndefined,
9
- assertArg,
10
- valueFn,
11
- assertNotHasOwnProperty,
12
- reverseParams,
13
- isObject,
14
- isDefined,
15
- } from "./shared/utils";
16
-
17
- var ARROW_ARG = /^([^(]+?)=>/;
18
- var FN_ARGS = /^[^(]*\(\s*([^)]*)\)/m;
19
- var FN_ARG_SPLIT = /,/;
20
- var FN_ARG = /^\s*(_?)(\S+?)\1\s*$/;
21
- var STRIP_COMMENTS = /((\/\/.*$)|(\/\*[\s\S]*?\*\/))/gm;
22
- var $injectorMinErr = minErr("$injector");
23
-
24
- function stringifyFn(fn) {
25
- return Function.prototype.toString.call(fn);
26
- }
27
-
28
- function extractArgs(fn) {
29
- var fnText = stringifyFn(fn).replace(STRIP_COMMENTS, ""),
30
- args = fnText.match(ARROW_ARG) || fnText.match(FN_ARGS);
31
- return args;
32
- }
33
-
34
- function anonFn(fn) {
35
- // For anonymous functions, showing at the very least the function signature can help in
36
- // debugging.
37
- var args = extractArgs(fn);
38
- if (args) {
39
- return "function(" + (args[1] || "").replace(/[\s\r\n]+/, " ") + ")";
40
- }
41
- return "fn";
42
- }
43
-
44
- function annotate(fn, strictDi, name) {
45
- var $inject, argDecl, last;
46
-
47
- if (typeof fn === "function") {
48
- if (!($inject = fn.$inject)) {
49
- $inject = [];
50
- if (fn.length) {
51
- if (strictDi) {
52
- if (!isString(name) || !name) {
53
- name = fn.name || anonFn(fn);
54
- }
55
- throw $injectorMinErr(
56
- "strictdi",
57
- "{0} is not using explicit annotation and cannot be invoked in strict mode",
58
- name,
59
- );
60
- }
61
- argDecl = extractArgs(fn);
62
- forEach(argDecl[1].split(FN_ARG_SPLIT), function (arg) {
63
- arg.replace(FN_ARG, function (all, underscore, name) {
64
- $inject.push(name);
65
- });
66
- });
67
- }
68
- fn.$inject = $inject;
69
- }
70
- } else if (Array.isArray(fn)) {
71
- last = fn.length - 1;
72
- assertArgFn(fn[last], "fn");
73
- $inject = fn.slice(0, last);
74
- } else {
75
- assertArgFn(fn, "fn", true);
76
- }
77
- return $inject;
78
- }
79
-
80
- const providerSuffix = "Provider";
81
- const INSTANTIATING = {};
82
-
83
- /**
84
- *
85
- * @param {*} modulesToLoad
86
- * @param {*} strictDi
87
- * @returns {import("./types").InjectorService}
88
- */
89
- export function createInjector(modulesToLoad, strictDi) {
90
- if (isDefined(strictDi) && !isBoolean(strictDi)) {
91
- throw $injectorMinErr("strictDi must be boolean");
92
- }
93
- strictDi = !!strictDi;
94
-
95
- const path = [];
96
- const loadedModules = new Map();
97
- const providerCache = {
98
- $provide: {
99
- provider: supportObject(provider),
100
- factory: supportObject(factory),
101
- service: supportObject(service),
102
- value: supportObject(value),
103
- constant: supportObject(constant),
104
- decorator,
105
- },
106
- };
107
-
108
- const providerInjector = (providerCache.$injector = createInternalInjector(
109
- providerCache,
110
- function (serviceName, caller) {
111
- if (isString(caller)) {
112
- path.push(caller);
113
- }
114
- throw $injectorMinErr("unpr", "Unknown provider: {0}", path.join(" <- "));
115
- },
116
- ));
117
- const instanceCache = {};
118
-
119
- let protoInstanceInjector = createInternalInjector(
120
- instanceCache,
121
- (serviceName, caller) => {
122
- const provider = providerInjector.get(
123
- serviceName + providerSuffix,
124
- caller,
125
- );
126
- return instanceInjector.invoke(
127
- provider.$get,
128
- provider,
129
- undefined,
130
- serviceName,
131
- );
132
- },
133
- );
134
-
135
- providerCache["$injector" + providerSuffix] = {
136
- $get: valueFn(protoInstanceInjector),
137
- };
138
- let instanceInjector = protoInstanceInjector;
139
- instanceInjector.modules = providerInjector.modules = Object.create(null);
140
- var runBlocks = loadModules(modulesToLoad);
141
- instanceInjector = protoInstanceInjector.get("$injector");
142
- instanceInjector.strictDi = strictDi;
143
- runBlocks.forEach((fn) => {
144
- if (fn) instanceInjector.invoke(fn);
145
- });
146
-
147
- instanceInjector.loadNewModules = function (mods) {
148
- loadModules(mods).forEach((fn) => {
149
- if (fn) instanceInjector.invoke(fn);
150
- });
151
- };
152
-
153
- return instanceInjector;
154
-
155
- ////////////////////////////////////
156
- // $provider
157
- ////////////////////////////////////
158
-
159
- function supportObject(delegate) {
160
- return function (key, value) {
161
- if (isObject(key)) {
162
- forEach(key, reverseParams(delegate));
163
- } else {
164
- return delegate(key, value);
165
- }
166
- };
167
- }
168
-
169
- function provider(name, provider_) {
170
- assertNotHasOwnProperty(name, "service");
171
- if (isFunction(provider_) || Array.isArray(provider_)) {
172
- provider_ = providerInjector.instantiate(provider_);
173
- }
174
- if (!provider_.$get) {
175
- throw $injectorMinErr(
176
- "pget",
177
- "Provider '{0}' must define $get factory method.",
178
- name,
179
- );
180
- }
181
- return (providerCache[name + providerSuffix] = provider_);
182
- }
183
-
184
- function enforceReturnValue(name, factory) {
185
- return function enforcedReturnValue() {
186
- const result = instanceInjector.invoke(factory, this);
187
- if (isUndefined(result)) {
188
- throw $injectorMinErr(
189
- "undef",
190
- "Provider '{0}' must return a value from $get factory method.",
191
- name,
192
- );
193
- }
194
- return result;
195
- };
196
- }
197
-
198
- function factory(name, factoryFn, enforce) {
199
- return provider(name, {
200
- $get: enforce !== false ? enforceReturnValue(name, factoryFn) : factoryFn,
201
- });
202
- }
203
-
204
- function service(name, constructor) {
205
- return factory(name, [
206
- "$injector",
207
- function ($injector) {
208
- return $injector.instantiate(constructor);
209
- },
210
- ]);
211
- }
212
-
213
- function value(name, val) {
214
- return factory(name, valueFn(val), false);
215
- }
216
-
217
- function constant(name, value) {
218
- assertNotHasOwnProperty(name, "constant");
219
- providerCache[name] = value;
220
- instanceCache[name] = value;
221
- }
222
-
223
- function decorator(serviceName, decorFn) {
224
- const origProvider = providerInjector.get(serviceName + providerSuffix);
225
- const orig$get = origProvider.$get;
226
-
227
- origProvider.$get = function () {
228
- const origInstance = instanceInjector.invoke(orig$get, origProvider);
229
- return instanceInjector.invoke(decorFn, null, {
230
- $delegate: origInstance,
231
- });
232
- };
233
- }
234
-
235
- ////////////////////////////////////
236
- // Module Loading
237
- ////////////////////////////////////
238
- function loadModules(modulesToLoad) {
239
- assertArg(
240
- isUndefined(modulesToLoad) || Array.isArray(modulesToLoad),
241
- "modulesToLoad",
242
- "not an array",
243
- );
244
- let runBlocks = [];
245
- let moduleFn;
246
- forEach(modulesToLoad, (module) => {
247
- if (loadedModules.get(module)) return;
248
- loadedModules.set(module, true);
249
-
250
- function runInvokeQueue(queue) {
251
- queue.forEach((invokeArgs) => {
252
- const provider = providerInjector.get(invokeArgs[0]);
253
- provider[invokeArgs[1]].apply(provider, invokeArgs[2]);
254
- });
255
- }
256
-
257
- try {
258
- if (isString(module)) {
259
- moduleFn = window["angular"].module(module);
260
- instanceInjector.modules[module] = moduleFn;
261
- runBlocks = runBlocks
262
- .concat(loadModules(moduleFn.requires))
263
- // @ts-ignore
264
- .concat(moduleFn._runBlocks);
265
- // @ts-ignore
266
- runInvokeQueue(moduleFn._invokeQueue);
267
- // @ts-ignore
268
- runInvokeQueue(moduleFn._configBlocks);
269
- } else if (isFunction(module)) {
270
- runBlocks.push(providerInjector.invoke(module));
271
- } else if (Array.isArray(module)) {
272
- runBlocks.push(providerInjector.invoke(module));
273
- } else {
274
- assertArgFn(module, "module");
275
- }
276
- } catch (e) {
277
- if (Array.isArray(module)) {
278
- module = module[module.length - 1];
279
- }
280
- if (e.message && e.stack && e.stack.indexOf(e.message) === -1) {
281
- // Safari & FF's stack traces don't contain error.message content
282
- // unlike those of Chrome and IE
283
- // So if stack doesn't contain message, we create a new string that contains both.
284
- // Since error.stack is read-only in Safari, I'm overriding e and not e.stack here.
285
-
286
- e = `${e.message}\n${e.stack}`;
287
- }
288
- throw $injectorMinErr(
289
- "modulerr",
290
- "Failed to instantiate module {0} due to:\n{1}",
291
- module,
292
- e.stack || e.message || e,
293
- );
294
- }
295
- });
296
- return runBlocks;
297
- }
298
-
299
- ////////////////////////////////////
300
- // internal Injector
301
- ////////////////////////////////////
302
-
303
- function createInternalInjector(cache, factory) {
304
- function get(serviceName, caller) {
305
- if (Object.prototype.hasOwnProperty.call(cache, serviceName)) {
306
- if (cache[serviceName] === INSTANTIATING) {
307
- throw $injectorMinErr(
308
- "cdep",
309
- "Circular dependency found: {0}",
310
- `${serviceName} <- ${path.join(" <- ")}`,
311
- );
312
- }
313
- return cache[serviceName];
314
- }
315
- try {
316
- path.unshift(serviceName);
317
- cache[serviceName] = INSTANTIATING;
318
- cache[serviceName] = factory(serviceName, caller);
319
- return cache[serviceName];
320
- } catch (err) {
321
- if (cache[serviceName] === INSTANTIATING) {
322
- delete cache[serviceName];
323
- }
324
- throw err;
325
- } finally {
326
- path.shift();
327
- }
328
- }
329
-
330
- function injectionArgs(fn, locals, serviceName) {
331
- const args = [];
332
- const $inject = annotate(fn, strictDi, serviceName);
333
-
334
- for (let i = 0, { length } = $inject; i < length; i++) {
335
- const key = $inject[i];
336
- if (typeof key !== "string") {
337
- throw $injectorMinErr(
338
- "itkn",
339
- "Incorrect injection token! Expected service name as string, got {0}",
340
- key,
341
- );
342
- }
343
- args.push(
344
- locals && Object.prototype.hasOwnProperty.call(locals, key)
345
- ? locals[key]
346
- : get(key, serviceName),
347
- );
348
- }
349
- return args;
350
- }
351
-
352
- function isClass(func) {
353
- let result = func.$$ngIsClass;
354
- if (!isBoolean(result)) {
355
- result = func.$$ngIsClass = /^class\b/.test(stringifyFn(func));
356
- }
357
- return result;
358
- }
359
-
360
- function invoke(fn, self, locals, serviceName) {
361
- if (typeof locals === "string") {
362
- serviceName = locals;
363
- locals = null;
364
- }
365
-
366
- const args = injectionArgs(fn, locals, serviceName);
367
- if (Array.isArray(fn)) {
368
- fn = fn[fn.length - 1];
369
- }
370
-
371
- if (!isClass(fn)) {
372
- // http://jsperf.com/angularjs-invoke-apply-vs-switch
373
- // #5388
374
- return fn.apply(self, args);
375
- }
376
- args.unshift(null);
377
- return new (Function.prototype.bind.apply(fn, args))();
378
- }
379
-
380
- function instantiate(Type, locals, serviceName) {
381
- // Check if Type is annotated and use just the given function at n-1 as parameter
382
- // e.g. someModule.factory('greeter', ['$window', function(renamed$window) {}]);
383
- const ctor = Array.isArray(Type) ? Type[Type.length - 1] : Type;
384
- const args = injectionArgs(Type, locals, serviceName);
385
- // Empty object at position 0 is ignored for invocation with `new`, but required.
386
- args.unshift(null);
387
- return new (Function.prototype.bind.apply(ctor, args))();
388
- }
389
-
390
- function has(name) {
391
- const hasProvider = Object.prototype.hasOwnProperty.call(
392
- providerCache,
393
- name + providerSuffix,
394
- );
395
- const hasCache = Object.prototype.hasOwnProperty.call(cache, name);
396
- return hasProvider || hasCache;
397
- }
398
-
399
- return {
400
- invoke,
401
- instantiate,
402
- get,
403
- annotate,
404
- has,
405
- };
406
- }
407
- }
408
-
409
- createInjector.$$annotate = annotate;
@@ -1,12 +0,0 @@
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
- export namespace createInjector {
9
- export { annotate as $$annotate };
10
- }
11
- declare function annotate(fn: any, strictDi: any, name: any): any;
12
- export {};