@angular-wave/angular.ts 0.0.63 → 0.0.65
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/Makefile +6 -2
- package/dist/angular-ts.esm.js +2 -2
- package/dist/angular-ts.umd.js +2 -2
- package/package.json +1 -1
- package/public/jasmine/jasmine-5.1.2/jasmine-html.js +0 -1
- package/src/angular.spec.js +14 -19
- package/src/animations/module.js +2 -2
- package/src/binding.spec.js +7 -4
- package/src/core/animate/animate.spec.js +2 -4
- package/src/core/cache/cache-factory.spec.js +3 -3
- package/src/core/compile/compile.spec.js +66 -60
- package/src/core/controller/controller.spec.js +3 -3
- package/src/core/cookie-reader.spec.js +3 -3
- package/src/core/di/injector.html +18 -0
- package/src/{injector.js → core/di/injector.js} +58 -45
- package/src/{injector.spec.js → core/di/injector.spec.js} +44 -34
- package/src/core/di/injector.test.js +12 -0
- package/src/core/di/ng-module.html +18 -0
- package/src/core/di/ng-module.js +202 -0
- package/src/core/di/ng-module.spec.js +269 -0
- package/src/core/di/ng-module.test.js +12 -0
- package/src/core/filter/filter.spec.js +5 -5
- package/src/core/interpolate/interpolate.spec.js +3 -3
- package/src/core/interval/interval.spec.js +11 -8
- package/src/core/location/location.spec.js +3 -3
- package/src/core/on.spec.js +3 -3
- package/src/core/parser/lexer.spec.js +12 -9
- package/src/core/parser/parse.spec.js +12 -9
- package/src/core/prop.spec.js +48 -36
- package/src/core/q/q.spec.js +7 -10
- package/src/core/q/q.test.js +12 -0
- package/src/core/root-element.spec.js +0 -2
- package/src/core/sce/sce.spec.js +8 -7
- package/src/core/scope/scope.js +0 -1
- package/src/core/scope/scope.spec.js +12 -9
- package/src/core/timeout/timeout.spec.js +11 -8
- package/src/directive/attrs/attrs.spec.js +6 -5
- package/src/directive/attrs/boolean.spec.js +3 -3
- package/src/directive/attrs/element-style.spec.js +5 -4
- package/src/directive/attrs/src.spec.js +9 -7
- package/src/directive/bind/bind.spec.js +12 -9
- package/src/directive/bind/bing-html.spec.js +3 -3
- package/src/directive/change/change.spec.js +3 -3
- package/src/directive/class/class.spec.js +3 -3
- package/src/directive/cloak/cloak.spec.js +3 -3
- package/src/directive/controller/controller.spec.js +3 -4
- package/src/directive/events/click.spec.js +4 -4
- package/src/directive/events/event.spec.js +16 -13
- package/src/directive/form/form.spec.js +12 -10
- package/src/directive/if/if.spec.js +2 -3
- package/src/directive/include/include.spec.js +12 -11
- package/src/directive/init/init.spec.js +3 -4
- package/src/directive/input/input.spec.js +11 -9
- package/src/directive/list/list.spec.js +4 -4
- package/src/directive/model/model.spec.js +12 -12
- package/src/directive/model-options/model-options.spec.js +12 -10
- package/src/directive/non-bindable/non-bindable.spec.js +12 -9
- package/src/directive/options/options.spec.js +11 -8
- package/src/directive/ref/href.spec.js +12 -9
- package/src/directive/ref/ref.spec.js +11 -8
- package/src/directive/repeat/repeat.spec.js +12 -11
- package/src/directive/script/script.spec.js +5 -4
- package/src/directive/select/select.spec.js +11 -8
- package/src/directive/show-hide/show-hide.spec.js +5 -4
- package/src/directive/style/style.spec.js +10 -7
- package/src/directive/switch/switch.spec.js +3 -3
- package/src/directive/validators/validators.spec.js +13 -10
- package/src/exts/aria/aria.js +2 -2
- package/src/exts/aria/aria.spec.js +3 -3
- package/src/exts/messages/messages.js +2 -2
- package/src/exts/messages/messages.spec.js +3 -3
- package/src/filters/filter.spec.js +5 -4
- package/src/filters/filters.spec.js +5 -4
- package/src/filters/limit-to.spec.js +5 -4
- package/src/filters/order-by.spec.js +8 -6
- package/src/index.js +2 -8
- package/src/loader.js +107 -539
- package/src/loader.md +142 -0
- package/src/loader.spec.js +8 -27
- package/src/public.js +113 -107
- package/src/public.spec.js +3 -5
- package/src/router/directives/state-directives.spec.js +0 -3
- package/src/router/directives/view-directive.spec.js +0 -6
- package/src/router/index.js +2 -2
- package/src/router/services.spec.js +0 -2
- package/src/router/state/state.spec.js +2 -4
- package/src/router/state-filter.spec.js +0 -2
- package/src/router/template-factory.spec.js +0 -2
- package/src/router/url/url-service.spec.js +0 -2
- package/src/router/view/view.spec.js +1 -2
- package/src/router/view-hook.spec.js +0 -2
- package/src/router/view-scroll.spec.js +0 -3
- package/src/services/http/http.spec.js +3 -3
- package/src/services/http/template-request.spec.js +4 -4
- package/src/services/http-backend/http-backend.spec.js +4 -3
- package/src/shared/jqlite/jqlite.js +0 -2
- package/src/shared/jqlite/jqlite.spec.js +4 -5
- package/src/shared/test-utils.js +1 -1
- package/src/shared/utils.js +10 -1
- package/src/src.html +0 -1
- package/types/animations/module.d.ts +1 -1
- package/types/core/di/injector.d.ts +12 -0
- package/types/core/di/ng-module.d.ts +79 -0
- package/types/exts/aria/aria.d.ts +1 -1
- package/types/exts/messages/messages.d.ts +1 -1
- package/types/index.d.ts +0 -3
- package/types/loader.d.ts +53 -179
- package/types/public.d.ts +6 -1
- package/types/router/index.d.ts +1 -1
- package/types/shared/test-utils.d.ts +3 -2
- package/types/shared/utils.d.ts +7 -1
- package/types/injector.d.ts +0 -12
- /package/src/{injector.md → core/di/injector.md} +0 -0
|
@@ -1,11 +1,10 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Angular } from "../../loader";
|
|
2
2
|
import { createInjector } from "./injector";
|
|
3
|
-
import {
|
|
4
|
-
import { valueFn, extend } from "./shared/utils";
|
|
3
|
+
import { valueFn, extend } from "../../shared/utils";
|
|
5
4
|
|
|
6
5
|
describe("injector.modules", () => {
|
|
7
6
|
beforeEach(() => {
|
|
8
|
-
|
|
7
|
+
window.angular = new Angular();
|
|
9
8
|
});
|
|
10
9
|
|
|
11
10
|
it("can be created", () => {
|
|
@@ -14,7 +13,7 @@ describe("injector.modules", () => {
|
|
|
14
13
|
});
|
|
15
14
|
|
|
16
15
|
it("should have $injector", () => {
|
|
17
|
-
const $injector = createInjector();
|
|
16
|
+
const $injector = createInjector([]);
|
|
18
17
|
expect($injector.get("$injector")).toBe($injector);
|
|
19
18
|
});
|
|
20
19
|
|
|
@@ -275,7 +274,7 @@ describe("injector.modules", () => {
|
|
|
275
274
|
expect(injector.invoke(fn)).toBe(3);
|
|
276
275
|
});
|
|
277
276
|
|
|
278
|
-
it("invokes
|
|
277
|
+
it("invokes a class with static property with dependency injection", () => {
|
|
279
278
|
const module = angular.module("myModule", []);
|
|
280
279
|
module.constant("a", 1);
|
|
281
280
|
module.constant("b", 2);
|
|
@@ -289,6 +288,20 @@ describe("injector.modules", () => {
|
|
|
289
288
|
expect(injector.invoke(Foo).c).toBe(3);
|
|
290
289
|
});
|
|
291
290
|
|
|
291
|
+
it("invokes an annotated class with dependency injection", () => {
|
|
292
|
+
const module = angular.module("myModule", []);
|
|
293
|
+
module.constant("a", 1);
|
|
294
|
+
module.constant("b", 2);
|
|
295
|
+
const injector = createInjector(["myModule"]);
|
|
296
|
+
class Foo {
|
|
297
|
+
constructor(a, b) {
|
|
298
|
+
this.c = a + b;
|
|
299
|
+
}
|
|
300
|
+
}
|
|
301
|
+
Foo.$inject = ["a", "b"];
|
|
302
|
+
expect(injector.invoke(Foo).c).toBe(3);
|
|
303
|
+
});
|
|
304
|
+
|
|
292
305
|
it("does not accept non-strings as injection tokens", () => {
|
|
293
306
|
const module = angular.module("myModule", []);
|
|
294
307
|
module.constant("a", 1);
|
|
@@ -326,7 +339,7 @@ describe("injector.modules", () => {
|
|
|
326
339
|
return one + this.two;
|
|
327
340
|
},
|
|
328
341
|
};
|
|
329
|
-
|
|
342
|
+
expect(injector.invoke(["a", obj.fn], obj)).toBe(3);
|
|
330
343
|
});
|
|
331
344
|
|
|
332
345
|
it("overrides dependencies with locals when invoking", () => {
|
|
@@ -376,7 +389,7 @@ describe("annotate", () => {
|
|
|
376
389
|
let annotate;
|
|
377
390
|
let injector;
|
|
378
391
|
beforeEach(() => {
|
|
379
|
-
|
|
392
|
+
window.angular = new Angular();
|
|
380
393
|
injector = createInjector([]);
|
|
381
394
|
annotate = injector.annotate;
|
|
382
395
|
});
|
|
@@ -393,7 +406,6 @@ describe("annotate", () => {
|
|
|
393
406
|
|
|
394
407
|
it("should create $inject", () => {
|
|
395
408
|
const extraParams = () => {};
|
|
396
|
-
/* eslint-disable space-before-function-paren */
|
|
397
409
|
// keep the multi-line to make sure we can handle it
|
|
398
410
|
function $f_n0 /*
|
|
399
411
|
*/(
|
|
@@ -672,7 +684,7 @@ describe("annotate", () => {
|
|
|
672
684
|
});
|
|
673
685
|
|
|
674
686
|
describe("provider", () => {
|
|
675
|
-
beforeEach(() =>
|
|
687
|
+
beforeEach(() => (window.angular = new Angular()));
|
|
676
688
|
|
|
677
689
|
it("allows registering a provider and uses its $get", () => {
|
|
678
690
|
const module = angular.module("myModule", []);
|
|
@@ -974,7 +986,7 @@ describe("provider", () => {
|
|
|
974
986
|
});
|
|
975
987
|
|
|
976
988
|
describe("$provide", () => {
|
|
977
|
-
beforeEach(() =>
|
|
989
|
+
beforeEach(() => (window.angular = new Angular()));
|
|
978
990
|
|
|
979
991
|
it("should inject providers", () => {
|
|
980
992
|
const module = angular.module("myModule", []);
|
|
@@ -1018,7 +1030,7 @@ describe("$provide", () => {
|
|
|
1018
1030
|
});
|
|
1019
1031
|
|
|
1020
1032
|
describe("config/run", () => {
|
|
1021
|
-
beforeEach(() =>
|
|
1033
|
+
beforeEach(() => (window.angular = new Angular()));
|
|
1022
1034
|
|
|
1023
1035
|
it("runs config blocks when the injector is created", () => {
|
|
1024
1036
|
const module = angular.module("myModule", []);
|
|
@@ -1093,7 +1105,7 @@ describe("config/run", () => {
|
|
|
1093
1105
|
});
|
|
1094
1106
|
|
|
1095
1107
|
describe("function modules", () => {
|
|
1096
|
-
beforeEach(() =>
|
|
1108
|
+
beforeEach(() => (window.angular = new Angular()));
|
|
1097
1109
|
|
|
1098
1110
|
it("runs a function module dependency as a config block", () => {
|
|
1099
1111
|
const functionModule = ($provide) => {
|
|
@@ -1141,7 +1153,7 @@ describe("function modules", () => {
|
|
|
1141
1153
|
});
|
|
1142
1154
|
|
|
1143
1155
|
describe("factories", () => {
|
|
1144
|
-
beforeEach(() =>
|
|
1156
|
+
beforeEach(() => (window.angular = new Angular()));
|
|
1145
1157
|
|
|
1146
1158
|
it("allows registering a factory", function () {
|
|
1147
1159
|
var module = angular.module("myModule", []);
|
|
@@ -1201,7 +1213,7 @@ describe("factories", () => {
|
|
|
1201
1213
|
});
|
|
1202
1214
|
|
|
1203
1215
|
describe("values", () => {
|
|
1204
|
-
beforeEach(() =>
|
|
1216
|
+
beforeEach(() => (window.angular = new Angular()));
|
|
1205
1217
|
|
|
1206
1218
|
it("allows registering a value", function () {
|
|
1207
1219
|
var module = angular.module("myModule", []);
|
|
@@ -1228,7 +1240,7 @@ describe("values", () => {
|
|
|
1228
1240
|
});
|
|
1229
1241
|
|
|
1230
1242
|
describe("services", () => {
|
|
1231
|
-
beforeEach(() =>
|
|
1243
|
+
beforeEach(() => (window.angular = new Angular()));
|
|
1232
1244
|
|
|
1233
1245
|
it("allows registering a service", function () {
|
|
1234
1246
|
var module = angular.module("myModule", []);
|
|
@@ -1280,7 +1292,7 @@ describe("services", () => {
|
|
|
1280
1292
|
});
|
|
1281
1293
|
|
|
1282
1294
|
describe("decorators", () => {
|
|
1283
|
-
beforeEach(() =>
|
|
1295
|
+
beforeEach(() => (window.angular = new Angular()));
|
|
1284
1296
|
|
|
1285
1297
|
it("allows changing an instance using a decorator", function () {
|
|
1286
1298
|
var module = angular.module("myModule", []);
|
|
@@ -1331,19 +1343,20 @@ describe("decorators", () => {
|
|
|
1331
1343
|
});
|
|
1332
1344
|
|
|
1333
1345
|
describe("controllers", () => {
|
|
1334
|
-
beforeEach(() =>
|
|
1346
|
+
beforeEach(() => (window.angular = new Angular()));
|
|
1335
1347
|
|
|
1336
1348
|
it("should provide the caller name for controllers", () => {
|
|
1337
|
-
angular
|
|
1349
|
+
window.angular
|
|
1350
|
+
.module("myModule", [])
|
|
1351
|
+
.controller("myCtrl", (idontexist) => {});
|
|
1338
1352
|
expect(() => {
|
|
1339
1353
|
createInjector(["myModule"]).get("$controller");
|
|
1340
1354
|
}).toThrowError(/Unknown provider/);
|
|
1341
1355
|
});
|
|
1342
1356
|
|
|
1343
1357
|
it("should be able to register a controller from a new module", () => {
|
|
1344
|
-
publishExternalAPI();
|
|
1345
1358
|
const injector = createInjector(["ng"]);
|
|
1346
|
-
angular
|
|
1359
|
+
window.angular
|
|
1347
1360
|
.module("a", [])
|
|
1348
1361
|
.controller("aController", function Controller($scope) {
|
|
1349
1362
|
$scope.test = "b";
|
|
@@ -1358,12 +1371,11 @@ describe("controllers", () => {
|
|
|
1358
1371
|
});
|
|
1359
1372
|
|
|
1360
1373
|
describe("filters", () => {
|
|
1361
|
-
beforeEach(() =>
|
|
1374
|
+
beforeEach(() => (window.angular = new Angular()));
|
|
1362
1375
|
|
|
1363
1376
|
it("should be able to register a filter from a new module", () => {
|
|
1364
|
-
publishExternalAPI();
|
|
1365
1377
|
const injector = createInjector(["ng"]);
|
|
1366
|
-
angular.module("a", []).filter(
|
|
1378
|
+
window.angular.module("a", []).filter(
|
|
1367
1379
|
"aFilter",
|
|
1368
1380
|
() =>
|
|
1369
1381
|
function (input) {
|
|
@@ -1379,12 +1391,12 @@ describe("filters", () => {
|
|
|
1379
1391
|
|
|
1380
1392
|
describe("directive", () => {
|
|
1381
1393
|
beforeEach(() => {
|
|
1382
|
-
|
|
1394
|
+
window.angular = new Angular();
|
|
1383
1395
|
});
|
|
1384
1396
|
|
|
1385
1397
|
it("should be able to register a directive from a new module", () => {
|
|
1386
1398
|
const injector = createInjector(["ng"]);
|
|
1387
|
-
angular
|
|
1399
|
+
window.angular
|
|
1388
1400
|
.module("a", [])
|
|
1389
1401
|
.directive("aDirective", () => ({ template: "test directive" }));
|
|
1390
1402
|
injector.loadNewModules(["a"]);
|
|
@@ -1398,7 +1410,7 @@ describe("directive", () => {
|
|
|
1398
1410
|
|
|
1399
1411
|
it("should be able to register a directive from a new module", () => {
|
|
1400
1412
|
const injector = createInjector(["ng"]);
|
|
1401
|
-
angular
|
|
1413
|
+
window.angular
|
|
1402
1414
|
.module("a", [])
|
|
1403
1415
|
.directive("aDirective", () => ({ template: "test directive" }));
|
|
1404
1416
|
injector.loadNewModules(["a"]);
|
|
@@ -1413,7 +1425,7 @@ describe("directive", () => {
|
|
|
1413
1425
|
|
|
1414
1426
|
it("should define module", () => {
|
|
1415
1427
|
let log = "";
|
|
1416
|
-
|
|
1428
|
+
createInjector([
|
|
1417
1429
|
function ($provide) {
|
|
1418
1430
|
$provide.value("value", "value;");
|
|
1419
1431
|
$provide.factory("fn", valueFn("function;"));
|
|
@@ -1432,7 +1444,7 @@ it("should define module", () => {
|
|
|
1432
1444
|
|
|
1433
1445
|
describe("module", () => {
|
|
1434
1446
|
beforeEach(() => {
|
|
1435
|
-
|
|
1447
|
+
window.angular = new Angular();
|
|
1436
1448
|
});
|
|
1437
1449
|
|
|
1438
1450
|
it("should provide $injector even when no module is requested", () => {
|
|
@@ -1485,9 +1497,7 @@ describe("module", () => {
|
|
|
1485
1497
|
it("should error on invalid module name", () => {
|
|
1486
1498
|
expect(() => {
|
|
1487
1499
|
createInjector(["IDontExist"], true);
|
|
1488
|
-
}).toThrowError(
|
|
1489
|
-
/\[\$injector:nomod] Module 'IDontExist' is not available! You either misspelled the module name or forgot to load it/,
|
|
1490
|
-
);
|
|
1500
|
+
}).toThrowError(/nomod/);
|
|
1491
1501
|
});
|
|
1492
1502
|
|
|
1493
1503
|
it("should load dependant modules only once", () => {
|
|
@@ -1770,7 +1780,7 @@ describe("decorator", () => {
|
|
|
1770
1780
|
|
|
1771
1781
|
beforeEach(() => {
|
|
1772
1782
|
log = [];
|
|
1773
|
-
|
|
1783
|
+
window.angular = new Angular();
|
|
1774
1784
|
});
|
|
1775
1785
|
|
|
1776
1786
|
it("should be called with the original instance", () => {
|
|
@@ -2253,7 +2263,7 @@ describe("strict-di injector", () => {
|
|
|
2253
2263
|
let module;
|
|
2254
2264
|
let $injector;
|
|
2255
2265
|
beforeEach(() => {
|
|
2256
|
-
|
|
2266
|
+
window.angular = new Angular();
|
|
2257
2267
|
module = angular.module("test1", []);
|
|
2258
2268
|
$injector = createInjector(["test1"], true);
|
|
2259
2269
|
});
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { test, expect } from "@playwright/test";
|
|
2
|
+
|
|
3
|
+
const TEST_URL = "src/core/di/injector.html";
|
|
4
|
+
|
|
5
|
+
test("unit tests contain no errors", async ({ page }) => {
|
|
6
|
+
await page.goto(TEST_URL);
|
|
7
|
+
await page.content();
|
|
8
|
+
await page.waitForTimeout(5000);
|
|
9
|
+
await expect(page.locator(".jasmine-overall-result")).toHaveText(
|
|
10
|
+
/0 failures/,
|
|
11
|
+
);
|
|
12
|
+
});
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
<!doctype html>
|
|
2
|
+
<html>
|
|
3
|
+
<head>
|
|
4
|
+
<meta charset="utf-8" />
|
|
5
|
+
<title>AngularTS Test Runner</title>
|
|
6
|
+
|
|
7
|
+
<link rel="shortcut icon" type="image/png" href="/images/favicon.ico" />
|
|
8
|
+
<link rel="stylesheet" href="/jasmine/jasmine-5.1.2/jasmine.css" />
|
|
9
|
+
<script src="/jasmine/jasmine-5.1.2/jasmine.js"></script>
|
|
10
|
+
<script src="/jasmine/jasmine-5.1.2/jasmine-html.js"></script>
|
|
11
|
+
<script src="/jasmine/jasmine-5.1.2/boot0.js"></script>
|
|
12
|
+
<script src="/jasmine/jasmine-5.1.2/boot1.js"></script>
|
|
13
|
+
<script type="module" src="/src/core/di/ng-module.spec.js"></script>
|
|
14
|
+
</head>
|
|
15
|
+
<body>
|
|
16
|
+
<div id="dummy"></div>
|
|
17
|
+
</body>
|
|
18
|
+
</html>
|
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
import {
|
|
2
|
+
isFunction,
|
|
3
|
+
isDefined,
|
|
4
|
+
isObject,
|
|
5
|
+
isString,
|
|
6
|
+
assert,
|
|
7
|
+
} from "../../shared/utils";
|
|
8
|
+
|
|
9
|
+
export const PROVIDE_LITERAL = "$provide";
|
|
10
|
+
export const INJECTOR_LITERAL = "$injector";
|
|
11
|
+
export const COMPILE_LITERAL = "$compileProvider";
|
|
12
|
+
export const ANIMATION_LITERAL = "$animateProvider";
|
|
13
|
+
export const FILTER_LITERAL = "$filterProvider";
|
|
14
|
+
export const CONTROLLER_LITERAL = "$controllerProvider";
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Modules are collections of application configuration information for components:
|
|
18
|
+
* controllers, directives, filters, etc. They provide recipes for the injector
|
|
19
|
+
* to do the actual instantiation. A module itself has no behaviour but only state.
|
|
20
|
+
* A such, it acts as a data structure between the Angular instance and the injector service.
|
|
21
|
+
*
|
|
22
|
+
* Since this is an internal structure that is exposed only via the Angular instance,
|
|
23
|
+
* it contains no validation of the items it receives. It is up to the instantiator on
|
|
24
|
+
* modules to do the actual validation.
|
|
25
|
+
*/
|
|
26
|
+
export class NgModule {
|
|
27
|
+
/**
|
|
28
|
+
*
|
|
29
|
+
* @param {String} name - Name of the module
|
|
30
|
+
* @param {Array<String>} requires - List of modules which the injector will load before the current module
|
|
31
|
+
* @param {Function} [configFn]
|
|
32
|
+
*/
|
|
33
|
+
constructor(name, requires, configFn) {
|
|
34
|
+
assert(isString(name), "name required");
|
|
35
|
+
assert(Array.isArray(requires), "requires array required");
|
|
36
|
+
/**
|
|
37
|
+
* @type {string}
|
|
38
|
+
* Name of the module.
|
|
39
|
+
*/
|
|
40
|
+
this.name = name;
|
|
41
|
+
/**
|
|
42
|
+
* Holds the list of modules which the injector will load before the current module is
|
|
43
|
+
* loaded.
|
|
44
|
+
*/
|
|
45
|
+
this.requires = requires;
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* Holds a collection of tasks, required to instantiate an angular component
|
|
49
|
+
* @type {!Array<Array<*>>}
|
|
50
|
+
*/
|
|
51
|
+
this.invokeQueue = [];
|
|
52
|
+
|
|
53
|
+
/** @type {!Array<Array<*>>} */
|
|
54
|
+
this.configBlocks = [];
|
|
55
|
+
|
|
56
|
+
/** @type {!Array.<Function>} */
|
|
57
|
+
this.runBlocks = [];
|
|
58
|
+
|
|
59
|
+
/** @type {Object} */
|
|
60
|
+
this.infoState = {};
|
|
61
|
+
|
|
62
|
+
if (configFn) {
|
|
63
|
+
this.config(configFn);
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
/**
|
|
68
|
+
* @param {Object} value
|
|
69
|
+
* @returns
|
|
70
|
+
*/
|
|
71
|
+
info(value) {
|
|
72
|
+
if (isDefined(value)) {
|
|
73
|
+
assert(isObject(value), "module info value must be an object");
|
|
74
|
+
this.infoState = value;
|
|
75
|
+
return this;
|
|
76
|
+
}
|
|
77
|
+
return this.infoState;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
/**
|
|
81
|
+
* @param {String} name
|
|
82
|
+
* @param {any} object
|
|
83
|
+
* @returns {NgModule}
|
|
84
|
+
*/
|
|
85
|
+
value(name, object) {
|
|
86
|
+
this.invokeQueue.push([PROVIDE_LITERAL, "value", [name, object]]);
|
|
87
|
+
return this;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
/**
|
|
91
|
+
* @param {String} name
|
|
92
|
+
* @param {any} object
|
|
93
|
+
* @returns {NgModule}
|
|
94
|
+
*/
|
|
95
|
+
constant(name, object) {
|
|
96
|
+
this.invokeQueue.unshift([PROVIDE_LITERAL, "constant", [name, object]]);
|
|
97
|
+
return this;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
/**
|
|
101
|
+
*
|
|
102
|
+
* @param {Function} configFn
|
|
103
|
+
* @returns {NgModule}
|
|
104
|
+
*/
|
|
105
|
+
config(configFn) {
|
|
106
|
+
this.configBlocks.push([INJECTOR_LITERAL, "invoke", [configFn]]);
|
|
107
|
+
return this;
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
run(block) {
|
|
111
|
+
this.runBlocks.push(block);
|
|
112
|
+
return this;
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
component(name, options) {
|
|
116
|
+
if (options && isFunction(options)) {
|
|
117
|
+
options.$$moduleName = name;
|
|
118
|
+
}
|
|
119
|
+
this.invokeQueue.push([COMPILE_LITERAL, "component", [name, options]]);
|
|
120
|
+
return this;
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
factory(name, providerFunction) {
|
|
124
|
+
if (providerFunction && isFunction(providerFunction)) {
|
|
125
|
+
providerFunction.$$moduleName = name;
|
|
126
|
+
}
|
|
127
|
+
this.invokeQueue.push([
|
|
128
|
+
PROVIDE_LITERAL,
|
|
129
|
+
"factory",
|
|
130
|
+
[name, providerFunction],
|
|
131
|
+
]);
|
|
132
|
+
return this;
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
service(name, serviceFunction) {
|
|
136
|
+
if (serviceFunction && isFunction(serviceFunction)) {
|
|
137
|
+
serviceFunction.$$moduleName = name;
|
|
138
|
+
}
|
|
139
|
+
this.invokeQueue.push([
|
|
140
|
+
PROVIDE_LITERAL,
|
|
141
|
+
"service",
|
|
142
|
+
[name, serviceFunction],
|
|
143
|
+
]);
|
|
144
|
+
return this;
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
provider(name, providerType) {
|
|
148
|
+
if (providerType && isFunction(providerType)) {
|
|
149
|
+
providerType.$$moduleName = name;
|
|
150
|
+
}
|
|
151
|
+
this.invokeQueue.push([PROVIDE_LITERAL, "provider", [name, providerType]]);
|
|
152
|
+
return this;
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
decorator(name, decorFn) {
|
|
156
|
+
if (decorFn && isFunction(decorFn)) {
|
|
157
|
+
decorFn.$$moduleName = name;
|
|
158
|
+
}
|
|
159
|
+
this.configBlocks.push([PROVIDE_LITERAL, "decorator", [name, decorFn]]);
|
|
160
|
+
return this;
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
directive(name, directiveFactory) {
|
|
164
|
+
if (directiveFactory && isFunction(directiveFactory)) {
|
|
165
|
+
directiveFactory.$$moduleName = name;
|
|
166
|
+
}
|
|
167
|
+
this.invokeQueue.push([
|
|
168
|
+
COMPILE_LITERAL,
|
|
169
|
+
"directive",
|
|
170
|
+
[name, directiveFactory],
|
|
171
|
+
]);
|
|
172
|
+
return this;
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
animation(name, animationFactory) {
|
|
176
|
+
if (animationFactory && isFunction(animationFactory)) {
|
|
177
|
+
animationFactory.$$moduleName = name;
|
|
178
|
+
}
|
|
179
|
+
this.invokeQueue.push([
|
|
180
|
+
ANIMATION_LITERAL,
|
|
181
|
+
"register",
|
|
182
|
+
[name, animationFactory],
|
|
183
|
+
]);
|
|
184
|
+
return this;
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
filter(name, filterFn) {
|
|
188
|
+
if (filterFn && isFunction(filterFn)) {
|
|
189
|
+
filterFn.$$moduleName = name;
|
|
190
|
+
}
|
|
191
|
+
this.invokeQueue.push([FILTER_LITERAL, "register", [name, filterFn]]);
|
|
192
|
+
return this;
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
controller(name, ctlFn) {
|
|
196
|
+
if (ctlFn && isFunction(ctlFn)) {
|
|
197
|
+
ctlFn.$$moduleName = name;
|
|
198
|
+
}
|
|
199
|
+
this.invokeQueue.push([CONTROLLER_LITERAL, "register", [name, ctlFn]]);
|
|
200
|
+
return this;
|
|
201
|
+
}
|
|
202
|
+
}
|