11 lines
2.3 KiB
JavaScript
11 lines
2.3 KiB
JavaScript
/**
|
|
* @claude-flow/plugin-gastown-bridge v0.1.3
|
|
*
|
|
* WASM-accelerated Gas Town orchestration for Claude Flow V3
|
|
* Bundle optimized: <100KB gzipped total
|
|
*
|
|
* @license MIT
|
|
* @copyright 2024 rUv
|
|
*/
|
|
var o=null,t=null,r=null,s=null;function _(){return typeof process<"u"&&process.versions?.node?"node":typeof window<"u"?"browser":"edge"}async function b(e,n={}){let{basePath:a="./wasm",preferGzip:u=true,fetch:W=globalThis.fetch,signal:h}=n,k=_(),m=e.replace(/-/g,"_"),M=u?[`${a}/${e}/pkg/${m}_bg.wasm.gz`,`${a}/${e}/pkg/${m}_bg.wasm`]:[`${a}/${e}/pkg/${m}_bg.wasm`,`${a}/${e}/pkg/${m}_bg.wasm.gz`];for(let f of M)try{if(k==="node"){let l=await import('fs'),c=await import('path'),d=await import('zlib'),{promisify:y}=await import('util'),g=c.resolve(f);if(l.existsSync(g)){let i=l.readFileSync(g);if(f.endsWith(".gz")){let p=await y(d.gunzip)(i);return p.buffer.slice(p.byteOffset,p.byteOffset+p.byteLength)}return i.buffer.slice(i.byteOffset,i.byteOffset+i.byteLength)}}else {let l=await W(f,{signal:h});if(l.ok){let c=await l.arrayBuffer();if(f.endsWith(".gz")){if(typeof DecompressionStream<"u"){let d=new Response(c).body;if(d){let y=d.pipeThrough(new DecompressionStream("gzip"));return new Response(y).arrayBuffer()}}throw new Error("Gzip decompression not supported")}return c}}}catch{continue}throw new Error(`Failed to load WASM module: ${e}`)}async function w(e,n={}){let a=await WebAssembly.compile(e),u=await WebAssembly.instantiate(a,n);return {instance:u.exports,memory:u.exports.memory,ready:true}}async function x(e={}){return o?.ready?o:r||(r=(async()=>{try{let n=await b("gastown-formula-wasm",e);return o=await w(n),o}finally{r=null;}})(),r)}async function P(e={}){return t?.ready?t:s||(s=(async()=>{try{let n=await b("ruvector-gnn-wasm",e);return t=await w(n),t}finally{s=null;}})(),s)}async function z(e={}){await Promise.all([x(e),P(e)]);}function A(){return {formula:o?.ready??false,gnn:t?.ready??false,all:(o?.ready??false)&&(t?.ready??false)}}function L(){o=null,t=null,r=null,s=null;}function v(){let e=o?.memory?.buffer.byteLength??0,n=t?.memory?.buffer.byteLength??0;return {formula:o?{pages:e/65536,bytes:e}:null,gnn:t?{pages:n/65536,bytes:n}:null,total:e+n}}export{L as clearWasmCache,v as getWasmMemoryStats,A as isWasmLoaded,x as loadFormulaWasm,P as loadGnnWasm,z as preloadAllWasm};//# sourceMappingURL=wasm-loader.js.map
|
|
//# sourceMappingURL=wasm-loader.js.map
|