Skip to content

Commit

Permalink
squash!
Browse files Browse the repository at this point in the history
  • Loading branch information
NikolaRHristov committed Jan 19, 2024
1 parent 5ab78bb commit 879281b
Show file tree
Hide file tree
Showing 17 changed files with 103 additions and 107 deletions.
6 changes: 3 additions & 3 deletions Source/Function/Directory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,21 @@
* TODO: Test this for performance, mainly importing the Integration.js System variable
*
*/
export default (async (...[Path]: Parameters<Type>) => {
export default ((async (...[Path]: Parameters<Type>) => {
let Clean = (await import("path")).parse(Path).dir;

Clean = (await import("path")).normalize(Clean);
Clean = Clean.replace(/\\/g, "/");
Clean = Clean.replace(
(await import("../Function/Integration.js")).System,
""
"",
);

if (!Clean.endsWith("/")) {
Clean += "/";
}

return Clean;
}) satisfies Type as Type;
}) satisfies Type as Type);

import type Type from "../Interface/Directory.js";
14 changes: 8 additions & 6 deletions Source/Function/Image/Writesharp.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* @module Image
*
*/
export default (async (...[Option, { Buffer, Input }]: Parameters<Type>) => {
export default ((async (...[Option, { Buffer, Input }]: Parameters<Type>) => {
const File = Input.split(".").pop();

if (!File) {
Expand All @@ -13,13 +13,13 @@ export default (async (...[Option, { Buffer, Input }]: Parameters<Type>) => {
typeof _Map[File as File] !== "undefined"
? _Map[File as File]
: typeof Option[File] !== "undefined"
? File
: false;
? File
: false;

if (
Type &&
["avif", "gif", "heif", "jpeg", "png", "raw", "tiff", "webp"].includes(
Type
Type,
) &&
typeof Option[Type] !== "undefined" &&
Option[Type] !== false
Expand All @@ -29,11 +29,13 @@ export default (async (...[Option, { Buffer, Input }]: Parameters<Type>) => {
(await Buffer[Type](
Option[Type] !== true
? Option[Type]
: (await import("../../Variable/Image/sharp.js")).default
: (
await import("../../Variable/Image/sharp.js")
).default,
).toBuffer())
);
}
}) satisfies Type as Type;
}) satisfies Type as Type);

import type Type from "../../Interface/Image/Writesharp.js";
import type File from "../../Type/Image/Filesharp.js";
Expand Down
40 changes: 17 additions & 23 deletions Source/Function/Integration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@
// TODO: Test this for security
export let System: string;

export default ((...[_Option = {}]: Parameters<Type>) => {
export default (((...[_Option = {}]: Parameters<Type>) => {
Object.entries(_Option).forEach(([Key, Value]) =>
Object.defineProperty(_Option, Key, {
value:
Value === true
? Default[Key as keyof typeof Default]
: _Option[Key as keyof typeof _Option],
})
}),
);

const {
Expand Down Expand Up @@ -43,17 +43,15 @@ export default ((...[_Option = {}]: Parameters<Type>) => {
Object.entries(Parser).forEach(([Key, Value]) =>
Object.defineProperty(Parser, Key, {
value: Array.isArray(Value) ? Value : [Value],
})
}),
);
}

return {
name: "astro-compress",
hooks: {
"astro:config:done": async ({
config: {
outDir: { pathname },
},
config: { outDir: { pathname } },
}) => {
System = (await import("path"))
.parse(pathname)
Expand All @@ -67,9 +65,9 @@ export default ((...[_Option = {}]: Parameters<Type>) => {
console.log(
`\n${(await import("kleur/colors")).bgGreen(
(await import("kleur/colors")).black(
" AstroCompress processing "
)
)}`
" AstroCompress processing ",
),
)}`,
);

if (typeof _Map !== "object") {
Expand Down Expand Up @@ -123,7 +121,7 @@ export default ((...[_Option = {}]: Parameters<Type>) => {
return (await import("csso")).minify(
Buffer.toString(),
// @ts-expect-error
Setting["csso"]
Setting["csso"],
).css;
}

Expand All @@ -133,7 +131,7 @@ export default ((...[_Option = {}]: Parameters<Type>) => {
).minify(
Buffer.toString(),
// @ts-expect-error
Setting["html-minifier-terser"]
Setting["html-minifier-terser"],
);
}

Expand All @@ -145,7 +143,7 @@ export default ((...[_Option = {}]: Parameters<Type>) => {
).minify(
Buffer.toString(),
// @ts-expect-error
Setting["terser"]
Setting["terser"],
)
).code ?? Buffer
);
Expand All @@ -170,7 +168,7 @@ export default ((...[_Option = {}]: Parameters<Type>) => {
).optimize(
Buffer.toString(),
// @ts-expect-error
Setting["svgo"]
Setting["svgo"],
);

return Data ?? Buffer;
Expand All @@ -194,10 +192,10 @@ export default ((...[_Option = {}]: Parameters<Type>) => {
await import(
"files-pipe/Target/Function/Bytes.js"
)
).default(Plan.Info.Total)}.`
)}`
).default(Plan.Info.Total)}.`,
)}`
: false,
} satisfies Action)
} satisfies Action),
);

if (File === "Image") {
Expand Down Expand Up @@ -238,7 +236,7 @@ export default ((...[_Option = {}]: Parameters<Type>) => {
// },
},
};
}) satisfies Type as Type;
}) satisfies Type as Type);

import type Onsharp from "../Interface/Image/Onsharp.js";
import type Type from "../Interface/Integration.js";
Expand All @@ -249,14 +247,10 @@ import type Path from "files-pipe/Target/Type/Path.js";
export const { default: Default } = await import("../Variable/Option.js");

export const {
default: {
Cache: { Search },
},
default: { Cache: { Search } },
} = await import("files-pipe/Target/Variable/Option.js");

export const { default: Merge } = await import(
"../Function/Merge.js"
);
export const { default: Merge } = await import("../Function/Merge.js");

export const { default: Defaultsharp } = await import("sharp");

Expand Down
4 changes: 2 additions & 2 deletions Source/Function/Merge.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
* @module Merge
*
*/
export default (await import("deepmerge-ts")).deepmergeCustom<Generic>({
export default ((await import("deepmerge-ts")).deepmergeCustom<Generic>({
mergeArrays: false,
}) satisfies Type<Generic> as Type<Generic>;
}) satisfies Type<Generic> as Type<Generic>);

import type Type from "../Interface/Merge.js";
import type { Generic } from "../Interface/Merge.js";
2 changes: 1 addition & 1 deletion Source/Interface/CSS/lightningcss.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@ export default interface Type
minify?: boolean;
}

import type { TransformOptions, CustomAtRules } from "lightningcss";
import type { CustomAtRules, TransformOptions } from "lightningcss";
4 changes: 1 addition & 3 deletions Source/Interface/Merge.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,7 @@ export default interface Type<
* @param ...Objects - An arbitrary number of objects to be merged.
*
*/
<Ts extends readonly unknown[]>(
...Objects: Ts
): DeepMergeHKT<
<Ts extends readonly unknown[]>(...Objects: Ts): DeepMergeHKT<
Ts,
GetDeepMergeMergeFunctionsURIs<PMF>,
DeepMergeBuiltInMetaData
Expand Down
4 changes: 2 additions & 2 deletions Source/Variable/CSS/csso.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@
* @module CSS
*
*/
export default {
export default ({
comments: false,
forceMediaMerge: true,
restructure: false,
} satisfies Type;
} satisfies Type);

import type Type from "../../Interface/CSS/csso.js";
4 changes: 2 additions & 2 deletions Source/Variable/CSS/lightningcss.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
* @module CSS
*
*/
export default {
export default ({
minify: true,
} satisfies Type;
} satisfies Type);

import type Type from "../../Interface/CSS/lightningcss.js";
4 changes: 2 additions & 2 deletions Source/Variable/HTML/html-minifier-terser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* @module HTML
*
*/
export default {
export default ({
caseSensitive: true,
collapseInlineTagWhitespace: false,
collapseWhitespace: true,
Expand Down Expand Up @@ -79,6 +79,6 @@ export default {
sortClassName: true,
trimCustomFragments: true,
useShortDoctype: false,
} satisfies Type;
} satisfies Type);

import type Type from "../../Type/HTML/html-minifier-terser.js";
4 changes: 2 additions & 2 deletions Source/Variable/Image/Mapsharp.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* @module Image
*
*/
export default {
export default ({
avci: "avif",
avcs: "avif",
avifs: "avif",
Expand All @@ -14,6 +14,6 @@ export default {
jpe: "jpeg",
apng: "png",
jpg: "jpeg",
} satisfies Type;
} satisfies Type);

import type Type from "../../Interface/Map.js";
4 changes: 2 additions & 2 deletions Source/Variable/Image/sharp.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* @module Image
*
*/
export default {
export default ({
avif: {
chromaSubsampling: "4:4:4",
effort: 9.0,
Expand All @@ -28,6 +28,6 @@ export default {
webp: {
effort: 6.0,
},
} satisfies Type;
} satisfies Type);

import type Type from "../../Interface/Image/sharp.js";
4 changes: 2 additions & 2 deletions Source/Variable/JavaScript/terser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* @module JavaScript
*
*/
export default {
export default ({
ecma: 5,
enclose: false,
keep_classnames: false,
Expand All @@ -14,6 +14,6 @@ export default {
format: {
comments: false,
},
} satisfies Type;
} satisfies Type);

import type Type from "../../Type/JavaScript/terser.js";
4 changes: 2 additions & 2 deletions Source/Variable/Map.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@
* @module Map
*
*/
export default {
export default ({
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}",
SVG: "**/*.svg",
} satisfies Type;
} satisfies Type);

import type Type from "../Interface/Map.js";
Loading

0 comments on commit 879281b

Please sign in to comment.