From 46d5e12941e148965c641af4cbebf8bcfd72c8eb Mon Sep 17 00:00:00 2001 From: Nikola Hristov <Nikola@PlayForm.LTD> Date: Wed, 8 Jan 2025 21:01:00 +0200 Subject: [PATCH] --- Target/Function/Directory.d.ts | 7 ++ Target/Function/Directory.js | 1 + Target/Function/Image/Writesharp.d.ts | 8 ++ Target/Function/Image/Writesharp.js | 1 + Target/Function/Integration.d.ts | 103 ++++++++++++++++++ Target/Function/Integration.js | 1 + Target/Function/Merge.d.ts | 16 +++ Target/Function/Merge.js | 1 + Target/Interface/CLI.d.ts | 8 ++ Target/Interface/CLI.js | 0 Target/Interface/CSS/csso.d.ts | 32 ++++++ Target/Interface/CSS/csso.js | 0 Target/Interface/CSS/lightningcss.d.ts | 21 ++++ Target/Interface/CSS/lightningcss.js | 0 Target/Interface/Directory.d.ts | 8 ++ Target/Interface/Directory.js | 0 Target/Interface/Image/Onsharp.d.ts | 11 ++ Target/Interface/Image/Onsharp.js | 0 Target/Interface/Image/Writesharp.d.ts | 9 ++ Target/Interface/Image/Writesharp.js | 0 Target/Interface/Image/sharp.d.ts | 16 +++ Target/Interface/Image/sharp.js | 0 Target/Interface/Integration.d.ts | 9 ++ Target/Interface/Integration.js | 0 Target/Interface/Map.d.ts | 7 ++ Target/Interface/Map.js | 0 Target/Interface/Option.d.ts | 61 +++++++++++ Target/Interface/Option.js | 0 Target/Interface/Parser.d.ts | 17 +++ Target/Interface/Parser.js | 0 Target/Type/HTML/html-minifier-terser.d.ts | 7 ++ Target/Type/HTML/html-minifier-terser.js | 0 Target/Type/Image/Filesharp.d.ts | 7 ++ Target/Type/Image/Filesharp.js | 1 + Target/Type/JavaScript/terser.d.ts | 7 ++ Target/Type/JavaScript/terser.js | 0 Target/Type/Parser/CSS.d.ts | 6 + Target/Type/Parser/CSS.js | 0 Target/Type/Parser/HTML.d.ts | 6 + Target/Type/Parser/HTML.js | 0 Target/Type/Parser/Image.d.ts | 6 + Target/Type/Parser/Image.js | 0 Target/Type/Parser/JavaScript.d.ts | 6 + Target/Type/Parser/JavaScript.js | 0 Target/Type/Parser/SVG.d.ts | 6 + Target/Type/Parser/SVG.js | 0 Target/Type/SVG/svgo.d.ts | 7 ++ Target/Type/SVG/svgo.js | 0 Target/Variable/CSS/csso.d.ts | 7 ++ Target/Variable/CSS/csso.js | 1 + Target/Variable/CSS/lightningcss.d.ts | 7 ++ Target/Variable/CSS/lightningcss.js | 1 + .../Variable/HTML/html-minifier-terser.d.ts | 33 ++++++ Target/Variable/HTML/html-minifier-terser.js | 1 + Target/Variable/Image/Mapsharp.d.ts | 7 ++ Target/Variable/Image/Mapsharp.js | 1 + Target/Variable/Image/sharp.d.ts | 7 ++ Target/Variable/Image/sharp.js | 1 + Target/Variable/JavaScript/terser.d.ts | 18 +++ Target/Variable/JavaScript/terser.js | 1 + Target/Variable/Map.d.ts | 7 ++ Target/Variable/Map.js | 1 + Target/Variable/Middleware.d.ts | 4 + Target/Variable/Middleware.js | 0 Target/Variable/Option.d.ts | 86 +++++++++++++++ Target/Variable/Option.js | 1 + Target/Variable/Parser.d.ts | 7 ++ Target/Variable/Parser.js | 1 + Target/Variable/SVG/svgo.d.ts | 13 +++ Target/Variable/SVG/svgo.js | 1 + package.json | 2 +- 71 files changed, 603 insertions(+), 1 deletion(-) create mode 100644 Target/Function/Directory.d.ts create mode 100644 Target/Function/Directory.js create mode 100644 Target/Function/Image/Writesharp.d.ts create mode 100644 Target/Function/Image/Writesharp.js create mode 100644 Target/Function/Integration.d.ts create mode 100644 Target/Function/Integration.js create mode 100644 Target/Function/Merge.d.ts create mode 100644 Target/Function/Merge.js create mode 100644 Target/Interface/CLI.d.ts create mode 100644 Target/Interface/CLI.js create mode 100644 Target/Interface/CSS/csso.d.ts create mode 100644 Target/Interface/CSS/csso.js create mode 100644 Target/Interface/CSS/lightningcss.d.ts create mode 100644 Target/Interface/CSS/lightningcss.js create mode 100644 Target/Interface/Directory.d.ts create mode 100644 Target/Interface/Directory.js create mode 100644 Target/Interface/Image/Onsharp.d.ts create mode 100644 Target/Interface/Image/Onsharp.js create mode 100644 Target/Interface/Image/Writesharp.d.ts create mode 100644 Target/Interface/Image/Writesharp.js create mode 100644 Target/Interface/Image/sharp.d.ts create mode 100644 Target/Interface/Image/sharp.js create mode 100644 Target/Interface/Integration.d.ts create mode 100644 Target/Interface/Integration.js create mode 100644 Target/Interface/Map.d.ts create mode 100644 Target/Interface/Map.js create mode 100644 Target/Interface/Option.d.ts create mode 100644 Target/Interface/Option.js create mode 100644 Target/Interface/Parser.d.ts create mode 100644 Target/Interface/Parser.js create mode 100644 Target/Type/HTML/html-minifier-terser.d.ts create mode 100644 Target/Type/HTML/html-minifier-terser.js create mode 100644 Target/Type/Image/Filesharp.d.ts create mode 100644 Target/Type/Image/Filesharp.js create mode 100644 Target/Type/JavaScript/terser.d.ts create mode 100644 Target/Type/JavaScript/terser.js create mode 100644 Target/Type/Parser/CSS.d.ts create mode 100644 Target/Type/Parser/CSS.js create mode 100644 Target/Type/Parser/HTML.d.ts create mode 100644 Target/Type/Parser/HTML.js create mode 100644 Target/Type/Parser/Image.d.ts create mode 100644 Target/Type/Parser/Image.js create mode 100644 Target/Type/Parser/JavaScript.d.ts create mode 100644 Target/Type/Parser/JavaScript.js create mode 100644 Target/Type/Parser/SVG.d.ts create mode 100644 Target/Type/Parser/SVG.js create mode 100644 Target/Type/SVG/svgo.d.ts create mode 100644 Target/Type/SVG/svgo.js create mode 100644 Target/Variable/CSS/csso.d.ts create mode 100644 Target/Variable/CSS/csso.js create mode 100644 Target/Variable/CSS/lightningcss.d.ts create mode 100644 Target/Variable/CSS/lightningcss.js create mode 100644 Target/Variable/HTML/html-minifier-terser.d.ts create mode 100644 Target/Variable/HTML/html-minifier-terser.js create mode 100644 Target/Variable/Image/Mapsharp.d.ts create mode 100644 Target/Variable/Image/Mapsharp.js create mode 100644 Target/Variable/Image/sharp.d.ts create mode 100644 Target/Variable/Image/sharp.js create mode 100644 Target/Variable/JavaScript/terser.d.ts create mode 100644 Target/Variable/JavaScript/terser.js create mode 100644 Target/Variable/Map.d.ts create mode 100644 Target/Variable/Map.js create mode 100644 Target/Variable/Middleware.d.ts create mode 100644 Target/Variable/Middleware.js create mode 100644 Target/Variable/Option.d.ts create mode 100644 Target/Variable/Option.js create mode 100644 Target/Variable/Parser.d.ts create mode 100644 Target/Variable/Parser.js create mode 100644 Target/Variable/SVG/svgo.d.ts create mode 100644 Target/Variable/SVG/svgo.js diff --git a/Target/Function/Directory.d.ts b/Target/Function/Directory.d.ts new file mode 100644 index 000000000..143582225 --- /dev/null +++ b/Target/Function/Directory.d.ts @@ -0,0 +1,7 @@ +import type Interface from "../Interface/Directory.js"; +/** + * @module Directory + * + */ +declare const _default: Interface; +export default _default; diff --git a/Target/Function/Directory.js b/Target/Function/Directory.js new file mode 100644 index 000000000..a80935812 --- /dev/null +++ b/Target/Function/Directory.js @@ -0,0 +1 @@ +var a=async(...[r])=>{let e=(await import("path")).normalize((await import("path")).parse(r).dir).replace(/\\/g,"/").replace((await import("./Integration.js")).System,"");return e.endsWith("/")||(e+="/"),e};export{a as default}; diff --git a/Target/Function/Image/Writesharp.d.ts b/Target/Function/Image/Writesharp.d.ts new file mode 100644 index 000000000..a10224c74 --- /dev/null +++ b/Target/Function/Image/Writesharp.d.ts @@ -0,0 +1,8 @@ +import type Interface from "../../Interface/Image/Writesharp.js"; +/** + * @module Image + * + */ +declare const _default: Interface; +export default _default; +export declare const _Map: import("../../Interface/Map.js").default; diff --git a/Target/Function/Image/Writesharp.js b/Target/Function/Image/Writesharp.js new file mode 100644 index 000000000..fcd5e6be9 --- /dev/null +++ b/Target/Function/Image/Writesharp.js @@ -0,0 +1 @@ +var s=async(...[t,{Buffer:f,Input:r}])=>{const a=r.split(".").pop();if(!a)return;const e=typeof i[a]<"u"?i[a]:typeof t[a]<"u"?a:!1;if(e&&["avif","gif","heif","jpeg","png","raw","tiff","webp"].includes(e)&&typeof t[e]<"u"&&t[e]!==!1)return e in f&&await f[e](t[e]!==!0?t[e]:(await import("../../Variable/Image/sharp.js")).default).toBuffer()};const{default:i}=await import("../../Variable/Image/Mapsharp.js");export{i as _Map,s as default}; diff --git a/Target/Function/Integration.d.ts b/Target/Function/Integration.d.ts new file mode 100644 index 000000000..70cea25e4 --- /dev/null +++ b/Target/Function/Integration.d.ts @@ -0,0 +1,103 @@ +import type Action from "@playform/pipe/Target/Interface/Action.js"; +import type Interface from "../Interface/Integration.js"; +/** + * @module Integration + * + */ +export declare let System: string; +declare const _default: Interface; +export default _default; +export declare const Default: { + CSS: { + csso: import("../Interface/CSS/csso.js").default; + lightningcss: import("../Interface/CSS/lightningcss.js").default; + }; + HTML: { + "html-minifier-terser": { + caseSensitive: true; + collapseInlineTagWhitespace: false; + collapseWhitespace: true; + continueOnParseError: true; + html5: true; + ignoreCustomComments: RegExp[]; + ignoreCustomFragments: never[]; + includeAutoGeneratedTags: true; + keepClosingSlash: true; + minifyCSS: true; + minifyJS: true; + minifyURLs: false; + noNewlinesBeforeTagClose: true; + preventAttributesEscaping: false; + processConditionalComments: false; + processScripts: string[]; + quoteCharacter: string; + removeAttributeQuotes: true; + removeComments: true; + removeScriptTypeAttributes: true; + removeStyleLinkTypeAttributes: true; + removeTagWhitespace: false; + sortAttributes: true; + sortClassName: true; + trimCustomFragments: true; + useShortDoctype: false; + }; + }; + JavaScript: { + terser: { + ecma: 5; + enclose: false; + keep_classnames: false; + keep_fnames: false; + ie8: false; + module: false; + safari10: false; + toplevel: false; + format: { + comments: false; + }; + }; + }; + Image: { + sharp: import("../Interface/Image/sharp.js").default; + }; + SVG: { + svgo: { + multipass: true; + js2svg: { + indent: number; + pretty: false; + }; + plugins: "preset-default"[]; + }; + }; + Map: import("../Interface/Map.js").default; + Parser: import("../Interface/Parser.js").default; + Action: { + Failed: ({ Input }: { + Input: any; + }) => Promise<string>; + Passed: ({ Before, Buffer }: { + Before: any; + Buffer: any; + }) => Promise<boolean>; + Accomplished: ({ Input, Before, After }: { + Input: any; + Before: any; + After: any; + }) => Promise<string>; + Changed: (Plan: any) => Promise<any>; + }; +}; +export declare const Search: any; +export declare const Merge: <Ts extends readonly unknown[]>(...objects: Ts) => import("deepmerge-ts").DeepMergeHKT<Ts, Readonly<{ + DeepMergeRecordsURI: "DeepMergeRecordsDefaultURI"; + DeepMergeArraysURI: "DeepMergeArraysDefaultURI"; + DeepMergeSetsURI: "DeepMergeSetsDefaultURI"; + DeepMergeMapsURI: "DeepMergeMapsDefaultURI"; + DeepMergeOthersURI: "DeepMergeLeafURI"; + DeepMergeFilterValuesURI: "DeepMergeFilterValuesDefaultURI"; +}>, Readonly<{ + key: PropertyKey; + parents: ReadonlyArray<Readonly<Record<PropertyKey, unknown>>>; +}>>; +export declare let _Action: Action; diff --git a/Target/Function/Integration.js b/Target/Function/Integration.js new file mode 100644 index 000000000..afa88d71d --- /dev/null +++ b/Target/Function/Integration.js @@ -0,0 +1 @@ +let d;var M=(...[p={}])=>{Object.entries(p).forEach(([a,r])=>Object.defineProperty(p,a,{value:r===!0?u[a]:p[a]}));const{Path:i,Cache:m,Logger:S,Map:h,Exclude:j,Action:w,CSS:b,HTML:A,Image:c,JavaScript:I,SVG:P,Parser:g}=n(u,p),f=new Set;return typeof i<"u"&&((Array.isArray(i)||i instanceof Set)&&i.forEach(a=>f.add(a)),i instanceof Map&&f.add(i)),typeof g=="object"&&Object.entries(g).forEach(([a,r])=>Object.defineProperty(g,a,{value:Array.isArray(r)?r:[r]})),{name:"astro-compress",hooks:{"astro:config:done":async({config:{outDir:{pathname:a}}})=>{d=(await import("path")).parse(a).dir.replace(/\\/g,"/"),d.startsWith("/")&&(d=d.substring(1))},"astro:build:done":async({dir:a})=>{if(typeof h=="object"){f.size===0&&f.add(a),typeof m=="object"&&m.Search===x&&(m.Search=a.toString());for(const[r,o]of Object.entries({CSS:b,HTML:A,Image:c,JavaScript:I,SVG:P}))if(!(!(o&&h[r])||typeof o!="object")){y=n(w,n(w,{Wrote:async({Buffer:t,Input:s})=>{switch(r){case"CSS":{let e=t.toString();try{o.lightningcss&&(e=(await import("lightningcss")).transform(n({code:(await import("buffer")).Buffer.from(e),filename:s},o.lightningcss)).code.toString()),o.csso&&(e=(await import("csso")).minify(e,o.csso).css)}catch(l){console.log(l)}return e}case"HTML":return await(await import("html-minifier-terser")).minify(t.toString(),o["html-minifier-terser"]);case"JavaScript":return(await(await import("terser")).minify(t.toString(),o.terser)).code??t;case"Image":try{return t instanceof(await import("sharp")).default?await(await import("./Image/Writesharp.js")).default(o.sharp,{Buffer:t,Input:s}):t}catch(e){return console.log(e),t}case"SVG":return(await import("svgo")).optimize(t.toString(),o.svgo).data??t;default:return t}},Fulfilled:async({File:t,Info:{Total:s}})=>t>0?`${(await import("kleur/colors")).green(`\u2713\u2001Successfully compressed a total of ${t} ${r} file${t!==1?"s":""} for ${(await import("@playform/pipe/Target/Function/Bytes.js")).default(s)}.`)}`:!1})),r==="Image"&&(y=n(y,{Read:async({Input:t,Buffer:s})=>{try{(await import("sharp")).default.cache(!1);const{format:e}=await(await import("sharp")).default(t).metadata(),l={animated:e==="webp"||e==="gif"};return(await import("sharp")).default(t,typeof c=="object"&&typeof c.sharp=="object"&&typeof c.sharp.sharp=="object"?n(l,c.sharp?.sharp):l)}catch(e){return console.log(e),s}}}));for(const t of f)await(await(await(await new(await import("@playform/pipe")).default(m,S).In(t)).By(h[r]??"**/*")).Not(j)).Pipe(y)}}}}}};const{default:u}=await import("../Variable/Option.js"),{default:{Cache:{Search:x}}}=await import("@playform/pipe/Target/Variable/Option.js"),{default:n}=await import("./Merge.js");let y;export{u as Default,n as Merge,x as Search,d as System,y as _Action,M as default}; diff --git a/Target/Function/Merge.d.ts b/Target/Function/Merge.d.ts new file mode 100644 index 000000000..b03db589c --- /dev/null +++ b/Target/Function/Merge.d.ts @@ -0,0 +1,16 @@ +/** + * @module Merge + * + */ +declare const _default: <Ts extends readonly unknown[]>(...objects: Ts) => import("deepmerge-ts").DeepMergeHKT<Ts, Readonly<{ + DeepMergeRecordsURI: "DeepMergeRecordsDefaultURI"; + DeepMergeArraysURI: "DeepMergeArraysDefaultURI"; + DeepMergeSetsURI: "DeepMergeSetsDefaultURI"; + DeepMergeMapsURI: "DeepMergeMapsDefaultURI"; + DeepMergeOthersURI: "DeepMergeLeafURI"; + DeepMergeFilterValuesURI: "DeepMergeFilterValuesDefaultURI"; +}>, Readonly<{ + key: PropertyKey; + parents: ReadonlyArray<Readonly<Record<PropertyKey, unknown>>>; +}>>; +export default _default; diff --git a/Target/Function/Merge.js b/Target/Function/Merge.js new file mode 100644 index 000000000..73286f248 --- /dev/null +++ b/Target/Function/Merge.js @@ -0,0 +1 @@ +var r=(await import("deepmerge-ts")).deepmergeCustom({mergeArrays:!1});export{r as default}; diff --git a/Target/Interface/CLI.d.ts b/Target/Interface/CLI.d.ts new file mode 100644 index 000000000..2d3853beb --- /dev/null +++ b/Target/Interface/CLI.d.ts @@ -0,0 +1,8 @@ +import type { Pattern } from "fast-glob"; +/** + * @module CLI + * + */ +export default interface Interface { + (File: Pattern[], Compress?: Pattern): Promise<void>; +} diff --git a/Target/Interface/CLI.js b/Target/Interface/CLI.js new file mode 100644 index 000000000..e69de29bb diff --git a/Target/Interface/CSS/csso.d.ts b/Target/Interface/CSS/csso.d.ts new file mode 100644 index 000000000..a4695ac1d --- /dev/null +++ b/Target/Interface/CSS/csso.d.ts @@ -0,0 +1,32 @@ +import type { CompressOptions, MinifyOptions } from "csso"; +/** + * @module CSS + * + */ +export default interface Interface extends MinifyOptions, CompressOptions { + /** + * Specify what comments to leave: + * - 'exclamation' or true – leave all exclamation comments + * - 'first-exclamation' – remove every comment except first one + * - false – remove all comments + * + * @default Compress false + * @default csso true + */ + comments?: boolean; + /** + * Enables merging of @media rules with the same media query by splitted by other rules. + * The optimisation is unsafe in general, but should work fine in most cases. Use it on your own risk. + * + * @default Compress true + * @default csso false + */ + forceMediaMerge?: boolean; + /** + * Disable or enable a structure optimisations. + * + * @default CompressAstro false + * @default csso true + */ + restructure?: boolean; +} diff --git a/Target/Interface/CSS/csso.js b/Target/Interface/CSS/csso.js new file mode 100644 index 000000000..e69de29bb diff --git a/Target/Interface/CSS/lightningcss.d.ts b/Target/Interface/CSS/lightningcss.d.ts new file mode 100644 index 000000000..2f8cc0833 --- /dev/null +++ b/Target/Interface/CSS/lightningcss.d.ts @@ -0,0 +1,21 @@ +import type { CustomAtRules, TransformOptions } from "lightningcss"; +/** + * @module CSS + * + */ +export default interface Interface extends Omit<TransformOptions<CustomAtRules>, "filename" | "code" | "unusedSymbols"> { + /** + * Whether to enable minification + * + * @default Compress true + * @default lightningcss false + */ + minify?: boolean; + /** + * Whether to remove unused selectors or keywords. + * + * @default Compress [] + * @default lightningcss undefined + */ + unusedSymbols?: string[]; +} diff --git a/Target/Interface/CSS/lightningcss.js b/Target/Interface/CSS/lightningcss.js new file mode 100644 index 000000000..e69de29bb diff --git a/Target/Interface/Directory.d.ts b/Target/Interface/Directory.d.ts new file mode 100644 index 000000000..406d95b85 --- /dev/null +++ b/Target/Interface/Directory.d.ts @@ -0,0 +1,8 @@ +import type { ParsedPath } from "path"; +/** + * @module Directory + * + */ +export default interface Interface { + (Path: string): Promise<ParsedPath["dir"]>; +} diff --git a/Target/Interface/Directory.js b/Target/Interface/Directory.js new file mode 100644 index 000000000..e69de29bb diff --git a/Target/Interface/Image/Onsharp.d.ts b/Target/Interface/Image/Onsharp.d.ts new file mode 100644 index 000000000..3544e577e --- /dev/null +++ b/Target/Interface/Image/Onsharp.d.ts @@ -0,0 +1,11 @@ +import type File from "@playform/pipe/Target/Interface/File.js"; +import type { Sharp } from "sharp"; +/** + * @module Image + * + */ +export default interface Interface extends Omit<File, "Buffer"> { + Buffer: { + [key: string]: any; + } & Sharp; +} diff --git a/Target/Interface/Image/Onsharp.js b/Target/Interface/Image/Onsharp.js new file mode 100644 index 000000000..e69de29bb diff --git a/Target/Interface/Image/Writesharp.d.ts b/Target/Interface/Image/Writesharp.d.ts new file mode 100644 index 000000000..c266cbe74 --- /dev/null +++ b/Target/Interface/Image/Writesharp.d.ts @@ -0,0 +1,9 @@ +import type On from "../../Interface/Image/Onsharp.js"; +import type Option from "../../Interface/Image/sharp.js"; +/** + * @module Image + * + */ +export default interface Interface { + (Option: Option, On: On): Promise<any>; +} diff --git a/Target/Interface/Image/Writesharp.js b/Target/Interface/Image/Writesharp.js new file mode 100644 index 000000000..e69de29bb diff --git a/Target/Interface/Image/sharp.d.ts b/Target/Interface/Image/sharp.d.ts new file mode 100644 index 000000000..b48804a6b --- /dev/null +++ b/Target/Interface/Image/sharp.d.ts @@ -0,0 +1,16 @@ +import type { AvifOptions, GifOptions, HeifOptions, JpegOptions, PngOptions, SharpOptions, TiffOptions, WebpOptions } from "sharp"; +/** + * @module Image + * + */ +export default interface Interface { + [key: string]: AvifOptions | GifOptions | HeifOptions | JpegOptions | PngOptions | SharpOptions | TiffOptions | WebpOptions | boolean | undefined; + avif?: boolean | AvifOptions; + gif?: boolean | GifOptions; + heif?: boolean | HeifOptions; + jpeg?: boolean | JpegOptions; + png?: boolean | PngOptions; + tiff?: boolean | TiffOptions; + webp?: boolean | WebpOptions; + sharp?: boolean | SharpOptions; +} diff --git a/Target/Interface/Image/sharp.js b/Target/Interface/Image/sharp.js new file mode 100644 index 000000000..e69de29bb diff --git a/Target/Interface/Integration.d.ts b/Target/Interface/Integration.d.ts new file mode 100644 index 000000000..88c1b86b5 --- /dev/null +++ b/Target/Interface/Integration.d.ts @@ -0,0 +1,9 @@ +import type { AstroIntegration } from "astro"; +import type Option from "../Interface/Option.js"; +/** + * @module Integration + * + */ +export default interface Interface { + (Option?: Option): AstroIntegration; +} diff --git a/Target/Interface/Integration.js b/Target/Interface/Integration.js new file mode 100644 index 000000000..e69de29bb diff --git a/Target/Interface/Map.d.ts b/Target/Interface/Map.d.ts new file mode 100644 index 000000000..f3f83af68 --- /dev/null +++ b/Target/Interface/Map.d.ts @@ -0,0 +1,7 @@ +/** + * @module Map + * + */ +export default interface Interface { + [key: string]: string; +} diff --git a/Target/Interface/Map.js b/Target/Interface/Map.js new file mode 100644 index 000000000..e69de29bb diff --git a/Target/Interface/Option.d.ts b/Target/Interface/Option.d.ts new file mode 100644 index 000000000..17cc83a98 --- /dev/null +++ b/Target/Interface/Option.d.ts @@ -0,0 +1,61 @@ +import type Option from "@playform/pipe/Target/Interface/Option.js"; +import type csso from "../Interface/CSS/csso.js"; +import type lightningcss from "../Interface/CSS/lightningcss.js"; +import type sharp from "../Interface/Image/sharp.js"; +import type _Map from "../Interface/Map.js"; +import type Parser from "../Interface/Parser.js"; +import type html_minifier_terser from "../Type/HTML/html-minifier-terser.js"; +import type terser from "../Type/JavaScript/terser.js"; +import type svgo from "../Type/SVG/svgo.js"; +/** + * @module Option + * + */ +export default interface Interface extends Option { + /** + * csso, lightningcss option properties + * + */ + CSS?: boolean | { + csso?: csso; + lightningcss?: lightningcss; + }; + /** + * html-minifier-terser option properties + * + */ + HTML?: boolean | { + "html-minifier-terser"?: html_minifier_terser; + }; + /** + * sharp option properties + * + */ + Image?: boolean | { + sharp?: sharp; + }; + /** + * terser option properties + * + */ + JavaScript?: boolean | { + terser?: terser; + }; + /** + * svgo option properties + * + */ + SVG?: boolean | { + svgo?: svgo; + }; + /** + * Map to different file paths + * + */ + Map?: boolean | _Map; + /** + * Parsers for different file types + * + */ + Parser?: Parser; +} diff --git a/Target/Interface/Option.js b/Target/Interface/Option.js new file mode 100644 index 000000000..e69de29bb diff --git a/Target/Interface/Parser.d.ts b/Target/Interface/Parser.d.ts new file mode 100644 index 000000000..1859b1b9a --- /dev/null +++ b/Target/Interface/Parser.d.ts @@ -0,0 +1,17 @@ +import type CSS from "../Type/Parser/CSS.js"; +import type HTML from "../Type/Parser/HTML.js"; +import type Image from "../Type/Parser/Image.js"; +import type JavaScript from "../Type/Parser/JavaScript.js"; +import type SVG from "../Type/Parser/SVG.js"; +/** + * @module Parser + * + */ +export default interface Interface { + [key: string]: any; + CSS?: CSS | CSS[]; + HTML?: HTML | HTML[]; + Image?: Image | Image[]; + JavaScript?: JavaScript | JavaScript[]; + SVG?: SVG | SVG[]; +} diff --git a/Target/Interface/Parser.js b/Target/Interface/Parser.js new file mode 100644 index 000000000..e69de29bb diff --git a/Target/Type/HTML/html-minifier-terser.d.ts b/Target/Type/HTML/html-minifier-terser.d.ts new file mode 100644 index 000000000..050c4d926 --- /dev/null +++ b/Target/Type/HTML/html-minifier-terser.d.ts @@ -0,0 +1,7 @@ +import type { Options } from "html-minifier-terser"; +/** + * @module HTML + * + */ +export type Type = Options; +export type { Type as default }; diff --git a/Target/Type/HTML/html-minifier-terser.js b/Target/Type/HTML/html-minifier-terser.js new file mode 100644 index 000000000..e69de29bb diff --git a/Target/Type/Image/Filesharp.d.ts b/Target/Type/Image/Filesharp.d.ts new file mode 100644 index 000000000..9313bdf56 --- /dev/null +++ b/Target/Type/Image/Filesharp.d.ts @@ -0,0 +1,7 @@ +/** + * @module File + * + */ +export type Type = keyof typeof _Map; +export type { Type as default }; +export declare const _Map: import("../../Interface/Map").default; diff --git a/Target/Type/Image/Filesharp.js b/Target/Type/Image/Filesharp.js new file mode 100644 index 000000000..fbf373277 --- /dev/null +++ b/Target/Type/Image/Filesharp.js @@ -0,0 +1 @@ +const{default:p}=await import("../../Variable/Image/Mapsharp.js");export{p as _Map}; diff --git a/Target/Type/JavaScript/terser.d.ts b/Target/Type/JavaScript/terser.d.ts new file mode 100644 index 000000000..249feb0d3 --- /dev/null +++ b/Target/Type/JavaScript/terser.d.ts @@ -0,0 +1,7 @@ +import type { MinifyOptions } from "terser"; +/** + * @module JavaScript + * + */ +export type Type = MinifyOptions; +export type { Type as default }; diff --git a/Target/Type/JavaScript/terser.js b/Target/Type/JavaScript/terser.js new file mode 100644 index 000000000..e69de29bb diff --git a/Target/Type/Parser/CSS.d.ts b/Target/Type/Parser/CSS.d.ts new file mode 100644 index 000000000..fe2c732d2 --- /dev/null +++ b/Target/Type/Parser/CSS.d.ts @@ -0,0 +1,6 @@ +/** + * @module Parser + * + */ +export type Type = "csso" | "lightningcss"; +export type { Type as default }; diff --git a/Target/Type/Parser/CSS.js b/Target/Type/Parser/CSS.js new file mode 100644 index 000000000..e69de29bb diff --git a/Target/Type/Parser/HTML.d.ts b/Target/Type/Parser/HTML.d.ts new file mode 100644 index 000000000..f2d7711c1 --- /dev/null +++ b/Target/Type/Parser/HTML.d.ts @@ -0,0 +1,6 @@ +/** + * @module Parser + * + */ +export type Type = "html-minifier-terser"; +export type { Type as default }; diff --git a/Target/Type/Parser/HTML.js b/Target/Type/Parser/HTML.js new file mode 100644 index 000000000..e69de29bb diff --git a/Target/Type/Parser/Image.d.ts b/Target/Type/Parser/Image.d.ts new file mode 100644 index 000000000..7aea86310 --- /dev/null +++ b/Target/Type/Parser/Image.d.ts @@ -0,0 +1,6 @@ +/** + * @module Parser + * + */ +export type Type = "sharp"; +export type { Type as default }; diff --git a/Target/Type/Parser/Image.js b/Target/Type/Parser/Image.js new file mode 100644 index 000000000..e69de29bb diff --git a/Target/Type/Parser/JavaScript.d.ts b/Target/Type/Parser/JavaScript.d.ts new file mode 100644 index 000000000..a0e73dba6 --- /dev/null +++ b/Target/Type/Parser/JavaScript.d.ts @@ -0,0 +1,6 @@ +/** + * @module Parser + * + */ +export type Type = "terser"; +export type { Type as default }; diff --git a/Target/Type/Parser/JavaScript.js b/Target/Type/Parser/JavaScript.js new file mode 100644 index 000000000..e69de29bb diff --git a/Target/Type/Parser/SVG.d.ts b/Target/Type/Parser/SVG.d.ts new file mode 100644 index 000000000..3848871e9 --- /dev/null +++ b/Target/Type/Parser/SVG.d.ts @@ -0,0 +1,6 @@ +/** + * @module Parser + * + */ +export type Type = "svgo"; +export type { Type as default }; diff --git a/Target/Type/Parser/SVG.js b/Target/Type/Parser/SVG.js new file mode 100644 index 000000000..e69de29bb diff --git a/Target/Type/SVG/svgo.d.ts b/Target/Type/SVG/svgo.d.ts new file mode 100644 index 000000000..7e65daf76 --- /dev/null +++ b/Target/Type/SVG/svgo.d.ts @@ -0,0 +1,7 @@ +import type { Config } from "svgo"; +/** + * @module SVG + * + */ +export type Type = Config; +export type { Type as default }; diff --git a/Target/Type/SVG/svgo.js b/Target/Type/SVG/svgo.js new file mode 100644 index 000000000..e69de29bb diff --git a/Target/Variable/CSS/csso.d.ts b/Target/Variable/CSS/csso.d.ts new file mode 100644 index 000000000..9a6352e1d --- /dev/null +++ b/Target/Variable/CSS/csso.d.ts @@ -0,0 +1,7 @@ +import type Interface from "../../Interface/CSS/csso.js"; +/** + * @module CSS + * + */ +declare const _default: Interface; +export default _default; diff --git a/Target/Variable/CSS/csso.js b/Target/Variable/CSS/csso.js new file mode 100644 index 000000000..34f0fce33 --- /dev/null +++ b/Target/Variable/CSS/csso.js @@ -0,0 +1 @@ +var r={comments:!1,forceMediaMerge:!0,restructure:!1};export{r as default}; diff --git a/Target/Variable/CSS/lightningcss.d.ts b/Target/Variable/CSS/lightningcss.d.ts new file mode 100644 index 000000000..ad976d10d --- /dev/null +++ b/Target/Variable/CSS/lightningcss.d.ts @@ -0,0 +1,7 @@ +import type Interface from "../../Interface/CSS/lightningcss.js"; +/** + * @module CSS + * + */ +declare const _default: Interface; +export default _default; diff --git a/Target/Variable/CSS/lightningcss.js b/Target/Variable/CSS/lightningcss.js new file mode 100644 index 000000000..b0354a298 --- /dev/null +++ b/Target/Variable/CSS/lightningcss.js @@ -0,0 +1 @@ +var e={and_chr:8585216,and_ff:8650752,android:8585216,chrome:7143424,edge:8519680,firefox:8388608,ios_saf:984576,op_mob:5242880,opera:7405568,safari:1115648,samsung:1703936};var r={minify:!0,sourceMap:!1,unusedSymbols:[],targets:e};export{r as default}; diff --git a/Target/Variable/HTML/html-minifier-terser.d.ts b/Target/Variable/HTML/html-minifier-terser.d.ts new file mode 100644 index 000000000..13f24d2c0 --- /dev/null +++ b/Target/Variable/HTML/html-minifier-terser.d.ts @@ -0,0 +1,33 @@ +/** + * @module HTML + * + */ +declare const _default: { + caseSensitive: true; + collapseInlineTagWhitespace: false; + collapseWhitespace: true; + continueOnParseError: true; + html5: true; + ignoreCustomComments: RegExp[]; + ignoreCustomFragments: never[]; + includeAutoGeneratedTags: true; + keepClosingSlash: true; + minifyCSS: true; + minifyJS: true; + minifyURLs: false; + noNewlinesBeforeTagClose: true; + preventAttributesEscaping: false; + processConditionalComments: false; + processScripts: string[]; + quoteCharacter: string; + removeAttributeQuotes: true; + removeComments: true; + removeScriptTypeAttributes: true; + removeStyleLinkTypeAttributes: true; + removeTagWhitespace: false; + sortAttributes: true; + sortClassName: true; + trimCustomFragments: true; + useShortDoctype: false; +}; +export default _default; diff --git a/Target/Variable/HTML/html-minifier-terser.js b/Target/Variable/HTML/html-minifier-terser.js new file mode 100644 index 000000000..7230a8037 --- /dev/null +++ b/Target/Variable/HTML/html-minifier-terser.js @@ -0,0 +1 @@ +var e={caseSensitive:!0,collapseInlineTagWhitespace:!1,collapseWhitespace:!0,continueOnParseError:!0,html5:!0,ignoreCustomComments:[/^\s*#/,/.*\$.*/,/^\s*\[/,/^\s*\]/,/^\s*!/,/^\s*\//,/^\s*astro:.*/,/^\s*astro:end/],ignoreCustomFragments:[],includeAutoGeneratedTags:!0,keepClosingSlash:!0,minifyCSS:!0,minifyJS:!0,minifyURLs:!1,noNewlinesBeforeTagClose:!0,preventAttributesEscaping:!1,processConditionalComments:!1,processScripts:["application/ecmascript","application/javascript","application/json","application/ld+json","application/manifest+json","application/schema+json","application/vnd.geo+json","application/x-web-app-manifest+json","application/xhtml+xml","application/xml","image/svg+xml","template-worker","template","text/css","text/ecmascript","text/html","text/javascript","text/markdown","text/ng-template","text/plain","text/template","text/x-dust","text/x-dustjs","text/x-eco-template","text/x-eco","text/x-handlebars-template","text/x-handlebars","text/x-jade-template","text/x-jade","text/x-less","text/x-lodash-template","text/x-lodash","text/x-markdown","text/x-mustache-template","text/x-mustache","text/x-pug-template","text/x-pug","text/x-sass","text/x-scss","text/x-stylus","text/x-template","text/x-underscore-template","text/x-underscore","text/x-yaml","text/xml"],quoteCharacter:'"',removeAttributeQuotes:!0,removeComments:!0,removeScriptTypeAttributes:!0,removeStyleLinkTypeAttributes:!0,removeTagWhitespace:!1,sortAttributes:!0,sortClassName:!0,trimCustomFragments:!0,useShortDoctype:!1};export{e as default}; diff --git a/Target/Variable/Image/Mapsharp.d.ts b/Target/Variable/Image/Mapsharp.d.ts new file mode 100644 index 000000000..12e7065f9 --- /dev/null +++ b/Target/Variable/Image/Mapsharp.d.ts @@ -0,0 +1,7 @@ +import type Interface from "../../Interface/Map.js"; +/** + * @module Image + * + */ +declare const _default: Interface; +export default _default; diff --git a/Target/Variable/Image/Mapsharp.js b/Target/Variable/Image/Mapsharp.js new file mode 100644 index 000000000..377f62612 --- /dev/null +++ b/Target/Variable/Image/Mapsharp.js @@ -0,0 +1 @@ +var f={avci:"avif",avcs:"avif",avifs:"avif",heic:"heif",heics:"heif",heifs:"heif",jfif:"jpeg",jif:"jpeg",jpe:"jpeg",apng:"png",jpg:"jpeg"};export{f as default}; diff --git a/Target/Variable/Image/sharp.d.ts b/Target/Variable/Image/sharp.d.ts new file mode 100644 index 000000000..f2d31c6f2 --- /dev/null +++ b/Target/Variable/Image/sharp.d.ts @@ -0,0 +1,7 @@ +import type Interface from "../../Interface/Image/sharp.js"; +/** + * @module Image + * + */ +declare const _default: Interface; +export default _default; diff --git a/Target/Variable/Image/sharp.js b/Target/Variable/Image/sharp.js new file mode 100644 index 000000000..0f1486c4d --- /dev/null +++ b/Target/Variable/Image/sharp.js @@ -0,0 +1 @@ +var r={avif:{chromaSubsampling:"4:4:4",effort:9,lossless:!0},gif:{effort:10},jpeg:{chromaSubsampling:"4:4:4",mozjpeg:!0,trellisQuantisation:!0,overshootDeringing:!0,optimiseScans:!0},png:{compressionLevel:9,palette:!0},tiff:{compression:"lzw"},webp:{effort:6,lossless:!0},heif:{effort:9,lossless:!0},sharp:{failOn:"error",sequentialRead:!0,unlimited:!0}};export{r as default}; diff --git a/Target/Variable/JavaScript/terser.d.ts b/Target/Variable/JavaScript/terser.d.ts new file mode 100644 index 000000000..f053777ee --- /dev/null +++ b/Target/Variable/JavaScript/terser.d.ts @@ -0,0 +1,18 @@ +/** + * @module JavaScript + * + */ +declare const _default: { + ecma: 5; + enclose: false; + keep_classnames: false; + keep_fnames: false; + ie8: false; + module: false; + safari10: false; + toplevel: false; + format: { + comments: false; + }; +}; +export default _default; diff --git a/Target/Variable/JavaScript/terser.js b/Target/Variable/JavaScript/terser.js new file mode 100644 index 000000000..93491467f --- /dev/null +++ b/Target/Variable/JavaScript/terser.js @@ -0,0 +1 @@ +var s={ecma:5,enclose:!1,keep_classnames:!1,keep_fnames:!1,ie8:!1,module:!1,safari10:!1,toplevel:!1,format:{comments:!1}};export{s as default}; diff --git a/Target/Variable/Map.d.ts b/Target/Variable/Map.d.ts new file mode 100644 index 000000000..02484f20c --- /dev/null +++ b/Target/Variable/Map.d.ts @@ -0,0 +1,7 @@ +import type Interface from "../Interface/Map.js"; +/** + * @module Map + * + */ +declare const _default: Interface; +export default _default; diff --git a/Target/Variable/Map.js b/Target/Variable/Map.js new file mode 100644 index 000000000..0402cf64c --- /dev/null +++ b/Target/Variable/Map.js @@ -0,0 +1 @@ +var s={CSS:"**/*.css",HTML:"**/*.html",Image:"**/*.{apng,avci,avcs,avif,avifs,gif,heic,heics,heif,heifs,jfif,jif,jpe,jpeg,jpg,png,raw,tiff,webp}",JavaScript:"**/*.{js,mjs,cjs,jsm,mts,tsx,ts}",SVG:"**/*.svg"};export{s as default}; diff --git a/Target/Variable/Middleware.d.ts b/Target/Variable/Middleware.d.ts new file mode 100644 index 000000000..ccb0db20c --- /dev/null +++ b/Target/Variable/Middleware.d.ts @@ -0,0 +1,4 @@ +/** + * @module Middleware + * + */ diff --git a/Target/Variable/Middleware.js b/Target/Variable/Middleware.js new file mode 100644 index 000000000..e69de29bb diff --git a/Target/Variable/Option.d.ts b/Target/Variable/Option.d.ts new file mode 100644 index 000000000..9ed4a7523 --- /dev/null +++ b/Target/Variable/Option.d.ts @@ -0,0 +1,86 @@ +/** + * @module Option + * + */ +declare const _default: { + CSS: { + csso: import("../Interface/CSS/csso.js").default; + lightningcss: import("../Interface/CSS/lightningcss.js").default; + }; + HTML: { + "html-minifier-terser": { + caseSensitive: true; + collapseInlineTagWhitespace: false; + collapseWhitespace: true; + continueOnParseError: true; + html5: true; + ignoreCustomComments: RegExp[]; + ignoreCustomFragments: never[]; + includeAutoGeneratedTags: true; + keepClosingSlash: true; + minifyCSS: true; + minifyJS: true; + minifyURLs: false; + noNewlinesBeforeTagClose: true; + preventAttributesEscaping: false; + processConditionalComments: false; + processScripts: string[]; + quoteCharacter: string; + removeAttributeQuotes: true; + removeComments: true; + removeScriptTypeAttributes: true; + removeStyleLinkTypeAttributes: true; + removeTagWhitespace: false; + sortAttributes: true; + sortClassName: true; + trimCustomFragments: true; + useShortDoctype: false; + }; + }; + JavaScript: { + terser: { + ecma: 5; + enclose: false; + keep_classnames: false; + keep_fnames: false; + ie8: false; + module: false; + safari10: false; + toplevel: false; + format: { + comments: false; + }; + }; + }; + Image: { + sharp: import("../Interface/Image/sharp.js").default; + }; + SVG: { + svgo: { + multipass: true; + js2svg: { + indent: number; + pretty: false; + }; + plugins: "preset-default"[]; + }; + }; + Map: import("../Interface/Map.js").default; + Parser: import("../Interface/Parser.js").default; + Action: { + Failed: ({ Input }: { + Input: any; + }) => Promise<string>; + Passed: ({ Before, Buffer }: { + Before: any; + Buffer: any; + }) => Promise<boolean>; + Accomplished: ({ Input, Before, After }: { + Input: any; + Before: any; + After: any; + }) => Promise<string>; + Changed: (Plan: any) => Promise<any>; + }; +}; +export default _default; diff --git a/Target/Variable/Option.js b/Target/Variable/Option.js new file mode 100644 index 000000000..e0849e705 --- /dev/null +++ b/Target/Variable/Option.js @@ -0,0 +1 @@ +var n=(await import("../Function/Merge.js")).default((await import("@playform/pipe/Target/Variable/Option.js")).default,{CSS:{csso:(await import("./CSS/csso.js")).default,lightningcss:(await import("./CSS/lightningcss.js")).default},HTML:{"html-minifier-terser":(await import("./HTML/html-minifier-terser.js")).default},JavaScript:{terser:(await import("./JavaScript/terser.js")).default},Image:{sharp:(await import("./Image/sharp.js")).default},SVG:{svgo:(await import("./SVG/svgo.js")).default},Map:(await import("./Map.js")).default,Parser:(await import("./Parser.js")).default,Action:{Failed:async({Input:t})=>`${r("Error:")} Cannot compress file ${e(await o(t))}${r((await import("path")).parse(t).base)}`,Passed:async({Before:t,Buffer:a})=>t>s.byteLength(a.toString()),Accomplished:async({Input:t,Before:a,After:f})=>{const i=a-f;return`${e(`(-${(await import("@playform/pipe/Target/Function/Bytes.js")).default(i)})`)} ${(await import("kleur/colors")).green(`${(i/a*100).toFixed(2)}%`)} reduction in ${e(await o(t))}${(await import("kleur/colors")).cyan((await import("path")).parse(t).base)}`},Changed:async t=>Object.defineProperty(t.Info,"Total",{value:(t.Info.Total?t.Info.Total:0)+(t.On.Before-t.On.After),configurable:!0,writable:!0})&&t}});const{gray:e,red:r}=await import("kleur/colors"),{default:o}=await import("../Function/Directory.js"),{Buffer:s}=await import("buffer");export{n as default}; diff --git a/Target/Variable/Parser.d.ts b/Target/Variable/Parser.d.ts new file mode 100644 index 000000000..e02d8a532 --- /dev/null +++ b/Target/Variable/Parser.d.ts @@ -0,0 +1,7 @@ +import type Interface from "../Interface/Parser.js"; +/** + * @module Parser + * + */ +declare const _default: Interface; +export default _default; diff --git a/Target/Variable/Parser.js b/Target/Variable/Parser.js new file mode 100644 index 000000000..d264982af --- /dev/null +++ b/Target/Variable/Parser.js @@ -0,0 +1 @@ +var r={CSS:["csso","lightningcss"],HTML:"html-minifier-terser",Image:"sharp",JavaScript:"terser",SVG:"svgo"};export{r as default}; diff --git a/Target/Variable/SVG/svgo.d.ts b/Target/Variable/SVG/svgo.d.ts new file mode 100644 index 000000000..5e8a88729 --- /dev/null +++ b/Target/Variable/SVG/svgo.d.ts @@ -0,0 +1,13 @@ +/** + * @module SVG + * + */ +declare const _default: { + multipass: true; + js2svg: { + indent: number; + pretty: false; + }; + plugins: "preset-default"[]; +}; +export default _default; diff --git a/Target/Variable/SVG/svgo.js b/Target/Variable/SVG/svgo.js new file mode 100644 index 000000000..abd22e2b8 --- /dev/null +++ b/Target/Variable/SVG/svgo.js @@ -0,0 +1 @@ +var s={multipass:!0,js2svg:{indent:0,pretty:!1},plugins:["preset-default"]};export{s as default}; diff --git a/package.json b/package.json index 651352d88..3e3c1ba40 100644 --- a/package.json +++ b/package.json @@ -58,7 +58,7 @@ }, "devDependencies": { "@playform/build": "0.2.1", - "browserslist": "4.24.3", + "browserslist": "4.24.4", "lightningcss": "1.28.2" }, "publishConfig": {