Socket
Socket
Sign inDemoInstall

react-share

Package Overview
Dependencies
Maintainers
1
Versions
73
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-share - npm Package Compare versions

Comparing version 1.0.1 to 1.1.0

CHANGELOG.md

49

build/share-count-getters.js

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

var _bluebird = require('bluebird');
var _bluebird2 = _interopRequireDefault(_bluebird);
var _platform = require('platform');
var _platform2 = _interopRequireDefault(_platform);
var _utils = require('./utils');
function jsonpPromise(url) {
return new Promise(function promiseCallback(resolve, reject) {
return new _bluebird2['default'](function promiseCallback(resolve, reject) {
(0, _jsonp2['default'])(url, function jsonpCallback(err, data) {

@@ -39,5 +47,3 @@ if (err) {

return fetch(endpoint).then(function (response) {
return response.json();
}).then(function (response) {
return jsonpPromise(endpoint).then(function (response) {
return response.length && response[0].share_count ? response[0].share_count : undefined;

@@ -56,9 +62,17 @@ });

function getGooglePlusShareCount(shareUrl) {
return fetch('https://clients6.google.com/rpc', {
method: 'post',
headers: {
'Accept': 'application/json',
'Content-Type': 'application/json'
},
body: JSON.stringify({
if (_platform2['default'].name === 'IE' && parseInt(_platform2['default'].version, 10) < 11) {
/* eslint-disable no-console */
console.error('Google plus share count is not supported in <=IE10!');
/* eslint-enable no-console */
return;
}
return new _bluebird2['default'](function promiseCb(resolve, reject) {
var xhr = new XMLHttpRequest();
xhr.open('POST', 'https://clients6.google.com/rpc');
xhr.setRequestHeader('Accept', 'application/json');
xhr.setRequestHeader('Content-type', 'application/json;charset=UTF-8');
xhr.send(JSON.stringify({
method: 'pos.plusones.get',

@@ -76,6 +90,13 @@ id: 'p',

apiVersion: 'v1'
})
}));
xhr.onload = function onSuccessResponse() {
console.log(this.responseText);
resolve(JSON.parse(this.responseText));
};
xhr.onerror = function onErrorResponse() {
reject();
};
}).then(function (response) {
return response.json();
}).then(function (response) {
return !!response ? response.result.metadata.globalCounts.count : undefined;

@@ -82,0 +103,0 @@ });

@@ -9,2 +9,8 @@ 'use strict';

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
var _platform = require('platform');
var _platform2 = _interopRequireDefault(_platform);
function objectToGetParams(object) {

@@ -41,5 +47,5 @@ return '?' + Object.keys(object).filter(function (key) {

return window.open(url, name, Object.keys(config).map(function (key) {
return window.open(url, _platform2['default'].name === 'IE' && parseInt(_platform2['default'].version, 10) < 10 ? '' : name, Object.keys(config).map(function (key) {
return key + '=' + config[key];
}).join(', '));
}
{
"name": "react-share",
"version": "1.0.1",
"version": "1.1.0",
"description": "Easy social media share buttons and share counts.",

@@ -49,5 +49,7 @@ "main": "./build/react-share.js",

"dependencies": {
"bluebird": "^3.0.5",
"jsonp": "^0.2.0",
"platform": "^1.3.0",
"react": "^0.14.0 || ^0.13.0"
}
}

@@ -20,2 +20,9 @@ # react-share

## Browser
ShareButtons work on all browsers.
ShareCounts works on all browsers, with the exception of Goolge Plus share count
working only on IE11 and newer (XHR CORS problem).
## Compatibility

@@ -22,0 +29,0 @@

import jsonp from 'jsonp';
import Promise from 'bluebird';
import platform from 'platform';
import { objectToGetParams } from './utils';
function jsonpPromise(url) {

@@ -26,4 +28,3 @@ return new Promise(function promiseCallback(resolve, reject) {

return fetch(endpoint)
.then(response => response.json())
return jsonpPromise(endpoint)
.then(response => response.length && response[0].share_count

@@ -43,9 +44,17 @@ ? response[0].share_count

export function getGooglePlusShareCount(shareUrl) {
return fetch(`https://clients6.google.com/rpc`, {
method: 'post',
headers: {
'Accept': 'application/json',
'Content-Type': 'application/json'
},
body: JSON.stringify({
if (platform.name === 'IE' && parseInt(platform.version, 10) < 11) {
/* eslint-disable no-console */
console.error('Google plus share count is not supported in <=IE10!');
/* eslint-enable no-console */
return;
}
return new Promise(function promiseCb(resolve, reject) {
const xhr = new XMLHttpRequest();
xhr.open('POST', 'https://clients6.google.com/rpc');
xhr.setRequestHeader('Accept', 'application/json');
xhr.setRequestHeader('Content-type', 'application/json;charset=UTF-8');
xhr.send(JSON.stringify({
method: 'pos.plusones.get',

@@ -63,7 +72,16 @@ id: 'p',

apiVersion: 'v1'
})
}).then(response => response.json())
.then(response => !!response
? response.result.metadata.globalCounts.count
: undefined);
}));
xhr.onload = function onSuccessResponse() {
console.log(this.responseText);
resolve(JSON.parse(this.responseText));
};
xhr.onerror = function onErrorResponse() {
reject();
};
})
.then(response => !!response
? response.result.metadata.globalCounts.count
: undefined);
}

@@ -70,0 +88,0 @@

@@ -0,1 +1,3 @@

import platform from 'platform';
export function objectToGetParams(object) {

@@ -32,5 +34,5 @@ return '?' + Object.keys(object)

url,
name,
platform.name === 'IE' && parseInt(platform.version, 10) < 10 ? '' : name,
Object.keys(config).map(key => `${key}=${config[key]}`).join(', ')
);
}

@@ -7,2 +7,4 @@ var webpack = require('webpack');

module.exports = {
debug: true,
devtool: '#inline-source-map',
entry: {

@@ -9,0 +11,0 @@ demo0: ['babel-core/polyfill', './demos/demo0/index.jsx']

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

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