@pbk20191/icodec 0.6.3 → 0.6.5
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/avif-dec.wasm +0 -0
- package/dist/avif-enc.wasm +0 -0
- package/dist/heic-enc.wasm +0 -0
- package/dist/jxl-dec.wasm +0 -0
- package/dist/jxl-enc.wasm +0 -0
- package/dist/mozjpeg.wasm +0 -0
- package/dist/pngquant.js +16 -16
- package/dist/pngquant_bg.wasm +0 -0
- package/dist/webp-enc.js +1 -1
- package/dist/webp-enc.wasm +0 -0
- package/dist/wp2-dec.wasm +0 -0
- package/dist/wp2-enc.wasm +0 -0
- package/lib/jpeg.d.ts +2 -2
- package/lib/jxl.d.ts +2 -2
- package/lib/webp.d.ts +11 -2
- package/lib/wp2.d.ts +2 -2
- package/package.json +9 -2
- package/versions.json +1 -1
- package/lib/avif.js +0 -47
- package/lib/common.js +0 -64
- package/lib/heic.js +0 -43
- package/lib/index.js +0 -19
- package/lib/jpeg.js +0 -53
- package/lib/jxl.js +0 -69
- package/lib/png.js +0 -45
- package/lib/qoi.js +0 -19
- package/lib/webp.js +0 -62
- package/lib/wp2.js +0 -46
package/dist/avif-dec.wasm
CHANGED
|
Binary file
|
package/dist/avif-enc.wasm
CHANGED
|
Binary file
|
package/dist/heic-enc.wasm
CHANGED
|
Binary file
|
package/dist/jxl-dec.wasm
CHANGED
|
Binary file
|
package/dist/jxl-enc.wasm
CHANGED
|
Binary file
|
package/dist/mozjpeg.wasm
CHANGED
|
Binary file
|
package/dist/pngquant.js
CHANGED
|
@@ -173,6 +173,22 @@ function passArray8ToWasm0(arg, malloc) {
|
|
|
173
173
|
WASM_VECTOR_LEN = arg.length;
|
|
174
174
|
return ptr;
|
|
175
175
|
}
|
|
176
|
+
/**
|
|
177
|
+
* @param {Uint8Array} data
|
|
178
|
+
* @param {number} width
|
|
179
|
+
* @param {number} height
|
|
180
|
+
* @param {any} options
|
|
181
|
+
* @returns {Uint8Array}
|
|
182
|
+
*/
|
|
183
|
+
export function optimize(data, width, height, options) {
|
|
184
|
+
const ptr0 = passArray8ToWasm0(data, wasm.__wbindgen_malloc);
|
|
185
|
+
const len0 = WASM_VECTOR_LEN;
|
|
186
|
+
const ret = wasm.optimize(ptr0, len0, width, height, options);
|
|
187
|
+
var v2 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
|
|
188
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
|
|
189
|
+
return v2;
|
|
190
|
+
}
|
|
191
|
+
|
|
176
192
|
/**
|
|
177
193
|
* @param {Uint8Array} data
|
|
178
194
|
* @param {number} width
|
|
@@ -202,22 +218,6 @@ export function png_to_rgba(data) {
|
|
|
202
218
|
return ret;
|
|
203
219
|
}
|
|
204
220
|
|
|
205
|
-
/**
|
|
206
|
-
* @param {Uint8Array} data
|
|
207
|
-
* @param {number} width
|
|
208
|
-
* @param {number} height
|
|
209
|
-
* @param {any} options
|
|
210
|
-
* @returns {Uint8Array}
|
|
211
|
-
*/
|
|
212
|
-
export function optimize(data, width, height, options) {
|
|
213
|
-
const ptr0 = passArray8ToWasm0(data, wasm.__wbindgen_malloc);
|
|
214
|
-
const len0 = WASM_VECTOR_LEN;
|
|
215
|
-
const ret = wasm.optimize(ptr0, len0, width, height, options);
|
|
216
|
-
var v2 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
|
|
217
|
-
wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
|
|
218
|
-
return v2;
|
|
219
|
-
}
|
|
220
|
-
|
|
221
221
|
const EXPECTED_RESPONSE_TYPES = new Set(['basic', 'cors', 'default']);
|
|
222
222
|
|
|
223
223
|
async function __wbg_load(module, imports) {
|
package/dist/pngquant_bg.wasm
CHANGED
|
Binary file
|
package/dist/webp-enc.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
async function Module(moduleArg={}){var moduleRtn;var Module=moduleArg;var ENVIRONMENT_IS_WEB=!!globalThis.window;var ENVIRONMENT_IS_WORKER=!!globalThis.WorkerGlobalScope;var ENVIRONMENT_IS_NODE=globalThis.process?.versions?.node&&globalThis.process?.type!="renderer";if(ENVIRONMENT_IS_NODE){const{createRequire}=await import("node:module");var require=createRequire(import.meta.url)}var arguments_=[];var thisProgram="./this.program";var quit_=(status,toThrow)=>{throw toThrow};var _scriptName=import.meta.url;var scriptDirectory="";function locateFile(path){if(Module["locateFile"]){return Module["locateFile"](path,scriptDirectory)}return scriptDirectory+path}var readAsync,readBinary;if(ENVIRONMENT_IS_NODE){var fs=require("node:fs");if(_scriptName.startsWith("file:")){scriptDirectory=require("node:path").dirname(require("node:url").fileURLToPath(_scriptName))+"/"}readBinary=filename=>{filename=isFileURI(filename)?new URL(filename):filename;var ret=fs.readFileSync(filename);return ret};readAsync=async(filename,binary=true)=>{filename=isFileURI(filename)?new URL(filename):filename;var ret=fs.readFileSync(filename,binary?undefined:"utf8");return ret};if(process.argv.length>1){thisProgram=process.argv[1].replace(/\\/g,"/")}arguments_=process.argv.slice(2);quit_=(status,toThrow)=>{process.exitCode=status;throw toThrow}}else if(ENVIRONMENT_IS_WEB||ENVIRONMENT_IS_WORKER){try{scriptDirectory=new URL(".",_scriptName).href}catch{}{if(ENVIRONMENT_IS_WORKER){readBinary=url=>{var xhr=new XMLHttpRequest;xhr.open("GET",url,false);xhr.responseType="arraybuffer";xhr.send(null);return new Uint8Array(xhr.response)}}readAsync=async url=>{var response=await fetch(url,{credentials:"same-origin"});if(response.ok){return response.arrayBuffer()}throw new Error(response.status+" : "+response.url)}}}else{}var out=console.log.bind(console);var err=console.error.bind(console);var wasmBinary;var ABORT=false;var EXITSTATUS;var isFileURI=filename=>filename.startsWith("file://");var readyPromiseResolve,readyPromiseReject;var HEAP8,HEAPU8,HEAP16,HEAPU16,HEAP32,HEAPU32,HEAPF32,HEAPF64;var HEAP64,HEAPU64;var runtimeInitialized=false;function updateMemoryViews(){var b=wasmMemory.buffer;HEAP8=new Int8Array(b);HEAP16=new Int16Array(b);HEAPU8=new Uint8Array(b);HEAPU16=new Uint16Array(b);HEAP32=new Int32Array(b);HEAPU32=new Uint32Array(b);HEAPF32=new Float32Array(b);HEAPF64=new Float64Array(b);HEAP64=new BigInt64Array(b);HEAPU64=new BigUint64Array(b)}function preRun(){if(Module["preRun"]){if(typeof Module["preRun"]=="function")Module["preRun"]=[Module["preRun"]];while(Module["preRun"].length){addOnPreRun(Module["preRun"].shift())}}callRuntimeCallbacks(onPreRuns)}function initRuntime(){runtimeInitialized=true;wasmExports["E"]()}function postRun(){if(Module["postRun"]){if(typeof Module["postRun"]=="function")Module["postRun"]=[Module["postRun"]];while(Module["postRun"].length){addOnPostRun(Module["postRun"].shift())}}callRuntimeCallbacks(onPostRuns)}function abort(what){Module["onAbort"]?.(what);what="Aborted("+what+")";err(what);ABORT=true;what+=". Build with -sASSERTIONS for more info.";var e=new WebAssembly.RuntimeError(what);readyPromiseReject?.(e);throw e}var wasmBinaryFile;function findWasmBinary(){if(Module["locateFile"]){return locateFile("webp-enc.wasm")}return new URL("webp-enc.wasm",import.meta.url).href}function getBinarySync(file){if(file==wasmBinaryFile&&wasmBinary){return new Uint8Array(wasmBinary)}if(readBinary){return readBinary(file)}throw"both async and sync fetching of the wasm failed"}async function getWasmBinary(binaryFile){if(!wasmBinary){try{var response=await readAsync(binaryFile);return new Uint8Array(response)}catch{}}return getBinarySync(binaryFile)}async function instantiateArrayBuffer(binaryFile,imports){try{var binary=await getWasmBinary(binaryFile);var instance=await WebAssembly.instantiate(binary,imports);return instance}catch(reason){err(`failed to asynchronously prepare wasm: ${reason}`);abort(reason)}}async function instantiateAsync(binary,binaryFile,imports){if(!binary&&!ENVIRONMENT_IS_NODE){try{var response=fetch(binaryFile,{credentials:"same-origin"});var instantiationResult=await WebAssembly.instantiateStreaming(response,imports);return instantiationResult}catch(reason){err(`wasm streaming compile failed: ${reason}`);err("falling back to ArrayBuffer instantiation")}}return instantiateArrayBuffer(binaryFile,imports)}function getWasmImports(){var imports={a:wasmImports};return imports}async function createWasm(){function receiveInstance(instance,module){wasmExports=instance.exports;wasmExports=applySignatureConversions(wasmExports);assignWasmExports(wasmExports);updateMemoryViews();return wasmExports}function receiveInstantiationResult(result){return receiveInstance(result["instance"])}var info=getWasmImports();if(Module["instantiateWasm"]){return new Promise((resolve,reject)=>{Module["instantiateWasm"](info,(inst,mod)=>{resolve(receiveInstance(inst,mod))})})}wasmBinaryFile??=findWasmBinary();var result=await instantiateAsync(wasmBinary,wasmBinaryFile,info);var exports=receiveInstantiationResult(result);return exports}class ExitStatus{name="ExitStatus";constructor(status){this.message=`Program terminated with exit(${status})`;this.status=status}}var callRuntimeCallbacks=callbacks=>{while(callbacks.length>0){callbacks.shift()(Module)}};var onPostRuns=[];var addOnPostRun=cb=>onPostRuns.push(cb);var onPreRuns=[];var addOnPreRun=cb=>onPreRuns.push(cb);var noExitRuntime=true;var __abort_js=()=>abort("");var structRegistrations={};var runDestructors=destructors=>{while(destructors.length){var ptr=destructors.pop();var del=destructors.pop();del(ptr)}};function readPointer(pointer){return this.fromWireType(Number(HEAPU64[pointer/8]))}var awaitingDependencies={};var registeredTypes={};var typeDependencies={};var InternalError=class InternalError extends Error{constructor(message){super(message);this.name="InternalError"}};var throwInternalError=message=>{throw new InternalError(message)};var whenDependentTypesAreResolved=(myTypes,dependentTypes,getTypeConverters)=>{myTypes.forEach(type=>typeDependencies[type]=dependentTypes);function onComplete(typeConverters){var myTypeConverters=getTypeConverters(typeConverters);if(myTypeConverters.length!==myTypes.length){throwInternalError("Mismatched type converter count")}for(var i=0;i<myTypes.length;++i){registerType(myTypes[i],myTypeConverters[i])}}var typeConverters=new Array(dependentTypes.length);var unregisteredTypes=[];var registered=0;for(let[i,dt]of dependentTypes.entries()){if(registeredTypes.hasOwnProperty(dt)){typeConverters[i]=registeredTypes[dt]}else{unregisteredTypes.push(dt);if(!awaitingDependencies.hasOwnProperty(dt)){awaitingDependencies[dt]=[]}awaitingDependencies[dt].push(()=>{typeConverters[i]=registeredTypes[dt];++registered;if(registered===unregisteredTypes.length){onComplete(typeConverters)}})}}if(0===unregisteredTypes.length){onComplete(typeConverters)}};var INT53_MAX=9007199254740992;var INT53_MIN=-9007199254740992;var bigintToI53Checked=num=>num<INT53_MIN||num>INT53_MAX?NaN:Number(num);var __embind_finalize_value_object=function(structType){structType=bigintToI53Checked(structType);var reg=structRegistrations[structType];delete structRegistrations[structType];var rawConstructor=reg.rawConstructor;var rawDestructor=reg.rawDestructor;var fieldRecords=reg.fields;var fieldTypes=fieldRecords.map(field=>field.getterReturnType).concat(fieldRecords.map(field=>field.setterArgumentType));whenDependentTypesAreResolved([structType],fieldTypes,fieldTypes=>{var fields={};for(var[i,field]of fieldRecords.entries()){const getterReturnType=fieldTypes[i];const getter=field.getter;const getterContext=field.getterContext;const setterArgumentType=fieldTypes[i+fieldRecords.length];const setter=field.setter;const setterContext=field.setterContext;fields[field.fieldName]={read:ptr=>getterReturnType.fromWireType(getter(getterContext,ptr)),write:(ptr,o)=>{var destructors=[];setter(setterContext,ptr,setterArgumentType.toWireType(destructors,o));runDestructors(destructors)},optional:getterReturnType.optional}}return[{name:reg.name,fromWireType:ptr=>{var rv={};for(var i in fields){rv[i]=fields[i].read(ptr)}rawDestructor(ptr);return rv},toWireType:(destructors,o)=>{for(var fieldName in fields){if(!(fieldName in o)&&!fields[fieldName].optional){throw new TypeError(`Missing field: "${fieldName}"`)}}var ptr=rawConstructor();for(fieldName in fields){fields[fieldName].write(ptr,o[fieldName])}if(destructors!==null){destructors.push(rawDestructor,ptr)}return ptr},readValueFromPointer:readPointer,destructorFunction:rawDestructor}]})};var AsciiToString=ptr=>{var str="";while(1){var ch=HEAPU8[ptr++];if(!ch)return str;str+=String.fromCharCode(ch)}};var BindingError=class BindingError extends Error{constructor(message){super(message);this.name="BindingError"}};var throwBindingError=message=>{throw new BindingError(message)};function sharedRegisterType(rawType,registeredInstance,options={}){var name=registeredInstance.name;if(!rawType){throwBindingError(`type "${name}" must have a positive integer typeid pointer`)}if(registeredTypes.hasOwnProperty(rawType)){if(options.ignoreDuplicateRegistrations){return}else{throwBindingError(`Cannot register type '${name}' twice`)}}registeredTypes[rawType]=registeredInstance;delete typeDependencies[rawType];if(awaitingDependencies.hasOwnProperty(rawType)){var callbacks=awaitingDependencies[rawType];delete awaitingDependencies[rawType];callbacks.forEach(cb=>cb())}}function registerType(rawType,registeredInstance,options={}){return sharedRegisterType(rawType,registeredInstance,options)}var integerReadValueFromPointer=(name,width,signed)=>{switch(width){case 1:return signed?pointer=>HEAP8[pointer]:pointer=>HEAPU8[pointer];case 2:return signed?pointer=>HEAP16[pointer/2]:pointer=>HEAPU16[pointer/2];case 4:return signed?pointer=>HEAP32[pointer/4]:pointer=>HEAPU32[pointer/4];case 8:return signed?pointer=>HEAP64[pointer/8]:pointer=>HEAPU64[pointer/8];default:throw new TypeError(`invalid integer width (${width}): ${name}`)}};var __embind_register_bigint=function(primitiveType,name,size,minRange,maxRange){primitiveType=bigintToI53Checked(primitiveType);name=bigintToI53Checked(name);size=bigintToI53Checked(size);name=AsciiToString(name);const isUnsignedType=minRange===0n;let fromWireType=value=>value;if(isUnsignedType){const bitSize=size*8;fromWireType=value=>{if(typeof value=="number"){return value>>>0}return BigInt.asUintN(bitSize,value)};maxRange=fromWireType(maxRange)}registerType(primitiveType,{name,fromWireType,toWireType:(destructors,value)=>{if(typeof value=="number"){value=BigInt(value)}return value},readValueFromPointer:integerReadValueFromPointer(name,size,!isUnsignedType),destructorFunction:null})};function __embind_register_bool(rawType,name,trueValue,falseValue){rawType=bigintToI53Checked(rawType);name=bigintToI53Checked(name);name=AsciiToString(name);registerType(rawType,{name,fromWireType:function(wt){return!!wt},toWireType:function(destructors,o){return o?trueValue:falseValue},readValueFromPointer:function(pointer){return this.fromWireType(HEAPU8[pointer])},destructorFunction:null})}var emval_freelist=[];var emval_handles=[0,1,,1,null,1,true,1,false,1];function __emval_decref(handle){handle=bigintToI53Checked(handle);if(handle>9&&0===--emval_handles[handle+1]){emval_handles[handle]=undefined;emval_freelist.push(handle)}}var Emval={toValue:handle=>{if(!handle){throwBindingError(`Cannot use deleted val. handle = ${handle}`)}return emval_handles[handle]},toHandle:value=>{switch(value){case undefined:return 2;case null:return 4;case true:return 6;case false:return 8;default:{const handle=emval_freelist.pop()||emval_handles.length;emval_handles[handle]=value;emval_handles[handle+1]=1;return handle}}}};var EmValType={name:"emscripten::val",fromWireType:handle=>{var rv=Emval.toValue(handle);__emval_decref(handle);return rv},toWireType:(destructors,value)=>Emval.toHandle(value),readValueFromPointer:readPointer,destructorFunction:null};function __embind_register_emval(rawType){rawType=bigintToI53Checked(rawType);return registerType(rawType,EmValType)}var ensureOverloadTable=(proto,methodName,humanName)=>{if(undefined===proto[methodName].overloadTable){var prevFunc=proto[methodName];proto[methodName]=function(...args){if(!proto[methodName].overloadTable.hasOwnProperty(args.length)){throwBindingError(`Function '${humanName}' called with an invalid number of arguments (${args.length}) - expects one of (${proto[methodName].overloadTable})!`)}return proto[methodName].overloadTable[args.length].apply(this,args)};proto[methodName].overloadTable=[];proto[methodName].overloadTable[prevFunc.argCount]=prevFunc}};var exposePublicSymbol=(name,value,numArguments)=>{if(Module.hasOwnProperty(name)){if(undefined===numArguments||undefined!==Module[name].overloadTable&&undefined!==Module[name].overloadTable[numArguments]){throwBindingError(`Cannot register public name '${name}' twice`)}ensureOverloadTable(Module,name,name);if(Module[name].overloadTable.hasOwnProperty(numArguments)){throwBindingError(`Cannot register multiple overloads of a function with the same number of arguments (${numArguments})!`)}Module[name].overloadTable[numArguments]=value}else{Module[name]=value;Module[name].argCount=numArguments}};var enumReadValueFromPointer=(name,width,signed)=>{switch(width){case 1:return signed?function(pointer){return this.fromWireType(HEAP8[pointer])}:function(pointer){return this.fromWireType(HEAPU8[pointer])};case 2:return signed?function(pointer){return this.fromWireType(HEAP16[pointer/2])}:function(pointer){return this.fromWireType(HEAPU16[pointer/2])};case 4:return signed?function(pointer){return this.fromWireType(HEAP32[pointer/4])}:function(pointer){return this.fromWireType(HEAPU32[pointer/4])};default:throw new TypeError(`invalid integer width (${width}): ${name}`)}};function getEnumValueType(rawValueType){return rawValueType===0?"object":rawValueType===1?"number":"string"}function __embind_register_enum(rawType,name,size,isSigned,rawValueType){rawType=bigintToI53Checked(rawType);name=bigintToI53Checked(name);size=bigintToI53Checked(size);name=AsciiToString(name);const valueType=getEnumValueType(rawValueType);switch(valueType){case"object":{function ctor(){}ctor.values={};registerType(rawType,{name,constructor:ctor,valueType,fromWireType:function(c){return this.constructor.values[c]},toWireType:(destructors,c)=>c.value,readValueFromPointer:enumReadValueFromPointer(name,size,isSigned),destructorFunction:null});exposePublicSymbol(name,ctor);break}case"number":{var keysMap={};registerType(rawType,{name,keysMap,valueType,fromWireType:c=>c,toWireType:(destructors,c)=>c,readValueFromPointer:enumReadValueFromPointer(name,size,isSigned),destructorFunction:null});exposePublicSymbol(name,keysMap);delete Module[name].argCount;break}case"string":{var valuesMap={};var reverseMap={};var keysMap={};registerType(rawType,{name,valuesMap,reverseMap,keysMap,valueType,fromWireType:function(c){return this.reverseMap[c]},toWireType:function(destructors,c){return this.valuesMap[c]},readValueFromPointer:enumReadValueFromPointer(name,size,isSigned),destructorFunction:null});exposePublicSymbol(name,keysMap);delete Module[name].argCount;break}}}var createNamedFunction=(name,func)=>Object.defineProperty(func,"name",{value:name});var getTypeName=type=>{var ptr=___getTypeName(type);var rv=AsciiToString(ptr);_free(ptr);return rv};var requireRegisteredType=(rawType,humanName)=>{var impl=registeredTypes[rawType];if(undefined===impl){throwBindingError(`${humanName} has unknown type ${getTypeName(rawType)}`)}return impl};function __embind_register_enum_value(rawEnumType,name,enumValue){rawEnumType=bigintToI53Checked(rawEnumType);name=bigintToI53Checked(name);var enumType=requireRegisteredType(rawEnumType,"enum");name=AsciiToString(name);switch(enumType.valueType){case"object":{var Enum=enumType.constructor;var Value=Object.create(enumType.constructor.prototype,{value:{value:enumValue},constructor:{value:createNamedFunction(`${enumType.name}_${name}`,function(){})}});Enum.values[enumValue]=Value;Enum[name]=Value;break}case"number":{enumType.keysMap[name]=enumValue;break}case"string":{enumType.valuesMap[name]=enumValue;enumType.reverseMap[enumValue]=name;enumType.keysMap[name]=name;break}}}var floatReadValueFromPointer=(name,width)=>{switch(width){case 4:return function(pointer){return this.fromWireType(HEAPF32[pointer/4])};case 8:return function(pointer){return this.fromWireType(HEAPF64[pointer/8])};default:throw new TypeError(`invalid float width (${width}): ${name}`)}};var __embind_register_float=function(rawType,name,size){rawType=bigintToI53Checked(rawType);name=bigintToI53Checked(name);size=bigintToI53Checked(size);name=AsciiToString(name);registerType(rawType,{name,fromWireType:value=>value,toWireType:(destructors,value)=>value,readValueFromPointer:floatReadValueFromPointer(name,size),destructorFunction:null})};function usesDestructorStack(argTypes){for(var i=1;i<argTypes.length;++i){if(argTypes[i]!==null&&argTypes[i].destructorFunction===undefined){return true}}return false}function createJsInvoker(argTypes,isClassMethodFunc,returns,isAsync){var needsDestructorStack=usesDestructorStack(argTypes);var argCount=argTypes.length-2;var argsList=[];var argsListWired=["fn"];if(isClassMethodFunc){argsListWired.push("thisWired")}for(var i=0;i<argCount;++i){argsList.push(`arg${i}`);argsListWired.push(`arg${i}Wired`)}argsList=argsList.join(",");argsListWired=argsListWired.join(",");var invokerFnBody=`return function (${argsList}) {\n`;if(needsDestructorStack){invokerFnBody+="var destructors = [];\n"}var dtorStack=needsDestructorStack?"destructors":"null";var args1=["humanName","throwBindingError","invoker","fn","runDestructors","fromRetWire","toClassParamWire"];if(isClassMethodFunc){invokerFnBody+=`var thisWired = toClassParamWire(${dtorStack}, this);\n`}for(var i=0;i<argCount;++i){var argName=`toArg${i}Wire`;invokerFnBody+=`var arg${i}Wired = ${argName}(${dtorStack}, arg${i});\n`;args1.push(argName)}invokerFnBody+=(returns||isAsync?"var rv = ":"")+`invoker(${argsListWired});\n`;if(needsDestructorStack){invokerFnBody+="runDestructors(destructors);\n"}else{for(var i=isClassMethodFunc?1:2;i<argTypes.length;++i){var paramName=i===1?"thisWired":"arg"+(i-2)+"Wired";if(argTypes[i].destructorFunction!==null){invokerFnBody+=`${paramName}_dtor(${paramName});\n`;args1.push(`${paramName}_dtor`)}}}if(returns){invokerFnBody+="var ret = fromRetWire(rv);\n"+"return ret;\n"}else{}invokerFnBody+="}\n";return new Function(args1,invokerFnBody)}function craftInvokerFunction(humanName,argTypes,classType,cppInvokerFunc,cppTargetFunc,isAsync){var argCount=argTypes.length;if(argCount<2){throwBindingError("argTypes array size mismatch! Must at least get return value and 'this' types!")}var isClassMethodFunc=argTypes[1]!==null&&classType!==null;var needsDestructorStack=usesDestructorStack(argTypes);var returns=!argTypes[0].isVoid;var retType=argTypes[0];var instType=argTypes[1];var closureArgs=[humanName,throwBindingError,cppInvokerFunc,cppTargetFunc,runDestructors,retType.fromWireType.bind(retType),instType?.toWireType.bind(instType)];for(var i=2;i<argCount;++i){var argType=argTypes[i];closureArgs.push(argType.toWireType.bind(argType))}if(!needsDestructorStack){for(var i=isClassMethodFunc?1:2;i<argTypes.length;++i){if(argTypes[i].destructorFunction!==null){closureArgs.push(argTypes[i].destructorFunction)}}}let invokerFactory=createJsInvoker(argTypes,isClassMethodFunc,returns,isAsync);var invokerFn=invokerFactory(...closureArgs);return createNamedFunction(humanName,invokerFn)}var heap32VectorToArray=(count,firstElement)=>{var array=[];for(var i=0;i<count;i++){array.push(Number(HEAPU64[(firstElement+i*8)/8]))}return array};var replacePublicSymbol=(name,value,numArguments)=>{if(!Module.hasOwnProperty(name)){throwInternalError("Replacing nonexistent public symbol")}if(undefined!==Module[name].overloadTable&&undefined!==numArguments){Module[name].overloadTable[numArguments]=value}else{Module[name]=value;Module[name].argCount=numArguments}};var wasmTableMirror=[];var getWasmTableEntry=funcPtr=>{funcPtr=Number(funcPtr);var func=wasmTableMirror[funcPtr];if(!func){wasmTableMirror[funcPtr]=func=wasmTable.get(BigInt(funcPtr))}return func};var dynCall=(sig,ptr,args=[],promising=false)=>{for(var i=1;i<sig.length;++i){if(sig[i]=="p")args[i-1]=BigInt(args[i-1])}var func=getWasmTableEntry(ptr);var rtn=func(...args);function convert(rtn){return sig[0]=="p"?Number(rtn):rtn}return convert(rtn)};var getDynCaller=(sig,ptr,promising=false)=>(...args)=>dynCall(sig,ptr,args,promising);var embind__requireFunction=(signature,rawFunction,isAsync=false)=>{signature=AsciiToString(signature);function makeDynCaller(){if(signature.includes("p")){return getDynCaller(signature,rawFunction,isAsync)}var rtn=getWasmTableEntry(rawFunction);return rtn}var fp=makeDynCaller();if(typeof fp!="function"){throwBindingError(`unknown function pointer with signature ${signature}: ${rawFunction}`)}return fp};class UnboundTypeError extends Error{}var throwUnboundTypeError=(message,types)=>{var unboundTypes=[];var seen={};function visit(type){if(seen[type]){return}if(registeredTypes[type]){return}if(typeDependencies[type]){typeDependencies[type].forEach(visit);return}unboundTypes.push(type);seen[type]=true}types.forEach(visit);throw new UnboundTypeError(`${message}: `+unboundTypes.map(getTypeName).join([", "]))};var getFunctionName=signature=>{signature=signature.trim();const argsIndex=signature.indexOf("(");if(argsIndex===-1)return signature;return signature.slice(0,argsIndex)};function __embind_register_function(name,argCount,rawArgTypesAddr,signature,rawInvoker,fn,isAsync,isNonnullReturn){name=bigintToI53Checked(name);rawArgTypesAddr=bigintToI53Checked(rawArgTypesAddr);signature=bigintToI53Checked(signature);rawInvoker=bigintToI53Checked(rawInvoker);fn=bigintToI53Checked(fn);var argTypes=heap32VectorToArray(argCount,rawArgTypesAddr);name=AsciiToString(name);name=getFunctionName(name);rawInvoker=embind__requireFunction(signature,rawInvoker,isAsync);exposePublicSymbol(name,function(){throwUnboundTypeError(`Cannot call ${name} due to unbound types`,argTypes)},argCount-1);whenDependentTypesAreResolved([],argTypes,argTypes=>{var invokerArgsArray=[argTypes[0],null].concat(argTypes.slice(1));replacePublicSymbol(name,craftInvokerFunction(name,invokerArgsArray,null,rawInvoker,fn,isAsync),argCount-1);return[]})}var __embind_register_integer=function(primitiveType,name,size,minRange,maxRange){primitiveType=bigintToI53Checked(primitiveType);name=bigintToI53Checked(name);size=bigintToI53Checked(size);name=AsciiToString(name);const isUnsignedType=minRange===0;let fromWireType=value=>value;if(isUnsignedType){var bitshift=32-8*size;fromWireType=value=>value<<bitshift>>>bitshift;maxRange=fromWireType(maxRange)}registerType(primitiveType,{name,fromWireType,toWireType:(destructors,value)=>value,readValueFromPointer:integerReadValueFromPointer(name,size,minRange!==0),destructorFunction:null})};function __embind_register_memory_view(rawType,dataTypeIndex,name){rawType=bigintToI53Checked(rawType);name=bigintToI53Checked(name);var typeMapping=[Int8Array,Uint8Array,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array,BigInt64Array,BigUint64Array];var TA=typeMapping[dataTypeIndex];function decodeMemoryView(handle){var size=Number(HEAPU64[handle/8]);var data=Number(HEAPU64[(handle+8)/8]);return new TA(HEAP8.buffer,data,size)}name=AsciiToString(name);registerType(rawType,{name,fromWireType:decodeMemoryView,readValueFromPointer:decodeMemoryView},{ignoreDuplicateRegistrations:true})}var stringToUTF8Array=(str,heap,outIdx,maxBytesToWrite)=>{if(!(maxBytesToWrite>0))return 0;var startIdx=outIdx;var endIdx=outIdx+maxBytesToWrite-1;for(var i=0;i<str.length;++i){var u=str.codePointAt(i);if(u<=127){if(outIdx>=endIdx)break;heap[outIdx++]=u}else if(u<=2047){if(outIdx+1>=endIdx)break;heap[outIdx++]=192|u>>6;heap[outIdx++]=128|u&63}else if(u<=65535){if(outIdx+2>=endIdx)break;heap[outIdx++]=224|u>>12;heap[outIdx++]=128|u>>6&63;heap[outIdx++]=128|u&63}else{if(outIdx+3>=endIdx)break;heap[outIdx++]=240|u>>18;heap[outIdx++]=128|u>>12&63;heap[outIdx++]=128|u>>6&63;heap[outIdx++]=128|u&63;i++}}heap[outIdx]=0;return outIdx-startIdx};var stringToUTF8=(str,outPtr,maxBytesToWrite)=>stringToUTF8Array(str,HEAPU8,outPtr,maxBytesToWrite);var lengthBytesUTF8=str=>{var len=0;for(var i=0;i<str.length;++i){var c=str.charCodeAt(i);if(c<=127){len++}else if(c<=2047){len+=2}else if(c>=55296&&c<=57343){len+=4;++i}else{len+=3}}return len};var UTF8Decoder=new TextDecoder;var findStringEnd=(heapOrArray,idx,maxBytesToRead,ignoreNul)=>{var maxIdx=idx+maxBytesToRead;if(ignoreNul)return maxIdx;while(heapOrArray[idx]&&!(idx>=maxIdx))++idx;return idx};var UTF8ToString=(ptr,maxBytesToRead,ignoreNul)=>{if(!ptr)return"";var end=findStringEnd(HEAPU8,ptr,maxBytesToRead,ignoreNul);return UTF8Decoder.decode(HEAPU8.subarray(ptr,end))};function __embind_register_std_string(rawType,name){rawType=bigintToI53Checked(rawType);name=bigintToI53Checked(name);name=AsciiToString(name);var stdStringIsUTF8=true;registerType(rawType,{name,fromWireType(value){var length=Number(HEAPU64[value/8]);var payload=value+8;var str;if(stdStringIsUTF8){str=UTF8ToString(payload,length,true)}else{str="";for(var i=0;i<length;++i){str+=String.fromCharCode(HEAPU8[payload+i])}}_free(value);return str},toWireType(destructors,value){if(value instanceof ArrayBuffer){value=new Uint8Array(value)}var length;var valueIsOfTypeString=typeof value=="string";if(!(valueIsOfTypeString||ArrayBuffer.isView(value)&&value.BYTES_PER_ELEMENT==1)){throwBindingError("Cannot pass non-string to std::string")}if(stdStringIsUTF8&&valueIsOfTypeString){length=lengthBytesUTF8(value)}else{length=value.length}var base=_malloc(8+length+1);var ptr=base+8;HEAPU64[base/8]=BigInt(length);if(valueIsOfTypeString){if(stdStringIsUTF8){stringToUTF8(value,ptr,length+1)}else{for(var i=0;i<length;++i){var charCode=value.charCodeAt(i);if(charCode>255){_free(base);throwBindingError("String has UTF-16 code units that do not fit in 8 bits")}HEAPU8[ptr+i]=charCode}}}else{HEAPU8.set(value,ptr)}if(destructors!==null){destructors.push(_free,base)}return base},readValueFromPointer:readPointer,destructorFunction(ptr){_free(ptr)}})}var UTF16Decoder=new TextDecoder("utf-16le");var UTF16ToString=(ptr,maxBytesToRead,ignoreNul)=>{var idx=ptr/2;var endIdx=findStringEnd(HEAPU16,idx,maxBytesToRead/2,ignoreNul);return UTF16Decoder.decode(HEAPU16.subarray(idx,endIdx))};var stringToUTF16=(str,outPtr,maxBytesToWrite)=>{maxBytesToWrite??=2147483647;if(maxBytesToWrite<2)return 0;maxBytesToWrite-=2;var startPtr=outPtr;var numCharsToWrite=maxBytesToWrite<str.length*2?maxBytesToWrite/2:str.length;for(var i=0;i<numCharsToWrite;++i){var codeUnit=str.charCodeAt(i);HEAP16[outPtr/2]=codeUnit;outPtr+=2}HEAP16[outPtr/2]=0;return outPtr-startPtr};var lengthBytesUTF16=str=>str.length*2;var UTF32ToString=(ptr,maxBytesToRead,ignoreNul)=>{var str="";var startIdx=ptr/4;for(var i=0;!(i>=maxBytesToRead/4);i++){var utf32=HEAPU32[startIdx+i];if(!utf32&&!ignoreNul)break;str+=String.fromCodePoint(utf32)}return str};var stringToUTF32=(str,outPtr,maxBytesToWrite)=>{maxBytesToWrite??=2147483647;if(maxBytesToWrite<4)return 0;var startPtr=outPtr;var endPtr=startPtr+maxBytesToWrite-4;for(var i=0;i<str.length;++i){var codePoint=str.codePointAt(i);if(codePoint>65535){i++}HEAP32[outPtr/4]=codePoint;outPtr+=4;if(outPtr+4>endPtr)break}HEAP32[outPtr/4]=0;return outPtr-startPtr};var lengthBytesUTF32=str=>{var len=0;for(var i=0;i<str.length;++i){var codePoint=str.codePointAt(i);if(codePoint>65535){i++}len+=4}return len};function __embind_register_std_wstring(rawType,charSize,name){rawType=bigintToI53Checked(rawType);charSize=bigintToI53Checked(charSize);name=bigintToI53Checked(name);name=AsciiToString(name);var decodeString,encodeString,lengthBytesUTF;if(charSize===2){decodeString=UTF16ToString;encodeString=stringToUTF16;lengthBytesUTF=lengthBytesUTF16}else{decodeString=UTF32ToString;encodeString=stringToUTF32;lengthBytesUTF=lengthBytesUTF32}registerType(rawType,{name,fromWireType:value=>{var length=Number(HEAPU64[value/8]);var str=decodeString(value+8,length*charSize,true);_free(value);return str},toWireType:(destructors,value)=>{if(!(typeof value=="string")){throwBindingError(`Cannot pass non-string to C++ string type ${name}`)}var length=lengthBytesUTF(value);var ptr=_malloc(8+length+charSize);HEAPU64[ptr/8]=BigInt(length/charSize);encodeString(value,ptr+8,length+charSize);if(destructors!==null){destructors.push(_free,ptr)}return ptr},readValueFromPointer:readPointer,destructorFunction(ptr){_free(ptr)}})}function __embind_register_value_object(rawType,name,constructorSignature,rawConstructor,destructorSignature,rawDestructor){rawType=bigintToI53Checked(rawType);name=bigintToI53Checked(name);constructorSignature=bigintToI53Checked(constructorSignature);rawConstructor=bigintToI53Checked(rawConstructor);destructorSignature=bigintToI53Checked(destructorSignature);rawDestructor=bigintToI53Checked(rawDestructor);structRegistrations[rawType]={name:AsciiToString(name),rawConstructor:embind__requireFunction(constructorSignature,rawConstructor),rawDestructor:embind__requireFunction(destructorSignature,rawDestructor),fields:[]}}function __embind_register_value_object_field(structType,fieldName,getterReturnType,getterSignature,getter,getterContext,setterArgumentType,setterSignature,setter,setterContext){structType=bigintToI53Checked(structType);fieldName=bigintToI53Checked(fieldName);getterReturnType=bigintToI53Checked(getterReturnType);getterSignature=bigintToI53Checked(getterSignature);getter=bigintToI53Checked(getter);getterContext=bigintToI53Checked(getterContext);setterArgumentType=bigintToI53Checked(setterArgumentType);setterSignature=bigintToI53Checked(setterSignature);setter=bigintToI53Checked(setter);setterContext=bigintToI53Checked(setterContext);structRegistrations[structType].fields.push({fieldName:AsciiToString(fieldName),getterReturnType,getter:embind__requireFunction(getterSignature,getter),getterContext,setterArgumentType,setter:embind__requireFunction(setterSignature,setter),setterContext})}var __embind_register_void=function(rawType,name){rawType=bigintToI53Checked(rawType);name=bigintToI53Checked(name);name=AsciiToString(name);registerType(rawType,{isVoid:true,name,fromWireType:()=>undefined,toWireType:(destructors,o)=>undefined})};var runtimeKeepaliveCounter=0;var __emscripten_runtime_keepalive_clear=()=>{noExitRuntime=false;runtimeKeepaliveCounter=0};var emval_methodCallers=[];var emval_addMethodCaller=caller=>{var id=emval_methodCallers.length;emval_methodCallers.push(caller);return id};var emval_lookupTypes=(argCount,argTypes)=>{var a=new Array(argCount);for(var i=0;i<argCount;++i){a[i]=requireRegisteredType(Number(HEAPU64[(argTypes+i*8)/8]),`parameter ${i}`)}return a};var emval_returnValue=(toReturnWire,destructorsRef,handle)=>{var destructors=[];var result=toReturnWire(destructors,handle);if(destructors.length){HEAPU64[destructorsRef/8]=BigInt(Emval.toHandle(destructors))}return result};var emval_symbols={};var getStringOrSymbol=address=>{var symbol=emval_symbols[address];if(symbol===undefined){return AsciiToString(address)}return symbol};var __emval_create_invoker=function(argCount,argTypesPtr,kind){argTypesPtr=bigintToI53Checked(argTypesPtr);var ret=(()=>{var GenericWireTypeSize=16;var[retType,...argTypes]=emval_lookupTypes(argCount,argTypesPtr);var toReturnWire=retType.toWireType.bind(retType);var argFromPtr=argTypes.map(type=>type.readValueFromPointer.bind(type));argCount--;var captures={toValue:Emval.toValue};var args=argFromPtr.map((argFromPtr,i)=>{var captureName=`argFromPtr${i}`;captures[captureName]=argFromPtr;return`${captureName}(args${i?"+"+i*GenericWireTypeSize:""})`});var functionBody;switch(kind){case 0:functionBody="toValue(handle)";break;case 2:functionBody="new (toValue(handle))";break;case 3:functionBody="";break;case 1:captures["getStringOrSymbol"]=getStringOrSymbol;functionBody="toValue(handle)[getStringOrSymbol(methodName)]";break}functionBody+=`(${args})`;if(!retType.isVoid){captures["toReturnWire"]=toReturnWire;captures["emval_returnValue"]=emval_returnValue;functionBody=`return emval_returnValue(toReturnWire, destructorsRef, ${functionBody})`}functionBody=`return function (handle, methodName, destructorsRef, args) {\n${functionBody}\n}`;var invokerFunction=new Function(Object.keys(captures),functionBody)(...Object.values(captures));var functionName=`methodCaller<(${argTypes.map(t=>t.name)}) => ${retType.name}>`;return emval_addMethodCaller(createNamedFunction(functionName,invokerFunction))})();return BigInt(ret)};var __emval_get_global=function(name){name=bigintToI53Checked(name);var ret=(()=>{if(!name){return Emval.toHandle(globalThis)}name=getStringOrSymbol(name);return Emval.toHandle(globalThis[name])})();return BigInt(ret)};function __emval_invoke(caller,handle,methodName,destructorsRef,args){caller=bigintToI53Checked(caller);handle=bigintToI53Checked(handle);methodName=bigintToI53Checked(methodName);destructorsRef=bigintToI53Checked(destructorsRef);args=bigintToI53Checked(args);return emval_methodCallers[caller](handle,methodName,destructorsRef,args)}var __emval_new_cstring=v=>{v=bigintToI53Checked(v);return BigInt(Emval.toHandle(getStringOrSymbol(v)))};function __emval_run_destructors(handle){handle=bigintToI53Checked(handle);var destructors=Emval.toValue(handle);runDestructors(destructors);__emval_decref(handle)}var timers={};var handleException=e=>{if(e instanceof ExitStatus||e=="unwind"){return EXITSTATUS}quit_(1,e)};var keepRuntimeAlive=()=>noExitRuntime||runtimeKeepaliveCounter>0;var _proc_exit=code=>{EXITSTATUS=code;if(!keepRuntimeAlive()){Module["onExit"]?.(code);ABORT=true}quit_(code,new ExitStatus(code))};var exitJS=(status,implicit)=>{EXITSTATUS=status;_proc_exit(status)};var _exit=exitJS;var maybeExit=()=>{if(!keepRuntimeAlive()){try{_exit(EXITSTATUS)}catch(e){handleException(e)}}};var callUserCallback=func=>{if(ABORT){return}try{return func()}catch(e){handleException(e)}finally{maybeExit()}};var _emscripten_get_now=()=>performance.now();var __setitimer_js=(which,timeout_ms)=>{if(timers[which]){clearTimeout(timers[which].id);delete timers[which]}if(!timeout_ms)return 0;var id=setTimeout(()=>{delete timers[which];callUserCallback(()=>__emscripten_timeout(which,_emscripten_get_now()))},timeout_ms);timers[which]={id,timeout_ms};return 0};var getHeapMax=()=>2147483648;var alignMemory=(size,alignment)=>Math.ceil(size/alignment)*alignment;var growMemory=size=>{var oldHeapSize=wasmMemory.buffer.byteLength;var pages=(size-oldHeapSize+65535)/65536|0;try{wasmMemory.grow(BigInt(pages));updateMemoryViews();return 1}catch(e){}};function _emscripten_resize_heap(requestedSize){requestedSize=bigintToI53Checked(requestedSize);var oldSize=HEAPU8.length;var maxHeapSize=getHeapMax();if(requestedSize>maxHeapSize){return false}for(var cutDown=1;cutDown<=4;cutDown*=2){var overGrownHeapSize=oldSize*(1+.2/cutDown);overGrownHeapSize=Math.min(overGrownHeapSize,requestedSize+100663296);var newSize=Math.min(maxHeapSize,alignMemory(Math.max(requestedSize,overGrownHeapSize),65536));var replacement=growMemory(newSize);if(replacement){return true}}return false}var _fd_close=fd=>52;function _fd_seek(fd,offset,whence,newOffset){offset=bigintToI53Checked(offset);newOffset=bigintToI53Checked(newOffset);return 70}var printCharBuffers=[null,[],[]];var UTF8ArrayToString=(heapOrArray,idx=0,maxBytesToRead,ignoreNul)=>{var endPtr=findStringEnd(heapOrArray,idx,maxBytesToRead,ignoreNul);return UTF8Decoder.decode(heapOrArray.buffer?heapOrArray.subarray(idx,endPtr):new Uint8Array(heapOrArray.slice(idx,endPtr)))};var printChar=(stream,curr)=>{var buffer=printCharBuffers[stream];if(curr===0||curr===10){(stream===1?out:err)(UTF8ArrayToString(buffer));buffer.length=0}else{buffer.push(curr)}};function _fd_write(fd,iov,iovcnt,pnum){iov=bigintToI53Checked(iov);iovcnt=bigintToI53Checked(iovcnt);pnum=bigintToI53Checked(pnum);var num=0;for(var i=0;i<iovcnt;i++){var ptr=Number(HEAPU64[iov/8]);var len=Number(HEAPU64[(iov+8)/8]);iov+=16;for(var j=0;j<len;j++){printChar(fd,HEAPU8[ptr+j])}num+=len}HEAPU64[pnum/8]=BigInt(num);return 0}{if(Module["noExitRuntime"])noExitRuntime=Module["noExitRuntime"];if(Module["print"])out=Module["print"];if(Module["printErr"])err=Module["printErr"];if(Module["wasmBinary"])wasmBinary=Module["wasmBinary"];if(Module["arguments"])arguments_=Module["arguments"];if(Module["thisProgram"])thisProgram=Module["thisProgram"];if(Module["preInit"]){if(typeof Module["preInit"]=="function")Module["preInit"]=[Module["preInit"]];while(Module["preInit"].length>0){Module["preInit"].shift()()}}}var ___getTypeName,_malloc,_free,__emscripten_timeout,memory,__indirect_function_table,wasmMemory,wasmTable;function assignWasmExports(wasmExports){___getTypeName=wasmExports["F"];_malloc=wasmExports["H"];_free=wasmExports["I"];__emscripten_timeout=wasmExports["J"];memory=wasmMemory=wasmExports["D"];__indirect_function_table=wasmTable=wasmExports["G"]}var wasmImports={v:__abort_js,l:__embind_finalize_value_object,e:__embind_register_bigint,z:__embind_register_bool,x:__embind_register_emval,n:__embind_register_enum,d:__embind_register_enum_value,j:__embind_register_float,o:__embind_register_function,c:__embind_register_integer,b:__embind_register_memory_view,y:__embind_register_std_string,f:__embind_register_std_wstring,m:__embind_register_value_object,a:__embind_register_value_object_field,A:__embind_register_void,q:__emscripten_runtime_keepalive_clear,k:__emval_create_invoker,g:__emval_decref,h:__emval_get_global,C:__emval_invoke,i:__emval_new_cstring,B:__emval_run_destructors,r:__setitimer_js,w:_emscripten_resize_heap,u:_fd_close,s:_fd_seek,t:_fd_write,p:_proc_exit};function applySignatureConversions(wasmExports){wasmExports=Object.assign({},wasmExports);var makeWrapper_pp=f=>a0=>Number(f(BigInt(a0)));var makeWrapper__p=f=>a0=>f(BigInt(a0));var makeWrapper_p=f=>()=>Number(f());wasmExports["F"]=makeWrapper_pp(wasmExports["F"]);wasmExports["H"]=makeWrapper_pp(wasmExports["H"]);wasmExports["I"]=makeWrapper__p(wasmExports["I"]);wasmExports["_emscripten_stack_restore"]=makeWrapper__p(wasmExports["_emscripten_stack_restore"]);wasmExports["_emscripten_stack_alloc"]=makeWrapper_pp(wasmExports["_emscripten_stack_alloc"]);wasmExports["emscripten_stack_get_current"]=makeWrapper_p(wasmExports["emscripten_stack_get_current"]);return wasmExports}function run(){preRun();function doRun(){Module["calledRun"]=true;if(ABORT)return;initRuntime();readyPromiseResolve?.(Module);Module["onRuntimeInitialized"]?.();postRun()}if(Module["setStatus"]){Module["setStatus"]("Running...");setTimeout(()=>{setTimeout(()=>Module["setStatus"](""),1);doRun()},1)}else{doRun()}}var wasmExports;wasmExports=await (createWasm());run();if(runtimeInitialized){moduleRtn=Module}else{moduleRtn=new Promise((resolve,reject)=>{readyPromiseResolve=resolve;readyPromiseReject=reject})}
|
|
1
|
+
async function Module(moduleArg={}){var moduleRtn;var Module=moduleArg;var ENVIRONMENT_IS_WEB=!!globalThis.window;var ENVIRONMENT_IS_WORKER=!!globalThis.WorkerGlobalScope;var ENVIRONMENT_IS_NODE=globalThis.process?.versions?.node&&globalThis.process?.type!="renderer";if(ENVIRONMENT_IS_NODE){const{createRequire}=await import("node:module");var require=createRequire(import.meta.url)}var arguments_=[];var thisProgram="./this.program";var quit_=(status,toThrow)=>{throw toThrow};var _scriptName=import.meta.url;var scriptDirectory="";function locateFile(path){if(Module["locateFile"]){return Module["locateFile"](path,scriptDirectory)}return scriptDirectory+path}var readAsync,readBinary;if(ENVIRONMENT_IS_NODE){var fs=require("node:fs");if(_scriptName.startsWith("file:")){scriptDirectory=require("node:path").dirname(require("node:url").fileURLToPath(_scriptName))+"/"}readBinary=filename=>{filename=isFileURI(filename)?new URL(filename):filename;var ret=fs.readFileSync(filename);return ret};readAsync=async(filename,binary=true)=>{filename=isFileURI(filename)?new URL(filename):filename;var ret=fs.readFileSync(filename,binary?undefined:"utf8");return ret};if(process.argv.length>1){thisProgram=process.argv[1].replace(/\\/g,"/")}arguments_=process.argv.slice(2);quit_=(status,toThrow)=>{process.exitCode=status;throw toThrow}}else if(ENVIRONMENT_IS_WEB||ENVIRONMENT_IS_WORKER){try{scriptDirectory=new URL(".",_scriptName).href}catch{}{if(ENVIRONMENT_IS_WORKER){readBinary=url=>{var xhr=new XMLHttpRequest;xhr.open("GET",url,false);xhr.responseType="arraybuffer";xhr.send(null);return new Uint8Array(xhr.response)}}readAsync=async url=>{var response=await fetch(url,{credentials:"same-origin"});if(response.ok){return response.arrayBuffer()}throw new Error(response.status+" : "+response.url)}}}else{}var out=console.log.bind(console);var err=console.error.bind(console);var wasmBinary;var ABORT=false;var EXITSTATUS;var isFileURI=filename=>filename.startsWith("file://");var readyPromiseResolve,readyPromiseReject;var HEAP8,HEAPU8,HEAP16,HEAPU16,HEAP32,HEAPU32,HEAPF32,HEAPF64;var HEAP64,HEAPU64;var runtimeInitialized=false;function updateMemoryViews(){var b=wasmMemory.buffer;HEAP8=new Int8Array(b);HEAP16=new Int16Array(b);HEAPU8=new Uint8Array(b);HEAPU16=new Uint16Array(b);HEAP32=new Int32Array(b);HEAPU32=new Uint32Array(b);HEAPF32=new Float32Array(b);HEAPF64=new Float64Array(b);HEAP64=new BigInt64Array(b);HEAPU64=new BigUint64Array(b)}function preRun(){if(Module["preRun"]){if(typeof Module["preRun"]=="function")Module["preRun"]=[Module["preRun"]];while(Module["preRun"].length){addOnPreRun(Module["preRun"].shift())}}callRuntimeCallbacks(onPreRuns)}function initRuntime(){runtimeInitialized=true;wasmExports["F"]()}function postRun(){if(Module["postRun"]){if(typeof Module["postRun"]=="function")Module["postRun"]=[Module["postRun"]];while(Module["postRun"].length){addOnPostRun(Module["postRun"].shift())}}callRuntimeCallbacks(onPostRuns)}function abort(what){Module["onAbort"]?.(what);what="Aborted("+what+")";err(what);ABORT=true;what+=". Build with -sASSERTIONS for more info.";var e=new WebAssembly.RuntimeError(what);readyPromiseReject?.(e);throw e}var wasmBinaryFile;function findWasmBinary(){if(Module["locateFile"]){return locateFile("webp-enc.wasm")}return new URL("webp-enc.wasm",import.meta.url).href}function getBinarySync(file){if(file==wasmBinaryFile&&wasmBinary){return new Uint8Array(wasmBinary)}if(readBinary){return readBinary(file)}throw"both async and sync fetching of the wasm failed"}async function getWasmBinary(binaryFile){if(!wasmBinary){try{var response=await readAsync(binaryFile);return new Uint8Array(response)}catch{}}return getBinarySync(binaryFile)}async function instantiateArrayBuffer(binaryFile,imports){try{var binary=await getWasmBinary(binaryFile);var instance=await WebAssembly.instantiate(binary,imports);return instance}catch(reason){err(`failed to asynchronously prepare wasm: ${reason}`);abort(reason)}}async function instantiateAsync(binary,binaryFile,imports){if(!binary&&!ENVIRONMENT_IS_NODE){try{var response=fetch(binaryFile,{credentials:"same-origin"});var instantiationResult=await WebAssembly.instantiateStreaming(response,imports);return instantiationResult}catch(reason){err(`wasm streaming compile failed: ${reason}`);err("falling back to ArrayBuffer instantiation")}}return instantiateArrayBuffer(binaryFile,imports)}function getWasmImports(){var imports={a:wasmImports};return imports}async function createWasm(){function receiveInstance(instance,module){wasmExports=instance.exports;wasmExports=applySignatureConversions(wasmExports);assignWasmExports(wasmExports);updateMemoryViews();return wasmExports}function receiveInstantiationResult(result){return receiveInstance(result["instance"])}var info=getWasmImports();if(Module["instantiateWasm"]){return new Promise((resolve,reject)=>{Module["instantiateWasm"](info,(inst,mod)=>{resolve(receiveInstance(inst,mod))})})}wasmBinaryFile??=findWasmBinary();var result=await instantiateAsync(wasmBinary,wasmBinaryFile,info);var exports=receiveInstantiationResult(result);return exports}class ExitStatus{name="ExitStatus";constructor(status){this.message=`Program terminated with exit(${status})`;this.status=status}}var callRuntimeCallbacks=callbacks=>{while(callbacks.length>0){callbacks.shift()(Module)}};var onPostRuns=[];var addOnPostRun=cb=>onPostRuns.push(cb);var onPreRuns=[];var addOnPreRun=cb=>onPreRuns.push(cb);var noExitRuntime=true;var __abort_js=()=>abort("");var structRegistrations={};var runDestructors=destructors=>{while(destructors.length){var ptr=destructors.pop();var del=destructors.pop();del(ptr)}};function readPointer(pointer){return this.fromWireType(Number(HEAPU64[pointer/8]))}var awaitingDependencies={};var registeredTypes={};var typeDependencies={};var InternalError=class InternalError extends Error{constructor(message){super(message);this.name="InternalError"}};var throwInternalError=message=>{throw new InternalError(message)};var whenDependentTypesAreResolved=(myTypes,dependentTypes,getTypeConverters)=>{myTypes.forEach(type=>typeDependencies[type]=dependentTypes);function onComplete(typeConverters){var myTypeConverters=getTypeConverters(typeConverters);if(myTypeConverters.length!==myTypes.length){throwInternalError("Mismatched type converter count")}for(var i=0;i<myTypes.length;++i){registerType(myTypes[i],myTypeConverters[i])}}var typeConverters=new Array(dependentTypes.length);var unregisteredTypes=[];var registered=0;for(let[i,dt]of dependentTypes.entries()){if(registeredTypes.hasOwnProperty(dt)){typeConverters[i]=registeredTypes[dt]}else{unregisteredTypes.push(dt);if(!awaitingDependencies.hasOwnProperty(dt)){awaitingDependencies[dt]=[]}awaitingDependencies[dt].push(()=>{typeConverters[i]=registeredTypes[dt];++registered;if(registered===unregisteredTypes.length){onComplete(typeConverters)}})}}if(0===unregisteredTypes.length){onComplete(typeConverters)}};var INT53_MAX=9007199254740992;var INT53_MIN=-9007199254740992;var bigintToI53Checked=num=>num<INT53_MIN||num>INT53_MAX?NaN:Number(num);var __embind_finalize_value_object=function(structType){structType=bigintToI53Checked(structType);var reg=structRegistrations[structType];delete structRegistrations[structType];var rawConstructor=reg.rawConstructor;var rawDestructor=reg.rawDestructor;var fieldRecords=reg.fields;var fieldTypes=fieldRecords.map(field=>field.getterReturnType).concat(fieldRecords.map(field=>field.setterArgumentType));whenDependentTypesAreResolved([structType],fieldTypes,fieldTypes=>{var fields={};for(var[i,field]of fieldRecords.entries()){const getterReturnType=fieldTypes[i];const getter=field.getter;const getterContext=field.getterContext;const setterArgumentType=fieldTypes[i+fieldRecords.length];const setter=field.setter;const setterContext=field.setterContext;fields[field.fieldName]={read:ptr=>getterReturnType.fromWireType(getter(getterContext,ptr)),write:(ptr,o)=>{var destructors=[];setter(setterContext,ptr,setterArgumentType.toWireType(destructors,o));runDestructors(destructors)},optional:getterReturnType.optional}}return[{name:reg.name,fromWireType:ptr=>{var rv={};for(var i in fields){rv[i]=fields[i].read(ptr)}rawDestructor(ptr);return rv},toWireType:(destructors,o)=>{for(var fieldName in fields){if(!(fieldName in o)&&!fields[fieldName].optional){throw new TypeError(`Missing field: "${fieldName}"`)}}var ptr=rawConstructor();for(fieldName in fields){fields[fieldName].write(ptr,o[fieldName])}if(destructors!==null){destructors.push(rawDestructor,ptr)}return ptr},readValueFromPointer:readPointer,destructorFunction:rawDestructor}]})};var AsciiToString=ptr=>{var str="";while(1){var ch=HEAPU8[ptr++];if(!ch)return str;str+=String.fromCharCode(ch)}};var BindingError=class BindingError extends Error{constructor(message){super(message);this.name="BindingError"}};var throwBindingError=message=>{throw new BindingError(message)};function sharedRegisterType(rawType,registeredInstance,options={}){var name=registeredInstance.name;if(!rawType){throwBindingError(`type "${name}" must have a positive integer typeid pointer`)}if(registeredTypes.hasOwnProperty(rawType)){if(options.ignoreDuplicateRegistrations){return}else{throwBindingError(`Cannot register type '${name}' twice`)}}registeredTypes[rawType]=registeredInstance;delete typeDependencies[rawType];if(awaitingDependencies.hasOwnProperty(rawType)){var callbacks=awaitingDependencies[rawType];delete awaitingDependencies[rawType];callbacks.forEach(cb=>cb())}}function registerType(rawType,registeredInstance,options={}){return sharedRegisterType(rawType,registeredInstance,options)}var integerReadValueFromPointer=(name,width,signed)=>{switch(width){case 1:return signed?pointer=>HEAP8[pointer]:pointer=>HEAPU8[pointer];case 2:return signed?pointer=>HEAP16[pointer/2]:pointer=>HEAPU16[pointer/2];case 4:return signed?pointer=>HEAP32[pointer/4]:pointer=>HEAPU32[pointer/4];case 8:return signed?pointer=>HEAP64[pointer/8]:pointer=>HEAPU64[pointer/8];default:throw new TypeError(`invalid integer width (${width}): ${name}`)}};var __embind_register_bigint=function(primitiveType,name,size,minRange,maxRange){primitiveType=bigintToI53Checked(primitiveType);name=bigintToI53Checked(name);size=bigintToI53Checked(size);name=AsciiToString(name);const isUnsignedType=minRange===0n;let fromWireType=value=>value;if(isUnsignedType){const bitSize=size*8;fromWireType=value=>{if(typeof value=="number"){return value>>>0}return BigInt.asUintN(bitSize,value)};maxRange=fromWireType(maxRange)}registerType(primitiveType,{name,fromWireType,toWireType:(destructors,value)=>{if(typeof value=="number"){value=BigInt(value)}return value},readValueFromPointer:integerReadValueFromPointer(name,size,!isUnsignedType),destructorFunction:null})};function __embind_register_bool(rawType,name,trueValue,falseValue){rawType=bigintToI53Checked(rawType);name=bigintToI53Checked(name);name=AsciiToString(name);registerType(rawType,{name,fromWireType:function(wt){return!!wt},toWireType:function(destructors,o){return o?trueValue:falseValue},readValueFromPointer:function(pointer){return this.fromWireType(HEAPU8[pointer])},destructorFunction:null})}var emval_freelist=[];var emval_handles=[0,1,,1,null,1,true,1,false,1];function __emval_decref(handle){handle=bigintToI53Checked(handle);if(handle>9&&0===--emval_handles[handle+1]){emval_handles[handle]=undefined;emval_freelist.push(handle)}}var Emval={toValue:handle=>{if(!handle){throwBindingError(`Cannot use deleted val. handle = ${handle}`)}return emval_handles[handle]},toHandle:value=>{switch(value){case undefined:return 2;case null:return 4;case true:return 6;case false:return 8;default:{const handle=emval_freelist.pop()||emval_handles.length;emval_handles[handle]=value;emval_handles[handle+1]=1;return handle}}}};var EmValType={name:"emscripten::val",fromWireType:handle=>{var rv=Emval.toValue(handle);__emval_decref(handle);return rv},toWireType:(destructors,value)=>Emval.toHandle(value),readValueFromPointer:readPointer,destructorFunction:null};function __embind_register_emval(rawType){rawType=bigintToI53Checked(rawType);return registerType(rawType,EmValType)}var ensureOverloadTable=(proto,methodName,humanName)=>{if(undefined===proto[methodName].overloadTable){var prevFunc=proto[methodName];proto[methodName]=function(...args){if(!proto[methodName].overloadTable.hasOwnProperty(args.length)){throwBindingError(`Function '${humanName}' called with an invalid number of arguments (${args.length}) - expects one of (${proto[methodName].overloadTable})!`)}return proto[methodName].overloadTable[args.length].apply(this,args)};proto[methodName].overloadTable=[];proto[methodName].overloadTable[prevFunc.argCount]=prevFunc}};var exposePublicSymbol=(name,value,numArguments)=>{if(Module.hasOwnProperty(name)){if(undefined===numArguments||undefined!==Module[name].overloadTable&&undefined!==Module[name].overloadTable[numArguments]){throwBindingError(`Cannot register public name '${name}' twice`)}ensureOverloadTable(Module,name,name);if(Module[name].overloadTable.hasOwnProperty(numArguments)){throwBindingError(`Cannot register multiple overloads of a function with the same number of arguments (${numArguments})!`)}Module[name].overloadTable[numArguments]=value}else{Module[name]=value;Module[name].argCount=numArguments}};var enumReadValueFromPointer=(name,width,signed)=>{switch(width){case 1:return signed?function(pointer){return this.fromWireType(HEAP8[pointer])}:function(pointer){return this.fromWireType(HEAPU8[pointer])};case 2:return signed?function(pointer){return this.fromWireType(HEAP16[pointer/2])}:function(pointer){return this.fromWireType(HEAPU16[pointer/2])};case 4:return signed?function(pointer){return this.fromWireType(HEAP32[pointer/4])}:function(pointer){return this.fromWireType(HEAPU32[pointer/4])};default:throw new TypeError(`invalid integer width (${width}): ${name}`)}};function getEnumValueType(rawValueType){return rawValueType===0?"object":rawValueType===1?"number":"string"}function __embind_register_enum(rawType,name,size,isSigned,rawValueType){rawType=bigintToI53Checked(rawType);name=bigintToI53Checked(name);size=bigintToI53Checked(size);name=AsciiToString(name);const valueType=getEnumValueType(rawValueType);switch(valueType){case"object":{function ctor(){}ctor.values={};registerType(rawType,{name,constructor:ctor,valueType,fromWireType:function(c){return this.constructor.values[c]},toWireType:(destructors,c)=>c.value,readValueFromPointer:enumReadValueFromPointer(name,size,isSigned),destructorFunction:null});exposePublicSymbol(name,ctor);break}case"number":{var keysMap={};registerType(rawType,{name,keysMap,valueType,fromWireType:c=>c,toWireType:(destructors,c)=>c,readValueFromPointer:enumReadValueFromPointer(name,size,isSigned),destructorFunction:null});exposePublicSymbol(name,keysMap);delete Module[name].argCount;break}case"string":{var valuesMap={};var reverseMap={};var keysMap={};registerType(rawType,{name,valuesMap,reverseMap,keysMap,valueType,fromWireType:function(c){return this.reverseMap[c]},toWireType:function(destructors,c){return this.valuesMap[c]},readValueFromPointer:enumReadValueFromPointer(name,size,isSigned),destructorFunction:null});exposePublicSymbol(name,keysMap);delete Module[name].argCount;break}}}var createNamedFunction=(name,func)=>Object.defineProperty(func,"name",{value:name});var getTypeName=type=>{var ptr=___getTypeName(type);var rv=AsciiToString(ptr);_free(ptr);return rv};var requireRegisteredType=(rawType,humanName)=>{var impl=registeredTypes[rawType];if(undefined===impl){throwBindingError(`${humanName} has unknown type ${getTypeName(rawType)}`)}return impl};function __embind_register_enum_value(rawEnumType,name,enumValue){rawEnumType=bigintToI53Checked(rawEnumType);name=bigintToI53Checked(name);var enumType=requireRegisteredType(rawEnumType,"enum");name=AsciiToString(name);switch(enumType.valueType){case"object":{var Enum=enumType.constructor;var Value=Object.create(enumType.constructor.prototype,{value:{value:enumValue},constructor:{value:createNamedFunction(`${enumType.name}_${name}`,function(){})}});Enum.values[enumValue]=Value;Enum[name]=Value;break}case"number":{enumType.keysMap[name]=enumValue;break}case"string":{enumType.valuesMap[name]=enumValue;enumType.reverseMap[enumValue]=name;enumType.keysMap[name]=name;break}}}var floatReadValueFromPointer=(name,width)=>{switch(width){case 4:return function(pointer){return this.fromWireType(HEAPF32[pointer/4])};case 8:return function(pointer){return this.fromWireType(HEAPF64[pointer/8])};default:throw new TypeError(`invalid float width (${width}): ${name}`)}};var __embind_register_float=function(rawType,name,size){rawType=bigintToI53Checked(rawType);name=bigintToI53Checked(name);size=bigintToI53Checked(size);name=AsciiToString(name);registerType(rawType,{name,fromWireType:value=>value,toWireType:(destructors,value)=>value,readValueFromPointer:floatReadValueFromPointer(name,size),destructorFunction:null})};function usesDestructorStack(argTypes){for(var i=1;i<argTypes.length;++i){if(argTypes[i]!==null&&argTypes[i].destructorFunction===undefined){return true}}return false}function createJsInvoker(argTypes,isClassMethodFunc,returns,isAsync){var needsDestructorStack=usesDestructorStack(argTypes);var argCount=argTypes.length-2;var argsList=[];var argsListWired=["fn"];if(isClassMethodFunc){argsListWired.push("thisWired")}for(var i=0;i<argCount;++i){argsList.push(`arg${i}`);argsListWired.push(`arg${i}Wired`)}argsList=argsList.join(",");argsListWired=argsListWired.join(",");var invokerFnBody=`return function (${argsList}) {\n`;if(needsDestructorStack){invokerFnBody+="var destructors = [];\n"}var dtorStack=needsDestructorStack?"destructors":"null";var args1=["humanName","throwBindingError","invoker","fn","runDestructors","fromRetWire","toClassParamWire"];if(isClassMethodFunc){invokerFnBody+=`var thisWired = toClassParamWire(${dtorStack}, this);\n`}for(var i=0;i<argCount;++i){var argName=`toArg${i}Wire`;invokerFnBody+=`var arg${i}Wired = ${argName}(${dtorStack}, arg${i});\n`;args1.push(argName)}invokerFnBody+=(returns||isAsync?"var rv = ":"")+`invoker(${argsListWired});\n`;if(needsDestructorStack){invokerFnBody+="runDestructors(destructors);\n"}else{for(var i=isClassMethodFunc?1:2;i<argTypes.length;++i){var paramName=i===1?"thisWired":"arg"+(i-2)+"Wired";if(argTypes[i].destructorFunction!==null){invokerFnBody+=`${paramName}_dtor(${paramName});\n`;args1.push(`${paramName}_dtor`)}}}if(returns){invokerFnBody+="var ret = fromRetWire(rv);\n"+"return ret;\n"}else{}invokerFnBody+="}\n";return new Function(args1,invokerFnBody)}function craftInvokerFunction(humanName,argTypes,classType,cppInvokerFunc,cppTargetFunc,isAsync){var argCount=argTypes.length;if(argCount<2){throwBindingError("argTypes array size mismatch! Must at least get return value and 'this' types!")}var isClassMethodFunc=argTypes[1]!==null&&classType!==null;var needsDestructorStack=usesDestructorStack(argTypes);var returns=!argTypes[0].isVoid;var retType=argTypes[0];var instType=argTypes[1];var closureArgs=[humanName,throwBindingError,cppInvokerFunc,cppTargetFunc,runDestructors,retType.fromWireType.bind(retType),instType?.toWireType.bind(instType)];for(var i=2;i<argCount;++i){var argType=argTypes[i];closureArgs.push(argType.toWireType.bind(argType))}if(!needsDestructorStack){for(var i=isClassMethodFunc?1:2;i<argTypes.length;++i){if(argTypes[i].destructorFunction!==null){closureArgs.push(argTypes[i].destructorFunction)}}}let invokerFactory=createJsInvoker(argTypes,isClassMethodFunc,returns,isAsync);var invokerFn=invokerFactory(...closureArgs);return createNamedFunction(humanName,invokerFn)}var heap32VectorToArray=(count,firstElement)=>{var array=[];for(var i=0;i<count;i++){array.push(Number(HEAPU64[(firstElement+i*8)/8]))}return array};var replacePublicSymbol=(name,value,numArguments)=>{if(!Module.hasOwnProperty(name)){throwInternalError("Replacing nonexistent public symbol")}if(undefined!==Module[name].overloadTable&&undefined!==numArguments){Module[name].overloadTable[numArguments]=value}else{Module[name]=value;Module[name].argCount=numArguments}};var wasmTableMirror=[];var getWasmTableEntry=funcPtr=>{funcPtr=Number(funcPtr);var func=wasmTableMirror[funcPtr];if(!func){wasmTableMirror[funcPtr]=func=wasmTable.get(BigInt(funcPtr))}return func};var dynCall=(sig,ptr,args=[],promising=false)=>{for(var i=1;i<sig.length;++i){if(sig[i]=="p")args[i-1]=BigInt(args[i-1])}var func=getWasmTableEntry(ptr);var rtn=func(...args);function convert(rtn){return sig[0]=="p"?Number(rtn):rtn}return convert(rtn)};var getDynCaller=(sig,ptr,promising=false)=>(...args)=>dynCall(sig,ptr,args,promising);var embind__requireFunction=(signature,rawFunction,isAsync=false)=>{signature=AsciiToString(signature);function makeDynCaller(){if(signature.includes("p")){return getDynCaller(signature,rawFunction,isAsync)}var rtn=getWasmTableEntry(rawFunction);return rtn}var fp=makeDynCaller();if(typeof fp!="function"){throwBindingError(`unknown function pointer with signature ${signature}: ${rawFunction}`)}return fp};class UnboundTypeError extends Error{}var throwUnboundTypeError=(message,types)=>{var unboundTypes=[];var seen={};function visit(type){if(seen[type]){return}if(registeredTypes[type]){return}if(typeDependencies[type]){typeDependencies[type].forEach(visit);return}unboundTypes.push(type);seen[type]=true}types.forEach(visit);throw new UnboundTypeError(`${message}: `+unboundTypes.map(getTypeName).join([", "]))};var getFunctionName=signature=>{signature=signature.trim();const argsIndex=signature.indexOf("(");if(argsIndex===-1)return signature;return signature.slice(0,argsIndex)};function __embind_register_function(name,argCount,rawArgTypesAddr,signature,rawInvoker,fn,isAsync,isNonnullReturn){name=bigintToI53Checked(name);rawArgTypesAddr=bigintToI53Checked(rawArgTypesAddr);signature=bigintToI53Checked(signature);rawInvoker=bigintToI53Checked(rawInvoker);fn=bigintToI53Checked(fn);var argTypes=heap32VectorToArray(argCount,rawArgTypesAddr);name=AsciiToString(name);name=getFunctionName(name);rawInvoker=embind__requireFunction(signature,rawInvoker,isAsync);exposePublicSymbol(name,function(){throwUnboundTypeError(`Cannot call ${name} due to unbound types`,argTypes)},argCount-1);whenDependentTypesAreResolved([],argTypes,argTypes=>{var invokerArgsArray=[argTypes[0],null].concat(argTypes.slice(1));replacePublicSymbol(name,craftInvokerFunction(name,invokerArgsArray,null,rawInvoker,fn,isAsync),argCount-1);return[]})}var __embind_register_integer=function(primitiveType,name,size,minRange,maxRange){primitiveType=bigintToI53Checked(primitiveType);name=bigintToI53Checked(name);size=bigintToI53Checked(size);name=AsciiToString(name);const isUnsignedType=minRange===0;let fromWireType=value=>value;if(isUnsignedType){var bitshift=32-8*size;fromWireType=value=>value<<bitshift>>>bitshift;maxRange=fromWireType(maxRange)}registerType(primitiveType,{name,fromWireType,toWireType:(destructors,value)=>value,readValueFromPointer:integerReadValueFromPointer(name,size,minRange!==0),destructorFunction:null})};function __embind_register_memory_view(rawType,dataTypeIndex,name){rawType=bigintToI53Checked(rawType);name=bigintToI53Checked(name);var typeMapping=[Int8Array,Uint8Array,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array,BigInt64Array,BigUint64Array];var TA=typeMapping[dataTypeIndex];function decodeMemoryView(handle){var size=Number(HEAPU64[handle/8]);var data=Number(HEAPU64[(handle+8)/8]);return new TA(HEAP8.buffer,data,size)}name=AsciiToString(name);registerType(rawType,{name,fromWireType:decodeMemoryView,readValueFromPointer:decodeMemoryView},{ignoreDuplicateRegistrations:true})}var EmValOptionalType=Object.assign({optional:true},EmValType);function __embind_register_optional(rawOptionalType,rawType){rawOptionalType=bigintToI53Checked(rawOptionalType);rawType=bigintToI53Checked(rawType);registerType(rawOptionalType,EmValOptionalType)}var stringToUTF8Array=(str,heap,outIdx,maxBytesToWrite)=>{if(!(maxBytesToWrite>0))return 0;var startIdx=outIdx;var endIdx=outIdx+maxBytesToWrite-1;for(var i=0;i<str.length;++i){var u=str.codePointAt(i);if(u<=127){if(outIdx>=endIdx)break;heap[outIdx++]=u}else if(u<=2047){if(outIdx+1>=endIdx)break;heap[outIdx++]=192|u>>6;heap[outIdx++]=128|u&63}else if(u<=65535){if(outIdx+2>=endIdx)break;heap[outIdx++]=224|u>>12;heap[outIdx++]=128|u>>6&63;heap[outIdx++]=128|u&63}else{if(outIdx+3>=endIdx)break;heap[outIdx++]=240|u>>18;heap[outIdx++]=128|u>>12&63;heap[outIdx++]=128|u>>6&63;heap[outIdx++]=128|u&63;i++}}heap[outIdx]=0;return outIdx-startIdx};var stringToUTF8=(str,outPtr,maxBytesToWrite)=>stringToUTF8Array(str,HEAPU8,outPtr,maxBytesToWrite);var lengthBytesUTF8=str=>{var len=0;for(var i=0;i<str.length;++i){var c=str.charCodeAt(i);if(c<=127){len++}else if(c<=2047){len+=2}else if(c>=55296&&c<=57343){len+=4;++i}else{len+=3}}return len};var UTF8Decoder=new TextDecoder;var findStringEnd=(heapOrArray,idx,maxBytesToRead,ignoreNul)=>{var maxIdx=idx+maxBytesToRead;if(ignoreNul)return maxIdx;while(heapOrArray[idx]&&!(idx>=maxIdx))++idx;return idx};var UTF8ToString=(ptr,maxBytesToRead,ignoreNul)=>{if(!ptr)return"";var end=findStringEnd(HEAPU8,ptr,maxBytesToRead,ignoreNul);return UTF8Decoder.decode(HEAPU8.subarray(ptr,end))};function __embind_register_std_string(rawType,name){rawType=bigintToI53Checked(rawType);name=bigintToI53Checked(name);name=AsciiToString(name);var stdStringIsUTF8=true;registerType(rawType,{name,fromWireType(value){var length=Number(HEAPU64[value/8]);var payload=value+8;var str;if(stdStringIsUTF8){str=UTF8ToString(payload,length,true)}else{str="";for(var i=0;i<length;++i){str+=String.fromCharCode(HEAPU8[payload+i])}}_free(value);return str},toWireType(destructors,value){if(value instanceof ArrayBuffer){value=new Uint8Array(value)}var length;var valueIsOfTypeString=typeof value=="string";if(!(valueIsOfTypeString||ArrayBuffer.isView(value)&&value.BYTES_PER_ELEMENT==1)){throwBindingError("Cannot pass non-string to std::string")}if(stdStringIsUTF8&&valueIsOfTypeString){length=lengthBytesUTF8(value)}else{length=value.length}var base=_malloc(8+length+1);var ptr=base+8;HEAPU64[base/8]=BigInt(length);if(valueIsOfTypeString){if(stdStringIsUTF8){stringToUTF8(value,ptr,length+1)}else{for(var i=0;i<length;++i){var charCode=value.charCodeAt(i);if(charCode>255){_free(base);throwBindingError("String has UTF-16 code units that do not fit in 8 bits")}HEAPU8[ptr+i]=charCode}}}else{HEAPU8.set(value,ptr)}if(destructors!==null){destructors.push(_free,base)}return base},readValueFromPointer:readPointer,destructorFunction(ptr){_free(ptr)}})}var UTF16Decoder=new TextDecoder("utf-16le");var UTF16ToString=(ptr,maxBytesToRead,ignoreNul)=>{var idx=ptr/2;var endIdx=findStringEnd(HEAPU16,idx,maxBytesToRead/2,ignoreNul);return UTF16Decoder.decode(HEAPU16.subarray(idx,endIdx))};var stringToUTF16=(str,outPtr,maxBytesToWrite)=>{maxBytesToWrite??=2147483647;if(maxBytesToWrite<2)return 0;maxBytesToWrite-=2;var startPtr=outPtr;var numCharsToWrite=maxBytesToWrite<str.length*2?maxBytesToWrite/2:str.length;for(var i=0;i<numCharsToWrite;++i){var codeUnit=str.charCodeAt(i);HEAP16[outPtr/2]=codeUnit;outPtr+=2}HEAP16[outPtr/2]=0;return outPtr-startPtr};var lengthBytesUTF16=str=>str.length*2;var UTF32ToString=(ptr,maxBytesToRead,ignoreNul)=>{var str="";var startIdx=ptr/4;for(var i=0;!(i>=maxBytesToRead/4);i++){var utf32=HEAPU32[startIdx+i];if(!utf32&&!ignoreNul)break;str+=String.fromCodePoint(utf32)}return str};var stringToUTF32=(str,outPtr,maxBytesToWrite)=>{maxBytesToWrite??=2147483647;if(maxBytesToWrite<4)return 0;var startPtr=outPtr;var endPtr=startPtr+maxBytesToWrite-4;for(var i=0;i<str.length;++i){var codePoint=str.codePointAt(i);if(codePoint>65535){i++}HEAP32[outPtr/4]=codePoint;outPtr+=4;if(outPtr+4>endPtr)break}HEAP32[outPtr/4]=0;return outPtr-startPtr};var lengthBytesUTF32=str=>{var len=0;for(var i=0;i<str.length;++i){var codePoint=str.codePointAt(i);if(codePoint>65535){i++}len+=4}return len};function __embind_register_std_wstring(rawType,charSize,name){rawType=bigintToI53Checked(rawType);charSize=bigintToI53Checked(charSize);name=bigintToI53Checked(name);name=AsciiToString(name);var decodeString,encodeString,lengthBytesUTF;if(charSize===2){decodeString=UTF16ToString;encodeString=stringToUTF16;lengthBytesUTF=lengthBytesUTF16}else{decodeString=UTF32ToString;encodeString=stringToUTF32;lengthBytesUTF=lengthBytesUTF32}registerType(rawType,{name,fromWireType:value=>{var length=Number(HEAPU64[value/8]);var str=decodeString(value+8,length*charSize,true);_free(value);return str},toWireType:(destructors,value)=>{if(!(typeof value=="string")){throwBindingError(`Cannot pass non-string to C++ string type ${name}`)}var length=lengthBytesUTF(value);var ptr=_malloc(8+length+charSize);HEAPU64[ptr/8]=BigInt(length/charSize);encodeString(value,ptr+8,length+charSize);if(destructors!==null){destructors.push(_free,ptr)}return ptr},readValueFromPointer:readPointer,destructorFunction(ptr){_free(ptr)}})}function __embind_register_value_object(rawType,name,constructorSignature,rawConstructor,destructorSignature,rawDestructor){rawType=bigintToI53Checked(rawType);name=bigintToI53Checked(name);constructorSignature=bigintToI53Checked(constructorSignature);rawConstructor=bigintToI53Checked(rawConstructor);destructorSignature=bigintToI53Checked(destructorSignature);rawDestructor=bigintToI53Checked(rawDestructor);structRegistrations[rawType]={name:AsciiToString(name),rawConstructor:embind__requireFunction(constructorSignature,rawConstructor),rawDestructor:embind__requireFunction(destructorSignature,rawDestructor),fields:[]}}function __embind_register_value_object_field(structType,fieldName,getterReturnType,getterSignature,getter,getterContext,setterArgumentType,setterSignature,setter,setterContext){structType=bigintToI53Checked(structType);fieldName=bigintToI53Checked(fieldName);getterReturnType=bigintToI53Checked(getterReturnType);getterSignature=bigintToI53Checked(getterSignature);getter=bigintToI53Checked(getter);getterContext=bigintToI53Checked(getterContext);setterArgumentType=bigintToI53Checked(setterArgumentType);setterSignature=bigintToI53Checked(setterSignature);setter=bigintToI53Checked(setter);setterContext=bigintToI53Checked(setterContext);structRegistrations[structType].fields.push({fieldName:AsciiToString(fieldName),getterReturnType,getter:embind__requireFunction(getterSignature,getter),getterContext,setterArgumentType,setter:embind__requireFunction(setterSignature,setter),setterContext})}var __embind_register_void=function(rawType,name){rawType=bigintToI53Checked(rawType);name=bigintToI53Checked(name);name=AsciiToString(name);registerType(rawType,{isVoid:true,name,fromWireType:()=>undefined,toWireType:(destructors,o)=>undefined})};var runtimeKeepaliveCounter=0;var __emscripten_runtime_keepalive_clear=()=>{noExitRuntime=false;runtimeKeepaliveCounter=0};var emval_methodCallers=[];var emval_addMethodCaller=caller=>{var id=emval_methodCallers.length;emval_methodCallers.push(caller);return id};var emval_lookupTypes=(argCount,argTypes)=>{var a=new Array(argCount);for(var i=0;i<argCount;++i){a[i]=requireRegisteredType(Number(HEAPU64[(argTypes+i*8)/8]),`parameter ${i}`)}return a};var emval_returnValue=(toReturnWire,destructorsRef,handle)=>{var destructors=[];var result=toReturnWire(destructors,handle);if(destructors.length){HEAPU64[destructorsRef/8]=BigInt(Emval.toHandle(destructors))}return result};var emval_symbols={};var getStringOrSymbol=address=>{var symbol=emval_symbols[address];if(symbol===undefined){return AsciiToString(address)}return symbol};var __emval_create_invoker=function(argCount,argTypesPtr,kind){argTypesPtr=bigintToI53Checked(argTypesPtr);var ret=(()=>{var GenericWireTypeSize=16;var[retType,...argTypes]=emval_lookupTypes(argCount,argTypesPtr);var toReturnWire=retType.toWireType.bind(retType);var argFromPtr=argTypes.map(type=>type.readValueFromPointer.bind(type));argCount--;var captures={toValue:Emval.toValue};var args=argFromPtr.map((argFromPtr,i)=>{var captureName=`argFromPtr${i}`;captures[captureName]=argFromPtr;return`${captureName}(args${i?"+"+i*GenericWireTypeSize:""})`});var functionBody;switch(kind){case 0:functionBody="toValue(handle)";break;case 2:functionBody="new (toValue(handle))";break;case 3:functionBody="";break;case 1:captures["getStringOrSymbol"]=getStringOrSymbol;functionBody="toValue(handle)[getStringOrSymbol(methodName)]";break}functionBody+=`(${args})`;if(!retType.isVoid){captures["toReturnWire"]=toReturnWire;captures["emval_returnValue"]=emval_returnValue;functionBody=`return emval_returnValue(toReturnWire, destructorsRef, ${functionBody})`}functionBody=`return function (handle, methodName, destructorsRef, args) {\n${functionBody}\n}`;var invokerFunction=new Function(Object.keys(captures),functionBody)(...Object.values(captures));var functionName=`methodCaller<(${argTypes.map(t=>t.name)}) => ${retType.name}>`;return emval_addMethodCaller(createNamedFunction(functionName,invokerFunction))})();return BigInt(ret)};var __emval_get_global=function(name){name=bigintToI53Checked(name);var ret=(()=>{if(!name){return Emval.toHandle(globalThis)}name=getStringOrSymbol(name);return Emval.toHandle(globalThis[name])})();return BigInt(ret)};function __emval_invoke(caller,handle,methodName,destructorsRef,args){caller=bigintToI53Checked(caller);handle=bigintToI53Checked(handle);methodName=bigintToI53Checked(methodName);destructorsRef=bigintToI53Checked(destructorsRef);args=bigintToI53Checked(args);return emval_methodCallers[caller](handle,methodName,destructorsRef,args)}var __emval_new_cstring=v=>{v=bigintToI53Checked(v);return BigInt(Emval.toHandle(getStringOrSymbol(v)))};function __emval_run_destructors(handle){handle=bigintToI53Checked(handle);var destructors=Emval.toValue(handle);runDestructors(destructors);__emval_decref(handle)}var timers={};var handleException=e=>{if(e instanceof ExitStatus||e=="unwind"){return EXITSTATUS}quit_(1,e)};var keepRuntimeAlive=()=>noExitRuntime||runtimeKeepaliveCounter>0;var _proc_exit=code=>{EXITSTATUS=code;if(!keepRuntimeAlive()){Module["onExit"]?.(code);ABORT=true}quit_(code,new ExitStatus(code))};var exitJS=(status,implicit)=>{EXITSTATUS=status;_proc_exit(status)};var _exit=exitJS;var maybeExit=()=>{if(!keepRuntimeAlive()){try{_exit(EXITSTATUS)}catch(e){handleException(e)}}};var callUserCallback=func=>{if(ABORT){return}try{return func()}catch(e){handleException(e)}finally{maybeExit()}};var _emscripten_get_now=()=>performance.now();var __setitimer_js=(which,timeout_ms)=>{if(timers[which]){clearTimeout(timers[which].id);delete timers[which]}if(!timeout_ms)return 0;var id=setTimeout(()=>{delete timers[which];callUserCallback(()=>__emscripten_timeout(which,_emscripten_get_now()))},timeout_ms);timers[which]={id,timeout_ms};return 0};var getHeapMax=()=>2147483648;var alignMemory=(size,alignment)=>Math.ceil(size/alignment)*alignment;var growMemory=size=>{var oldHeapSize=wasmMemory.buffer.byteLength;var pages=(size-oldHeapSize+65535)/65536|0;try{wasmMemory.grow(BigInt(pages));updateMemoryViews();return 1}catch(e){}};function _emscripten_resize_heap(requestedSize){requestedSize=bigintToI53Checked(requestedSize);var oldSize=HEAPU8.length;var maxHeapSize=getHeapMax();if(requestedSize>maxHeapSize){return false}for(var cutDown=1;cutDown<=4;cutDown*=2){var overGrownHeapSize=oldSize*(1+.2/cutDown);overGrownHeapSize=Math.min(overGrownHeapSize,requestedSize+100663296);var newSize=Math.min(maxHeapSize,alignMemory(Math.max(requestedSize,overGrownHeapSize),65536));var replacement=growMemory(newSize);if(replacement){return true}}return false}var _fd_close=fd=>52;function _fd_seek(fd,offset,whence,newOffset){offset=bigintToI53Checked(offset);newOffset=bigintToI53Checked(newOffset);return 70}var printCharBuffers=[null,[],[]];var UTF8ArrayToString=(heapOrArray,idx=0,maxBytesToRead,ignoreNul)=>{var endPtr=findStringEnd(heapOrArray,idx,maxBytesToRead,ignoreNul);return UTF8Decoder.decode(heapOrArray.buffer?heapOrArray.subarray(idx,endPtr):new Uint8Array(heapOrArray.slice(idx,endPtr)))};var printChar=(stream,curr)=>{var buffer=printCharBuffers[stream];if(curr===0||curr===10){(stream===1?out:err)(UTF8ArrayToString(buffer));buffer.length=0}else{buffer.push(curr)}};function _fd_write(fd,iov,iovcnt,pnum){iov=bigintToI53Checked(iov);iovcnt=bigintToI53Checked(iovcnt);pnum=bigintToI53Checked(pnum);var num=0;for(var i=0;i<iovcnt;i++){var ptr=Number(HEAPU64[iov/8]);var len=Number(HEAPU64[(iov+8)/8]);iov+=16;for(var j=0;j<len;j++){printChar(fd,HEAPU8[ptr+j])}num+=len}HEAPU64[pnum/8]=BigInt(num);return 0}{if(Module["noExitRuntime"])noExitRuntime=Module["noExitRuntime"];if(Module["print"])out=Module["print"];if(Module["printErr"])err=Module["printErr"];if(Module["wasmBinary"])wasmBinary=Module["wasmBinary"];if(Module["arguments"])arguments_=Module["arguments"];if(Module["thisProgram"])thisProgram=Module["thisProgram"];if(Module["preInit"]){if(typeof Module["preInit"]=="function")Module["preInit"]=[Module["preInit"]];while(Module["preInit"].length>0){Module["preInit"].shift()()}}}var ___getTypeName,_malloc,_free,__emscripten_timeout,memory,__indirect_function_table,wasmMemory,wasmTable;function assignWasmExports(wasmExports){___getTypeName=wasmExports["G"];_malloc=wasmExports["I"];_free=wasmExports["J"];__emscripten_timeout=wasmExports["K"];memory=wasmMemory=wasmExports["E"];__indirect_function_table=wasmTable=wasmExports["H"]}var wasmImports={w:__abort_js,D:__embind_finalize_value_object,e:__embind_register_bigint,A:__embind_register_bool,y:__embind_register_emval,i:__embind_register_enum,c:__embind_register_enum_value,n:__embind_register_float,m:__embind_register_function,d:__embind_register_integer,b:__embind_register_memory_view,C:__embind_register_optional,z:__embind_register_std_string,f:__embind_register_std_wstring,p:__embind_register_value_object,a:__embind_register_value_object_field,B:__embind_register_void,r:__emscripten_runtime_keepalive_clear,l:__emval_create_invoker,g:__emval_decref,h:__emval_get_global,k:__emval_invoke,o:__emval_new_cstring,j:__emval_run_destructors,s:__setitimer_js,x:_emscripten_resize_heap,v:_fd_close,t:_fd_seek,u:_fd_write,q:_proc_exit};function applySignatureConversions(wasmExports){wasmExports=Object.assign({},wasmExports);var makeWrapper_pp=f=>a0=>Number(f(BigInt(a0)));var makeWrapper__p=f=>a0=>f(BigInt(a0));var makeWrapper_p=f=>()=>Number(f());wasmExports["G"]=makeWrapper_pp(wasmExports["G"]);wasmExports["I"]=makeWrapper_pp(wasmExports["I"]);wasmExports["J"]=makeWrapper__p(wasmExports["J"]);wasmExports["_emscripten_stack_restore"]=makeWrapper__p(wasmExports["_emscripten_stack_restore"]);wasmExports["_emscripten_stack_alloc"]=makeWrapper_pp(wasmExports["_emscripten_stack_alloc"]);wasmExports["emscripten_stack_get_current"]=makeWrapper_p(wasmExports["emscripten_stack_get_current"]);return wasmExports}function run(){preRun();function doRun(){Module["calledRun"]=true;if(ABORT)return;initRuntime();readyPromiseResolve?.(Module);Module["onRuntimeInitialized"]?.();postRun()}if(Module["setStatus"]){Module["setStatus"]("Running...");setTimeout(()=>{setTimeout(()=>Module["setStatus"](""),1);doRun()},1)}else{doRun()}}var wasmExports;wasmExports=await (createWasm());run();if(runtimeInitialized){moduleRtn=Module}else{moduleRtn=new Promise((resolve,reject)=>{readyPromiseResolve=resolve;readyPromiseReject=reject})}
|
|
2
2
|
;return moduleRtn}export default Module;
|
package/dist/webp-enc.wasm
CHANGED
|
Binary file
|
package/dist/wp2-dec.wasm
CHANGED
|
Binary file
|
package/dist/wp2-enc.wasm
CHANGED
|
Binary file
|
package/lib/jpeg.d.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { ImageDataLike, WasmSource } from "./common.js";
|
|
2
|
-
export declare enum ColorSpace {
|
|
2
|
+
export declare const enum ColorSpace {
|
|
3
3
|
GRAYSCALE = 1,
|
|
4
4
|
RGB = 2,
|
|
5
5
|
YCbCr = 3
|
|
6
6
|
}
|
|
7
|
-
export declare enum Quantization {
|
|
7
|
+
export declare const enum Quantization {
|
|
8
8
|
JPEG_Annex_K = 0,
|
|
9
9
|
Flat = 1,
|
|
10
10
|
MSSIM_Tuned_Kodak = 2,
|
package/lib/jxl.d.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { ImageDataLike, WasmSource } from "./common.js";
|
|
2
|
-
export declare enum Override {
|
|
2
|
+
export declare const enum Override {
|
|
3
3
|
Default = -1,
|
|
4
4
|
False = 0,
|
|
5
5
|
True = 1
|
|
6
6
|
}
|
|
7
|
-
export declare enum Predictor {
|
|
7
|
+
export declare const enum Predictor {
|
|
8
8
|
Default = -1,
|
|
9
9
|
Zero = 0,
|
|
10
10
|
Left = 1,
|
package/lib/webp.d.ts
CHANGED
|
@@ -1,14 +1,22 @@
|
|
|
1
1
|
import { ImageDataLike, WasmSource } from "./common.js";
|
|
2
|
-
export declare enum Preprocess {
|
|
2
|
+
export declare const enum Preprocess {
|
|
3
3
|
None = 0,
|
|
4
4
|
SegmentSmooth = 1,
|
|
5
5
|
Dithering = 2
|
|
6
6
|
}
|
|
7
|
-
export declare enum AlphaFiltering {
|
|
7
|
+
export declare const enum AlphaFiltering {
|
|
8
8
|
None = 0,
|
|
9
9
|
Fast = 1,
|
|
10
10
|
Best = 2
|
|
11
11
|
}
|
|
12
|
+
export declare const enum WebPPreset {
|
|
13
|
+
Default = 0,
|
|
14
|
+
Picture = 1,
|
|
15
|
+
Photo = 2,
|
|
16
|
+
Drawing = 3,
|
|
17
|
+
Icon = 4,
|
|
18
|
+
Text = 5
|
|
19
|
+
}
|
|
12
20
|
export interface Options {
|
|
13
21
|
/**
|
|
14
22
|
* Encode the image without any loss (pixel values of fully transparent area may different).
|
|
@@ -216,4 +224,5 @@ export declare const extension = "webp";
|
|
|
216
224
|
export declare function loadEncoder(input?: WasmSource): Promise<any>;
|
|
217
225
|
export declare function loadDecoder(input?: WasmSource): Promise<any>;
|
|
218
226
|
export declare function encode(image: ImageDataLike, options?: Options): Uint8Array<ArrayBufferLike>;
|
|
227
|
+
export declare function preset(config: Options, preset: WebPPreset): Options | null;
|
|
219
228
|
export declare function decode(input: BufferSource): ImageData;
|
package/lib/wp2.d.ts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { ImageDataLike, WasmSource } from "./common.js";
|
|
2
|
-
export declare enum UVMode {
|
|
2
|
+
export declare const enum UVMode {
|
|
3
3
|
UVAdapt = 0,
|
|
4
4
|
UV420 = 1,
|
|
5
5
|
UV444 = 2,
|
|
6
6
|
UVAuto = 3
|
|
7
7
|
}
|
|
8
|
-
export declare enum Csp {
|
|
8
|
+
export declare const enum Csp {
|
|
9
9
|
YCoCg = 0,
|
|
10
10
|
YCbCr = 1,
|
|
11
11
|
Custom = 2,
|
package/package.json
CHANGED
|
@@ -1,15 +1,22 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pbk20191/icodec",
|
|
3
|
-
"version": "0.6.
|
|
3
|
+
"version": "0.6.5",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "Image encoders & decoders built with WebAssembly",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"author": "pbk20191 <contact@pbk20191.com>",
|
|
8
8
|
"repository": {
|
|
9
9
|
"type": "git",
|
|
10
|
-
"url": "https://github.com/pbk20191/icodec"
|
|
10
|
+
"url": "git+https://github.com/pbk20191/icodec.git"
|
|
11
11
|
},
|
|
12
12
|
"type": "module",
|
|
13
|
+
"scripts": {
|
|
14
|
+
"wasm": "node scripts/build.js",
|
|
15
|
+
"types": "tsc --emitDeclarationOnly -p tsconfig.json",
|
|
16
|
+
"build": "npm run wasm && npm run types",
|
|
17
|
+
"test-convert": "tsx test/test-convert.js",
|
|
18
|
+
"demo": "node scripts/start-demo.js"
|
|
19
|
+
},
|
|
13
20
|
"keywords": [
|
|
14
21
|
"WebAssembly",
|
|
15
22
|
"wasm",
|
package/versions.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
[{"name":"mozjpeg","version":"v4.1.5","repository":"https://github.com/mozilla/mozjpeg","date":"2023-10-12"},{"name":"qoi","version":"6fff9b7","repository":"https://github.com/phoboslab/qoi","date":"2026-02-14"},{"name":"libwebp","version":"v1.5.0","repository":"https://github.com/webmproject/libwebp","date":"2024-
|
|
1
|
+
[{"name":"mozjpeg","version":"v4.1.5","repository":"https://github.com/mozilla/mozjpeg","date":"2023-10-12"},{"name":"qoi","version":"6fff9b7","repository":"https://github.com/phoboslab/qoi","date":"2026-02-14"},{"name":"libwebp","version":"v1.5.0","repository":"https://github.com/webmproject/libwebp","date":"2024-12-20"},{"name":"libjxl","version":"v0.11.2","repository":"https://github.com/libjxl/libjxl","date":"2026-02-09"},{"name":"libavif","version":"v1.3.0","repository":"https://github.com/AOMediaCodec/libavif","date":"2025-05-08"},{"name":"aom","version":"v3.13.1","repository":"https://aomedia.googlesource.com/aom","date":"2025-09-05"},{"name":"libwebp2","version":"b88188e","repository":"https://chromium.googlesource.com/codecs/libwebp2","date":"2025-12-01"},{"name":"x265","version":"e660273","repository":"https://bitbucket.org/multicoreware/x265_git","date":"2024-11-08"},{"name":"libde265","version":"v1.0.16","repository":"https://github.com/strukturag/libde265","date":"2025-05-03"},{"name":"libheif","version":"v1.21.2","repository":"https://github.com/strukturag/libheif","date":"2026-01-15"}]
|
package/lib/avif.js
DELETED
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
import wasmFactoryEnc from "../dist/avif-enc.js";
|
|
2
|
-
import wasmFactoryDec from "../dist/avif-dec.js";
|
|
3
|
-
import { check, encodeES, loadES } from "./common.js";
|
|
4
|
-
export var Subsampling;
|
|
5
|
-
(function (Subsampling) {
|
|
6
|
-
Subsampling[Subsampling["YUV444"] = 1] = "YUV444";
|
|
7
|
-
Subsampling[Subsampling["YUV422"] = 2] = "YUV422";
|
|
8
|
-
Subsampling[Subsampling["YUV420"] = 3] = "YUV420";
|
|
9
|
-
Subsampling[Subsampling["YUV400"] = 4] = "YUV400";
|
|
10
|
-
})(Subsampling || (Subsampling = {}));
|
|
11
|
-
export var AVIFTune;
|
|
12
|
-
(function (AVIFTune) {
|
|
13
|
-
AVIFTune[AVIFTune["Auto"] = 0] = "Auto";
|
|
14
|
-
AVIFTune[AVIFTune["PSNR"] = 1] = "PSNR";
|
|
15
|
-
AVIFTune[AVIFTune["SSIM"] = 2] = "SSIM";
|
|
16
|
-
})(AVIFTune || (AVIFTune = {}));
|
|
17
|
-
export const defaultOptions = {
|
|
18
|
-
quality: 50,
|
|
19
|
-
qualityAlpha: -1,
|
|
20
|
-
speed: 6,
|
|
21
|
-
subsample: Subsampling.YUV420,
|
|
22
|
-
autoTiling: false,
|
|
23
|
-
tileColsLog2: 0,
|
|
24
|
-
tileRowsLog2: 0,
|
|
25
|
-
chromaDeltaQ: false,
|
|
26
|
-
sharpness: 0,
|
|
27
|
-
denoiseLevel: 0,
|
|
28
|
-
tune: AVIFTune.Auto,
|
|
29
|
-
sharpYUV: false,
|
|
30
|
-
};
|
|
31
|
-
export const mimeType = "image/avif";
|
|
32
|
-
export const extension = "avif";
|
|
33
|
-
export const bitDepth = [8, 10, 12, 16];
|
|
34
|
-
let encoderWASM;
|
|
35
|
-
let decoderWASM;
|
|
36
|
-
export async function loadEncoder(input) {
|
|
37
|
-
return encoderWASM ??= await loadES(wasmFactoryEnc, input);
|
|
38
|
-
}
|
|
39
|
-
export async function loadDecoder(input) {
|
|
40
|
-
return decoderWASM ??= await loadES(wasmFactoryDec, input);
|
|
41
|
-
}
|
|
42
|
-
export function encode(image, options) {
|
|
43
|
-
return encodeES("AVIF Encode", encoderWASM, defaultOptions, image, options);
|
|
44
|
-
}
|
|
45
|
-
export function decode(input) {
|
|
46
|
-
return check(decoderWASM.decode(input), "AVIF Decode");
|
|
47
|
-
}
|
package/lib/common.js
DELETED
|
@@ -1,64 +0,0 @@
|
|
|
1
|
-
export function loadES(factory, source) {
|
|
2
|
-
return typeof source === "string"
|
|
3
|
-
? factory({ locateFile: () => source })
|
|
4
|
-
: factory({ wasmBinary: source });
|
|
5
|
-
}
|
|
6
|
-
export function toBitDepth(image, value) {
|
|
7
|
-
const { data, width, height, depth = 8 } = image;
|
|
8
|
-
if (value === depth) {
|
|
9
|
-
return image;
|
|
10
|
-
}
|
|
11
|
-
const pixels = width * height * 4;
|
|
12
|
-
const dist = value === 8
|
|
13
|
-
? new Uint8ClampedArray(pixels)
|
|
14
|
-
: new Uint16Array(pixels);
|
|
15
|
-
const view = depth === 8
|
|
16
|
-
? data
|
|
17
|
-
: new Uint16Array(data.buffer, data.byteOffset);
|
|
18
|
-
const from = (1 << depth) - 1;
|
|
19
|
-
const to = (1 << value) - 1;
|
|
20
|
-
for (let i = 0; i < pixels; i++) {
|
|
21
|
-
dist[i] = view[i] / from * to + 0.5;
|
|
22
|
-
}
|
|
23
|
-
const nd = new Uint8ClampedArray(dist.buffer, dist.byteOffset, dist.byteLength);
|
|
24
|
-
return _icodec_ImageData(nd, width, height, value);
|
|
25
|
-
}
|
|
26
|
-
/**
|
|
27
|
-
* Node does not have `ImageData` class, so we define a pure version.
|
|
28
|
-
*/
|
|
29
|
-
export class PureImageData {
|
|
30
|
-
data;
|
|
31
|
-
width;
|
|
32
|
-
height;
|
|
33
|
-
depth;
|
|
34
|
-
constructor(data, width, height, depth = 8) {
|
|
35
|
-
this.data = data;
|
|
36
|
-
this.width = width;
|
|
37
|
-
this.height = height;
|
|
38
|
-
this.depth = depth;
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
// @ts-expect-error
|
|
42
|
-
PureImageData.prototype.colorSpace = "srgb";
|
|
43
|
-
export function encodeES(name, wasm, defaults, image, options) {
|
|
44
|
-
options = { ...defaults, ...options };
|
|
45
|
-
const { data, width, height } = image;
|
|
46
|
-
options.bitDepth = image.depth ?? 8;
|
|
47
|
-
const result = wasm.encode(data, width, height, options);
|
|
48
|
-
if (result instanceof Error) {
|
|
49
|
-
throw result;
|
|
50
|
-
}
|
|
51
|
-
return check(result, name);
|
|
52
|
-
}
|
|
53
|
-
export function check(value, hint) {
|
|
54
|
-
if (typeof value === "string") {
|
|
55
|
-
throw new Error(`${hint}: ${value}`);
|
|
56
|
-
}
|
|
57
|
-
if (value instanceof Error) {
|
|
58
|
-
throw value;
|
|
59
|
-
}
|
|
60
|
-
if (value)
|
|
61
|
-
return value;
|
|
62
|
-
else
|
|
63
|
-
throw new Error(hint + " failed");
|
|
64
|
-
}
|
package/lib/heic.js
DELETED
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
import wasmFactoryEnc from "../dist/heic-enc.js";
|
|
2
|
-
import wasmFactoryDec from "../dist/heic-dec.js";
|
|
3
|
-
import { check, encodeES, loadES } from "./common.js";
|
|
4
|
-
export const Presets = ["ultrafast", "superfast", "veryfast", "faster", "fast", "medium", "slow", "slower", "veryslow", "placebo"];
|
|
5
|
-
export const Subsampling = ["420", "422", "444"];
|
|
6
|
-
export const Tune = ["psnr", "ssim", "grain", "fastdecode"];
|
|
7
|
-
export const defaultOptions = {
|
|
8
|
-
quality: 50,
|
|
9
|
-
lossless: false,
|
|
10
|
-
preset: "slow",
|
|
11
|
-
tune: "ssim",
|
|
12
|
-
tuIntraDepth: 2,
|
|
13
|
-
complexity: 50,
|
|
14
|
-
chroma: "420",
|
|
15
|
-
sharpYUV: false,
|
|
16
|
-
};
|
|
17
|
-
export const mimeType = "image/heic";
|
|
18
|
-
export const extension = "heic";
|
|
19
|
-
export const bitDepth = [8, 10, 12];
|
|
20
|
-
let encoderWASM;
|
|
21
|
-
let decoderWASM;
|
|
22
|
-
export async function loadEncoder(input) {
|
|
23
|
-
return encoderWASM ??= await loadES(wasmFactoryEnc, input);
|
|
24
|
-
}
|
|
25
|
-
export async function loadDecoder(input) {
|
|
26
|
-
return decoderWASM ??= await loadES(wasmFactoryDec, input);
|
|
27
|
-
}
|
|
28
|
-
export function encode(image, options) {
|
|
29
|
-
const new_encode = (...args) => {
|
|
30
|
-
const holder = {};
|
|
31
|
-
encoderWASM.encode(...args, holder);
|
|
32
|
-
if (holder.error) {
|
|
33
|
-
return holder.error;
|
|
34
|
-
}
|
|
35
|
-
if (holder.success) {
|
|
36
|
-
return holder.success;
|
|
37
|
-
}
|
|
38
|
-
};
|
|
39
|
-
return encodeES("HEIC Encode", { encode: new_encode }, defaultOptions, image, options);
|
|
40
|
-
}
|
|
41
|
-
export function decode(input) {
|
|
42
|
-
return check(decoderWASM.decode(input), "HEIC Decode");
|
|
43
|
-
}
|
package/lib/index.js
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import { PureImageData, toBitDepth } from "./common.js";
|
|
2
|
-
export { toBitDepth };
|
|
3
|
-
export * as avif from "./avif.js";
|
|
4
|
-
export * as png from "./png.js";
|
|
5
|
-
export * as jpeg from "./jpeg.js";
|
|
6
|
-
export * as jxl from "./jxl.js";
|
|
7
|
-
export * as webp from "./webp.js";
|
|
8
|
-
export * as heic from "./heic.js";
|
|
9
|
-
export * as qoi from "./qoi.js";
|
|
10
|
-
export * as wp2 from "./wp2.js";
|
|
11
|
-
globalThis._icodec_ImageData = (data, w, h, depth) => {
|
|
12
|
-
if (depth === 8) {
|
|
13
|
-
return new ImageDataEx(data, w, h);
|
|
14
|
-
}
|
|
15
|
-
return new PureImageData(data, w, h, depth);
|
|
16
|
-
};
|
|
17
|
-
class ImageDataEx extends ImageData {
|
|
18
|
-
depth = 8;
|
|
19
|
-
}
|
package/lib/jpeg.js
DELETED
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
import wasmFactoryEnc from "../dist/mozjpeg.js";
|
|
2
|
-
import { check, encodeES, loadES } from "./common.js";
|
|
3
|
-
export var ColorSpace;
|
|
4
|
-
(function (ColorSpace) {
|
|
5
|
-
ColorSpace[ColorSpace["GRAYSCALE"] = 1] = "GRAYSCALE";
|
|
6
|
-
ColorSpace[ColorSpace["RGB"] = 2] = "RGB";
|
|
7
|
-
ColorSpace[ColorSpace["YCbCr"] = 3] = "YCbCr";
|
|
8
|
-
})(ColorSpace || (ColorSpace = {}));
|
|
9
|
-
// https://github.com/mozilla/mozjpeg/blob/6c9f0897afa1c2738d7222a0a9ab49e8b536a267/jcparam.c#L74
|
|
10
|
-
export var Quantization;
|
|
11
|
-
(function (Quantization) {
|
|
12
|
-
Quantization[Quantization["JPEG_Annex_K"] = 0] = "JPEG_Annex_K";
|
|
13
|
-
Quantization[Quantization["Flat"] = 1] = "Flat";
|
|
14
|
-
Quantization[Quantization["MSSIM_Tuned_Kodak"] = 2] = "MSSIM_Tuned_Kodak";
|
|
15
|
-
Quantization[Quantization["ImageMagick"] = 3] = "ImageMagick";
|
|
16
|
-
Quantization[Quantization["PSNR_HVS_M_Tuned_Kodak"] = 4] = "PSNR_HVS_M_Tuned_Kodak";
|
|
17
|
-
Quantization[Quantization["Klein_Silverstein_Carney"] = 5] = "Klein_Silverstein_Carney";
|
|
18
|
-
Quantization[Quantization["Watson_Taylor_Borthwick"] = 6] = "Watson_Taylor_Borthwick";
|
|
19
|
-
Quantization[Quantization["Ahumada_Watson_Peterson"] = 7] = "Ahumada_Watson_Peterson";
|
|
20
|
-
Quantization[Quantization["Peterson_Ahumada_Watson"] = 8] = "Peterson_Ahumada_Watson";
|
|
21
|
-
})(Quantization || (Quantization = {}));
|
|
22
|
-
export const defaultOptions = {
|
|
23
|
-
quality: 75,
|
|
24
|
-
baseline: false,
|
|
25
|
-
arithmetic: false,
|
|
26
|
-
progressive: true,
|
|
27
|
-
optimizeCoding: true,
|
|
28
|
-
smoothing: 0,
|
|
29
|
-
colorSpace: ColorSpace.YCbCr,
|
|
30
|
-
quantTable: Quantization.ImageMagick,
|
|
31
|
-
trellisMultipass: false,
|
|
32
|
-
trellisOptZero: false,
|
|
33
|
-
trellisOptTable: false,
|
|
34
|
-
trellisLoops: 1,
|
|
35
|
-
autoSubsample: true,
|
|
36
|
-
chromaSubsample: 2,
|
|
37
|
-
separateChromaQuality: false,
|
|
38
|
-
chromaQuality: 75,
|
|
39
|
-
};
|
|
40
|
-
export const bitDepth = [8];
|
|
41
|
-
export const mimeType = "image/jpeg";
|
|
42
|
-
export const extension = "jpg";
|
|
43
|
-
let codecWASM;
|
|
44
|
-
export async function loadEncoder(input) {
|
|
45
|
-
return codecWASM = await loadES(wasmFactoryEnc, input);
|
|
46
|
-
}
|
|
47
|
-
export const loadDecoder = loadEncoder;
|
|
48
|
-
export function encode(image, options) {
|
|
49
|
-
return encodeES("JPEG Encode", codecWASM, defaultOptions, image, options);
|
|
50
|
-
}
|
|
51
|
-
export function decode(input) {
|
|
52
|
-
return check(codecWASM.decode(input), "JPEG Decode");
|
|
53
|
-
}
|
package/lib/jxl.js
DELETED
|
@@ -1,69 +0,0 @@
|
|
|
1
|
-
import wasmFactoryEnc from "../dist/jxl-enc.js";
|
|
2
|
-
import wasmFactoryDec from "../dist/jxl-dec.js";
|
|
3
|
-
import { check, encodeES, loadES } from "./common.js";
|
|
4
|
-
// Tristate bool value, `Default` means encoder chooses.
|
|
5
|
-
export var Override;
|
|
6
|
-
(function (Override) {
|
|
7
|
-
Override[Override["Default"] = -1] = "Default";
|
|
8
|
-
Override[Override["False"] = 0] = "False";
|
|
9
|
-
Override[Override["True"] = 1] = "True";
|
|
10
|
-
})(Override || (Override = {}));
|
|
11
|
-
export var Predictor;
|
|
12
|
-
(function (Predictor) {
|
|
13
|
-
Predictor[Predictor["Default"] = -1] = "Default";
|
|
14
|
-
Predictor[Predictor["Zero"] = 0] = "Zero";
|
|
15
|
-
Predictor[Predictor["Left"] = 1] = "Left";
|
|
16
|
-
Predictor[Predictor["Top"] = 2] = "Top";
|
|
17
|
-
Predictor[Predictor["Average0"] = 3] = "Average0";
|
|
18
|
-
Predictor[Predictor["Select"] = 4] = "Select";
|
|
19
|
-
Predictor[Predictor["Gradient"] = 5] = "Gradient";
|
|
20
|
-
Predictor[Predictor["Weighted"] = 6] = "Weighted";
|
|
21
|
-
Predictor[Predictor["TopRight"] = 7] = "TopRight";
|
|
22
|
-
Predictor[Predictor["TopLeft"] = 8] = "TopLeft";
|
|
23
|
-
Predictor[Predictor["LeftLeft"] = 9] = "LeftLeft";
|
|
24
|
-
Predictor[Predictor["Average1"] = 10] = "Average1";
|
|
25
|
-
Predictor[Predictor["Average2"] = 11] = "Average2";
|
|
26
|
-
Predictor[Predictor["Average3"] = 12] = "Average3";
|
|
27
|
-
Predictor[Predictor["Average4"] = 13] = "Average4";
|
|
28
|
-
// The following predictors are encoder-only.
|
|
29
|
-
Predictor[Predictor["Best"] = 14] = "Best";
|
|
30
|
-
Predictor[Predictor["Variable"] = 15] = "Variable";
|
|
31
|
-
})(Predictor || (Predictor = {}));
|
|
32
|
-
export const defaultOptions = {
|
|
33
|
-
lossless: false,
|
|
34
|
-
quality: 75,
|
|
35
|
-
alphaQuality: 100,
|
|
36
|
-
effort: 7,
|
|
37
|
-
brotliEffort: -1,
|
|
38
|
-
epf: -1,
|
|
39
|
-
gaborish: -1,
|
|
40
|
-
responsive: -1,
|
|
41
|
-
progressiveDC: -1,
|
|
42
|
-
progressiveAC: -1,
|
|
43
|
-
qProgressiveAC: -1,
|
|
44
|
-
decodingSpeed: 0,
|
|
45
|
-
photonNoiseIso: 0,
|
|
46
|
-
modular: false,
|
|
47
|
-
lossyPalette: false,
|
|
48
|
-
paletteColors: -1,
|
|
49
|
-
iterations: -1,
|
|
50
|
-
modularColorspace: -1,
|
|
51
|
-
modularPredictor: Predictor.Default,
|
|
52
|
-
};
|
|
53
|
-
export const mimeType = "image/jxl";
|
|
54
|
-
export const extension = "jxl";
|
|
55
|
-
export const bitDepth = [8, 9, 10, 11, 12, 13, 14, 15, 16];
|
|
56
|
-
let encoderWASM;
|
|
57
|
-
let decoderWASM;
|
|
58
|
-
export async function loadEncoder(input) {
|
|
59
|
-
return encoderWASM ??= await loadES(wasmFactoryEnc, input);
|
|
60
|
-
}
|
|
61
|
-
export async function loadDecoder(input) {
|
|
62
|
-
return decoderWASM ??= await loadES(wasmFactoryDec, input);
|
|
63
|
-
}
|
|
64
|
-
export function encode(image, options) {
|
|
65
|
-
return encodeES("JXL Encode", encoderWASM, defaultOptions, image, options);
|
|
66
|
-
}
|
|
67
|
-
export function decode(input) {
|
|
68
|
-
return check(decoderWASM.decode(input), "JXL Decode");
|
|
69
|
-
}
|
package/lib/png.js
DELETED
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
import wasmFactory, { optimize, png_to_rgba, quantize } from "../dist/pngquant.js";
|
|
2
|
-
import { toBitDepth } from "./common.js";
|
|
3
|
-
export const defaultOptions = {
|
|
4
|
-
speed: 4,
|
|
5
|
-
quality: 75,
|
|
6
|
-
colors: 256,
|
|
7
|
-
dithering: 1,
|
|
8
|
-
level: 3,
|
|
9
|
-
interlace: false,
|
|
10
|
-
quantize: true,
|
|
11
|
-
bit_depth: 8,
|
|
12
|
-
};
|
|
13
|
-
export const bitDepth = [8, 16];
|
|
14
|
-
export const mimeType = "image/png";
|
|
15
|
-
export const extension = "png";
|
|
16
|
-
export const loadEncoder = (module_or_path) => wasmFactory({ module_or_path });
|
|
17
|
-
export const loadDecoder = loadEncoder;
|
|
18
|
-
/**
|
|
19
|
-
* Reduces the colors used in the image at a slight loss, using a combination
|
|
20
|
-
* of vector quantization algorithms.
|
|
21
|
-
*
|
|
22
|
-
* Can be used before other compression algorithm to boost compression ratio.
|
|
23
|
-
*/
|
|
24
|
-
export function reduceColors(image, options) {
|
|
25
|
-
options = { ...defaultOptions, ...options };
|
|
26
|
-
const { data, width, height } = toBitDepth(image, 8);
|
|
27
|
-
return quantize(data, width, height, { ...defaultOptions, ...options });
|
|
28
|
-
}
|
|
29
|
-
export function encode(image, options) {
|
|
30
|
-
options = { ...defaultOptions, ...options };
|
|
31
|
-
if (options.quantize) {
|
|
32
|
-
image = toBitDepth(image, 8);
|
|
33
|
-
}
|
|
34
|
-
const { data, width, height, depth } = image;
|
|
35
|
-
options.bit_depth = depth;
|
|
36
|
-
return optimize(data, width, height, { ...defaultOptions, ...options });
|
|
37
|
-
}
|
|
38
|
-
export function decode(input) {
|
|
39
|
-
const [data, width, depth] = png_to_rgba(input);
|
|
40
|
-
let height = data.byteLength / width / 4;
|
|
41
|
-
if (depth === 16) {
|
|
42
|
-
height /= 2;
|
|
43
|
-
}
|
|
44
|
-
return _icodec_ImageData(data, width, height, depth);
|
|
45
|
-
}
|
package/lib/qoi.js
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import wasmFactory from "../dist/qoi.js";
|
|
2
|
-
import { check, loadES } from "./common.js";
|
|
3
|
-
export const defaultOptions = undefined;
|
|
4
|
-
export const bitDepth = [8];
|
|
5
|
-
export const mimeType = "image/qoi";
|
|
6
|
-
export const extension = "qoi";
|
|
7
|
-
let codecWASM;
|
|
8
|
-
export async function loadEncoder(input) {
|
|
9
|
-
return codecWASM = await loadES(wasmFactory, input);
|
|
10
|
-
}
|
|
11
|
-
export const loadDecoder = loadEncoder;
|
|
12
|
-
export function encode(image) {
|
|
13
|
-
const { data, width, height } = image;
|
|
14
|
-
const result = codecWASM.encode(data, width, height, undefined);
|
|
15
|
-
return check(result, "QOI Encode");
|
|
16
|
-
}
|
|
17
|
-
export function decode(input) {
|
|
18
|
-
return check(codecWASM.decode(input), "QOI Decode");
|
|
19
|
-
}
|
package/lib/webp.js
DELETED
|
@@ -1,62 +0,0 @@
|
|
|
1
|
-
import wasmFactoryEnc from "../dist/webp-enc.js";
|
|
2
|
-
import wasmFactoryDec from "../dist/webp-dec.js";
|
|
3
|
-
import { check, encodeES, loadES } from "./common.js";
|
|
4
|
-
export var Preprocess;
|
|
5
|
-
(function (Preprocess) {
|
|
6
|
-
Preprocess[Preprocess["None"] = 0] = "None";
|
|
7
|
-
Preprocess[Preprocess["SegmentSmooth"] = 1] = "SegmentSmooth";
|
|
8
|
-
Preprocess[Preprocess["Dithering"] = 2] = "Dithering";
|
|
9
|
-
})(Preprocess || (Preprocess = {}));
|
|
10
|
-
export var AlphaFiltering;
|
|
11
|
-
(function (AlphaFiltering) {
|
|
12
|
-
AlphaFiltering[AlphaFiltering["None"] = 0] = "None";
|
|
13
|
-
AlphaFiltering[AlphaFiltering["Fast"] = 1] = "Fast";
|
|
14
|
-
AlphaFiltering[AlphaFiltering["Best"] = 2] = "Best";
|
|
15
|
-
})(AlphaFiltering || (AlphaFiltering = {}));
|
|
16
|
-
export const defaultOptions = {
|
|
17
|
-
lossless: false,
|
|
18
|
-
nearLossless: 100,
|
|
19
|
-
quality: 75,
|
|
20
|
-
targetSize: 0,
|
|
21
|
-
targetPSNR: 0,
|
|
22
|
-
method: 4,
|
|
23
|
-
snsStrength: 50,
|
|
24
|
-
filterStrength: 60,
|
|
25
|
-
filterSharpness: 0,
|
|
26
|
-
filterType: true,
|
|
27
|
-
segments: 4,
|
|
28
|
-
pass: 1,
|
|
29
|
-
sharpYUV: false,
|
|
30
|
-
preprocessing: Preprocess.None,
|
|
31
|
-
autofilter: false,
|
|
32
|
-
partitionLimit: 0,
|
|
33
|
-
alphaCompression: 1,
|
|
34
|
-
alphaFiltering: AlphaFiltering.Fast,
|
|
35
|
-
alphaQuality: 100,
|
|
36
|
-
exact: false,
|
|
37
|
-
emulateJpegSize: false,
|
|
38
|
-
lowMemory: false,
|
|
39
|
-
// Undocumented options, only for compatibility.
|
|
40
|
-
partitions: 0,
|
|
41
|
-
showCompressed: 0,
|
|
42
|
-
imageHint: 0,
|
|
43
|
-
threadLevel: 0,
|
|
44
|
-
useDeltaPalette: 0,
|
|
45
|
-
};
|
|
46
|
-
export const bitDepth = [8];
|
|
47
|
-
export const mimeType = "image/webp";
|
|
48
|
-
export const extension = "webp";
|
|
49
|
-
let encoderWASM;
|
|
50
|
-
let decoderWASM;
|
|
51
|
-
export async function loadEncoder(input) {
|
|
52
|
-
return encoderWASM ??= await loadES(wasmFactoryEnc, input);
|
|
53
|
-
}
|
|
54
|
-
export async function loadDecoder(input) {
|
|
55
|
-
return decoderWASM ??= await loadES(wasmFactoryDec, input);
|
|
56
|
-
}
|
|
57
|
-
export function encode(image, options) {
|
|
58
|
-
return encodeES("Webp Encode", encoderWASM, defaultOptions, image, options);
|
|
59
|
-
}
|
|
60
|
-
export function decode(input) {
|
|
61
|
-
return check(decoderWASM.decode(input), "Webp Decode");
|
|
62
|
-
}
|
package/lib/wp2.js
DELETED
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
import { check, encodeES, loadES } from "./common.js";
|
|
2
|
-
import wasmFactoryEnc from "../dist/wp2-enc.js";
|
|
3
|
-
import wasmFactoryDec from "../dist/wp2-dec.js";
|
|
4
|
-
export var UVMode;
|
|
5
|
-
(function (UVMode) {
|
|
6
|
-
UVMode[UVMode["UVAdapt"] = 0] = "UVAdapt";
|
|
7
|
-
UVMode[UVMode["UV420"] = 1] = "UV420";
|
|
8
|
-
UVMode[UVMode["UV444"] = 2] = "UV444";
|
|
9
|
-
UVMode[UVMode["UVAuto"] = 3] = "UVAuto";
|
|
10
|
-
})(UVMode || (UVMode = {}));
|
|
11
|
-
export var Csp;
|
|
12
|
-
(function (Csp) {
|
|
13
|
-
Csp[Csp["YCoCg"] = 0] = "YCoCg";
|
|
14
|
-
Csp[Csp["YCbCr"] = 1] = "YCbCr";
|
|
15
|
-
Csp[Csp["Custom"] = 2] = "Custom";
|
|
16
|
-
Csp[Csp["YIQ"] = 3] = "YIQ";
|
|
17
|
-
})(Csp || (Csp = {}));
|
|
18
|
-
export const defaultOptions = {
|
|
19
|
-
quality: 75,
|
|
20
|
-
alphaQuality: 100,
|
|
21
|
-
effort: 5,
|
|
22
|
-
pass: 1,
|
|
23
|
-
sns: 50,
|
|
24
|
-
uvMode: UVMode.UVAuto,
|
|
25
|
-
cspType: Csp.YCoCg,
|
|
26
|
-
errorDiffusion: 0,
|
|
27
|
-
useRandomMatrix: false,
|
|
28
|
-
};
|
|
29
|
-
export const bitDepth = [8];
|
|
30
|
-
// WebP 2 will not be released as an image format, but wee need define these properties.
|
|
31
|
-
export const mimeType = "image/webp2";
|
|
32
|
-
export const extension = "wp2";
|
|
33
|
-
let encoderWASM;
|
|
34
|
-
let decoderWASM;
|
|
35
|
-
export async function loadEncoder(input) {
|
|
36
|
-
return encoderWASM ??= await loadES(wasmFactoryEnc, input);
|
|
37
|
-
}
|
|
38
|
-
export async function loadDecoder(input) {
|
|
39
|
-
return decoderWASM ??= await loadES(wasmFactoryDec, input);
|
|
40
|
-
}
|
|
41
|
-
export function encode(image, options) {
|
|
42
|
-
return encodeES("Webp2 Encode", encoderWASM, defaultOptions, image, options);
|
|
43
|
-
}
|
|
44
|
-
export function decode(input) {
|
|
45
|
-
return check(decoderWASM.decode(input), "Webp2 Decode");
|
|
46
|
-
}
|