Skip to content

Commit de352f1

Browse files
authored
Merge pull request #45 from tuld01061/hotfix/dependencies-update
Update dependencies
2 parents e8314f9 + de9a7f3 commit de352f1

File tree

6 files changed

+2673
-1594
lines changed

6 files changed

+2673
-1594
lines changed

.babelrc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"presets": [
3-
"env",
4-
"react"
3+
"@babel/preset-env",
4+
"@babel/preset-react"
55
]
66
}

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
## Change Log
22

3+
### Ver 0.5.0
4+
5+
* Update `Babel` from 6.x to 7.x
6+
* Update other dependencies
7+
38
### Ver 0.4.0
49

510
* [add service worker registration prop](https://github.com/georgeOsdDev/react-web-notification/pull/41)

karma.conf.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,8 @@ module.exports = function(config) {
4040
{
4141
'compact': false,
4242
'presets': [
43-
'env',
44-
'react'
43+
"@babel/preset-env",
44+
"@babel/preset-react"
4545
]
4646
}
4747
]

lib/components/Notification.js

Lines changed: 61 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,33 @@
1-
'use strict';
1+
"use strict";
22

33
Object.defineProperty(exports, "__esModule", {
44
value: true
55
});
6+
exports.default = void 0;
67

7-
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
8+
var _react = _interopRequireDefault(require("react"));
89

9-
var _react = require('react');
10-
11-
var _react2 = _interopRequireDefault(_react);
12-
13-
var _propTypes = require('prop-types');
10+
var _propTypes = require("prop-types");
1411

1512
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
1613

14+
function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
15+
1716
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
1817

19-
function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
18+
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
19+
20+
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
21+
22+
function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
2023

21-
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
24+
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
25+
26+
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
27+
28+
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
29+
30+
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
2231

2332
var PERMISSION_GRANTED = 'granted';
2433
var PERMISSION_DENIED = 'denied';
@@ -29,20 +38,26 @@ var seqGen = function seqGen() {
2938
return i++;
3039
};
3140
};
41+
3242
var seq = seqGen();
3343

34-
var Notification = function (_React$Component) {
44+
var Notification =
45+
/*#__PURE__*/
46+
function (_React$Component) {
3547
_inherits(Notification, _React$Component);
3648

3749
function Notification(props) {
38-
_classCallCheck(this, Notification);
50+
var _this;
3951

40-
var _this = _possibleConstructorReturn(this, (Notification.__proto__ || Object.getPrototypeOf(Notification)).call(this, props));
52+
_classCallCheck(this, Notification);
4153

54+
_this = _possibleConstructorReturn(this, _getPrototypeOf(Notification).call(this, props));
4255
var supported = false;
4356
var granted = false;
57+
4458
if ('Notification' in window && window.Notification) {
4559
supported = true;
60+
4661
if (window.Notification.permission === PERMISSION_GRANTED) {
4762
granted = true;
4863
}
@@ -51,32 +66,33 @@ var Notification = function (_React$Component) {
5166
_this.state = {
5267
supported: supported,
5368
granted: granted
54-
};
55-
// Do not save Notification instance in state
69+
}; // Do not save Notification instance in state
70+
5671
_this.notifications = {};
5772
_this.windowFocus = true;
58-
_this.onWindowFocus = _this._onWindowFocus.bind(_this);
59-
_this.onWindowBlur = _this._onWindowBlur.bind(_this);
73+
_this.onWindowFocus = _this._onWindowFocus.bind(_assertThisInitialized(_assertThisInitialized(_this)));
74+
_this.onWindowBlur = _this._onWindowBlur.bind(_assertThisInitialized(_assertThisInitialized(_this)));
6075
return _this;
6176
}
6277

6378
_createClass(Notification, [{
64-
key: '_onWindowFocus',
79+
key: "_onWindowFocus",
6580
value: function _onWindowFocus() {
6681
this.windowFocus = true;
6782
}
6883
}, {
69-
key: '_onWindowBlur',
84+
key: "_onWindowBlur",
7085
value: function _onWindowBlur() {
7186
this.windowFocus = false;
7287
}
7388
}, {
74-
key: '_askPermission',
89+
key: "_askPermission",
7590
value: function _askPermission() {
7691
var _this2 = this;
7792

7893
window.Notification.requestPermission(function (permission) {
7994
var result = permission === PERMISSION_GRANTED;
95+
8096
_this2.setState({
8197
granted: result
8298
}, function () {
@@ -89,7 +105,7 @@ var Notification = function (_React$Component) {
89105
});
90106
}
91107
}, {
92-
key: 'componentDidMount',
108+
key: "componentDidMount",
93109
value: function componentDidMount() {
94110
if (this.props.disableActiveWindow) {
95111
window.addEventListener('focus', this.onWindowFocus);
@@ -113,22 +129,23 @@ var Notification = function (_React$Component) {
113129
}
114130
}
115131
}, {
116-
key: 'componentWillUnmount',
132+
key: "componentWillUnmount",
117133
value: function componentWillUnmount() {
118134
if (this.props.disableActiveWindow) {
119135
window.removeEventListener('focus', this.onWindowFocus);
120136
window.removeEventListener('blur', this.onWindowBlur);
121137
}
122138
}
123139
}, {
124-
key: 'render',
140+
key: "render",
125141
value: function render() {
126142
var _this3 = this;
127143

128144
var doNotShowOnActiveWindow = this.props.disableActiveWindow && this.windowFocus;
129-
if (!this.props.ignore && this.props.title && this.state.supported && this.state.granted && !doNotShowOnActiveWindow) {
130145

146+
if (!this.props.ignore && this.props.title && this.state.supported && this.state.granted && !doNotShowOnActiveWindow) {
131147
var opt = this.props.options;
148+
132149
if (typeof opt.tag !== 'string') {
133150
opt.tag = 'web-notification-' + seq();
134151
}
@@ -139,50 +156,59 @@ var Notification = function (_React$Component) {
139156
this.notifications[opt.tag] = {};
140157
} else {
141158
var n = new window.Notification(this.props.title, opt);
159+
142160
n.onshow = function (e) {
143161
_this3.props.onShow(e, opt.tag);
162+
144163
setTimeout(function () {
145164
_this3.close(n);
146165
}, _this3.props.timeout);
147166
};
167+
148168
n.onclick = function (e) {
149169
_this3.props.onClick(e, opt.tag);
150170
};
171+
151172
n.onclose = function (e) {
152173
_this3.props.onClose(e, opt.tag);
153174
};
175+
154176
n.onerror = function (e) {
155177
_this3.props.onError(e, opt.tag);
156178
};
157179

158180
this.notifications[opt.tag] = n;
159181
}
160182
}
161-
}
162-
163-
// return null cause
183+
} // return null cause
164184
// Error: Invariant Violation: Notification.render(): A valid ReactComponent must be returned. You may have returned undefined, an array or some other invalid object.
165-
return _react2.default.createElement('input', { type: 'hidden', name: 'dummy-for-react-web-notification', style: { display: 'none' } });
185+
186+
187+
return _react.default.createElement("input", {
188+
type: "hidden",
189+
name: "dummy-for-react-web-notification",
190+
style: {
191+
display: 'none'
192+
}
193+
});
166194
}
167195
}, {
168-
key: 'close',
196+
key: "close",
169197
value: function close(n) {
170198
if (n && typeof n.close === 'function') {
171199
n.close();
172200
}
173-
}
174-
175-
// for debug
201+
} // for debug
176202

177203
}, {
178-
key: '_getNotificationInstance',
204+
key: "_getNotificationInstance",
179205
value: function _getNotificationInstance(tag) {
180206
return this.notifications[tag];
181207
}
182208
}]);
183209

184210
return Notification;
185-
}(_react2.default.Component);
211+
}(_react.default.Component);
186212

187213
Notification.propTypes = {
188214
ignore: _propTypes.bool,
@@ -200,7 +226,6 @@ Notification.propTypes = {
200226
options: _propTypes.object,
201227
swRegistration: _propTypes.object
202228
};
203-
204229
Notification.defaultProps = {
205230
ignore: false,
206231
disableActiveWindow: false,
@@ -216,5 +241,5 @@ Notification.defaultProps = {
216241
options: {},
217242
swRegistration: null
218243
};
219-
220-
exports.default = Notification;
244+
var _default = Notification;
245+
exports.default = _default;

package.json

Lines changed: 27 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -29,37 +29,37 @@
2929
},
3030
"homepage": "https://github.com/georgeosddev/react-web-notification",
3131
"devDependencies": {
32-
"babel-cli": "^6.3.17",
33-
"babel-core": "^6.3.21",
34-
"babel-eslint": "^8.0.2",
35-
"babel-preset-env": "^1.6.1",
36-
"babel-preset-react": "^6.3.13",
37-
"babelify": "^8.0.0",
38-
"browser-sync": "^2.10.1",
39-
"browserify": "^14.5.0",
40-
"chai": "^4.1.2",
41-
"eslint": "^4.12.1",
42-
"eslint-plugin-react": "^7.5.1",
43-
"karma": "^1.7.1",
44-
"karma-browserify": "^5.1.2",
32+
"@babel/cli": "^7.2.0",
33+
"@babel/core": "^7.2.2",
34+
"@babel/preset-env": "^7.2.0",
35+
"@babel/preset-react": "^7.0.0",
36+
"babel-eslint": "^10.0.1",
37+
"babelify": "^10.0.0",
38+
"browser-sync": "^2.26.3",
39+
"browserify": "^16.2.3",
40+
"chai": "^4.2.0",
41+
"eslint": "^5.10.0",
42+
"eslint-plugin-react": "^7.11.1",
43+
"karma": "^3.1.3",
44+
"karma-browserify": "^6.0.0",
4545
"karma-chai": "^0.1.0",
4646
"karma-chrome-launcher": "^2.2.0",
47-
"karma-cli": "1.0.1",
48-
"karma-firefox-launcher": "^1.0.1",
47+
"karma-cli": "2.0.0",
48+
"karma-firefox-launcher": "^1.1.0",
4949
"karma-mocha": "^1.3.0",
5050
"karma-safari-launcher": "^1.0.0",
51-
"karma-spec-reporter": "0.0.31",
52-
"mocha": "^4.0.1",
53-
"prop-types": "^15.5.8",
54-
"react": "^0.14.3 || ^15.0.1 || ^16.2.0",
55-
"react-addons-test-utils": "^0.14.3 || ^15.0.1",
56-
"react-dom": "^0.14.3 || ^15.0.1 || ^16.2.0",
57-
"rimraf": "^2.4.4",
58-
"sinon": "^4.1.2",
59-
"watchify": "^3.6.1"
51+
"karma-spec-reporter": "0.0.32",
52+
"mocha": "^5.2.0",
53+
"prop-types": "^15.6.2",
54+
"react": "^16.6.3",
55+
"react-addons-test-utils": "^15.6.2",
56+
"react-dom": "^16.6.3",
57+
"rimraf": "^2.6.2",
58+
"sinon": "^7.2.2",
59+
"watchify": "^3.11.0"
6060
},
6161
"peerDependencies": {
62-
"react": "^0.14.3 || ^15.0.1 || ^16.2.0"
62+
"react": "^16.6.3"
6363
},
6464
"browserify": {
6565
"transform": [
@@ -68,8 +68,8 @@
6868
{
6969
"compact": false,
7070
"presets": [
71-
"env",
72-
"react"
71+
"@babel/preset-env",
72+
"@babel/preset-react"
7373
]
7474
}
7575
]

0 commit comments

Comments
 (0)