@angular-wave/angular.ts 0.0.66 → 0.0.67

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 (64) 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/src/animations/animate-js.js +4 -4
  5. package/src/animations/animate-swap.js +3 -0
  6. package/src/core/compile/compile.js +3 -3
  7. package/src/core/controller/controller.js +0 -5
  8. package/src/core/di/injector.js +9 -12
  9. package/src/core/di/internal-injector.js +113 -60
  10. package/src/core/parser/parse.js +1 -12
  11. package/src/core/parser/parse.spec.js +96 -110
  12. package/src/core/timeout/timeout.js +110 -111
  13. package/src/directive/input/input.js +32 -726
  14. package/src/directive/input/input.md +706 -0
  15. package/src/directive/select/select.js +48 -122
  16. package/src/directive/select/select.md +74 -0
  17. package/src/directive/show-hide/show-hide.js +13 -224
  18. package/src/directive/show-hide/show-hide.md +257 -0
  19. package/src/filters/limit-to.spec.js +1 -1
  20. package/src/filters/order-by.spec.js +1 -1
  21. package/src/index.js +6 -2
  22. package/src/loader.js +7 -3
  23. package/src/public.js +1 -7
  24. package/src/router/state/state-builder.js +2 -4
  25. package/src/router/state/state-service.js +1 -1
  26. package/src/router/state-provider.js +1 -1
  27. package/src/router/template-factory.js +10 -10
  28. package/src/router/url/url-service.js +4 -4
  29. package/src/services/anchor-scroll.js +2 -2
  30. package/src/services/browser.js +2 -9
  31. package/src/services/cache-factory.js +0 -67
  32. package/src/services/cache-factory.md +75 -0
  33. package/src/services/cookie-reader.js +36 -55
  34. package/src/services/http/http.js +62 -587
  35. package/src/services/http/http.md +413 -0
  36. package/src/services/http-backend/http-backend.js +19 -44
  37. package/src/services/template-request.js +1 -9
  38. package/src/shared/jqlite/jqlite.js +4 -69
  39. package/src/types.js +2 -4
  40. package/types/animations/animate-swap.d.ts +4 -7
  41. package/types/core/compile/compile.d.ts +6 -6
  42. package/types/core/controller/controller.d.ts +0 -5
  43. package/types/core/di/internal-injector.d.ts +73 -18
  44. package/types/core/exception-handler.d.ts +1 -1
  45. package/types/core/parser/parse.d.ts +1 -1
  46. package/types/core/timeout/timeout.d.ts +16 -26
  47. package/types/directive/input/input.d.ts +19 -124
  48. package/types/directive/select/select.d.ts +7 -74
  49. package/types/directive/show-hide/show-hide.d.ts +11 -224
  50. package/types/loader.d.ts +4 -4
  51. package/types/router/state/state-builder.d.ts +1 -2
  52. package/types/router/state/state-service.d.ts +2 -2
  53. package/types/router/state-provider.d.ts +2 -2
  54. package/types/router/template-factory.d.ts +15 -15
  55. package/types/router/url/url-service.d.ts +4 -4
  56. package/types/services/anchor-scroll.d.ts +1 -1
  57. package/types/services/browser.d.ts +0 -10
  58. package/types/services/cache-factory.d.ts +0 -67
  59. package/types/services/cookie-reader.d.ts +2 -10
  60. package/types/services/http/http.d.ts +53 -61
  61. package/types/services/http-backend/http-backend.d.ts +8 -31
  62. package/types/services/template-request.d.ts +1 -9
  63. package/types/shared/jqlite/jqlite.d.ts +9 -9
  64. package/types/types.d.ts +1 -9
@@ -1,7 +1,6 @@
1
1
  import { AST } from "./ast";
2
2
  import { Lexer } from "./lexer";
