chore: create version 3.26-beta and upgrade dependencies
This commit is contained in:
@@ -95,7 +95,7 @@ Below is a list of used packages.
|
||||
* To render SVG images
|
||||
* [ptarjan/node-cache](https://github.com/ptarjan/node-cache)
|
||||
* To cache generated content
|
||||
* [oliver-moran/jimp](https://github.com/oliver-moran/jimp), [foliojs/png.js](https://github.com/foliojs/png.js) and [eugeneware/gifencoder](https://github.com/eugeneware/gifencoder)
|
||||
* [lovell/sharp](https://github.com/lovell/sharp), [foliojs/png.js](https://github.com/foliojs/png.js) and [eugeneware/gifencoder](https://github.com/eugeneware/gifencoder)
|
||||
* To process images transformations
|
||||
* [svg/svgo](https://github.com/svg/svgo)
|
||||
* To optimize generated SVG
|
||||
|
||||
3131
package-lock.json
generated
3131
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
16
package.json
16
package.json
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "metrics",
|
||||
"version": "3.25.0",
|
||||
"version": "3.26.0-beta",
|
||||
"description": "An infographics generator with 40+ plugins and 200+ options to display stats about your GitHub account and render them as SVG, Markdown, PDF or JSON!",
|
||||
"main": "index.mjs",
|
||||
"scripts": {
|
||||
@@ -34,7 +34,7 @@
|
||||
"@faker-js/faker": "^7.3.0",
|
||||
"@octokit/graphql": "^4.8.0",
|
||||
"@octokit/rest": "^18.12.0",
|
||||
"@primer/css": "^20.2.3",
|
||||
"@primer/css": "^20.2.4",
|
||||
"@primer/octicons": "^17.3.0",
|
||||
"axios": "^0.27.2",
|
||||
"clipboard": "^2.0.11",
|
||||
@@ -44,9 +44,9 @@
|
||||
"emoji-name-map": "^1.2.9",
|
||||
"express": "^4.18.1",
|
||||
"express-rate-limit": "^6.4.0",
|
||||
"jimp": "^0.16.1",
|
||||
"file-type": "^17.1.2",
|
||||
"js-yaml": "^4.1.0",
|
||||
"linguist-js": "^2.5.0",
|
||||
"linguist-js": "^2.5.2",
|
||||
"marked": "^4.0.17",
|
||||
"memory-cache": "^0.2.0",
|
||||
"minimatch": "^5.1.0",
|
||||
@@ -55,11 +55,12 @@
|
||||
"open-graph-scraper": "^4.11.1",
|
||||
"png-js": "^1.0.0",
|
||||
"prismjs": "^1.28.0",
|
||||
"puppeteer": "^15.0.2",
|
||||
"puppeteer": "^15.3.0",
|
||||
"purgecss": "^4.1.3",
|
||||
"rss-parser": "^3.12.0",
|
||||
"sanitize-html": "^2.7.0",
|
||||
"simple-git": "^3.9.0",
|
||||
"sharp": "^0.30.7",
|
||||
"simple-git": "^3.10.0",
|
||||
"svgo": "^2.8.0",
|
||||
"twemoji-parser": "^14.0.0",
|
||||
"vue": "^2.6.14",
|
||||
@@ -69,8 +70,7 @@
|
||||
"devDependencies": {
|
||||
"eslint": "^8.18.0",
|
||||
"jest": "^28.1.1",
|
||||
"libxmljs2": "^0.30.1",
|
||||
"nodemon": "^2.0.18"
|
||||
"libxmljs2": "^0.30.1"
|
||||
},
|
||||
"jest": {
|
||||
"testEnvironment": "node",
|
||||
|
||||
@@ -7,7 +7,7 @@ import { minify as csso } from "csso"
|
||||
import emoji from "emoji-name-map"
|
||||
import fss from "fs"
|
||||
import fs from "fs/promises"
|
||||
import jimp from "jimp"
|
||||
import sharp from "sharp"
|
||||
import linguist from "linguist-js"
|
||||
import { marked } from "marked"
|
||||
import minimatch from "minimatch"
|
||||
@@ -30,10 +30,11 @@ import twemojis from "twemoji-parser"
|
||||
import url from "url"
|
||||
import util from "util"
|
||||
import xmlformat from "xml-formatter"
|
||||
import {fileTypeFromBuffer} from "file-type"
|
||||
prism_lang()
|
||||
|
||||
//Exports
|
||||
export { axios, emoji, fetch, fs, git, jimp, minimatch, opengraph, os, paths, processes, rss, url, util }
|
||||
export { axios, emoji, fetch, fs, git, sharp, minimatch, opengraph, os, paths, processes, rss, url, util }
|
||||
|
||||
/**Returns module __dirname */
|
||||
export function __module(module) {
|
||||
@@ -330,21 +331,23 @@ export async function imgb64(image, {width, height, fallback = true} = {}) {
|
||||
if (!image)
|
||||
return fallback ? "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mOcOnfpfwAGfgLYttYINwAAAABJRU5ErkJggg==" : null
|
||||
//Load image
|
||||
let ext = "png"
|
||||
try {
|
||||
//Fix: redirections are not properly supported by jimp (https://github.com/oliver-moran/jimp/issues/909), seems to occur only when in jest environment
|
||||
if ((typeof image === "string") && ((process.env.JEST_WORKER_ID) || (process.env.METRICS_MOCKED))) {
|
||||
image = (await axios.get(image)).then(response => response.request.responseURL).catch(() => null)
|
||||
console.debug(`metrics/svg/imgb64 > redirected image link to ${image}`)
|
||||
if (image.startsWith("http://") || image.startsWith("https://")) {
|
||||
const buffer = Buffer.from(await fetch(image).then(response => response.arrayBuffer()))
|
||||
ext = (await fileTypeFromBuffer(buffer)).ext ?? ext
|
||||
image = sharp(buffer)
|
||||
}
|
||||
image = await jimp.read(image)
|
||||
else
|
||||
image = sharp(image)
|
||||
}
|
||||
catch {
|
||||
return null
|
||||
return imgb64(null, {fallback})
|
||||
}
|
||||
//Resize image
|
||||
if ((width) && (height))
|
||||
image = image.resize(width, height)
|
||||
return image.getBase64Async(jimp.AUTO)
|
||||
return `data:image/${ext};base64,${(await image.toBuffer()).toString("base64")}`
|
||||
}
|
||||
|
||||
/**SVG utils */
|
||||
@@ -633,7 +636,7 @@ export async function record({page, width, height, frames, scale = 1, quality =
|
||||
console.debug(`metrics/record > processed ${frames}/${frames} frames`)
|
||||
//Post-processing
|
||||
console.debug("metrics/record > applying post-processing")
|
||||
return Promise.all(images.map(async buffer => (await jimp.read(buffer)).scale(scale).quality(quality).getBase64Async("image/png")))
|
||||
return Promise.all(images.map(async buffer => `data:image/png;base64,${(await (sharp(buffer).resize({width:Math.round(width*scale), height:Math.round(height*scale)}).png({quality}).toBuffer())).toString("base64")}`))
|
||||
}
|
||||
|
||||
/**Create gif from puppeteer browser*/
|
||||
|
||||
@@ -585,6 +585,6 @@
|
||||
<!-- Scripts -->
|
||||
<script src="/.js/axios.min.js"></script>
|
||||
<script src="/.js/vue.min.js"></script>
|
||||
<script src="/about/.statics/script.js?v=3.25"></script>
|
||||
<script src="/about/.statics/script.js?v=3.26"></script>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
@@ -201,7 +201,7 @@
|
||||
<script src="/.js/vue.min.js"></script>
|
||||
<script src="/.js/vue.prism.min.js"></script>
|
||||
<script src="/.js/clipboard.min.js"></script>
|
||||
<script src="/.js/app.placeholder.js?v=3.25"></script>
|
||||
<script src="/.js/app.js?v=3.25"></script>
|
||||
<script src="/.js/app.placeholder.js?v=3.26"></script>
|
||||
<script src="/.js/app.js?v=3.26"></script>
|
||||
</body>
|
||||
</html>
|
||||
@@ -28,11 +28,12 @@ export default async function({login, q, imports, data, account}, {enabled = fal
|
||||
}, selector)
|
||||
console.debug(`metrics/compute/${login}/plugins > screenshot > coordinates ${JSON.stringify(clip)}`)
|
||||
const [buffer] = await imports.record({page, ...clip, frames: 1, background})
|
||||
const screenshot = await (await imports.jimp.read(Buffer.from(buffer.split(",").pop(), "base64"))).resize(Math.min(454 * (1 + data.large), clip.width), imports.jimp.AUTO)
|
||||
const screenshot = await imports.sharp(Buffer.from(buffer.split(",").pop(), "base64")).resize({width:Math.min(454 * (1 + data.large), clip.width)})
|
||||
const metadata = await screenshot.metadata()
|
||||
await browser.close()
|
||||
|
||||
//Results
|
||||
return {image: await screenshot.getBase64Async("image/png"), title, height: screenshot.bitmap.height, width: screenshot.bitmap.width, url}
|
||||
return {image: `data:image/png;base64,${(await screenshot.toBuffer()).toString("base64")}`, title, height: metadata.height, width: metadata.width, url}
|
||||
}
|
||||
//Handle errors
|
||||
catch (error) {
|
||||
|
||||
Reference in New Issue
Block a user