@bit-blazer/libsquoosh 0.5.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/README.md +167 -0
- package/build/auto-optimizer.d.ts +23 -0
- package/build/auto-optimizer.d.ts.map +1 -0
- package/build/avif_node_dec-6389baeb.wasm +0 -0
- package/build/avif_node_enc-5646e209.wasm +0 -0
- package/build/avif_node_enc_mt-6b0f9451.wasm +0 -0
- package/build/avif_node_enc_mt-f295f4f0.js +1 -0
- package/build/avif_node_enc_mt.worker-4dc93f28.js +1 -0
- package/build/codecs.d.ts +222 -0
- package/build/codecs.d.ts.map +1 -0
- package/build/emscripten-utils.d.ts +3 -0
- package/build/emscripten-utils.d.ts.map +1 -0
- package/build/image_data.d.ts +7 -0
- package/build/image_data.d.ts.map +1 -0
- package/build/imagequant_node-a4aafbae.wasm +0 -0
- package/build/index.d.ts +97 -0
- package/build/index.d.ts.map +1 -0
- package/build/index.js +129 -0
- package/build/jxl_node_dec-c51936e8.wasm +0 -0
- package/build/jxl_node_enc-b8ea914c.wasm +0 -0
- package/build/mozjpeg_node_dec-4fa549e7.wasm +0 -0
- package/build/mozjpeg_node_enc-7b3a94eb.wasm +0 -0
- package/build/rotate-e8fb6784.wasm +0 -0
- package/build/squoosh_oxipng_bg-60d7d0b0.wasm +0 -0
- package/build/squoosh_png_bg-afa2f8d4.wasm +0 -0
- package/build/squoosh_resize_bg-3d426466.wasm +0 -0
- package/build/visdif-f4d1bd06.wasm +0 -0
- package/build/webp_node_dec-dde61ffa.wasm +0 -0
- package/build/webp_node_enc-21e7a82d.wasm +0 -0
- package/build/worker_pool.d.ts +24 -0
- package/build/worker_pool.d.ts.map +1 -0
- package/build/wp2_node_dec-87bef8e5.wasm +0 -0
- package/build/wp2_node_enc-683ca61a.wasm +0 -0
- package/package.json +42 -0
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
export declare function pathify(path: string): string;
|
|
2
|
+
export declare function instantiateEmscriptenWasm<T extends EmscriptenWasm.Module>(factory: EmscriptenWasm.ModuleFactory<T>, path: string, workerJS?: string): Promise<T>;
|
|
3
|
+
//# sourceMappingURL=emscripten-utils.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"emscripten-utils.d.ts","sourceRoot":"","sources":["../../../../libsquoosh/src/emscripten-utils.ts"],"names":[],"mappings":"AAEA,wBAAgB,OAAO,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAK5C;AAED,wBAAgB,yBAAyB,CAAC,CAAC,SAAS,cAAc,CAAC,MAAM,EACvE,OAAO,EAAE,cAAc,CAAC,aAAa,CAAC,CAAC,CAAC,EACxC,IAAI,EAAE,MAAM,EACZ,QAAQ,GAAE,MAAW,GACpB,OAAO,CAAC,CAAC,CAAC,CAYZ"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"image_data.d.ts","sourceRoot":"","sources":["../../../../libsquoosh/src/image_data.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,OAAO,OAAO,SAAS;IAC5B,QAAQ,CAAC,IAAI,EAAE,iBAAiB,CAAC;IACjC,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;gBAEZ,IAAI,EAAE,iBAAiB,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM;CAKnE"}
|
|
Binary file
|
package/build/index.d.ts
ADDED
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
import { codecs as encoders, preprocessors } from './codecs.js';
|
|
2
|
+
import WorkerPool from './worker_pool.js';
|
|
3
|
+
import type ImageData from './image_data';
|
|
4
|
+
export { ImagePool, encoders, preprocessors };
|
|
5
|
+
declare type EncoderKey = keyof typeof encoders;
|
|
6
|
+
declare type PreprocessorKey = keyof typeof preprocessors;
|
|
7
|
+
declare function decodeFile({ file, }: {
|
|
8
|
+
file: ArrayBuffer | ArrayLike<number>;
|
|
9
|
+
}): Promise<{
|
|
10
|
+
bitmap: ImageData;
|
|
11
|
+
size: number;
|
|
12
|
+
}>;
|
|
13
|
+
declare function preprocessImage({ preprocessorName, options, image, }: {
|
|
14
|
+
preprocessorName: PreprocessorKey;
|
|
15
|
+
options: any;
|
|
16
|
+
image: {
|
|
17
|
+
bitmap: ImageData;
|
|
18
|
+
};
|
|
19
|
+
}): Promise<{
|
|
20
|
+
bitmap: ImageData;
|
|
21
|
+
}>;
|
|
22
|
+
declare function encodeImage({ bitmap: bitmapIn, encName, encConfig, optimizerButteraugliTarget, maxOptimizerRounds, }: {
|
|
23
|
+
bitmap: ImageData;
|
|
24
|
+
encName: EncoderKey;
|
|
25
|
+
encConfig: any;
|
|
26
|
+
optimizerButteraugliTarget: number;
|
|
27
|
+
maxOptimizerRounds: number;
|
|
28
|
+
}): Promise<{
|
|
29
|
+
optionsUsed: any;
|
|
30
|
+
binary: Uint8Array;
|
|
31
|
+
extension: "jpg" | "webp" | "avif" | "jxl" | "wp2" | "png";
|
|
32
|
+
size: number;
|
|
33
|
+
}>;
|
|
34
|
+
declare type EncodeParams = {
|
|
35
|
+
operation: 'encode';
|
|
36
|
+
} & Parameters<typeof encodeImage>[0];
|
|
37
|
+
declare type DecodeParams = {
|
|
38
|
+
operation: 'decode';
|
|
39
|
+
} & Parameters<typeof decodeFile>[0];
|
|
40
|
+
declare type PreprocessParams = {
|
|
41
|
+
operation: 'preprocess';
|
|
42
|
+
} & Parameters<typeof preprocessImage>[0];
|
|
43
|
+
declare type JobMessage = EncodeParams | DecodeParams | PreprocessParams;
|
|
44
|
+
/**
|
|
45
|
+
* Represents an ingested image.
|
|
46
|
+
*/
|
|
47
|
+
declare class Image {
|
|
48
|
+
file: ArrayBuffer | ArrayLike<number>;
|
|
49
|
+
workerPool: WorkerPool<JobMessage, any>;
|
|
50
|
+
decoded: Promise<{
|
|
51
|
+
bitmap: ImageData;
|
|
52
|
+
}>;
|
|
53
|
+
encodedWith: {
|
|
54
|
+
[key: string]: any;
|
|
55
|
+
};
|
|
56
|
+
constructor(workerPool: WorkerPool<JobMessage, any>, file: ArrayBuffer | ArrayLike<number>);
|
|
57
|
+
/**
|
|
58
|
+
* Define one or several preprocessors to use on the image.
|
|
59
|
+
* @param {object} preprocessOptions - An object with preprocessors to use, and their settings.
|
|
60
|
+
* @returns {Promise<undefined>} - A promise that resolves when all preprocessors have completed their work.
|
|
61
|
+
*/
|
|
62
|
+
preprocess(preprocessOptions?: {}): Promise<void>;
|
|
63
|
+
/**
|
|
64
|
+
* Define one or several encoders to use on the image.
|
|
65
|
+
* @param {object} encodeOptions - An object with encoders to use, and their settings.
|
|
66
|
+
* @returns {Promise<void>} - A promise that resolves when the image has been encoded with all the specified encoders.
|
|
67
|
+
*/
|
|
68
|
+
encode(encodeOptions?: {
|
|
69
|
+
optimizerButteraugliTarget?: number;
|
|
70
|
+
maxOptimizerRounds?: number;
|
|
71
|
+
} & {
|
|
72
|
+
[key in EncoderKey]?: any;
|
|
73
|
+
}): Promise<void>;
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* A pool where images can be ingested and squooshed.
|
|
77
|
+
*/
|
|
78
|
+
declare class ImagePool {
|
|
79
|
+
workerPool: WorkerPool<JobMessage, any>;
|
|
80
|
+
/**
|
|
81
|
+
* Create a new pool.
|
|
82
|
+
* @param {number} [threads] - Number of concurrent image processes to run in the pool.
|
|
83
|
+
*/
|
|
84
|
+
constructor(threads: number);
|
|
85
|
+
/**
|
|
86
|
+
* Ingest an image into the image pool.
|
|
87
|
+
* @param {ArrayBuffer | ArrayLike<number>} file - The image that should be ingested and decoded.
|
|
88
|
+
* @returns {Image} - A custom class reference to the decoded image.
|
|
89
|
+
*/
|
|
90
|
+
ingestImage(file: ArrayBuffer | ArrayLike<number>): Image;
|
|
91
|
+
/**
|
|
92
|
+
* Closes the underlying image processing pipeline. The already processed images will still be there, but no new processing can start.
|
|
93
|
+
* @returns {Promise<void>} - A promise that resolves when the underlying pipeline has closed.
|
|
94
|
+
*/
|
|
95
|
+
close(): Promise<void>;
|
|
96
|
+
}
|
|
97
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../libsquoosh/src/index.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,MAAM,IAAI,QAAQ,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAChE,OAAO,UAAU,MAAM,kBAAkB,CAAC;AAE1C,OAAO,KAAK,SAAS,MAAM,cAAc,CAAC;AAG1C,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,aAAa,EAAE,CAAC;AAC9C,aAAK,UAAU,GAAG,MAAM,OAAO,QAAQ,CAAC;AACxC,aAAK,eAAe,GAAG,MAAM,OAAO,aAAa,CAAC;AAElD,iBAAe,UAAU,CAAC,EACxB,IAAI,GACL,EAAE;IACD,IAAI,EAAE,WAAW,GAAG,SAAS,CAAC,MAAM,CAAC,CAAC;CACvC,GAAG,OAAO,CAAC;IAAE,MAAM,EAAE,SAAS,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE,CAAC,CAmB/C;AAED,iBAAe,eAAe,CAAC,EAC7B,gBAAgB,EAChB,OAAO,EACP,KAAK,GACN,EAAE;IACD,gBAAgB,EAAE,eAAe,CAAC;IAClC,OAAO,EAAE,GAAG,CAAC;IACb,KAAK,EAAE;QAAE,MAAM,EAAE,SAAS,CAAA;KAAE,CAAC;CAC9B;YADkB,SAAS;GAU3B;AAED,iBAAe,WAAW,CAAC,EACzB,MAAM,EAAE,QAAQ,EAChB,OAAO,EACP,SAAS,EACT,0BAA0B,EAC1B,kBAAkB,GACnB,EAAE;IACD,MAAM,EAAE,SAAS,CAAC;IAClB,OAAO,EAAE,UAAU,CAAC;IACpB,SAAS,EAAE,GAAG,CAAC;IACf,0BAA0B,EAAE,MAAM,CAAC;IACnC,kBAAkB,EAAE,MAAM,CAAC;CAC5B;;;;;GA4DA;AAED,aAA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