@angular-wave/angular.ts 0.0.28 → 0.0.30

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 (80) hide show
  1. package/dist/angular-ts.esm.js +1 -1
  2. package/dist/angular-ts.umd.js +1 -1
  3. package/index.html +2 -2
  4. package/package.json +1 -1
  5. package/src/core/controller.js +3 -0
  6. package/src/directive/controller.js +0 -56
  7. package/src/directive/controller.md +46 -0
  8. package/src/router/common/trace.js +7 -7
  9. package/src/router/directives/state-directives.js +75 -75
  10. package/src/router/directives/view-directive.js +21 -21
  11. package/src/router/hooks/update-globals.js +1 -1
  12. package/src/router/index.js +12 -12
  13. package/src/router/injectables.js +11 -11
  14. package/src/router/resolve/resolve-context.js +1 -1
  15. package/src/router/router.js +8 -77
  16. package/src/router/services.js +5 -43
  17. package/src/router/state/state-builder.js +1 -0
  18. package/src/router/state/state-object.js +1 -1
  19. package/src/router/state/state-registry.js +56 -3
  20. package/src/router/state/state-service.js +16 -25
  21. package/src/router/state/target-state.js +1 -1
  22. package/src/router/state/views.js +5 -5
  23. package/src/router/state-filters.js +0 -2
  24. package/src/router/state-provider.js +0 -2
  25. package/src/router/template-factory.js +4 -4
  26. package/src/router/transition/transition-service.js +2 -3
  27. package/src/router/url/url-config.js +0 -2
  28. package/src/router/url/url-matcher-factory.js +0 -1
  29. package/src/router/url/url-matcher.js +0 -8
  30. package/src/router/url/url-router.js +4 -0
  31. package/src/router/url/url-service.js +6 -6
  32. package/src/router/view/view.js +67 -65
  33. package/src/services/browser.js +1 -5
  34. package/src/shared/common.js +1 -1
  35. package/test/core/pubsub.spec.js +73 -0
  36. package/test/module-test.html +5 -5
  37. package/test/original-test.html +3 -3
  38. package/test/router/services.spec.js +1 -1
  39. package/test/router/state-directives.spec.js +72 -80
  40. package/test/router/state-filter.spec.js +6 -4
  41. package/test/router/state.spec.js +15 -13
  42. package/test/router/template-factory.spec.js +4 -4
  43. package/test/router/url-matcher-factory.spec.js +2 -2
  44. package/test/router/view-directive.spec.js +165 -163
  45. package/test/router/view-hook.spec.js +2 -2
  46. package/test/router/view-scroll.spec.js +14 -14
  47. package/test/router/view.spec.js +2 -2
  48. package/types/router/core/common/coreservices.d.ts +2 -2
  49. package/types/router/core/common/trace.d.ts +7 -7
  50. package/types/router/core/globals.d.ts +2 -1
  51. package/types/router/core/interface.d.ts +3 -10
  52. package/types/router/core/params/interface.d.ts +3 -3
  53. package/types/router/core/resolve/resolveContext.d.ts +4 -4
  54. package/types/router/core/router.d.ts +5 -51
  55. package/types/router/core/state/interface.d.ts +12 -12
  56. package/types/router/core/state/stateObject.d.ts +1 -1
  57. package/types/router/core/state/stateQueueManager.d.ts +2 -2
  58. package/types/router/core/state/stateRegistry.d.ts +5 -4
  59. package/types/router/core/state/stateService.d.ts +13 -13
  60. package/types/router/core/state/targetState.d.ts +1 -1
  61. package/types/router/core/transition/interface.d.ts +2 -2
  62. package/types/router/core/transition/transition.d.ts +12 -12
  63. package/types/router/core/transition/transitionService.d.ts +5 -5
  64. package/types/router/core/url/interface.d.ts +3 -3
  65. package/types/router/core/url/urlConfig.d.ts +3 -3
  66. package/types/router/core/url/urlMatcherFactory.d.ts +3 -3
  67. package/types/router/core/url/urlRouter.d.ts +2 -2
  68. package/types/router/core/url/urlRule.d.ts +6 -6
  69. package/types/router/core/url/urlRules.d.ts +6 -6
  70. package/types/router/core/url/urlService.d.ts +8 -8
  71. package/types/router/core/view/interface.d.ts +3 -3
  72. package/types/router/core/view/view.d.ts +26 -26
  73. package/types/router/directives/viewDirective.d.ts +6 -6
  74. package/types/router/interface.d.ts +8 -8
  75. package/types/router/locationServices.d.ts +3 -3
  76. package/types/router/services.d.ts +1 -1
  77. package/types/router/stateProvider.d.ts +5 -5
  78. package/types/router/statebuilders/views.d.ts +1 -1
  79. package/types/router/templateFactory.d.ts +2 -2
  80. package/types/router/viewScroll.d.ts +2 -2
@@ -311,4 +311,77 @@ describe("PubSub", function () {
311
311
  }, 0);
312
312
  }, 0);
313
313
  });
