@social-embed/lib
Advanced tools
Comparing version 0.0.1-next.10 to 0.0.1-next.11
@@ -58,2 +58,130 @@ 'use strict'; | ||
/** | ||
* Detection and parsing for Edpuzzle URLs | ||
* | ||
* [Edpuzzle's officie embed docs](https://support.edpuzzle.com/hc/en-us/articles/360007260632-Can-I-embed-an-assignment-into-an-LMS-blog-or-website-) | ||
* | ||
* @module providers/edpuzzle | ||
*/ | ||
/** | ||
* Matches ID from URLs matching: https://edpuzzle.com/media/606b413369971e424ec6021e | ||
*/ | ||
var edPuzzleUrlRegex = /*#__PURE__*/new RegExp('^(?:(?:https?):)?(?://)?[^/]*edpuzzle.com.*[=/]media/([-\\w]+)'); | ||
/** | ||
* Return ID from shared link. | ||
* | ||
* @param url Shared URL link. | ||
*/ | ||
var getEdPuzzleIdFromUrl = function getEdPuzzleIdFromUrl(url) { | ||
if (url) { | ||
var _url$match$, _url$match; | ||
return (_url$match$ = (_url$match = url.match(edPuzzleUrlRegex)) == null ? void 0 : _url$match[1]) != null ? _url$match$ : ''; | ||
} | ||
return ''; | ||
}; | ||
/** | ||
* Return embed-friendly URL from ID. | ||
* | ||
* @param edPuzzleId ID of embed | ||
*/ | ||
var getEdPuzzleEmbedUrlFromId = function getEdPuzzleEmbedUrlFromId(edPuzzleId) { | ||
return "https://edpuzzle.com/embed/media/" + edPuzzleId; | ||
}; | ||
/** | ||
* Detecting and parsing for Wistia URLs. | ||
* | ||
* [Wistia's Official embed documentation](https://wistia.com/support/embed-and-share/video-on-your-website) | ||
* [Wistia's Embed building documentation](https://wistia.com/support/developers/construct-an-embed-code) | ||
* | ||
* @module providers/wistia | ||
*/ | ||
/* | ||
<iframe src="//fast.wistia.net/embed/iframe/26sk4lmiix" allowtransparency="true" frameborder="0" scrolling="no" class="wistia_embed" name="wistia_embed" allowfullscreen mozallowfullscreen webkitallowfullscreen oallowfullscreen msallowfullscreen width="620" height="349"></iframe> | ||
<script src="//fast.wistia.net/assets/external/E-v1.js" async></script> | ||
*/ | ||
/** | ||
* Matches ID from URLs matching: | ||
* - https://support.wistia.com/medias/26sk4lmiix | ||
* - https://support.wistia.com/embed/26sk4lmiix | ||
* | ||
* While these are not used, these are mentions on [Wistia's embed construction](https://wistia.com/support/developers/construct-an-embed-code) docs: | ||
* - https://support.wi.st/embed/26sk4lmiix | ||
* - https://support.wi.st/medias/26sk4lmiix | ||
*/ | ||
var wistiaUrlRegex = /*#__PURE__*/new RegExp('^(?:(?:https?):)?(?://)?[^/]*(?:wistia.com|wi.st).*[=/](?:medias|embed)/([-\\w]+)' // '^(?:(?:https?):)?(?://)?[^/]*wistia.com.*[=/]medias/([-\\w]+)' // v1 (handcrafted by Tony) | ||
); | ||
/** | ||
* Return ID from shared link. | ||
* | ||
* @param url Shared URL link. | ||
*/ | ||
var getWistiaIdFromUrl = function getWistiaIdFromUrl(url) { | ||
if (url) { | ||
var _url$match$, _url$match; | ||
return (_url$match$ = (_url$match = url.match(wistiaUrlRegex)) == null ? void 0 : _url$match[1]) != null ? _url$match$ : ''; | ||
} | ||
return ''; | ||
}; | ||
/** | ||
* Return embed-friendly URL from ID. | ||
* | ||
* @param wistiaId ID of embed | ||
*/ | ||
var getWistiaEmbedUrlFromId = function getWistiaEmbedUrlFromId(wistiaId) { | ||
return "https://fast.wistia.net/embed/iframe/" + wistiaId; | ||
}; | ||
/** | ||
* Detecting and parsing for Loom URLs. | ||
* | ||
* [Loom's Official embed documentation](https://www.loom.com/share/e883f70b219a49f6ba7fbeac71a72604) | ||
* | ||
* @module providers/loom | ||
*/ | ||
/* | ||
<div style="position: relative; padding-bottom: 61.224489795918366%; height: 0;"><iframe src="https://www.loom.com/embed/e883f70b219a49f6ba7fbeac71a72604" frameborder="0" webkitallowfullscreen mozallowfullscreen allowfullscreen style="position: absolute; top: 0; left: 0; width: 100%; height: 100%;"></iframe></div> | ||
*/ | ||
/** | ||
* Matches ID from URLs matching: https://www.loom.com/share/e883f70b219a49f6ba7fbeac71a72604 | ||
*/ | ||
var loomUrlRegex = /*#__PURE__*/new RegExp('^(?:(?:https?):)?(?://)?[^/]*loom.com.*[=/]share/([-\\w]+)'); | ||
/** | ||
* Return ID from shared link. | ||
* | ||
* @param url Shared URL link. | ||
*/ | ||
var getLoomIdFromUrl = function getLoomIdFromUrl(url) { | ||
if (url) { | ||
var _url$match$, _url$match; | ||
return (_url$match$ = (_url$match = url.match(loomUrlRegex)) == null ? void 0 : _url$match[1]) != null ? _url$match$ : ''; | ||
} | ||
return ''; | ||
}; | ||
/** | ||
* Return embed-friendly URL from ID. | ||
* | ||
* @param loomId ID of embed | ||
*/ | ||
var getLoomEmbedUrlFromId = function getLoomEmbedUrlFromId(loomId) { | ||
return "https://www.loom.com/embed/" + loomId; | ||
}; | ||
var _ProviderIdFunctionMa, _ProviderIdUrlFunctio; | ||
@@ -66,2 +194,5 @@ | ||
Provider["DailyMotion"] = "DailyMotion"; | ||
Provider["EdPuzzle"] = "EdPuzzle"; | ||
Provider["Loom"] = "Loom"; | ||
Provider["Wistia"] = "Wistia"; | ||
})(exports.Provider || (exports.Provider = {})); | ||
@@ -90,6 +221,18 @@ | ||
if (url.match(/edpuzzle.com/)) { | ||
return exports.Provider.EdPuzzle; | ||
} | ||
if (getWistiaIdFromUrl(url)) { | ||
return exports.Provider.Wistia; | ||
} | ||
if (getLoomIdFromUrl(url)) { | ||
return exports.Provider.Loom; | ||
} | ||
return undefined; | ||
}; | ||
var ProviderIdFunctionMap = (_ProviderIdFunctionMa = {}, _ProviderIdFunctionMa[exports.Provider.DailyMotion] = getDailyMotionIdFromUrl, _ProviderIdFunctionMa[exports.Provider.Spotify] = getSpotifyIdAndTypeFromUrl, _ProviderIdFunctionMa[exports.Provider.Vimeo] = getVimeoIdFromUrl, _ProviderIdFunctionMa[exports.Provider.YouTube] = getYouTubeIdFromUrl, _ProviderIdFunctionMa); | ||
var ProviderIdUrlFunctionMap = (_ProviderIdUrlFunctio = {}, _ProviderIdUrlFunctio[exports.Provider.DailyMotion] = getDailyMotionEmbedFromId, _ProviderIdUrlFunctio[exports.Provider.Spotify] = getSpotifyEmbedUrlFromIdAndType, _ProviderIdUrlFunctio[exports.Provider.Vimeo] = getVimeoEmbedUrlFromId, _ProviderIdUrlFunctio[exports.Provider.YouTube] = getYouTubeEmbedUrlFromId, _ProviderIdUrlFunctio); | ||
var ProviderIdFunctionMap = (_ProviderIdFunctionMa = {}, _ProviderIdFunctionMa[exports.Provider.DailyMotion] = getDailyMotionIdFromUrl, _ProviderIdFunctionMa[exports.Provider.Spotify] = getSpotifyIdAndTypeFromUrl, _ProviderIdFunctionMa[exports.Provider.Vimeo] = getVimeoIdFromUrl, _ProviderIdFunctionMa[exports.Provider.YouTube] = getYouTubeIdFromUrl, _ProviderIdFunctionMa[exports.Provider.EdPuzzle] = getEdPuzzleIdFromUrl, _ProviderIdFunctionMa[exports.Provider.Loom] = getLoomIdFromUrl, _ProviderIdFunctionMa[exports.Provider.Wistia] = getWistiaIdFromUrl, _ProviderIdFunctionMa); | ||
var ProviderIdUrlFunctionMap = (_ProviderIdUrlFunctio = {}, _ProviderIdUrlFunctio[exports.Provider.DailyMotion] = getDailyMotionEmbedFromId, _ProviderIdUrlFunctio[exports.Provider.Spotify] = getSpotifyEmbedUrlFromIdAndType, _ProviderIdUrlFunctio[exports.Provider.Vimeo] = getVimeoEmbedUrlFromId, _ProviderIdUrlFunctio[exports.Provider.YouTube] = getYouTubeEmbedUrlFromId, _ProviderIdUrlFunctio[exports.Provider.EdPuzzle] = getEdPuzzleEmbedUrlFromId, _ProviderIdUrlFunctio[exports.Provider.Loom] = getLoomEmbedUrlFromId, _ProviderIdUrlFunctio[exports.Provider.Wistia] = getWistiaEmbedUrlFromId, _ProviderIdUrlFunctio); | ||
var convertUrlToEmbedUrl = function convertUrlToEmbedUrl(url) { | ||
@@ -119,4 +262,9 @@ var provider = getProviderFromUrl(url); | ||
exports.dailyMotionUrlRegex = dailyMotionUrlRegex; | ||
exports.edPuzzleUrlRegex = edPuzzleUrlRegex; | ||
exports.getDailyMotionEmbedFromId = getDailyMotionEmbedFromId; | ||
exports.getDailyMotionIdFromUrl = getDailyMotionIdFromUrl; | ||
exports.getEdPuzzleEmbedUrlFromId = getEdPuzzleEmbedUrlFromId; | ||
exports.getEdPuzzleIdFromUrl = getEdPuzzleIdFromUrl; | ||
exports.getLoomEmbedUrlFromId = getLoomEmbedUrlFromId; | ||
exports.getLoomIdFromUrl = getLoomIdFromUrl; | ||
exports.getProviderFromUrl = getProviderFromUrl; | ||
@@ -127,8 +275,12 @@ exports.getSpotifyEmbedUrlFromIdAndType = getSpotifyEmbedUrlFromIdAndType; | ||
exports.getVimeoIdFromUrl = getVimeoIdFromUrl; | ||
exports.getWistiaEmbedUrlFromId = getWistiaEmbedUrlFromId; | ||
exports.getWistiaIdFromUrl = getWistiaIdFromUrl; | ||
exports.getYouTubeEmbedUrlFromId = getYouTubeEmbedUrlFromId; | ||
exports.getYouTubeIdFromUrl = getYouTubeIdFromUrl; | ||
exports.loomUrlRegex = loomUrlRegex; | ||
exports.spotifySymbolRegex = spotifySymbolRegex; | ||
exports.spotifyUrlRegex = spotifyUrlRegex; | ||
exports.vimeoUrlRegex = vimeoUrlRegex; | ||
exports.wistiaUrlRegex = wistiaUrlRegex; | ||
exports.youTubeUrlRegex = youTubeUrlRegex; | ||
//# sourceMappingURL=lib.cjs.development.js.map |
@@ -1,2 +0,2 @@ | ||
"use strict";var o,r,e,t="^(?:(?:https?):)?(?://)?[^/]*(?:youtube(?:-nocookie)?.com|youtu.be).*[=/]([-\\w]{11})(?:\\?|=|&|$)",i=function(o){var r,e;return o&&null!=(r=null==(e=o.match(t))?void 0:e[1])?r:""},p=function(o){return"https://www.youtube.com/embed/"+o},n=/^(?:(?:https?):)?(?:\/\/)?(?:www\.)?(?:(?:dailymotion\.com(?:\/embed)?\/video)|dai\.ly)\/([a-zA-Z0-9]+)(?:_[\w_-]+)?(?:\?playlist=[a-zA-Z0-9]+)?$/,u=function(o){var r,e;return null!=(r=null==(e=o.match(n))?void 0:e[1])?r:""},s=function(o){return"https://www.dailymotion.com/embed/video/"+o},d=/(?:(?:https?):)?(?:\/\/)?(?:embed\.|open\.)(?:spotify\.com\/)(?:(album|track|playlist)\/|\?uri=spotify:track:)((\w|-){22})/,m=/spotify:(?:(album|track|playlist):|\?uri=spotify:track:)((\w|-){22})/,l=function(o){var r=o.match(d)||o.match(m)||[];return[r[2],r[1]]},a=function(o,r){return"https://open.spotify.com/embed/"+r+"/"+o},y=/(?:(?:https?):)?(?:\/\/)?(?:www\.|player\.)?vimeo\.com\/(?:channels\/(?:\w+\/)?|groups\/(?:[^/]*)\/videos\/|video\/|)(\d+)(?:|\/\?)/,v=function(o){var r,e;return null!=(r=null==(e=o.match(y))?void 0:e[1])?r:""},c=function(o){return"https://player.vimeo.com/video/"+o};(e=exports.Provider||(exports.Provider={})).YouTube="YouTube",e.Spotify="Spotify",e.Vimeo="Vimeo",e.DailyMotion="DailyMotion";var x=function(o){if(o)return o.match(/dailymotion/)?exports.Provider.DailyMotion:o.match(/spotify/)?exports.Provider.Spotify:o.match(/vimeo/)?exports.Provider.Vimeo:o.match(/youtu\.?be/)?exports.Provider.YouTube:void 0},f=((o={})[exports.Provider.DailyMotion]=u,o[exports.Provider.Spotify]=l,o[exports.Provider.Vimeo]=v,o[exports.Provider.YouTube]=i,o),b=((r={})[exports.Provider.DailyMotion]=s,r[exports.Provider.Spotify]=a,r[exports.Provider.Vimeo]=c,r[exports.Provider.YouTube]=p,r);exports.ProviderIdFunctionMap=f,exports.ProviderIdUrlFunctionMap=b,exports.convertUrlToEmbedUrl=function(o){var r=x(o);if(!r)return"";var e=b[r],t=(0,f[r])(o);if(Array.isArray(t)){var i=t.shift();return i?e.apply(void 0,[i].concat(t)):""}return e(t)},exports.dailyMotionUrlRegex=n,exports.getDailyMotionEmbedFromId=s,exports.getDailyMotionIdFromUrl=u,exports.getProviderFromUrl=x,exports.getSpotifyEmbedUrlFromIdAndType=a,exports.getSpotifyIdAndTypeFromUrl=l,exports.getVimeoEmbedUrlFromId=c,exports.getVimeoIdFromUrl=v,exports.getYouTubeEmbedUrlFromId=p,exports.getYouTubeIdFromUrl=i,exports.spotifySymbolRegex=m,exports.spotifyUrlRegex=d,exports.vimeoUrlRegex=y,exports.youTubeUrlRegex=t; | ||
"use strict";var o,e,r,t="^(?:(?:https?):)?(?://)?[^/]*(?:youtube(?:-nocookie)?.com|youtu.be).*[=/]([-\\w]{11})(?:\\?|=|&|$)",i=function(o){var e,r;return o&&null!=(e=null==(r=o.match(t))?void 0:r[1])?e:""},p=function(o){return"https://www.youtube.com/embed/"+o},s=/^(?:(?:https?):)?(?:\/\/)?(?:www\.)?(?:(?:dailymotion\.com(?:\/embed)?\/video)|dai\.ly)\/([a-zA-Z0-9]+)(?:_[\w_-]+)?(?:\?playlist=[a-zA-Z0-9]+)?$/,d=function(o){var e,r;return null!=(e=null==(r=o.match(s))?void 0:r[1])?e:""},m=function(o){return"https://www.dailymotion.com/embed/video/"+o},n=/(?:(?:https?):)?(?:\/\/)?(?:embed\.|open\.)(?:spotify\.com\/)(?:(album|track|playlist)\/|\?uri=spotify:track:)((\w|-){22})/,u=/spotify:(?:(album|track|playlist):|\?uri=spotify:track:)((\w|-){22})/,l=function(o){var e=o.match(n)||o.match(u)||[];return[e[2],e[1]]},a=function(o,e){return"https://open.spotify.com/embed/"+e+"/"+o},x=/(?:(?:https?):)?(?:\/\/)?(?:www\.|player\.)?vimeo\.com\/(?:channels\/(?:\w+\/)?|groups\/(?:[^/]*)\/videos\/|video\/|)(\d+)(?:|\/\?)/,v=function(o){var e,r;return null!=(e=null==(r=o.match(x))?void 0:r[1])?e:""},c=function(o){return"https://player.vimeo.com/video/"+o},y=new RegExp("^(?:(?:https?):)?(?://)?[^/]*edpuzzle.com.*[=/]media/([-\\w]+)"),f=function(o){var e,r;return o&&null!=(e=null==(r=o.match(y))?void 0:r[1])?e:""},P=function(o){return"https://edpuzzle.com/embed/media/"+o},b=new RegExp("^(?:(?:https?):)?(?://)?[^/]*(?:wistia.com|wi.st).*[=/](?:medias|embed)/([-\\w]+)"),h=function(o){var e,r;return o&&null!=(e=null==(r=o.match(b))?void 0:r[1])?e:""},w=function(o){return"https://fast.wistia.net/embed/iframe/"+o},g=new RegExp("^(?:(?:https?):)?(?://)?[^/]*loom.com.*[=/]share/([-\\w]+)"),z=function(o){var e,r;return o&&null!=(e=null==(r=o.match(g))?void 0:r[1])?e:""},U=function(o){return"https://www.loom.com/embed/"+o};(r=exports.Provider||(exports.Provider={})).YouTube="YouTube",r.Spotify="Spotify",r.Vimeo="Vimeo",r.DailyMotion="DailyMotion",r.EdPuzzle="EdPuzzle",r.Loom="Loom",r.Wistia="Wistia";var E=function(o){if(o)return o.match(/dailymotion/)?exports.Provider.DailyMotion:o.match(/spotify/)?exports.Provider.Spotify:o.match(/vimeo/)?exports.Provider.Vimeo:o.match(/youtu\.?be/)?exports.Provider.YouTube:o.match(/edpuzzle.com/)?exports.Provider.EdPuzzle:h(o)?exports.Provider.Wistia:z(o)?exports.Provider.Loom:void 0},F=((o={})[exports.Provider.DailyMotion]=d,o[exports.Provider.Spotify]=l,o[exports.Provider.Vimeo]=v,o[exports.Provider.YouTube]=i,o[exports.Provider.EdPuzzle]=f,o[exports.Provider.Loom]=z,o[exports.Provider.Wistia]=h,o),I=((e={})[exports.Provider.DailyMotion]=m,e[exports.Provider.Spotify]=a,e[exports.Provider.Vimeo]=c,e[exports.Provider.YouTube]=p,e[exports.Provider.EdPuzzle]=P,e[exports.Provider.Loom]=U,e[exports.Provider.Wistia]=w,e);exports.ProviderIdFunctionMap=F,exports.ProviderIdUrlFunctionMap=I,exports.convertUrlToEmbedUrl=function(o){var e=E(o);if(!e)return"";var r=I[e],t=(0,F[e])(o);if(Array.isArray(t)){var i=t.shift();return i?r.apply(void 0,[i].concat(t)):""}return r(t)},exports.dailyMotionUrlRegex=s,exports.edPuzzleUrlRegex=y,exports.getDailyMotionEmbedFromId=m,exports.getDailyMotionIdFromUrl=d,exports.getEdPuzzleEmbedUrlFromId=P,exports.getEdPuzzleIdFromUrl=f,exports.getLoomEmbedUrlFromId=U,exports.getLoomIdFromUrl=z,exports.getProviderFromUrl=E,exports.getSpotifyEmbedUrlFromIdAndType=a,exports.getSpotifyIdAndTypeFromUrl=l,exports.getVimeoEmbedUrlFromId=c,exports.getVimeoIdFromUrl=v,exports.getWistiaEmbedUrlFromId=w,exports.getWistiaIdFromUrl=h,exports.getYouTubeEmbedUrlFromId=p,exports.getYouTubeIdFromUrl=i,exports.loomUrlRegex=g,exports.spotifySymbolRegex=u,exports.spotifyUrlRegex=n,exports.vimeoUrlRegex=x,exports.wistiaUrlRegex=b,exports.youTubeUrlRegex=t; | ||
//# sourceMappingURL=lib.cjs.production.min.js.map |
@@ -56,2 +56,130 @@ /** | ||
/** | ||
* Detection and parsing for Edpuzzle URLs | ||
* | ||
* [Edpuzzle's officie embed docs](https://support.edpuzzle.com/hc/en-us/articles/360007260632-Can-I-embed-an-assignment-into-an-LMS-blog-or-website-) | ||
* | ||
* @module providers/edpuzzle | ||
*/ | ||
/** | ||
* Matches ID from URLs matching: https://edpuzzle.com/media/606b413369971e424ec6021e | ||
*/ | ||
var edPuzzleUrlRegex = /*#__PURE__*/new RegExp('^(?:(?:https?):)?(?://)?[^/]*edpuzzle.com.*[=/]media/([-\\w]+)'); | ||
/** | ||
* Return ID from shared link. | ||
* | ||
* @param url Shared URL link. | ||
*/ | ||
var getEdPuzzleIdFromUrl = function getEdPuzzleIdFromUrl(url) { | ||
if (url) { | ||
var _url$match$, _url$match; | ||
return (_url$match$ = (_url$match = url.match(edPuzzleUrlRegex)) == null ? void 0 : _url$match[1]) != null ? _url$match$ : ''; | ||
} | ||
return ''; | ||
}; | ||
/** | ||
* Return embed-friendly URL from ID. | ||
* | ||
* @param edPuzzleId ID of embed | ||
*/ | ||
var getEdPuzzleEmbedUrlFromId = function getEdPuzzleEmbedUrlFromId(edPuzzleId) { | ||
return "https://edpuzzle.com/embed/media/" + edPuzzleId; | ||
}; | ||
/** | ||
* Detecting and parsing for Wistia URLs. | ||
* | ||
* [Wistia's Official embed documentation](https://wistia.com/support/embed-and-share/video-on-your-website) | ||
* [Wistia's Embed building documentation](https://wistia.com/support/developers/construct-an-embed-code) | ||
* | ||
* @module providers/wistia | ||
*/ | ||
/* | ||
<iframe src="//fast.wistia.net/embed/iframe/26sk4lmiix" allowtransparency="true" frameborder="0" scrolling="no" class="wistia_embed" name="wistia_embed" allowfullscreen mozallowfullscreen webkitallowfullscreen oallowfullscreen msallowfullscreen width="620" height="349"></iframe> | ||
<script src="//fast.wistia.net/assets/external/E-v1.js" async></script> | ||
*/ | ||
/** | ||
* Matches ID from URLs matching: | ||
* - https://support.wistia.com/medias/26sk4lmiix | ||
* - https://support.wistia.com/embed/26sk4lmiix | ||
* | ||
* While these are not used, these are mentions on [Wistia's embed construction](https://wistia.com/support/developers/construct-an-embed-code) docs: | ||
* - https://support.wi.st/embed/26sk4lmiix | ||
* - https://support.wi.st/medias/26sk4lmiix | ||
*/ | ||
var wistiaUrlRegex = /*#__PURE__*/new RegExp('^(?:(?:https?):)?(?://)?[^/]*(?:wistia.com|wi.st).*[=/](?:medias|embed)/([-\\w]+)' // '^(?:(?:https?):)?(?://)?[^/]*wistia.com.*[=/]medias/([-\\w]+)' // v1 (handcrafted by Tony) | ||
); | ||
/** | ||
* Return ID from shared link. | ||
* | ||
* @param url Shared URL link. | ||
*/ | ||
var getWistiaIdFromUrl = function getWistiaIdFromUrl(url) { | ||
if (url) { | ||
var _url$match$, _url$match; | ||
return (_url$match$ = (_url$match = url.match(wistiaUrlRegex)) == null ? void 0 : _url$match[1]) != null ? _url$match$ : ''; | ||
} | ||
return ''; | ||
}; | ||
/** | ||
* Return embed-friendly URL from ID. | ||
* | ||
* @param wistiaId ID of embed | ||
*/ | ||
var getWistiaEmbedUrlFromId = function getWistiaEmbedUrlFromId(wistiaId) { | ||
return "https://fast.wistia.net/embed/iframe/" + wistiaId; | ||
}; | ||
/** | ||
* Detecting and parsing for Loom URLs. | ||
* | ||
* [Loom's Official embed documentation](https://www.loom.com/share/e883f70b219a49f6ba7fbeac71a72604) | ||
* | ||
* @module providers/loom | ||
*/ | ||
/* | ||
<div style="position: relative; padding-bottom: 61.224489795918366%; height: 0;"><iframe src="https://www.loom.com/embed/e883f70b219a49f6ba7fbeac71a72604" frameborder="0" webkitallowfullscreen mozallowfullscreen allowfullscreen style="position: absolute; top: 0; left: 0; width: 100%; height: 100%;"></iframe></div> | ||
*/ | ||
/** | ||
* Matches ID from URLs matching: https://www.loom.com/share/e883f70b219a49f6ba7fbeac71a72604 | ||
*/ | ||
var loomUrlRegex = /*#__PURE__*/new RegExp('^(?:(?:https?):)?(?://)?[^/]*loom.com.*[=/]share/([-\\w]+)'); | ||
/** | ||
* Return ID from shared link. | ||
* | ||
* @param url Shared URL link. | ||
*/ | ||
var getLoomIdFromUrl = function getLoomIdFromUrl(url) { | ||
if (url) { | ||
var _url$match$, _url$match; | ||
return (_url$match$ = (_url$match = url.match(loomUrlRegex)) == null ? void 0 : _url$match[1]) != null ? _url$match$ : ''; | ||
} | ||
return ''; | ||
}; | ||
/** | ||
* Return embed-friendly URL from ID. | ||
* | ||
* @param loomId ID of embed | ||
*/ | ||
var getLoomEmbedUrlFromId = function getLoomEmbedUrlFromId(loomId) { | ||
return "https://www.loom.com/embed/" + loomId; | ||
}; | ||
var _ProviderIdFunctionMa, _ProviderIdUrlFunctio; | ||
@@ -65,2 +193,5 @@ var Provider; | ||
Provider["DailyMotion"] = "DailyMotion"; | ||
Provider["EdPuzzle"] = "EdPuzzle"; | ||
Provider["Loom"] = "Loom"; | ||
Provider["Wistia"] = "Wistia"; | ||
})(Provider || (Provider = {})); | ||
@@ -89,6 +220,18 @@ | ||
if (url.match(/edpuzzle.com/)) { | ||
return Provider.EdPuzzle; | ||
} | ||
if (getWistiaIdFromUrl(url)) { | ||
return Provider.Wistia; | ||
} | ||
if (getLoomIdFromUrl(url)) { | ||
return Provider.Loom; | ||
} | ||
return undefined; | ||
}; | ||
var ProviderIdFunctionMap = (_ProviderIdFunctionMa = {}, _ProviderIdFunctionMa[Provider.DailyMotion] = getDailyMotionIdFromUrl, _ProviderIdFunctionMa[Provider.Spotify] = getSpotifyIdAndTypeFromUrl, _ProviderIdFunctionMa[Provider.Vimeo] = getVimeoIdFromUrl, _ProviderIdFunctionMa[Provider.YouTube] = getYouTubeIdFromUrl, _ProviderIdFunctionMa); | ||
var ProviderIdUrlFunctionMap = (_ProviderIdUrlFunctio = {}, _ProviderIdUrlFunctio[Provider.DailyMotion] = getDailyMotionEmbedFromId, _ProviderIdUrlFunctio[Provider.Spotify] = getSpotifyEmbedUrlFromIdAndType, _ProviderIdUrlFunctio[Provider.Vimeo] = getVimeoEmbedUrlFromId, _ProviderIdUrlFunctio[Provider.YouTube] = getYouTubeEmbedUrlFromId, _ProviderIdUrlFunctio); | ||
var ProviderIdFunctionMap = (_ProviderIdFunctionMa = {}, _ProviderIdFunctionMa[Provider.DailyMotion] = getDailyMotionIdFromUrl, _ProviderIdFunctionMa[Provider.Spotify] = getSpotifyIdAndTypeFromUrl, _ProviderIdFunctionMa[Provider.Vimeo] = getVimeoIdFromUrl, _ProviderIdFunctionMa[Provider.YouTube] = getYouTubeIdFromUrl, _ProviderIdFunctionMa[Provider.EdPuzzle] = getEdPuzzleIdFromUrl, _ProviderIdFunctionMa[Provider.Loom] = getLoomIdFromUrl, _ProviderIdFunctionMa[Provider.Wistia] = getWistiaIdFromUrl, _ProviderIdFunctionMa); | ||
var ProviderIdUrlFunctionMap = (_ProviderIdUrlFunctio = {}, _ProviderIdUrlFunctio[Provider.DailyMotion] = getDailyMotionEmbedFromId, _ProviderIdUrlFunctio[Provider.Spotify] = getSpotifyEmbedUrlFromIdAndType, _ProviderIdUrlFunctio[Provider.Vimeo] = getVimeoEmbedUrlFromId, _ProviderIdUrlFunctio[Provider.YouTube] = getYouTubeEmbedUrlFromId, _ProviderIdUrlFunctio[Provider.EdPuzzle] = getEdPuzzleEmbedUrlFromId, _ProviderIdUrlFunctio[Provider.Loom] = getLoomEmbedUrlFromId, _ProviderIdUrlFunctio[Provider.Wistia] = getWistiaEmbedUrlFromId, _ProviderIdUrlFunctio); | ||
var convertUrlToEmbedUrl = function convertUrlToEmbedUrl(url) { | ||
@@ -114,3 +257,3 @@ var provider = getProviderFromUrl(url); | ||
export { Provider, ProviderIdFunctionMap, ProviderIdUrlFunctionMap, convertUrlToEmbedUrl, dailyMotionUrlRegex, getDailyMotionEmbedFromId, getDailyMotionIdFromUrl, getProviderFromUrl, getSpotifyEmbedUrlFromIdAndType, getSpotifyIdAndTypeFromUrl, getVimeoEmbedUrlFromId, getVimeoIdFromUrl, getYouTubeEmbedUrlFromId, getYouTubeIdFromUrl, spotifySymbolRegex, spotifyUrlRegex, vimeoUrlRegex, youTubeUrlRegex }; | ||
export { Provider, ProviderIdFunctionMap, ProviderIdUrlFunctionMap, convertUrlToEmbedUrl, dailyMotionUrlRegex, edPuzzleUrlRegex, getDailyMotionEmbedFromId, getDailyMotionIdFromUrl, getEdPuzzleEmbedUrlFromId, getEdPuzzleIdFromUrl, getLoomEmbedUrlFromId, getLoomIdFromUrl, getProviderFromUrl, getSpotifyEmbedUrlFromIdAndType, getSpotifyIdAndTypeFromUrl, getVimeoEmbedUrlFromId, getVimeoIdFromUrl, getWistiaEmbedUrlFromId, getWistiaIdFromUrl, getYouTubeEmbedUrlFromId, getYouTubeIdFromUrl, loomUrlRegex, spotifySymbolRegex, spotifyUrlRegex, vimeoUrlRegex, wistiaUrlRegex, youTubeUrlRegex }; | ||
//# sourceMappingURL=lib.esm.js.map |
@@ -5,2 +5,5 @@ export * from './youtube'; | ||
export * from './vimeo'; | ||
export * from './edpuzzle'; | ||
export * from './wistia'; | ||
export * from './loom'; | ||
//# sourceMappingURL=index.d.ts.map |
@@ -5,3 +5,6 @@ export declare enum Provider { | ||
Vimeo = "Vimeo", | ||
DailyMotion = "DailyMotion" | ||
DailyMotion = "DailyMotion", | ||
EdPuzzle = "EdPuzzle", | ||
Loom = "Loom", | ||
Wistia = "Wistia" | ||
} | ||
@@ -8,0 +11,0 @@ export declare const getProviderFromUrl: (url: string) => Provider | undefined; |
{ | ||
"name": "@social-embed/lib", | ||
"description": "Regexes, ID extraction, for embed providers (YouTube, other OEmbed compatible providers),", | ||
"version": "0.0.1-next.10", | ||
"version": "0.0.1-next.11", | ||
"main": "dist/index.js", | ||
@@ -34,8 +34,5 @@ "module": "dist/lib.esm.js", | ||
"test": "tsdx test", | ||
"docs": "yarn typedoc src/index.ts", | ||
"docs:serve": "python -m http.server --directory docs 8082", | ||
"lint": "eslint src", | ||
"ncu": "ncu", | ||
"update": "ncu", | ||
"typedoc": "typedoc" | ||
"update": "ncu" | ||
}, | ||
@@ -45,5 +42,4 @@ "devDependencies": { | ||
"prettier": "^2.2.1", | ||
"tsdx": "^0.14.1", | ||
"typedoc": "^0.20.34" | ||
"tsdx": "^0.14.1" | ||
} | ||
} |
@@ -5,1 +5,4 @@ export * from './youtube'; | ||
export * from './vimeo'; | ||
export * from './edpuzzle'; | ||
export * from './wistia'; | ||
export * from './loom'; |
@@ -5,2 +5,5 @@ import * as YouTube from './providers/youtube'; | ||
import * as DailyMotion from './providers/dailymotion'; | ||
import * as EdPuzzle from './providers/edpuzzle'; | ||
import * as Loom from './providers/loom'; | ||
import * as Wistia from './providers/wistia'; | ||
@@ -12,2 +15,5 @@ export enum Provider { | ||
DailyMotion = 'DailyMotion', | ||
EdPuzzle = 'EdPuzzle', | ||
Loom = 'Loom', | ||
Wistia = 'Wistia', | ||
} | ||
@@ -31,2 +37,11 @@ | ||
} | ||
if (url.match(/edpuzzle.com/)) { | ||
return Provider.EdPuzzle; | ||
} | ||
if (Wistia.getWistiaIdFromUrl(url)) { | ||
return Provider.Wistia; | ||
} | ||
if (Loom.getLoomIdFromUrl(url)) { | ||
return Provider.Loom; | ||
} | ||
return undefined; | ||
@@ -46,2 +61,5 @@ }; | ||
[Provider.YouTube]: YouTube.getYouTubeIdFromUrl, | ||
[Provider.EdPuzzle]: EdPuzzle.getEdPuzzleIdFromUrl, | ||
[Provider.Loom]: Loom.getLoomIdFromUrl, | ||
[Provider.Wistia]: Wistia.getWistiaIdFromUrl, | ||
}; | ||
@@ -56,2 +74,5 @@ | ||
[Provider.YouTube]: YouTube.getYouTubeEmbedUrlFromId, | ||
[Provider.EdPuzzle]: EdPuzzle.getEdPuzzleEmbedUrlFromId, | ||
[Provider.Loom]: Loom.getLoomEmbedUrlFromId, | ||
[Provider.Wistia]: Wistia.getWistiaEmbedUrlFromId, | ||
}; | ||
@@ -58,0 +79,0 @@ |
@@ -22,3 +22,3 @@ { | ||
"include": ["src/**/*.ts"], | ||
"exclude": [] | ||
"exclude": ["test/**"] | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
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
86620
3
41
881
0