taglib-wasm 0.2.4 → 0.2.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/README.md +3 -1
- package/build/taglib.js +5 -20
- package/build/taglib.wasm +0 -0
- package/package.json +1 -1
- package/src/taglib-embind.ts +231 -0
- package/src/taglib-jsr.ts +151 -1
- package/src/taglib.ts +150 -1
- package/src/types.ts +29 -0
- package/src/wasm-embind.ts +55 -0
- package/src/wasm-jsr.ts +155 -54
- package/src/wasm.ts +12 -0
package/README.md
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
`taglib-wasm` is designed to be **TagLib for JavaScript/TypeScript** platforms — specifically Deno, Node.js, Bun, web browsers, and Cloudflare Workers. It does this by leveraging technologies including [TagLib](https://taglib.org/) itself, [Emscripten](https://emscripten.org/), and [Wasm](https://webassembly.org/) ([WebAssembly](https://webassembly.org/)).
|
|
6
6
|
|
|
7
7
|
> [!NOTE]
|
|
8
|
-
> I
|
|
8
|
+
> I recently created this to support another project I’m creating, but it’s still very new. You’re likely to experience some surprises at this stage of `taglib-wasm`’s development, but I’m extremely moditivated to help address them.
|
|
9
9
|
|
|
10
10
|
## Why?
|
|
11
11
|
|
|
@@ -36,11 +36,13 @@ import { TagLib } from "jsr:@charleswiltgen/taglib-wasm";
|
|
|
36
36
|
```bash
|
|
37
37
|
npm install taglib-wasm
|
|
38
38
|
```
|
|
39
|
+
|
|
39
40
|
### Bun
|
|
40
41
|
|
|
41
42
|
```bash
|
|
42
43
|
bun add taglib-wasm
|
|
43
44
|
```
|
|
45
|
+
|
|
44
46
|
## 🚀 Quick Start
|
|
45
47
|
|
|
46
48
|
### Deno
|
package/build/taglib.js
CHANGED
|
@@ -1,25 +1,10 @@
|
|
|
1
|
-
var
|
|
1
|
+
var createTagLibModule = (() => {
|
|
2
2
|
var _scriptName = typeof document != 'undefined' ? document.currentScript?.src : undefined;
|
|
3
3
|
return (
|
|
4
4
|
async function(moduleArg = {}) {
|
|
5
5
|
var moduleRtn;
|
|
6
6
|
|
|
7
|
-
var c=moduleArg,aa="object"==typeof window,ba="undefined"!=typeof WorkerGlobalScope,m="object"==typeof process&&process.versions?.node&&"renderer"!=process.type;"undefined"!=typeof __filename&&(_scriptName=__filename);var p="",q,r;
|
|
8
|
-
if(m){var fs=require("fs");p=__dirname+"/";r=a=>{a=t(a)?new URL(a):a;return fs.readFileSync(a)};q=async a=>{a=t(a)?new URL(a):a;return fs.readFileSync(a,void 0)};process.argv.slice(2)}else if(aa||ba){try{p=(new URL(".",_scriptName)).href}catch{}q=async a=>{a=await fetch(a,{credentials:"same-origin"});if(a.ok)return a.arrayBuffer();throw Error(a.status+" : "+a.url);}}console.log.bind(console);var u=console.error.bind(console),v,w=!1,t=a=>a.startsWith("file://"),x,y,z,A,B,C,D,E,F,G,H,I=!1;
|
|
9
|
-
function J(){var a=z.buffer;A=new Int8Array(a);C=new Int16Array(a);B=new Uint8Array(a);new Uint16Array(a);D=new Int32Array(a);E=new Uint32Array(a);F=new Float32Array(a);G=new Float64Array(a);H=new BigInt64Array(a);new BigUint64Array(a)}var K=0,L=null;function M(a){c.onAbort?.(a);a="Aborted("+a+")";u(a);w=!0;a=new WebAssembly.RuntimeError(a+". Build with -sASSERTIONS for more info.");y?.(a);throw a;}var N;
|
|
10
|
-
async function ca(a){if(!v)try{var d=await q(a);return new Uint8Array(d)}catch{}if(a==N&&v)a=new Uint8Array(v);else if(r)a=r(a);else throw"both async and sync fetching of the wasm failed";return a}async function da(a,d){try{var b=await ca(a);return await WebAssembly.instantiate(b,d)}catch(e){u(`failed to asynchronously prepare wasm: ${e}`),M(e)}}
|
|
11
|
-
async function ea(a){var d=N;if(!v&&"function"==typeof WebAssembly.instantiateStreaming&&!m)try{var b=fetch(d,{credentials:"same-origin"});return await WebAssembly.instantiateStreaming(b,a)}catch(e){u(`wasm streaming compile failed: ${e}`),u("falling back to ArrayBuffer instantiation")}return da(d,a)}var O=a=>{for(;0<a.length;)a.shift()(c)},P=[],Q=[],fa=()=>{var a=c.preRun.shift();Q.push(a)};class ha{constructor(a){this.J=a-24}}
|
|
12
|
-
var R=0,ia=0,S=a=>{for(var d=0,b=0;b<a.length;++b){var e=a.charCodeAt(b);127>=e?d++:2047>=e?d+=2:55296<=e&&57343>=e?(d+=4,++b):d+=3}return d},T=(a,d,b,e)=>{if(!(0<e))return 0;var f=b;e=b+e-1;for(var h=0;h<a.length;++h){var g=a.codePointAt(h);if(127>=g){if(b>=e)break;d[b++]=g}else if(2047>=g){if(b+1>=e)break;d[b++]=192|g>>6;d[b++]=128|g&63}else if(65535>=g){if(b+2>=e)break;d[b++]=224|g>>12;d[b++]=128|g>>6&63;d[b++]=128|g&63}else{if(b+3>=e)break;d[b++]=240|g>>18;d[b++]=128|g>>12&63;d[b++]=128|g>>6&
|
|
13
|
-
63;d[b++]=128|g&63;h++}}d[b]=0;return b-f},U="undefined"!=typeof TextDecoder?new TextDecoder:void 0,ja=(a=0)=>{for(var d=B,b=a+NaN,e=a;d[e]&&!(e>=b);)++e;if(16<e-a&&d.buffer&&U)return U.decode(d.subarray(a,e));for(b="";a<e;){var f=d[a++];if(f&128){var h=d[a++]&63;if(192==(f&224))b+=String.fromCharCode((f&31)<<6|h);else{var g=d[a++]&63;f=224==(f&240)?(f&15)<<12|h<<6|g:(f&7)<<18|h<<12|g<<6|d[a++]&63;65536>f?b+=String.fromCharCode(f):(f-=65536,b+=String.fromCharCode(55296|f>>10,56320|f&1023))}}else b+=
|
|
14
|
-
String.fromCharCode(f)}return b},ma=(a,d,b,e)=>{var f={string:k=>{var l=0;if(null!==k&&void 0!==k&&0!==k){l=S(k)+1;var Y=V(l);T(k,B,Y,l);l=Y}return l},array:k=>{var l=V(k.length);A.set(k,l);return l}};a=c["_"+a];var h=[],g=0;if(e)for(var n=0;n<e.length;n++){var Z=f[b[n]];Z?(0===g&&(g=ka()),h[n]=Z(e[n])):h[n]=e[n]}b=a(...h);return b=function(k){0!==g&&la(g);return"string"===d?k?ja(k):"":"boolean"===d?!!k:k}(b)};c.printErr&&(u=c.printErr);c.wasmBinary&&(v=c.wasmBinary);c.ccall=ma;
|
|
15
|
-
c.cwrap=(a,d,b,e)=>{var f=!b||b.every(h=>"number"===h||"boolean"===h);return"string"!==d&&f&&!e?c["_"+a]:(...h)=>ma(a,d,b,h,e)};c.setValue=function(a,d,b="i8"){b.endsWith("*")&&(b="*");switch(b){case "i1":A[a]=d;break;case "i8":A[a]=d;break;case "i16":C[a>>1]=d;break;case "i32":D[a>>2]=d;break;case "i64":H[a>>3]=BigInt(d);break;case "float":F[a>>2]=d;break;case "double":G[a>>3]=d;break;case "*":E[a>>2]=d;break;default:M(`invalid type for setValue: ${b}`)}};
|
|
16
|
-
c.getValue=function(a,d="i8"){d.endsWith("*")&&(d="*");switch(d){case "i1":return A[a];case "i8":return A[a];case "i16":return C[a>>1];case "i32":return D[a>>2];case "i64":return H[a>>3];case "float":return F[a>>2];case "double":return G[a>>3];case "*":return E[a>>2];default:M(`invalid type for getValue: ${d}`)}};c.intArrayFromString=(a,d,b)=>{b=Array(0<b?b:S(a)+1);a=T(a,b,0,b.length);d&&(b.length=a);return b};c.ALLOC_NORMAL=0;
|
|
17
|
-
c.allocate=(a,d)=>{d=1==d?V(a.length):na(a.length);a.subarray||a.slice||(a=new Uint8Array(a));B.set(a,d);return d};
|
|
18
|
-
var na,la,V,ka,oa={a:(a,d,b)=>{var e=new ha(a);E[e.J+16>>2]=0;E[e.J+4>>2]=d;E[e.J+8>>2]=b;R=a;ia++;throw R;},b:()=>M(""),c:a=>{var d=B.length;a>>>=0;if(268435456<a)return!1;for(var b=1;4>=b;b*=2){var e=d*(1+.2/b);e=Math.min(e,a+100663296);a:{e=(Math.min(268435456,65536*Math.ceil(Math.max(a,e)/65536))-z.buffer.byteLength+65535)/65536|0;try{z.grow(e);J();var f=1;break a}catch(h){}f=void 0}if(f)return!0}return!1}},W=await (async function(){function a(b){W=b.exports;z=W.d;J();b=W;c._taglib_file_new_from_buffer=
|
|
19
|
-
b.f;c._taglib_file_delete=b.g;c._taglib_file_save=b.h;c._taglib_file_is_valid=b.i;c._taglib_file_format=b.j;c._taglib_file_tag=b.k;c._taglib_tag_title=b.l;c._taglib_tag_artist=b.m;c._taglib_tag_album=b.n;c._taglib_tag_comment=b.o;c._taglib_tag_genre=b.p;c._taglib_tag_year=b.q;c._taglib_tag_track=b.r;c._taglib_tag_set_title=b.s;c._taglib_tag_set_artist=b.t;c._taglib_tag_set_album=b.u;c._taglib_tag_set_comment=b.v;c._taglib_tag_set_genre=b.w;c._taglib_tag_set_year=b.x;c._taglib_tag_set_track=b.y;c._taglib_file_audioproperties=
|
|
20
|
-
b.z;c._taglib_audioproperties_length=b.A;c._taglib_audioproperties_bitrate=b.B;c._taglib_audioproperties_samplerate=b.C;c._taglib_audioproperties_channels=b.D;c._malloc=na=b.E;c._free=b.F;la=b.G;V=b.H;ka=b.I;K--;c.monitorRunDependencies?.(K);0==K&&L&&(b=L,L=null,b());return W}K++;c.monitorRunDependencies?.(K);var d={a:oa};if(c.instantiateWasm)return new Promise(b=>{c.instantiateWasm(d,(e,f)=>{b(a(e,f))})});N??=c.locateFile?c.locateFile("taglib.wasm",p):p+"taglib.wasm";return a((await ea(d)).instance)}());
|
|
21
|
-
function X(){function a(){c.calledRun=!0;if(!w){I=!0;W.e();x?.(c);c.onRuntimeInitialized?.();if(c.postRun)for("function"==typeof c.postRun&&(c.postRun=[c.postRun]);c.postRun.length;){var d=c.postRun.shift();P.push(d)}O(P)}}if(0<K)L=X;else{if(c.preRun)for("function"==typeof c.preRun&&(c.preRun=[c.preRun]);c.preRun.length;)fa();O(Q);0<K?L=X:c.setStatus?(c.setStatus("Running..."),setTimeout(()=>{setTimeout(()=>c.setStatus(""),1);a()},1)):a()}}
|
|
22
|
-
if(c.preInit)for("function"==typeof c.preInit&&(c.preInit=[c.preInit]);0<c.preInit.length;)c.preInit.shift()();X();I?moduleRtn=c:moduleRtn=new Promise((a,d)=>{x=a;y=d});
|
|
7
|
+
var Module=moduleArg;var ENVIRONMENT_IS_WEB=typeof window=="object";var ENVIRONMENT_IS_WORKER=typeof WorkerGlobalScope!="undefined";var ENVIRONMENT_IS_NODE=typeof process=="object"&&process.versions?.node&&process.type!="renderer";var arguments_=[];var thisProgram="./this.program";var quit_=(status,toThrow)=>{throw toThrow};if(typeof __filename!="undefined"){_scriptName=__filename}else if(ENVIRONMENT_IS_WORKER){_scriptName=self.location.href}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("fs");scriptDirectory=__dirname+"/";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=>{if(isFileURI(url)){return new Promise((resolve,reject)=>{var xhr=new XMLHttpRequest;xhr.open("GET",url,true);xhr.responseType="arraybuffer";xhr.onload=()=>{if(xhr.status==200||xhr.status==0&&xhr.response){resolve(xhr.response);return}reject(xhr.status)};xhr.onerror=reject;xhr.send(null)})}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 isFileURI=filename=>filename.startsWith("file://");var readyPromiseResolve,readyPromiseReject;var wasmMemory;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["pa"]()}function postRun(){if(Module["postRun"]){if(typeof Module["postRun"]=="function")Module["postRun"]=[Module["postRun"]];while(Module["postRun"].length){addOnPostRun(Module["postRun"].shift())}}callRuntimeCallbacks(onPostRuns)}var runDependencies=0;var dependenciesFulfilled=null;function addRunDependency(id){runDependencies++;Module["monitorRunDependencies"]?.(runDependencies)}function removeRunDependency(id){runDependencies--;Module["monitorRunDependencies"]?.(runDependencies);if(runDependencies==0){if(dependenciesFulfilled){var callback=dependenciesFulfilled;dependenciesFulfilled=null;callback()}}}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(){return locateFile("taglib.wasm")}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&&typeof WebAssembly.instantiateStreaming=="function"&&!isFileURI(binaryFile)&&!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(){return{a:wasmImports}}async function createWasm(){function receiveInstance(instance,module){wasmExports=instance.exports;wasmMemory=wasmExports["oa"];updateMemoryViews();wasmTable=wasmExports["qa"];assignWasmExports(wasmExports);removeRunDependency("wasm-instantiate");return wasmExports}addRunDependency("wasm-instantiate");function receiveInstantiationResult(result){return receiveInstance(result["instance"])}var info=getWasmImports();if(Module["instantiateWasm"]){return new Promise((resolve,reject)=>{Module["instantiateWasm"](info,(mod,inst)=>{resolve(receiveInstance(mod,inst))})})}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);function getValue(ptr,type="i8"){if(type.endsWith("*"))type="*";switch(type){case"i1":return HEAP8[ptr];case"i8":return HEAP8[ptr];case"i16":return HEAP16[ptr>>1];case"i32":return HEAP32[ptr>>2];case"i64":return HEAP64[ptr>>3];case"float":return HEAPF32[ptr>>2];case"double":return HEAPF64[ptr>>3];case"*":return HEAPU32[ptr>>2];default:abort(`invalid type for getValue: ${type}`)}}var noExitRuntime=true;function setValue(ptr,value,type="i8"){if(type.endsWith("*"))type="*";switch(type){case"i1":HEAP8[ptr]=value;break;case"i8":HEAP8[ptr]=value;break;case"i16":HEAP16[ptr>>1]=value;break;case"i32":HEAP32[ptr>>2]=value;break;case"i64":HEAP64[ptr>>3]=BigInt(value);break;case"float":HEAPF32[ptr>>2]=value;break;case"double":HEAPF64[ptr>>3]=value;break;case"*":HEAPU32[ptr>>2]=value;break;default:abort(`invalid type for setValue: ${type}`)}}var stackRestore=val=>__emscripten_stack_restore(val);var stackSave=()=>_emscripten_stack_get_current();var exceptionCaught=[];var uncaughtExceptionCount=0;var ___cxa_begin_catch=ptr=>{var info=new ExceptionInfo(ptr);if(!info.get_caught()){info.set_caught(true);uncaughtExceptionCount--}info.set_rethrown(false);exceptionCaught.push(info);___cxa_increment_exception_refcount(ptr);return ___cxa_get_exception_ptr(ptr)};var exceptionLast=0;var ___cxa_end_catch=()=>{_setThrew(0,0);var info=exceptionCaught.pop();___cxa_decrement_exception_refcount(info.excPtr);exceptionLast=0};class ExceptionInfo{constructor(excPtr){this.excPtr=excPtr;this.ptr=excPtr-24}set_type(type){HEAPU32[this.ptr+4>>2]=type}get_type(){return HEAPU32[this.ptr+4>>2]}set_destructor(destructor){HEAPU32[this.ptr+8>>2]=destructor}get_destructor(){return HEAPU32[this.ptr+8>>2]}set_caught(caught){caught=caught?1:0;HEAP8[this.ptr+12]=caught}get_caught(){return HEAP8[this.ptr+12]!=0}set_rethrown(rethrown){rethrown=rethrown?1:0;HEAP8[this.ptr+13]=rethrown}get_rethrown(){return HEAP8[this.ptr+13]!=0}init(type,destructor){this.set_adjusted_ptr(0);this.set_type(type);this.set_destructor(destructor)}set_adjusted_ptr(adjustedPtr){HEAPU32[this.ptr+16>>2]=adjustedPtr}get_adjusted_ptr(){return HEAPU32[this.ptr+16>>2]}}var setTempRet0=val=>__emscripten_tempret_set(val);var findMatchingCatch=args=>{var thrown=exceptionLast;if(!thrown){setTempRet0(0);return 0}var info=new ExceptionInfo(thrown);info.set_adjusted_ptr(thrown);var thrownType=info.get_type();if(!thrownType){setTempRet0(0);return thrown}for(var caughtType of args){if(caughtType===0||caughtType===thrownType){break}var adjusted_ptr_addr=info.ptr+16;if(___cxa_can_catch(caughtType,thrownType,adjusted_ptr_addr)){setTempRet0(caughtType);return thrown}}setTempRet0(thrownType);return thrown};var ___cxa_find_matching_catch_2=()=>findMatchingCatch([]);var ___cxa_find_matching_catch_3=arg0=>findMatchingCatch([arg0]);var ___cxa_rethrow=()=>{var info=exceptionCaught.pop();if(!info){abort("no exception to throw")}var ptr=info.excPtr;if(!info.get_rethrown()){exceptionCaught.push(info);info.set_rethrown(true);info.set_caught(false);uncaughtExceptionCount++}exceptionLast=ptr;throw exceptionLast};var ___cxa_throw=(ptr,type,destructor)=>{var info=new ExceptionInfo(ptr);info.init(type,destructor);exceptionLast=ptr;uncaughtExceptionCount++;throw exceptionLast};var ___resumeException=ptr=>{if(!exceptionLast){exceptionLast=ptr}throw exceptionLast};var __abort_js=()=>abort("");var AsciiToString=ptr=>{var str="";while(1){var ch=HEAPU8[ptr++];if(!ch)return str;str+=String.fromCharCode(ch)}};var awaitingDependencies={};var registeredTypes={};var typeDependencies={};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>>1]:pointer=>HEAPU16[pointer>>1];case 4:return signed?pointer=>HEAP32[pointer>>2]:pointer=>HEAPU32[pointer>>2];case 8:return signed?pointer=>HEAP64[pointer>>3]:pointer=>HEAPU64[pointer>>3];default:throw new TypeError(`invalid integer width (${width}): ${name}`)}};var __embind_register_bigint=(primitiveType,name,size,minRange,maxRange)=>{name=AsciiToString(name);const isUnsignedType=minRange===0n;let fromWireType=value=>value;if(isUnsignedType){const bitSize=size*8;fromWireType=value=>BigInt.asUintN(bitSize,value);maxRange=fromWireType(maxRange)}registerType(primitiveType,{name,fromWireType,toWireType:(destructors,value)=>{if(typeof value=="number"){value=BigInt(value)}return value},argPackAdvance:GenericWireTypeSize,readValueFromPointer:integerReadValueFromPointer(name,size,!isUnsignedType),destructorFunction:null})};var GenericWireTypeSize=8;var __embind_register_bool=(rawType,name,trueValue,falseValue)=>{name=AsciiToString(name);registerType(rawType,{name,fromWireType:function(wt){return!!wt},toWireType:function(destructors,o){return o?trueValue:falseValue},argPackAdvance:GenericWireTypeSize,readValueFromPointer:function(pointer){return this["fromWireType"](HEAPU8[pointer])},destructorFunction:null})};var shallowCopyInternalPointer=o=>({count:o.count,deleteScheduled:o.deleteScheduled,preservePointerOnDelete:o.preservePointerOnDelete,ptr:o.ptr,ptrType:o.ptrType,smartPtr:o.smartPtr,smartPtrType:o.smartPtrType});var throwInstanceAlreadyDeleted=obj=>{function getInstanceTypeName(handle){return handle.$$.ptrType.registeredClass.name}throwBindingError(getInstanceTypeName(obj)+" instance already deleted")};var finalizationRegistry=false;var detachFinalizer=handle=>{};var runDestructor=$$=>{if($$.smartPtr){$$.smartPtrType.rawDestructor($$.smartPtr)}else{$$.ptrType.registeredClass.rawDestructor($$.ptr)}};var releaseClassHandle=$$=>{$$.count.value-=1;var toDelete=0===$$.count.value;if(toDelete){runDestructor($$)}};var attachFinalizer=handle=>{if("undefined"===typeof FinalizationRegistry){attachFinalizer=handle=>handle;return handle}finalizationRegistry=new FinalizationRegistry(info=>{releaseClassHandle(info.$$)});attachFinalizer=handle=>{var $$=handle.$$;var hasSmartPtr=!!$$.smartPtr;if(hasSmartPtr){var info={$$};finalizationRegistry.register(handle,info,handle)}return handle};detachFinalizer=handle=>finalizationRegistry.unregister(handle);return attachFinalizer(handle)};var deletionQueue=[];var flushPendingDeletes=()=>{while(deletionQueue.length){var obj=deletionQueue.pop();obj.$$.deleteScheduled=false;obj["delete"]()}};var delayFunction;var init_ClassHandle=()=>{let proto=ClassHandle.prototype;Object.assign(proto,{isAliasOf(other){if(!(this instanceof ClassHandle)){return false}if(!(other instanceof ClassHandle)){return false}var leftClass=this.$$.ptrType.registeredClass;var left=this.$$.ptr;other.$$=other.$$;var rightClass=other.$$.ptrType.registeredClass;var right=other.$$.ptr;while(leftClass.baseClass){left=leftClass.upcast(left);leftClass=leftClass.baseClass}while(rightClass.baseClass){right=rightClass.upcast(right);rightClass=rightClass.baseClass}return leftClass===rightClass&&left===right},clone(){if(!this.$$.ptr){throwInstanceAlreadyDeleted(this)}if(this.$$.preservePointerOnDelete){this.$$.count.value+=1;return this}else{var clone=attachFinalizer(Object.create(Object.getPrototypeOf(this),{$$:{value:shallowCopyInternalPointer(this.$$)}}));clone.$$.count.value+=1;clone.$$.deleteScheduled=false;return clone}},delete(){if(!this.$$.ptr){throwInstanceAlreadyDeleted(this)}if(this.$$.deleteScheduled&&!this.$$.preservePointerOnDelete){throwBindingError("Object already scheduled for deletion")}detachFinalizer(this);releaseClassHandle(this.$$);if(!this.$$.preservePointerOnDelete){this.$$.smartPtr=undefined;this.$$.ptr=undefined}},isDeleted(){return!this.$$.ptr},deleteLater(){if(!this.$$.ptr){throwInstanceAlreadyDeleted(this)}if(this.$$.deleteScheduled&&!this.$$.preservePointerOnDelete){throwBindingError("Object already scheduled for deletion")}deletionQueue.push(this);if(deletionQueue.length===1&&delayFunction){delayFunction(flushPendingDeletes)}this.$$.deleteScheduled=true;return this}});const symbolDispose=Symbol.dispose;if(symbolDispose){proto[symbolDispose]=proto["delete"]}};function ClassHandle(){}var createNamedFunction=(name,func)=>Object.defineProperty(func,"name",{value:name});var registeredPointers={};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 char_0=48;var char_9=57;var makeLegalFunctionName=name=>{name=name.replace(/[^a-zA-Z0-9_]/g,"$");var f=name.charCodeAt(0);if(f>=char_0&&f<=char_9){return`_${name}`}return name};function RegisteredClass(name,constructor,instancePrototype,rawDestructor,baseClass,getActualType,upcast,downcast){this.name=name;this.constructor=constructor;this.instancePrototype=instancePrototype;this.rawDestructor=rawDestructor;this.baseClass=baseClass;this.getActualType=getActualType;this.upcast=upcast;this.downcast=downcast;this.pureVirtualFunctions=[]}var upcastPointer=(ptr,ptrClass,desiredClass)=>{while(ptrClass!==desiredClass){if(!ptrClass.upcast){throwBindingError(`Expected null or instance of ${desiredClass.name}, got an instance of ${ptrClass.name}`)}ptr=ptrClass.upcast(ptr);ptrClass=ptrClass.baseClass}return ptr};var embindRepr=v=>{if(v===null){return"null"}var t=typeof v;if(t==="object"||t==="array"||t==="function"){return v.toString()}else{return""+v}};function constNoSmartPtrRawPointerToWireType(destructors,handle){if(handle===null){if(this.isReference){throwBindingError(`null is not a valid ${this.name}`)}return 0}if(!handle.$$){throwBindingError(`Cannot pass "${embindRepr(handle)}" as a ${this.name}`)}if(!handle.$$.ptr){throwBindingError(`Cannot pass deleted object as a pointer of type ${this.name}`)}var handleClass=handle.$$.ptrType.registeredClass;var ptr=upcastPointer(handle.$$.ptr,handleClass,this.registeredClass);return ptr}function genericPointerToWireType(destructors,handle){var ptr;if(handle===null){if(this.isReference){throwBindingError(`null is not a valid ${this.name}`)}if(this.isSmartPointer){ptr=this.rawConstructor();if(destructors!==null){destructors.push(this.rawDestructor,ptr)}return ptr}else{return 0}}if(!handle||!handle.$$){throwBindingError(`Cannot pass "${embindRepr(handle)}" as a ${this.name}`)}if(!handle.$$.ptr){throwBindingError(`Cannot pass deleted object as a pointer of type ${this.name}`)}if(!this.isConst&&handle.$$.ptrType.isConst){throwBindingError(`Cannot convert argument of type ${handle.$$.smartPtrType?handle.$$.smartPtrType.name:handle.$$.ptrType.name} to parameter type ${this.name}`)}var handleClass=handle.$$.ptrType.registeredClass;ptr=upcastPointer(handle.$$.ptr,handleClass,this.registeredClass);if(this.isSmartPointer){if(undefined===handle.$$.smartPtr){throwBindingError("Passing raw pointer to smart pointer is illegal")}switch(this.sharingPolicy){case 0:if(handle.$$.smartPtrType===this){ptr=handle.$$.smartPtr}else{throwBindingError(`Cannot convert argument of type ${handle.$$.smartPtrType?handle.$$.smartPtrType.name:handle.$$.ptrType.name} to parameter type ${this.name}`)}break;case 1:ptr=handle.$$.smartPtr;break;case 2:if(handle.$$.smartPtrType===this){ptr=handle.$$.smartPtr}else{var clonedHandle=handle["clone"]();ptr=this.rawShare(ptr,Emval.toHandle(()=>clonedHandle["delete"]()));if(destructors!==null){destructors.push(this.rawDestructor,ptr)}}break;default:throwBindingError("Unsupporting sharing policy")}}return ptr}function nonConstNoSmartPtrRawPointerToWireType(destructors,handle){if(handle===null){if(this.isReference){throwBindingError(`null is not a valid ${this.name}`)}return 0}if(!handle.$$){throwBindingError(`Cannot pass "${embindRepr(handle)}" as a ${this.name}`)}if(!handle.$$.ptr){throwBindingError(`Cannot pass deleted object as a pointer of type ${this.name}`)}if(handle.$$.ptrType.isConst){throwBindingError(`Cannot convert argument of type ${handle.$$.ptrType.name} to parameter type ${this.name}`)}var handleClass=handle.$$.ptrType.registeredClass;var ptr=upcastPointer(handle.$$.ptr,handleClass,this.registeredClass);return ptr}function readPointer(pointer){return this["fromWireType"](HEAPU32[pointer>>2])}var downcastPointer=(ptr,ptrClass,desiredClass)=>{if(ptrClass===desiredClass){return ptr}if(undefined===desiredClass.baseClass){return null}var rv=downcastPointer(ptr,ptrClass,desiredClass.baseClass);if(rv===null){return null}return desiredClass.downcast(rv)};var registeredInstances={};var getBasestPointer=(class_,ptr)=>{if(ptr===undefined){throwBindingError("ptr should not be undefined")}while(class_.baseClass){ptr=class_.upcast(ptr);class_=class_.baseClass}return ptr};var getInheritedInstance=(class_,ptr)=>{ptr=getBasestPointer(class_,ptr);return registeredInstances[ptr]};var InternalError=class InternalError extends Error{constructor(message){super(message);this.name="InternalError"}};var throwInternalError=message=>{throw new InternalError(message)};var makeClassHandle=(prototype,record)=>{if(!record.ptrType||!record.ptr){throwInternalError("makeClassHandle requires ptr and ptrType")}var hasSmartPtrType=!!record.smartPtrType;var hasSmartPtr=!!record.smartPtr;if(hasSmartPtrType!==hasSmartPtr){throwInternalError("Both smartPtrType and smartPtr must be specified")}record.count={value:1};return attachFinalizer(Object.create(prototype,{$$:{value:record,writable:true}}))};function RegisteredPointer_fromWireType(ptr){var rawPointer=this.getPointee(ptr);if(!rawPointer){this.destructor(ptr);return null}var registeredInstance=getInheritedInstance(this.registeredClass,rawPointer);if(undefined!==registeredInstance){if(0===registeredInstance.$$.count.value){registeredInstance.$$.ptr=rawPointer;registeredInstance.$$.smartPtr=ptr;return registeredInstance["clone"]()}else{var rv=registeredInstance["clone"]();this.destructor(ptr);return rv}}function makeDefaultHandle(){if(this.isSmartPointer){return makeClassHandle(this.registeredClass.instancePrototype,{ptrType:this.pointeeType,ptr:rawPointer,smartPtrType:this,smartPtr:ptr})}else{return makeClassHandle(this.registeredClass.instancePrototype,{ptrType:this,ptr})}}var actualType=this.registeredClass.getActualType(rawPointer);var registeredPointerRecord=registeredPointers[actualType];if(!registeredPointerRecord){return makeDefaultHandle.call(this)}var toType;if(this.isConst){toType=registeredPointerRecord.constPointerType}else{toType=registeredPointerRecord.pointerType}var dp=downcastPointer(rawPointer,this.registeredClass,toType.registeredClass);if(dp===null){return makeDefaultHandle.call(this)}if(this.isSmartPointer){return makeClassHandle(toType.registeredClass.instancePrototype,{ptrType:toType,ptr:dp,smartPtrType:this,smartPtr:ptr})}else{return makeClassHandle(toType.registeredClass.instancePrototype,{ptrType:toType,ptr:dp})}}var init_RegisteredPointer=()=>{Object.assign(RegisteredPointer.prototype,{getPointee(ptr){if(this.rawGetPointee){ptr=this.rawGetPointee(ptr)}return ptr},destructor(ptr){this.rawDestructor?.(ptr)},argPackAdvance:GenericWireTypeSize,readValueFromPointer:readPointer,fromWireType:RegisteredPointer_fromWireType})};function RegisteredPointer(name,registeredClass,isReference,isConst,isSmartPointer,pointeeType,sharingPolicy,rawGetPointee,rawConstructor,rawShare,rawDestructor){this.name=name;this.registeredClass=registeredClass;this.isReference=isReference;this.isConst=isConst;this.isSmartPointer=isSmartPointer;this.pointeeType=pointeeType;this.sharingPolicy=sharingPolicy;this.rawGetPointee=rawGetPointee;this.rawConstructor=rawConstructor;this.rawShare=rawShare;this.rawDestructor=rawDestructor;if(!isSmartPointer&®isteredClass.baseClass===undefined){if(isConst){this["toWireType"]=constNoSmartPtrRawPointerToWireType;this.destructorFunction=null}else{this["toWireType"]=nonConstNoSmartPtrRawPointerToWireType;this.destructorFunction=null}}else{this["toWireType"]=genericPointerToWireType}}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 wasmTable;var getWasmTableEntry=funcPtr=>{var func=wasmTableMirror[funcPtr];if(!func){wasmTableMirror[funcPtr]=func=wasmTable.get(funcPtr)}return func};var embind__requireFunction=(signature,rawFunction,isAsync=false)=>{signature=AsciiToString(signature);function makeDynCaller(){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 getTypeName=type=>{var ptr=___getTypeName(type);var rv=AsciiToString(ptr);_free(ptr);return rv};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 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;dependentTypes.forEach((dt,i)=>{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 __embind_register_class=(rawType,rawPointerType,rawConstPointerType,baseClassRawType,getActualTypeSignature,getActualType,upcastSignature,upcast,downcastSignature,downcast,name,destructorSignature,rawDestructor)=>{name=AsciiToString(name);getActualType=embind__requireFunction(getActualTypeSignature,getActualType);upcast&&=embind__requireFunction(upcastSignature,upcast);downcast&&=embind__requireFunction(downcastSignature,downcast);rawDestructor=embind__requireFunction(destructorSignature,rawDestructor);var legalFunctionName=makeLegalFunctionName(name);exposePublicSymbol(legalFunctionName,function(){throwUnboundTypeError(`Cannot construct ${name} due to unbound types`,[baseClassRawType])});whenDependentTypesAreResolved([rawType,rawPointerType,rawConstPointerType],baseClassRawType?[baseClassRawType]:[],base=>{base=base[0];var baseClass;var basePrototype;if(baseClassRawType){baseClass=base.registeredClass;basePrototype=baseClass.instancePrototype}else{basePrototype=ClassHandle.prototype}var constructor=createNamedFunction(name,function(...args){if(Object.getPrototypeOf(this)!==instancePrototype){throw new BindingError(`Use 'new' to construct ${name}`)}if(undefined===registeredClass.constructor_body){throw new BindingError(`${name} has no accessible constructor`)}var body=registeredClass.constructor_body[args.length];if(undefined===body){throw new BindingError(`Tried to invoke ctor of ${name} with invalid number of parameters (${args.length}) - expected (${Object.keys(registeredClass.constructor_body).toString()}) parameters instead!`)}return body.apply(this,args)});var instancePrototype=Object.create(basePrototype,{constructor:{value:constructor}});constructor.prototype=instancePrototype;var registeredClass=new RegisteredClass(name,constructor,instancePrototype,rawDestructor,baseClass,getActualType,upcast,downcast);if(registeredClass.baseClass){registeredClass.baseClass.__derivedClasses??=[];registeredClass.baseClass.__derivedClasses.push(registeredClass)}var referenceConverter=new RegisteredPointer(name,registeredClass,true,false,false);var pointerConverter=new RegisteredPointer(name+"*",registeredClass,false,false,false);var constPointerConverter=new RegisteredPointer(name+" const*",registeredClass,false,true,false);registeredPointers[rawType]={pointerType:pointerConverter,constPointerType:constPointerConverter};replacePublicSymbol(legalFunctionName,constructor);return[referenceConverter,pointerConverter,constPointerConverter]})};var heap32VectorToArray=(count,firstElement)=>{var array=[];for(var i=0;i<count;i++){array.push(HEAPU32[firstElement+i*4>>2])}return array};var runDestructors=destructors=>{while(destructors.length){var ptr=destructors.pop();var del=destructors.pop();del(ptr)}};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","retType","classParam"];if(isClassMethodFunc){invokerFnBody+=`var thisWired = classParam['toWireType'](${dtorStack}, this);\n`}for(var i=0;i<argCount;++i){invokerFnBody+=`var arg${i}Wired = argType${i}['toWireType'](${dtorStack}, arg${i});\n`;args1.push(`argType${i}`)}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 = retType['fromWireType'](rv);\n"+"return ret;\n"}else{}invokerFnBody+="}\n";return[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].name!=="void";var closureArgs=[humanName,throwBindingError,cppInvokerFunc,cppTargetFunc,runDestructors,argTypes[0],argTypes[1]];for(var i=0;i<argCount-2;++i){closureArgs.push(argTypes[i+2])}if(!needsDestructorStack){for(var i=isClassMethodFunc?1:2;i<argTypes.length;++i){if(argTypes[i].destructorFunction!==null){closureArgs.push(argTypes[i].destructorFunction)}}}let[args,invokerFnBody]=createJsInvoker(argTypes,isClassMethodFunc,returns,isAsync);var invokerFn=new Function(...args,invokerFnBody)(...closureArgs);return createNamedFunction(humanName,invokerFn)}var __embind_register_class_constructor=(rawClassType,argCount,rawArgTypesAddr,invokerSignature,invoker,rawConstructor)=>{var rawArgTypes=heap32VectorToArray(argCount,rawArgTypesAddr);invoker=embind__requireFunction(invokerSignature,invoker);whenDependentTypesAreResolved([],[rawClassType],classType=>{classType=classType[0];var humanName=`constructor ${classType.name}`;if(undefined===classType.registeredClass.constructor_body){classType.registeredClass.constructor_body=[]}if(undefined!==classType.registeredClass.constructor_body[argCount-1]){throw new BindingError(`Cannot register multiple constructors with identical number of parameters (${argCount-1}) for class '${classType.name}'! Overload resolution is currently only performed using the parameter count, not actual type info!`)}classType.registeredClass.constructor_body[argCount-1]=()=>{throwUnboundTypeError(`Cannot construct ${classType.name} due to unbound types`,rawArgTypes)};whenDependentTypesAreResolved([],rawArgTypes,argTypes=>{argTypes.splice(1,0,null);classType.registeredClass.constructor_body[argCount-1]=craftInvokerFunction(humanName,argTypes,null,invoker,rawConstructor);return[]});return[]})};var getFunctionName=signature=>{signature=signature.trim();const argsIndex=signature.indexOf("(");if(argsIndex===-1)return signature;return signature.slice(0,argsIndex)};var __embind_register_class_function=(rawClassType,methodName,argCount,rawArgTypesAddr,invokerSignature,rawInvoker,context,isPureVirtual,isAsync,isNonnullReturn)=>{var rawArgTypes=heap32VectorToArray(argCount,rawArgTypesAddr);methodName=AsciiToString(methodName);methodName=getFunctionName(methodName);rawInvoker=embind__requireFunction(invokerSignature,rawInvoker,isAsync);whenDependentTypesAreResolved([],[rawClassType],classType=>{classType=classType[0];var humanName=`${classType.name}.${methodName}`;if(methodName.startsWith("@@")){methodName=Symbol[methodName.substring(2)]}if(isPureVirtual){classType.registeredClass.pureVirtualFunctions.push(methodName)}function unboundTypesHandler(){throwUnboundTypeError(`Cannot call ${humanName} due to unbound types`,rawArgTypes)}var proto=classType.registeredClass.instancePrototype;var method=proto[methodName];if(undefined===method||undefined===method.overloadTable&&method.className!==classType.name&&method.argCount===argCount-2){unboundTypesHandler.argCount=argCount-2;unboundTypesHandler.className=classType.name;proto[methodName]=unboundTypesHandler}else{ensureOverloadTable(proto,methodName,humanName);proto[methodName].overloadTable[argCount-2]=unboundTypesHandler}whenDependentTypesAreResolved([],rawArgTypes,argTypes=>{var memberFunction=craftInvokerFunction(humanName,argTypes,classType,rawInvoker,context,isAsync);if(undefined===proto[methodName].overloadTable){memberFunction.argCount=argCount-2;proto[methodName]=memberFunction}else{proto[methodName].overloadTable[argCount-2]=memberFunction}return[]});return[]})};var emval_freelist=[];var emval_handles=[0,1,,1,null,1,true,1,false,1];var __emval_decref=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),argPackAdvance:GenericWireTypeSize,readValueFromPointer:readPointer,destructorFunction:null};var __embind_register_emval=rawType=>registerType(rawType,EmValType);var floatReadValueFromPointer=(name,width)=>{switch(width){case 4:return function(pointer){return this["fromWireType"](HEAPF32[pointer>>2])};case 8:return function(pointer){return this["fromWireType"](HEAPF64[pointer>>3])};default:throw new TypeError(`invalid float width (${width}): ${name}`)}};var __embind_register_float=(rawType,name,size)=>{name=AsciiToString(name);registerType(rawType,{name,fromWireType:value=>value,toWireType:(destructors,value)=>value,argPackAdvance:GenericWireTypeSize,readValueFromPointer:floatReadValueFromPointer(name,size),destructorFunction:null})};var __embind_register_function=(name,argCount,rawArgTypesAddr,signature,rawInvoker,fn,isAsync,isNonnullReturn)=>{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=(primitiveType,name,size,minRange,maxRange)=>{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,argPackAdvance:GenericWireTypeSize,readValueFromPointer:integerReadValueFromPointer(name,size,minRange!==0),destructorFunction:null})};var __embind_register_memory_view=(rawType,dataTypeIndex,name)=>{var typeMapping=[Int8Array,Uint8Array,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array,BigInt64Array,BigUint64Array];var TA=typeMapping[dataTypeIndex];function decodeMemoryView(handle){var size=HEAPU32[handle>>2];var data=HEAPU32[handle+4>>2];return new TA(HEAP8.buffer,data,size)}name=AsciiToString(name);registerType(rawType,{name,fromWireType:decodeMemoryView,argPackAdvance:GenericWireTypeSize,readValueFromPointer:decodeMemoryView},{ignoreDuplicateRegistrations:true})};var EmValOptionalType=Object.assign({optional:true},EmValType);var __embind_register_optional=(rawOptionalType,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=typeof TextDecoder!="undefined"?new TextDecoder:undefined;var UTF8ArrayToString=(heapOrArray,idx=0,maxBytesToRead=NaN)=>{var endIdx=idx+maxBytesToRead;var endPtr=idx;while(heapOrArray[endPtr]&&!(endPtr>=endIdx))++endPtr;if(endPtr-idx>16&&heapOrArray.buffer&&UTF8Decoder){return UTF8Decoder.decode(heapOrArray.subarray(idx,endPtr))}var str="";while(idx<endPtr){var u0=heapOrArray[idx++];if(!(u0&128)){str+=String.fromCharCode(u0);continue}var u1=heapOrArray[idx++]&63;if((u0&224)==192){str+=String.fromCharCode((u0&31)<<6|u1);continue}var u2=heapOrArray[idx++]&63;if((u0&240)==224){u0=(u0&15)<<12|u1<<6|u2}else{u0=(u0&7)<<18|u1<<12|u2<<6|heapOrArray[idx++]&63}if(u0<65536){str+=String.fromCharCode(u0)}else{var ch=u0-65536;str+=String.fromCharCode(55296|ch>>10,56320|ch&1023)}}return str};var UTF8ToString=(ptr,maxBytesToRead)=>ptr?UTF8ArrayToString(HEAPU8,ptr,maxBytesToRead):"";var __embind_register_std_string=(rawType,name)=>{name=AsciiToString(name);var stdStringIsUTF8=true;registerType(rawType,{name,fromWireType(value){var length=HEAPU32[value>>2];var payload=value+4;var str;if(stdStringIsUTF8){var decodeStartPtr=payload;for(var i=0;i<=length;++i){var currentBytePtr=payload+i;if(i==length||HEAPU8[currentBytePtr]==0){var maxRead=currentBytePtr-decodeStartPtr;var stringSegment=UTF8ToString(decodeStartPtr,maxRead);if(str===undefined){str=stringSegment}else{str+=String.fromCharCode(0);str+=stringSegment}decodeStartPtr=currentBytePtr+1}}}else{var a=new Array(length);for(var i=0;i<length;++i){a[i]=String.fromCharCode(HEAPU8[payload+i])}str=a.join("")}_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(4+length+1);var ptr=base+4;HEAPU32[base>>2]=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},argPackAdvance:GenericWireTypeSize,readValueFromPointer:readPointer,destructorFunction(ptr){_free(ptr)}})};var UTF16Decoder=typeof TextDecoder!="undefined"?new TextDecoder("utf-16le"):undefined;var UTF16ToString=(ptr,maxBytesToRead)=>{var idx=ptr>>1;var maxIdx=idx+maxBytesToRead/2;var endIdx=idx;while(!(endIdx>=maxIdx)&&HEAPU16[endIdx])++endIdx;if(endIdx-idx>16&&UTF16Decoder)return UTF16Decoder.decode(HEAPU16.subarray(idx,endIdx));var str="";for(var i=idx;!(i>=maxIdx);++i){var codeUnit=HEAPU16[i];if(codeUnit==0)break;str+=String.fromCharCode(codeUnit)}return str};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>>1]=codeUnit;outPtr+=2}HEAP16[outPtr>>1]=0;return outPtr-startPtr};var lengthBytesUTF16=str=>str.length*2;var UTF32ToString=(ptr,maxBytesToRead)=>{var str="";for(var i=0;!(i>=maxBytesToRead/4);i++){var utf32=HEAP32[ptr+i*4>>2];if(!utf32)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>>2]=codePoint;outPtr+=4;if(outPtr+4>endPtr)break}HEAP32[outPtr>>2]=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};var __embind_register_std_wstring=(rawType,charSize,name)=>{name=AsciiToString(name);var decodeString,encodeString,readCharAt,lengthBytesUTF;if(charSize===2){decodeString=UTF16ToString;encodeString=stringToUTF16;lengthBytesUTF=lengthBytesUTF16;readCharAt=pointer=>HEAPU16[pointer>>1]}else if(charSize===4){decodeString=UTF32ToString;encodeString=stringToUTF32;lengthBytesUTF=lengthBytesUTF32;readCharAt=pointer=>HEAPU32[pointer>>2]}registerType(rawType,{name,fromWireType:value=>{var length=HEAPU32[value>>2];var str;var decodeStartPtr=value+4;for(var i=0;i<=length;++i){var currentBytePtr=value+4+i*charSize;if(i==length||readCharAt(currentBytePtr)==0){var maxReadBytes=currentBytePtr-decodeStartPtr;var stringSegment=decodeString(decodeStartPtr,maxReadBytes);if(str===undefined){str=stringSegment}else{str+=String.fromCharCode(0);str+=stringSegment}decodeStartPtr=currentBytePtr+charSize}}_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(4+length+charSize);HEAPU32[ptr>>2]=length/charSize;encodeString(value,ptr+4,length+charSize);if(destructors!==null){destructors.push(_free,ptr)}return ptr},argPackAdvance:GenericWireTypeSize,readValueFromPointer:readPointer,destructorFunction(ptr){_free(ptr)}})};var __embind_register_void=(rawType,name)=>{name=AsciiToString(name);registerType(rawType,{isVoid:true,name,argPackAdvance:0,fromWireType:()=>undefined,toWireType:(destructors,o)=>undefined})};var requireRegisteredType=(rawType,humanName)=>{var impl=registeredTypes[rawType];if(undefined===impl){throwBindingError(`${humanName} has unknown type ${getTypeName(rawType)}`)}return impl};var emval_returnValue=(returnType,destructorsRef,handle)=>{var destructors=[];var result=returnType["toWireType"](destructors,handle);if(destructors.length){HEAPU32[destructorsRef>>2]=Emval.toHandle(destructors)}return result};var __emval_as=(handle,returnType,destructorsRef)=>{handle=Emval.toValue(handle);returnType=requireRegisteredType(returnType,"emval::as");return emval_returnValue(returnType,destructorsRef,handle)};var emval_symbols={};var getStringOrSymbol=address=>{var symbol=emval_symbols[address];if(symbol===undefined){return AsciiToString(address)}return symbol};var emval_methodCallers=[];var __emval_call_method=(caller,objHandle,methodName,destructorsRef,args)=>{caller=emval_methodCallers[caller];objHandle=Emval.toValue(objHandle);methodName=getStringOrSymbol(methodName);return caller(objHandle,objHandle[methodName],destructorsRef,args)};var emval_get_global=()=>globalThis;var __emval_get_global=name=>{if(name===0){return Emval.toHandle(emval_get_global())}else{name=getStringOrSymbol(name);return Emval.toHandle(emval_get_global()[name])}};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(HEAPU32[argTypes+i*4>>2],`parameter ${i}`)}return a};var __emval_get_method_caller=(argCount,argTypes,kind)=>{var types=emval_lookupTypes(argCount,argTypes);var retType=types.shift();argCount--;var functionBody=`return function (obj, func, destructorsRef, args) {\n`;var offset=0;var argsList=[];if(kind===0){argsList.push("obj")}var params=["retType"];var args=[retType];for(var i=0;i<argCount;++i){argsList.push(`arg${i}`);params.push(`argType${i}`);args.push(types[i]);functionBody+=` var arg${i} = argType${i}.readValueFromPointer(args${offset?"+"+offset:""});\n`;offset+=types[i].argPackAdvance}var invoker=kind===1?"new func":"func.call";functionBody+=` var rv = ${invoker}(${argsList.join(", ")});\n`;if(!retType.isVoid){params.push("emval_returnValue");args.push(emval_returnValue);functionBody+=" return emval_returnValue(retType, destructorsRef, rv);\n"}functionBody+="};\n";var invokerFunction=new Function(...params,functionBody)(...args);var functionName=`methodCaller<(${types.map(t=>t.name).join(", ")}) => ${retType.name}>`;return emval_addMethodCaller(createNamedFunction(functionName,invokerFunction))};var __emval_get_property=(handle,key)=>{handle=Emval.toValue(handle);key=Emval.toValue(key);return Emval.toHandle(handle[key])};var __emval_incref=handle=>{if(handle>9){emval_handles[handle+1]+=1}};var __emval_instanceof=(object,constructor)=>{object=Emval.toValue(object);constructor=Emval.toValue(constructor);return object instanceof constructor};var __emval_new_array=()=>Emval.toHandle([]);var __emval_new_cstring=v=>Emval.toHandle(getStringOrSymbol(v));var __emval_new_object=()=>Emval.toHandle({});var __emval_run_destructors=handle=>{var destructors=Emval.toValue(handle);runDestructors(destructors);__emval_decref(handle)};var __emval_set_property=(handle,key,value)=>{handle=Emval.toValue(handle);key=Emval.toValue(key);value=Emval.toValue(value);handle[key]=value};var __emval_take_value=(type,arg)=>{type=requireRegisteredType(type,"_emval_take_value");var v=type["readValueFromPointer"](arg);return Emval.toHandle(v)};var getHeapMax=()=>1073741824;var alignMemory=(size,alignment)=>Math.ceil(size/alignment)*alignment;var growMemory=size=>{var b=wasmMemory.buffer;var pages=(size-b.byteLength+65535)/65536|0;try{wasmMemory.grow(pages);updateMemoryViews();return 1}catch(e){}};var _emscripten_resize_heap=requestedSize=>{var oldSize=HEAPU8.length;requestedSize>>>=0;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 _llvm_eh_typeid_for=type=>type;var ALLOC_STACK=1;var stackAlloc=sz=>__emscripten_stack_alloc(sz);var allocate=(slab,allocator)=>{var ret;if(allocator==ALLOC_STACK){ret=stackAlloc(slab.length)}else{ret=_malloc(slab.length)}if(!slab.subarray&&!slab.slice){slab=new Uint8Array(slab)}HEAPU8.set(slab,ret);return ret};init_ClassHandle();init_RegisteredPointer();{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"]}Module["setValue"]=setValue;Module["getValue"]=getValue;Module["UTF8ToString"]=UTF8ToString;Module["stringToUTF8"]=stringToUTF8;Module["lengthBytesUTF8"]=lengthBytesUTF8;Module["allocate"]=allocate;var _malloc,___getTypeName,_free,_setThrew,__emscripten_tempret_set,__emscripten_stack_restore,__emscripten_stack_alloc,_emscripten_stack_get_current,___cxa_decrement_exception_refcount,___cxa_increment_exception_refcount,___cxa_can_catch,___cxa_get_exception_ptr;function assignWasmExports(wasmExports){_malloc=wasmExports["ra"];___getTypeName=wasmExports["sa"];_free=wasmExports["ta"];_setThrew=wasmExports["ua"];__emscripten_tempret_set=wasmExports["va"];__emscripten_stack_restore=wasmExports["wa"];__emscripten_stack_alloc=wasmExports["xa"];_emscripten_stack_get_current=wasmExports["ya"];___cxa_decrement_exception_refcount=wasmExports["za"];___cxa_increment_exception_refcount=wasmExports["Aa"];___cxa_can_catch=wasmExports["Ba"];___cxa_get_exception_ptr=wasmExports["Ca"]}var wasmImports={z:___cxa_begin_catch,I:___cxa_end_catch,a:___cxa_find_matching_catch_2,l:___cxa_find_matching_catch_3,$:___cxa_rethrow,y:___cxa_throw,c:___resumeException,S:__abort_js,K:__embind_register_bigint,X:__embind_register_bool,C:__embind_register_class,B:__embind_register_class_constructor,n:__embind_register_class_function,V:__embind_register_emval,J:__embind_register_float,fa:__embind_register_function,w:__embind_register_integer,s:__embind_register_memory_view,da:__embind_register_optional,W:__embind_register_std_string,D:__embind_register_std_wstring,Y:__embind_register_void,P:__emval_as,Q:__emval_call_method,ja:__emval_decref,ia:__emval_get_global,R:__emval_get_method_caller,ga:__emval_get_property,ba:__emval_incref,ea:__emval_instanceof,ma:__emval_new_array,ha:__emval_new_cstring,na:__emval_new_object,ka:__emval_run_destructors,ca:__emval_set_property,F:__emval_take_value,U:_emscripten_resize_heap,G:invoke_diii,la:invoke_diiiii,H:invoke_i,d:invoke_ii,b:invoke_iii,f:invoke_iiii,m:invoke_iiiii,r:invoke_iiiiii,N:invoke_iiiiiiii,Z:invoke_iiiijii,v:invoke_iiij,p:invoke_iiiji,L:invoke_iij,o:invoke_ji,A:invoke_jiiji,O:invoke_jij,t:invoke_v,h:invoke_vi,g:invoke_vii,e:invoke_viii,i:invoke_viiii,u:invoke_viiiii,k:invoke_viiiiii,T:invoke_viiiiiii,aa:invoke_viiiiiiii,x:invoke_viij,q:invoke_viiji,E:invoke_vij,j:invoke_viji,_:invoke_vijj,M:_llvm_eh_typeid_for};var wasmExports=await createWasm();function invoke_iiii(index,a1,a2,a3){var sp=stackSave();try{return getWasmTableEntry(index)(a1,a2,a3)}catch(e){stackRestore(sp);if(e!==e+0)throw e;_setThrew(1,0)}}function invoke_ii(index,a1){var sp=stackSave();try{return getWasmTableEntry(index)(a1)}catch(e){stackRestore(sp);if(e!==e+0)throw e;_setThrew(1,0)}}function invoke_iii(index,a1,a2){var sp=stackSave();try{return getWasmTableEntry(index)(a1,a2)}catch(e){stackRestore(sp);if(e!==e+0)throw e;_setThrew(1,0)}}function invoke_viji(index,a1,a2,a3){var sp=stackSave();try{getWasmTableEntry(index)(a1,a2,a3)}catch(e){stackRestore(sp);if(e!==e+0)throw e;_setThrew(1,0)}}function invoke_iiiii(index,a1,a2,a3,a4){var sp=stackSave();try{return getWasmTableEntry(index)(a1,a2,a3,a4)}catch(e){stackRestore(sp);if(e!==e+0)throw e;_setThrew(1,0)}}function invoke_viii(index,a1,a2,a3){var sp=stackSave();try{getWasmTableEntry(index)(a1,a2,a3)}catch(e){stackRestore(sp);if(e!==e+0)throw e;_setThrew(1,0)}}function invoke_iiiiii(index,a1,a2,a3,a4,a5){var sp=stackSave();try{return getWasmTableEntry(index)(a1,a2,a3,a4,a5)}catch(e){stackRestore(sp);if(e!==e+0)throw e;_setThrew(1,0)}}function invoke_vii(index,a1,a2){var sp=stackSave();try{getWasmTableEntry(index)(a1,a2)}catch(e){stackRestore(sp);if(e!==e+0)throw e;_setThrew(1,0)}}function invoke_i(index){var sp=stackSave();try{return getWasmTableEntry(index)()}catch(e){stackRestore(sp);if(e!==e+0)throw e;_setThrew(1,0)}}function invoke_diiiii(index,a1,a2,a3,a4,a5){var sp=stackSave();try{return getWasmTableEntry(index)(a1,a2,a3,a4,a5)}catch(e){stackRestore(sp);if(e!==e+0)throw e;_setThrew(1,0)}}function invoke_vi(index,a1){var sp=stackSave();try{getWasmTableEntry(index)(a1)}catch(e){stackRestore(sp);if(e!==e+0)throw e;_setThrew(1,0)}}function invoke_viiii(index,a1,a2,a3,a4){var sp=stackSave();try{getWasmTableEntry(index)(a1,a2,a3,a4)}catch(e){stackRestore(sp);if(e!==e+0)throw e;_setThrew(1,0)}}function invoke_diii(index,a1,a2,a3){var sp=stackSave();try{return getWasmTableEntry(index)(a1,a2,a3)}catch(e){stackRestore(sp);if(e!==e+0)throw e;_setThrew(1,0)}}function invoke_v(index){var sp=stackSave();try{getWasmTableEntry(index)()}catch(e){stackRestore(sp);if(e!==e+0)throw e;_setThrew(1,0)}}function invoke_viiiii(index,a1,a2,a3,a4,a5){var sp=stackSave();try{getWasmTableEntry(index)(a1,a2,a3,a4,a5)}catch(e){stackRestore(sp);if(e!==e+0)throw e;_setThrew(1,0)}}function invoke_ji(index,a1){var sp=stackSave();try{return getWasmTableEntry(index)(a1)}catch(e){stackRestore(sp);if(e!==e+0)throw e;_setThrew(1,0);return 0n}}function invoke_iiiji(index,a1,a2,a3,a4){var sp=stackSave();try{return getWasmTableEntry(index)(a1,a2,a3,a4)}catch(e){stackRestore(sp);if(e!==e+0)throw e;_setThrew(1,0)}}function invoke_iiij(index,a1,a2,a3){var sp=stackSave();try{return getWasmTableEntry(index)(a1,a2,a3)}catch(e){stackRestore(sp);if(e!==e+0)throw e;_setThrew(1,0)}}function invoke_viiji(index,a1,a2,a3,a4){var sp=stackSave();try{getWasmTableEntry(index)(a1,a2,a3,a4)}catch(e){stackRestore(sp);if(e!==e+0)throw e;_setThrew(1,0)}}function invoke_jij(index,a1,a2){var sp=stackSave();try{return getWasmTableEntry(index)(a1,a2)}catch(e){stackRestore(sp);if(e!==e+0)throw e;_setThrew(1,0);return 0n}}function invoke_viiiiii(index,a1,a2,a3,a4,a5,a6){var sp=stackSave();try{getWasmTableEntry(index)(a1,a2,a3,a4,a5,a6)}catch(e){stackRestore(sp);if(e!==e+0)throw e;_setThrew(1,0)}}function invoke_viij(index,a1,a2,a3){var sp=stackSave();try{getWasmTableEntry(index)(a1,a2,a3)}catch(e){stackRestore(sp);if(e!==e+0)throw e;_setThrew(1,0)}}function invoke_iiiiiiii(index,a1,a2,a3,a4,a5,a6,a7){var sp=stackSave();try{return getWasmTableEntry(index)(a1,a2,a3,a4,a5,a6,a7)}catch(e){stackRestore(sp);if(e!==e+0)throw e;_setThrew(1,0)}}function invoke_vij(index,a1,a2){var sp=stackSave();try{getWasmTableEntry(index)(a1,a2)}catch(e){stackRestore(sp);if(e!==e+0)throw e;_setThrew(1,0)}}function invoke_jiiji(index,a1,a2,a3,a4){var sp=stackSave();try{return getWasmTableEntry(index)(a1,a2,a3,a4)}catch(e){stackRestore(sp);if(e!==e+0)throw e;_setThrew(1,0);return 0n}}function invoke_viiiiiiii(index,a1,a2,a3,a4,a5,a6,a7,a8){var sp=stackSave();try{getWasmTableEntry(index)(a1,a2,a3,a4,a5,a6,a7,a8)}catch(e){stackRestore(sp);if(e!==e+0)throw e;_setThrew(1,0)}}function invoke_vijj(index,a1,a2,a3){var sp=stackSave();try{getWasmTableEntry(index)(a1,a2,a3)}catch(e){stackRestore(sp);if(e!==e+0)throw e;_setThrew(1,0)}}function invoke_iij(index,a1,a2){var sp=stackSave();try{return getWasmTableEntry(index)(a1,a2)}catch(e){stackRestore(sp);if(e!==e+0)throw e;_setThrew(1,0)}}function invoke_iiiijii(index,a1,a2,a3,a4,a5,a6){var sp=stackSave();try{return getWasmTableEntry(index)(a1,a2,a3,a4,a5,a6)}catch(e){stackRestore(sp);if(e!==e+0)throw e;_setThrew(1,0)}}function invoke_viiiiiii(index,a1,a2,a3,a4,a5,a6,a7){var sp=stackSave();try{getWasmTableEntry(index)(a1,a2,a3,a4,a5,a6,a7)}catch(e){stackRestore(sp);if(e!==e+0)throw e;_setThrew(1,0)}}function run(){if(runDependencies>0){dependenciesFulfilled=run;return}preRun();if(runDependencies>0){dependenciesFulfilled=run;return}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()}}function preInit(){if(Module["preInit"]){if(typeof Module["preInit"]=="function")Module["preInit"]=[Module["preInit"]];while(Module["preInit"].length>0){Module["preInit"].shift()()}}}preInit();run();if(runtimeInitialized){moduleRtn=Module}else{moduleRtn=new Promise((resolve,reject)=>{readyPromiseResolve=resolve;readyPromiseReject=reject})}
|
|
23
8
|
|
|
24
9
|
|
|
25
10
|
return moduleRtn;
|
|
@@ -27,9 +12,9 @@ if(c.preInit)for("function"==typeof c.preInit&&(c.preInit=[c.preInit]);0<c.preIn
|
|
|
27
12
|
);
|
|
28
13
|
})();
|
|
29
14
|
if (typeof exports === 'object' && typeof module === 'object') {
|
|
30
|
-
module.exports =
|
|
15
|
+
module.exports = createTagLibModule;
|
|
31
16
|
// This default export looks redundant, but it allows TS to import this
|
|
32
17
|
// commonjs style module.
|
|
33
|
-
module.exports.default =
|
|
18
|
+
module.exports.default = createTagLibModule;
|
|
34
19
|
} else if (typeof define === 'function' && define['amd'])
|
|
35
|
-
define([], () =>
|
|
20
|
+
define([], () => createTagLibModule);
|
package/build/taglib.wasm
CHANGED
|
Binary file
|
package/package.json
CHANGED
|
@@ -0,0 +1,231 @@
|
|
|
1
|
+
import type { TagLibModule, WasmModule } from "./wasm-embind.ts";
|
|
2
|
+
import type { AudioFile as AudioFileInterface, AudioProperties, FileType, PropertyMap, Tag } from "./types.ts";
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Audio file wrapper using Embind API
|
|
6
|
+
*/
|
|
7
|
+
export class AudioFile implements AudioFileInterface {
|
|
8
|
+
private fileHandle: any;
|
|
9
|
+
private cachedTag: Tag | null = null;
|
|
10
|
+
private cachedAudioProperties: AudioProperties | null = null;
|
|
11
|
+
|
|
12
|
+
constructor(
|
|
13
|
+
private module: TagLibModule,
|
|
14
|
+
fileHandle: any,
|
|
15
|
+
) {
|
|
16
|
+
this.fileHandle = fileHandle;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Get file format
|
|
21
|
+
*/
|
|
22
|
+
getFormat(): FileType {
|
|
23
|
+
return this.fileHandle.getFormat() as FileType;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* Get tag object for reading/writing metadata
|
|
28
|
+
*/
|
|
29
|
+
tag(): Tag {
|
|
30
|
+
if (!this.cachedTag) {
|
|
31
|
+
const tagWrapper = this.fileHandle.getTag();
|
|
32
|
+
if (!tagWrapper) {
|
|
33
|
+
throw new Error("Failed to get tag from file");
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
this.cachedTag = {
|
|
37
|
+
title: () => tagWrapper.title(),
|
|
38
|
+
artist: () => tagWrapper.artist(),
|
|
39
|
+
album: () => tagWrapper.album(),
|
|
40
|
+
comment: () => tagWrapper.comment(),
|
|
41
|
+
genre: () => tagWrapper.genre(),
|
|
42
|
+
year: () => tagWrapper.year(),
|
|
43
|
+
track: () => tagWrapper.track(),
|
|
44
|
+
|
|
45
|
+
setTitle: (value: string) => tagWrapper.setTitle(value),
|
|
46
|
+
setArtist: (value: string) => tagWrapper.setArtist(value),
|
|
47
|
+
setAlbum: (value: string) => tagWrapper.setAlbum(value),
|
|
48
|
+
setComment: (value: string) => tagWrapper.setComment(value),
|
|
49
|
+
setGenre: (value: string) => tagWrapper.setGenre(value),
|
|
50
|
+
setYear: (value: number) => tagWrapper.setYear(value),
|
|
51
|
+
setTrack: (value: number) => tagWrapper.setTrack(value),
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
return this.cachedTag;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* Get audio properties
|
|
60
|
+
*/
|
|
61
|
+
audioProperties(): AudioProperties | null {
|
|
62
|
+
if (!this.cachedAudioProperties) {
|
|
63
|
+
const propsWrapper = this.fileHandle.getAudioProperties();
|
|
64
|
+
if (!propsWrapper) {
|
|
65
|
+
return null;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
this.cachedAudioProperties = {
|
|
69
|
+
length: propsWrapper.lengthInSeconds(),
|
|
70
|
+
lengthInMilliseconds: propsWrapper.lengthInMilliseconds(),
|
|
71
|
+
bitrate: propsWrapper.bitrate(),
|
|
72
|
+
sampleRate: propsWrapper.sampleRate(),
|
|
73
|
+
channels: propsWrapper.channels(),
|
|
74
|
+
};
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
return this.cachedAudioProperties;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
/**
|
|
81
|
+
* Get all properties as a PropertyMap
|
|
82
|
+
*/
|
|
83
|
+
properties(): PropertyMap {
|
|
84
|
+
const jsObj = this.fileHandle.getProperties();
|
|
85
|
+
const result: PropertyMap = {};
|
|
86
|
+
|
|
87
|
+
// Convert from Emscripten val to plain object
|
|
88
|
+
const keys = Object.keys(jsObj);
|
|
89
|
+
for (const key of keys) {
|
|
90
|
+
result[key] = jsObj[key];
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
return result;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
/**
|
|
97
|
+
* Set properties from a PropertyMap
|
|
98
|
+
*/
|
|
99
|
+
setProperties(properties: PropertyMap): void {
|
|
100
|
+
this.fileHandle.setProperties(properties);
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
/**
|
|
104
|
+
* Get a single property value
|
|
105
|
+
*/
|
|
106
|
+
getProperty(key: string): string | undefined {
|
|
107
|
+
const value = this.fileHandle.getProperty(key);
|
|
108
|
+
return value === "" ? undefined : value;
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
/**
|
|
112
|
+
* Set a single property value
|
|
113
|
+
*/
|
|
114
|
+
setProperty(key: string, value: string): void {
|
|
115
|
+
this.fileHandle.setProperty(key, value);
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
/**
|
|
119
|
+
* Check if this is an MP4 file
|
|
120
|
+
*/
|
|
121
|
+
isMP4(): boolean {
|
|
122
|
+
return this.fileHandle.isMP4();
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
/**
|
|
126
|
+
* Get MP4-specific item
|
|
127
|
+
*/
|
|
128
|
+
getMP4Item(key: string): string | undefined {
|
|
129
|
+
if (!this.isMP4()) {
|
|
130
|
+
throw new Error("Not an MP4 file");
|
|
131
|
+
}
|
|
132
|
+
const value = this.fileHandle.getMP4Item(key);
|
|
133
|
+
return value === "" ? undefined : value;
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
/**
|
|
137
|
+
* Set MP4-specific item
|
|
138
|
+
*/
|
|
139
|
+
setMP4Item(key: string, value: string): void {
|
|
140
|
+
if (!this.isMP4()) {
|
|
141
|
+
throw new Error("Not an MP4 file");
|
|
142
|
+
}
|
|
143
|
+
this.fileHandle.setMP4Item(key, value);
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
/**
|
|
147
|
+
* Remove MP4-specific item
|
|
148
|
+
*/
|
|
149
|
+
removeMP4Item(key: string): void {
|
|
150
|
+
if (!this.isMP4()) {
|
|
151
|
+
throw new Error("Not an MP4 file");
|
|
152
|
+
}
|
|
153
|
+
this.fileHandle.removeMP4Item(key);
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
/**
|
|
157
|
+
* Save changes to the file
|
|
158
|
+
*/
|
|
159
|
+
save(): boolean {
|
|
160
|
+
// Clear caches since values may have changed
|
|
161
|
+
this.cachedTag = null;
|
|
162
|
+
this.cachedAudioProperties = null;
|
|
163
|
+
|
|
164
|
+
return this.fileHandle.save();
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
/**
|
|
168
|
+
* Check if the file is valid
|
|
169
|
+
*/
|
|
170
|
+
isValid(): boolean {
|
|
171
|
+
return this.fileHandle.isValid();
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
/**
|
|
175
|
+
* Free resources
|
|
176
|
+
*/
|
|
177
|
+
dispose(): void {
|
|
178
|
+
if (this.fileHandle) {
|
|
179
|
+
// Embind will handle cleanup when the object goes out of scope
|
|
180
|
+
// But we can help by clearing our references
|
|
181
|
+
this.fileHandle = null;
|
|
182
|
+
this.cachedTag = null;
|
|
183
|
+
this.cachedAudioProperties = null;
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
/**
|
|
189
|
+
* Main TagLib interface using Embind
|
|
190
|
+
*/
|
|
191
|
+
export class TagLib {
|
|
192
|
+
private module: TagLibModule;
|
|
193
|
+
|
|
194
|
+
constructor(module: WasmModule) {
|
|
195
|
+
this.module = module as TagLibModule;
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
/**
|
|
199
|
+
* Open a file from a buffer
|
|
200
|
+
*/
|
|
201
|
+
async openFile(buffer: ArrayBuffer): Promise<AudioFile> {
|
|
202
|
+
// Convert ArrayBuffer to string for Embind
|
|
203
|
+
const uint8Array = new Uint8Array(buffer);
|
|
204
|
+
const binaryString = Array.from(uint8Array, byte => String.fromCharCode(byte)).join('');
|
|
205
|
+
|
|
206
|
+
// Create a new FileHandle
|
|
207
|
+
const fileHandle = this.module.createFileHandle();
|
|
208
|
+
|
|
209
|
+
// Load the buffer
|
|
210
|
+
const success = fileHandle.loadFromBuffer(binaryString);
|
|
211
|
+
if (!success) {
|
|
212
|
+
throw new Error("Failed to load file from buffer");
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
return new AudioFile(this.module, fileHandle);
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
/**
|
|
219
|
+
* Get version information
|
|
220
|
+
*/
|
|
221
|
+
version(): string {
|
|
222
|
+
return "2.1.0"; // TagLib version we're using
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
/**
|
|
227
|
+
* Create a TagLib instance
|
|
228
|
+
*/
|
|
229
|
+
export async function createTagLib(module: WasmModule): Promise<TagLib> {
|
|
230
|
+
return new TagLib(module);
|
|
231
|
+
}
|
package/src/taglib-jsr.ts
CHANGED
|
@@ -8,8 +8,10 @@
|
|
|
8
8
|
import type {
|
|
9
9
|
AudioFormat,
|
|
10
10
|
AudioProperties,
|
|
11
|
+
BitrateControlMode,
|
|
11
12
|
ExtendedTag,
|
|
12
13
|
Picture,
|
|
14
|
+
PropertyMap,
|
|
13
15
|
Tag,
|
|
14
16
|
TagLibConfig,
|
|
15
17
|
} from "./types.ts";
|
|
@@ -19,7 +21,11 @@ import {
|
|
|
19
21
|
loadTagLibModuleJSR,
|
|
20
22
|
type TagLibModule,
|
|
21
23
|
} from "./wasm-jsr.ts";
|
|
22
|
-
import {
|
|
24
|
+
import {
|
|
25
|
+
BITRATE_CONTROL_MODE_NAMES,
|
|
26
|
+
BITRATE_CONTROL_MODE_VALUES,
|
|
27
|
+
METADATA_MAPPINGS
|
|
28
|
+
} from "./types.ts";
|
|
23
29
|
|
|
24
30
|
/**
|
|
25
31
|
* JSR-compatible TagLib singleton for WASM module management
|
|
@@ -358,6 +364,150 @@ export class AudioFileJSR {
|
|
|
358
364
|
}
|
|
359
365
|
setAppleSoundCheck(soundCheck: string): void {}
|
|
360
366
|
|
|
367
|
+
/**
|
|
368
|
+
* Get all properties as a PropertyMap
|
|
369
|
+
*/
|
|
370
|
+
properties(): PropertyMap {
|
|
371
|
+
const jsonPtr = this.module._taglib_file_properties_json(this.fileId);
|
|
372
|
+
if (jsonPtr === 0) return {};
|
|
373
|
+
|
|
374
|
+
const jsonStr = cStringToJSJSR(this.module, jsonPtr);
|
|
375
|
+
try {
|
|
376
|
+
return JSON.parse(jsonStr);
|
|
377
|
+
} catch {
|
|
378
|
+
return {};
|
|
379
|
+
}
|
|
380
|
+
}
|
|
381
|
+
|
|
382
|
+
/**
|
|
383
|
+
* Set properties from a PropertyMap
|
|
384
|
+
*/
|
|
385
|
+
setProperties(properties: PropertyMap): boolean {
|
|
386
|
+
const jsonStr = JSON.stringify(properties);
|
|
387
|
+
const jsonPtr = jsToCStringJSR(this.module, jsonStr);
|
|
388
|
+
try {
|
|
389
|
+
return this.module._taglib_file_set_properties_json(this.fileId, jsonPtr) !== 0;
|
|
390
|
+
} finally {
|
|
391
|
+
this.module._free(jsonPtr);
|
|
392
|
+
}
|
|
393
|
+
}
|
|
394
|
+
|
|
395
|
+
/**
|
|
396
|
+
* Get a specific property value
|
|
397
|
+
*/
|
|
398
|
+
getProperty(key: string): string[] | undefined {
|
|
399
|
+
const keyPtr = jsToCStringJSR(this.module, key);
|
|
400
|
+
try {
|
|
401
|
+
const valuePtr = this.module._taglib_file_get_property(this.fileId, keyPtr);
|
|
402
|
+
if (valuePtr === 0) return undefined;
|
|
403
|
+
|
|
404
|
+
const value = cStringToJSJSR(this.module, valuePtr);
|
|
405
|
+
return value ? [value] : undefined;
|
|
406
|
+
} finally {
|
|
407
|
+
this.module._free(keyPtr);
|
|
408
|
+
}
|
|
409
|
+
}
|
|
410
|
+
|
|
411
|
+
/**
|
|
412
|
+
* Set a specific property value
|
|
413
|
+
*/
|
|
414
|
+
setProperty(key: string, values: string | string[]): boolean {
|
|
415
|
+
const value = Array.isArray(values) ? values[0] : values;
|
|
416
|
+
if (!value) return false;
|
|
417
|
+
|
|
418
|
+
const keyPtr = jsToCStringJSR(this.module, key);
|
|
419
|
+
const valuePtr = jsToCStringJSR(this.module, value);
|
|
420
|
+
try {
|
|
421
|
+
return this.module._taglib_file_set_property(this.fileId, keyPtr, valuePtr) !== 0;
|
|
422
|
+
} finally {
|
|
423
|
+
this.module._free(keyPtr);
|
|
424
|
+
this.module._free(valuePtr);
|
|
425
|
+
}
|
|
426
|
+
}
|
|
427
|
+
|
|
428
|
+
/**
|
|
429
|
+
* Check if this is an MP4 file
|
|
430
|
+
*/
|
|
431
|
+
isMP4(): boolean {
|
|
432
|
+
return this.module._taglib_file_is_mp4(this.fileId) !== 0;
|
|
433
|
+
}
|
|
434
|
+
|
|
435
|
+
/**
|
|
436
|
+
* Get MP4-specific item (for custom atoms)
|
|
437
|
+
*/
|
|
438
|
+
getMP4Item(key: string): string | undefined {
|
|
439
|
+
if (!this.isMP4()) return undefined;
|
|
440
|
+
|
|
441
|
+
const keyPtr = jsToCStringJSR(this.module, key);
|
|
442
|
+
try {
|
|
443
|
+
const valuePtr = this.module._taglib_mp4_get_item(this.fileId, keyPtr);
|
|
444
|
+
if (valuePtr === 0) return undefined;
|
|
445
|
+
|
|
446
|
+
return cStringToJSJSR(this.module, valuePtr);
|
|
447
|
+
} finally {
|
|
448
|
+
this.module._free(keyPtr);
|
|
449
|
+
}
|
|
450
|
+
}
|
|
451
|
+
|
|
452
|
+
/**
|
|
453
|
+
* Set MP4-specific item (for custom atoms)
|
|
454
|
+
*/
|
|
455
|
+
setMP4Item(key: string, value: string): boolean {
|
|
456
|
+
if (!this.isMP4()) return false;
|
|
457
|
+
|
|
458
|
+
const keyPtr = jsToCStringJSR(this.module, key);
|
|
459
|
+
const valuePtr = jsToCStringJSR(this.module, value);
|
|
460
|
+
try {
|
|
461
|
+
return this.module._taglib_mp4_set_item(this.fileId, keyPtr, valuePtr) !== 0;
|
|
462
|
+
} finally {
|
|
463
|
+
this.module._free(keyPtr);
|
|
464
|
+
this.module._free(valuePtr);
|
|
465
|
+
}
|
|
466
|
+
}
|
|
467
|
+
|
|
468
|
+
/**
|
|
469
|
+
* Remove MP4-specific item
|
|
470
|
+
*/
|
|
471
|
+
removeMP4Item(key: string): boolean {
|
|
472
|
+
if (!this.isMP4()) return false;
|
|
473
|
+
|
|
474
|
+
const keyPtr = jsToCStringJSR(this.module, key);
|
|
475
|
+
try {
|
|
476
|
+
return this.module._taglib_mp4_remove_item(this.fileId, keyPtr) !== 0;
|
|
477
|
+
} finally {
|
|
478
|
+
this.module._free(keyPtr);
|
|
479
|
+
}
|
|
480
|
+
}
|
|
481
|
+
|
|
482
|
+
/**
|
|
483
|
+
* Get bitrate control mode (MP4/M4A specific)
|
|
484
|
+
* Reads from the 'acbf' atom
|
|
485
|
+
*/
|
|
486
|
+
getBitrateControlMode(): BitrateControlMode | undefined {
|
|
487
|
+
if (!this.isMP4()) return undefined;
|
|
488
|
+
|
|
489
|
+
const value = this.getMP4Item("acbf");
|
|
490
|
+
if (!value) return undefined;
|
|
491
|
+
|
|
492
|
+
const numValue = parseInt(value, 10);
|
|
493
|
+
if (isNaN(numValue) || numValue < 0 || numValue > 3) return undefined;
|
|
494
|
+
|
|
495
|
+
return BITRATE_CONTROL_MODE_NAMES[numValue];
|
|
496
|
+
}
|
|
497
|
+
|
|
498
|
+
/**
|
|
499
|
+
* Set bitrate control mode (MP4/M4A specific)
|
|
500
|
+
* Writes to the 'acbf' atom
|
|
501
|
+
*/
|
|
502
|
+
setBitrateControlMode(mode: BitrateControlMode): boolean {
|
|
503
|
+
if (!this.isMP4()) return false;
|
|
504
|
+
|
|
505
|
+
const numValue = BITRATE_CONTROL_MODE_VALUES[mode];
|
|
506
|
+
if (numValue === undefined) return false;
|
|
507
|
+
|
|
508
|
+
return this.setMP4Item("acbf", numValue.toString());
|
|
509
|
+
}
|
|
510
|
+
|
|
361
511
|
/**
|
|
362
512
|
* Save changes to the file
|
|
363
513
|
*/
|
package/src/taglib.ts
CHANGED
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
import type {
|
|
6
6
|
AudioFormat,
|
|
7
7
|
AudioProperties,
|
|
8
|
+
BitrateControlMode,
|
|
8
9
|
ExtendedTag,
|
|
9
10
|
FieldMapping,
|
|
10
11
|
Picture,
|
|
@@ -12,7 +13,11 @@ import type {
|
|
|
12
13
|
Tag,
|
|
13
14
|
TagLibConfig,
|
|
14
15
|
} from "./types.ts";
|
|
15
|
-
import {
|
|
16
|
+
import {
|
|
17
|
+
BITRATE_CONTROL_MODE_NAMES,
|
|
18
|
+
BITRATE_CONTROL_MODE_VALUES,
|
|
19
|
+
METADATA_MAPPINGS
|
|
20
|
+
} from "./types.ts";
|
|
16
21
|
import {
|
|
17
22
|
cStringToJS,
|
|
18
23
|
jsToCString,
|
|
@@ -168,6 +173,150 @@ export class AudioFile {
|
|
|
168
173
|
this.module._taglib_tag_set_track(this.tagPtr, track);
|
|
169
174
|
}
|
|
170
175
|
|
|
176
|
+
/**
|
|
177
|
+
* Get all properties as a PropertyMap
|
|
178
|
+
*/
|
|
179
|
+
properties(): PropertyMap {
|
|
180
|
+
const jsonPtr = this.module._taglib_file_properties_json(this.fileId);
|
|
181
|
+
if (jsonPtr === 0) return {};
|
|
182
|
+
|
|
183
|
+
const jsonStr = cStringToJS(this.module, jsonPtr);
|
|
184
|
+
try {
|
|
185
|
+
return JSON.parse(jsonStr);
|
|
186
|
+
} catch {
|
|
187
|
+
return {};
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
/**
|
|
192
|
+
* Set properties from a PropertyMap
|
|
193
|
+
*/
|
|
194
|
+
setProperties(properties: PropertyMap): boolean {
|
|
195
|
+
const jsonStr = JSON.stringify(properties);
|
|
196
|
+
const jsonPtr = jsToCString(this.module, jsonStr);
|
|
197
|
+
try {
|
|
198
|
+
return this.module._taglib_file_set_properties_json(this.fileId, jsonPtr) !== 0;
|
|
199
|
+
} finally {
|
|
200
|
+
this.module._free(jsonPtr);
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
/**
|
|
205
|
+
* Get a specific property value
|
|
206
|
+
*/
|
|
207
|
+
getProperty(key: string): string[] | undefined {
|
|
208
|
+
const keyPtr = jsToCString(this.module, key);
|
|
209
|
+
try {
|
|
210
|
+
const valuePtr = this.module._taglib_file_get_property(this.fileId, keyPtr);
|
|
211
|
+
if (valuePtr === 0) return undefined;
|
|
212
|
+
|
|
213
|
+
const value = cStringToJS(this.module, valuePtr);
|
|
214
|
+
return value ? [value] : undefined;
|
|
215
|
+
} finally {
|
|
216
|
+
this.module._free(keyPtr);
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
/**
|
|
221
|
+
* Set a specific property value
|
|
222
|
+
*/
|
|
223
|
+
setProperty(key: string, values: string | string[]): boolean {
|
|
224
|
+
const value = Array.isArray(values) ? values[0] : values;
|
|
225
|
+
if (!value) return false;
|
|
226
|
+
|
|
227
|
+
const keyPtr = jsToCString(this.module, key);
|
|
228
|
+
const valuePtr = jsToCString(this.module, value);
|
|
229
|
+
try {
|
|
230
|
+
return this.module._taglib_file_set_property(this.fileId, keyPtr, valuePtr) !== 0;
|
|
231
|
+
} finally {
|
|
232
|
+
this.module._free(keyPtr);
|
|
233
|
+
this.module._free(valuePtr);
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
/**
|
|
238
|
+
* Check if this is an MP4 file
|
|
239
|
+
*/
|
|
240
|
+
isMP4(): boolean {
|
|
241
|
+
return this.module._taglib_file_is_mp4(this.fileId) !== 0;
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
/**
|
|
245
|
+
* Get MP4-specific item (for custom atoms)
|
|
246
|
+
*/
|
|
247
|
+
getMP4Item(key: string): string | undefined {
|
|
248
|
+
if (!this.isMP4()) return undefined;
|
|
249
|
+
|
|
250
|
+
const keyPtr = jsToCString(this.module, key);
|
|
251
|
+
try {
|
|
252
|
+
const valuePtr = this.module._taglib_mp4_get_item(this.fileId, keyPtr);
|
|
253
|
+
if (valuePtr === 0) return undefined;
|
|
254
|
+
|
|
255
|
+
return cStringToJS(this.module, valuePtr);
|
|
256
|
+
} finally {
|
|
257
|
+
this.module._free(keyPtr);
|
|
258
|
+
}
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
/**
|
|
262
|
+
* Set MP4-specific item (for custom atoms)
|
|
263
|
+
*/
|
|
264
|
+
setMP4Item(key: string, value: string): boolean {
|
|
265
|
+
if (!this.isMP4()) return false;
|
|
266
|
+
|
|
267
|
+
const keyPtr = jsToCString(this.module, key);
|
|
268
|
+
const valuePtr = jsToCString(this.module, value);
|
|
269
|
+
try {
|
|
270
|
+
return this.module._taglib_mp4_set_item(this.fileId, keyPtr, valuePtr) !== 0;
|
|
271
|
+
} finally {
|
|
272
|
+
this.module._free(keyPtr);
|
|
273
|
+
this.module._free(valuePtr);
|
|
274
|
+
}
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
/**
|
|
278
|
+
* Remove MP4-specific item
|
|
279
|
+
*/
|
|
280
|
+
removeMP4Item(key: string): boolean {
|
|
281
|
+
if (!this.isMP4()) return false;
|
|
282
|
+
|
|
283
|
+
const keyPtr = jsToCString(this.module, key);
|
|
284
|
+
try {
|
|
285
|
+
return this.module._taglib_mp4_remove_item(this.fileId, keyPtr) !== 0;
|
|
286
|
+
} finally {
|
|
287
|
+
this.module._free(keyPtr);
|
|
288
|
+
}
|
|
289
|
+
}
|
|
290
|
+
|
|
291
|
+
/**
|
|
292
|
+
* Get bitrate control mode (MP4/M4A specific)
|
|
293
|
+
* Reads from the 'acbf' atom
|
|
294
|
+
*/
|
|
295
|
+
getBitrateControlMode(): BitrateControlMode | undefined {
|
|
296
|
+
if (!this.isMP4()) return undefined;
|
|
297
|
+
|
|
298
|
+
const value = this.getMP4Item("acbf");
|
|
299
|
+
if (!value) return undefined;
|
|
300
|
+
|
|
301
|
+
const numValue = parseInt(value, 10);
|
|
302
|
+
if (isNaN(numValue) || numValue < 0 || numValue > 3) return undefined;
|
|
303
|
+
|
|
304
|
+
return BITRATE_CONTROL_MODE_NAMES[numValue];
|
|
305
|
+
}
|
|
306
|
+
|
|
307
|
+
/**
|
|
308
|
+
* Set bitrate control mode (MP4/M4A specific)
|
|
309
|
+
* Writes to the 'acbf' atom
|
|
310
|
+
*/
|
|
311
|
+
setBitrateControlMode(mode: BitrateControlMode): boolean {
|
|
312
|
+
if (!this.isMP4()) return false;
|
|
313
|
+
|
|
314
|
+
const numValue = BITRATE_CONTROL_MODE_VALUES[mode];
|
|
315
|
+
if (numValue === undefined) return false;
|
|
316
|
+
|
|
317
|
+
return this.setMP4Item("acbf", numValue.toString());
|
|
318
|
+
}
|
|
319
|
+
|
|
171
320
|
/**
|
|
172
321
|
* Save changes to the file
|
|
173
322
|
*/
|
package/src/types.ts
CHANGED
|
@@ -341,6 +341,35 @@ export enum PictureType {
|
|
|
341
341
|
PublisherLogo = 20,
|
|
342
342
|
}
|
|
343
343
|
|
|
344
|
+
/**
|
|
345
|
+
* Bitrate control modes for audio encoding (MP4/M4A specific)
|
|
346
|
+
*/
|
|
347
|
+
export type BitrateControlMode =
|
|
348
|
+
| "Constant"
|
|
349
|
+
| "LongTermAverage"
|
|
350
|
+
| "VariableConstrained"
|
|
351
|
+
| "Variable";
|
|
352
|
+
|
|
353
|
+
/**
|
|
354
|
+
* Map of bitrate control mode names to their numeric values
|
|
355
|
+
*/
|
|
356
|
+
export const BITRATE_CONTROL_MODE_VALUES: Record<BitrateControlMode, number> = {
|
|
357
|
+
Constant: 0,
|
|
358
|
+
LongTermAverage: 1,
|
|
359
|
+
VariableConstrained: 2,
|
|
360
|
+
Variable: 3,
|
|
361
|
+
};
|
|
362
|
+
|
|
363
|
+
/**
|
|
364
|
+
* Map of numeric values to bitrate control mode names
|
|
365
|
+
*/
|
|
366
|
+
export const BITRATE_CONTROL_MODE_NAMES: Record<number, BitrateControlMode> = {
|
|
367
|
+
0: "Constant",
|
|
368
|
+
1: "LongTermAverage",
|
|
369
|
+
2: "VariableConstrained",
|
|
370
|
+
3: "Variable",
|
|
371
|
+
};
|
|
372
|
+
|
|
344
373
|
/**
|
|
345
374
|
* Configuration options for TagLib initialization
|
|
346
375
|
*/
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* WebAssembly module interface for Embind version
|
|
3
|
+
*/
|
|
4
|
+
export interface WasmModule {
|
|
5
|
+
// Memory access
|
|
6
|
+
HEAP8: Int8Array;
|
|
7
|
+
HEAP16: Int16Array;
|
|
8
|
+
HEAP32: Int32Array;
|
|
9
|
+
HEAPU8: Uint8Array;
|
|
10
|
+
HEAPU16: Uint16Array;
|
|
11
|
+
HEAPU32: Uint32Array;
|
|
12
|
+
HEAPF32: Float32Array;
|
|
13
|
+
HEAPF64: Float64Array;
|
|
14
|
+
|
|
15
|
+
// Runtime methods
|
|
16
|
+
allocate: (size: number, type: number) => number;
|
|
17
|
+
_malloc: (size: number) => number;
|
|
18
|
+
_free: (ptr: number) => void;
|
|
19
|
+
getValue: (ptr: number, type: string) => number;
|
|
20
|
+
setValue: (ptr: number, value: number, type: string) => void;
|
|
21
|
+
UTF8ToString: (ptr: number) => string;
|
|
22
|
+
stringToUTF8: (str: string, outPtr: number, maxBytesToWrite: number) => void;
|
|
23
|
+
lengthBytesUTF8: (str: string) => number;
|
|
24
|
+
|
|
25
|
+
// Allocation types
|
|
26
|
+
ALLOC_NORMAL: number;
|
|
27
|
+
ALLOC_STACK: number;
|
|
28
|
+
|
|
29
|
+
// Embind classes (these will be available after module loads)
|
|
30
|
+
FileHandle: any;
|
|
31
|
+
TagWrapper: any;
|
|
32
|
+
AudioPropertiesWrapper: any;
|
|
33
|
+
createFileHandle: () => any;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* Extended module interface with our Embind classes
|
|
38
|
+
*/
|
|
39
|
+
export interface TagLibModule extends WasmModule {
|
|
40
|
+
// These are the actual class constructors from Embind
|
|
41
|
+
FileHandle: {
|
|
42
|
+
new(): any;
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
TagWrapper: {
|
|
46
|
+
new(tagPtr: number): any;
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
AudioPropertiesWrapper: {
|
|
50
|
+
new(propsPtr: number): any;
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
// Factory function
|
|
54
|
+
createFileHandle: () => any;
|
|
55
|
+
}
|
package/src/wasm-jsr.ts
CHANGED
|
@@ -59,6 +59,18 @@ export interface TagLibModule {
|
|
|
59
59
|
_taglib_audioproperties_bitrate: (props: number) => number;
|
|
60
60
|
_taglib_audioproperties_samplerate: (props: number) => number;
|
|
61
61
|
_taglib_audioproperties_channels: (props: number) => number;
|
|
62
|
+
|
|
63
|
+
// PropertyMap operations
|
|
64
|
+
_taglib_file_properties_json: (fileId: number) => number;
|
|
65
|
+
_taglib_file_set_properties_json: (fileId: number, json: number) => number;
|
|
66
|
+
_taglib_file_get_property: (fileId: number, key: number) => number;
|
|
67
|
+
_taglib_file_set_property: (fileId: number, key: number, value: number) => number;
|
|
68
|
+
|
|
69
|
+
// MP4-specific operations
|
|
70
|
+
_taglib_file_is_mp4: (fileId: number) => number;
|
|
71
|
+
_taglib_mp4_get_item: (fileId: number, key: number) => number;
|
|
72
|
+
_taglib_mp4_set_item: (fileId: number, key: number, value: number) => number;
|
|
73
|
+
_taglib_mp4_remove_item: (fileId: number, key: number) => number;
|
|
62
74
|
}
|
|
63
75
|
|
|
64
76
|
/**
|
|
@@ -67,46 +79,124 @@ export interface TagLibModule {
|
|
|
67
79
|
export async function loadTagLibModuleJSR(
|
|
68
80
|
config?: TagLibConfig,
|
|
69
81
|
): Promise<TagLibModule> {
|
|
70
|
-
// Load WASM file as bytes
|
|
82
|
+
// Load WASM file as bytes (same file for all platforms)
|
|
71
83
|
const wasmUrl = new URL("../build/taglib.wasm", import.meta.url);
|
|
72
84
|
const wasmBytes = await fetch(wasmUrl).then((r) => r.arrayBuffer());
|
|
73
85
|
|
|
74
|
-
//
|
|
75
|
-
const
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
86
|
+
// Create memory
|
|
87
|
+
const memory = new WebAssembly.Memory({ initial: 256, maximum: 4096 });
|
|
88
|
+
|
|
89
|
+
// Create heap views
|
|
90
|
+
let HEAP8: Int8Array;
|
|
91
|
+
let HEAPU8: Uint8Array;
|
|
92
|
+
let HEAP16: Int16Array;
|
|
93
|
+
let HEAPU16: Uint16Array;
|
|
94
|
+
let HEAP32: Int32Array;
|
|
95
|
+
let HEAPU32: Uint32Array;
|
|
96
|
+
let HEAPF32: Float32Array;
|
|
97
|
+
let HEAPF64: Float64Array;
|
|
98
|
+
|
|
99
|
+
function updateMemoryViews() {
|
|
100
|
+
const buffer = memory.buffer;
|
|
101
|
+
HEAP8 = new Int8Array(buffer);
|
|
102
|
+
HEAPU8 = new Uint8Array(buffer);
|
|
103
|
+
HEAP16 = new Int16Array(buffer);
|
|
104
|
+
HEAPU16 = new Uint16Array(buffer);
|
|
105
|
+
HEAP32 = new Int32Array(buffer);
|
|
106
|
+
HEAPU32 = new Uint32Array(buffer);
|
|
107
|
+
HEAPF32 = new Float32Array(buffer);
|
|
108
|
+
HEAPF64 = new Float64Array(buffer);
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
updateMemoryViews();
|
|
112
|
+
|
|
113
|
+
// Import functions expected by the WASM module (still minified with -O3)
|
|
114
|
+
const wasmImports = {
|
|
115
|
+
a: {
|
|
116
|
+
// a: ___cxa_throw
|
|
117
|
+
a: (ptr: number, type: number, destructor: number) => {
|
|
118
|
+
throw new Error('Exception thrown from WASM');
|
|
119
|
+
},
|
|
120
|
+
// e: __abort_js
|
|
121
|
+
e: () => {
|
|
122
|
+
throw new Error('Abort called from WASM');
|
|
123
|
+
},
|
|
124
|
+
// b: __tzset_js
|
|
125
|
+
b: (timezone: number, daylight: number, std_name: number, dst_name: number) => {
|
|
126
|
+
// Minimal timezone implementation
|
|
127
|
+
},
|
|
128
|
+
// f: _emscripten_resize_heap
|
|
129
|
+
f: (requestedSize: number) => {
|
|
130
|
+
const oldSize = HEAPU8.length;
|
|
131
|
+
const newSize = Math.max(oldSize, requestedSize);
|
|
132
|
+
const pages = Math.ceil((newSize - memory.buffer.byteLength) / 65536);
|
|
133
|
+
try {
|
|
134
|
+
memory.grow(pages);
|
|
135
|
+
updateMemoryViews();
|
|
136
|
+
return 1;
|
|
137
|
+
} catch (e) {
|
|
138
|
+
return 0;
|
|
139
|
+
}
|
|
140
|
+
},
|
|
141
|
+
// c: _environ_get
|
|
142
|
+
c: (__environ: number, environ_buf: number) => 0,
|
|
143
|
+
// d: _environ_sizes_get
|
|
144
|
+
d: (penviron_count: number, penviron_buf_size: number) => {
|
|
145
|
+
HEAPU32[penviron_count >> 2] = 0;
|
|
146
|
+
HEAPU32[penviron_buf_size >> 2] = 0;
|
|
147
|
+
return 0;
|
|
148
|
+
},
|
|
149
|
+
// g: memory
|
|
150
|
+
g: memory,
|
|
81
151
|
},
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
const
|
|
152
|
+
};
|
|
153
|
+
|
|
154
|
+
// Instantiate WASM with the expected imports
|
|
155
|
+
const wasmModule = await WebAssembly.instantiate(wasmBytes, wasmImports);
|
|
86
156
|
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
157
|
+
const exports = wasmModule.instance.exports as any;
|
|
158
|
+
|
|
159
|
+
// Update memory reference from exports (g is memory in minified version)
|
|
160
|
+
if (exports.g) {
|
|
161
|
+
updateMemoryViews();
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
// Initialize runtime (h is the init function in minified version)
|
|
165
|
+
if (exports.h) {
|
|
166
|
+
exports.h();
|
|
167
|
+
}
|
|
90
168
|
|
|
91
169
|
// Build the module interface
|
|
92
170
|
const module: TagLibModule = {
|
|
93
171
|
// Memory arrays
|
|
94
|
-
HEAPU8
|
|
95
|
-
HEAP8
|
|
96
|
-
HEAP16
|
|
97
|
-
HEAP32
|
|
98
|
-
HEAPU16
|
|
99
|
-
HEAPU32
|
|
100
|
-
HEAPF32
|
|
101
|
-
HEAPF64
|
|
102
|
-
|
|
103
|
-
// Standard functions
|
|
104
|
-
_malloc: exports.
|
|
172
|
+
HEAPU8,
|
|
173
|
+
HEAP8,
|
|
174
|
+
HEAP16,
|
|
175
|
+
HEAP32,
|
|
176
|
+
HEAPU16,
|
|
177
|
+
HEAPU32,
|
|
178
|
+
HEAPF32,
|
|
179
|
+
HEAPF64,
|
|
180
|
+
|
|
181
|
+
// Standard functions (minified with -O3)
|
|
182
|
+
_malloc: exports.P || (() => {
|
|
105
183
|
throw new Error("malloc not available");
|
|
106
184
|
}),
|
|
107
|
-
_free: exports.
|
|
185
|
+
_free: exports.Q || (() => {}),
|
|
108
186
|
allocate: (array: Uint8Array, type: number) => {
|
|
109
187
|
const ptr = module._malloc(array.length);
|
|
188
|
+
// Ensure we have the latest memory view
|
|
189
|
+
if (memory.buffer !== module.HEAPU8.buffer) {
|
|
190
|
+
updateMemoryViews();
|
|
191
|
+
module.HEAPU8 = HEAPU8;
|
|
192
|
+
module.HEAP8 = HEAP8;
|
|
193
|
+
module.HEAP16 = HEAP16;
|
|
194
|
+
module.HEAP32 = HEAP32;
|
|
195
|
+
module.HEAPU16 = HEAPU16;
|
|
196
|
+
module.HEAPU32 = HEAPU32;
|
|
197
|
+
module.HEAPF32 = HEAPF32;
|
|
198
|
+
module.HEAPF64 = HEAPF64;
|
|
199
|
+
}
|
|
110
200
|
module.HEAPU8.set(array, ptr);
|
|
111
201
|
return ptr;
|
|
112
202
|
},
|
|
@@ -118,33 +208,44 @@ export async function loadTagLibModuleJSR(
|
|
|
118
208
|
ALLOC_DYNAMIC: 3,
|
|
119
209
|
ALLOC_NONE: 4,
|
|
120
210
|
|
|
121
|
-
// TagLib functions - map from WASM exports
|
|
122
|
-
_taglib_file_new_from_buffer: exports.
|
|
123
|
-
_taglib_file_delete: exports.
|
|
124
|
-
_taglib_file_save: exports.
|
|
125
|
-
_taglib_file_is_valid: exports.
|
|
126
|
-
_taglib_file_format: exports.
|
|
127
|
-
_taglib_file_tag: exports.
|
|
128
|
-
_taglib_tag_title: exports.
|
|
129
|
-
_taglib_tag_artist: exports.
|
|
130
|
-
_taglib_tag_album: exports.
|
|
131
|
-
_taglib_tag_comment: exports.
|
|
132
|
-
_taglib_tag_genre: exports.
|
|
133
|
-
_taglib_tag_year: exports.
|
|
134
|
-
_taglib_tag_track: exports.
|
|
135
|
-
_taglib_tag_set_title: exports.
|
|
136
|
-
_taglib_tag_set_artist: exports.
|
|
137
|
-
_taglib_tag_set_album: exports.
|
|
138
|
-
_taglib_tag_set_comment: exports.
|
|
139
|
-
_taglib_tag_set_genre: exports.
|
|
140
|
-
_taglib_tag_set_year: exports.
|
|
141
|
-
_taglib_tag_set_track: exports.
|
|
142
|
-
_taglib_file_audioproperties: exports.
|
|
143
|
-
_taglib_audioproperties_length: exports.
|
|
144
|
-
_taglib_audioproperties_bitrate: exports.
|
|
145
|
-
_taglib_audioproperties_samplerate:
|
|
146
|
-
|
|
147
|
-
|
|
211
|
+
// TagLib functions - map from minified WASM exports (with -O3)
|
|
212
|
+
_taglib_file_new_from_buffer: exports.i,
|
|
213
|
+
_taglib_file_delete: exports.j,
|
|
214
|
+
_taglib_file_save: exports.k,
|
|
215
|
+
_taglib_file_is_valid: exports.l,
|
|
216
|
+
_taglib_file_format: exports.m,
|
|
217
|
+
_taglib_file_tag: exports.n,
|
|
218
|
+
_taglib_tag_title: exports.o,
|
|
219
|
+
_taglib_tag_artist: exports.p,
|
|
220
|
+
_taglib_tag_album: exports.q,
|
|
221
|
+
_taglib_tag_comment: exports.r,
|
|
222
|
+
_taglib_tag_genre: exports.s,
|
|
223
|
+
_taglib_tag_year: exports.t,
|
|
224
|
+
_taglib_tag_track: exports.u,
|
|
225
|
+
_taglib_tag_set_title: exports.v,
|
|
226
|
+
_taglib_tag_set_artist: exports.w,
|
|
227
|
+
_taglib_tag_set_album: exports.x,
|
|
228
|
+
_taglib_tag_set_comment: exports.y,
|
|
229
|
+
_taglib_tag_set_genre: exports.z,
|
|
230
|
+
_taglib_tag_set_year: exports.A,
|
|
231
|
+
_taglib_tag_set_track: exports.B,
|
|
232
|
+
_taglib_file_audioproperties: exports.C,
|
|
233
|
+
_taglib_audioproperties_length: exports.D,
|
|
234
|
+
_taglib_audioproperties_bitrate: exports.E,
|
|
235
|
+
_taglib_audioproperties_samplerate: exports.F,
|
|
236
|
+
_taglib_audioproperties_channels: exports.G,
|
|
237
|
+
|
|
238
|
+
// PropertyMap operations
|
|
239
|
+
_taglib_file_properties_json: exports.H,
|
|
240
|
+
_taglib_file_set_properties_json: exports.I,
|
|
241
|
+
_taglib_file_get_property: exports.J,
|
|
242
|
+
_taglib_file_set_property: exports.K,
|
|
243
|
+
|
|
244
|
+
// MP4-specific operations
|
|
245
|
+
_taglib_file_is_mp4: exports.L,
|
|
246
|
+
_taglib_mp4_get_item: exports.M,
|
|
247
|
+
_taglib_mp4_set_item: exports.N,
|
|
248
|
+
_taglib_mp4_remove_item: exports.O,
|
|
148
249
|
};
|
|
149
250
|
|
|
150
251
|
return module;
|
package/src/wasm.ts
CHANGED
|
@@ -75,6 +75,18 @@ export interface TagLibModule {
|
|
|
75
75
|
_taglib_audioproperties_samplerate: (props: number) => number;
|
|
76
76
|
_taglib_audioproperties_channels: (props: number) => number;
|
|
77
77
|
|
|
78
|
+
// PropertyMap operations
|
|
79
|
+
_taglib_file_properties_json: (fileId: number) => number;
|
|
80
|
+
_taglib_file_set_properties_json: (fileId: number, json: number) => number;
|
|
81
|
+
_taglib_file_get_property: (fileId: number, key: number) => number;
|
|
82
|
+
_taglib_file_set_property: (fileId: number, key: number, value: number) => number;
|
|
83
|
+
|
|
84
|
+
// MP4-specific operations
|
|
85
|
+
_taglib_file_is_mp4: (fileId: number) => number;
|
|
86
|
+
_taglib_mp4_get_item: (fileId: number, key: number) => number;
|
|
87
|
+
_taglib_mp4_set_item: (fileId: number, key: number, value: number) => number;
|
|
88
|
+
_taglib_mp4_remove_item: (fileId: number, key: number) => number;
|
|
89
|
+
|
|
78
90
|
// String utilities
|
|
79
91
|
_taglib_string_new: (str: number) => number;
|
|
80
92
|
_taglib_string_delete: (str: number) => void;
|