Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

react-facebook

Package Overview
Dependencies
Maintainers
1
Versions
84
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-facebook - npm Package Compare versions

Comparing version 3.0.8 to 4.0.1

lib/InitFacebook.js

6

__tests__/share.jsx

@@ -8,3 +8,3 @@ import React from 'react';

const wrapper = mount(
<FacebookProvider appID="123456789">
<FacebookProvider appId="123456789">
<span>Test</span>

@@ -19,4 +19,4 @@ </FacebookProvider>

const wrapper = mount(
<FacebookProvider appID="123456789">
<Share popup>
<FacebookProvider appId="123456789">
<Share>
<button type="button" onClick={done}>

@@ -23,0 +23,0 @@ Test

import gulp from 'gulp';
import babel from 'gulp-babel';
import jsxCoverage from 'gulp-jsx-coverage';
import path from 'path';
import coveralls from 'gulp-coveralls';
gulp.task('test', jsxCoverage.createTask({
src: ['./tests/**/*{.js,.jsx}'],
istanbul: {
preserveComments: true,
coverageVariable: '__MY_TEST_COVERAGE__',
exclude: /node_modules|test[0-9]/,
},
threshold: 50,
thresholdType: 'lines',
transpile: {
babel: {
include: /\.jsx?$/,
exclude: /node_modules/,
omitExt: false,
},
},
coverage: {
reporters: ['text-summary', 'json', 'lcov'],
directory: 'coverage',
},
mocha: {
reporter: 'spec',
},
}));
gulp.task('build', () =>

@@ -38,10 +9,1 @@ gulp.src('./src/**/*.{js,jsx}')

);
gulp.task('coveralls', ['test'], () => {
if (!process.env.CI) {
return void 0;
}
return gulp.src(path.join(__dirname, 'coverage/lcov.info'))
.pipe(coveralls());
});
'use strict';
exports.__esModule = true;
exports.default = undefined;
exports.default = Comments;
var _extends2 = require('babel-runtime/helpers/extends');
var _extends3 = _interopRequireDefault(_extends2);
var _classCallCheck2 = require('babel-runtime/helpers/classCallCheck');
var _classCallCheck3 = _interopRequireDefault(_classCallCheck2);
var _possibleConstructorReturn2 = require('babel-runtime/helpers/possibleConstructorReturn');
var _possibleConstructorReturn3 = _interopRequireDefault(_possibleConstructorReturn2);
var _inherits2 = require('babel-runtime/helpers/inherits');
var _inherits3 = _interopRequireDefault(_inherits2);
var _class, _temp;
var _react = require('react');

@@ -32,5 +14,5 @@

var _Parser2 = require('./Parser');
var _Parser = require('./Parser');
var _Parser3 = _interopRequireDefault(_Parser2);
var _Parser2 = _interopRequireDefault(_Parser);

@@ -51,22 +33,17 @@ var _getCurrentHref = require('./utils/getCurrentHref');

var Comments = (_temp = _class = function (_Parser) {
(0, _inherits3.default)(Comments, _Parser);
function Comments(props) {
var className = props.className,
colorScheme = props.colorScheme,
_props$href = props.href,
href = _props$href === undefined ? (0, _getCurrentHref2.default)() : _props$href,
numPosts = props.numPosts,
orderBy = props.orderBy,
width = props.width,
children = props.children;
function Comments() {
(0, _classCallCheck3.default)(this, Comments);
return (0, _possibleConstructorReturn3.default)(this, _Parser.apply(this, arguments));
}
Comments.prototype.renderComponent = function renderComponent() {
var _props = this.props,
colorScheme = _props.colorScheme,
_props$href = _props.href,
href = _props$href === undefined ? (0, _getCurrentHref2.default)() : _props$href,
numPosts = _props.numPosts,
orderBy = _props.orderBy,
width = _props.width,
children = _props.children;
return _react2.default.createElement(
return _react2.default.createElement(
_Parser2.default,
{ className: className },
_react2.default.createElement(
'div',

@@ -83,7 +60,8 @@ {

children
);
};
)
);
}
return Comments;
}(_Parser3.default), _class.propTypes = (0, _extends3.default)({}, _Parser3.default.propTypes, {
Comments.propTypes = {
className: _propTypes2.default.string,
href: _propTypes2.default.string,

@@ -95,8 +73,12 @@ numPosts: _propTypes2.default.number.isRequired,

children: _propTypes2.default.node
}), _class.defaultProps = {
};
Comments.defaultProps = {
numPosts: 10,
orderBy: _CommentsOrderBy2.default.SOCIAL,
width: 550,
colorScheme: _ColorScheme2.default.LIGHT
}, _temp);
exports.default = Comments;
colorScheme: _ColorScheme2.default.LIGHT,
children: undefined,
className: undefined,
href: undefined
};
'use strict';
exports.__esModule = true;
exports.default = undefined;
exports.default = CommentsCount;
var _extends2 = require('babel-runtime/helpers/extends');
var _extends3 = _interopRequireDefault(_extends2);
var _classCallCheck2 = require('babel-runtime/helpers/classCallCheck');
var _classCallCheck3 = _interopRequireDefault(_classCallCheck2);
var _possibleConstructorReturn2 = require('babel-runtime/helpers/possibleConstructorReturn');
var _possibleConstructorReturn3 = _interopRequireDefault(_possibleConstructorReturn2);
var _inherits2 = require('babel-runtime/helpers/inherits');
var _inherits3 = _interopRequireDefault(_inherits2);
var _class, _temp;
var _react = require('react');

@@ -32,5 +14,5 @@

var _Parser2 = require('./Parser');
var _Parser = require('./Parser');
var _Parser3 = _interopRequireDefault(_Parser2);
var _Parser2 = _interopRequireDefault(_Parser);

@@ -43,18 +25,13 @@ var _getCurrentHref = require('./utils/getCurrentHref');

var CommentsCount = (_temp = _class = function (_Parser) {
(0, _inherits3.default)(CommentsCount, _Parser);
function CommentsCount(props) {
var className = props.className,
_props$href = props.href,
href = _props$href === undefined ? (0, _getCurrentHref2.default)() : _props$href,
children = props.children;
function CommentsCount() {
(0, _classCallCheck3.default)(this, CommentsCount);
return (0, _possibleConstructorReturn3.default)(this, _Parser.apply(this, arguments));
}
CommentsCount.prototype.renderComponent = function renderComponent() {
var _props = this.props,
_props$href = _props.href,
href = _props$href === undefined ? (0, _getCurrentHref2.default)() : _props$href,
children = _props.children;
return _react2.default.createElement(
return _react2.default.createElement(
_Parser2.default,
{ className: className },
_react2.default.createElement(
'span',

@@ -66,10 +43,16 @@ {

children
);
};
)
);
}
return CommentsCount;
}(_Parser3.default), _class.propTypes = (0, _extends3.default)({}, _Parser3.default.propTypes, {
CommentsCount.propTypes = {
className: _propTypes2.default.string,
href: _propTypes2.default.string,
children: _propTypes2.default.node
}), _temp);
exports.default = CommentsCount;
};
CommentsCount.defaultProps = {
className: undefined,
href: undefined,
children: undefined
};
'use strict';
exports.__esModule = true;
exports.default = undefined;
exports.default = EmbeddedPost;
var _classCallCheck2 = require('babel-runtime/helpers/classCallCheck');
var _classCallCheck3 = _interopRequireDefault(_classCallCheck2);
var _possibleConstructorReturn2 = require('babel-runtime/helpers/possibleConstructorReturn');
var _possibleConstructorReturn3 = _interopRequireDefault(_possibleConstructorReturn2);
var _inherits2 = require('babel-runtime/helpers/inherits');
var _inherits3 = _interopRequireDefault(_inherits2);
var _class, _temp;
var _react = require('react');

@@ -28,25 +14,20 @@

var _Parser2 = require('./Parser');
var _Parser = require('./Parser');
var _Parser3 = _interopRequireDefault(_Parser2);
var _Parser2 = _interopRequireDefault(_Parser);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
var EmbeddedPost = (_temp = _class = function (_Parser) {
(0, _inherits3.default)(EmbeddedPost, _Parser);
function EmbeddedPost(props) {
var className = props.className,
href = props.href,
width = props.width,
showText = props.showText,
children = props.children;
function EmbeddedPost() {
(0, _classCallCheck3.default)(this, EmbeddedPost);
return (0, _possibleConstructorReturn3.default)(this, _Parser.apply(this, arguments));
}
EmbeddedPost.prototype.renderComponent = function renderComponent() {
var _props = this.props,
href = _props.href,
width = _props.width,
showText = _props.showText,
children = _props.children;
return _react2.default.createElement(
return _react2.default.createElement(
_Parser2.default,
{ className: className },
_react2.default.createElement(
'div',

@@ -60,17 +41,20 @@ {

children
);
};
)
);
}
return EmbeddedPost;
}(_Parser3.default), _class.propTypes = {
EmbeddedPost.propTypes = {
className: _propTypes2.default.string,
href: _propTypes2.default.string.isRequired,
width: _propTypes2.default.oneOfType([_propTypes2.default.number.isRequired, _propTypes2.default.string.isRequired]),
showText: _propTypes2.default.bool.isRequired,
children: _propTypes2.default.node,
className: _propTypes2.default.string
}, _class.defaultProps = {
children: _propTypes2.default.node
};
EmbeddedPost.defaultProps = {
href: 'http://www.facebook.com',
width: 500, // 350 - 750
showText: false
}, _temp);
exports.default = EmbeddedPost;
showText: false,
children: undefined,
className: undefined
};

@@ -59,2 +59,6 @@ 'use strict';

Facebook.prototype.getAppId = function getAppId() {
return this.options.appId;
};
Facebook.prototype.init = function () {

@@ -61,0 +65,0 @@ var _ref = (0, _asyncToGenerator3.default)(_regenerator2.default.mark(function _callee() {

@@ -10,2 +10,10 @@ 'use strict';

var _regenerator = require('babel-runtime/regenerator');
var _regenerator2 = _interopRequireDefault(_regenerator);
var _asyncToGenerator2 = require('babel-runtime/helpers/asyncToGenerator');
var _asyncToGenerator3 = _interopRequireDefault(_asyncToGenerator2);
var _classCallCheck2 = require('babel-runtime/helpers/classCallCheck');

@@ -23,8 +31,4 @@

var _class, _temp2;
var _class, _temp;
var _react = require('react');
var _react2 = _interopRequireDefault(_react);
var _propTypes = require('prop-types');

@@ -34,105 +38,62 @@

var _qs = require('qs');
var _getCurrentHref = require('./utils/getCurrentHref');
var _qs2 = _interopRequireDefault(_qs);
var _getCurrentHref2 = _interopRequireDefault(_getCurrentHref);
var _FacebookProvider = require('./FacebookProvider');
var _Process2 = require('./Process');
var _FacebookProvider2 = _interopRequireDefault(_FacebookProvider);
var _Process3 = _interopRequireDefault(_Process2);
var _getCurrentHref = require('./utils/getCurrentHref');
var _getCurrentHref2 = _interopRequireDefault(_getCurrentHref);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
var Feed = (_temp2 = _class = function (_Component) {
(0, _inherits3.default)(Feed, _Component);
var Feed = (_temp = _class = function (_Process) {
(0, _inherits3.default)(Feed, _Process);
function Feed() {
var _temp, _this, _ret;
(0, _classCallCheck3.default)(this, Feed);
for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) {
args[_key] = arguments[_key];
}
return _ret = (_temp = (_this = (0, _possibleConstructorReturn3.default)(this, _Component.call.apply(_Component, [this].concat(args))), _this), _this.onClick = function (evn) {
evn.preventDefault();
evn.stopPropagation();
var href = _this.getSharerHref();
var _this$props = _this.props,
width = _this$props.width,
height = _this$props.height;
var halfWidth = Math.floor(width / 2);
var halfHeight = Math.floor(height / 2);
var left = Math.floor(window.innerWidth / 2 - halfWidth);
var top = Math.floor(window.innerHeight / 2 - halfHeight);
var params = 'status=0, width=' + width + ', height=' + height + ', top=' + top + ', left=' + left + ', toolbar=0, location=0, menubar=0, directories=0, scrollbars=0';
window.open(href, 'sharer', params);
var children = _this.props.children;
if (children && children.props && children.props.onClick) {
children.props.onClick(evn);
}
}, _temp), (0, _possibleConstructorReturn3.default)(_this, _ret);
return (0, _possibleConstructorReturn3.default)(this, _Process.apply(this, arguments));
}
Feed.prototype.getSharerHref = function getSharerHref() {
var facebook = this.context.facebook;
var _props = this.props,
_props$appId = _props.appId,
appId = _props$appId === undefined ? facebook.props.appId : _props$appId,
redirectURI = _props.redirectURI,
display = _props.display,
from = _props.from,
to = _props.to,
_props$link = _props.link,
link = _props$link === undefined ? (0, _getCurrentHref2.default)() : _props$link,
picture = _props.picture,
source = _props.source,
name = _props.name,
caption = _props.caption,
description = _props.description,
ref = _props.ref;
Feed.prototype.process = function () {
var _ref = (0, _asyncToGenerator3.default)(_regenerator2.default.mark(function _callee(facebook) {
var _props, _props$link, link, display, _props$appId, appId, redirectURI, from, to, picture, source, name, caption, description, ref;
return _regenerator2.default.wrap(function _callee$(_context) {
while (1) {
switch (_context.prev = _context.next) {
case 0:
_props = this.props, _props$link = _props.link, link = _props$link === undefined ? (0, _getCurrentHref2.default)() : _props$link, display = _props.display, _props$appId = _props.appId, appId = _props$appId === undefined ? facebook.getAppId() : _props$appId, redirectURI = _props.redirectURI, from = _props.from, to = _props.to, picture = _props.picture, source = _props.source, name = _props.name, caption = _props.caption, description = _props.description, ref = _props.ref;
return _context.abrupt('return', facebook.ui({
method: 'feed',
link: link,
display: display,
app_id: appId,
redirect_uri: redirectURI,
from: from,
to: to,
picture: picture,
source: source,
name: name,
caption: caption,
description: description,
ref: ref
}));
var query = _qs2.default.stringify({
app_id: appId,
redirect_uri: redirectURI,
display: display,
from: from,
to: to,
link: link,
picture: picture,
source: source,
name: name,
caption: caption,
description: description,
ref: ref
});
case 2:
case 'end':
return _context.stop();
}
}
}, _callee, this);
}));
return '//www.facebook.com/dialog/feed?' + query;
};
function process(_x) {
return _ref.apply(this, arguments);
}
Feed.prototype.render = function render() {
var children = this.props.children;
return process;
}();
return _react2.default.cloneElement(children, { onClick: this.onClick });
};
return Feed;
}(_react.Component), _class.contextTypes = (0, _extends3.default)({}, _FacebookProvider2.default.childContextTypes), _class.propTypes = {
children: _propTypes2.default.node,
width: _propTypes2.default.number.isRequired,
height: _propTypes2.default.number.isRequired,
}(_Process3.default), _class.propTypes = (0, _extends3.default)({}, _Process3.default.propTypes, {
appId: _propTypes2.default.string,

@@ -150,10 +111,8 @@ redirectURI: _propTypes2.default.string,

ref: _propTypes2.default.string
}, _class.defaultProps = {
}), _class.defaultProps = (0, _extends3.default)({}, _Process3.default.defaultProps, {
link: undefined,
display: 'popup',
width: 626,
height: 436,
buttonClassName: 'btn btn-lg',
iconClassName: 'fa fa-facebook pull-left',
icon: true
}, _temp2);
appId: undefined,
redirectURI: undefined
}), _temp);
exports.default = Feed;
'use strict';
exports.__esModule = true;
exports.CommentsOrderBy = exports.LikeAction = exports.ColorScheme = exports.LikeLayout = exports.LikeSize = exports.Feed = exports.CommentsCount = exports.Comments = exports.EmbeddedPost = exports.LoginButton = exports.Login = exports.Page = exports.ShareButton = exports.Share = exports.Like = exports.FacebookProvider = exports.default = undefined;
exports.CommentsOrderBy = exports.LikeAction = exports.ColorScheme = exports.LikeLayout = exports.LikeSize = exports.Feed = exports.CommentsCount = exports.Comments = exports.EmbeddedPost = exports.LoginButton = exports.Login = exports.Page = exports.ShareButton = exports.Share = exports.Like = exports.InitFacebook = exports.Parser = exports.FacebookProvider = exports.default = undefined;

@@ -10,2 +10,10 @@ var _FacebookProvider2 = require('./FacebookProvider');

var _Parser2 = require('./Parser');
var _Parser3 = _interopRequireDefault(_Parser2);
var _InitFacebook2 = require('./InitFacebook');
var _InitFacebook3 = _interopRequireDefault(_InitFacebook2);
var _Like2 = require('./Like');

@@ -75,2 +83,4 @@

exports.FacebookProvider = _FacebookProvider3.default;
exports.Parser = _Parser3.default;
exports.InitFacebook = _InitFacebook3.default;
exports.Like = _Like3.default;

@@ -77,0 +87,0 @@ exports.Share = _Share3.default;

'use strict';
exports.__esModule = true;
exports.default = undefined;
exports.default = Like;
var _extends2 = require('babel-runtime/helpers/extends');
var _extends3 = _interopRequireDefault(_extends2);
var _classCallCheck2 = require('babel-runtime/helpers/classCallCheck');
var _classCallCheck3 = _interopRequireDefault(_classCallCheck2);
var _possibleConstructorReturn2 = require('babel-runtime/helpers/possibleConstructorReturn');
var _possibleConstructorReturn3 = _interopRequireDefault(_possibleConstructorReturn2);
var _inherits2 = require('babel-runtime/helpers/inherits');
var _inherits3 = _interopRequireDefault(_inherits2);
var _class, _temp;
var _react = require('react');

@@ -32,5 +14,5 @@

var _Parser2 = require('./Parser');
var _Parser = require('./Parser');
var _Parser3 = _interopRequireDefault(_Parser2);
var _Parser2 = _interopRequireDefault(_Parser);

@@ -59,27 +41,22 @@ var _getCurrentHref = require('./utils/getCurrentHref');

var Like = (_temp = _class = function (_Parser) {
(0, _inherits3.default)(Like, _Parser);
function Like(props) {
var className = props.className,
_props$href = props.href,
href = _props$href === undefined ? (0, _getCurrentHref2.default)() : _props$href,
layout = props.layout,
colorScheme = props.colorScheme,
action = props.action,
showFaces = props.showFaces,
share = props.share,
children = props.children,
width = props.width,
size = props.size,
kidDirectedSite = props.kidDirectedSite,
referral = props.referral;
function Like() {
(0, _classCallCheck3.default)(this, Like);
return (0, _possibleConstructorReturn3.default)(this, _Parser.apply(this, arguments));
}
Like.prototype.renderComponent = function renderComponent() {
var _props = this.props,
_props$href = _props.href,
href = _props$href === undefined ? (0, _getCurrentHref2.default)() : _props$href,
layout = _props.layout,
colorScheme = _props.colorScheme,
action = _props.action,
showFaces = _props.showFaces,
share = _props.share,
children = _props.children,
width = _props.width,
size = _props.size,
kidDirectedSite = _props.kidDirectedSite,
referral = _props.referral;
return _react2.default.createElement(
return _react2.default.createElement(
_Parser2.default,
{ className: className },
_react2.default.createElement(
'div',

@@ -100,7 +77,8 @@ {

children
);
};
)
);
}
return Like;
}(_Parser3.default), _class.propTypes = (0, _extends3.default)({}, _Parser3.default.propTypes, {
Like.propTypes = {
className: _propTypes2.default.string,
referral: _propTypes2.default.string,

@@ -117,3 +95,5 @@ href: _propTypes2.default.string,

kidDirectedSite: _propTypes2.default.bool.isRequired
}), _class.defaultProps = {
};
Like.defaultProps = {
layout: _LikeLayout2.default.STANDARD,

@@ -125,4 +105,8 @@ showFaces: false,

size: _LikeSize2.default.SMALL,
kidDirectedSite: false
}, _temp);
exports.default = Like;
kidDirectedSite: false,
children: undefined,
className: undefined,
href: undefined,
referral: undefined,
width: undefined
};

@@ -30,8 +30,4 @@ 'use strict';

var _class, _temp2;
var _class, _temp;
var _react = require('react');
var _react2 = _interopRequireDefault(_react);
var _propTypes = require('prop-types');

@@ -41,218 +37,69 @@

var _canUseDom = require('can-use-dom');
var _Process2 = require('./Process');
var _canUseDom2 = _interopRequireDefault(_canUseDom);
var _Process3 = _interopRequireDefault(_Process2);
var _Facebook = require('./Facebook');
var _FacebookProvider = require('./FacebookProvider');
var _FacebookProvider2 = _interopRequireDefault(_FacebookProvider);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
var Login = (_temp2 = _class = function (_Component) {
(0, _inherits3.default)(Login, _Component);
var Login = (_temp = _class = function (_Process) {
(0, _inherits3.default)(Login, _Process);
function Login() {
var _this2 = this;
var _temp, _this, _ret;
(0, _classCallCheck3.default)(this, Login);
return (0, _possibleConstructorReturn3.default)(this, _Process.apply(this, arguments));
}
for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) {
args[_key] = arguments[_key];
}
Login.prototype.process = function () {
var _ref = (0, _asyncToGenerator3.default)(_regenerator2.default.mark(function _callee(facebook) {
var _props, scope, fields, returnScopes, rerequest, loginQpts, response;
return _ret = (_temp = (_this = (0, _possibleConstructorReturn3.default)(this, _Component.call.apply(_Component, [this].concat(args))), _this), _this.state = {}, _this.onClick = function () {
var _ref = (0, _asyncToGenerator3.default)(_regenerator2.default.mark(function _callee(evn) {
var _this$state, facebook, isWorking, _this$props, scope, fields, onError, onResponse, returnScopes, rerequest, loginQpts, response, data;
return _regenerator2.default.wrap(function _callee$(_context) {
while (1) {
switch (_context.prev = _context.next) {
case 0:
_props = this.props, scope = _props.scope, fields = _props.fields, returnScopes = _props.returnScopes, rerequest = _props.rerequest;
loginQpts = { scope: scope };
return _regenerator2.default.wrap(function _callee$(_context) {
while (1) {
switch (_context.prev = _context.next) {
case 0:
evn.stopPropagation();
evn.preventDefault();
_this$state = _this.state, facebook = _this$state.facebook, isWorking = _this$state.isWorking;
if (returnScopes) {
loginQpts.return_scopes = true;
}
if (!(!facebook || isWorking)) {
_context.next = 5;
break;
}
if (rerequest) {
loginQpts.auth_type = 'rerequest';
}
return _context.abrupt('return');
_context.next = 6;
return facebook.login(loginQpts);
case 5:
case 6:
response = _context.sent;
_this.setState({
isWorking: true
});
_this$props = _this.props, scope = _this$props.scope, fields = _this$props.fields, onError = _this$props.onError, onResponse = _this$props.onResponse, returnScopes = _this$props.returnScopes, rerequest = _this$props.rerequest;
loginQpts = { scope: scope };
if (returnScopes) {
loginQpts.return_scopes = true;
}
if (rerequest) {
loginQpts.auth_type = 'rerequest';
}
_context.prev = 10;
_context.next = 13;
return facebook.login(loginQpts);
case 13:
response = _context.sent;
if (!(response.status !== 'connected')) {
_context.next = 16;
break;
}
throw new Error('Unauthorized user');
case 16:
_context.next = 18;
return facebook.getTokenDetailWithProfile({ fields: fields });
case 18:
data = _context.sent;
_this.setState({
isWorking: false,
data: data,
error: null
});
if (onResponse) {
onResponse(data);
}
_context.next = 27;
if (!(response.status !== 'connected')) {
_context.next = 9;
break;
}
case 23:
_context.prev = 23;
_context.t0 = _context['catch'](10);
throw new Error('Unauthorized user');
_this.setState({
isWorking: false,
data: null,
error: _context.t0
});
case 9:
return _context.abrupt('return', facebook.getTokenDetailWithProfile({ fields: fields }));
if (onError) {
onError(_context.t0);
}
case 27:
case 'end':
return _context.stop();
}
}
}, _callee, _this2, [[10, 23]]);
}));
return function (_x) {
return _ref.apply(this, arguments);
};
}(), _temp), (0, _possibleConstructorReturn3.default)(_this, _ret);
}
Login.prototype.componentDidMount = function componentDidMount() {
if (_canUseDom2.default) {
this.initFacebook();
}
};
Login.prototype.initFacebook = function () {
var _ref2 = (0, _asyncToGenerator3.default)(_regenerator2.default.mark(function _callee2() {
var facebook, onReady;
return _regenerator2.default.wrap(function _callee2$(_context2) {
while (1) {
switch (_context2.prev = _context2.next) {
case 0:
_context2.next = 2;
return this.context.facebook.init();
case 2:
facebook = _context2.sent;
this.setState({
facebook: facebook
});
onReady = this.props.onReady;
if (onReady) {
onReady();
}
case 6:
case 10:
case 'end':
return _context2.stop();
return _context.stop();
}
}
}, _callee2, this);
}, _callee, this);
}));
function initFacebook() {
return _ref2.apply(this, arguments);
function process(_x) {
return _ref.apply(this, arguments);
}
return initFacebook;
return process;
}();
Login.prototype.render = function render() {
var _props = this.props,
children = _props.children,
render = _props.render,
Component = _props.component;
var _state = this.state,
error = _state.error,
data = _state.data,
facebook = _state.facebook,
_state$isWorking = _state.isWorking,
isWorking = _state$isWorking === undefined ? false : _state$isWorking;
var isLoading = !facebook;
if (render) {
return render({
isLoading: isLoading,
isWorking: isWorking,
data: data,
error: error,
onClick: this.onClick
});
}
if (Component) {
return _react2.default.createElement(Component, {
isLoading: isLoading,
isWorking: isWorking,
data: data,
error: error,
onClick: this.onClick
});
}
return (0, _react.cloneElement)(children, {
isLoading: isLoading,
isWorking: isWorking,
data: data,
error: error,
onClick: this.onClick
});
};
return Login;
}(_react.Component), _class.propTypes = {
}(_Process3.default), _class.propTypes = (0, _extends3.default)({}, _Process3.default.propTypes, {
scope: _propTypes2.default.string.isRequired,

@@ -263,8 +110,5 @@ fields: _propTypes2.default.array.isRequired,

onReady: _propTypes2.default.func,
children: _propTypes2.default.node,
render: _propTypes2.default.func,
returnScopes: _propTypes2.default.bool,
rerequest: _propTypes2.default.bool,
component: _propTypes2.default.node
}, _class.contextTypes = (0, _extends3.default)({}, _FacebookProvider2.default.childContextTypes), _class.defaultProps = {
rerequest: _propTypes2.default.bool
}), _class.defaultProps = (0, _extends3.default)({}, _Process3.default.defaultProps, {
scope: '',

@@ -274,7 +118,4 @@ fields: ['id', 'first_name', 'last_name', 'middle_name', 'name', 'email', 'locale', 'gender', 'timezone', 'verified', 'link'],

rerequest: false,
onReady: undefined,
children: undefined,
render: undefined,
component: undefined
}, _temp2);
onReady: undefined
}), _temp);
exports.default = Login;
'use strict';
exports.__esModule = true;
exports.default = undefined;
exports.default = Page;
var _extends2 = require('babel-runtime/helpers/extends');
var _extends3 = _interopRequireDefault(_extends2);
var _classCallCheck2 = require('babel-runtime/helpers/classCallCheck');
var _classCallCheck3 = _interopRequireDefault(_classCallCheck2);
var _possibleConstructorReturn2 = require('babel-runtime/helpers/possibleConstructorReturn');
var _possibleConstructorReturn3 = _interopRequireDefault(_possibleConstructorReturn2);
var _inherits2 = require('babel-runtime/helpers/inherits');
var _inherits3 = _interopRequireDefault(_inherits2);
var _class, _temp;
var _react = require('react');

@@ -32,5 +14,5 @@

var _Parser2 = require('./Parser');
var _Parser = require('./Parser');
var _Parser3 = _interopRequireDefault(_Parser2);
var _Parser2 = _interopRequireDefault(_Parser);

@@ -43,29 +25,24 @@ var _getCurrentHref = require('./utils/getCurrentHref');

var Page = (_temp = _class = function (_Parser) {
(0, _inherits3.default)(Page, _Parser);
function Page(props, context) {
var className = props.className,
style = props.style,
_props$href = props.href,
href = _props$href === undefined ? (0, _getCurrentHref2.default)() : _props$href,
tabs = props.tabs,
hideCover = props.hideCover,
width = props.width,
height = props.height,
showFacepile = props.showFacepile,
hideCTA = props.hideCTA,
smallHeader = props.smallHeader,
adaptContainerWidth = props.adaptContainerWidth,
children = props.children;
function Page() {
(0, _classCallCheck3.default)(this, Page);
return (0, _possibleConstructorReturn3.default)(this, _Parser.apply(this, arguments));
}
Page.prototype.renderComponent = function renderComponent() {
var _props = this.props,
style = _props.style,
_props$href = _props.href,
href = _props$href === undefined ? (0, _getCurrentHref2.default)() : _props$href,
tabs = _props.tabs,
hideCover = _props.hideCover,
width = _props.width,
height = _props.height,
showFacepile = _props.showFacepile,
hideCTA = _props.hideCTA,
smallHeader = _props.smallHeader,
adaptContainerWidth = _props.adaptContainerWidth,
children = _props.children;
var appId = context.facebook && context.facebook.props.appId;
var appId = this.context.facebook && this.context.facebook.props.appId;
return _react2.default.createElement(
return _react2.default.createElement(
_Parser2.default,
{ className: className },
_react2.default.createElement(
'div',

@@ -87,7 +64,8 @@ {

children
);
};
)
);
}
return Page;
}(_Parser3.default), _class.propTypes = (0, _extends3.default)({}, _Parser3.default.propTypes, {
Page.propTypes = {
className: _propTypes2.default.string,
href: _propTypes2.default.string.isRequired,

@@ -103,3 +81,5 @@ tabs: _propTypes2.default.string,

children: _propTypes2.default.node
}), _class.defaultProps = {
};
Page.defaultProps = {
width: 340,

@@ -112,4 +92,9 @@ height: 500,

smallHeader: false,
adaptContainerWidth: true
}, _temp);
exports.default = Page;
adaptContainerWidth: true,
children: undefined,
className: undefined
};
Page.contextTypes = {
facebook: _propTypes2.default.object.isRequired
};

@@ -6,14 +6,2 @@ 'use strict';

var _extends2 = require('babel-runtime/helpers/extends');
var _extends3 = _interopRequireDefault(_extends2);
var _regenerator = require('babel-runtime/regenerator');
var _regenerator2 = _interopRequireDefault(_regenerator);
var _asyncToGenerator2 = require('babel-runtime/helpers/asyncToGenerator');
var _asyncToGenerator3 = _interopRequireDefault(_asyncToGenerator2);
var _classCallCheck2 = require('babel-runtime/helpers/classCallCheck');

@@ -41,10 +29,6 @@

var _canUseDom = require('can-use-dom');
var _InitFacebook = require('./InitFacebook');
var _canUseDom2 = _interopRequireDefault(_canUseDom);
var _InitFacebook2 = _interopRequireDefault(_InitFacebook);
var _FacebookProvider = require('./FacebookProvider');
var _FacebookProvider2 = _interopRequireDefault(_FacebookProvider);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

@@ -64,3 +48,5 @@

return _ret = (_temp = (_this = (0, _possibleConstructorReturn3.default)(this, _Component.call.apply(_Component, [this].concat(args))), _this), _this.handleContainer = function (container) {
return _ret = (_temp = (_this = (0, _possibleConstructorReturn3.default)(this, _Component.call.apply(_Component, [this].concat(args))), _this), _this.handleFacebookReady = function (facebook) {
facebook.parse(_this.container);
}, _this.handleContainer = function (container) {
_this.container = container;

@@ -70,8 +56,2 @@ }, _temp), (0, _possibleConstructorReturn3.default)(_this, _ret);

Parser.prototype.componentDidMount = function componentDidMount() {
if (_canUseDom2.default) {
this.initFacebook();
}
};
Parser.prototype.shouldComponentUpdate = function shouldComponentUpdate() {

@@ -81,40 +61,16 @@ return false;

Parser.prototype.initFacebook = function () {
var _ref = (0, _asyncToGenerator3.default)(_regenerator2.default.mark(function _callee() {
var facebook;
return _regenerator2.default.wrap(function _callee$(_context) {
while (1) {
switch (_context.prev = _context.next) {
case 0:
_context.next = 2;
return this.context.facebook.init();
case 2:
facebook = _context.sent;
facebook.parse(this.container);
case 4:
case 'end':
return _context.stop();
}
}
}, _callee, this);
}));
function initFacebook() {
return _ref.apply(this, arguments);
}
return initFacebook;
}();
Parser.prototype.render = function render() {
var className = this.props.className;
var _props = this.props,
className = _props.className,
children = _props.children;
return _react2.default.createElement(
'div',
{ className: className, ref: this.handleContainer },
this.renderComponent()
_InitFacebook2.default,
{ onReady: this.handleFacebookReady },
_react2.default.createElement(
'div',
{ className: className, ref: this.handleContainer },
children
)
);

@@ -125,6 +81,8 @@ };

}(_react.Component), _class.propTypes = {
className: _propTypes2.default.string
className: _propTypes2.default.string,
children: _propTypes2.default.node
}, _class.defaultProps = {
className: undefined
}, _class.contextTypes = (0, _extends3.default)({}, _FacebookProvider2.default.childContextTypes), _temp2);
className: undefined,
children: undefined
}, _temp2);
exports.default = Parser;

@@ -30,8 +30,4 @@ 'use strict';

var _class, _temp2;
var _class, _temp;
var _react = require('react');
var _react2 = _interopRequireDefault(_react);
var _propTypes = require('prop-types');

@@ -41,187 +37,58 @@

var _qs = require('qs');
var _getCurrentHref = require('./utils/getCurrentHref');
var _qs2 = _interopRequireDefault(_qs);
var _getCurrentHref2 = _interopRequireDefault(_getCurrentHref);
var _canUseDom = require('can-use-dom');
var _Process2 = require('./Process');
var _canUseDom2 = _interopRequireDefault(_canUseDom);
var _Process3 = _interopRequireDefault(_Process2);
var _FacebookProvider = require('./FacebookProvider');
var _FacebookProvider2 = _interopRequireDefault(_FacebookProvider);
var _getCurrentHref = require('./utils/getCurrentHref');
var _getCurrentHref2 = _interopRequireDefault(_getCurrentHref);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
var Share = (_temp2 = _class = function (_Component) {
(0, _inherits3.default)(Share, _Component);
var Share = (_temp = _class = function (_Process) {
(0, _inherits3.default)(Share, _Process);
function Share() {
var _this2 = this;
var _temp, _this, _ret;
(0, _classCallCheck3.default)(this, Share);
return (0, _possibleConstructorReturn3.default)(this, _Process.apply(this, arguments));
}
for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) {
args[_key] = arguments[_key];
}
Share.prototype.process = function () {
var _ref = (0, _asyncToGenerator3.default)(_regenerator2.default.mark(function _callee(facebook) {
var _props, _props$href, href, display, _props$appId, appId, hashtag, redirectURI, quote, mobileIframe;
return _ret = (_temp = (_this = (0, _possibleConstructorReturn3.default)(this, _Component.call.apply(_Component, [this].concat(args))), _this), _this.onClick = function () {
var _ref = (0, _asyncToGenerator3.default)(_regenerator2.default.mark(function _callee(evn) {
var popup, facebook, _this$props, _this$props$href, href, display, _this$props$appId, appId, hashtag, redirectURI, quote, mobileIframe, fb, response, _this$props2, children, onResponse;
return _regenerator2.default.wrap(function _callee$(_context) {
while (1) {
switch (_context.prev = _context.next) {
case 0:
_props = this.props, _props$href = _props.href, href = _props$href === undefined ? (0, _getCurrentHref2.default)() : _props$href, display = _props.display, _props$appId = _props.appId, appId = _props$appId === undefined ? facebook.getAppId() : _props$appId, hashtag = _props.hashtag, redirectURI = _props.redirectURI, quote = _props.quote, mobileIframe = _props.mobileIframe;
return _context.abrupt('return', facebook.ui({
method: 'share',
href: href,
display: display,
app_id: appId,
hashtag: hashtag,
redirect_uri: redirectURI,
quote: quote,
mobile_iframe: mobileIframe
}));
return _regenerator2.default.wrap(function _callee$(_context) {
while (1) {
switch (_context.prev = _context.next) {
case 0:
evn.preventDefault();
evn.stopPropagation();
popup = _this.props.popup;
if (!popup) {
_context.next = 5;
break;
}
return _context.abrupt('return', _this.openPopup(evn));
case 5:
facebook = _this.context.facebook;
_this$props = _this.props, _this$props$href = _this$props.href, href = _this$props$href === undefined ? (0, _getCurrentHref2.default)() : _this$props$href, display = _this$props.display, _this$props$appId = _this$props.appId, appId = _this$props$appId === undefined ? facebook.props.appId : _this$props$appId, hashtag = _this$props.hashtag, redirectURI = _this$props.redirectURI, quote = _this$props.quote, mobileIframe = _this$props.mobileIframe;
_context.next = 9;
return facebook.init();
case 9:
fb = _context.sent;
_context.next = 12;
return fb.ui({
method: 'share',
href: href,
display: display,
app_id: appId,
hashtag: hashtag,
redirect_uri: redirectURI,
quote: quote,
mobile_iframe: mobileIframe
});
case 12:
response = _context.sent;
_this$props2 = _this.props, children = _this$props2.children, onResponse = _this$props2.onResponse;
if (children && children.props && children.props.onClick) {
children.props.onClick(evn);
}
if (onResponse) {
onResponse(response);
}
return _context.abrupt('return', response);
case 17:
case 'end':
return _context.stop();
}
case 2:
case 'end':
return _context.stop();
}
}, _callee, _this2);
}));
}
}, _callee, this);
}));
return function (_x) {
return _ref.apply(this, arguments);
};
}(), _temp), (0, _possibleConstructorReturn3.default)(_this, _ret);
}
Share.prototype.componentDidMount = function componentDidMount() {
var popup = this.props.popup;
if (_canUseDom2.default && !popup) {
this.context.facebook.init();
function process(_x) {
return _ref.apply(this, arguments);
}
};
Share.prototype.openPopup = function openPopup(evn) {
var href = this.getSharerHref();
var _props = this.props,
width = _props.width,
height = _props.height;
return process;
}();
var halfWidth = Math.floor(width / 2);
var halfHeight = Math.floor(height / 2);
var left = Math.floor(window.innerWidth / 2 - halfWidth);
var top = Math.floor(window.innerHeight / 2 - halfHeight);
var params = 'status=0, width=' + width + ', height=' + height + ', top=' + top + ', left=' + left + ', toolbar=0, location=0, menubar=0, directories=0, scrollbars=0';
window.open(href, 'sharer', params);
var children = this.props.children;
if (children && children.props && children.props.onClick) {
children.props.onClick(evn);
}
};
Share.prototype.getSharerHref = function getSharerHref() {
var facebook = this.context.facebook;
var _props2 = this.props,
_props2$href = _props2.href,
href = _props2$href === undefined ? (0, _getCurrentHref2.default)() : _props2$href,
display = _props2.display,
_props2$appId = _props2.appId,
appId = _props2$appId === undefined ? facebook.props.appId : _props2$appId,
hashtag = _props2.hashtag,
redirectURI = _props2.redirectURI,
quote = _props2.quote,
mobileIframe = _props2.mobileIframe;
return '//www.facebook.com/dialog/share?' + _qs2.default.stringify({
href: href,
display: display,
app_id: appId,
hashtag: hashtag,
redirect_uri: redirectURI,
quote: quote,
mobile_iframe: mobileIframe
});
};
Share.prototype.render = function render() {
var _props3 = this.props,
children = _props3.children,
render = _props3.render,
Component = _props3.component;
if (render) {
return render({
onClick: this.onClick
});
}
if (Component) {
return _react2.default.createElement(Component, { onClick: this.onClick });
}
return (0, _react.cloneElement)(children, {
onClick: this.onClick
});
};
return Share;
}(_react.Component), _class.contextTypes = (0, _extends3.default)({}, _FacebookProvider2.default.childContextTypes), _class.propTypes = {
}(_Process3.default), _class.propTypes = (0, _extends3.default)({}, _Process3.default.propTypes, {
href: _propTypes2.default.string,
width: _propTypes2.default.number.isRequired,
height: _propTypes2.default.number.isRequired,
children: _propTypes2.default.node,
hashtag: _propTypes2.default.string,

@@ -232,10 +99,5 @@ quote: _propTypes2.default.string,

appId: _propTypes2.default.string,
redirectURI: _propTypes2.default.string,
render: _propTypes2.default.func,
component: _propTypes2.default.node,
popup: _propTypes2.default.bool,
onResponse: _propTypes2.default.func
}, _class.defaultProps = {
redirectURI: _propTypes2.default.string
}), _class.defaultProps = (0, _extends3.default)({}, _Process3.default.defaultProps, {
href: undefined,
children: undefined,
hashtag: undefined,

@@ -245,14 +107,5 @@ quote: undefined,

display: 'popup',
width: 626,
height: 436,
buttonClassName: 'btn btn-lg',
iconClassName: 'fa fa-facebook pull-left',
icon: true,
appId: undefined,
redirectURI: undefined,
render: undefined,
component: undefined,
popup: false,
onResponse: undefined
}, _temp2);
redirectURI: undefined
}), _temp);
exports.default = Share;
'use strict';
exports.__esModule = true;
exports.default = undefined;

@@ -10,16 +9,8 @@ var _extends2 = require('babel-runtime/helpers/extends');

var _classCallCheck2 = require('babel-runtime/helpers/classCallCheck');
var _objectWithoutProperties2 = require('babel-runtime/helpers/objectWithoutProperties');
var _classCallCheck3 = _interopRequireDefault(_classCallCheck2);
var _objectWithoutProperties3 = _interopRequireDefault(_objectWithoutProperties2);
var _possibleConstructorReturn2 = require('babel-runtime/helpers/possibleConstructorReturn');
exports.default = ShareButton;
var _possibleConstructorReturn3 = _interopRequireDefault(_possibleConstructorReturn2);
var _inherits2 = require('babel-runtime/helpers/inherits');
var _inherits3 = _interopRequireDefault(_inherits2);
var _class, _temp;
var _react = require('react');

@@ -39,63 +30,35 @@

var ShareButton = (_temp = _class = function (_Component) {
(0, _inherits3.default)(ShareButton, _Component);
function ShareButton(props) {
var className = props.className,
iconClassName = props.iconClassName,
icon = props.icon,
children = props.children,
rest = (0, _objectWithoutProperties3.default)(props, ['className', 'iconClassName', 'icon', 'children']);
function ShareButton() {
(0, _classCallCheck3.default)(this, ShareButton);
return (0, _possibleConstructorReturn3.default)(this, _Component.apply(this, arguments));
}
ShareButton.prototype.render = function render() {
var _props = this.props,
className = _props.className,
iconClassName = _props.iconClassName,
icon = _props.icon,
children = _props.children;
var _props2 = this.props,
width = _props2.width,
href = _props2.href,
height = _props2.height,
hashtag = _props2.hashtag,
quote = _props2.quote,
mobileIframe = _props2.mobileIframe,
display = _props2.display,
appId = _props2.appId,
redirectURI = _props2.redirectURI;
return _react2.default.createElement(
_Share2.default,
return _react2.default.createElement(
_Share2.default,
rest,
_react2.default.createElement(
'button',
{
href: href,
width: width,
height: height,
hashtag: hashtag,
quote: quote,
mobileIframe: mobileIframe,
display: display,
appId: appId,
redirectURI: redirectURI
type: 'button',
className: className
},
_react2.default.createElement(
'button',
{
type: 'button',
className: className
},
!!icon && _react2.default.createElement('i', { className: iconClassName }),
children
)
);
};
!!icon && _react2.default.createElement('i', { className: iconClassName }),
children
)
);
}
return ShareButton;
}(_react.Component), _class.propTypes = (0, _extends3.default)({}, _Share2.default.propTypes, {
ShareButton.propTypes = (0, _extends3.default)({}, _Share2.default.propTypes, {
className: _propTypes2.default.string,
iconClassName: _propTypes2.default.string,
icon: _propTypes2.default.bool
}), _class.defaultProps = (0, _extends3.default)({}, _Share2.default.defaultProps, {
});
ShareButton.defaultProps = (0, _extends3.default)({}, _Share2.default.defaultProps, {
className: 'btn btn-lg',
iconClassName: 'fa fa-facebook pull-left',
icon: true
}), _temp);
exports.default = ShareButton;
});
{
"name": "react-facebook",
"version": "3.0.8",
"version": "4.0.1",
"description": "Facebook components like a Login button, Like, Share, Comments or Embedded Post",

@@ -40,3 +40,2 @@ "author": {

"build": "babel-node ./node_modules/gulp/bin/gulp.js build",
"coveralls": "babel-node ./node_modules/gulp/bin/gulp.js coveralls",
"eslint": "node ./node_modules/eslint/bin/eslint.js --ext .js,.jsx ./src"

@@ -46,3 +45,2 @@ },

"react-spinner-children": "^1.0.5",
"qs": "^6.4.0",
"can-use-dom": "^0.1.0",

@@ -71,4 +69,2 @@ "prop-types": "^15.5.8",

"gulp-babel": "^6.1.2",
"gulp-coveralls": "^0.1.4",
"gulp-jsx-coverage": "^0.4.0",
"gulp-util": "^3.0.8",

@@ -75,0 +71,0 @@ "react": "^15.5.4",

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc