Apply linter
This commit is contained in:
@@ -155,15 +155,15 @@
|
|||||||
const padding = {width:pw, height:ph ?? pw}
|
const padding = {width:pw, height:ph ?? pw}
|
||||||
console.debug(`metrics/svg/resize > padding width*${padding.width}, height*${padding.height}`)
|
console.debug(`metrics/svg/resize > padding width*${padding.width}, height*${padding.height}`)
|
||||||
//Render through browser and resize height
|
//Render through browser and resize height
|
||||||
console.debug(`metrics/svg/resize > loading svg`)
|
console.debug("metrics/svg/resize > loading svg")
|
||||||
const page = await svg.resize.browser.newPage()
|
const page = await svg.resize.browser.newPage()
|
||||||
page.on("console", ({_text:text}) => console.debug(`metrics/svg/resize > puppeteer > ${text}`))
|
page.on("console", ({_text:text}) => console.debug(`metrics/svg/resize > puppeteer > ${text}`))
|
||||||
await page.setContent(rendered, {waitUntil:["load", "domcontentloaded", "networkidle2"]})
|
await page.setContent(rendered, {waitUntil:["load", "domcontentloaded", "networkidle2"]})
|
||||||
console.debug(`metrics/svg/resize > loaded svg successfully`)
|
console.debug("metrics/svg/resize > loaded svg successfully")
|
||||||
await page.addStyleTag({content:"body { margin: 0; padding: 0; }"})
|
await page.addStyleTag({content:"body { margin: 0; padding: 0; }"})
|
||||||
let mime = "image/svg+xml"
|
let mime = "image/svg+xml"
|
||||||
console.debug(`metrics/svg/resize > resizing svg`)
|
console.debug("metrics/svg/resize > resizing svg")
|
||||||
let resized, width, height
|
let height, resized, width
|
||||||
try {
|
try {
|
||||||
({resized, width, height} = await page.evaluate(async padding => {
|
({resized, width, height} = await page.evaluate(async padding => {
|
||||||
//Disable animations
|
//Disable animations
|
||||||
@@ -171,7 +171,7 @@
|
|||||||
if (animated)
|
if (animated)
|
||||||
document.querySelector("svg").classList.add("no-animations")
|
document.querySelector("svg").classList.add("no-animations")
|
||||||
console.debug(`animations are ${animated ? "enabled" : "disabled"}`)
|
console.debug(`animations are ${animated ? "enabled" : "disabled"}`)
|
||||||
await new Promise(solve => setTimeout(solve, 2400))
|
await new Promise(solve => setTimeout(solve, 2400)) //eslint-disable-line no-promise-executor-return
|
||||||
//Get bounds and resize
|
//Get bounds and resize
|
||||||
let {y:height, width} = document.querySelector("svg #metrics-end").getBoundingClientRect()
|
let {y:height, width} = document.querySelector("svg #metrics-end").getBoundingClientRect()
|
||||||
console.debug(`bounds width=${width}, height=${height}`)
|
console.debug(`bounds width=${width}, height=${height}`)
|
||||||
@@ -200,7 +200,7 @@
|
|||||||
}
|
}
|
||||||
//Result
|
//Result
|
||||||
await page.close()
|
await page.close()
|
||||||
console.debug(`metrics/svg/resize > rendering complete`)
|
console.debug("metrics/svg/resize > rendering complete")
|
||||||
return {resized, mime}
|
return {resized, mime}
|
||||||
},
|
},
|
||||||
/**Render twemojis */
|
/**Render twemojis */
|
||||||
|
|||||||
Reference in New Issue
Block a user