Socket
Socket
Sign inDemoInstall

@vonage/vvd-fonts

Package Overview
Dependencies
Maintainers
19
Versions
124
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@vonage/vvd-fonts - npm Package Compare versions

Comparing version 2.13.0 to 2.14.0

9

package.json
{
"name": "@vonage/vvd-fonts",
"version": "2.13.0",
"version": "2.14.0",
"description": "Vivid fonts initialisation service",

@@ -31,10 +31,11 @@ "homepage": "https://github.com/Vonage/vivid/tree/master/common/fonts",

"lit-element": "^2.4.0",
"ramda": "^0.27.1",
"tslib": "^2.3.0"
},
"devDependencies": {
"@vonage/vvd-foundation": "2.13.0",
"@vonage/vvd-umbrella": "2.13.0",
"@vonage/vvd-foundation": "2.14.0",
"@vonage/vvd-umbrella": "2.14.0",
"typescript": "^4.3.2"
},
"gitHead": "8a1e11c4ec32b43256abe393ddc76a4cdb40e41f"
"gitHead": "2b854786ed0a192d8f22c5124bdc0af87d151409"
}

@@ -16,5 +16,5 @@ ### Vivid Fonts

```javascript
import fonts from '@vonage/vvd-fonts';
import { init } from '@vonage/vvd-fonts';
...
fonts.init().then(() =>
init().then(() =>
// do post init stuff here

@@ -21,0 +21,0 @@ );

@@ -1,5 +0,1 @@

declare const _default: Readonly<{
init: typeof init;
}>;
export default _default;
declare function init(): Promise<Record<string, unknown>>;
export declare const init: () => Promise<boolean>;

@@ -1,67 +0,17 @@

export default Object.freeze({
init: init,
import { once, always } from 'ramda';
export const init = once(function () {
return import('./vvd-fonts.css.js')
.then(({ style: { cssText } }) => {
document
.querySelectorAll('head')
.forEach((headEl) => {
headEl.appendChild((function () {
const styleEl = document.createElement('style');
styleEl.innerHTML = cssText;
return styleEl;
})());
});
})
.then(always(true));
});
const READY_PROMISE_TIMEOUT = 12000;
let INIT_PROMISE = null;
async function init() {
if (!INIT_PROMISE) {
INIT_PROMISE = new Promise((resolve, reject) => {
// console.info('Vivid Fonts initialization start...');
// const st = performance.now();
const testElements = setupInitTestElements();
import('./vvd-fonts.css.js')
.then((cssDefs) => {
const ds = document.createElement('style');
ds.innerHTML = cssDefs.style.cssText;
document.head.appendChild(ds);
return ensureInit(testElements);
})
.then(resolve)
.catch(reject)
.finally(() => {
cleanInitTestElements(testElements);
// console.info(
// `Vivid Fonts initialization took ${Math.floor(performance.now() - st)}ms`
// );
});
});
}
return INIT_PROMISE;
}
function setupInitTestElements() {
const result = ['var(--vvd-font-family-spezia)', 'initial'].map((ff) => {
const e = document.createElement('span');
e.textContent = 'testing text to measure font appliance';
e.style.cssText = `position:absolute;top:-999px;font-family:${ff}`;
return e;
});
if (document.body) {
result.forEach(e => document.body.appendChild(e));
}
else {
document.addEventListener('DOMContentLoaded', () => result.forEach(e => document.body.appendChild(e)), { once: true });
}
return result;
}
async function ensureInit(testElements) {
return new Promise((resolve, reject) => {
const pollStart = Date.now();
let pollDuration;
function innerTest() {
if (testElements[0].offsetWidth !== testElements[1].offsetWidth) {
resolve({});
}
else if ((pollDuration = Date.now() - pollStart) > READY_PROMISE_TIMEOUT) {
reject(new Error(`fonts init timed out after ${pollDuration}ms`));
}
else {
setTimeout(innerTest, 25);
}
}
innerTest();
});
}
function cleanInitTestElements(testElements) {
testElements.forEach(e => e.remove());
}
//# sourceMappingURL=vvd-fonts.js.map

Sorry, the diff of this file is not supported yet

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