Skip to content

Commit 8caf609

Browse files
authored
Fix/exporting reducer (#46)
* Export reducer properly and add test * build
1 parent fb30000 commit 8caf609

File tree

5 files changed

+198
-72
lines changed

5 files changed

+198
-72
lines changed

dist/react-notification-system-redux.js

Lines changed: 175 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,9 @@
33

44
/**
55
* Copyright (c) 2013-present, Facebook, Inc.
6-
* All rights reserved.
76
*
8-
* This source code is licensed under the BSD-style license found in the
9-
* LICENSE file in the root directory of this source tree. An additional grant
10-
* of patent rights can be found in the PATENTS file in the same directory.
7+
* This source code is licensed under the MIT license found in the
8+
* LICENSE file in the root directory of this source tree.
119
*
1210
*
1311
*/
@@ -40,11 +38,9 @@ module.exports = emptyFunction;
4038
},{}],2:[function(require,module,exports){
4139
/**
4240
* Copyright (c) 2013-present, Facebook, Inc.
43-
* All rights reserved.
4441
*
45-
* This source code is licensed under the BSD-style license found in the
46-
* LICENSE file in the root directory of this source tree. An additional grant
47-
* of patent rights can be found in the PATENTS file in the same directory.
42+
* This source code is licensed under the MIT license found in the
43+
* LICENSE file in the root directory of this source tree.
4844
*
4945
*/
5046

@@ -95,12 +91,10 @@ function invariant(condition, format, a, b, c, d, e, f) {
9591
module.exports = invariant;
9692
},{}],3:[function(require,module,exports){
9793
/**
98-
* Copyright 2014-2015, Facebook, Inc.
99-
* All rights reserved.
94+
* Copyright (c) 2014-present, Facebook, Inc.
10095
*
101-
* This source code is licensed under the BSD-style license found in the
102-
* LICENSE file in the root directory of this source tree. An additional grant
103-
* of patent rights can be found in the PATENTS file in the same directory.
96+
* This source code is licensed under the MIT license found in the
97+
* LICENSE file in the root directory of this source tree.
10498
*
10599
*/
106100

@@ -159,13 +153,103 @@ if ("production" !== 'production') {
159153

160154
module.exports = warning;
161155
},{"./emptyFunction":1}],4:[function(require,module,exports){
156+
/*
157+
object-assign
158+
(c) Sindre Sorhus
159+
@license MIT
160+
*/
161+
162+
'use strict';
163+
/* eslint-disable no-unused-vars */
164+
var getOwnPropertySymbols = Object.getOwnPropertySymbols;
165+
var hasOwnProperty = Object.prototype.hasOwnProperty;
166+
var propIsEnumerable = Object.prototype.propertyIsEnumerable;
167+
168+
function toObject(val) {
169+
if (val === null || val === undefined) {
170+
throw new TypeError('Object.assign cannot be called with null or undefined');
171+
}
172+
173+
return Object(val);
174+
}
175+
176+
function shouldUseNative() {
177+
try {
178+
if (!Object.assign) {
179+
return false;
180+
}
181+
182+
// Detect buggy property enumeration order in older V8 versions.
183+
184+
// https://bugs.chromium.org/p/v8/issues/detail?id=4118
185+
var test1 = new String('abc'); // eslint-disable-line no-new-wrappers
186+
test1[5] = 'de';
187+
if (Object.getOwnPropertyNames(test1)[0] === '5') {
188+
return false;
189+
}
190+
191+
// https://bugs.chromium.org/p/v8/issues/detail?id=3056
192+
var test2 = {};
193+
for (var i = 0; i < 10; i++) {
194+
test2['_' + String.fromCharCode(i)] = i;
195+
}
196+
var order2 = Object.getOwnPropertyNames(test2).map(function (n) {
197+
return test2[n];
198+
});
199+
if (order2.join('') !== '0123456789') {
200+
return false;
201+
}
202+
203+
// https://bugs.chromium.org/p/v8/issues/detail?id=3056
204+
var test3 = {};
205+
'abcdefghijklmnopqrst'.split('').forEach(function (letter) {
206+
test3[letter] = letter;
207+
});
208+
if (Object.keys(Object.assign({}, test3)).join('') !==
209+
'abcdefghijklmnopqrst') {
210+
return false;
211+
}
212+
213+
return true;
214+
} catch (err) {
215+
// We don't expect any of the above to throw, but better to be safe.
216+
return false;
217+
}
218+
}
219+
220+
module.exports = shouldUseNative() ? Object.assign : function (target, source) {
221+
var from;
222+
var to = toObject(target);
223+
var symbols;
224+
225+
for (var s = 1; s < arguments.length; s++) {
226+
from = Object(arguments[s]);
227+
228+
for (var key in from) {
229+
if (hasOwnProperty.call(from, key)) {
230+
to[key] = from[key];
231+
}
232+
}
233+
234+
if (getOwnPropertySymbols) {
235+
symbols = getOwnPropertySymbols(from);
236+
for (var i = 0; i < symbols.length; i++) {
237+
if (propIsEnumerable.call(from, symbols[i])) {
238+
to[symbols[i]] = from[symbols[i]];
239+
}
240+
}
241+
}
242+
}
243+
244+
return to;
245+
};
246+
247+
},{}],5:[function(require,module,exports){
162248
/**
163-
* Copyright 2013-present, Facebook, Inc.
164-
* All rights reserved.
249+
* Copyright (c) 2013-present, Facebook, Inc.
165250
*
166-
* This source code is licensed under the BSD-style license found in the
167-
* LICENSE file in the root directory of this source tree. An additional grant
168-
* of patent rights can be found in the PATENTS file in the same directory.
251+
* This source code is licensed under the MIT license found in the
252+
* LICENSE file in the root directory of this source tree.
169253
*/
170254

171255
'use strict';
@@ -199,7 +283,7 @@ function checkPropTypes(typeSpecs, values, location, componentName, getStack) {
199283
try {
200284
// This is intentionally an invariant that gets caught. It's the same
201285
// behavior as without this statement except with a better message.
202-
invariant(typeof typeSpecs[typeSpecName] === 'function', '%s: %s type `%s` is invalid; it must be a function, usually from ' + 'React.PropTypes.', componentName || 'React class', location, typeSpecName);
286+
invariant(typeof typeSpecs[typeSpecName] === 'function', '%s: %s type `%s` is invalid; it must be a function, usually from ' + 'the `prop-types` package, but received `%s`.', componentName || 'React class', location, typeSpecName, typeof typeSpecs[typeSpecName]);
203287
error = typeSpecs[typeSpecName](values, typeSpecName, componentName, location, null, ReactPropTypesSecret);
204288
} catch (ex) {
205289
error = ex;
@@ -221,14 +305,12 @@ function checkPropTypes(typeSpecs, values, location, componentName, getStack) {
221305

222306
module.exports = checkPropTypes;
223307

224-
},{"./lib/ReactPropTypesSecret":8,"fbjs/lib/invariant":2,"fbjs/lib/warning":3}],5:[function(require,module,exports){
308+
},{"./lib/ReactPropTypesSecret":9,"fbjs/lib/invariant":2,"fbjs/lib/warning":3}],6:[function(require,module,exports){
225309
/**
226-
* Copyright 2013-present, Facebook, Inc.
227-
* All rights reserved.
310+
* Copyright (c) 2013-present, Facebook, Inc.
228311
*
229-
* This source code is licensed under the BSD-style license found in the
230-
* LICENSE file in the root directory of this source tree. An additional grant
231-
* of patent rights can be found in the PATENTS file in the same directory.
312+
* This source code is licensed under the MIT license found in the
313+
* LICENSE file in the root directory of this source tree.
232314
*/
233315

234316
'use strict';
@@ -273,7 +355,8 @@ module.exports = function() {
273355
objectOf: getShim,
274356
oneOf: getShim,
275357
oneOfType: getShim,
276-
shape: getShim
358+
shape: getShim,
359+
exact: getShim
277360
};
278361

279362
ReactPropTypes.checkPropTypes = emptyFunction;
@@ -282,21 +365,20 @@ module.exports = function() {
282365
return ReactPropTypes;
283366
};
284367

285-
},{"./lib/ReactPropTypesSecret":8,"fbjs/lib/emptyFunction":1,"fbjs/lib/invariant":2}],6:[function(require,module,exports){
368+
},{"./lib/ReactPropTypesSecret":9,"fbjs/lib/emptyFunction":1,"fbjs/lib/invariant":2}],7:[function(require,module,exports){
286369
/**
287-
* Copyright 2013-present, Facebook, Inc.
288-
* All rights reserved.
370+
* Copyright (c) 2013-present, Facebook, Inc.
289371
*
290-
* This source code is licensed under the BSD-style license found in the
291-
* LICENSE file in the root directory of this source tree. An additional grant
292-
* of patent rights can be found in the PATENTS file in the same directory.
372+
* This source code is licensed under the MIT license found in the
373+
* LICENSE file in the root directory of this source tree.
293374
*/
294375

295376
'use strict';
296377

297378
var emptyFunction = require('fbjs/lib/emptyFunction');
298379
var invariant = require('fbjs/lib/invariant');
299380
var warning = require('fbjs/lib/warning');
381+
var assign = require('object-assign');
300382

301383
var ReactPropTypesSecret = require('./lib/ReactPropTypesSecret');
302384
var checkPropTypes = require('./checkPropTypes');
@@ -395,7 +477,8 @@ module.exports = function(isValidElement, throwOnDirectAccess) {
395477
objectOf: createObjectOfTypeChecker,
396478
oneOf: createEnumTypeChecker,
397479
oneOfType: createUnionTypeChecker,
398-
shape: createShapeTypeChecker
480+
shape: createShapeTypeChecker,
481+
exact: createStrictShapeTypeChecker,
399482
};
400483

401484
/**
@@ -610,7 +693,7 @@ module.exports = function(isValidElement, throwOnDirectAccess) {
610693
if (typeof checker !== 'function') {
611694
warning(
612695
false,
613-
'Invalid argument supplid to oneOfType. Expected an array of check functions, but ' +
696+
'Invalid argument supplied to oneOfType. Expected an array of check functions, but ' +
614697
'received %s at index %s.',
615698
getPostfixForTypeWarning(checker),
616699
i
@@ -664,6 +747,36 @@ module.exports = function(isValidElement, throwOnDirectAccess) {
664747
return createChainableTypeChecker(validate);
665748
}
666749

750+
function createStrictShapeTypeChecker(shapeTypes) {
751+
function validate(props, propName, componentName, location, propFullName) {
752+
var propValue = props[propName];
753+
var propType = getPropType(propValue);
754+
if (propType !== 'object') {
755+
return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of type `' + propType + '` ' + ('supplied to `' + componentName + '`, expected `object`.'));
756+
}
757+
// We need to check all keys in case some are required but missing from
758+
// props.
759+
var allKeys = assign({}, props[propName], shapeTypes);
760+
for (var key in allKeys) {
761+
var checker = shapeTypes[key];
762+
if (!checker) {
763+
return new PropTypeError(
764+
'Invalid ' + location + ' `' + propFullName + '` key `' + key + '` supplied to `' + componentName + '`.' +
765+
'\nBad object: ' + JSON.stringify(props[propName], null, ' ') +
766+
'\nValid keys: ' + JSON.stringify(Object.keys(shapeTypes), null, ' ')
767+
);
768+
}
769+
var error = checker(propValue, key, componentName, location, propFullName + '.' + key, ReactPropTypesSecret);
770+
if (error) {
771+
return error;
772+
}
773+
}
774+
return null;
775+
}
776+
777+
return createChainableTypeChecker(validate);
778+
}
779+
667780
function isNode(propValue) {
668781
switch (typeof propValue) {
669782
case 'number':
@@ -796,14 +909,12 @@ module.exports = function(isValidElement, throwOnDirectAccess) {
796909
return ReactPropTypes;
797910
};
798911

799-
},{"./checkPropTypes":4,"./lib/ReactPropTypesSecret":8,"fbjs/lib/emptyFunction":1,"fbjs/lib/invariant":2,"fbjs/lib/warning":3}],7:[function(require,module,exports){
912+
},{"./checkPropTypes":5,"./lib/ReactPropTypesSecret":9,"fbjs/lib/emptyFunction":1,"fbjs/lib/invariant":2,"fbjs/lib/warning":3,"object-assign":4}],8:[function(require,module,exports){
800913
/**
801-
* Copyright 2013-present, Facebook, Inc.
802-
* All rights reserved.
914+
* Copyright (c) 2013-present, Facebook, Inc.
803915
*
804-
* This source code is licensed under the BSD-style license found in the
805-
* LICENSE file in the root directory of this source tree. An additional grant
806-
* of patent rights can be found in the PATENTS file in the same directory.
916+
* This source code is licensed under the MIT license found in the
917+
* LICENSE file in the root directory of this source tree.
807918
*/
808919

809920
if ("production" !== 'production') {
@@ -828,14 +939,12 @@ if ("production" !== 'production') {
828939
module.exports = require('./factoryWithThrowingShims')();
829940
}
830941

831-
},{"./factoryWithThrowingShims":5,"./factoryWithTypeCheckers":6}],8:[function(require,module,exports){
942+
},{"./factoryWithThrowingShims":6,"./factoryWithTypeCheckers":7}],9:[function(require,module,exports){
832943
/**
833-
* Copyright 2013-present, Facebook, Inc.
834-
* All rights reserved.
944+
* Copyright (c) 2013-present, Facebook, Inc.
835945
*
836-
* This source code is licensed under the BSD-style license found in the
837-
* LICENSE file in the root directory of this source tree. An additional grant
838-
* of patent rights can be found in the PATENTS file in the same directory.
946+
* This source code is licensed under the MIT license found in the
947+
* LICENSE file in the root directory of this source tree.
839948
*/
840949

841950
'use strict';
@@ -844,7 +953,7 @@ var ReactPropTypesSecret = 'SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED';
844953

845954
module.exports = ReactPropTypesSecret;
846955

847-
},{}],9:[function(require,module,exports){
956+
},{}],10:[function(require,module,exports){
848957
Object.defineProperty(exports, "__esModule", {
849958
value: true
850959
});
@@ -914,19 +1023,20 @@ function removeAll() {
9141023
return { type: _const.RNS_REMOVE_ALL_NOTIFICATIONS };
9151024
}
9161025

917-
},{"./const":10}],10:[function(require,module,exports){
1026+
},{"./const":11}],11:[function(require,module,exports){
9181027
Object.defineProperty(exports, "__esModule", {
9191028
value: true
9201029
});
9211030
var RNS_SHOW_NOTIFICATION = exports.RNS_SHOW_NOTIFICATION = 'RNS_SHOW_NOTIFICATION';
9221031
var RNS_HIDE_NOTIFICATION = exports.RNS_HIDE_NOTIFICATION = 'RNS_HIDE_NOTIFICATION';
9231032
var RNS_REMOVE_ALL_NOTIFICATIONS = exports.RNS_REMOVE_ALL_NOTIFICATIONS = 'RNS_REMOVE_ALL_NOTIFICATIONS';
9241033

925-
},{}],11:[function(require,module,exports){
1034+
},{}],12:[function(require,module,exports){
9261035
(function (global){
9271036
Object.defineProperty(exports, "__esModule", {
9281037
value: true
9291038
});
1039+
exports.reducer = undefined;
9301040

9311041
var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };
9321042

@@ -948,6 +1058,19 @@ Object.keys(_actions).forEach(function (key) {
9481058
});
9491059
});
9501060

1061+
var _reducer = require('./reducer');
1062+
1063+
Object.defineProperty(exports, 'reducer', {
1064+
enumerable: true,
1065+
get: function () {
1066+
function get() {
1067+
return _interopRequireDefault(_reducer)['default'];
1068+
}
1069+
1070+
return get;
1071+
}()
1072+
});
1073+
9511074
var _react = (typeof window !== "undefined" ? window['React'] : typeof global !== "undefined" ? global['React'] : null);
9521075

9531076
var _react2 = _interopRequireDefault(_react);
@@ -958,10 +1081,6 @@ var _propTypes2 = _interopRequireDefault(_propTypes);
9581081

9591082
var actions = _interopRequireWildcard(_actions);
9601083

961-
var _reducer = require('./reducer');
962-
963-
var _reducer2 = _interopRequireDefault(_reducer);
964-
9651084
var _reactNotificationSystem = require('react-notification-system');
9661085

9671086
var _reactNotificationSystem2 = _interopRequireDefault(_reactNotificationSystem);
@@ -1074,14 +1193,11 @@ Notifications.contextTypes = {
10741193
store: _propTypes2['default'].object
10751194
};
10761195

1077-
// Tie actions to Notifications component instance
1078-
1079-
1080-
Notifications.reducer = _reducer2['default'];
1196+
// Export actions and reducer
10811197
exports['default'] = Notifications;
10821198

10831199
}).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
1084-
},{"./actions":9,"./reducer":12,"prop-types":7,"react-notification-system":undefined}],12:[function(require,module,exports){
1200+
},{"./actions":10,"./reducer":13,"prop-types":8,"react-notification-system":undefined}],13:[function(require,module,exports){
10851201
Object.defineProperty(exports, "__esModule", {
10861202
value: true
10871203
});
@@ -1116,5 +1232,5 @@ function Notifications() {
11161232
return state;
11171233
}
11181234

1119-
},{"./const":10}]},{},[11])(11)
1235+
},{"./const":11}]},{},[12])(12)
11201236
});

0 commit comments

Comments
 (0)