Skip to content

Commit fefa907

Browse files
committed
chore(dependencies): upgrade dependencies
BREAKING CHANGE: The peer dependencies have been upgraded to be: * "rxjs": "^5.4.2", * "@angular/core": "^4.3.0", * "@ngrx/store": "^2.2.3" close #2, close #3
1 parent dd18a17 commit fefa907

15 files changed

+4576
-142
lines changed

CHANGELOG.md

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
<a name="2.0.0"></a>
2+
# [2.0.0](https://github.com/ngrx/notify/compare/v1.0.0...v2.0.0) (2017-07-22)
3+
4+
5+
### Chores
6+
7+
* **dependencies:** upgrade dependencies ([8592504](https://github.com/ngrx/notify/commit/8592504)), closes [#2](https://github.com/ngrx/notify/issues/2) [#3](https://github.com/ngrx/notify/issues/3)
8+
9+
10+
### BREAKING CHANGES
11+
12+
* **dependencies:** The peer dependencies have been upgraded to be:
13+
* "rxjs": "^5.4.2",
14+
* "@angular/core": "^4.3.0",
15+
* "@ngrx/store": "^2.2.3"
16+
17+
18+
19+
<a name="1.0.0"></a>
20+
# 1.0.0 (2016-06-07)
21+
22+
23+

karma.conf.js

+40-21
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
var path = require('path');
2+
var webpack = require('webpack');
23

34
module.exports = function(karma) {
45
'use strict';
@@ -18,16 +19,17 @@ module.exports = function(karma) {
1819
'tests.js': ['coverage', 'webpack', 'sourcemap']
1920
},
2021

21-
reporters: ['mocha', 'coverage'],
22+
reporters: ['mocha', 'coverage-istanbul'],
2223

23-
coverageReporter: {
24-
dir: 'coverage/',
25-
subdir: '.',
26-
reporters: [
27-
{ type: 'text-summary' },
28-
{ type: 'json' },
29-
{ type: 'html' }
30-
]
24+
coverageIstanbulReporter: {
25+
dir: path.join(__dirname, 'coverage'),
26+
reports: [
27+
'html',
28+
'lcovonly',
29+
'json',
30+
'clover'
31+
],
32+
fixWebpackSourcePaths: true
3133
},
3234

3335
browsers: ['Chrome'],
@@ -41,32 +43,49 @@ module.exports = function(karma) {
4143

4244
webpack: {
4345
devtool: 'inline-source-map',
46+
entry: undefined,
4447
resolve: {
45-
root: __dirname,
46-
extensions: ['', '.ts', '.js']
48+
extensions: ['.ts', '.js'],
49+
modules: [
50+
path.join(__dirname),
51+
'node_modules'
52+
]
4753
},
4854
module: {
49-
loaders: [
55+
rules: [
5056
{
5157
test: /\.ts?$/,
52-
exclude: /(node_modules)/,
53-
loader: 'ts-loader?target=es5&module=commonjs'
54-
}
55-
],
56-
postLoaders: [
58+
use: [
59+
{
60+
loader: 'ts-loader?target=es5&module=commonjs'
61+
}
62+
]
63+
},
5764
{
58-
test: /\.(js|ts)$/, loader: 'istanbul-instrumenter-loader',
65+
test: /\.(js|ts)$/,
66+
enforce: 'post',
5967
include: path.resolve(__dirname, 'lib'),
6068
exclude: [
6169
/\.(e2e|spec)\.ts$/,
6270
/node_modules/
71+
],
72+
use: [
73+
{
74+
loader: 'istanbul-instrumenter-loader'
75+
}
6376
]
6477
}
6578
]
6679
},
67-
ts: {
68-
configFileName: './spec/tsconfig.json'
69-
}
80+
plugins: [
81+
new webpack.LoaderOptionsPlugin({
82+
options: {
83+
ts: {
84+
configFileName: './spec/tsconfig.json'
85+
}
86+
}
87+
})
88+
]
7089
},
7190

7291
webpackServer: {

lib/index.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
export { Notify } from './notify';
2-
export { NOTIFY_PROVIDERS, NOTIFY_GLOBAL_OPTIONS } from './ng2';
2+
export { NotifyModule, NOTIFY_GLOBAL_OPTIONS } from './ng2';
33
export { NotificationInstance, NotificationOptions } from './notification';

lib/ng2.ts

+50-39
Original file line numberDiff line numberDiff line change
@@ -1,45 +1,56 @@
1-
import { OpaqueToken } from '@angular/core';
1+
import { InjectionToken, ModuleWithProviders, NgModule } from '@angular/core';
22

33
import { Notify } from './notify';
44
import { NotificationStatic, NotificationOptions } from './notification';
55
import { NotificationPermission } from './notification-permission';
66

7-
declare var Notification: NotificationStatic;
8-
9-
export const NOTIFY_GLOBAL_OPTIONS = new OpaqueToken('[@ngrx/notify] Global Options');
10-
export const NOTIFICATION_STATIC = new OpaqueToken('[@ngrx/notify] Notification Static Constructor');
11-
12-
13-
const NOTIFICATION_STATIC_PROVIDER = {
14-
provide: NOTIFICATION_STATIC,
15-
useValue: Notification
16-
};
17-
18-
const NOTIFICATION_PERMISSION_PROVIDER = {
19-
provide: NotificationPermission,
20-
deps: [ NOTIFICATION_STATIC ],
21-
useFactory(Notification: NotificationStatic) {
22-
return new NotificationPermission(Notification);
7+
export declare var Notification: NotificationStatic;
8+
9+
export const NOTIFY_GLOBAL_OPTIONS = new InjectionToken<NotificationOptions>('[@ngrx/notify] Global Options');
10+
export const NOTIFICATION_STATIC = new InjectionToken<NotificationStatic>('[@ngrx/notify] Notification Static Constructor');
11+
12+
export function createNotification(): NotificationStatic {
13+
return Notification;
14+
}
15+
16+
export function createNotificationPermission(notification: NotificationStatic): NotificationPermission {
17+
return new NotificationPermission(notification);
18+
}
19+
20+
export function createNotify(notification: NotificationStatic, options: NotificationOptions, permission$: NotificationPermission): Notify {
21+
return new Notify(notification, options, permission$);
22+
}
23+
24+
@NgModule({
25+
})
26+
export class NotifyModule {
27+
static forRoot(options: NotificationOptions = {}): ModuleWithProviders {
28+
return {
29+
ngModule: NotifyModule,
30+
providers: [
31+
{
32+
provide: NOTIFICATION_STATIC,
33+
useFactory: (createNotification)
34+
},
35+
{
36+
provide: NotificationPermission,
37+
deps: [NOTIFICATION_STATIC],
38+
useFactory: (createNotificationPermission)
39+
},
40+
{
41+
provide: NOTIFY_GLOBAL_OPTIONS,
42+
useValue: options
43+
},
44+
{
45+
provide: Notify,
46+
deps: [
47+
NOTIFICATION_STATIC,
48+
NOTIFY_GLOBAL_OPTIONS,
49+
NotificationPermission
50+
],
51+
useFactory: (createNotify)
52+
}
53+
]
54+
};
2355
}
24-
};
25-
26-
const NOTIFY_PROVIDER = {
27-
provide: Notify,
28-
deps: [ NOTIFICATION_STATIC, NOTIFY_GLOBAL_OPTIONS, NotificationPermission ],
29-
useFactory(Notification: NotificationStatic, options: NotificationOptions[], permission$: NotificationPermission) {
30-
return new Notify(Notification, options, permission$);
31-
}
32-
};
33-
34-
const DEFAULT_GLOBAL_OPTIONS_PROVIDER = {
35-
provide: NOTIFY_GLOBAL_OPTIONS,
36-
multi: true,
37-
useValue: {}
38-
};
39-
40-
export const NOTIFY_PROVIDERS: any[] = [
41-
NOTIFICATION_STATIC_PROVIDER,
42-
NOTIFICATION_PERMISSION_PROVIDER,
43-
NOTIFY_PROVIDER,
44-
DEFAULT_GLOBAL_OPTIONS_PROVIDER
45-
];
56+
}

lib/notification.ts

+5-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
1-
export type NotificationPermissionStatus = 'denied' | 'granted' | 'default';
1+
export enum NotificationPermissionStatus {
2+
DENIED = 'denied',
3+
GRANTED = 'granted',
4+
DEFAULT = 'default'
5+
}
26

37
export interface NotificationOptions {
48
dir?: 'auto' | 'ltr' | 'rtl';

lib/notify.ts

+5-7
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,27 @@
1-
import 'rxjs/add/operator/cache';
2-
import 'rxjs/add/operator/mergeMap';
31
import 'rxjs/add/observable/throw';
2+
import 'rxjs/add/operator/mergeMap';
3+
import 'rxjs/add/operator/share';
44
import { Observable } from 'rxjs/Observable';
55
import { Subscriber } from 'rxjs/Subscriber';
6-
76
import { NotificationStatic, NotificationOptions, NotificationInstance } from './notification';
87

9-
108
export class Notify {
119
private _permission$: Observable<boolean>;
1210

1311
constructor(
1412
private notificationConstructor: NotificationStatic,
15-
private globalOptions: NotificationOptions[],
13+
private globalOptions: NotificationOptions,
1614
permission$: Observable<boolean>
1715
) {
18-
this._permission$ = permission$.cache();
16+
this._permission$ = permission$.share();
1917
}
2018

2119
requestPermission(): Observable<boolean> {
2220
return this._permission$;
2321
}
2422

2523
private _createNotificationObservable(title: string, _options?: NotificationOptions) {
26-
const options: NotificationOptions = Object.assign({}, ...this.globalOptions, _options);
24+
const options: NotificationOptions = { ...this.globalOptions, ..._options };
2725

2826
return new Observable((subscriber: Subscriber<NotificationInstance>) => {
2927
const notification = new this.notificationConstructor(title, options);

0 commit comments

Comments
 (0)