@streamoji/aitwin 0.1.4 → 0.1.6
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.
|
@@ -0,0 +1 @@
|
|
|
1
|
+
(function(){"use strict";function G(e,t,n){return{width:e.crop?.source_width??t,height:e.crop?.source_height??n}}function j(e,t){const n=e.crop;return{x:t?.source_x??n?.x??0,y:t?.source_y??n?.y??0,width:t?.source_w??n?.width??e.frame_width??0,height:t?.source_h??n?.height??e.frame_height??0}}function Q(e){return e?(e.w??0)>0&&(e.h??0)>0:!1}function X(e){const t=e.trim();if(t.length%2!==0)throw new Error("Invalid hex key");const n=new Uint8Array(t.length/2);for(let r=0;r<t.length;r+=2)n[r/2]=Number.parseInt(t.slice(r,r+2),16);return n}function I(e){return Uint8Array.from(e)}function Y(e,t){const n=new Uint8Array(e.length+t.length);return n.set(e,0),n.set(t,e.length),n}async function Z(e,t){if(!t)throw new Error("Asset key is required for encrypted assets");if(e.byteLength<28)throw new Error("Encrypted payload too small");const n=new Uint8Array(e),r=I(n.subarray(0,12)),s=I(n.subarray(12,28)),a=I(n.subarray(28)),o=I(Y(a,s)),_=await crypto.subtle.importKey("raw",X(t),{name:"AES-GCM"},!1,["decrypt"]);return crypto.subtle.decrypt({name:"AES-GCM",iv:r,tagLength:128},_,o)}async function B(e,t){const n=await fetch(e);if(!n.ok)throw new Error(`Failed to load encrypted asset: ${e}`);const r=await n.arrayBuffer();return Z(r,t)}async function V(e,t){if(!t)throw new Error("Missing asset key for encrypted JSON");const n=await B(e,t),r=new TextDecoder().decode(n);return JSON.parse(r)}async function tt(e){const t=new Blob([e],{type:"image/webp"});return createImageBitmap(t)}const p=15,O=["t01_0.17","t02_0.33","t03_0.50","t04_0.67","t05_0.83"],et=O.length,H=new Set(["aa__kk","aa__nn","aa__sil","CH__aa","CH__DD","CH__E","CH__FF","CH__I","CH__kk","CH__nn","CH__O","CH__PP","CH__RR","CH__sil","CH__SS","CH__TH","CH__U","DD__aa","DD__E","DD__FF","DD__I","DD__kk","DD__nn","DD__O","DD__PP","DD__RR","DD__sil","DD__SS","DD__TH","DD__U","E__aa","E__FF","E__I","E__kk","E__nn","E__O","E__PP","E__RR","E__sil","E__SS","E__TH","E__U","FF__aa","FF__I","FF__kk","FF__nn","FF__O","FF__PP","FF__RR","FF__sil","FF__SS","FF__TH","FF__U","I__aa","I__kk","I__nn","I__O","I__PP","I__RR","I__sil","I__SS","I__TH","I__U","kk__nn","kk__sil","nn__sil","O__aa","O__kk","O__nn","O__PP","O__RR","O__sil","O__SS","O__TH","O__U","PP__aa","PP__kk","PP__nn","PP__RR","PP__sil","PP__SS","PP__TH","PP__U","RR__aa","RR__kk","RR__nn","RR__sil","RR__SS","RR__TH","RR__U","SS__aa","SS__kk","SS__nn","SS__sil","SS__TH","SS__U","TH__aa","TH__kk","TH__nn","TH__sil","TH__U","U__aa","U__kk","U__nn","U__sil"]);function v(e,t){return`${e}__${t}`}function U(e,t){return`pairs/${e}/${t}_minus_sil.png`}function q(e){return`${e}_minus_sil.png`}function nt(e,t){if(e===t)return[];const n=[],r=v(e,t);if(H.has(r)){for(const a of O)n.push(U(r,a));return n}const s=v(t,e);if(H.has(s)){for(let a=et-1;a>=0;a--)n.push(U(s,O[a]));return n}return[]}function rt(e){return e<16?[]:e<35?[2]:e<51?[0,4]:e<67?[0,2,4]:e<83?[0,1,2,3]:[0,1,2,3,4]}function st(e,t){return rt(t).map(r=>e[r]).filter(r=>r!=null)}function at(e,t,n){if(!n)return`${e}/${t}`;const r=t.split("/").pop()??t,s=r.includes(".")?r.slice(0,r.lastIndexOf(".")):r;return`${e}/${s}.bin`}function ot(e,t,n,r,s=p){const a=new OffscreenCanvas(n,r),o=a.getContext("2d",{willReadFrequently:!0});o.drawImage(e,0,0,n,r);const _=o.getImageData(0,0,n,r),i=o.createImageData(n,r);i.data.set(_.data);const f=new OffscreenCanvas(n,r).getContext("2d",{willReadFrequently:!0});for(const D of t){f.clearRect(0,0,n,r),f.drawImage(D,0,0,n,r);const d=f.getImageData(0,0,n,r);for(let c=0;c<i.data.length;c+=4){const E=d.data[c],P=d.data[c+1],J=d.data[c+2];Math.max(E,P,J)>s&&(i.data[c]=E,i.data[c+1]=P,i.data[c+2]=J,i.data[c+3]=255)}}return o.putImageData(i,0,0),a}const N=-1;function it(e){return e<0}let S=0,L=Promise.resolve();function F(e,t){const n=t>0?-t:N,r={type:"renderDone",requestId:e,generation:n};self.postMessage(r)}async function ct(e){const t=typeof e.liveSeq=="number"?e.liveSeq:0;if(t>0&&(S=t),!u)throw new Error("Worker not initialized");if(t>0&&t!==S){F(e.requestId,t);return}if(await m(w??void 0),t>0&&t!==S){F(e.requestId,t);return}if(await K(u,e.diffPath,e.expressionDiffPath??null,e.threshold??p),t>0&&t!==S){F(e.requestId,t);return}const n=t>0?-t:N;await $(n),F(e.requestId,t)}let u=null,y=null,w=null,M=null,b="sil";const k=new Map;function g(){if(!M)throw new Error("Worker assets not configured");return M}function _t(){return`${g().twinBase}/sil.png`}function lt(){const e=g();return e.encrypted?`${e.binBase}/atlas.bin`:`${e.twinBase}/atlas.json`}function ft(){const e=g();return e.encrypted?`${e.binBase}/expression_atlas.bin`:`${e.twinBase}/expression_atlas.json`}function ut(){const e=g();return e.encrypted?e.binBase:e.twinBase}function x(){return g().encrypted}async function C(e){const t=await fetch(e);if(!t.ok)throw new Error(`Failed to load image: ${e}`);const n=await t.blob();return createImageBitmap(n)}async function W(e,t,n){const r=x(),s=r?await V(e,n):await fetch(e).then(l=>{if(!l.ok)throw new Error(`Failed to load ${e}`);return l.json()}),a=s.sheets?.[0];if(!a?.path)throw new Error(`${e} has no sheets[0].path`);const o=r?await tt(await B(at(t,a.path,r),n??"")):await C(`${t}/${a.path}`),_=new Map;for(const l of s.cells??[])l.path&&_.set(l.path,l);const i=new Map;for(const l of s.sheets??[])i.set(l.index,l);return{atlas:o,atlasMeta:s,cellByPath:_,sheetByIndex:i,diffBase:t}}async function m(e){if(x()&&!e)throw new Error("Encrypted assets enabled but no key provided");if(y&&(!x()||w===(e??null)))return y;w=e??null,k.clear();const t=ut();return y=(async()=>{const n=await C(_t()),r=await W(lt(),t,e);let s=null;try{s=await W(ft(),t,e)}catch{s=null}return{sil:n,viseme:r,expression:s}})(),y}function R(e){return G(e.viseme.atlasMeta,e.sil.width,e.sil.height)}function dt(e,t){if(!e.sheetByIndex.get(t.sheet??0))throw new Error(`Unknown sheet index: ${t.sheet}`);const r=new OffscreenCanvas(t.w,t.h);return r.getContext("2d",{willReadFrequently:!0}).drawImage(e.atlas,t.x,t.y,t.w,t.h,0,0,t.w,t.h),r}async function wt(e){return createImageBitmap(e)}async function z(e,t,n){const r=`${t.diffBase}::${n}`,s=k.get(r);if(s)return s;const a=(async()=>{const o=t.cellByPath.get(n);if(!o)throw new Error(`No atlas cell for path: ${n}`);const _=j(t.atlasMeta,o),i=R(e);if(Q(o)){const D=dt(t,o),d=new OffscreenCanvas(i.width,i.height),c=d.getContext("2d");return c.fillStyle="#000",c.fillRect(0,0,i.width,i.height),c.drawImage(D,_.x,_.y),wt(d)}const l=`${t.diffBase}/${n}`,f=await C(l);if(f.width===i.width&&f.height===i.height)return f;throw f.close(),new Error(`Diff PNG wrong size for ${n}`)})();return k.set(r,a),a}function A(e,t){const n={type:"status",label:e,generation:t};self.postMessage(n)}function ht(e,t){const n={type:"error",requestId:e,message:t};self.postMessage(n)}async function $(e){if(!u)return;const t=it(e);if(!t&&e!==h)return;const n=await createImageBitmap(u);if(!t&&e!==h){n.close();return}const r={type:"frame",bitmap:n,generation:e};self.postMessage(r,{transfer:[n]})}function pt(e,t,n){return new Promise((r,s)=>{setTimeout(()=>{t!==n?s(new DOMException("Aborted","AbortError")):r()},e)})}async function K(e,t,n,r=p){const s=await m(w??void 0),{width:a,height:o}=R(s);(e.width!==a||e.height!==o)&&(e.width=a,e.height=o);const _=[];if(t){if(!s.viseme.cellByPath.get(t))throw new Error(`No viseme atlas cell for path: ${t}`);_.push(await z(s,s.viseme,t))}if(n&&s.expression){if(!s.expression.cellByPath.get(n))throw new Error(`No expression atlas cell for path: ${n}`);_.push(await z(s,s.expression,n))}const i=e.getContext("2d");if(i.clearRect(0,0,a,o),_.length===0){i.drawImage(s.sil,0,0,a,o);return}const l=ot(s.sil,_,a,o,r);i.drawImage(l,0,0)}async function T(e,t,n,r,s=p){await K(e,t,n,s),await $(r)}async function yt(e,t,n){b="sil";const r=await m(w??void 0);if(t!==n)throw new DOMException("Aborted","AbortError");const{width:s,height:a}=R(r);e.width=s,e.height=a;const o=e.getContext("2d");o.clearRect(0,0,s,a),o.drawImage(r.sil,0,0,s,a),await $(t)}async function gt(e,t,n,r,s={}){const a=s.from??b,o=s.transitionDurationMs??400,_=s.gapMs??o,i=s.threshold??p;if(await m(w??void 0),a===t){if(A(t,n),await T(e,q(t),null,n,i),n!==r)throw new DOMException("Aborted","AbortError");b=t;return}const l=nt(a,t),f=st(l,_),D=q(t),d=f.length>0?o/f.length:0;f.length===0&&A(`${a} → ${t} (no pair; final only)`,n);for(let c=0;c<f.length;c++){if(n!==r)throw new DOMException("Aborted","AbortError");const E=f[c],P=E.split("/").pop()?.replace("_minus_sil.png","")??`frame ${c}`;if(A(`${a} → ${t} (${P})`,n),await T(e,E,null,n,i),n!==r)throw new DOMException("Aborted","AbortError");d>0&&await pt(d,n,r)}if(n!==r)throw new DOMException("Aborted","AbortError");if(A(t,n),await T(e,D,null,n,i),n!==r)throw new DOMException("Aborted","AbortError");b=t}let h=0;self.onmessage=e=>{const t=e.data;(async()=>{try{switch(t.type){case"init":{u=new OffscreenCanvas(1,1);const n={type:"ready",requestId:t.requestId};self.postMessage(n);break}case"loadAssets":{M=t.urls,y=null,w=null,k.clear();const n=await m(t.keyHex),{width:r,height:s}=R(n),a={type:"loadAssetsDone",requestId:t.requestId,width:r,height:s};self.postMessage(a);break}case"drawFrame":{await new Promise((n,r)=>{L=L.then(()=>ct(t)).then(n).catch(r)});break}case"renderSil":{if(h=t.generation,!u)throw new Error("Worker not initialized");await yt(u,t.generation,h);const n={type:"renderDone",requestId:t.requestId,generation:t.generation};self.postMessage(n);break}case"renderViseme":{if(h=t.generation,!u)throw new Error("Worker not initialized");await gt(u,t.to,t.generation,h,{from:t.from,transitionDurationMs:t.transitionDurationMs,gapMs:t.gapMs,threshold:t.threshold});const n={type:"renderDone",requestId:t.requestId,generation:t.generation};self.postMessage(n);break}default:break}}catch(n){if(n instanceof DOMException&&n.name==="AbortError"){const r={type:"renderAborted",requestId:t.requestId,generation:"generation"in t?t.generation:h};self.postMessage(r);return}ht(t.requestId,n instanceof Error?n.message:String(n))}})()}})();
|
package/package.json
CHANGED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
(function(){"use strict";function K(e,t,n){return{width:e.crop?.source_width??t,height:e.crop?.source_height??n}}function J(e,t){const n=e.crop;return{x:t?.source_x??n?.x??0,y:t?.source_y??n?.y??0,width:t?.source_w??n?.width??e.frame_width??0,height:t?.source_h??n?.height??e.frame_height??0}}function L(e){return e?(e.w??0)>0&&(e.h??0)>0:!1}function G(e){const t=e.trim();if(t.length%2!==0)throw new Error("Invalid hex key");const n=new Uint8Array(t.length/2);for(let r=0;r<t.length;r+=2)n[r/2]=Number.parseInt(t.slice(r,r+2),16);return n}function I(e){return Uint8Array.from(e)}function j(e,t){const n=new Uint8Array(e.length+t.length);return n.set(e,0),n.set(t,e.length),n}async function Q(e,t){if(!t)throw new Error("Asset key is required for encrypted assets");if(e.byteLength<28)throw new Error("Encrypted payload too small");const n=new Uint8Array(e),r=I(n.subarray(0,12)),s=I(n.subarray(12,28)),a=I(n.subarray(28)),o=I(j(a,s)),_=await crypto.subtle.importKey("raw",G(t),{name:"AES-GCM"},!1,["decrypt"]);return crypto.subtle.decrypt({name:"AES-GCM",iv:r,tagLength:128},_,o)}async function T(e,t){const n=await fetch(e);if(!n.ok)throw new Error(`Failed to load encrypted asset: ${e}`);const r=await n.arrayBuffer();return Q(r,t)}async function X(e,t){if(!t)throw new Error("Missing asset key for encrypted JSON");const n=await T(e,t),r=new TextDecoder().decode(n);return JSON.parse(r)}async function Y(e){const t=new Blob([e],{type:"image/webp"});return createImageBitmap(t)}const p=15,P=["t01_0.17","t02_0.33","t03_0.50","t04_0.67","t05_0.83"],Z=P.length,B=new Set(["aa__kk","aa__nn","aa__sil","CH__aa","CH__DD","CH__E","CH__FF","CH__I","CH__kk","CH__nn","CH__O","CH__PP","CH__RR","CH__sil","CH__SS","CH__TH","CH__U","DD__aa","DD__E","DD__FF","DD__I","DD__kk","DD__nn","DD__O","DD__PP","DD__RR","DD__sil","DD__SS","DD__TH","DD__U","E__aa","E__FF","E__I","E__kk","E__nn","E__O","E__PP","E__RR","E__sil","E__SS","E__TH","E__U","FF__aa","FF__I","FF__kk","FF__nn","FF__O","FF__PP","FF__RR","FF__sil","FF__SS","FF__TH","FF__U","I__aa","I__kk","I__nn","I__O","I__PP","I__RR","I__sil","I__SS","I__TH","I__U","kk__nn","kk__sil","nn__sil","O__aa","O__kk","O__nn","O__PP","O__RR","O__sil","O__SS","O__TH","O__U","PP__aa","PP__kk","PP__nn","PP__RR","PP__sil","PP__SS","PP__TH","PP__U","RR__aa","RR__kk","RR__nn","RR__sil","RR__SS","RR__TH","RR__U","SS__aa","SS__kk","SS__nn","SS__sil","SS__TH","SS__U","TH__aa","TH__kk","TH__nn","TH__sil","TH__U","U__aa","U__kk","U__nn","U__sil"]);function H(e,t){return`${e}__${t}`}function U(e,t){return`pairs/${e}/${t}_minus_sil.png`}function q(e){return`${e}_minus_sil.png`}function V(e,t){if(e===t)return[];const n=[],r=H(e,t);if(B.has(r)){for(const a of P)n.push(U(r,a));return n}const s=H(t,e);if(B.has(s)){for(let a=Z-1;a>=0;a--)n.push(U(s,P[a]));return n}return[]}function tt(e){return e<16?[]:e<35?[2]:e<51?[0,4]:e<67?[0,2,4]:e<83?[0,1,2,3]:[0,1,2,3,4]}function et(e,t){return tt(t).map(r=>e[r]).filter(r=>r!=null)}function nt(e,t,n){if(!n)return`${e}/${t}`;const r=t.split("/").pop()??t,s=r.includes(".")?r.slice(0,r.lastIndexOf(".")):r;return`${e}/${s}.bin`}function rt(e,t,n,r,s=p){const a=new OffscreenCanvas(n,r),o=a.getContext("2d",{willReadFrequently:!0});o.drawImage(e,0,0,n,r);const _=o.getImageData(0,0,n,r),i=o.createImageData(n,r);i.data.set(_.data);const f=new OffscreenCanvas(n,r).getContext("2d",{willReadFrequently:!0});for(const E of t){f.clearRect(0,0,n,r),f.drawImage(E,0,0,n,r);const d=f.getImageData(0,0,n,r);for(let c=0;c<i.data.length;c+=4){const D=d.data[c],R=d.data[c+1],z=d.data[c+2];Math.max(D,R,z)>s&&(i.data[c]=D,i.data[c+1]=R,i.data[c+2]=z,i.data[c+3]=255)}}return o.putImageData(i,0,0),a}const S=-1;let u=null,y=null,w=null,O=null,F="sil";const b=new Map;function g(){if(!O)throw new Error("Worker assets not configured");return O}function st(){return`${g().twinBase}/sil.png`}function at(){const e=g();return e.encrypted?`${e.binBase}/atlas.bin`:`${e.twinBase}/atlas.json`}function ot(){const e=g();return e.encrypted?`${e.binBase}/expression_atlas.bin`:`${e.twinBase}/expression_atlas.json`}function it(){const e=g();return e.encrypted?e.binBase:e.twinBase}function M(){return g().encrypted}async function x(e){const t=await fetch(e);if(!t.ok)throw new Error(`Failed to load image: ${e}`);const n=await t.blob();return createImageBitmap(n)}async function v(e,t,n){const r=M(),s=r?await X(e,n):await fetch(e).then(l=>{if(!l.ok)throw new Error(`Failed to load ${e}`);return l.json()}),a=s.sheets?.[0];if(!a?.path)throw new Error(`${e} has no sheets[0].path`);const o=r?await Y(await T(nt(t,a.path,r),n??"")):await x(`${t}/${a.path}`),_=new Map;for(const l of s.cells??[])l.path&&_.set(l.path,l);const i=new Map;for(const l of s.sheets??[])i.set(l.index,l);return{atlas:o,atlasMeta:s,cellByPath:_,sheetByIndex:i,diffBase:t}}async function m(e){if(M()&&!e)throw new Error("Encrypted assets enabled but no key provided");if(y&&(!M()||w===(e??null)))return y;w=e??null,b.clear();const t=it();return y=(async()=>{const n=await x(st()),r=await v(at(),t,e);let s=null;try{s=await v(ot(),t,e)}catch{s=null}return{sil:n,viseme:r,expression:s}})(),y}function k(e){return K(e.viseme.atlasMeta,e.sil.width,e.sil.height)}function ct(e,t){if(!e.sheetByIndex.get(t.sheet??0))throw new Error(`Unknown sheet index: ${t.sheet}`);const r=new OffscreenCanvas(t.w,t.h);return r.getContext("2d",{willReadFrequently:!0}).drawImage(e.atlas,t.x,t.y,t.w,t.h,0,0,t.w,t.h),r}async function _t(e){return createImageBitmap(e)}async function N(e,t,n){const r=`${t.diffBase}::${n}`,s=b.get(r);if(s)return s;const a=(async()=>{const o=t.cellByPath.get(n);if(!o)throw new Error(`No atlas cell for path: ${n}`);const _=J(t.atlasMeta,o),i=k(e);if(L(o)){const E=ct(t,o),d=new OffscreenCanvas(i.width,i.height),c=d.getContext("2d");return c.fillStyle="#000",c.fillRect(0,0,i.width,i.height),c.drawImage(E,_.x,_.y),_t(d)}const l=`${t.diffBase}/${n}`,f=await x(l);if(f.width===i.width&&f.height===i.height)return f;throw f.close(),new Error(`Diff PNG wrong size for ${n}`)})();return b.set(r,a),a}function A(e,t){const n={type:"status",label:e,generation:t};self.postMessage(n)}function lt(e,t){const n={type:"error",requestId:e,message:t};self.postMessage(n)}async function C(e){if(!u||e!==S&&e!==h)return;const t=await createImageBitmap(u);if(e!==S&&e!==h){t.close();return}const n={type:"frame",bitmap:t,generation:e};self.postMessage(n,{transfer:[t]})}function ft(e,t,n){return new Promise((r,s)=>{setTimeout(()=>{t!==n?s(new DOMException("Aborted","AbortError")):r()},e)})}async function W(e,t,n,r=p){const s=await m(w??void 0),{width:a,height:o}=k(s);(e.width!==a||e.height!==o)&&(e.width=a,e.height=o);const _=[];if(t){if(!s.viseme.cellByPath.get(t))throw new Error(`No viseme atlas cell for path: ${t}`);_.push(await N(s,s.viseme,t))}if(n&&s.expression){if(!s.expression.cellByPath.get(n))throw new Error(`No expression atlas cell for path: ${n}`);_.push(await N(s,s.expression,n))}const i=e.getContext("2d");if(i.clearRect(0,0,a,o),_.length===0){i.drawImage(s.sil,0,0,a,o);return}const l=rt(s.sil,_,a,o,r);i.drawImage(l,0,0)}async function $(e,t,n,r,s=p){await W(e,t,n,s),await C(r)}async function ut(e,t,n){F="sil";const r=await m(w??void 0);if(t!==n)throw new DOMException("Aborted","AbortError");const{width:s,height:a}=k(r);e.width=s,e.height=a;const o=e.getContext("2d");o.clearRect(0,0,s,a),o.drawImage(r.sil,0,0,s,a),await C(t)}async function dt(e,t,n,r,s={}){const a=s.from??F,o=s.transitionDurationMs??400,_=s.gapMs??o,i=s.threshold??p;if(await m(w??void 0),a===t){if(A(t,n),await $(e,q(t),null,n,i),n!==r)throw new DOMException("Aborted","AbortError");F=t;return}const l=V(a,t),f=et(l,_),E=q(t),d=f.length>0?o/f.length:0;f.length===0&&A(`${a} → ${t} (no pair; final only)`,n);for(let c=0;c<f.length;c++){if(n!==r)throw new DOMException("Aborted","AbortError");const D=f[c],R=D.split("/").pop()?.replace("_minus_sil.png","")??`frame ${c}`;if(A(`${a} → ${t} (${R})`,n),await $(e,D,null,n,i),n!==r)throw new DOMException("Aborted","AbortError");d>0&&await ft(d,n,r)}if(n!==r)throw new DOMException("Aborted","AbortError");if(A(t,n),await $(e,E,null,n,i),n!==r)throw new DOMException("Aborted","AbortError");F=t}let h=0;self.onmessage=e=>{const t=e.data;(async()=>{try{switch(t.type){case"init":{u=new OffscreenCanvas(1,1);const n={type:"ready",requestId:t.requestId};self.postMessage(n);break}case"loadAssets":{O=t.urls,y=null,w=null,b.clear();const n=await m(t.keyHex),{width:r,height:s}=k(n),a={type:"loadAssetsDone",requestId:t.requestId,width:r,height:s};self.postMessage(a);break}case"drawFrame":{if(!u)throw new Error("Worker not initialized");await m(w??void 0),await W(u,t.diffPath,t.expressionDiffPath??null,t.threshold??p),await C(S);const n={type:"renderDone",requestId:t.requestId,generation:S};self.postMessage(n);break}case"renderSil":{if(h=t.generation,!u)throw new Error("Worker not initialized");await ut(u,t.generation,h);const n={type:"renderDone",requestId:t.requestId,generation:t.generation};self.postMessage(n);break}case"renderViseme":{if(h=t.generation,!u)throw new Error("Worker not initialized");await dt(u,t.to,t.generation,h,{from:t.from,transitionDurationMs:t.transitionDurationMs,gapMs:t.gapMs,threshold:t.threshold});const n={type:"renderDone",requestId:t.requestId,generation:t.generation};self.postMessage(n);break}default:break}}catch(n){if(n instanceof DOMException&&n.name==="AbortError"){const r={type:"renderAborted",requestId:t.requestId,generation:"generation"in t?t.generation:h};self.postMessage(r);return}lt(t.requestId,n instanceof Error?n.message:String(n))}})()}})();
|