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

@loomhq/loom-embed

Package Overview
Dependencies
Maintainers
61
Versions
41
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@loomhq/loom-embed - npm Package Compare versions

Comparing version 1.2.5 to 1.2.6

4

dist/.types/oembed.d.ts

@@ -9,4 +9,4 @@ interface Option {

title: string;
height: number;
width: number;
height: number | null;
width: number | null;
provider_name: 'Loom';

@@ -13,0 +13,0 @@ provider_url: string;

@@ -11,6 +11,19 @@ "use strict";

const iframeStyles = 'position: absolute; top: 0; left: 0; width: 100%; height: 100%;';
return (`<div class="lo-emb-vid" style="${wrapperStyles}"><iframe src="${embedURL}" ` +
'frameborder="0" webkitallowfullscreen mozallowfullscreen ' +
`allowfullscreen style="${iframeStyles}"></iframe></div>`);
const staticAttributes = 'frameborder="0" webkitallowfullscreen mozallowfullscreen allowfullscreen';
return `
<div class="lo-emb-vid" style="${wrapperStyles}">
<iframe src="${embedURL}" style="${iframeStyles}" ${staticAttributes}></iframe>
</div>`
.split('\n')
.map(s => s.trim())
.join('');
};
const chooseAspectRatio = (data) => {
const { width, height } = data;
// Fallback to 16:9 ratio when width or height is null
if (width == null || height == null) {
return 1080 / 1920;
}
return height / width;
};
const enhanceEmbedCode = (videoData, options) => {

@@ -20,6 +33,5 @@ // If needed, we alter the embed code to

const { width, height } = options;
const { width: videoWidth, height: videoHeight } = videoData;
if (!width && !height) {
const [, embedUrl] = videoData.html.match(SRC_URL_REGEX);
const aspectRatio = videoHeight / videoWidth;
const aspectRatio = chooseAspectRatio(videoData);
return Object.assign(Object.assign({}, videoData), { html: getResponsiveEmbedCode(embedUrl, aspectRatio) });

@@ -26,0 +38,0 @@ }

@@ -34,3 +34,3 @@ "use strict";

const result = yield oembed_1.oembed('https://www.loom.com/share/0281766fa2d04bb788eaf19e65135184');
expect(result).toEqual(Object.assign(Object.assign({}, oembedProperties), { html: '<div class="lo-emb-vid" style="position: relative; padding-bottom: 100%; height: 0;"><iframe src="https://www.loom.com/embed/0281766fa2d04bb788eaf19e65135184" frameborder="0" webkitallowfullscreen mozallowfullscreen allowfullscreen style="position: absolute; top: 0; left: 0; width: 100%; height: 100%;"></iframe></div>' }));
expect(result).toEqual(Object.assign(Object.assign({}, oembedProperties), { html: '<div class="lo-emb-vid" style="position: relative; padding-bottom: 100%; height: 0;"><iframe src="https://www.loom.com/embed/0281766fa2d04bb788eaf19e65135184" style="position: absolute; top: 0; left: 0; width: 100%; height: 100%;" frameborder="0" webkitallowfullscreen mozallowfullscreen allowfullscreen></iframe></div>' }));
}));

@@ -37,0 +37,0 @@ test('wth options', () => __awaiter(void 0, void 0, void 0, function* () {

@@ -8,6 +8,19 @@ import { isValidEmbedUrl } from './validate';

const iframeStyles = 'position: absolute; top: 0; left: 0; width: 100%; height: 100%;';
return (`<div class="lo-emb-vid" style="${wrapperStyles}"><iframe src="${embedURL}" ` +
'frameborder="0" webkitallowfullscreen mozallowfullscreen ' +
`allowfullscreen style="${iframeStyles}"></iframe></div>`);
const staticAttributes = 'frameborder="0" webkitallowfullscreen mozallowfullscreen allowfullscreen';
return `
<div class="lo-emb-vid" style="${wrapperStyles}">
<iframe src="${embedURL}" style="${iframeStyles}" ${staticAttributes}></iframe>
</div>`
.split('\n')
.map(s => s.trim())
.join('');
};
const chooseAspectRatio = (data) => {
const { width, height } = data;
// Fallback to 16:9 ratio when width or height is null
if (width == null || height == null) {
return 1080 / 1920;
}
return height / width;
};
const enhanceEmbedCode = (videoData, options) => {

@@ -17,6 +30,5 @@ // If needed, we alter the embed code to

const { width, height } = options;
const { width: videoWidth, height: videoHeight } = videoData;
if (!width && !height) {
const [, embedUrl] = videoData.html.match(SRC_URL_REGEX);
const aspectRatio = videoHeight / videoWidth;
const aspectRatio = chooseAspectRatio(videoData);
return Object.assign(Object.assign({}, videoData), { html: getResponsiveEmbedCode(embedUrl, aspectRatio) });

@@ -23,0 +35,0 @@ }

@@ -32,3 +32,3 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {

const result = yield oembed('https://www.loom.com/share/0281766fa2d04bb788eaf19e65135184');
expect(result).toEqual(Object.assign(Object.assign({}, oembedProperties), { html: '<div class="lo-emb-vid" style="position: relative; padding-bottom: 100%; height: 0;"><iframe src="https://www.loom.com/embed/0281766fa2d04bb788eaf19e65135184" frameborder="0" webkitallowfullscreen mozallowfullscreen allowfullscreen style="position: absolute; top: 0; left: 0; width: 100%; height: 100%;"></iframe></div>' }));
expect(result).toEqual(Object.assign(Object.assign({}, oembedProperties), { html: '<div class="lo-emb-vid" style="position: relative; padding-bottom: 100%; height: 0;"><iframe src="https://www.loom.com/embed/0281766fa2d04bb788eaf19e65135184" style="position: absolute; top: 0; left: 0; width: 100%; height: 100%;" frameborder="0" webkitallowfullscreen mozallowfullscreen allowfullscreen></iframe></div>' }));
}));

@@ -35,0 +35,0 @@ test('wth options', () => __awaiter(void 0, void 0, void 0, function* () {

{
"name": "@loomhq/loom-embed",
"version": "1.2.5",
"version": "1.2.6",
"description": "SDK for easily embedding videos",

@@ -5,0 +5,0 @@ "main": "dist/cjs/index.js",

SocketSocket SOC 2 Logo

Product

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

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc