react-twitter-widgets
Advanced tools
Comparing version 1.10.0 to 1.11.0
191
es/index.js
@@ -1,14 +0,4 @@ | ||
import _regeneratorRuntime from "@babel/runtime/regenerator"; | ||
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } } | ||
function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; } | ||
import React, { useRef, useEffect, useState } from "react"; | ||
import { canUseDOM, twLoad, useShallowCompareMemoize, removeChildrenWithAttribute, twWidgetFactory, cloneShallow } from "./utils"; | ||
if (canUseDOM) { | ||
twLoad(); | ||
} | ||
import { canUseDOM, useShallowCompareMemoize, removeChildrenWithAttribute, twWidgetFactory, cloneShallow } from "./utils"; | ||
export { loadTwitterLibrary as eagerLoadTwitterLibrary } from "./utils"; | ||
var childDivIdentifyingAttribute = "twdiv"; | ||
@@ -48,90 +38,43 @@ | ||
if (ref.current) { | ||
var loadWidget = /*#__PURE__*/function () { | ||
var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee() { | ||
var childEl, wf, resultMaybe; | ||
return _regeneratorRuntime.wrap(function _callee$(_context) { | ||
while (1) { | ||
switch (_context.prev = _context.next) { | ||
case 0: | ||
if (!(!ref || !ref.current)) { | ||
_context.next = 2; | ||
break; | ||
} | ||
removeChildrenWithAttribute(ref.current, childDivIdentifyingAttribute); | ||
return _context.abrupt("return"); | ||
if (!ref || !ref.current) { | ||
return; | ||
} | ||
case 2: | ||
childEl = document.createElement("div"); | ||
childEl.setAttribute(childDivIdentifyingAttribute, "yes"); | ||
ref.current.appendChild(childEl); | ||
_context.prev = 5; | ||
_context.next = 8; | ||
return twWidgetFactory(); | ||
var childEl = document.createElement("div"); | ||
childEl.setAttribute(childDivIdentifyingAttribute, "yes"); | ||
ref.current.appendChild(childEl); | ||
twWidgetFactory().then(function (wf) { | ||
// primaryArg (possibly an object) and options must be cloned | ||
// since twitter mutates them (gah!). | ||
// There currently aren't any nested arrays or objects, so they | ||
// can be cloned in a shallow manner. | ||
return wf[factoryFunctionName](cloneShallow(primaryArg), childEl, cloneShallow(options)); | ||
}).then(function (resultMaybe) { | ||
// Twitter returns undefined if widget creation fails. | ||
// However, if deps are stale (isCanceled), suppress error (likely race condition). | ||
if (!resultMaybe && !isCanceled) { | ||
throw new Error("Twitter could not create widget. If it is a Timeline or " + "Tweet, ensure the screenName/tweetId exists."); | ||
} | ||
case 8: | ||
wf = _context.sent; | ||
_context.next = 11; | ||
return wf[factoryFunctionName](cloneShallow(primaryArg), childEl, cloneShallow(options)); | ||
if (!ref || !ref.current) { | ||
return; | ||
} | ||
case 11: | ||
resultMaybe = _context.sent; | ||
if (isCanceled) { | ||
if (childEl) { | ||
childEl.remove(); | ||
} | ||
if (!(!resultMaybe && !isCanceled)) { | ||
_context.next = 14; | ||
break; | ||
} | ||
return; | ||
} | ||
throw new Error("Twitter could not create widget. If it is a Timeline or " + "Tweet, ensure the screenName/tweetId exists."); | ||
case 14: | ||
_context.next = 21; | ||
break; | ||
case 16: | ||
_context.prev = 16; | ||
_context.t0 = _context["catch"](5); | ||
console.error(_context.t0); | ||
setError(_context.t0); | ||
return _context.abrupt("return"); | ||
case 21: | ||
if (!(!ref || !ref.current)) { | ||
_context.next = 23; | ||
break; | ||
} | ||
return _context.abrupt("return"); | ||
case 23: | ||
if (!isCanceled) { | ||
_context.next = 26; | ||
break; | ||
} | ||
if (childEl) { | ||
childEl.remove(); | ||
} | ||
return _context.abrupt("return"); | ||
case 26: | ||
if (onLoad) { | ||
onLoad(); | ||
} | ||
case 27: | ||
case "end": | ||
return _context.stop(); | ||
} | ||
} | ||
}, _callee, null, [[5, 16]]); | ||
})); | ||
return function loadWidget() { | ||
return _ref.apply(this, arguments); | ||
}; | ||
}(); | ||
removeChildrenWithAttribute(ref.current, childDivIdentifyingAttribute); | ||
loadWidget(); | ||
if (onLoad) { | ||
onLoad(); | ||
} | ||
})["catch"](function (e) { | ||
console.error(e); | ||
setError(e); | ||
}); | ||
} | ||
@@ -149,7 +92,7 @@ | ||
export var Follow = function Follow(_ref2) { | ||
var username = _ref2.username, | ||
options = _ref2.options, | ||
onLoad = _ref2.onLoad, | ||
renderError = _ref2.renderError; | ||
export var Follow = function Follow(_ref) { | ||
var username = _ref.username, | ||
options = _ref.options, | ||
onLoad = _ref.onLoad, | ||
renderError = _ref.renderError; | ||
@@ -164,7 +107,7 @@ var _useTwitterWidget = useTwitterWidget("createFollowButton", username, options, onLoad), | ||
}; | ||
export var Hashtag = function Hashtag(_ref3) { | ||
var hashtag = _ref3.hashtag, | ||
options = _ref3.options, | ||
onLoad = _ref3.onLoad, | ||
renderError = _ref3.renderError; | ||
export var Hashtag = function Hashtag(_ref2) { | ||
var hashtag = _ref2.hashtag, | ||
options = _ref2.options, | ||
onLoad = _ref2.onLoad, | ||
renderError = _ref2.renderError; | ||
@@ -179,7 +122,7 @@ var _useTwitterWidget2 = useTwitterWidget("createHashtagButton", hashtag, options, onLoad), | ||
}; | ||
export var Mention = function Mention(_ref4) { | ||
var username = _ref4.username, | ||
options = _ref4.options, | ||
onLoad = _ref4.onLoad, | ||
renderError = _ref4.renderError; | ||
export var Mention = function Mention(_ref3) { | ||
var username = _ref3.username, | ||
options = _ref3.options, | ||
onLoad = _ref3.onLoad, | ||
renderError = _ref3.renderError; | ||
@@ -194,7 +137,7 @@ var _useTwitterWidget3 = useTwitterWidget("createMentionButton", username, options, onLoad), | ||
}; | ||
export var Share = function Share(_ref5) { | ||
var url = _ref5.url, | ||
options = _ref5.options, | ||
onLoad = _ref5.onLoad, | ||
renderError = _ref5.renderError; | ||
export var Share = function Share(_ref4) { | ||
var url = _ref4.url, | ||
options = _ref4.options, | ||
onLoad = _ref4.onLoad, | ||
renderError = _ref4.renderError; | ||
@@ -209,7 +152,7 @@ var _useTwitterWidget4 = useTwitterWidget("createShareButton", url, options, onLoad), | ||
}; | ||
export var Timeline = function Timeline(_ref6) { | ||
var dataSource = _ref6.dataSource, | ||
options = _ref6.options, | ||
onLoad = _ref6.onLoad, | ||
renderError = _ref6.renderError; | ||
export var Timeline = function Timeline(_ref5) { | ||
var dataSource = _ref5.dataSource, | ||
options = _ref5.options, | ||
onLoad = _ref5.onLoad, | ||
renderError = _ref5.renderError; | ||
@@ -224,7 +167,7 @@ var _useTwitterWidget5 = useTwitterWidget("createTimeline", dataSource, options, onLoad), | ||
}; | ||
export var Tweet = function Tweet(_ref7) { | ||
var tweetId = _ref7.tweetId, | ||
options = _ref7.options, | ||
onLoad = _ref7.onLoad, | ||
renderError = _ref7.renderError; | ||
export var Tweet = function Tweet(_ref6) { | ||
var tweetId = _ref6.tweetId, | ||
options = _ref6.options, | ||
onLoad = _ref6.onLoad, | ||
renderError = _ref6.renderError; | ||
@@ -231,0 +174,0 @@ var _useTwitterWidget6 = useTwitterWidget("createTweet", tweetId, options, onLoad), |
@@ -1,3 +0,1 @@ | ||
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); } | ||
import loadjs from "loadjs"; | ||
@@ -9,4 +7,6 @@ import { useRef } from "react"; | ||
export var canUseDOM = !!(typeof window !== "undefined" && window.document && window.document.createElement); | ||
export function twLoad() { | ||
loadjs(twScriptUrl, twScriptName); | ||
export function loadTwitterLibrary() { | ||
if (!loadjs.isDefined(twScriptName)) { | ||
loadjs(twScriptUrl, twScriptName); | ||
} | ||
} | ||
@@ -19,2 +19,3 @@ export function twWidgetFactory() { | ||
loadTwitterLibrary(); | ||
loadjs.ready(twScriptName, { | ||
@@ -88,3 +89,3 @@ success: function success() { | ||
export function cloneShallow(value) { | ||
return typeof value === "object" ? _extends({}, value) : value; | ||
return typeof value === "object" ? Object.assign({}, value) : value; | ||
} |
193
lib/index.js
"use strict"; | ||
exports.__esModule = true; | ||
exports.Tweet = exports.Timeline = exports.Share = exports.Mention = exports.Hashtag = exports.Follow = void 0; | ||
exports.Tweet = exports.Timeline = exports.Share = exports.Mention = exports.Hashtag = exports.Follow = exports.eagerLoadTwitterLibrary = void 0; | ||
var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator")); | ||
var _react = _interopRequireWildcard(require("react")); | ||
@@ -12,2 +10,4 @@ | ||
exports.eagerLoadTwitterLibrary = _utils.loadTwitterLibrary; | ||
function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function _getRequireWildcardCache() { return cache; }; return cache; } | ||
@@ -17,12 +17,2 @@ | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; } | ||
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } } | ||
function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; } | ||
if (_utils.canUseDOM) { | ||
(0, _utils.twLoad)(); | ||
} | ||
var childDivIdentifyingAttribute = "twdiv"; | ||
@@ -62,90 +52,43 @@ | ||
if (ref.current) { | ||
var loadWidget = /*#__PURE__*/function () { | ||
var _ref = _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee() { | ||
var childEl, wf, resultMaybe; | ||
return _regenerator["default"].wrap(function _callee$(_context) { | ||
while (1) { | ||
switch (_context.prev = _context.next) { | ||
case 0: | ||
if (!(!ref || !ref.current)) { | ||
_context.next = 2; | ||
break; | ||
} | ||
(0, _utils.removeChildrenWithAttribute)(ref.current, childDivIdentifyingAttribute); | ||
return _context.abrupt("return"); | ||
if (!ref || !ref.current) { | ||
return; | ||
} | ||
case 2: | ||
childEl = document.createElement("div"); | ||
childEl.setAttribute(childDivIdentifyingAttribute, "yes"); | ||
ref.current.appendChild(childEl); | ||
_context.prev = 5; | ||
_context.next = 8; | ||
return (0, _utils.twWidgetFactory)(); | ||
var childEl = document.createElement("div"); | ||
childEl.setAttribute(childDivIdentifyingAttribute, "yes"); | ||
ref.current.appendChild(childEl); | ||
(0, _utils.twWidgetFactory)().then(function (wf) { | ||
// primaryArg (possibly an object) and options must be cloned | ||
// since twitter mutates them (gah!). | ||
// There currently aren't any nested arrays or objects, so they | ||
// can be cloned in a shallow manner. | ||
return wf[factoryFunctionName]((0, _utils.cloneShallow)(primaryArg), childEl, (0, _utils.cloneShallow)(options)); | ||
}).then(function (resultMaybe) { | ||
// Twitter returns undefined if widget creation fails. | ||
// However, if deps are stale (isCanceled), suppress error (likely race condition). | ||
if (!resultMaybe && !isCanceled) { | ||
throw new Error("Twitter could not create widget. If it is a Timeline or " + "Tweet, ensure the screenName/tweetId exists."); | ||
} | ||
case 8: | ||
wf = _context.sent; | ||
_context.next = 11; | ||
return wf[factoryFunctionName]((0, _utils.cloneShallow)(primaryArg), childEl, (0, _utils.cloneShallow)(options)); | ||
if (!ref || !ref.current) { | ||
return; | ||
} | ||
case 11: | ||
resultMaybe = _context.sent; | ||
if (isCanceled) { | ||
if (childEl) { | ||
childEl.remove(); | ||
} | ||
if (!(!resultMaybe && !isCanceled)) { | ||
_context.next = 14; | ||
break; | ||
} | ||
return; | ||
} | ||
throw new Error("Twitter could not create widget. If it is a Timeline or " + "Tweet, ensure the screenName/tweetId exists."); | ||
case 14: | ||
_context.next = 21; | ||
break; | ||
case 16: | ||
_context.prev = 16; | ||
_context.t0 = _context["catch"](5); | ||
console.error(_context.t0); | ||
setError(_context.t0); | ||
return _context.abrupt("return"); | ||
case 21: | ||
if (!(!ref || !ref.current)) { | ||
_context.next = 23; | ||
break; | ||
} | ||
return _context.abrupt("return"); | ||
case 23: | ||
if (!isCanceled) { | ||
_context.next = 26; | ||
break; | ||
} | ||
if (childEl) { | ||
childEl.remove(); | ||
} | ||
return _context.abrupt("return"); | ||
case 26: | ||
if (onLoad) { | ||
onLoad(); | ||
} | ||
case 27: | ||
case "end": | ||
return _context.stop(); | ||
} | ||
} | ||
}, _callee, null, [[5, 16]]); | ||
})); | ||
return function loadWidget() { | ||
return _ref.apply(this, arguments); | ||
}; | ||
}(); | ||
(0, _utils.removeChildrenWithAttribute)(ref.current, childDivIdentifyingAttribute); | ||
loadWidget(); | ||
if (onLoad) { | ||
onLoad(); | ||
} | ||
})["catch"](function (e) { | ||
console.error(e); | ||
setError(e); | ||
}); | ||
} | ||
@@ -163,7 +106,7 @@ | ||
var Follow = function Follow(_ref2) { | ||
var username = _ref2.username, | ||
options = _ref2.options, | ||
onLoad = _ref2.onLoad, | ||
renderError = _ref2.renderError; | ||
var Follow = function Follow(_ref) { | ||
var username = _ref.username, | ||
options = _ref.options, | ||
onLoad = _ref.onLoad, | ||
renderError = _ref.renderError; | ||
@@ -181,7 +124,7 @@ var _useTwitterWidget = useTwitterWidget("createFollowButton", username, options, onLoad), | ||
var Hashtag = function Hashtag(_ref3) { | ||
var hashtag = _ref3.hashtag, | ||
options = _ref3.options, | ||
onLoad = _ref3.onLoad, | ||
renderError = _ref3.renderError; | ||
var Hashtag = function Hashtag(_ref2) { | ||
var hashtag = _ref2.hashtag, | ||
options = _ref2.options, | ||
onLoad = _ref2.onLoad, | ||
renderError = _ref2.renderError; | ||
@@ -199,7 +142,7 @@ var _useTwitterWidget2 = useTwitterWidget("createHashtagButton", hashtag, options, onLoad), | ||
var Mention = function Mention(_ref4) { | ||
var username = _ref4.username, | ||
options = _ref4.options, | ||
onLoad = _ref4.onLoad, | ||
renderError = _ref4.renderError; | ||
var Mention = function Mention(_ref3) { | ||
var username = _ref3.username, | ||
options = _ref3.options, | ||
onLoad = _ref3.onLoad, | ||
renderError = _ref3.renderError; | ||
@@ -217,7 +160,7 @@ var _useTwitterWidget3 = useTwitterWidget("createMentionButton", username, options, onLoad), | ||
var Share = function Share(_ref5) { | ||
var url = _ref5.url, | ||
options = _ref5.options, | ||
onLoad = _ref5.onLoad, | ||
renderError = _ref5.renderError; | ||
var Share = function Share(_ref4) { | ||
var url = _ref4.url, | ||
options = _ref4.options, | ||
onLoad = _ref4.onLoad, | ||
renderError = _ref4.renderError; | ||
@@ -235,7 +178,7 @@ var _useTwitterWidget4 = useTwitterWidget("createShareButton", url, options, onLoad), | ||
var Timeline = function Timeline(_ref6) { | ||
var dataSource = _ref6.dataSource, | ||
options = _ref6.options, | ||
onLoad = _ref6.onLoad, | ||
renderError = _ref6.renderError; | ||
var Timeline = function Timeline(_ref5) { | ||
var dataSource = _ref5.dataSource, | ||
options = _ref5.options, | ||
onLoad = _ref5.onLoad, | ||
renderError = _ref5.renderError; | ||
@@ -253,7 +196,7 @@ var _useTwitterWidget5 = useTwitterWidget("createTimeline", dataSource, options, onLoad), | ||
var Tweet = function Tweet(_ref7) { | ||
var tweetId = _ref7.tweetId, | ||
options = _ref7.options, | ||
onLoad = _ref7.onLoad, | ||
renderError = _ref7.renderError; | ||
var Tweet = function Tweet(_ref6) { | ||
var tweetId = _ref6.tweetId, | ||
options = _ref6.options, | ||
onLoad = _ref6.onLoad, | ||
renderError = _ref6.renderError; | ||
@@ -260,0 +203,0 @@ var _useTwitterWidget6 = useTwitterWidget("createTweet", tweetId, options, onLoad), |
"use strict"; | ||
exports.__esModule = true; | ||
exports.twLoad = twLoad; | ||
exports.loadTwitterLibrary = loadTwitterLibrary; | ||
exports.twWidgetFactory = twWidgetFactory; | ||
@@ -17,4 +17,2 @@ exports.removeChildrenWithAttribute = removeChildrenWithAttribute; | ||
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); } | ||
var twScriptUrl = "https://platform.twitter.com/widgets.js"; | ||
@@ -26,4 +24,6 @@ var twScriptWindowFieldName = "twttr"; | ||
function twLoad() { | ||
(0, _loadjs["default"])(twScriptUrl, twScriptName); | ||
function loadTwitterLibrary() { | ||
if (!_loadjs["default"].isDefined(twScriptName)) { | ||
(0, _loadjs["default"])(twScriptUrl, twScriptName); | ||
} | ||
} | ||
@@ -37,2 +37,4 @@ | ||
loadTwitterLibrary(); | ||
_loadjs["default"].ready(twScriptName, { | ||
@@ -108,3 +110,3 @@ success: function success() { | ||
function cloneShallow(value) { | ||
return typeof value === "object" ? _extends({}, value) : value; | ||
return typeof value === "object" ? Object.assign({}, value) : value; | ||
} |
{ | ||
"name": "react-twitter-widgets", | ||
"version": "1.10.0", | ||
"version": "1.11.0", | ||
"description": "Twitter widgets as React components", | ||
@@ -37,3 +37,3 @@ "author": "Andrew Suzuki", | ||
"peerDependencies": { | ||
"react": "^16.8.0 || ^17" | ||
"react": "^16.8.0 || ^17 || ^18" | ||
}, | ||
@@ -40,0 +40,0 @@ "scripts": { |
@@ -54,3 +54,3 @@ # react-twitter-widgets | ||
**`Follow`** and **`Mention`** require a `username` prop. NOTE that the Twitter | ||
documentation now refers to this as *screenName*. | ||
documentation now refers to this as _screenName_. | ||
@@ -73,6 +73,15 @@ **`Hashtag`** requires a `hashtag` prop. | ||
### Lazy vs. Eager Loading | ||
By default, the remote Twitter library will be lazy-loaded when the first widget renders. To instead load it eagerly, call `eagerLoadTwitterLibrary`. | ||
```js | ||
import { eagerLoadTwitterLibrary } from "react-twitter-widgets"; | ||
eagerLoadTwitterLibrary(); | ||
``` | ||
## Further Information | ||
* This library loads the remote *Twitter for Websites* script. | ||
* Twitter widgets are only loaded in the browser. A blank div will be rendered during SSR. | ||
- This library loads the remote _Twitter for Websites_ library. | ||
- Twitter widgets are only loaded in the browser. A blank div will be rendered during SSR. | ||
@@ -89,3 +98,3 @@ ## Contributing | ||
* Andrew Suzuki - @andrewsuzuki - [andrewsuzuki.com](http://andrewsuzuki.com) | ||
- Andrew Suzuki - @andrewsuzuki - [andrewsuzuki.com](http://andrewsuzuki.com) | ||
@@ -92,0 +101,0 @@ ## License |
/*! | ||
* react-twitter-widgets v1.10.0 - https://github.com/andrewsuzuki/react-twitter-widgets | ||
* react-twitter-widgets v1.11.0 - https://github.com/andrewsuzuki/react-twitter-widgets | ||
* MIT Licensed | ||
@@ -98,3 +98,3 @@ */ | ||
/******/ // Load entry module and return exports | ||
/******/ return __webpack_require__(__webpack_require__.s = 3); | ||
/******/ return __webpack_require__(__webpack_require__.s = 2); | ||
/******/ }) | ||
@@ -112,9 +112,2 @@ /************************************************************************/ | ||
module.exports = __webpack_require__(4); | ||
/***/ }), | ||
/* 2 */ | ||
/***/ (function(module, exports, __webpack_require__) { | ||
var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;(function(root, factory) { | ||
@@ -438,745 +431,10 @@ if (true) { | ||
/***/ }), | ||
/* 3 */ | ||
/* 2 */ | ||
/***/ (function(module, exports, __webpack_require__) { | ||
module.exports = __webpack_require__(5); | ||
module.exports = __webpack_require__(3); | ||
/***/ }), | ||
/* 4 */ | ||
/***/ (function(module, exports, __webpack_require__) { | ||
/** | ||
* Copyright (c) 2014-present, Facebook, Inc. | ||
* | ||
* This source code is licensed under the MIT license found in the | ||
* LICENSE file in the root directory of this source tree. | ||
*/ | ||
var runtime = (function (exports) { | ||
"use strict"; | ||
var Op = Object.prototype; | ||
var hasOwn = Op.hasOwnProperty; | ||
var undefined; // More compressible than void 0. | ||
var $Symbol = typeof Symbol === "function" ? Symbol : {}; | ||
var iteratorSymbol = $Symbol.iterator || "@@iterator"; | ||
var asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator"; | ||
var toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag"; | ||
function wrap(innerFn, outerFn, self, tryLocsList) { | ||
// If outerFn provided and outerFn.prototype is a Generator, then outerFn.prototype instanceof Generator. | ||
var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator; | ||
var generator = Object.create(protoGenerator.prototype); | ||
var context = new Context(tryLocsList || []); | ||
// The ._invoke method unifies the implementations of the .next, | ||
// .throw, and .return methods. | ||
generator._invoke = makeInvokeMethod(innerFn, self, context); | ||
return generator; | ||
} | ||
exports.wrap = wrap; | ||
// Try/catch helper to minimize deoptimizations. Returns a completion | ||
// record like context.tryEntries[i].completion. This interface could | ||
// have been (and was previously) designed to take a closure to be | ||
// invoked without arguments, but in all the cases we care about we | ||
// already have an existing method we want to call, so there's no need | ||
// to create a new function object. We can even get away with assuming | ||
// the method takes exactly one argument, since that happens to be true | ||
// in every case, so we don't have to touch the arguments object. The | ||
// only additional allocation required is the completion record, which | ||
// has a stable shape and so hopefully should be cheap to allocate. | ||
function tryCatch(fn, obj, arg) { | ||
try { | ||
return { type: "normal", arg: fn.call(obj, arg) }; | ||
} catch (err) { | ||
return { type: "throw", arg: err }; | ||
} | ||
} | ||
var GenStateSuspendedStart = "suspendedStart"; | ||
var GenStateSuspendedYield = "suspendedYield"; | ||
var GenStateExecuting = "executing"; | ||
var GenStateCompleted = "completed"; | ||
// Returning this object from the innerFn has the same effect as | ||
// breaking out of the dispatch switch statement. | ||
var ContinueSentinel = {}; | ||
// Dummy constructor functions that we use as the .constructor and | ||
// .constructor.prototype properties for functions that return Generator | ||
// objects. For full spec compliance, you may wish to configure your | ||
// minifier not to mangle the names of these two functions. | ||
function Generator() {} | ||
function GeneratorFunction() {} | ||
function GeneratorFunctionPrototype() {} | ||
// This is a polyfill for %IteratorPrototype% for environments that | ||
// don't natively support it. | ||
var IteratorPrototype = {}; | ||
IteratorPrototype[iteratorSymbol] = function () { | ||
return this; | ||
}; | ||
var getProto = Object.getPrototypeOf; | ||
var NativeIteratorPrototype = getProto && getProto(getProto(values([]))); | ||
if (NativeIteratorPrototype && | ||
NativeIteratorPrototype !== Op && | ||
hasOwn.call(NativeIteratorPrototype, iteratorSymbol)) { | ||
// This environment has a native %IteratorPrototype%; use it instead | ||
// of the polyfill. | ||
IteratorPrototype = NativeIteratorPrototype; | ||
} | ||
var Gp = GeneratorFunctionPrototype.prototype = | ||
Generator.prototype = Object.create(IteratorPrototype); | ||
GeneratorFunction.prototype = Gp.constructor = GeneratorFunctionPrototype; | ||
GeneratorFunctionPrototype.constructor = GeneratorFunction; | ||
GeneratorFunctionPrototype[toStringTagSymbol] = | ||
GeneratorFunction.displayName = "GeneratorFunction"; | ||
// Helper for defining the .next, .throw, and .return methods of the | ||
// Iterator interface in terms of a single ._invoke method. | ||
function defineIteratorMethods(prototype) { | ||
["next", "throw", "return"].forEach(function(method) { | ||
prototype[method] = function(arg) { | ||
return this._invoke(method, arg); | ||
}; | ||
}); | ||
} | ||
exports.isGeneratorFunction = function(genFun) { | ||
var ctor = typeof genFun === "function" && genFun.constructor; | ||
return ctor | ||
? ctor === GeneratorFunction || | ||
// For the native GeneratorFunction constructor, the best we can | ||
// do is to check its .name property. | ||
(ctor.displayName || ctor.name) === "GeneratorFunction" | ||
: false; | ||
}; | ||
exports.mark = function(genFun) { | ||
if (Object.setPrototypeOf) { | ||
Object.setPrototypeOf(genFun, GeneratorFunctionPrototype); | ||
} else { | ||
genFun.__proto__ = GeneratorFunctionPrototype; | ||
if (!(toStringTagSymbol in genFun)) { | ||
genFun[toStringTagSymbol] = "GeneratorFunction"; | ||
} | ||
} | ||
genFun.prototype = Object.create(Gp); | ||
return genFun; | ||
}; | ||
// Within the body of any async function, `await x` is transformed to | ||
// `yield regeneratorRuntime.awrap(x)`, so that the runtime can test | ||
// `hasOwn.call(value, "__await")` to determine if the yielded value is | ||
// meant to be awaited. | ||
exports.awrap = function(arg) { | ||
return { __await: arg }; | ||
}; | ||
function AsyncIterator(generator, PromiseImpl) { | ||
function invoke(method, arg, resolve, reject) { | ||
var record = tryCatch(generator[method], generator, arg); | ||
if (record.type === "throw") { | ||
reject(record.arg); | ||
} else { | ||
var result = record.arg; | ||
var value = result.value; | ||
if (value && | ||
typeof value === "object" && | ||
hasOwn.call(value, "__await")) { | ||
return PromiseImpl.resolve(value.__await).then(function(value) { | ||
invoke("next", value, resolve, reject); | ||
}, function(err) { | ||
invoke("throw", err, resolve, reject); | ||
}); | ||
} | ||
return PromiseImpl.resolve(value).then(function(unwrapped) { | ||
// When a yielded Promise is resolved, its final value becomes | ||
// the .value of the Promise<{value,done}> result for the | ||
// current iteration. | ||
result.value = unwrapped; | ||
resolve(result); | ||
}, function(error) { | ||
// If a rejected Promise was yielded, throw the rejection back | ||
// into the async generator function so it can be handled there. | ||
return invoke("throw", error, resolve, reject); | ||
}); | ||
} | ||
} | ||
var previousPromise; | ||
function enqueue(method, arg) { | ||
function callInvokeWithMethodAndArg() { | ||
return new PromiseImpl(function(resolve, reject) { | ||
invoke(method, arg, resolve, reject); | ||
}); | ||
} | ||
return previousPromise = | ||
// If enqueue has been called before, then we want to wait until | ||
// all previous Promises have been resolved before calling invoke, | ||
// so that results are always delivered in the correct order. If | ||
// enqueue has not been called before, then it is important to | ||
// call invoke immediately, without waiting on a callback to fire, | ||
// so that the async generator function has the opportunity to do | ||
// any necessary setup in a predictable way. This predictability | ||
// is why the Promise constructor synchronously invokes its | ||
// executor callback, and why async functions synchronously | ||
// execute code before the first await. Since we implement simple | ||
// async functions in terms of async generators, it is especially | ||
// important to get this right, even though it requires care. | ||
previousPromise ? previousPromise.then( | ||
callInvokeWithMethodAndArg, | ||
// Avoid propagating failures to Promises returned by later | ||
// invocations of the iterator. | ||
callInvokeWithMethodAndArg | ||
) : callInvokeWithMethodAndArg(); | ||
} | ||
// Define the unified helper method that is used to implement .next, | ||
// .throw, and .return (see defineIteratorMethods). | ||
this._invoke = enqueue; | ||
} | ||
defineIteratorMethods(AsyncIterator.prototype); | ||
AsyncIterator.prototype[asyncIteratorSymbol] = function () { | ||
return this; | ||
}; | ||
exports.AsyncIterator = AsyncIterator; | ||
// Note that simple async functions are implemented on top of | ||
// AsyncIterator objects; they just return a Promise for the value of | ||
// the final result produced by the iterator. | ||
exports.async = function(innerFn, outerFn, self, tryLocsList, PromiseImpl) { | ||
if (PromiseImpl === void 0) PromiseImpl = Promise; | ||
var iter = new AsyncIterator( | ||
wrap(innerFn, outerFn, self, tryLocsList), | ||
PromiseImpl | ||
); | ||
return exports.isGeneratorFunction(outerFn) | ||
? iter // If outerFn is a generator, return the full iterator. | ||
: iter.next().then(function(result) { | ||
return result.done ? result.value : iter.next(); | ||
}); | ||
}; | ||
function makeInvokeMethod(innerFn, self, context) { | ||
var state = GenStateSuspendedStart; | ||
return function invoke(method, arg) { | ||
if (state === GenStateExecuting) { | ||
throw new Error("Generator is already running"); | ||
} | ||
if (state === GenStateCompleted) { | ||
if (method === "throw") { | ||
throw arg; | ||
} | ||
// Be forgiving, per 25.3.3.3.3 of the spec: | ||
// https://people.mozilla.org/~jorendorff/es6-draft.html#sec-generatorresume | ||
return doneResult(); | ||
} | ||
context.method = method; | ||
context.arg = arg; | ||
while (true) { | ||
var delegate = context.delegate; | ||
if (delegate) { | ||
var delegateResult = maybeInvokeDelegate(delegate, context); | ||
if (delegateResult) { | ||
if (delegateResult === ContinueSentinel) continue; | ||
return delegateResult; | ||
} | ||
} | ||
if (context.method === "next") { | ||
// Setting context._sent for legacy support of Babel's | ||
// function.sent implementation. | ||
context.sent = context._sent = context.arg; | ||
} else if (context.method === "throw") { | ||
if (state === GenStateSuspendedStart) { | ||
state = GenStateCompleted; | ||
throw context.arg; | ||
} | ||
context.dispatchException(context.arg); | ||
} else if (context.method === "return") { | ||
context.abrupt("return", context.arg); | ||
} | ||
state = GenStateExecuting; | ||
var record = tryCatch(innerFn, self, context); | ||
if (record.type === "normal") { | ||
// If an exception is thrown from innerFn, we leave state === | ||
// GenStateExecuting and loop back for another invocation. | ||
state = context.done | ||
? GenStateCompleted | ||
: GenStateSuspendedYield; | ||
if (record.arg === ContinueSentinel) { | ||
continue; | ||
} | ||
return { | ||
value: record.arg, | ||
done: context.done | ||
}; | ||
} else if (record.type === "throw") { | ||
state = GenStateCompleted; | ||
// Dispatch the exception by looping back around to the | ||
// context.dispatchException(context.arg) call above. | ||
context.method = "throw"; | ||
context.arg = record.arg; | ||
} | ||
} | ||
}; | ||
} | ||
// Call delegate.iterator[context.method](context.arg) and handle the | ||
// result, either by returning a { value, done } result from the | ||
// delegate iterator, or by modifying context.method and context.arg, | ||
// setting context.delegate to null, and returning the ContinueSentinel. | ||
function maybeInvokeDelegate(delegate, context) { | ||
var method = delegate.iterator[context.method]; | ||
if (method === undefined) { | ||
// A .throw or .return when the delegate iterator has no .throw | ||
// method always terminates the yield* loop. | ||
context.delegate = null; | ||
if (context.method === "throw") { | ||
// Note: ["return"] must be used for ES3 parsing compatibility. | ||
if (delegate.iterator["return"]) { | ||
// If the delegate iterator has a return method, give it a | ||
// chance to clean up. | ||
context.method = "return"; | ||
context.arg = undefined; | ||
maybeInvokeDelegate(delegate, context); | ||
if (context.method === "throw") { | ||
// If maybeInvokeDelegate(context) changed context.method from | ||
// "return" to "throw", let that override the TypeError below. | ||
return ContinueSentinel; | ||
} | ||
} | ||
context.method = "throw"; | ||
context.arg = new TypeError( | ||
"The iterator does not provide a 'throw' method"); | ||
} | ||
return ContinueSentinel; | ||
} | ||
var record = tryCatch(method, delegate.iterator, context.arg); | ||
if (record.type === "throw") { | ||
context.method = "throw"; | ||
context.arg = record.arg; | ||
context.delegate = null; | ||
return ContinueSentinel; | ||
} | ||
var info = record.arg; | ||
if (! info) { | ||
context.method = "throw"; | ||
context.arg = new TypeError("iterator result is not an object"); | ||
context.delegate = null; | ||
return ContinueSentinel; | ||
} | ||
if (info.done) { | ||
// Assign the result of the finished delegate to the temporary | ||
// variable specified by delegate.resultName (see delegateYield). | ||
context[delegate.resultName] = info.value; | ||
// Resume execution at the desired location (see delegateYield). | ||
context.next = delegate.nextLoc; | ||
// If context.method was "throw" but the delegate handled the | ||
// exception, let the outer generator proceed normally. If | ||
// context.method was "next", forget context.arg since it has been | ||
// "consumed" by the delegate iterator. If context.method was | ||
// "return", allow the original .return call to continue in the | ||
// outer generator. | ||
if (context.method !== "return") { | ||
context.method = "next"; | ||
context.arg = undefined; | ||
} | ||
} else { | ||
// Re-yield the result returned by the delegate method. | ||
return info; | ||
} | ||
// The delegate iterator is finished, so forget it and continue with | ||
// the outer generator. | ||
context.delegate = null; | ||
return ContinueSentinel; | ||
} | ||
// Define Generator.prototype.{next,throw,return} in terms of the | ||
// unified ._invoke helper method. | ||
defineIteratorMethods(Gp); | ||
Gp[toStringTagSymbol] = "Generator"; | ||
// A Generator should always return itself as the iterator object when the | ||
// @@iterator function is called on it. Some browsers' implementations of the | ||
// iterator prototype chain incorrectly implement this, causing the Generator | ||
// object to not be returned from this call. This ensures that doesn't happen. | ||
// See https://github.com/facebook/regenerator/issues/274 for more details. | ||
Gp[iteratorSymbol] = function() { | ||
return this; | ||
}; | ||
Gp.toString = function() { | ||
return "[object Generator]"; | ||
}; | ||
function pushTryEntry(locs) { | ||
var entry = { tryLoc: locs[0] }; | ||
if (1 in locs) { | ||
entry.catchLoc = locs[1]; | ||
} | ||
if (2 in locs) { | ||
entry.finallyLoc = locs[2]; | ||
entry.afterLoc = locs[3]; | ||
} | ||
this.tryEntries.push(entry); | ||
} | ||
function resetTryEntry(entry) { | ||
var record = entry.completion || {}; | ||
record.type = "normal"; | ||
delete record.arg; | ||
entry.completion = record; | ||
} | ||
function Context(tryLocsList) { | ||
// The root entry object (effectively a try statement without a catch | ||
// or a finally block) gives us a place to store values thrown from | ||
// locations where there is no enclosing try statement. | ||
this.tryEntries = [{ tryLoc: "root" }]; | ||
tryLocsList.forEach(pushTryEntry, this); | ||
this.reset(true); | ||
} | ||
exports.keys = function(object) { | ||
var keys = []; | ||
for (var key in object) { | ||
keys.push(key); | ||
} | ||
keys.reverse(); | ||
// Rather than returning an object with a next method, we keep | ||
// things simple and return the next function itself. | ||
return function next() { | ||
while (keys.length) { | ||
var key = keys.pop(); | ||
if (key in object) { | ||
next.value = key; | ||
next.done = false; | ||
return next; | ||
} | ||
} | ||
// To avoid creating an additional object, we just hang the .value | ||
// and .done properties off the next function object itself. This | ||
// also ensures that the minifier will not anonymize the function. | ||
next.done = true; | ||
return next; | ||
}; | ||
}; | ||
function values(iterable) { | ||
if (iterable) { | ||
var iteratorMethod = iterable[iteratorSymbol]; | ||
if (iteratorMethod) { | ||
return iteratorMethod.call(iterable); | ||
} | ||
if (typeof iterable.next === "function") { | ||
return iterable; | ||
} | ||
if (!isNaN(iterable.length)) { | ||
var i = -1, next = function next() { | ||
while (++i < iterable.length) { | ||
if (hasOwn.call(iterable, i)) { | ||
next.value = iterable[i]; | ||
next.done = false; | ||
return next; | ||
} | ||
} | ||
next.value = undefined; | ||
next.done = true; | ||
return next; | ||
}; | ||
return next.next = next; | ||
} | ||
} | ||
// Return an iterator with no values. | ||
return { next: doneResult }; | ||
} | ||
exports.values = values; | ||
function doneResult() { | ||
return { value: undefined, done: true }; | ||
} | ||
Context.prototype = { | ||
constructor: Context, | ||
reset: function(skipTempReset) { | ||
this.prev = 0; | ||
this.next = 0; | ||
// Resetting context._sent for legacy support of Babel's | ||
// function.sent implementation. | ||
this.sent = this._sent = undefined; | ||
this.done = false; | ||
this.delegate = null; | ||
this.method = "next"; | ||
this.arg = undefined; | ||
this.tryEntries.forEach(resetTryEntry); | ||
if (!skipTempReset) { | ||
for (var name in this) { | ||
// Not sure about the optimal order of these conditions: | ||
if (name.charAt(0) === "t" && | ||
hasOwn.call(this, name) && | ||
!isNaN(+name.slice(1))) { | ||
this[name] = undefined; | ||
} | ||
} | ||
} | ||
}, | ||
stop: function() { | ||
this.done = true; | ||
var rootEntry = this.tryEntries[0]; | ||
var rootRecord = rootEntry.completion; | ||
if (rootRecord.type === "throw") { | ||
throw rootRecord.arg; | ||
} | ||
return this.rval; | ||
}, | ||
dispatchException: function(exception) { | ||
if (this.done) { | ||
throw exception; | ||
} | ||
var context = this; | ||
function handle(loc, caught) { | ||
record.type = "throw"; | ||
record.arg = exception; | ||
context.next = loc; | ||
if (caught) { | ||
// If the dispatched exception was caught by a catch block, | ||
// then let that catch block handle the exception normally. | ||
context.method = "next"; | ||
context.arg = undefined; | ||
} | ||
return !! caught; | ||
} | ||
for (var i = this.tryEntries.length - 1; i >= 0; --i) { | ||
var entry = this.tryEntries[i]; | ||
var record = entry.completion; | ||
if (entry.tryLoc === "root") { | ||
// Exception thrown outside of any try block that could handle | ||
// it, so set the completion value of the entire function to | ||
// throw the exception. | ||
return handle("end"); | ||
} | ||
if (entry.tryLoc <= this.prev) { | ||
var hasCatch = hasOwn.call(entry, "catchLoc"); | ||
var hasFinally = hasOwn.call(entry, "finallyLoc"); | ||
if (hasCatch && hasFinally) { | ||
if (this.prev < entry.catchLoc) { | ||
return handle(entry.catchLoc, true); | ||
} else if (this.prev < entry.finallyLoc) { | ||
return handle(entry.finallyLoc); | ||
} | ||
} else if (hasCatch) { | ||
if (this.prev < entry.catchLoc) { | ||
return handle(entry.catchLoc, true); | ||
} | ||
} else if (hasFinally) { | ||
if (this.prev < entry.finallyLoc) { | ||
return handle(entry.finallyLoc); | ||
} | ||
} else { | ||
throw new Error("try statement without catch or finally"); | ||
} | ||
} | ||
} | ||
}, | ||
abrupt: function(type, arg) { | ||
for (var i = this.tryEntries.length - 1; i >= 0; --i) { | ||
var entry = this.tryEntries[i]; | ||
if (entry.tryLoc <= this.prev && | ||
hasOwn.call(entry, "finallyLoc") && | ||
this.prev < entry.finallyLoc) { | ||
var finallyEntry = entry; | ||
break; | ||
} | ||
} | ||
if (finallyEntry && | ||
(type === "break" || | ||
type === "continue") && | ||
finallyEntry.tryLoc <= arg && | ||
arg <= finallyEntry.finallyLoc) { | ||
// Ignore the finally entry if control is not jumping to a | ||
// location outside the try/catch block. | ||
finallyEntry = null; | ||
} | ||
var record = finallyEntry ? finallyEntry.completion : {}; | ||
record.type = type; | ||
record.arg = arg; | ||
if (finallyEntry) { | ||
this.method = "next"; | ||
this.next = finallyEntry.finallyLoc; | ||
return ContinueSentinel; | ||
} | ||
return this.complete(record); | ||
}, | ||
complete: function(record, afterLoc) { | ||
if (record.type === "throw") { | ||
throw record.arg; | ||
} | ||
if (record.type === "break" || | ||
record.type === "continue") { | ||
this.next = record.arg; | ||
} else if (record.type === "return") { | ||
this.rval = this.arg = record.arg; | ||
this.method = "return"; | ||
this.next = "end"; | ||
} else if (record.type === "normal" && afterLoc) { | ||
this.next = afterLoc; | ||
} | ||
return ContinueSentinel; | ||
}, | ||
finish: function(finallyLoc) { | ||
for (var i = this.tryEntries.length - 1; i >= 0; --i) { | ||
var entry = this.tryEntries[i]; | ||
if (entry.finallyLoc === finallyLoc) { | ||
this.complete(entry.completion, entry.afterLoc); | ||
resetTryEntry(entry); | ||
return ContinueSentinel; | ||
} | ||
} | ||
}, | ||
"catch": function(tryLoc) { | ||
for (var i = this.tryEntries.length - 1; i >= 0; --i) { | ||
var entry = this.tryEntries[i]; | ||
if (entry.tryLoc === tryLoc) { | ||
var record = entry.completion; | ||
if (record.type === "throw") { | ||
var thrown = record.arg; | ||
resetTryEntry(entry); | ||
} | ||
return thrown; | ||
} | ||
} | ||
// The context.catch method must only be called with a location | ||
// argument that corresponds to a known catch block. | ||
throw new Error("illegal catch attempt"); | ||
}, | ||
delegateYield: function(iterable, resultName, nextLoc) { | ||
this.delegate = { | ||
iterator: values(iterable), | ||
resultName: resultName, | ||
nextLoc: nextLoc | ||
}; | ||
if (this.method === "next") { | ||
// Deliberately forget the last sent value so that we don't | ||
// accidentally pass it on to the delegate. | ||
this.arg = undefined; | ||
} | ||
return ContinueSentinel; | ||
} | ||
}; | ||
// Regardless of whether this script is executing as a CommonJS module | ||
// or not, return the runtime object so that we can declare the variable | ||
// regeneratorRuntime in the outer scope, which allows this module to be | ||
// injected easily by `bin/regenerator --include-runtime script.js`. | ||
return exports; | ||
}( | ||
// If this script is executing as a CommonJS module, use module.exports | ||
// as the regeneratorRuntime namespace. Otherwise create a new empty | ||
// object. Either way, the resulting object will be used to initialize | ||
// the regeneratorRuntime variable at the top of this file. | ||
true ? module.exports : undefined | ||
)); | ||
try { | ||
regeneratorRuntime = runtime; | ||
} catch (accidentalStrictMode) { | ||
// This module should not be running in strict mode, so the above | ||
// assignment should always work unless something is misconfigured. Just | ||
// in case runtime.js accidentally runs in strict mode, we can escape | ||
// strict mode using a global Function call. This could conceivably fail | ||
// if a Content Security Policy forbids using Function, but in that case | ||
// the proper solution is to fix the accidental strict mode problem. If | ||
// you've misconfigured your bundler to force strict mode and applied a | ||
// CSP to forbid Function, and you're not willing to fix either of those | ||
// problems, please detail your unique predicament in a GitHub issue. | ||
Function("r", "regeneratorRuntime = r")(runtime); | ||
} | ||
/***/ }), | ||
/* 5 */ | ||
/* 3 */ | ||
/***/ (function(module, __webpack_exports__, __webpack_require__) { | ||
@@ -1189,2 +447,3 @@ | ||
// EXPORTS | ||
__webpack_require__.d(__webpack_exports__, "eagerLoadTwitterLibrary", function() { return /* reexport */ loadTwitterLibrary; }); | ||
__webpack_require__.d(__webpack_exports__, "Follow", function() { return /* binding */ src_Follow; }); | ||
@@ -1197,6 +456,2 @@ __webpack_require__.d(__webpack_exports__, "Hashtag", function() { return /* binding */ src_Hashtag; }); | ||
// EXTERNAL MODULE: ./node_modules/@babel/runtime/regenerator/index.js | ||
var regenerator = __webpack_require__(1); | ||
var regenerator_default = /*#__PURE__*/__webpack_require__.n(regenerator); | ||
// EXTERNAL MODULE: external {"root":"React","commonjs2":"react","commonjs":"react","amd":"react"} | ||
@@ -1207,10 +462,8 @@ var external_root_React_commonjs2_react_commonjs_react_amd_react_ = __webpack_require__(0); | ||
// EXTERNAL MODULE: ./node_modules/loadjs/dist/loadjs.umd.js | ||
var loadjs_umd = __webpack_require__(2); | ||
var loadjs_umd = __webpack_require__(1); | ||
var loadjs_umd_default = /*#__PURE__*/__webpack_require__.n(loadjs_umd); | ||
// CONCATENATED MODULE: ./src/utils.js | ||
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); } | ||
var twScriptUrl = "https://platform.twitter.com/widgets.js"; | ||
@@ -1220,4 +473,6 @@ var twScriptWindowFieldName = "twttr"; | ||
var canUseDOM = !!(typeof window !== "undefined" && window.document && window.document.createElement); | ||
function twLoad() { | ||
loadjs_umd_default()(twScriptUrl, twScriptName); | ||
function loadTwitterLibrary() { | ||
if (!loadjs_umd_default.a.isDefined(twScriptName)) { | ||
loadjs_umd_default()(twScriptUrl, twScriptName); | ||
} | ||
} | ||
@@ -1230,2 +485,3 @@ function twWidgetFactory() { | ||
loadTwitterLibrary(); | ||
loadjs_umd_default.a.ready(twScriptName, { | ||
@@ -1299,3 +555,3 @@ success: function success() { | ||
function cloneShallow(value) { | ||
return typeof value === "object" ? _extends({}, value) : value; | ||
return typeof value === "object" ? Object.assign({}, value) : value; | ||
} | ||
@@ -1305,13 +561,3 @@ // CONCATENATED MODULE: ./src/index.js | ||
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } } | ||
function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; } | ||
if (canUseDOM) { | ||
twLoad(); | ||
} | ||
var childDivIdentifyingAttribute = "twdiv"; | ||
@@ -1351,90 +597,43 @@ | ||
if (ref.current) { | ||
var loadWidget = /*#__PURE__*/function () { | ||
var _ref = _asyncToGenerator( /*#__PURE__*/regenerator_default.a.mark(function _callee() { | ||
var childEl, wf, resultMaybe; | ||
return regenerator_default.a.wrap(function _callee$(_context) { | ||
while (1) { | ||
switch (_context.prev = _context.next) { | ||
case 0: | ||
if (!(!ref || !ref.current)) { | ||
_context.next = 2; | ||
break; | ||
} | ||
removeChildrenWithAttribute(ref.current, childDivIdentifyingAttribute); | ||
return _context.abrupt("return"); | ||
if (!ref || !ref.current) { | ||
return; | ||
} | ||
case 2: | ||
childEl = document.createElement("div"); | ||
childEl.setAttribute(childDivIdentifyingAttribute, "yes"); | ||
ref.current.appendChild(childEl); | ||
_context.prev = 5; | ||
_context.next = 8; | ||
return twWidgetFactory(); | ||
var childEl = document.createElement("div"); | ||
childEl.setAttribute(childDivIdentifyingAttribute, "yes"); | ||
ref.current.appendChild(childEl); | ||
twWidgetFactory().then(function (wf) { | ||
// primaryArg (possibly an object) and options must be cloned | ||
// since twitter mutates them (gah!). | ||
// There currently aren't any nested arrays or objects, so they | ||
// can be cloned in a shallow manner. | ||
return wf[factoryFunctionName](cloneShallow(primaryArg), childEl, cloneShallow(options)); | ||
}).then(function (resultMaybe) { | ||
// Twitter returns undefined if widget creation fails. | ||
// However, if deps are stale (isCanceled), suppress error (likely race condition). | ||
if (!resultMaybe && !isCanceled) { | ||
throw new Error("Twitter could not create widget. If it is a Timeline or " + "Tweet, ensure the screenName/tweetId exists."); | ||
} | ||
case 8: | ||
wf = _context.sent; | ||
_context.next = 11; | ||
return wf[factoryFunctionName](cloneShallow(primaryArg), childEl, cloneShallow(options)); | ||
if (!ref || !ref.current) { | ||
return; | ||
} | ||
case 11: | ||
resultMaybe = _context.sent; | ||
if (isCanceled) { | ||
if (childEl) { | ||
childEl.remove(); | ||
} | ||
if (!(!resultMaybe && !isCanceled)) { | ||
_context.next = 14; | ||
break; | ||
} | ||
return; | ||
} | ||
throw new Error("Twitter could not create widget. If it is a Timeline or " + "Tweet, ensure the screenName/tweetId exists."); | ||
case 14: | ||
_context.next = 21; | ||
break; | ||
case 16: | ||
_context.prev = 16; | ||
_context.t0 = _context["catch"](5); | ||
console.error(_context.t0); | ||
setError(_context.t0); | ||
return _context.abrupt("return"); | ||
case 21: | ||
if (!(!ref || !ref.current)) { | ||
_context.next = 23; | ||
break; | ||
} | ||
return _context.abrupt("return"); | ||
case 23: | ||
if (!isCanceled) { | ||
_context.next = 26; | ||
break; | ||
} | ||
if (childEl) { | ||
childEl.remove(); | ||
} | ||
return _context.abrupt("return"); | ||
case 26: | ||
if (onLoad) { | ||
onLoad(); | ||
} | ||
case 27: | ||
case "end": | ||
return _context.stop(); | ||
} | ||
} | ||
}, _callee, null, [[5, 16]]); | ||
})); | ||
return function loadWidget() { | ||
return _ref.apply(this, arguments); | ||
}; | ||
}(); | ||
removeChildrenWithAttribute(ref.current, childDivIdentifyingAttribute); | ||
loadWidget(); | ||
if (onLoad) { | ||
onLoad(); | ||
} | ||
})["catch"](function (e) { | ||
console.error(e); | ||
setError(e); | ||
}); | ||
} | ||
@@ -1452,7 +651,7 @@ | ||
var src_Follow = function Follow(_ref2) { | ||
var username = _ref2.username, | ||
options = _ref2.options, | ||
onLoad = _ref2.onLoad, | ||
renderError = _ref2.renderError; | ||
var src_Follow = function Follow(_ref) { | ||
var username = _ref.username, | ||
options = _ref.options, | ||
onLoad = _ref.onLoad, | ||
renderError = _ref.renderError; | ||
@@ -1467,7 +666,7 @@ var _useTwitterWidget = useTwitterWidget("createFollowButton", username, options, onLoad), | ||
}; | ||
var src_Hashtag = function Hashtag(_ref3) { | ||
var hashtag = _ref3.hashtag, | ||
options = _ref3.options, | ||
onLoad = _ref3.onLoad, | ||
renderError = _ref3.renderError; | ||
var src_Hashtag = function Hashtag(_ref2) { | ||
var hashtag = _ref2.hashtag, | ||
options = _ref2.options, | ||
onLoad = _ref2.onLoad, | ||
renderError = _ref2.renderError; | ||
@@ -1482,7 +681,7 @@ var _useTwitterWidget2 = useTwitterWidget("createHashtagButton", hashtag, options, onLoad), | ||
}; | ||
var src_Mention = function Mention(_ref4) { | ||
var username = _ref4.username, | ||
options = _ref4.options, | ||
onLoad = _ref4.onLoad, | ||
renderError = _ref4.renderError; | ||
var src_Mention = function Mention(_ref3) { | ||
var username = _ref3.username, | ||
options = _ref3.options, | ||
onLoad = _ref3.onLoad, | ||
renderError = _ref3.renderError; | ||
@@ -1497,7 +696,7 @@ var _useTwitterWidget3 = useTwitterWidget("createMentionButton", username, options, onLoad), | ||
}; | ||
var src_Share = function Share(_ref5) { | ||
var url = _ref5.url, | ||
options = _ref5.options, | ||
onLoad = _ref5.onLoad, | ||
renderError = _ref5.renderError; | ||
var src_Share = function Share(_ref4) { | ||
var url = _ref4.url, | ||
options = _ref4.options, | ||
onLoad = _ref4.onLoad, | ||
renderError = _ref4.renderError; | ||
@@ -1512,7 +711,7 @@ var _useTwitterWidget4 = useTwitterWidget("createShareButton", url, options, onLoad), | ||
}; | ||
var src_Timeline = function Timeline(_ref6) { | ||
var dataSource = _ref6.dataSource, | ||
options = _ref6.options, | ||
onLoad = _ref6.onLoad, | ||
renderError = _ref6.renderError; | ||
var src_Timeline = function Timeline(_ref5) { | ||
var dataSource = _ref5.dataSource, | ||
options = _ref5.options, | ||
onLoad = _ref5.onLoad, | ||
renderError = _ref5.renderError; | ||
@@ -1527,7 +726,7 @@ var _useTwitterWidget5 = useTwitterWidget("createTimeline", dataSource, options, onLoad), | ||
}; | ||
var src_Tweet = function Tweet(_ref7) { | ||
var tweetId = _ref7.tweetId, | ||
options = _ref7.options, | ||
onLoad = _ref7.onLoad, | ||
renderError = _ref7.renderError; | ||
var src_Tweet = function Tweet(_ref6) { | ||
var tweetId = _ref6.tweetId, | ||
options = _ref6.options, | ||
onLoad = _ref6.onLoad, | ||
renderError = _ref6.renderError; | ||
@@ -1534,0 +733,0 @@ var _useTwitterWidget6 = useTwitterWidget("createTweet", tweetId, options, onLoad), |
/*! | ||
* react-twitter-widgets v1.10.0 - https://github.com/andrewsuzuki/react-twitter-widgets | ||
* react-twitter-widgets v1.11.0 - https://github.com/andrewsuzuki/react-twitter-widgets | ||
* MIT Licensed | ||
*/ | ||
!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e(require("react")):"function"==typeof define&&define.amd?define(["react"],e):"object"==typeof exports?exports.ReactTwitterWidgets=e(require("react")):t.ReactTwitterWidgets=e(t.React)}(window,(function(t){return function(t){var e={};function r(n){if(e[n])return e[n].exports;var o=e[n]={i:n,l:!1,exports:{}};return t[n].call(o.exports,o,o.exports,r),o.l=!0,o.exports}return r.m=t,r.c=e,r.d=function(t,e,n){r.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:n})},r.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},r.t=function(t,e){if(1&e&&(t=r(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var n=Object.create(null);if(r.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var o in t)r.d(n,o,function(e){return t[e]}.bind(null,o));return n},r.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return r.d(e,"a",e),e},r.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},r.p="",r(r.s=3)}([function(e,r){e.exports=t},function(t,e,r){t.exports=r(4)},function(t,e,r){var n,o,i;o=[],void 0===(i="function"==typeof(n=function(){var t=function(){},e={},r={},n={};function o(t,e){if(t){var o=n[t];if(r[t]=e,o)for(;o.length;)o[0](t,e),o.splice(0,1)}}function i(e,r){e.call&&(e={success:e}),r.length?(e.error||t)(r):(e.success||t)(e)}function a(e,r,n,o){var i,u,c=document,f=n.async,s=(n.numRetries||0)+1,l=n.before||t,h=e.replace(/[\?|#].*$/,""),p=e.replace(/^(css|img)!/,"");o=o||0,/(^css!|\.css$)/.test(h)?((u=c.createElement("link")).rel="stylesheet",u.href=p,(i="hideFocus"in u)&&u.relList&&(i=0,u.rel="preload",u.as="style")):/(^img!|\.(png|gif|jpg|svg|webp)$)/.test(h)?(u=c.createElement("img")).src=p:((u=c.createElement("script")).src=e,u.async=void 0===f||f),u.onload=u.onerror=u.onbeforeload=function(t){var c=t.type[0];if(i)try{u.sheet.cssText.length||(c="e")}catch(t){18!=t.code&&(c="e")}if("e"==c){if((o+=1)<s)return a(e,r,n,o)}else if("preload"==u.rel&&"style"==u.as)return u.rel="stylesheet";r(e,c,t.defaultPrevented)},!1!==l(e,u)&&c.head.appendChild(u)}function u(t,r,n){var u,c;if(r&&r.trim&&(u=r),c=(u?n:r)||{},u){if(u in e)throw"LoadJS";e[u]=!0}function f(e,r){!function(t,e,r){var n,o,i=(t=t.push?t:[t]).length,u=i,c=[];for(n=function(t,r,n){if("e"==r&&c.push(t),"b"==r){if(!n)return;c.push(t)}--i||e(c)},o=0;o<u;o++)a(t[o],n,r)}(t,(function(t){i(c,t),e&&i({success:e,error:r},t),o(u,t)}),c)}if(c.returnPromise)return new Promise(f);f()}return u.ready=function(t,e){return function(t,e){t=t.push?t:[t];var o,i,a,u=[],c=t.length,f=c;for(o=function(t,r){r.length&&u.push(t),--f||e(u)};c--;)i=t[c],(a=r[i])?o(i,a):(n[i]=n[i]||[]).push(o)}(t,(function(t){i(e,t)})),u},u.done=function(t){o(t,[])},u.reset=function(){e={},r={},n={}},u.isDefined=function(t){return t in e},u})?n.apply(e,o):n)||(t.exports=i)},function(t,e,r){t.exports=r(5)},function(t,e,r){var n=function(t){"use strict";var e=Object.prototype,r=e.hasOwnProperty,n="function"==typeof Symbol?Symbol:{},o=n.iterator||"@@iterator",i=n.asyncIterator||"@@asyncIterator",a=n.toStringTag||"@@toStringTag";function u(t,e,r,n){var o=e&&e.prototype instanceof s?e:s,i=Object.create(o.prototype),a=new E(n||[]);return i._invoke=function(t,e,r){var n="suspendedStart";return function(o,i){if("executing"===n)throw new Error("Generator is already running");if("completed"===n){if("throw"===o)throw i;return j()}for(r.method=o,r.arg=i;;){var a=r.delegate;if(a){var u=w(a,r);if(u){if(u===f)continue;return u}}if("next"===r.method)r.sent=r._sent=r.arg;else if("throw"===r.method){if("suspendedStart"===n)throw n="completed",r.arg;r.dispatchException(r.arg)}else"return"===r.method&&r.abrupt("return",r.arg);n="executing";var s=c(t,e,r);if("normal"===s.type){if(n=r.done?"completed":"suspendedYield",s.arg===f)continue;return{value:s.arg,done:r.done}}"throw"===s.type&&(n="completed",r.method="throw",r.arg=s.arg)}}}(t,r,a),i}function c(t,e,r){try{return{type:"normal",arg:t.call(e,r)}}catch(t){return{type:"throw",arg:t}}}t.wrap=u;var f={};function s(){}function l(){}function h(){}var p={};p[o]=function(){return this};var d=Object.getPrototypeOf,v=d&&d(d(L([])));v&&v!==e&&r.call(v,o)&&(p=v);var y=h.prototype=s.prototype=Object.create(p);function m(t){["next","throw","return"].forEach((function(e){t[e]=function(t){return this._invoke(e,t)}}))}function g(t,e){var n;this._invoke=function(o,i){function a(){return new e((function(n,a){!function n(o,i,a,u){var f=c(t[o],t,i);if("throw"!==f.type){var s=f.arg,l=s.value;return l&&"object"==typeof l&&r.call(l,"__await")?e.resolve(l.__await).then((function(t){n("next",t,a,u)}),(function(t){n("throw",t,a,u)})):e.resolve(l).then((function(t){s.value=t,a(s)}),(function(t){return n("throw",t,a,u)}))}u(f.arg)}(o,i,n,a)}))}return n=n?n.then(a,a):a()}}function w(t,e){var r=t.iterator[e.method];if(void 0===r){if(e.delegate=null,"throw"===e.method){if(t.iterator.return&&(e.method="return",e.arg=void 0,w(t,e),"throw"===e.method))return f;e.method="throw",e.arg=new TypeError("The iterator does not provide a 'throw' method")}return f}var n=c(r,t.iterator,e.arg);if("throw"===n.type)return e.method="throw",e.arg=n.arg,e.delegate=null,f;var o=n.arg;return o?o.done?(e[t.resultName]=o.value,e.next=t.nextLoc,"return"!==e.method&&(e.method="next",e.arg=void 0),e.delegate=null,f):o:(e.method="throw",e.arg=new TypeError("iterator result is not an object"),e.delegate=null,f)}function b(t){var e={tryLoc:t[0]};1 in t&&(e.catchLoc=t[1]),2 in t&&(e.finallyLoc=t[2],e.afterLoc=t[3]),this.tryEntries.push(e)}function x(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function E(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(b,this),this.reset(!0)}function L(t){if(t){var e=t[o];if(e)return e.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var n=-1,i=function e(){for(;++n<t.length;)if(r.call(t,n))return e.value=t[n],e.done=!1,e;return e.value=void 0,e.done=!0,e};return i.next=i}}return{next:j}}function j(){return{value:void 0,done:!0}}return l.prototype=y.constructor=h,h.constructor=l,h[a]=l.displayName="GeneratorFunction",t.isGeneratorFunction=function(t){var e="function"==typeof t&&t.constructor;return!!e&&(e===l||"GeneratorFunction"===(e.displayName||e.name))},t.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,h):(t.__proto__=h,a in t||(t[a]="GeneratorFunction")),t.prototype=Object.create(y),t},t.awrap=function(t){return{__await:t}},m(g.prototype),g.prototype[i]=function(){return this},t.AsyncIterator=g,t.async=function(e,r,n,o,i){void 0===i&&(i=Promise);var a=new g(u(e,r,n,o),i);return t.isGeneratorFunction(r)?a:a.next().then((function(t){return t.done?t.value:a.next()}))},m(y),y[a]="Generator",y[o]=function(){return this},y.toString=function(){return"[object Generator]"},t.keys=function(t){var e=[];for(var r in t)e.push(r);return e.reverse(),function r(){for(;e.length;){var n=e.pop();if(n in t)return r.value=n,r.done=!1,r}return r.done=!0,r}},t.values=L,E.prototype={constructor:E,reset:function(t){if(this.prev=0,this.next=0,this.sent=this._sent=void 0,this.done=!1,this.delegate=null,this.method="next",this.arg=void 0,this.tryEntries.forEach(x),!t)for(var e in this)"t"===e.charAt(0)&&r.call(this,e)&&!isNaN(+e.slice(1))&&(this[e]=void 0)},stop:function(){this.done=!0;var t=this.tryEntries[0].completion;if("throw"===t.type)throw t.arg;return this.rval},dispatchException:function(t){if(this.done)throw t;var e=this;function n(r,n){return a.type="throw",a.arg=t,e.next=r,n&&(e.method="next",e.arg=void 0),!!n}for(var o=this.tryEntries.length-1;o>=0;--o){var i=this.tryEntries[o],a=i.completion;if("root"===i.tryLoc)return n("end");if(i.tryLoc<=this.prev){var u=r.call(i,"catchLoc"),c=r.call(i,"finallyLoc");if(u&&c){if(this.prev<i.catchLoc)return n(i.catchLoc,!0);if(this.prev<i.finallyLoc)return n(i.finallyLoc)}else if(u){if(this.prev<i.catchLoc)return n(i.catchLoc,!0)}else{if(!c)throw new Error("try statement without catch or finally");if(this.prev<i.finallyLoc)return n(i.finallyLoc)}}}},abrupt:function(t,e){for(var n=this.tryEntries.length-1;n>=0;--n){var o=this.tryEntries[n];if(o.tryLoc<=this.prev&&r.call(o,"finallyLoc")&&this.prev<o.finallyLoc){var i=o;break}}i&&("break"===t||"continue"===t)&&i.tryLoc<=e&&e<=i.finallyLoc&&(i=null);var a=i?i.completion:{};return a.type=t,a.arg=e,i?(this.method="next",this.next=i.finallyLoc,f):this.complete(a)},complete:function(t,e){if("throw"===t.type)throw t.arg;return"break"===t.type||"continue"===t.type?this.next=t.arg:"return"===t.type?(this.rval=this.arg=t.arg,this.method="return",this.next="end"):"normal"===t.type&&e&&(this.next=e),f},finish:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),x(r),f}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.tryLoc===t){var n=r.completion;if("throw"===n.type){var o=n.arg;x(r)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(t,e,r){return this.delegate={iterator:L(t),resultName:e,nextLoc:r},"next"===this.method&&(this.arg=void 0),f}},t}(t.exports);try{regeneratorRuntime=n}catch(t){Function("r","regeneratorRuntime = r")(n)}},function(t,e,r){"use strict";r.r(e),r.d(e,"Follow",(function(){return y})),r.d(e,"Hashtag",(function(){return m})),r.d(e,"Mention",(function(){return g})),r.d(e,"Share",(function(){return w})),r.d(e,"Timeline",(function(){return b})),r.d(e,"Tweet",(function(){return x}));var n=r(1),o=r.n(n),i=r(0),a=r.n(i),u=r(2),c=r.n(u);function f(){return(f=Object.assign||function(t){for(var e=1;e<arguments.length;e++){var r=arguments[e];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(t[n]=r[n])}return t}).apply(this,arguments)}var s=!("undefined"==typeof window||!window.document||!window.document.createElement);function l(t,e){return t===e?0!==t||0!==e||1/t==1/e:t!=t&&e!=e}function h(t){var e=Object(i.useRef)();return function(t,e){if(l(t,e))return!0;if("object"!=typeof t||null===t||"object"!=typeof e||null===e)return!1;var r=Object.keys(t),n=Object.keys(e);if(r.length!==n.length)return!1;for(var o=0;o<r.length;o++)if(!Object.prototype.hasOwnProperty.call(e,r[o])||!l(t[r[o]],e[r[o]]))return!1;return!0}(t,e.current)||(e.current=t),e.current}function p(t){return"object"==typeof t?f({},t):t}function d(t,e,r,n,o,i,a){try{var u=t[i](a),c=u.value}catch(t){return void r(t)}u.done?e(c):Promise.resolve(c).then(n,o)}s&&c()("https://platform.twitter.com/widgets.js","twttr");function v(t,e,r,n){var a=Object(i.useState)(null),u=a[0],f=a[1],l=Object(i.useRef)(null);if(!s)return{ref:l,error:u};var v=[t,h(e),h(r)];return Object(i.useEffect)((function(){f(null);var i,a,u=!1;if(l.current){var s=function(){var i,a=(i=o.a.mark((function i(){var a,s;return o.a.wrap((function(o){for(;;)switch(o.prev=o.next){case 0:if(l&&l.current){o.next=2;break}return o.abrupt("return");case 2:return(a=document.createElement("div")).setAttribute("twdiv","yes"),l.current.appendChild(a),o.prev=5,o.next=8,new Promise((function(t,e){var r=function(){return e(new Error("Could not load remote twitter widgets js"))};c.a.ready("twttr",{success:function(){var e=window.twttr;e&&e.widgets||r(),t(e.widgets)},error:r})}));case 8:return s=o.sent,o.next=11,s[t](p(e),a,p(r));case 11:if(o.sent||u){o.next=14;break}throw new Error("Twitter could not create widget. If it is a Timeline or Tweet, ensure the screenName/tweetId exists.");case 14:o.next=21;break;case 16:return o.prev=16,o.t0=o.catch(5),console.error(o.t0),f(o.t0),o.abrupt("return");case 21:if(l&&l.current){o.next=23;break}return o.abrupt("return");case 23:if(!u){o.next=26;break}return a&&a.remove(),o.abrupt("return");case 26:n&&n();case 27:case"end":return o.stop()}}),i,null,[[5,16]])})),function(){var t=this,e=arguments;return new Promise((function(r,n){var o=i.apply(t,e);function a(t){d(o,r,n,a,u,"next",t)}function u(t){d(o,r,n,a,u,"throw",t)}a(void 0)}))});return function(){return a.apply(this,arguments)}}();i=l.current,a="twdiv",i&&i.querySelectorAll("*").forEach((function(t){t.hasAttribute(a)&&t.remove()})),s()}return function(){u=!0}}),v),{ref:l,error:u}}var y=function(t){var e=t.username,r=t.options,n=t.onLoad,o=t.renderError,i=v("createFollowButton",e,r,n),u=i.ref,c=i.error;return a.a.createElement("div",{ref:u},c&&o&&o(c))},m=function(t){var e=t.hashtag,r=t.options,n=t.onLoad,o=t.renderError,i=v("createHashtagButton",e,r,n),u=i.ref,c=i.error;return a.a.createElement("div",{ref:u},c&&o&&o(c))},g=function(t){var e=t.username,r=t.options,n=t.onLoad,o=t.renderError,i=v("createMentionButton",e,r,n),u=i.ref,c=i.error;return a.a.createElement("div",{ref:u},c&&o&&o(c))},w=function(t){var e=t.url,r=t.options,n=t.onLoad,o=t.renderError,i=v("createShareButton",e,r,n),u=i.ref,c=i.error;return a.a.createElement("div",{ref:u},c&&o&&o(c))},b=function(t){var e=t.dataSource,r=t.options,n=t.onLoad,o=t.renderError,i=v("createTimeline",e,r,n),u=i.ref,c=i.error;return a.a.createElement("div",{ref:u},c&&o&&o(c))},x=function(t){var e=t.tweetId,r=t.options,n=t.onLoad,o=t.renderError,i=v("createTweet",e,r,n),u=i.ref,c=i.error;return a.a.createElement("div",{ref:u},c&&o&&o(c))}}]).default})); | ||
!function(e,r){"object"==typeof exports&&"object"==typeof module?module.exports=r(require("react")):"function"==typeof define&&define.amd?define(["react"],r):"object"==typeof exports?exports.ReactTwitterWidgets=r(require("react")):e.ReactTwitterWidgets=r(e.React)}(window,(function(e){return function(e){var r={};function t(n){if(r[n])return r[n].exports;var o=r[n]={i:n,l:!1,exports:{}};return e[n].call(o.exports,o,o.exports,t),o.l=!0,o.exports}return t.m=e,t.c=r,t.d=function(e,r,n){t.o(e,r)||Object.defineProperty(e,r,{enumerable:!0,get:n})},t.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},t.t=function(e,r){if(1&r&&(e=t(e)),8&r)return e;if(4&r&&"object"==typeof e&&e&&e.__esModule)return e;var n=Object.create(null);if(t.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:e}),2&r&&"string"!=typeof e)for(var o in e)t.d(n,o,function(r){return e[r]}.bind(null,o));return n},t.n=function(e){var r=e&&e.__esModule?function(){return e.default}:function(){return e};return t.d(r,"a",r),r},t.o=function(e,r){return Object.prototype.hasOwnProperty.call(e,r)},t.p="",t(t.s=2)}([function(r,t){r.exports=e},function(e,r,t){var n,o,u;o=[],void 0===(u="function"==typeof(n=function(){var e=function(){},r={},t={},n={};function o(e,r){if(e){var o=n[e];if(t[e]=r,o)for(;o.length;)o[0](e,r),o.splice(0,1)}}function u(r,t){r.call&&(r={success:r}),t.length?(r.error||e)(t):(r.success||e)(r)}function i(r,t,n,o){var u,c,f=document,a=n.async,s=(n.numRetries||0)+1,l=n.before||e,d=r.replace(/[\?|#].*$/,""),p=r.replace(/^(css|img)!/,"");o=o||0,/(^css!|\.css$)/.test(d)?((c=f.createElement("link")).rel="stylesheet",c.href=p,(u="hideFocus"in c)&&c.relList&&(u=0,c.rel="preload",c.as="style")):/(^img!|\.(png|gif|jpg|svg|webp)$)/.test(d)?(c=f.createElement("img")).src=p:((c=f.createElement("script")).src=r,c.async=void 0===a||a),c.onload=c.onerror=c.onbeforeload=function(e){var f=e.type[0];if(u)try{c.sheet.cssText.length||(f="e")}catch(e){18!=e.code&&(f="e")}if("e"==f){if((o+=1)<s)return i(r,t,n,o)}else if("preload"==c.rel&&"style"==c.as)return c.rel="stylesheet";t(r,f,e.defaultPrevented)},!1!==l(r,c)&&f.head.appendChild(c)}function c(e,t,n){var c,f;if(t&&t.trim&&(c=t),f=(c?n:t)||{},c){if(c in r)throw"LoadJS";r[c]=!0}function a(r,t){!function(e,r,t){var n,o,u=(e=e.push?e:[e]).length,c=u,f=[];for(n=function(e,t,n){if("e"==t&&f.push(e),"b"==t){if(!n)return;f.push(e)}--u||r(f)},o=0;o<c;o++)i(e[o],n,t)}(e,(function(e){u(f,e),r&&u({success:r,error:t},e),o(c,e)}),f)}if(f.returnPromise)return new Promise(a);a()}return c.ready=function(e,r){return function(e,r){e=e.push?e:[e];var o,u,i,c=[],f=e.length,a=f;for(o=function(e,t){t.length&&c.push(e),--a||r(c)};f--;)u=e[f],(i=t[u])?o(u,i):(n[u]=n[u]||[]).push(o)}(e,(function(e){u(r,e)})),c},c.done=function(e){o(e,[])},c.reset=function(){r={},t={},n={}},c.isDefined=function(e){return e in r},c})?n.apply(r,o):n)||(e.exports=u)},function(e,r,t){e.exports=t(3)},function(e,r,t){"use strict";t.r(r),t.d(r,"eagerLoadTwitterLibrary",(function(){return f})),t.d(r,"Follow",(function(){return p})),t.d(r,"Hashtag",(function(){return v})),t.d(r,"Mention",(function(){return m})),t.d(r,"Share",(function(){return w})),t.d(r,"Timeline",(function(){return h})),t.d(r,"Tweet",(function(){return y}));var n=t(0),o=t.n(n),u=t(1),i=t.n(u),c=!("undefined"==typeof window||!window.document||!window.document.createElement);function f(){i.a.isDefined("twttr")||i()("https://platform.twitter.com/widgets.js","twttr")}function a(e,r){return e===r?0!==e||0!==r||1/e==1/r:e!=e&&r!=r}function s(e){var r=Object(n.useRef)();return function(e,r){if(a(e,r))return!0;if("object"!=typeof e||null===e||"object"!=typeof r||null===r)return!1;var t=Object.keys(e),n=Object.keys(r);if(t.length!==n.length)return!1;for(var o=0;o<t.length;o++)if(!Object.prototype.hasOwnProperty.call(r,t[o])||!a(e[t[o]],r[t[o]]))return!1;return!0}(e,r.current)||(r.current=e),r.current}function l(e){return"object"==typeof e?Object.assign({},e):e}function d(e,r,t,o){var u=Object(n.useState)(null),a=u[0],d=u[1],p=Object(n.useRef)(null);if(!c)return{ref:p,error:a};var v=[e,s(r),s(t)];return Object(n.useEffect)((function(){d(null);var n,u,c=!1;if(p.current){if(n=p.current,u="twdiv",n&&n.querySelectorAll("*").forEach((function(e){e.hasAttribute(u)&&e.remove()})),!p||!p.current)return;var a=document.createElement("div");a.setAttribute("twdiv","yes"),p.current.appendChild(a),new Promise((function(e,r){var t=function(){return r(new Error("Could not load remote twitter widgets js"))};f(),i.a.ready("twttr",{success:function(){var r=window.twttr;r&&r.widgets||t(),e(r.widgets)},error:t})})).then((function(n){return n[e](l(r),a,l(t))})).then((function(e){if(!e&&!c)throw new Error("Twitter could not create widget. If it is a Timeline or Tweet, ensure the screenName/tweetId exists.");p&&p.current&&(c?a&&a.remove():o&&o())})).catch((function(e){console.error(e),d(e)}))}return function(){c=!0}}),v),{ref:p,error:a}}var p=function(e){var r=e.username,t=e.options,n=e.onLoad,u=e.renderError,i=d("createFollowButton",r,t,n),c=i.ref,f=i.error;return o.a.createElement("div",{ref:c},f&&u&&u(f))},v=function(e){var r=e.hashtag,t=e.options,n=e.onLoad,u=e.renderError,i=d("createHashtagButton",r,t,n),c=i.ref,f=i.error;return o.a.createElement("div",{ref:c},f&&u&&u(f))},m=function(e){var r=e.username,t=e.options,n=e.onLoad,u=e.renderError,i=d("createMentionButton",r,t,n),c=i.ref,f=i.error;return o.a.createElement("div",{ref:c},f&&u&&u(f))},w=function(e){var r=e.url,t=e.options,n=e.onLoad,u=e.renderError,i=d("createShareButton",r,t,n),c=i.ref,f=i.error;return o.a.createElement("div",{ref:c},f&&u&&u(f))},h=function(e){var r=e.dataSource,t=e.options,n=e.onLoad,u=e.renderError,i=d("createTimeline",r,t,n),c=i.ref,f=i.error;return o.a.createElement("div",{ref:c},f&&u&&u(f))},y=function(e){var r=e.tweetId,t=e.options,n=e.onLoad,u=e.renderError,i=d("createTweet",r,t,n),c=i.ref,f=i.error;return o.a.createElement("div",{ref:c},f&&u&&u(f))}}]).default})); | ||
//# sourceMappingURL=react-twitter-widgets.min.js.map |
Sorry, the diff of this file is not supported yet
Uses eval
Supply chain riskPackage uses dynamic code execution (e.g., eval()), which is a dangerous practice. This can prevent the code from running in certain environments and increases the risk that the code may contain exploits or malicious behavior.
Found 1 instance in 1 package
101
0
80650
1147