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

@kaciras-blog/media

Package Overview
Dependencies
Maintainers
0
Versions
27
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@kaciras-blog/media - npm Package Compare versions

Comparing version 2.6.2 to 2.6.3

4

lib/command/build-cache.js

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

import * as consumers from "stream/consumers";
import { join, parse } from "path";
import { Presets, SingleBar } from "cli-progress";
import { LocalFileStore, RasterOptimizer, SVGOptimizer } from "../index.js";
import { bodyToBuffer } from "../common.js";
const parameters = {};

@@ -30,3 +30,3 @@ const theme = Presets.shades_classic;

}
const buffer = await bodyToBuffer(file.data);
const buffer = await consumers.buffer(file.data);
/*

@@ -33,0 +33,0 @@ * 优化器出异常可能导致生成部分缓存,且外部难以判断是否成功。

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

import * as consumers from "stream/consumers";
import { join, parse } from "path";
import { Presets, SingleBar } from "cli-progress";
import { LocalFileStore, RasterOptimizer, SVGOptimizer } from "../index.js";
import { bodyToBuffer } from "../common.js";

@@ -42,3 +42,3 @@ const parameters = {};

}
const buffer = await bodyToBuffer(file.data);
const buffer = await consumers.buffer(file.data);

@@ -45,0 +45,0 @@ /*

@@ -35,20 +35,2 @@ import { xxHash3_128 } from "@kaciras-blog/nativelib";

}
/**
* 将 FileBody 的多种数据类型类型统一转换为 Buffer。如果是字符串则使用 UTF-8 解码。
*/
export async function bodyToBuffer(body) {
if (typeof body === "string") {
return Buffer.from(body);
}
else if (Buffer.isBuffer(body)) {
return body;
}
// NodeJS 16+ 新出的模块:
// return import("stream/consumers").buffer(body);
const chunks = [];
for await (const chunk of body) {
chunks.push(chunk);
}
return Buffer.concat(chunks);
}
//# sourceMappingURL=common.js.map
import { xxHash3_128 } from "@kaciras-blog/nativelib";
import { FileBody } from "./FileStore.js";

@@ -37,20 +36,1 @@ /**

}
/**
* 将 FileBody 的多种数据类型类型统一转换为 Buffer。如果是字符串则使用 UTF-8 解码。
*/
export async function bodyToBuffer(body: FileBody) {
if (typeof body === "string") {
return Buffer.from(body);
} else if (Buffer.isBuffer(body)) {
return body;
}
// NodeJS 16+ 新出的模块:
// return import("stream/consumers").buffer(body);
const chunks = [];
for await (const chunk of body) {
chunks.push(chunk);
}
return Buffer.concat(chunks as Buffer[]);
}

@@ -11,2 +11,7 @@ import sharp from "sharp";

};
const WebPLossless = {
quality: 99,
effort: 6,
lossless: true,
};
/**

@@ -43,3 +48,3 @@ * 判断图片数据是否是 GIF 格式,GIF 图片的前三字节为 GIF 这仨字。

input.webp(WebPLossy).toBuffer(),
input.webp({ lossless: true }).toBuffer(),
input.webp(WebPLossless).toBuffer(),
]);

@@ -46,0 +51,0 @@ const [lossy, lossless] = await task.catch(BadDataError.convert);

@@ -13,2 +13,8 @@ import sharp, { WebpOptions } from "sharp";

const WebPLossless: WebpOptions = {
quality: 99,
effort: 6,
lossless: true,
};
/**

@@ -46,3 +52,3 @@ * 判断图片数据是否是 GIF 格式,GIF 图片的前三字节为 GIF 这仨字。

input.webp(WebPLossy).toBuffer(),
input.webp({ lossless: true }).toBuffer(),
input.webp(WebPLossless).toBuffer(),
]);

@@ -49,0 +55,0 @@

@@ -15,3 +15,3 @@ import sharp, { Metadata, Sharp, Stats } from "sharp";

const metadata = await image.metadata().catch(BadDataError.convert);
return [metadata, stats] as [Metadata, Stats];
return [metadata, stats] as const;
}

@@ -18,0 +18,0 @@

@@ -1,2 +0,2 @@

import zlib from "zlib";
import { brotliCompress, gzip } from "zlib";
import { promisify } from "util";

@@ -6,4 +6,4 @@ import { optimize } from "svgo";

const algorithms = {
gzip: promisify(zlib.gzip),
br: promisify(zlib.brotliCompress),
gzip: promisify(gzip),
br: promisify(brotliCompress),
};

@@ -54,4 +54,3 @@ const THRESHOLD = 2048;

const { acceptEncodings } = request;
const encodings = ENCODINGS
.filter(e => acceptEncodings.includes(e));
const encodings = ENCODINGS.filter(e => acceptEncodings.includes(e));
return [...encodings, undefined]

@@ -58,0 +57,0 @@ .map(e => items.find(i => i.encoding === e))

@@ -1,2 +0,2 @@

import zlib, { InputType } from "zlib";
import { brotliCompress, gzip, InputType } from "zlib";
import { promisify } from "util";

@@ -9,4 +9,4 @@ import { Config, optimize } from "svgo";

const algorithms = {
gzip: promisify<InputType, Buffer>(zlib.gzip),
br: promisify<InputType, Buffer>(zlib.brotliCompress),
gzip: promisify<InputType, Buffer>(gzip),
br: promisify<InputType, Buffer>(brotliCompress),
};

@@ -69,4 +69,3 @@

const encodings = ENCODINGS
.filter(e => acceptEncodings.includes(e as any));
const encodings = ENCODINGS.filter(e => acceptEncodings.includes(e));

@@ -73,0 +72,0 @@ return [...encodings, undefined]

{
"name": "@kaciras-blog/media",
"version": "2.6.2",
"version": "2.6.3",
"description": "Media processor for Kaciras Blog",

@@ -22,19 +22,19 @@ "license": "MIT",

"@kaciras-blog/nativelib": "^0.3.2",
"@kaciras/utilities": "^1.0.0",
"@kaciras/utilities": "^1.0.3",
"cli-progress": "^3.12.0",
"execa": "^9.2.0",
"execa": "^9.3.1",
"gifsicle": "^7.0.1",
"log4js": "^6.9.1",
"mozjpeg": "^8.0.0",
"sharp": "^0.33.4",
"simple-statistics": "^7.8.3",
"sharp": "^0.33.5",
"simple-statistics": "^7.8.5",
"svgo": "^3.3.2"
},
"devDependencies": {
"@types/cli-progress": "^3.11.5",
"@types/cli-progress": "^3.11.6",
"@types/gifsicle": "^5.2.2",
"@types/mime-types": "^2.1.4",
"@types/mozjpeg": "^5.0.2",
"file-type": "^19.0.0"
"file-type": "^19.4.1"
}
}

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

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