Skip to content

Commit

Permalink
1.0.0
Browse files Browse the repository at this point in the history
Refactor
Bumps @types/node, @types/svgo, astro, esbuild to current latest
  • Loading branch information
NikolaRHristov committed Aug 16, 2022
1 parent 20cac24 commit f6004b4
Show file tree
Hide file tree
Showing 29 changed files with 528 additions and 429 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 1.0.0

- First stable version

## 0.0.19

- Cleanup
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ your Astro project.
There are two ways to add integrations to your project. Let's try the most
convenient option first!

### (experimental) `astro add` command
### `astro add` command

Astro includes a CLI tool for adding first party integrations: `astro add`. This
command will:
Expand Down
2 changes: 1 addition & 1 deletion dist/index.d.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type { AstroIntegration } from "astro";
import Options from "./options";
import { Options } from "./options";
/**
* It takes in an object of options, and returns an object that Astro can use to create a plugin
* @param {Options} integrationOptions - Options = {}
Expand Down
2 changes: 1 addition & 1 deletion dist/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 9 additions & 0 deletions dist/lib/format-bytes.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
/**
* It takes a number of bytes and returns a string with the number of bytes formatted in a human
* readable way
* @param {number} bytes - The number of bytes to format.
* @param [decimals=2] - The number of decimals to show.
* @returns A function that takes two parameters, bytes and decimals.
*/
declare const _default: (bytes: number, decimals?: number) => Promise<string>;
export default _default;
1 change: 1 addition & 0 deletions dist/lib/format-bytes.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 12 additions & 0 deletions dist/lib/parse.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
/**
* It takes a glob, a debug level, a type, a write function, and a read function, and then it
* compresses all the files that match the glob using the write function, and then it logs the results
* to the console using the debug level
* @param {string} glob - The glob pattern to search for files.
* @param {number} [debug=2] - The level of debug output. 0 = none, 1 = summary, 2 = detailed.
* @param {string} [type] - The type of file you're compressing. This is used for the console output.
* @param write - (data: string) => any = async (data) => data,
* @param read - (file: string) => any = async (file) =>
*/
declare const _default: (glob: string, debug?: number, type?: string, write?: (data: string) => any, read?: (file: string) => any) => Promise<void>;
export default _default;
1 change: 1 addition & 0 deletions dist/lib/parse.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions dist/lib/pipe-all.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import { Options } from "src/options";
/**
* It takes a settings object, loops through each key, and calls the appropriate function for each key
* @param {Options} settings - Options - The settings object that you pass to the pipeAll function.
* @param {number} [debug=2] - 0 = no output, 1 = output file names, 2 = output file names and sizes
*/
declare const _default: (settings: Options, debug?: number) => Promise<void>;
export default _default;
1 change: 1 addition & 0 deletions dist/lib/pipe-all.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 10 additions & 0 deletions dist/lib/sharp-read.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import IMG from "src/options/img";
/**
* It takes a sharp file and an options object, and returns a buffer of the file in the format
* specified in the options object
* @param {any} sharpFile - The sharp file object
* @param {IMG} options - IMG = {}
* @returns A function that returns a promise that resolves to a buffer.
*/
declare const _default: (sharpFile: any, options?: IMG) => Promise<any>;
export default _default;
1 change: 1 addition & 0 deletions dist/lib/sharp-read.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

