@divriots/jampack 0.2.3 → 0.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/utils.js CHANGED
@@ -1,5 +1,3 @@
1
- import * as url from 'url';
2
- import * as path from 'path';
3
1
  export function formatBytes(bytes, decimals = 2) {
4
2
  if (!+bytes)
5
3
  return '0 Bytes';
@@ -9,17 +7,6 @@ export function formatBytes(bytes, decimals = 2) {
9
7
  const i = Math.floor(Math.log(bytes) / Math.log(k));
10
8
  return `${(bytes / Math.pow(k, i)).toFixed(dm)} ${sizes[i]}`;
11
9
  }
12
- export function isLocal(src) {
13
- const u = url.parse(src);
14
- return !u.host;
15
- }
16
- export function translateSrc(projectRoot, htmlRelativePath, src) {
17
- if (!isLocal(src)) {
18
- throw new Error('Source should be local');
19
- }
20
- const srcAbsolutePath = path.join(projectRoot, src.startsWith('/') ? '' : htmlRelativePath, src);
21
- return path.resolve(srcAbsolutePath);
22
- }
23
10
  export function isNumeric(value) {
24
11
  return /^\d+$/.test(value);
25
12
  }
@@ -0,0 +1 @@
1
+ export declare const VERSION: string;
@@ -0,0 +1,3 @@
1
+ // @ts-ignore
2
+ import json from '../package.json' assert { type: 'json' };
3
+ export const VERSION = json.version;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@divriots/jampack",
3
- "version": "0.2.3",
3
+ "version": "0.4.0",
4
4
  "description": "Packer for static websites",
5
5
  "author": "Georges Gomes @georges-gomes",
6
6
  "bin": {
@@ -16,7 +16,7 @@
16
16
  "/dist"
17
17
  ],
18
18
  "dependencies": {
19
- "@swc/core": "^1.3.4",
19
+ "@swc/core": "^1.3.21",
20
20
  "@types/cheerio": "^0.22.31",
21
21
  "@types/commander": "^2.12.2",
22
22
  "@types/csso": "^5.0.0",
@@ -25,25 +25,27 @@
25
25
  "@types/sharp": "^0.31.0",
26
26
  "@types/svgo": "^2.6.4",
27
27
  "@types/table": "^6.3.2",
28
- "chalk": "^5.0.1",
28
+ "chalk": "^5.1.2",
29
29
  "cheerio": "0.22.0",
30
30
  "commander": "^9.4.1",
31
31
  "csso": "^5.0.5",
32
+ "file-type": "^18.0.0",
32
33
  "globby": "^13.1.2",
33
- "html-minifier-terser": "^7.0.0",
34
+ "hasha": "^5.2.2",
35
+ "html-minifier-terser": "^7.1.0",
34
36
  "kleur": "^4.1.5",
35
37
  "mini-svg-data-uri": "^1.4.4",
36
38
  "ora": "^6.1.2",
37
- "sharp": "^0.31.1",
39
+ "sharp": "^0.31.2",
38
40
  "svgo": "^2.8.0",
39
- "table": "^6.8.0"
41
+ "table": "^6.8.1"
40
42
  },
41
43
  "devDependencies": {
42
- "@types/node": "^16.9.4",
44
+ "@types/node": "^16.11.59",
43
45
  "shx": "^0.3.3",
44
46
  "ts-node": "^10.2.1",
45
- "tslib": "^2.3.1",
46
- "typescript": "^4.8.4"
47
+ "tslib": "^2.4.1",
48
+ "typescript": "^4.9.3"
47
49
  },
48
50
  "scripts": {
49
51
  "watch": "pnpm build --watch",
@@ -1 +0,0 @@
1
- export {};
@@ -1 +0,0 @@
1
- export {};
@@ -1 +0,0 @@
1
- export {};
@@ -1 +0,0 @@
1
- export {};
package/dist/options.d.ts DELETED
@@ -1,30 +0,0 @@
1
- export declare type WebpOptions = {
2
- effort: number;
3
- mode: 'lossless' | 'lossly';
4
- quality: number;
5
- };
6
- export declare type Options = {
7
- image: {
8
- embed_size: number;
9
- srcset_min_width: number;
10
- srcset_max_width: number;
11
- jpeg: {
12
- options: {
13
- quality: number;
14
- mozjpeg: boolean;
15
- };
16
- };
17
- png: {
18
- options: {
19
- compressionLevel: number;
20
- };
21
- };
22
- webp: {
23
- options_lossless: WebpOptions;
24
- options_lossly: WebpOptions;
25
- };
26
- };
27
- };
28
- declare const default_options: Options;
29
- export declare function fast(): void;
30
- export default default_options;
package/dist/options.js DELETED
@@ -1,59 +0,0 @@
1
- const default_options = {
2
- image: {
3
- embed_size: 400,
4
- srcset_min_width: 400,
5
- srcset_max_width: 5120,
6
- jpeg: {
7
- options: {
8
- quality: 80,
9
- mozjpeg: true
10
- }
11
- },
12
- png: {
13
- options: {
14
- compressionLevel: 9,
15
- }
16
- },
17
- webp: {
18
- options_lossless: {
19
- effort: 4,
20
- quality: 80,
21
- mode: 'lossless'
22
- },
23
- options_lossly: {
24
- effort: 4,
25
- quality: 80,
26
- mode: 'lossly'
27
- }
28
- }
29
- }
30
- };
31
- const fast_options_override = {
32
- image: {
33
- embed_size: 0,
34
- srcset_min_width: 1024,
35
- srcset_max_width: 1024,
36
- jpeg: {
37
- options: {
38
- mozjpeg: false
39
- }
40
- },
41
- png: {
42
- options: {
43
- compressionLevel: 0,
44
- }
45
- },
46
- webp: {
47
- options_lossless: {
48
- effort: 0,
49
- },
50
- options_lossly: {
51
- effort: 0,
52
- }
53
- }
54
- }
55
- };
56
- export function fast() {
57
- Object.assign(default_options, fast_options_override);
58
- }
59
- export default default_options;
@@ -1,25 +0,0 @@
1
- export declare type Args = {
2
- nowrite?: boolean;
3
- };
4
- export declare type Result = {
5
- file: string;
6
- originalSize: number;
7
- compressedSize: number;
8
- };
9
- export declare type Summary = {
10
- nbFiles: number;
11
- nbFilesCompressed: number;
12
- dataLenUncompressed: number;
13
- dataLenCompressed: number;
14
- };
15
- export declare class GlobalState {
16
- dir: string;
17
- args: Args;
18
- compressedFiles: Set<string>;
19
- compressedFilesResult: Result[];
20
- summary: Summary;
21
- summaryByExtension: Record<string, Summary>;
22
- addFile(r: Result): void;
23
- }
24
- declare const state: GlobalState;
25
- export default state;
@@ -1,45 +0,0 @@
1
- import path from "path";
2
- export class GlobalState {
3
- constructor() {
4
- this.dir = 'dist';
5
- this.args = {};
6
- this.compressedFiles = new Set();
7
- this.compressedFilesResult = [];
8
- this.summary = {
9
- nbFiles: 0,
10
- nbFilesCompressed: 0,
11
- dataLenCompressed: 0,
12
- dataLenUncompressed: 0
13
- };
14
- this.summaryByExtension = {};
15
- }
16
- addFile(r) {
17
- const isCompressed = r.compressedSize < r.originalSize ? 1 : 0;
18
- this.compressedFiles.add(r.file);
19
- this.compressedFilesResult.push(r);
20
- this.summary.nbFiles++;
21
- state.summary.nbFilesCompressed += isCompressed;
22
- state.summary.dataLenUncompressed += r.originalSize;
23
- state.summary.dataLenCompressed += r.compressedSize;
24
- const ext = path.extname(r.file);
25
- if (ext) {
26
- let summary = this.summaryByExtension[ext];
27
- if (!summary) {
28
- summary = {
29
- nbFiles: 0,
30
- nbFilesCompressed: 0,
31
- dataLenUncompressed: 0,
32
- dataLenCompressed: 0
33
- };
34
- this.summaryByExtension[ext] = summary;
35
- }
36
- summary.nbFiles++;
37
- summary.nbFilesCompressed += isCompressed;
38
- summary.dataLenUncompressed += r.originalSize;
39
- summary.dataLenCompressed += r.compressedSize;
40
- }
41
- }
42
- ;
43
- }
44
- const state = new GlobalState();
45
- export default state;