forked from external-repos/squoosh
Fix types after rebase onto latest dev
This commit is contained in:
4
codecs/jxl/dec/jxl_dec.d.ts
vendored
4
codecs/jxl/dec/jxl_dec.d.ts
vendored
@@ -1,5 +1,5 @@
|
|||||||
interface JXLModule extends EmscriptenWasm.Module {
|
interface JXLModule extends EmscriptenWasm.Module {
|
||||||
decode(data: BufferSource): ImageData;
|
decode(data: BufferSource): ImageData | null;
|
||||||
}
|
}
|
||||||
|
|
||||||
export default function(opts: EmscriptenWasm.ModuleOpts): JXLModule;
|
export default function(opts: EmscriptenWasm.ModuleOpts): Promise<JXLModule>;
|
||||||
|
|||||||
7
codecs/jxl/enc/jxl_enc.d.ts
vendored
7
codecs/jxl/enc/jxl_enc.d.ts
vendored
@@ -1,8 +1,7 @@
|
|||||||
import { EncodeOptions } from '../../src/codecs/jxl/encoder-meta';
|
import { EncodeOptions } from '../../../src/codecs/jxl/encoder-meta';
|
||||||
|
|
||||||
interface JXLModule extends EmscriptenWasm.Module {
|
interface JXLModule extends EmscriptenWasm.Module {
|
||||||
encode(data: BufferSource, width: number, height: number, options: EncodeOptions): Uint8Array;
|
encode(data: BufferSource, width: number, height: number, options: EncodeOptions): Uint8Array | null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export default function(opts: EmscriptenWasm.ModuleOpts): Promise<JXLModule>;
|
||||||
export default function(opts: EmscriptenWasm.ModuleOpts): JXLModule;
|
|
||||||
|
|||||||
@@ -8,5 +8,9 @@ export async function decode(data: ArrayBuffer): Promise<ImageData> {
|
|||||||
if (!emscriptenModule) emscriptenModule = initEmscriptenModule(jxl_dec, wasmUrl);
|
if (!emscriptenModule) emscriptenModule = initEmscriptenModule(jxl_dec, wasmUrl);
|
||||||
|
|
||||||
const module = await emscriptenModule;
|
const module = await emscriptenModule;
|
||||||
return module.decode(data);
|
const result = module.decode(data);
|
||||||
|
if (!result) {
|
||||||
|
throw new Error('Decoding error');
|
||||||
|
}
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,6 +10,9 @@ export async function encode(data: ImageData, options: EncodeOptions): Promise<A
|
|||||||
|
|
||||||
const module = await emscriptenModule;
|
const module = await emscriptenModule;
|
||||||
const result = module.encode(data.data, data.width, data.height, options);
|
const result = module.encode(data.data, data.width, data.height, options);
|
||||||
|
if (!result) {
|
||||||
|
throw new Error('Encoding error');
|
||||||
|
}
|
||||||
|
|
||||||
// wasm can’t run on SharedArrayBuffers, so we hard-cast to ArrayBuffer.
|
// wasm can’t run on SharedArrayBuffers, so we hard-cast to ArrayBuffer.
|
||||||
return result.buffer as ArrayBuffer;
|
return result.buffer as ArrayBuffer;
|
||||||
|
|||||||
Reference in New Issue
Block a user