31 changes: 12 additions & 19 deletions dist/options/css.d.ts
Original file line number Diff line number Diff line change
@@ -1,68 +1,61 @@
export interface beforeCompressOptions {
ast?: {};
options?: {};
}
export interface afterCompressOptions {
compressResult?: String;
options?: {};
}
export default interface CSS {
import { MinifyOptions, CompressOptions, BeforeCompressFn, AfterCompressFn, Usage } from "csso";
export default interface CSS extends MinifyOptions, CompressOptions {
[key: string]: any;
/**
* Generate a source map when true.
* @default false
*/
sourceMap?: Boolean;
sourceMap?: boolean | undefined;
/**
* Filename of input CSS, uses for source map generation.
* @default '<unknown>'
*/
filename?: String;
filename?: string | undefined;
/**
* Output debug information to stderr.
* @default false
*/
debug?: Boolean;
debug?: boolean | undefined;
/**
* Called right after parse is run.
* @default null
*/
beforeCompress?: ({}: beforeCompressOptions) => void | Array<({}: beforeCompressOptions) => void> | null;
beforeCompress?: BeforeCompressFn | BeforeCompressFn[] | undefined;
/**
* Called right after syntax.compress() is run.
* @default null
*/
afterCompress?: ({}: afterCompressOptions) => void | Array<({}: afterCompressOptions) => void> | null;
afterCompress?: AfterCompressFn | AfterCompressFn[] | undefined;
/**
* Disable | enable a structure optimisations.
* @default true
*/
restructure?: Boolean;
restructure?: 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 false
* @default astro-compress: true
*/
forceMediaMerge?: Boolean;
forceMediaMerge?: boolean;
/**
* Transform a copy of input AST if true. Useful in case of AST reuse.
* @default false
*/
clone?: Boolean;
clone?: boolean;
/**
* Specify what comments to leave:
* 'exclamation' | true – leave all exclamation comments (i.e. /*! .. *\/)
* 'first-exclamation' – remove every comment except first one false – remove all comments
* @default true
* @default astro-compress: false
*/
comments?: String | Boolean;
comments?: string | boolean | undefined;
/**
* Usage data for advanced optimisations.
* @default null
*/
usage?: {} | null;
usage?: Usage | undefined;
/**
* Function to track every step of transformation.
* @default null
Expand Down
20 changes: 19 additions & 1 deletion dist/options/html.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,13 @@ export default interface HTML {
/**
* Treat attributes in case sensitive manner (useful for custom HTML tags).
* @default false
* @default astro-compress: true
*/
caseSensitive?: Boolean;
/**
* Omit attribute values from boolean attributes.
* @default false
* @default astro-compress: true
*/
collapseBooleanAttributes?: Boolean;
/**
Expand All @@ -19,6 +21,7 @@ export default interface HTML {
/**
* Collapse white space that contributes to text nodes in a document tree.
* @default false
* @default astro-compress: true
*/
collapseWhitespace?: Boolean;
/**
Expand All @@ -39,8 +42,9 @@ export default interface HTML {
customAttrAssign?: RegExp[];
/**
* Regex that specifies custom attribute to strip newlines from (e.g. `/ng-class/`).
* @default astro-compress: new RegExp("", "i")
*/
customAttrCollapse?: String;
customAttrCollapse?: RegExp;
/**
* Arrays of regex'es that allow to support custom attribute surround expressions (e.g. `<input {{#if value}}checked="checked"{{/if}}>`).
* @default []
Expand All @@ -64,11 +68,13 @@ export default interface HTML {
/**
* Array of regex'es that allow to ignore certain comments, when matched.
* @default [/^!/, /^\s*#/]
* @default astro-compress: []
*/
ignoreCustomComments?: RegExp[];
/**
* Array of regex'es that allow to ignore certain fragments, when matched (e.g. `<?php ... ?>`, `{{ ... }}`, etc.).
* @default [/<%[\s\S]*?%>/, /<\?[\s\S]*?\?>/]
* @default astro-compress: []
*/
ignoreCustomFragments?: RegExp[];
/**
Expand All @@ -79,6 +85,7 @@ export default interface HTML {
/**
* Keep the trailing slash on singleton elements.
* @default false
* @default astro-compress: true
*/
keepClosingSlash?: Boolean;
/**
Expand All @@ -90,6 +97,7 @@ export default interface HTML {
/**
* Minify CSS in style elements and style attributes (uses clean-css).
* @default false (could be `true`, `Object`, `Function(text, type)`
* @default astro-compress: true
*/
minifyCSS?: Boolean | Object | (({}: {
text: string;
Expand All @@ -98,6 +106,7 @@ export default interface HTML {
/**
* Minify JavaScript in script elements and event attributes (uses Terser).
* @default false (could be `true`, `Object`, `Function(text, inline)`
* @default astro-compress: true
*/
minifyJS?: Boolean | Object | (({}: {
text: string;
Expand Down Expand Up @@ -129,16 +138,19 @@ export default interface HTML {
/**
* Process contents of conditional comments through minifier.
* @default false
* @default astro-compress: true
*/
processConditionalComments?: Boolean;
/**
* Array of strings corresponding to types of script elements to process through minifier (e.g. `text/ng-template`, `text/x-handlebars-template`, etc.).
* @default []
* @default astro-compress: ["module"]
*/
processScripts?: String[];
/**
* Type of quote to use for attribute values (' or ").
* @default ""
* @default astro-compress: '"'
*/
quoteCharacter?: String;
/**
Expand Down Expand Up @@ -172,34 +184,40 @@ export default interface HTML {
/**
* Remove attributes when value matches default.
* @default false
* @default astro-compress: true
*/
removeRedundantAttributes?: Boolean;
/**
* Remove `type="text/javascript"` from `script` tags.
* Other `type` attribute values are left intact
* @default false
* @default astro-compress: true
*/
removeScriptTypeAttributes?: Boolean;
/**
* Remove `type="text/css"` from `style` and `link` tags.
* Other `type` attribute values are left intact
* @default false
* @default astro-compress: true
*/
removeStyleLinkTypeAttributes?: Boolean;
/**
* Remove space between attributes whenever possible.
* Note that this will result in invalid HTML!
* @default false
* @default astro-compress: true
*/
removeTagWhitespace?: Boolean;
/**
* Sort attributes by frequency.
* @default false
* @default astro-compress: true
*/
sortAttributes?: Boolean;
/**
* Sort style classes by frequency.
* @default false
* @default astro-compress: true
*/
sortClassName?: Boolean;
/**
Expand Down
2 changes: 2 additions & 0 deletions dist/options/img.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,7 @@ export default interface IMG {
/**
* Zlib compression level, 0 (fastest, largest) to 9 (slowest, smallest)
* @default 6
* @default astro-compress: 9
*/
compressionLevel?: number;
/**
Expand All @@ -186,6 +187,7 @@ export default interface IMG {
/**
* Quantise to a palette-based image with alpha transparency support
* @default false
* @default astro-compress: true
*/
palette?: boolean;
/**
Expand Down
4 changes: 3 additions & 1 deletion dist/options/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import HTML from "./html";
import IMG from "./img";
import JS from "./js";
import SVG from "./svg";
export default interface Options {
export interface Options {
[key: string]: any;
/**
* Astro build path.
Expand Down Expand Up @@ -36,3 +36,5 @@ export default interface Options {
*/
logger?: number;
}
declare const _default: Options;
export default _default;
20 changes: 6 additions & 14 deletions dist/options/svg.d.ts
Original file line number Diff line number Diff line change
@@ -1,29 +1,21 @@
export interface js2svgOptions {
/**
* String with spaces or number of spaces
* @default 4
*/
indent?: string | number;
/**
* @default false
*/
pretty?: boolean;
}
export default interface SVG {
import { Js2SvgOptions, OptimizeOptions } from "svgo";
export default interface SVG extends OptimizeOptions {
[key: string]: any;
/**
* @default false
* @default astro-compress: true
*/
multipass?: boolean;
/**
* 'enc' or 'unenc'
* @default "base64"
*/
datauri?: string;
datauri?: "enc" | "unenc" | "base64" | undefined;
/**
* @default { indent: 4, pretty: false }
* @default astro-compress: { indent: 0, pretty: false }
*/
js2svg?: js2svgOptions;
js2svg?: Js2SvgOptions;
/**
* @default ["preset-default"]
*/
Expand Down
13 changes: 7 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "astro-compress",
"version": "0.0.19",
"version": "1.0.0",
"type": "module",
"description": "🗜️ AstroJS compression utilities. Compress HTML, CSS, JavaScript and more.",
"repository": {
Expand Down Expand Up @@ -28,7 +28,7 @@
"svg"
],
"scripts": {
"build": "esbuild --format=esm --platform=node --target=node14 --minify --outdir=dist src/index.ts && tsc"
"build": "ts-node ./scripts/build.ts && tsc"
},
"dependencies": {
"csso": "5.0.5",
Expand All @@ -42,11 +42,12 @@
"devDependencies": {
"@types/csso": "5.0.0",
"@types/html-minifier-terser": "7.0.0",
"@types/node": "18.7.5",
"@types/node": "18.7.6",
"@types/sharp": "0.30.5",
"@types/svgo": "2.6.3",
"astro": "1.0.5",
"esbuild": "0.15.3",
"@types/svgo": "2.6.4",
"astro": "1.0.6",
"esbuild": "0.15.4",
"ts-node": "10.9.1",
"typescript": "4.7.4"
}
}
Loading

0 comments on commit f6004b4

Please sign in to comment.