From f17ebd975a381bce0f21c92c0c822d97253ab7a6 Mon Sep 17 00:00:00 2001 From: Nikola Hristov Date: Sat, 25 Feb 2023 15:30:45 +0200 Subject: [PATCH] 1.1.34 --- CHANGELOG.md | 4 ++++ dist/index.js | 2 +- dist/lib/sharp-read.d.ts | 4 ++-- package.json | 4 ++-- src/index.ts | 4 ++-- src/lib/sharp-read.ts | 10 +++++----- 6 files changed, 16 insertions(+), 12 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index a1bc2e3d..d8eaf04f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,7 @@ +## 1.1.34 + +- Updates files-pipeline component + ## 1.1.33 - Process scripts enhancement diff --git a/dist/index.js b/dist/index.js index e185ee4b..cdb85999 100644 --- a/dist/index.js +++ b/dist/index.js @@ -1 +1 @@ -import n from"./lib/format-bytes.js";import o from"files-pipeline/dist/lib/deepmerge.js";import c from"files-pipeline/dist/options/index.js";import m from"./options/index.js";import{files as l}from"files-pipeline";import{minify as d}from"csso";import{minify as h}from"html-minifier-terser";import p from"sharp";import{optimize as y}from"svgo";import{minify as w}from"terser";import b from"./lib/sharp-read.js";var R=(t={})=>{for(const r in t)Object.prototype.hasOwnProperty.call(t,r)&&t[r]===!0&&(t[r]=m[r]);t=o(m,t);const i=new Set;if(typeof t.path<"u"&&(t.path instanceof Array||t.path instanceof Set))for(const r of t.path)i.add(r);return{name:"astro-compress",hooks:{"astro:build:done":async({dir:r})=>{i.size||i.add(r);for(const[s,f]of Object.entries(t))if(f)for(const u of i)await(await(await(await new l(t.logger).in(u)).by(typeof t.map=="object"?t.map[s]:"")).not(t.exclude)).pipeline(o(t.pipeline,{wrote:async e=>{switch(s){case"css":return d(e.buffer.toString(),f).css;case"html":return await h(e.buffer.toString(),f);case"js":{const{code:a}=await w(e.buffer.toString(),f);return a||e.buffer}case"img":return b(f,e);case"svg":{const{data:a}=y(e.buffer.toString(),f);return typeof a<"u"?a:e.buffer}default:return e.buffer}},read:async e=>{switch(s){case"img":{const{format:a}=await p(e.inputPath).metadata();return p(e.inputPath,{failOn:"none",sequentialRead:!0,unlimited:!0,animated:a==="webp"||a==="gif"})}default:return await c.pipeline.read(e)}},fulfilled:async e=>e.files>0?`Successfully compressed a total of ${e.files} ${s.toUpperCase()} ${e.files===1?"file":"files"} for ${await n(e.info.total)}.`:!1}))}}}};export{R as default}; +import u from"./lib/format-bytes.js";import o from"files-pipeline/dist/lib/deepmerge.js";import c from"files-pipeline/dist/options/index.js";import m from"./options/index.js";import{files as l}from"files-pipeline";import{minify as d}from"csso";import{minify as h}from"html-minifier-terser";import p from"sharp";import{optimize as y}from"svgo";import{minify as w}from"terser";import b from"./lib/sharp-read.js";var I=(t={})=>{for(const r in t)Object.prototype.hasOwnProperty.call(t,r)&&t[r]===!0&&(t[r]=m[r]);t=o(m,t);const f=new Set;if(typeof t.path<"u"&&(t.path instanceof Array||t.path instanceof Set))for(const r of t.path)f.add(r);return{name:"astro-compress",hooks:{"astro:build:done":async({dir:r})=>{f.size||f.add(r);for(const[s,i]of Object.entries(t))if(i)for(const n of f)await(await(await(await new l(t.logger).in(n)).by(typeof t.map=="object"?t.map[s]:"")).not(t.exclude)).pipeline(o(t.pipeline,{wrote:async e=>{switch(s){case"css":return d(e.buffer.toString(),i).css;case"html":return await h(e.buffer.toString(),i);case"js":{const{code:a}=await w(e.buffer.toString(),i);return a||e.buffer}case"img":return b(i,e);case"svg":{const{data:a}=y(e.buffer.toString(),i);return typeof a<"u"?a:e.buffer}default:return e.buffer}},read:async e=>{switch(s){case"img":{const{format:a}=await p(e.inputPath).metadata();return p(e.inputPath,{failOn:"none",sequentialRead:!0,unlimited:!0,animated:a==="webp"||a==="gif"})}default:return await c.pipeline.read(e)}},fulfilled:async e=>e.files>0?`Successfully compressed a total of ${e.files} ${s.toUpperCase()} ${e.files===1?"file":"files"} for ${await u(e.info.total)}.`:!1}))}}}};export{I as default}; diff --git a/dist/lib/sharp-read.d.ts b/dist/lib/sharp-read.d.ts index 030cee5f..5662d888 100644 --- a/dist/lib/sharp-read.d.ts +++ b/dist/lib/sharp-read.d.ts @@ -4,8 +4,8 @@ import type { Sharp } from "sharp"; export interface sharpBuffer extends Sharp { [key: string]: any; } -export interface currentSharp extends Omit { +export interface ongoingSharp extends Omit { buffer: sharpBuffer; } -declare const _default: (options: IMG, current: currentSharp) => Promise; +declare const _default: (options: IMG, ongoing: ongoingSharp) => Promise; export default _default; diff --git a/package.json b/package.json index ec3c89cd..34c92d8f 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "astro-compress", - "version": "1.1.33", + "version": "1.1.34", "type": "module", "description": "🗜️ AstroJS compression utilities. Compress HTML, CSS, JavaScript and more.", "repository": { @@ -35,7 +35,7 @@ "@types/html-minifier-terser": "7.0.0", "@types/sharp": "0.31.1", "csso": "5.0.5", - "files-pipeline": "0.0.3", + "files-pipeline": "0.0.4", "html-minifier-terser": "7.1.0", "sharp": "0.31.3", "svgo": "3.0.2", diff --git a/src/index.ts b/src/index.ts index 4154cc1e..0f165c50 100644 --- a/src/index.ts +++ b/src/index.ts @@ -23,7 +23,7 @@ import { optimize as svgo } from "svgo"; import { minify as terser } from "terser"; import type { Output } from "svgo"; -import type { currentSharp } from "./lib/sharp-read.js"; +import type { ongoingSharp } from "./lib/sharp-read.js"; import sharpRead from "./lib/sharp-read.js"; export default (options: Options = {}): AstroIntegration => { @@ -105,7 +105,7 @@ export default (options: Options = {}): AstroIntegration => { case "img": { return sharpRead( setting, - ongoing as currentSharp + ongoing as ongoingSharp ); } diff --git a/src/lib/sharp-read.ts b/src/lib/sharp-read.ts index 19cfb386..ed526a4a 100644 --- a/src/lib/sharp-read.ts +++ b/src/lib/sharp-read.ts @@ -10,12 +10,12 @@ export interface sharpBuffer extends Sharp { [key: string]: any; } -export interface currentSharp extends Omit { +export interface ongoingSharp extends Omit { buffer: sharpBuffer; } -export default async (options: IMG, current: currentSharp) => { - const fileType = current.inputPath.split(".").pop(); +export default async (options: IMG, ongoing: ongoingSharp) => { + const fileType = ongoing["inputPath"].split(".").pop(); if (!fileType) { return; @@ -61,8 +61,8 @@ export default async (options: IMG, current: currentSharp) => { typeof options[optionType] !== "undefined" && options[optionType] !== false ) { - if (optionType in current.buffer) { - return await current.buffer[optionType]( + if (optionType in ongoing.buffer) { + return await ongoing.buffer[optionType]( options[optionType] !== true ? options[optionType] : defaults["img"]