314
+
315
+ describe("publish", () => {
316
+ let context, fooCalled, barCalled, SOME_TOPIC;
317
+
318
+ beforeEach(function () {
319
+ context = {};
320
+ fooCalled = false;
321
+ barCalled = false;
322
+ SOME_TOPIC = "someTopic";
323
+ });
324
+
325
+ function foo(record) {
326
+ fooCalled = true;
327
+ expect(record.x).toBe("x");
328
+ expect(record.y).toBe("y");
329
+ }
330
+
331
+ function bar(record) {
332
+ barCalled = true;
333
+ expect(this).toBe(context);
334
+ expect(record.x).toBe("x");
335
+ expect(record.y).toBe("y");
336
+ }
337
+
338
+ it("should call subscribed functions on publish", function () {
339
+ pubsub.subscribe(SOME_TOPIC, foo);
340
+ pubsub.subscribe(SOME_TOPIC, bar, context);
341
+
342
+ expect(pubsub.publish(SOME_TOPIC, { x: "x", y: "y" })).toBe(true);
343
+ expect(fooCalled).toBe(true, "foo() must have been called");
344
+ expect(barCalled).toBe(true, "bar() must have been called");
345
+ });
346
+
347
+ it("should not call unsubscribed functions on publish", function () {
348
+ pubsub.subscribe(SOME_TOPIC, foo);
349
+ pubsub.subscribe(SOME_TOPIC, bar, context);
350
+
351
+ pubsub.publish(SOME_TOPIC, { x: "x", y: "y" });
352
+ fooCalled = false;
353
+ barCalled = false;
354
+ expect(pubsub.unsubscribe(SOME_TOPIC, foo)).toBe(true);
355
+
356
+ expect(pubsub.publish(SOME_TOPIC, { x: "x", y: "y" })).toBe(true);
357
+ expect(fooCalled).toBe(false, "foo() must not have been called");
358
+ expect(barCalled).toBe(true, "bar() must have been called");
359
+ });
360
+
361
+ it("should only call functions subscribed to the correct topic", function () {
362
+ pubsub.subscribe(SOME_TOPIC, bar, context);
363
+ pubsub.subscribe("differentTopic", foo);
364
+
365
+ pubsub.publish(SOME_TOPIC, { x: "x", y: "y" });
366
+ fooCalled = false;
367
+ barCalled = false;
368
+
369
+ expect(pubsub.publish(SOME_TOPIC, { x: "x", y: "y" })).toBe(true);
370
+ expect(fooCalled).toBe(false, "foo() must not have been called");
371
+ expect(barCalled).toBe(true, "bar() must have been called");
372
+ });
373
+
374
+ it("should trigger functions if not arguments are provided", function () {
375
+ let called = false;
376
+ pubsub.subscribe(SOME_TOPIC, () => {
377
+ called = true;
378
+ 0;
379
+ });
380
+
381
+ pubsub.publish(SOME_TOPIC);
382
+
383
+ expect(pubsub.publish(SOME_TOPIC)).toBe(true);
384
+ expect(called).toBeTrue();
385
+ });
386
+ });
314
387
  });
@@ -5,7 +5,7 @@
5
5
  <script type="module" src="../src/index.js"></script>
6
6
  <script>
7
7
  document.addEventListener("DOMContentLoaded", () => {
8
- var myApp = window.angular.module("test", ["ui.router"]);
8
+ var myApp = window.angular.module("test", ["ng.router"]);
9
9
  myApp
10
10
  .config(function ($stateProvider) {
11
11
  $stateProvider
@@ -20,19 +20,19 @@
20
20
  name: "contacts",
21
21
  url: "/contacts",
22
22
  template:
23
- '<a ui-sref=".item({ id: 5 })" class="item">Person</a> <ui-view></ui-view>',
23
+ '<a ng-sref=".item({ id: 5 })" class="item">Person</a> <ng-view></ng-view>',
24
24
  })
25
25
  .state({
26
26
  name: "contacts.item",
27
27
  url: "/{id:int}",
28
28
  template:
29
- '<a ui-sref=".detail" class="item-detail">Detail</a> | <a ui-sref="^" class="item-parent">Parent</a> | <ui-view></ui-view>',
29
+ '<a ng-sref=".detail" class="item-detail">Detail</a> | <a ng-sref="^" class="item-parent">Parent</a> | <ng-view></ng-view>',
30
30
  })
31
31
  .state({
32
32
  name: "contacts.item.detail",
33
33
  url: "/{id}",
34
34
  template:
35
- '<div class="title">Detail</div> | <a ui-sref="^" class="item-parent2">Item</a>',
35
+ '<div class="title">Detail</div> | <a ng-sref="^" class="item-parent2">Item</a>',
36
36
  });
37
37
  })
38
38
  .controller(
@@ -52,7 +52,7 @@
52
52
  <body ng-app="test">
53
53
  <div ng-controller="TestController as $ctrl">
54
54
  {{$ctrl.test}}
55
- <a ui-sref="contacts.item.detail({ id: contact.id })">Details</a>
55
+ <a ng-sref="contacts.item.detail({ id: contact.id })">Details</a>
56
56
  </div>
57
57
  </body>
58
58
  </html>
@@ -5,7 +5,7 @@
5
5
 
6
6
  <script src="//unpkg.com/@uirouter/angularjs/release/angular-ui-router.js"></script>
7
7
  <script>
8
- var myApp = angular.module("test", ["ui.router"]);
8
+ var myApp = angular.module("test", ["ng.router"]);
9
9
 
10
10
  myApp.config(function ($stateProvider) {
11
11
  var helloState = {
@@ -26,8 +26,8 @@
26
26
  </script>
27
27
  </head>
28
28
  <body ng-app="test">
29
- <a ui-sref="hello" ui-sref-active="active">Hello</a>
30
- <ui-view></ui-view>
29
+ <a ng-sref="hello" ng-sref-active="active">Hello</a>
30
+ <ng-view></ng-view>
31
31
  {{ 2 + 2}}
32
32
  </body>
33
33
  </html>
@@ -9,7 +9,7 @@ describe("router services", () => {
9
9
  beforeEach(() => {
10
10
  window.angular = new Angular();
11
11
  publishExternalAPI();
12
- let module = window.angular.module("defaultModule", ["ui.router"]);
12
+ let module = window.angular.module("defaultModule", ["ng.router"]);
13
13
  module.config(
14
14
  (
15
15
  _$routerProvider_,