@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.
- package/dist/angular-ts.esm.js +1 -1
- package/dist/angular-ts.umd.js +1 -1
- package/index.html +2 -2
- package/package.json +1 -1
- package/src/core/controller.js +3 -0
- package/src/directive/controller.js +0 -56
- package/src/directive/controller.md +46 -0
- package/src/router/common/trace.js +7 -7
- package/src/router/directives/state-directives.js +75 -75
- package/src/router/directives/view-directive.js +21 -21
- package/src/router/hooks/update-globals.js +1 -1
- package/src/router/index.js +12 -12
- package/src/router/injectables.js +11 -11
- package/src/router/resolve/resolve-context.js +1 -1
- package/src/router/router.js +8 -77
- package/src/router/services.js +5 -43
- package/src/router/state/state-builder.js +1 -0
- package/src/router/state/state-object.js +1 -1
- package/src/router/state/state-registry.js +56 -3
- package/src/router/state/state-service.js +16 -25
- package/src/router/state/target-state.js +1 -1
- package/src/router/state/views.js +5 -5
- package/src/router/state-filters.js +0 -2
- package/src/router/state-provider.js +0 -2
- package/src/router/template-factory.js +4 -4
- package/src/router/transition/transition-service.js +2 -3
- package/src/router/url/url-config.js +0 -2
- package/src/router/url/url-matcher-factory.js +0 -1
- package/src/router/url/url-matcher.js +0 -8
- package/src/router/url/url-router.js +4 -0
- package/src/router/url/url-service.js +6 -6
- package/src/router/view/view.js +67 -65
- package/src/services/browser.js +1 -5
- package/src/shared/common.js +1 -1
- package/test/core/pubsub.spec.js +73 -0
- package/test/module-test.html +5 -5
- package/test/original-test.html +3 -3
- package/test/router/services.spec.js +1 -1
- package/test/router/state-directives.spec.js +72 -80
- package/test/router/state-filter.spec.js +6 -4
- package/test/router/state.spec.js +15 -13
- package/test/router/template-factory.spec.js +4 -4
- package/test/router/url-matcher-factory.spec.js +2 -2
- package/test/router/view-directive.spec.js +165 -163
- package/test/router/view-hook.spec.js +2 -2
- package/test/router/view-scroll.spec.js +14 -14
- package/test/router/view.spec.js +2 -2
- package/types/router/core/common/coreservices.d.ts +2 -2
- package/types/router/core/common/trace.d.ts +7 -7
- package/types/router/core/globals.d.ts +2 -1
- package/types/router/core/interface.d.ts +3 -10
- package/types/router/core/params/interface.d.ts +3 -3
- package/types/router/core/resolve/resolveContext.d.ts +4 -4
- package/types/router/core/router.d.ts +5 -51
- package/types/router/core/state/interface.d.ts +12 -12
- package/types/router/core/state/stateObject.d.ts +1 -1
- package/types/router/core/state/stateQueueManager.d.ts +2 -2
- package/types/router/core/state/stateRegistry.d.ts +5 -4
- package/types/router/core/state/stateService.d.ts +13 -13
- package/types/router/core/state/targetState.d.ts +1 -1
- package/types/router/core/transition/interface.d.ts +2 -2
- package/types/router/core/transition/transition.d.ts +12 -12
- package/types/router/core/transition/transitionService.d.ts +5 -5
- package/types/router/core/url/interface.d.ts +3 -3
- package/types/router/core/url/urlConfig.d.ts +3 -3
- package/types/router/core/url/urlMatcherFactory.d.ts +3 -3
- package/types/router/core/url/urlRouter.d.ts +2 -2
- package/types/router/core/url/urlRule.d.ts +6 -6
- package/types/router/core/url/urlRules.d.ts +6 -6
- package/types/router/core/url/urlService.d.ts +8 -8
- package/types/router/core/view/interface.d.ts +3 -3
- package/types/router/core/view/view.d.ts +26 -26
- package/types/router/directives/viewDirective.d.ts +6 -6
- package/types/router/interface.d.ts +8 -8
- package/types/router/locationServices.d.ts +3 -3
- package/types/router/services.d.ts +1 -1
- package/types/router/stateProvider.d.ts +5 -5
- package/types/router/statebuilders/views.d.ts +1 -1
- package/types/router/templateFactory.d.ts +2 -2
- package/types/router/viewScroll.d.ts +2 -2
package/test/core/pubsub.spec.js
CHANGED
|
@@ -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
|
});
|
package/test/module-test.html
CHANGED
|
@@ -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", ["
|
|
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
|
|
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
|
|
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
|
|
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
|
|
55
|
+
<a ng-sref="contacts.item.detail({ id: contact.id })">Details</a>
|
|
56
56
|
</div>
|
|
57
57
|
</body>
|
|
58
58
|
</html>
|
package/test/original-test.html
CHANGED
|
@@ -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", ["
|
|
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
|
|
30
|
-
<
|
|
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", ["
|
|
12
|
+
let module = window.angular.module("defaultModule", ["ng.router"]);
|
|
13
13
|
module.config(
|
|
14
14
|
(
|
|
15
15
|
_$routerProvider_,
|