react-instagram-embed
Advanced tools
Comparing version 1.4.0 to 1.4.1
@@ -1,11 +0,13 @@ | ||
function _instanceof(left, right) { if (right != null && typeof Symbol !== "undefined" && right[Symbol.hasInstance]) { return right[Symbol.hasInstance](left); } else { return left instanceof right; } } | ||
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); } | ||
function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; } | ||
function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; } | ||
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; } | ||
function _extends() { _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; }; return _extends.apply(this, arguments); } | ||
function _classCallCheck(instance, Constructor) { if (!_instanceof(instance, Constructor)) { throw new TypeError("Cannot call a class as a function"); } } | ||
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; var ownKeys = Object.keys(source); if (typeof Object.getOwnPropertySymbols === 'function') { ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function (sym) { return Object.getOwnPropertyDescriptor(source, sym).enumerable; })); } ownKeys.forEach(function (key) { _defineProperty(target, key, source[key]); }); } return target; } | ||
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a 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); } } | ||
@@ -28,3 +30,2 @@ | ||
import React, { Component } from 'react'; | ||
import jsonp from 'jsonp-p'; | ||
import qs from 'query-string'; | ||
@@ -40,3 +41,3 @@ | ||
var _temp, _this2; | ||
var _this2; | ||
@@ -49,5 +50,13 @@ _classCallCheck(this, InstagramEmbed); | ||
return _possibleConstructorReturn(_this2, (_temp = _this2 = _possibleConstructorReturn(this, (_getPrototypeOf2 = _getPrototypeOf(InstagramEmbed)).call.apply(_getPrototypeOf2, [this].concat(_args))), _defineProperty(_assertThisInitialized(_assertThisInitialized(_this2)), "jsonp", void 0), _defineProperty(_assertThisInitialized(_assertThisInitialized(_this2)), "_timer", void 0), _defineProperty(_assertThisInitialized(_assertThisInitialized(_this2)), "state", { | ||
_this2 = _possibleConstructorReturn(this, (_getPrototypeOf2 = _getPrototypeOf(InstagramEmbed)).call.apply(_getPrototypeOf2, [this].concat(_args))); | ||
_defineProperty(_assertThisInitialized(_assertThisInitialized(_this2)), "request", void 0); | ||
_defineProperty(_assertThisInitialized(_assertThisInitialized(_this2)), "_timer", void 0); | ||
_defineProperty(_assertThisInitialized(_assertThisInitialized(_this2)), "state", { | ||
__html: null | ||
}), _defineProperty(_assertThisInitialized(_assertThisInitialized(_this2)), "handleFetchSuccess", function (response) { | ||
}); | ||
_defineProperty(_assertThisInitialized(_assertThisInitialized(_this2)), "handleFetchSuccess", function (response) { | ||
_this2.props.onSuccess && _this2.props.onSuccess(response); | ||
@@ -61,3 +70,5 @@ | ||
}); | ||
}), _defineProperty(_assertThisInitialized(_assertThisInitialized(_this2)), "handleFetchFailure", function () { | ||
}); | ||
_defineProperty(_assertThisInitialized(_assertThisInitialized(_this2)), "handleFetchFailure", function () { | ||
var _this2$props; | ||
@@ -67,7 +78,35 @@ | ||
_this2.props.onFailure && (_this2$props = _this2.props).onFailure.apply(_this2$props, arguments); | ||
}), _defineProperty(_assertThisInitialized(_assertThisInitialized(_this2)), "cancel", function () { | ||
if (_this2.jsonp) { | ||
_this2.jsonp.cancel(); | ||
}); | ||
_defineProperty(_assertThisInitialized(_assertThisInitialized(_this2)), "cancel", function () { | ||
if (_this2.request) { | ||
_this2.request.cancel(); | ||
} | ||
}), _temp)); | ||
}); | ||
_defineProperty(_assertThisInitialized(_assertThisInitialized(_this2)), "createRequestPromise", function (url) { | ||
for (var _len2 = arguments.length, opts = new Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) { | ||
opts[_key2 - 1] = arguments[_key2]; | ||
} | ||
var request = {}; | ||
request.promise = new Promise(function (resolve, reject) { | ||
var promise = fetch(url, _objectSpread({}, opts)).then(function (response) { | ||
return response.json(); | ||
}).then(function (json) { | ||
return resolve(json); | ||
}).catch(function (err) { | ||
return reject(err); | ||
}); | ||
request.cancel = function () { | ||
return reject(new Error('Cancelled')); | ||
}; | ||
return promise; | ||
}); | ||
return request; | ||
}); | ||
return _this2; | ||
} | ||
@@ -102,3 +141,3 @@ | ||
if (prevProps.url !== url || prevProps.hideCaption !== hideCaption || prevProps.maxWidth !== maxWidth || prevProps.containerTagName !== containerTagName) { | ||
this.jsonp.cancel(); | ||
this.request.cancel(); | ||
this.fetchEmbed(this.getQueryParams(this.props)); | ||
@@ -196,5 +235,5 @@ } | ||
value: function fetchEmbed(queryParams) { | ||
this.jsonp = jsonp("https://api.instagram.com/oembed/?".concat(queryParams)); | ||
this.request = this.createRequestPromise("https://api.instagram.com/oembed/?".concat(queryParams)); | ||
this.props.onLoading && this.props.onLoading(); | ||
this.jsonp.promise.then(this.handleFetchSuccess).catch(this.handleFetchFailure); | ||
this.request.promise.then(this.handleFetchSuccess).catch(this.handleFetchFailure); | ||
} | ||
@@ -201,0 +240,0 @@ }, { |
@@ -10,4 +10,2 @@ "use strict"; | ||
var _jsonpP = _interopRequireDefault(require("jsonp-p")); | ||
var _queryString = _interopRequireDefault(require("query-string")); | ||
@@ -19,12 +17,14 @@ | ||
function _instanceof(left, right) { if (right != null && typeof Symbol !== "undefined" && right[Symbol.hasInstance]) { return right[Symbol.hasInstance](left); } else { return left instanceof right; } } | ||
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); } | ||
function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; } | ||
function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; } | ||
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; } | ||
function _extends() { _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; }; return _extends.apply(this, arguments); } | ||
function _classCallCheck(instance, Constructor) { if (!_instanceof(instance, Constructor)) { throw new TypeError("Cannot call a class as a function"); } } | ||
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; var ownKeys = Object.keys(source); if (typeof Object.getOwnPropertySymbols === 'function') { ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function (sym) { return Object.getOwnPropertyDescriptor(source, sym).enumerable; })); } ownKeys.forEach(function (key) { _defineProperty(target, key, source[key]); }); } return target; } | ||
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a 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); } } | ||
@@ -54,3 +54,3 @@ | ||
var _temp, _this2; | ||
var _this2; | ||
@@ -63,5 +63,13 @@ _classCallCheck(this, InstagramEmbed); | ||
return _possibleConstructorReturn(_this2, (_temp = _this2 = _possibleConstructorReturn(this, (_getPrototypeOf2 = _getPrototypeOf(InstagramEmbed)).call.apply(_getPrototypeOf2, [this].concat(_args))), _defineProperty(_assertThisInitialized(_assertThisInitialized(_this2)), "jsonp", void 0), _defineProperty(_assertThisInitialized(_assertThisInitialized(_this2)), "_timer", void 0), _defineProperty(_assertThisInitialized(_assertThisInitialized(_this2)), "state", { | ||
_this2 = _possibleConstructorReturn(this, (_getPrototypeOf2 = _getPrototypeOf(InstagramEmbed)).call.apply(_getPrototypeOf2, [this].concat(_args))); | ||
_defineProperty(_assertThisInitialized(_assertThisInitialized(_this2)), "request", void 0); | ||
_defineProperty(_assertThisInitialized(_assertThisInitialized(_this2)), "_timer", void 0); | ||
_defineProperty(_assertThisInitialized(_assertThisInitialized(_this2)), "state", { | ||
__html: null | ||
}), _defineProperty(_assertThisInitialized(_assertThisInitialized(_this2)), "handleFetchSuccess", function (response) { | ||
}); | ||
_defineProperty(_assertThisInitialized(_assertThisInitialized(_this2)), "handleFetchSuccess", function (response) { | ||
_this2.props.onSuccess && _this2.props.onSuccess(response); | ||
@@ -75,3 +83,5 @@ | ||
}); | ||
}), _defineProperty(_assertThisInitialized(_assertThisInitialized(_this2)), "handleFetchFailure", function () { | ||
}); | ||
_defineProperty(_assertThisInitialized(_assertThisInitialized(_this2)), "handleFetchFailure", function () { | ||
var _this2$props; | ||
@@ -81,7 +91,35 @@ | ||
_this2.props.onFailure && (_this2$props = _this2.props).onFailure.apply(_this2$props, arguments); | ||
}), _defineProperty(_assertThisInitialized(_assertThisInitialized(_this2)), "cancel", function () { | ||
if (_this2.jsonp) { | ||
_this2.jsonp.cancel(); | ||
}); | ||
_defineProperty(_assertThisInitialized(_assertThisInitialized(_this2)), "cancel", function () { | ||
if (_this2.request) { | ||
_this2.request.cancel(); | ||
} | ||
}), _temp)); | ||
}); | ||
_defineProperty(_assertThisInitialized(_assertThisInitialized(_this2)), "createRequestPromise", function (url) { | ||
for (var _len2 = arguments.length, opts = new Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) { | ||
opts[_key2 - 1] = arguments[_key2]; | ||
} | ||
var request = {}; | ||
request.promise = new Promise(function (resolve, reject) { | ||
var promise = fetch(url, _objectSpread({}, opts)).then(function (response) { | ||
return response.json(); | ||
}).then(function (json) { | ||
return resolve(json); | ||
}).catch(function (err) { | ||
return reject(err); | ||
}); | ||
request.cancel = function () { | ||
return reject(new Error('Cancelled')); | ||
}; | ||
return promise; | ||
}); | ||
return request; | ||
}); | ||
return _this2; | ||
} | ||
@@ -116,3 +154,3 @@ | ||
if (prevProps.url !== url || prevProps.hideCaption !== hideCaption || prevProps.maxWidth !== maxWidth || prevProps.containerTagName !== containerTagName) { | ||
this.jsonp.cancel(); | ||
this.request.cancel(); | ||
this.fetchEmbed(this.getQueryParams(this.props)); | ||
@@ -210,5 +248,5 @@ } | ||
value: function fetchEmbed(queryParams) { | ||
this.jsonp = (0, _jsonpP.default)("https://api.instagram.com/oembed/?".concat(queryParams)); | ||
this.request = this.createRequestPromise("https://api.instagram.com/oembed/?".concat(queryParams)); | ||
this.props.onLoading && this.props.onLoading(); | ||
this.jsonp.promise.then(this.handleFetchSuccess).catch(this.handleFetchFailure); | ||
this.request.promise.then(this.handleFetchSuccess).catch(this.handleFetchFailure); | ||
} | ||
@@ -215,0 +253,0 @@ }, { |
{ | ||
"name": "react-instagram-embed", | ||
"version": "1.4.0", | ||
"version": "1.4.1", | ||
"description": "React embedding Instagram posts component", | ||
@@ -61,20 +61,17 @@ "main": "lib/index.js", | ||
"dependencies": { | ||
"jsonp-p": "^2.0.0", | ||
"query-string": "^5.1.0" | ||
}, | ||
"devDependencies": { | ||
"@babel/cli": "^7.0.0-beta.49", | ||
"@babel/core": "^7.0.0-beta.49", | ||
"@babel/plugin-proposal-class-properties": "^7.0.0-beta.49", | ||
"@babel/plugin-proposal-object-rest-spread": "^7.0.0-beta.49", | ||
"@babel/plugin-transform-flow-strip-types": "^7.0.0-beta.49", | ||
"@babel/polyfill": "^7.0.0-beta.49", | ||
"@babel/preset-es2015": "^7.0.0-beta.49", | ||
"@babel/preset-es2016": "^7.0.0-beta.49", | ||
"@babel/preset-es2017": "^7.0.0-beta.49", | ||
"@babel/preset-react": "^7.0.0-beta.49", | ||
"@babel/register": "^7.0.0-beta.49", | ||
"@babel/cli": "^7.0.0", | ||
"@babel/core": "^7.0.0", | ||
"@babel/plugin-proposal-class-properties": "^7.0.0", | ||
"@babel/plugin-proposal-object-rest-spread": "^7.0.0", | ||
"@babel/plugin-transform-flow-strip-types": "^7.0.0", | ||
"@babel/polyfill": "^7.0.0", | ||
"@babel/preset-env": "^7.0.0", | ||
"@babel/preset-react": "^7.0.0", | ||
"@babel/register": "^7.0.0", | ||
"ava": "^1.0.0-beta.5.1", | ||
"babel-eslint": "^8.2.3", | ||
"babel-loader": "^8.0.0-beta.3", | ||
"babel-loader": "^8.0.4", | ||
"browser-env": "^3.2.5", | ||
@@ -81,0 +78,0 @@ "css-loader": "^0.28.11", |
# react-instagram-embed | ||
[![CircleCI][circleci-image]][circleci-url] | ||
[![Dependency Status][david-image]][david-url] | ||
[![Devdependency Status][david-dev-image]][david-dev-url] | ||
[![npm version][npm-image]][npm-url] | ||
@@ -64,7 +62,3 @@ [![License][license-image]][license-url] | ||
[circleci-url]: https://circleci.com/gh/sugarshin/react-instagram-embed/tree/master | ||
[david-image]: https://david-dm.org/sugarshin/react-instagram-embed.svg?style=flat-square | ||
[david-url]: https://david-dm.org/sugarshin/react-instagram-embed | ||
[david-dev-image]: https://david-dm.org/sugarshin/react-instagram-embed/dev-status.svg?style=flat-square | ||
[david-dev-url]: https://david-dm.org/sugarshin/react-instagram-embed#info=devDependencies | ||
[license-image]: https://img.shields.io/:license-mit-blue.svg?style=flat-square | ||
[license-url]: https://sugarshin.mit-license.org/ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Network access
Supply chain riskThis module accesses the network.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
29024
3
37
448
64
2
- Removedjsonp-p@^2.0.0
- Removeddebug@2.6.9(transitive)
- Removedjsonp@0.2.1(transitive)
- Removedjsonp-p@2.0.0(transitive)
- Removedms@2.0.0(transitive)