mirror of
https://github.com/GoogleChromeLabs/squoosh.git
synced 2025-11-12 16:57:26 +00:00
Types were handwritten
This commit is contained in:
@@ -11,14 +11,21 @@ $(filter enc/%,$(OUT_JS)): enc/mozjpeg_enc.cpp
|
|||||||
|
|
||||||
%.js:
|
%.js:
|
||||||
$(CXX) \
|
$(CXX) \
|
||||||
-I ${MOZJPEG}/include \
|
-O3 \
|
||||||
-L ${MOZJPEG}/lib \
|
-flto \
|
||||||
${CXXFLAGS} \
|
-s FILESYSTEM=0 \
|
||||||
${LDFLAGS} \
|
-s PTHREAD_POOL_SIZE=navigator.hardwareConcurrency \
|
||||||
--bind \
|
-s ALLOW_MEMORY_GROWTH=1 \
|
||||||
|
-s TEXTDECODER=2 \
|
||||||
|
-s NODEJS_CATCH_EXIT=0 -s NODEJS_CATCH_REJECTION=0 \
|
||||||
-s ENVIRONMENT=$(ENVIRONMENT) \
|
-s ENVIRONMENT=$(ENVIRONMENT) \
|
||||||
-s EXPORT_ES6=1 \
|
-s EXPORT_ES6=1 \
|
||||||
|
-lembind \
|
||||||
|
${CXXFLAGS} \
|
||||||
|
${LDFLAGS} \
|
||||||
-o $@ \
|
-o $@ \
|
||||||
|
-I ${MOZJPEG}/include \
|
||||||
|
-L ${MOZJPEG}/lib \
|
||||||
-ljpeg \
|
-ljpeg \
|
||||||
${MOZJPEG}/lib/rdswitch.o \
|
${MOZJPEG}/lib/rdswitch.o \
|
||||||
$+
|
$+
|
||||||
|
|||||||
37
codecs/mozjpeg/enc/mozjpeg_enc.d.ts
vendored
Normal file
37
codecs/mozjpeg/enc/mozjpeg_enc.d.ts
vendored
Normal file
@@ -0,0 +1,37 @@
|
|||||||
|
export const enum MozJpegColorSpace {
|
||||||
|
GRAYSCALE = 1,
|
||||||
|
RGB,
|
||||||
|
YCbCr,
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface EncodeOptions {
|
||||||
|
quality: number;
|
||||||
|
baseline: boolean;
|
||||||
|
arithmetic: boolean;
|
||||||
|
progressive: boolean;
|
||||||
|
optimize_coding: boolean;
|
||||||
|
smoothing: number;
|
||||||
|
color_space: MozJpegColorSpace;
|
||||||
|
quant_table: number;
|
||||||
|
trellis_multipass: boolean;
|
||||||
|
trellis_opt_zero: boolean;
|
||||||
|
trellis_opt_table: boolean;
|
||||||
|
trellis_loops: number;
|
||||||
|
auto_subsample: boolean;
|
||||||
|
chroma_subsample: number;
|
||||||
|
separate_chroma_quality: boolean;
|
||||||
|
chroma_quality: number;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface MozJPEGModule extends EmscriptenWasm.Module {
|
||||||
|
encode(
|
||||||
|
data: BufferSource,
|
||||||
|
width: number,
|
||||||
|
height: number,
|
||||||
|
options: EncodeOptions,
|
||||||
|
): Uint8Array;
|
||||||
|
}
|
||||||
|
|
||||||
|
declare var moduleFactory: EmscriptenWasm.ModuleFactory<MozJPEGModule>;
|
||||||
|
|
||||||
|
export default moduleFactory;
|
||||||
@@ -20,12 +20,12 @@
|
|||||||
pkgs = nixpkgs.legacyPackages.${system};
|
pkgs = nixpkgs.legacyPackages.${system};
|
||||||
in
|
in
|
||||||
with pkgs;
|
with pkgs;
|
||||||
{
|
rec {
|
||||||
packages = rec {
|
packages = rec {
|
||||||
default = mozjpeg-squoosh;
|
default = mozjpeg-squoosh;
|
||||||
mozjpeg-squoosh = stdenv.mkDerivation {
|
mozjpeg-squoosh = stdenv.mkDerivation {
|
||||||
name = "mozjpeg-squoosh";
|
name = "mozjpeg-squoosh";
|
||||||
src = ./.;
|
src = lib.cleanSource ./.;
|
||||||
nativeBuildInputs = [
|
nativeBuildInputs = [
|
||||||
emscripten
|
emscripten
|
||||||
mozjpeg
|
mozjpeg
|
||||||
@@ -38,7 +38,7 @@
|
|||||||
'';
|
'';
|
||||||
installPhase = ''
|
installPhase = ''
|
||||||
mkdir -p $out
|
mkdir -p $out
|
||||||
cp enc/*.{wasm,js} $out
|
cp -r enc $out
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
mozjpeg = stdenv.mkDerivation {
|
mozjpeg = stdenv.mkDerivation {
|
||||||
@@ -77,14 +77,15 @@
|
|||||||
dontFixup = true;
|
dontFixup = true;
|
||||||
};
|
};
|
||||||
installScript = writeShellScriptBin "install.sh" ''
|
installScript = writeShellScriptBin "install.sh" ''
|
||||||
${pkgs.coreutils}/bin/mkdir build
|
${pkgs.coreutils}/bin/rm -rf build
|
||||||
${pkgs.coreutils}/bin/cp ${mozjpeg-squoosh}/* build/
|
${pkgs.coreutils}/bin/mkdir -p build
|
||||||
|
${pkgs.rsync}/bin/rsync --chmod=u+w -r ${mozjpeg-squoosh}/* build/
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
apps = {
|
apps = {
|
||||||
install = {
|
install = {
|
||||||
type = "app";
|
type = "app";
|
||||||
# program = "
|
program = "${packages.installScript}/bin/install.sh";
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
4
codecs/mozjpeg/package-lock.json
generated
4
codecs/mozjpeg/package-lock.json
generated
@@ -1,4 +0,0 @@
|
|||||||
{
|
|
||||||
"name": "mozjpeg_enc",
|
|
||||||
"lockfileVersion": 1
|
|
||||||
}
|
|
||||||
@@ -1,5 +0,0 @@
|
|||||||
{
|
|
||||||
"scripts": {
|
|
||||||
"build": "../build-cpp.sh"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -13,7 +13,7 @@
|
|||||||
import {
|
import {
|
||||||
EncodeOptions,
|
EncodeOptions,
|
||||||
MozJpegColorSpace,
|
MozJpegColorSpace,
|
||||||
} from 'codecs/mozjpeg/enc/mozjpeg_enc';
|
} from 'codecs/mozjpeg/build/enc/mozjpeg_enc';
|
||||||
export { EncodeOptions, MozJpegColorSpace };
|
export { EncodeOptions, MozJpegColorSpace };
|
||||||
|
|
||||||
export const label = 'MozJPEG';
|
export const label = 'MozJPEG';
|
||||||
|
|||||||
@@ -10,7 +10,9 @@
|
|||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
import mozjpeg_enc, { MozJPEGModule } from 'codecs/mozjpeg/enc/mozjpeg_enc';
|
import mozjpeg_enc, {
|
||||||
|
MozJPEGModule,
|
||||||
|
} from 'codecs/mozjpeg/build/enc/mozjpeg_enc';
|
||||||
import { EncodeOptions } from '../shared/meta';
|
import { EncodeOptions } from '../shared/meta';
|
||||||
import { initEmscriptenModule } from 'features/worker-utils';
|
import { initEmscriptenModule } from 'features/worker-utils';
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user