3
3
  import {
4
- forEach,
5
4
  isFunction,
6
5
  sliceArgs,
7
6
  csp,
@@ -580,27 +579,24 @@ describe("parser", () => {
580
579
 
581
580
  it("should understand literals", () => {
582
581
  // In a strict sense, `undefined` is not a literal but an identifier
583
- forEach(
584
- {
585
- 123: 123,
586
- '"123"': "123",
587
- true: true,
588
- false: false,
589
- null: null,
590
- undefined: undefined,
591
- },
592
- (value, expression) => {
593
- expect(createAst(expression)).toEqual({
594
- type: ASTType.Program,
595
- body: [
596
- {
597
- type: ASTType.ExpressionStatement,
598
- expression: { type: ASTType.Literal, value },
599
- },
600
- ],
601
- });
602
- },
603
- );
582
+ Object.entries({
583
+ 123: 123,
584
+ '"123"': "123",
585
+ true: true,
586
+ false: false,
587
+ null: null,
588
+ undefined: undefined,
589
+ }).forEach(([expression, value]) => {
590
+ expect(createAst(expression)).toEqual({
591
+ type: ASTType.Program,
592
+ body: [
593
+ {
594
+ type: ASTType.ExpressionStatement,
595
+ expression: { type: ASTType.Literal, value },
596
+ },
597
+ ],
598
+ });
599
+ });
604
600
  });
605
601
 
606
602
  it("should understand the `this` expression", () => {
@@ -628,8 +624,7 @@ describe("parser", () => {
628
624
  });
629
625
 
630
626
  it("should not confuse `this`, `$locals`, `undefined`, `true`, `false`, `null` when used as identifiers", () => {
631
- forEach(
632
- ["this", "$locals", "undefined", "true", "false", "null"],
627
+ ["this", "$locals", "undefined", "true", "false", "null"].forEach(
633
628
  (identifier) => {
634
629
  expect(createAst(`foo.${identifier}`)).toEqual({
635
630
  type: ASTType.Program,
@@ -662,7 +657,7 @@ describe("parser", () => {
662
657
  });
663
658
 
664
659
  it("should understand the unary operators `-`, `+` and `!`", () => {
665
- forEach(["-", "+", "!"], (operator) => {
660
+ ["-", "+", "!"].forEach((operator) => {
666
661
  expect(createAst(`${operator}foo`)).toEqual({
667
662
  type: ASTType.Program,
668
663
  body: [
@@ -681,75 +676,69 @@ describe("parser", () => {
681
676
  });
682
677
 
683
678
  it("should handle all unary operators with the same precedence", () => {
684
- forEach(
685
- [
686
- ["+", "-", "!"],
687
- ["-", "!", "+"],
688
- ["!", "+", "-"],
689
- ],
690
- (operators) => {
691
- expect(createAst(`${operators.join("")}foo`)).toEqual({
692
- type: ASTType.Program,
693
- body: [
694
- {
695
- type: ASTType.ExpressionStatement,
696
- expression: {
679
+ [
680
+ ["+", "-", "!"],
681
+ ["-", "!", "+"],
682
+ ["!", "+", "-"],
683
+ ].forEach((operators) => {
684
+ expect(createAst(`${operators.join("")}foo`)).toEqual({
685
+ type: ASTType.Program,
686
+ body: [
687
+ {
688
+ type: ASTType.ExpressionStatement,
689
+ expression: {
690
+ type: ASTType.UnaryExpression,
691
+ operator: operators[0],
692
+ prefix: true,
693
+ argument: {
697
694
  type: ASTType.UnaryExpression,
698
- operator: operators[0],
695
+ operator: operators[1],
699
696
  prefix: true,
700
697
  argument: {
701
698
  type: ASTType.UnaryExpression,
702
- operator: operators[1],
699
+ operator: operators[2],
703
700
  prefix: true,
704
- argument: {
705
- type: ASTType.UnaryExpression,
706
- operator: operators[2],
707
- prefix: true,
708
- argument: { type: ASTType.Identifier, name: "foo" },
709
- },
701
+ argument: { type: ASTType.Identifier, name: "foo" },
710
702
  },
711
703
  },
712
704
  },
713
- ],
714
- });
715
- },
716
- );
705
+ },
706
+ ],
707
+ });
708
+ });
717
709
  });
718
710
 
719
711
  it("should be able to understand binary operators", () => {
720
- forEach(
721
- [
722
- "*",
723
- "/",
724
- "%",
725
- "+",
726
- "-",
727
- "<",
728
- ">",
729
- "<=",
730
- ">=",
731
- "==",
732
- "!=",
733
- "===",
734
- "!==",
735
- ],
736
- (operator) => {
737
- expect(createAst(`foo${operator}bar`)).toEqual({
738
- type: ASTType.Program,
739
- body: [
740
- {
741
- type: ASTType.ExpressionStatement,
742
- expression: {
743
- type: ASTType.BinaryExpression,
744
- operator,
745
- left: { type: ASTType.Identifier, name: "foo" },
746
- right: { type: ASTType.Identifier, name: "bar" },
747
- },
712
+ [
713
+ "*",
714
+ "/",
715
+ "%",
716
+ "+",
717
+ "-",
718
+ "<",
719
+ ">",
720
+ "<=",
721
+ ">=",
722
+ "==",
723
+ "!=",
724
+ "===",
725
+ "!==",
726
+ ].forEach((operator) => {
727
+ expect(createAst(`foo${operator}bar`)).toEqual({
728
+ type: ASTType.Program,
729
+ body: [
730
+ {
731
+ type: ASTType.ExpressionStatement,
732
+ expression: {
733
+ type: ASTType.BinaryExpression,
734
+ operator,
735
+ left: { type: ASTType.Identifier, name: "foo" },
736
+ right: { type: ASTType.Identifier, name: "bar" },
748
737
  },
749
- ],
750
- });
751
- },
752
- );
738
+ },
739
+ ],
740
+ });
741
+ });
753
742
  });
754
743
 
755
744
  it("should associate binary operators with the same precedence left-to-right", () => {
@@ -759,9 +748,9 @@ describe("parser", () => {
759
748
  ["<", ">", "<=", ">="],
760
749
  ["==", "!=", "===", "!=="],
761
750
  ];
762
- forEach(operatorsByPrecedence, (operators) => {
763
- forEach(operators, (op1) => {
764
- forEach(operators, (op2) => {
751
+ operatorsByPrecedence.forEach((operators) => {
752
+ operators.forEach((op1) => {
753
+ operators.forEach((op2) => {
765
754
  expect(createAst(`foo${op1}bar${op2}baz`)).toEqual({
766
755
  type: ASTType.Program,
767
756
  body: [
@@ -787,7 +776,7 @@ describe("parser", () => {
787
776
  });
788
777
 
789
778
  it("should give higher precedence to member calls than to unary expressions", () => {
790
- forEach(["!", "+", "-"], (operator) => {
779
+ ["!", "+", "-"].forEach((operator) => {
791
780
  expect(createAst(`${operator}foo()`)).toEqual({
792
781
  type: ASTType.Program,
793
782
  body: [
@@ -848,8 +837,8 @@ describe("parser", () => {
848
837
  });
849
838
 
850
839
  it("should give higher precedence to unary operators over multiplicative operators", () => {
851
- forEach(["!", "+", "-"], (op1) => {
852
- forEach(["*", "/", "%"], (op2) => {
840
+ ["!", "+", "-"].forEach((op1) => {
841
+ ["*", "/", "%"].forEach((op2) => {
853
842
  expect(createAst(`${op1}foo${op2}${op1}bar`)).toEqual({
854
843
  type: ASTType.Program,
855
844
  body: [
@@ -886,8 +875,8 @@ describe("parser", () => {
886
875
  ["==", "!=", "===", "!=="],
887
876
  ];
888
877
  for (let i = 0; i < operatorsByPrecedence.length - 1; ++i) {
889
- forEach(operatorsByPrecedence[i], (op1) => {
890
- forEach(operatorsByPrecedence[i + 1], (op2) => {
878
+ operatorsByPrecedence[i].forEach((op1) => {
879
+ operatorsByPrecedence[i + 1].forEach((op2) => {
891
880
  expect(createAst(`foo${op1}bar${op2}baz${op1}man`)).toEqual({
892
881
  type: ASTType.Program,
893
882
  body: [
@@ -918,7 +907,7 @@ describe("parser", () => {
918
907
  });
919
908
 
920
909
  it("should understand logical operators", () => {
921
- forEach(["||", "&&"], (operator) => {
910
+ ["||", "&&"].forEach((operator) => {
922
911
  expect(createAst(`foo${operator}bar`)).toEqual({
923
912
  type: ASTType.Program,
924
913
  body: [
@@ -937,7 +926,7 @@ describe("parser", () => {
937
926
  });
938
927
 
939
928
  it("should associate logical operators left-to-right", () => {
940
- forEach(["||", "&&"], (op) => {
929
+ ["||", "&&"].forEach((op) => {
941
930
  expect(createAst(`foo${op}bar${op}baz`)).toEqual({
942
931
  type: ASTType.Program,
943
932
  body: [
@@ -1053,7 +1042,7 @@ describe("parser", () => {
1053
1042
  });
1054
1043
 
1055
1044
  it("should give higher precedence to equality than to the logical `and` operator", () => {
1056
- forEach(["==", "!=", "===", "!=="], (operator) => {
1045
+ ["==", "!=", "===", "!=="].forEach((operator) => {
1057
1046
  expect(createAst(`foo${operator}bar && man${operator}shell`)).toEqual({
1058
1047
  type: ASTType.Program,
1059
1048
  body: [
@@ -1775,7 +1764,7 @@ describe("parser", () => {
1775
1764
  });
1776
1765
  });
1777
1766
 
1778
- forEach([true, false], (cspEnabled) => {
1767
+ [true, false].forEach((cspEnabled) => {
1779
1768
  describe(`csp: ${cspEnabled}`, () => {
1780
1769
  beforeEach(() => {
1781
1770
  createInjector([
@@ -2016,7 +2005,7 @@ describe("parser", () => {
2016
2005
  expect(scope.$eval("a.b.c.d.e.f.g.h.i.j.k.l.m.n", scope)).toBe("nooo!");
2017
2006
  });
2018
2007
 
2019
- forEach([2, 3, 4, 5, 6, 7, 8, 9, 10, 20, 42, 99], (pathLength) => {
2008
+ [2, 3, 4, 5, 6, 7, 8, 9, 10, 20, 42, 99].forEach((pathLength) => {
2020
2009
  it(`should resolve nested paths of length ${pathLength}`, () => {
2021
2010
  // Create a nested object {x2: {x3: {x4: ... {x[n]: 42} ... }}}.
2022
2011
  let obj = 42;
@@ -2397,23 +2386,20 @@ describe("parser", () => {
2397
2386
 
2398
2387
  it("should throw TypeError on using a 'broken' object as a key to access a property", () => {
2399
2388
  scope.object = {};
2400
- forEach(
2401
- [
2402
- { toString: 2 },
2403
- { toString: null },
2404
- {
2405
- toString() {
2406
- return {};
2407
- },
2389
+ [
2390
+ { toString: 2 },
2391
+ { toString: null },
2392
+ {
2393
+ toString() {
2394
+ return {};
2408
2395
  },
2409
- ],
2410
- (brokenObject) => {
2411
- scope.brokenObject = brokenObject;
2412
- expect(() => {
2413
- scope.$eval("object[brokenObject]");
2414
- }).toThrow();
2415
2396
  },
2416
- );
2397
+ ].forEach((brokenObject) => {
2398
+ scope.brokenObject = brokenObject;
2399
+ expect(() => {
2400
+ scope.$eval("object[brokenObject]");
2401
+ }).toThrow();
2402
+ });
2417
2403
  });
2418
2404
 
2419
2405
  it("should support method calls on primitive types", () => {
@@ -3,128 +3,127 @@ import { isDefined, isFunction, minErr, sliceArgs } from "../../shared/utils";
3
3
 
4
4
  const $timeoutMinErr = minErr("$timeout");
5
5
 
6
- /**
7
- *
8
- * @param {*} $rootScope
9
- * @param {*} $browser
10
- * @param {*} $q
11
- * @param {*} $$q
12
- * @param {import('../exception-handler').ErrorHandler} $exceptionHandler
13
- * @returns
14
- */
15
- export function $timeout($rootScope, $browser, $q, $$q, $exceptionHandler) {
16
- const deferreds = {};
17
-
18
- /**
19
- * @ngdoc service
20
- * @name $timeout
21
- *
22
- * @description
23
- * AngularJS's wrapper for `window.setTimeout`. The `fn` function is wrapped into a try/catch
24
- * block and delegates any exceptions to
25
- * {@link ng.$exceptionHandler $exceptionHandler} service.
26
- *
27
- * The return value of calling `$timeout` is a promise, which will be resolved when
28
- * the delay has passed and the timeout function, if provided, is executed.
29
- *
30
- * To cancel a timeout request, call `$timeout.cancel(promise)`.
31
- *
32
- * In tests you can use {@link ngMock.$timeout `$timeout.flush()`} to
33
- * synchronously flush the queue of deferred functions.
34
- *
35
- * If you only want a promise that will be resolved after some specified delay
36
- * then you can call `$timeout` without the `fn` function.
37
- *
38
- * @param {function()=} fn A function, whose execution should be delayed.
39
- * @param {number=} [delay=0] Delay in milliseconds.
40
- * @param {boolean=} [invokeApply=true] If set to `false` skips model dirty checking, otherwise
41
- * will invoke `fn` within the {@link ng.$rootScope.Scope#$apply $apply} block.
42
- * @param {...*=} Pass additional parameters to the executed function.
43
- * @returns {Promise} Promise that will be resolved when the timeout is reached. The promise
44
- * will be resolved with the return value of the `fn` function.
45
- *
46
- */
47
- function timeout(fn, delay, invokeApply) {
48
- if (!isFunction(fn)) {
49
- invokeApply = delay;
50
- delay = fn;
51
- fn = () => {};
52
- }
53
-
54
- const args = sliceArgs(arguments, 3);
55
- const skipApply = isDefined(invokeApply) && !invokeApply;
56
- const deferred = (skipApply ? $$q : $q).defer();
57
- const { promise } = deferred;
58
- let timeoutId;
6
+ export function $TimeoutProvider() {
7
+ this.$get = [
8
+ "$rootScope",
9
+ "$browser",
10
+ "$q",
11
+ "$$q",
12
+ "$exceptionHandler",
13
+ /**
14
+ *
15
+ * @param {import('../scope/scope').Scope} $rootScope
16
+ * @param {import('../../services/browser').Browser} $browser
17
+ * @param {*} $q
18
+ * @param {*} $$q
19
+ * @param {import('../exception-handler').ErrorHandler} $exceptionHandler
20
+ * @returns
21
+ */
22
+ function ($rootScope, $browser, $q, $$q, $exceptionHandler) {
23
+ const deferreds = {};
59
24
 
60
- timeoutId = $browser.defer(
61
- () => {
62
- try {
63
- deferred.resolve(fn.apply(null, args));
64
- } catch (e) {
65
- deferred.reject(e);
66
- $exceptionHandler(e);
67
- } finally {
68
- delete deferreds[promise.$$timeoutId];
25
+ /**
26
+ * @ngdoc service
27
+ * @name $timeout
28
+ *
29
+ * @description
30
+ * AngularJS's wrapper for `window.setTimeout`. The `fn` function is wrapped into a try/catch
31
+ * block and delegates any exceptions to
32
+ * {@link ng.$exceptionHandler $exceptionHandler} service.
33
+ *
34
+ * The return value of calling `$timeout` is a promise, which will be resolved when
35
+ * the delay has passed and the timeout function, if provided, is executed.
36
+ *
37
+ * To cancel a timeout request, call `$timeout.cancel(promise)`.
38
+ *
39
+ * In tests you can use {@link ngMock.$timeout `$timeout.flush()`} to
40
+ * synchronously flush the queue of deferred functions.
41
+ *
42
+ * If you only want a promise that will be resolved after some specified delay
43
+ * then you can call `$timeout` without the `fn` function.
44
+ *
45
+ * @param {function()=} fn A function, whose execution should be delayed.
46
+ * @param {number=} [delay=0] Delay in milliseconds.
47
+ * @param {boolean=} [invokeApply=true] If set to `false` skips model dirty checking, otherwise
48
+ * will invoke `fn` within the {@link ng.$rootScope.Scope#$apply $apply} block.
49
+ * @returns {Promise} Promise that will be resolved when the timeout is reached. The promise
50
+ * will be resolved with the return value of the `fn` function.
51
+ *
52
+ */
53
+ function timeout(fn, delay, invokeApply = true) {
54
+ if (!isFunction(fn)) {
55
+ invokeApply = delay;
56
+ delay = fn;
57
+ fn = () => {};
69
58
  }
70
59
 
71
- if (!skipApply) $rootScope.$apply();
72
- },
73
- delay,
74
- "$timeout",
75
- );
60
+ const args = sliceArgs(arguments, 3);
61
+ const skipApply = isDefined(invokeApply) && !invokeApply;
62
+ const deferred = (skipApply ? $$q : $q).defer();
63
+ const { promise } = deferred;
64
+ let timeoutId;
76
65
 
77
- promise.$$timeoutId = timeoutId;
78
- deferreds[timeoutId] = deferred;
66
+ timeoutId = $browser.defer(
67
+ () => {
68
+ try {
69
+ deferred.resolve(fn.apply(null, args));
70
+ } catch (e) {
71
+ deferred.reject(e);
72
+ $exceptionHandler(e);
73
+ } finally {
74
+ delete deferreds[promise.$$timeoutId];
75
+ }
79
76
 
80
- return promise;
81
- }
77
+ if (!skipApply) $rootScope.$apply();
78
+ },
79
+ delay,
80
+ "$timeout",
81
+ );
82
82
 
83
- /**
84
- * @ngdoc method
85
- * @name $timeout#cancel
86
- *
87
- * @description
88
- * Cancels a task associated with the `promise`. As a result of this, the promise will be
89
- * resolved with a rejection.
90
- *
91
- * @param {Promise=} promise Promise returned by the `$timeout` function.
92
- * @returns {boolean} Returns `true` if the task hasn't executed yet and was successfully
93
- * canceled.
94
- */
95
- timeout.cancel = function (promise) {
96
- if (!promise) return false;
83
+ promise.$$timeoutId = timeoutId;
84
+ deferreds[timeoutId] = deferred;
97
85
 
98
- if (!Object.prototype.hasOwnProperty.call(promise, "$$timeoutId")) {
99
- throw $timeoutMinErr(
100
- "badprom",
101
- "`$timeout.cancel()` called with a promise that was not generated by `$timeout()`.",
102
- );
103
- }
86
+ return promise;
87
+ }
104
88
 
105
- if (!Object.prototype.hasOwnProperty.call(deferreds, promise.$$timeoutId))
106
- return false;
107
- const id = promise.$$timeoutId;
108
- const deferred = deferreds[id];
89
+ /**
90
+ * @ngdoc method
91
+ * @name $timeout#cancel
92
+ *
93
+ * @description
94
+ * Cancels a task associated with the `promise`. As a result of this, the promise will be
95
+ * resolved with a rejection.
96
+ *
97
+ * @param {Promise=} promise Promise returned by the `$timeout` function.
98
+ * @returns {boolean} Returns `true` if the task hasn't executed yet and was successfully
99
+ * canceled.
100
+ */
101
+ timeout.cancel = function (promise) {
102
+ if (!promise) return false;
109
103
 
110
- // Timeout cancels should not report an unhandled promise.
111
- markQExceptionHandled(deferred.promise);
112
- deferred.reject("canceled");
113
- delete deferreds[id];
104
+ if (!Object.prototype.hasOwnProperty.call(promise, "$$timeoutId")) {
105
+ throw $timeoutMinErr(
106
+ "badprom",
107
+ "`$timeout.cancel()` called with a promise that was not generated by `$timeout()`.",
108
+ );
109
+ }
114
110
 
115
- return $browser.cancel(id);
116
- };
111
+ if (
112
+ !Object.prototype.hasOwnProperty.call(deferreds, promise.$$timeoutId)
113
+ )
114
+ return false;
115
+ const id = promise.$$timeoutId;
116
+ const deferred = deferreds[id];
117
117
 
118
- return timeout;
119
- }
118
+ // Timeout cancels should not report an unhandled promise.
119
+ markQExceptionHandled(deferred.promise);
120
+ deferred.reject("canceled");
121
+ delete deferreds[id];
120
122
 
121
- export function $TimeoutProvider() {
122
- this.$get = [
123
- "$rootScope",
124
- "$browser",
125
- "$q",
126
- "$$q",
127
- "$exceptionHandler",
128
- $timeout,
123
+ return $browser.cancel(id);
124
+ };
125
+
126
+ return timeout;
127
+ },
129
128
  ];
130
129
  }