@graphty/cytoscape-extensions 0.0.29 → 0.0.30
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cdn/chunks/{elements-DkrLtNP8.js → elements-DIunzJUl.js} +1 -1
- package/dist/cdn/chunks/{gpu-platform-browser-VBah74fl.js → gpu-platform-browser-DnQwf3s0.js} +1 -1
- package/dist/cdn/chunks/{index-CAhmhhmb.js → index-C-jUF_Ve.js} +1 -1
- package/dist/cdn/chunks/io-D-Vr0j3W.js +269 -0
- package/dist/cdn/chunks/{preload-helper-DEpZAvig.js → preload-helper-Crt_PPe8.js} +1 -1
- package/dist/cdn/chunks/{samples-BkLzaDJ3.js → samples-Dja23zzq.js} +1 -1
- package/dist/cdn/chunks/{sigv4-EokFic1V-CWJiFeEe.js → sigv4-BXwVbza3-DZCCNyQA.js} +1 -1
- package/dist/cdn/chunks/sources-cypher-oj3S6pKb.js +5 -0
- package/dist/cdn/chunks/{sources-ndex-CxnPOYff.js → sources-ndex-BgZhxHsL.js} +1 -1
- package/dist/cdn/chunks/{sources-rest-BPNV8mX-.js → sources-rest-E6On5P3z.js} +1 -1
- package/dist/cdn/chunks/sources-sparql-BAxh1dw-.js +5 -0
- package/dist/cdn/cytoscape-extensions.js +1 -1
- package/dist/cdn/io.js +1 -1
- package/dist/cytoscape-extensions.bundle.js +1 -1
- package/package.json +7 -7
- package/dist/cdn/chunks/io-Da5POp5D.js +0 -268
- package/dist/cdn/chunks/sources-cypher-BGGD4kJ9.js +0 -5
- package/dist/cdn/chunks/sources-sparql-BiqRQuHD.js +0 -5
|
@@ -1 +1 @@
|
|
|
1
|
-
import{f as F}from"./preload-helper-
|
|
1
|
+
import{f as F}from"./preload-helper-Crt_PPe8.js";function S(e){return e===0?0:-e}function C(e){return e.pxPerUnit===void 0||e.pxPerUnitY===void 0?1:e.pxPerUnitY/e.pxPerUnit}function M(e,t,n,o){e[1]*=C(t),t.anchor==="top-left"&&n!==null&&(e[0]+=n[0]/2,e[1]+=t.yAxis==="down"?n[1]/2:-n[1]/2),e[2]=o?e[2]-(t.zOrigin??0):0,t.yAxis==="down"&&(e[1]=S(e[1]),e[2]=S(e[2]))}function N(e,t,n){const o=new Float64Array(e.length),r=t.yAxis==="down",i=C(t);for(let s=0;s<e.length;s+=3){let l=e[s+1]/i,u=e[s+2];r&&(l=S(l),u=S(u)),o[s]=e[s],o[s+1]=l,o[s+2]=u===0&&t.sourceDims!==3?0:u+(t.zOrigin??0);const f=s/3;t.anchor==="top-left"&&n!==void 0&&(o[s]-=n.width[f]/2,o[s+1]-=r?n.height[f]/2:-n.height[f]/2)}return o}function V(e){if(e.length===0)return null;e.sort((n,o)=>n-o);const t=e.length>>1;return e.length%2===1?e[t]:(e[t-1]+e[t])/2}const O={gml:{yAxis:"down"},pajek:{yAxis:"down",zOrigin:.5}};function P(e,t){const n=O[e];return n===void 0?t:N(t,n)}const A=new Set(["id","source","target","parent","__proto__"]);function k(e){return ArrayBuffer.isView(e)?Array.from(e):e}function x(e){return e===0?0:-e}function q(e,t,n,o=!1){const r=[];for(let s=0;s<e.nodeCount;s++)r.push(String(e.ids.idOf(s)));const i=o?s=>b(s)&&!_(s):b;return[...I(e,r,t,i),...R(e,r,t,n,i)]}function b(e){return e.meta.role!=="id"&&e.meta.role!=="parent"}const U=new Set(["color","size","shape","thickness"]);function _(e){const{role:t,name:n,origin:o}=e.meta;return t!==null&&U.has(t)||n==="shape.uri"&&o?.namespace==="viz"}function T(e,t,n){const o=new Set([...A,...e.map(i=>i.meta.name)]),r=new Map;for(const i of e){const s=i.meta.name;if(!A.has(s)){r.set(i,s);continue}const l=i.meta.origin?.id??null,u=l===null?s:`${s}#${l}`;let f=u;if(l===null||o.has(u)){let a=2;for(;o.has(`${u}#${a}`);)a++;f=`${u}#${a}`}o.add(f),r.set(i,f),n?.({domain:t,from:s,to:f})}return r}function $(e,t,n){const o={};for(const r of e)r.isSet(t)&&(o[n(r)]=k(r.value(t)));return o}function I(e,t,n,o){const r=[...e.nodes].filter(o),i=r.find(a=>a.meta.role==="position"&&a.meta.components>=2),s=r.filter(a=>a!==i),l=T(s,"node",n),u=e.nodes.byRole("parent"),f=[];for(let a=0;a<e.nodeCount;a++){const p=$(s,a,g=>l.get(g)??g.meta.name);p.id=t[a];const m=u?.isSet(a)===!0?u.value(a):void 0;typeof m=="number"&&m!==a&&m<t.length&&(p.parent=t[m]);const h={group:"nodes",data:p},c=i?.isSet(a)===!0?i.value(a):void 0;c!==void 0&&Number.isFinite(c[0])&&Number.isFinite(c[1])&&(h.position={x:c[0],y:c[1]}),f.push(h)}return f}function R(e,t,n,o,r){const i=[...e.edges].filter(r),s=i.some(c=>c.meta.name==="weight"),l=i.find(c=>c.meta.role==="weight"),u=T(i,"edge",n),f=c=>c===l&&!s?"weight":u.get(c)??c.meta.name,a=e.edges.byRole("id"),p=new Set(t),m=new Set,h=[];for(let c=0;c<e.edgeCount;c++){const g=$(i,c,f);l===void 0&&!s&&e.weights!==null&&(g.weight=e.weights[e.edgeToArc[c]]);const y=a?.isSet(c)===!0?Y(String(a.value(c)),p,m,o):void 0;y!==void 0&&(g.id=y),g.source=t[e.edgeSource(c)],g.target=t[e.edgeTarget(c)],h.push({group:"edges",data:g})}return h}function Y(e,t,n,o){if(t.has(e)||n.has(e)){o?.(e,t.has(e)?"node":"edge");return}return n.add(e),e}function D(e,t){const n=e.filter(i=>i!=null);if(n.length===0)return;const o=e.map(i=>i===void 0?null:i),r=i=>n.every(i);return r(i=>typeof i=="number")?{data:o,decl:{dtype:"f64"}}:r(i=>typeof i=="boolean")?{data:o,decl:{dtype:"bool"}}:r(i=>typeof i=="string")?{data:o,decl:{dtype:"string",...t?{role:"label"}:{}}}:{data:e.map(i=>i??void 0),decl:{dtype:"json"}}}function v(e){const t=new Set;for(const o of e)for(const r of Object.keys(o))A.has(r)||t.add(r);const n={};for(const o of t){const r=D(e.map(i=>i[o]),o==="label");r!==void 0&&(n[o]=r)}return n}function L(e){const t=new Set(e.nodes().map(n=>n.id()));return e.edges().filter(n=>t.has(n.source().id())&&t.has(n.target().id()))}function z(e,t={}){const n=e.nodes(),o=new Map,r=n.map((d,w)=>(o.set(d.id(),w),d.id())),s=t.integerIds===!0&&r.every(d=>/^(?:0|[1-9]\d{0,14})$/.test(d))?r.map(Number):r,l=L(e),u=new Uint32Array(l.length),f=new Uint32Array(l.length);l.forEach((d,w)=>{u[w]=o.get(d.source().id())??0,f[w]=o.get(d.target().id())??0});const a=new Float64Array(n.length*3);n.forEach((d,w)=>{const E=d.position();a[3*w]=E.x,a[3*w+1]=x(E.y)});const p=t.format===void 0?a:P(t.format,a),m=new Float64Array(n.length*2);for(let d=0;d<n.length;d++)m[2*d]=p[3*d],m[2*d+1]=p[3*d+1];const h=n.map(d=>o.get(d.parent().first().id())??null),c=v(l.map(d=>d.data()));let g;const y=c.weight;return y?.decl.dtype==="f64"&&y.data.every(d=>d!==null)&&(g=Float64Array.from(y.data),delete c.weight),F({directed:t.directed??!1,ids:s,src:u,dst:f,weights:g,nodeColumns:{...v(n.map(d=>d.data())),position:{data:m,decl:{dtype:"f64",components:2,role:"position"}},...h.some(d=>d!==null)?{parent:{data:h,decl:{dtype:"u32",role:"parent",refersTo:"node"}}}:{}},edgeColumns:{...c,id:{data:l.map(d=>d.id()),decl:{dtype:"string",role:"id",unique:!0}}}})}export{N as a,x as b,L as c,z as e,S as f,V as m,q as s,M as t};
|
package/dist/cdn/chunks/{gpu-platform-browser-VBah74fl.js → gpu-platform-browser-DnQwf3s0.js}
RENAMED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{I as dt,d as _n,u as No,b as Bo,m as oi,q as $o}from"./preload-helper-DEpZAvig.js";import{a as ai}from"./index-CAhmhhmb.js";const Os=256,Ct=65535,Zr=Ct*Os,ye=4294967295,kr=256,Mt=64,Ar=256,Ye=256,Pn=32768,Co=3,Mo=256,Sn=16*1024*1024,Go=4,zo=4*1024,Fo=64*1024*1024,ci=16*1024*1024,li=2,Fe=256,qt=32,He=256,ui=64,At=Object.freeze({maxIter:100,jitterTolerance:1,scalingRatio:2,gravity:1,strongGravity:!1,distributedAction:!1,linlog:!1,dissuadeHubs:!1,dim:2,scale:1,settleThreshold:.001,settleWindow:10,iterationsPerStep:1,maxInFlight:2}),mt=Object.freeze({repulsion:"auto",exactMaxNodes:Pn,nearMax:64,deterministic:!0,gridMax2D:512,gridMax3D:128,extentFactor:6,compat:"paper"}),Wo=.01,Uo=1e-4,Vo=1e-8,En=128,ys=1,In=2,yr=.1,jo=.7,qo=.9,Ko=5,Ho=1e4,Yo=Object.freeze({k:null,iterations:50,fixed:null,dim:2,scale:1,settleThreshold:.001,settleWindow:10,iterationsPerStep:1,maxInFlight:2,cooling:"linear"}),Xo=300,_s=Object.freeze({springLength:10,springCoefficient:.8,gravity:-12,dragCoefficient:.9,timeStep:.5,dim:2,scale:1,settleThreshold:.001,settleWindow:10,iterationsPerStep:1,maxInFlight:2}),kn=Object.freeze({springElectrical:.003,fruchtermanReingold:.002}),Qo=2e3,Zo=2**128-2**104,di=8,fi=4,An=1024,xn=1e-6,Rn=1.01,Jo=24,ue=32,ea=4096,ta=2,ra=24,sa=32,Gt=2139095040,ia=.25,na=256,oa=2,aa=100,ca=256,Sr=64,Ns=32,la=4096,hi=8,It=4,ua=2147483648,da=32,Jr=128,es=65e3,Ln=2,fa=32,ha=Object.freeze({});class h extends Error{constructor(e,t,s){super(t),this.name="WebGpuGraphError",this.code=e,this.details=s===void 0?ha:Object.freeze({...s})}}function Nt(r){if(typeof r!="object"||r===null)return!1;const e=r;return e.name==="WebGpuGraphError"&&typeof e.code=="string"}function Er(r,e){return Nt(r)&&r.code===e}const pi=Object.freeze(["maxBufferSize","maxStorageBufferBindingSize","maxStorageBuffersPerShaderStage","maxComputeWorkgroupStorageSize","maxComputeInvocationsPerWorkgroup","maxComputeWorkgroupSizeX"]),pa=["maxTextureDimension1D","maxTextureDimension2D","maxTextureDimension3D","maxTextureArrayLayers","maxBindGroups","maxBindGroupsPlusVertexBuffers","maxBindingsPerBindGroup","maxDynamicUniformBuffersPerPipelineLayout","maxDynamicStorageBuffersPerPipelineLayout","maxSampledTexturesPerShaderStage","maxSamplersPerShaderStage","maxStorageBuffersPerShaderStage","maxStorageBuffersInVertexStage","maxStorageBuffersInFragmentStage","maxStorageTexturesPerShaderStage","maxStorageTexturesInVertexStage","maxStorageTexturesInFragmentStage","maxUniformBuffersPerShaderStage","maxUniformBufferBindingSize","maxStorageBufferBindingSize","minUniformBufferOffsetAlignment","minStorageBufferOffsetAlignment","maxVertexBuffers","maxBufferSize","maxVertexAttributes","maxVertexBufferArrayStride","maxInterStageShaderVariables","maxColorAttachments","maxColorAttachmentBytesPerSample","maxComputeWorkgroupStorageSize","maxComputeInvocationsPerWorkgroup","maxComputeWorkgroupSizeX","maxComputeWorkgroupSizeY","maxComputeWorkgroupSizeZ","maxComputeWorkgroupsPerDimension","maxImmediateSize"],gi=new WeakSet;function Dn(r){return r instanceof Error?r.message:String(r)}function Tn(r){return r.architecture==="software"||r.architecture==="swiftshader"||r.architecture==="warp"||r.isFallbackAdapter===!0}function Kt(r){const{info:e}=r,t=r.limits,s={};for(const i of pa){const n=t[i];typeof n=="number"&&(s[i]=n)}return Object.freeze({vendor:e.vendor,architecture:e.architecture,device:e.device,description:e.description,software:Tn(e),subgroupMinSize:e.subgroupMinSize??0,subgroupMaxSize:e.subgroupMaxSize??0,features:Object.freeze(Array.from(r.features).sort()),limits:Object.freeze(s)})}async function On(r,e){let t;try{t=await r.requestAdapter({powerPreference:e})}catch(s){const i=`requestAdapter() threw: ${Dn(s)}`;throw new h("E_NO_ADAPTER",i,{reason:i})}if(t===null){const s="requestAdapter() returned null: no usable WebGPU adapter";throw new h("E_NO_ADAPTER",s,{reason:s})}return t}function ga(r,e){const t={};if(e==="default")return t;if(e==="raise"){for(const s of pi)t[s]=r.limits[s];return t}for(const s of pi){const i=e[s];if(i===void 0)continue;const n=r.limits[s];if(i>n)throw new h("E_NO_DEVICE",`requested ${s} = ${i} exceeds the adapter's ${n}`,{reason:"limit",adapter:Kt(r),limit:s,requested:i,available:n});t[s]=i}return t}function ma(r,e,t){const s=[];for(const i of e){if(!r.features.has(i))throw new h("E_NO_DEVICE",`required feature "${i}" is not supported by the adapter`,{reason:"feature",adapter:Kt(r),requested:i});s.includes(i)||s.push(i)}for(const i of t)r.features.has(i)&&!s.includes(i)&&s.push(i);return s}function mi(r,e){return new h("E_NO_DEVICE",`the adapter already created a device (an adapter is consumed by one requestDevice, spec 2.2 step 1): ${e}`,{reason:"consumed",adapter:Kt(r)})}async function wa(r,e){if(gi.has(r))throw mi(r,"recorded by this package");let t;try{t=await r.requestDevice(e)}catch(s){const i=Dn(s);throw/consumed|already been used/i.test(i)?mi(r,i):new h("E_NO_DEVICE",`requestDevice() rejected: ${i}`,{reason:"requestDevice",adapter:Kt(r)})}return gi.add(r),t}function ba(r,e,t,s){const i=new Set(r.features),n=i.has("subgroups");return{limits:r.limits,features:i,wgslFeatures:new Set(s),subgroupMinSize:n?e.subgroupMinSize??0:0,subgroupMaxSize:n?e.subgroupMaxSize??0:0,software:Tn(e),runtime:t,vendor:e.vendor,architecture:e.architecture,device:e.device,description:e.description}}function wi(r,e){const t=new Set(r.features),s=t.has("subgroups");return{limits:r.limits,features:t,wgslFeatures:e?.wgslFeatures??new Set,subgroupMinSize:s?e?.subgroupMinSize??0:0,subgroupMaxSize:s?e?.subgroupMaxSize??0:0,software:e?.software??!1,runtime:e?.runtime??"unknown",vendor:e?.vendor??"",architecture:e?.architecture??"",device:e?.device??"",description:e?.description??""}}function Bs(r){const e=Math.min(Os,r.limits.maxComputeInvocationsPerWorkgroup);let t=1;for(;t*2<=e;)t*=2;return t}function ts(r){const e=r.limits.maxComputeWorkgroupsPerDimension;if(e!==Ct)throw new h("E_NO_DEVICE",`maxComputeWorkgroupsPerDimension is ${e}; the dispatch planner and the WGSL prelude bake ${Ct}`,{reason:"maxComputeWorkgroupsPerDimension",adapter:null,requested:Ct,available:e});const t=Bs(r);if(t<64)throw new h("E_NO_DEVICE",`the device allows a workgroup of ${t} invocations; the kernels need a power of two >= 64`,{reason:"limit",adapter:null,limit:"maxComputeInvocationsPerWorkgroup",requested:64,available:t})}function va(r,e){return r.messages.map(t=>{if(t.lineNum===0)return`${t.type} ${t.message}`;const s=t.lineNum-e;return s>=1?`${t.type} ${s}:${t.linePos} ${t.message}`:`${t.type} prelude:${t.lineNum}:${t.linePos} ${t.message}`})}class ya{constructor(e,t){this.live=new Map,this.residentBytes=0,this.pending=[],this.failure=null,this.serial=0,this.device=e,this.threshold=t??Sn}createBuffer(e){this.serial+=1;const t=e.label===void 0||e.label===""?`buffer-${this.serial}`:e.label,{size:s}=e,i=s>=this.threshold;i&&this.device.pushErrorScope("out-of-memory");const n=this.device.createBuffer({...e,label:t});if(this.live.set(n,s),this.residentBytes+=s,i){const o=this.device.popErrorScope().then(a=>{a!==null&&(this.live.has(n)&&(this.live.delete(n),this.residentBytes-=s),this.failure===null&&(this.failure=new h("E_OUT_OF_MEMORY",`out of memory creating "${t}" (${s} bytes, ${this.residentBytes} resident): ${a.message}`,{requested:s,resident:this.residentBytes,label:t})))},()=>{});this.pending.push(o)}return n}destroy(e){const t=this.live.get(e);t!==void 0&&(this.live.delete(e),this.residentBytes-=t),e.destroy()}async check(){for(;this.pending.length>0;){const e=this.pending.splice(0);await Promise.all(e)}if(this.failure!==null)throw this.failure}reset(){this.failure=null}get resident(){return this.residentBytes}get liveBuffers(){return this.live.size}}class _a{constructor(){this.queue=[]}set(e){this.queue.push(e)}take(){if(this.queue.length===0)return null;const e=this.queue.splice(0);let t=null;for(let s=e.length-1;s>=0;s-=1){const i=e[s];t=t===null?i:new h(i.code,i.message,{...i.details,next:t})}return t}get pending(){return this.queue.length>0}}function Pa(r,e){const{message:t}=r;return r.constructor.name==="GPUOutOfMemoryError"?new h("E_OUT_OF_MEMORY",`uncaptured out-of-memory error on "${e}": ${t}`,{requested:0,resident:0,label:e}):new h("E_VALIDATION",`uncaptured validation error on "${e}": ${t}`,{label:e,message:t})}function Sa(r,e,t){let s=!0;const i=r.label??"",n=o=>{if(!s)return;const a=Pa(o.error,i);t!==null?t(a):e.set(a)};return r.addEventListener("uncapturederror",n),()=>{s=!1,typeof r.removeEventListener=="function"&&r.removeEventListener("uncapturederror",n)}}function Ea(r,e){let t=!1;return r.lost.then(s=>(t||(t=!0,e(s)),s))}function Nn(r){return new h("E_DEVICE_LOST",`device lost (${r.reason}): ${r.message}`,{reason:r.reason,message:r.message})}const rs=16,Ia=32,bi=new WeakMap;let vi=1;function ka(r){let e=bi.get(r);return e===void 0&&(e=vi,vi+=1,bi.set(r,e)),e}function Aa(r,e){return r.offset<e.offset+e.size&&e.offset<r.offset+r.size}class xa{constructor(e,t,s,i,n){this.cache=new Map,this.device=e,this.spec=t,this.pipeline=i,this.layouts=n,this.workgroupSize=s.overrides.WG,this.entryPoint=s.entryPoint;const o=n.map(()=>[]);for(const a of t.bindings)o[a.group].push(a);for(const a of o)a.sort((c,l)=>c.binding-l.binding);this.groups=o,this.dynamicCounts=o.map(a=>a.filter(c=>c.kind==="uniform").length)}bind(e){const{id:t}=this.spec,s=new Map(this.spec.bindings.map(f=>[f.name,f]));for(const f of Object.keys(e))if(!s.has(f))throw new h("E_INVALID_ARGUMENT",`${t}: no binding named "${f}"`,{argument:"bindings",value:f,expected:[...s.keys()].join(", ")});const i=[];for(const f of this.spec.bindings){const p=e[f.name];if(p===void 0)throw new h("E_INVALID_ARGUMENT",`${t}: binding "${f.name}" is missing`,{argument:"bindings",value:f.name,expected:"a Binding for every declared name"});if(!(Number.isInteger(p.size)&&p.size>0))throw new h("E_INVALID_ARGUMENT",`${t}: binding "${f.name}" has size ${p.size}`,{argument:f.name,value:p.size,expected:"size > 0 (a zero-length buffer is never bound)"});if(!(Number.isInteger(p.offset)&&p.offset>=0&&p.offset%Ar===0))throw new h("E_INVALID_ARGUMENT",`${t}: binding "${f.name}" has offset ${p.offset}`,{argument:f.name,value:p.offset,expected:`a multiple of ${Ar} (spec 2.6: the offset alignment the package always honours)`});i.push({decl:f,binding:p})}for(let f=0;f<i.length;f++)for(let p=f+1;p<i.length;p++){const g=i[f],m=i[p];if(!(g.binding.buffer!==m.binding.buffer||!(g.decl.kind==="storage"||m.decl.kind==="storage"))){if(g.decl.kind!==m.decl.kind)throw new h("E_INVALID_ARGUMENT",`${t}: "${g.decl.name}" and "${m.decl.name}" bind one buffer with different access modes (writable usage next to another usage)`,{argument:"aliasing",value:[g.decl.name,m.decl.name],expected:"one access mode per buffer when a slot is read_write",reason:"usage"});if(Aa(g.binding,m.binding))throw new h("E_INVALID_ARGUMENT",`${t}: "${g.decl.name}" and "${m.decl.name}" bind intersecting ranges of one read_write buffer`,{argument:"aliasing",value:[g.decl.name,m.decl.name],expected:"disjoint ranges",reason:"range"})}}const n=i.map(({binding:f})=>`${ka(f.buffer)}:${f.offset}:${f.size}`).join("|"),o=this.cache.get(n);if(o!==void 0)return this.cache.delete(n),this.cache.set(n,o),o;const a=new Map(i.map(({decl:f,binding:p})=>[f.name,p])),c=this.layouts.map((f,p)=>this.device.createBindGroup({label:`${t}/${p}`,layout:f,entries:this.groups[p].map(g=>{const m=a.get(g.name);return{binding:g.binding,resource:{buffer:m.buffer,offset:m.offset,size:m.size}}})})),l=[];this.dynamicCounts.forEach((f,p)=>{f>0&&l.push(p)});const d=Object.freeze({kernel:this,bindGroups:Object.freeze(c),dynamicGroups:Object.freeze(l)});return this.cache.set(n,d),this.cache.size>Ia&&this.cache.delete(this.cache.keys().next().value),d}dispatch(e,t,s,i){this.check(t,i),s.x!==0&&(this.setUp(e,t,i),e.dispatchWorkgroups(s.x,s.y,s.z))}dispatchIndirect(e,t,s,i,n){if(this.check(t,n),!Number.isInteger(i)||i<0||(i+1)*rs>s.size)throw new h("E_INVALID_ARGUMENT",`${this.spec.id}: args slot ${i} is outside the binding`,{argument:"slot",value:i,expected:`0 <= slot < ${Math.floor(s.size/rs)}`});this.setUp(e,t,n),e.dispatchWorkgroupsIndirect(s.buffer,s.offset+rs*i)}check(e,t){const{id:s}=this.spec;if(e.kernel!==this)throw new h("E_INVALID_ARGUMENT",`${s}: the bound kernel belongs to "${e.kernel.spec.id}"`,{argument:"bound",value:e.kernel.spec.id,expected:s});if(t!==void 0&&t.length!==e.dynamicGroups.length)throw new h("E_INVALID_ARGUMENT",`${s}: ${t.length} dynamic offsets for ${e.dynamicGroups.length} dynamic groups`,{argument:"dynamicOffsets",value:t.length,expected:e.dynamicGroups.length})}setUp(e,t,s){e.setPipeline(this.pipeline);let i=0;t.bindGroups.forEach((n,o)=>{const a=this.dynamicCounts[o];if(a>0){const c=s?.[i]??0;i+=1;const l=[];for(let d=0;d<a;d++)l.push(c);e.setBindGroup(o,n,l)}else e.setBindGroup(o,n)})}invalidate(){this.cache.clear()}}const ie=Object.freeze({MAP_READ:1,MAP_WRITE:2,COPY_SRC:4,COPY_DST:8,INDEX:16,VERTEX:32,UNIFORM:64,STORAGE:128,INDIRECT:256,QUERY_RESOLVE:512}),yi=Object.freeze({READ:1,WRITE:2}),_i=Object.freeze({VERTEX:1,FRAGMENT:2,COMPUTE:4});function kt(r){if(!Number.isFinite(r))throw new h("E_INVALID_ARGUMENT",`wgslF32Literal: ${r} is not a finite number`,{argument:"value",value:r,expected:"a finite number"});const e=String(r);return/[.e]/.test(e)?e:`${e}.0`}const Bn=`// ---- prelude: constants, standard overrides, helpers (every module receives this text first)
|
|
1
|
+
import{I as dt,d as _n,u as No,b as Bo,m as oi,q as $o}from"./preload-helper-Crt_PPe8.js";import{a as ai}from"./index-C-jUF_Ve.js";const Os=256,Ct=65535,Zr=Ct*Os,ye=4294967295,kr=256,Mt=64,Ar=256,Ye=256,Pn=32768,Co=3,Mo=256,Sn=16*1024*1024,Go=4,zo=4*1024,Fo=64*1024*1024,ci=16*1024*1024,li=2,Fe=256,qt=32,He=256,ui=64,At=Object.freeze({maxIter:100,jitterTolerance:1,scalingRatio:2,gravity:1,strongGravity:!1,distributedAction:!1,linlog:!1,dissuadeHubs:!1,dim:2,scale:1,settleThreshold:.001,settleWindow:10,iterationsPerStep:1,maxInFlight:2}),mt=Object.freeze({repulsion:"auto",exactMaxNodes:Pn,nearMax:64,deterministic:!0,gridMax2D:512,gridMax3D:128,extentFactor:6,compat:"paper"}),Wo=.01,Uo=1e-4,Vo=1e-8,En=128,ys=1,In=2,yr=.1,jo=.7,qo=.9,Ko=5,Ho=1e4,Yo=Object.freeze({k:null,iterations:50,fixed:null,dim:2,scale:1,settleThreshold:.001,settleWindow:10,iterationsPerStep:1,maxInFlight:2,cooling:"linear"}),Xo=300,_s=Object.freeze({springLength:10,springCoefficient:.8,gravity:-12,dragCoefficient:.9,timeStep:.5,dim:2,scale:1,settleThreshold:.001,settleWindow:10,iterationsPerStep:1,maxInFlight:2}),kn=Object.freeze({springElectrical:.003,fruchtermanReingold:.002}),Qo=2e3,Zo=2**128-2**104,di=8,fi=4,An=1024,xn=1e-6,Rn=1.01,Jo=24,ue=32,ea=4096,ta=2,ra=24,sa=32,Gt=2139095040,ia=.25,na=256,oa=2,aa=100,ca=256,Sr=64,Ns=32,la=4096,hi=8,It=4,ua=2147483648,da=32,Jr=128,es=65e3,Ln=2,fa=32,ha=Object.freeze({});class h extends Error{constructor(e,t,s){super(t),this.name="WebGpuGraphError",this.code=e,this.details=s===void 0?ha:Object.freeze({...s})}}function Nt(r){if(typeof r!="object"||r===null)return!1;const e=r;return e.name==="WebGpuGraphError"&&typeof e.code=="string"}function Er(r,e){return Nt(r)&&r.code===e}const pi=Object.freeze(["maxBufferSize","maxStorageBufferBindingSize","maxStorageBuffersPerShaderStage","maxComputeWorkgroupStorageSize","maxComputeInvocationsPerWorkgroup","maxComputeWorkgroupSizeX"]),pa=["maxTextureDimension1D","maxTextureDimension2D","maxTextureDimension3D","maxTextureArrayLayers","maxBindGroups","maxBindGroupsPlusVertexBuffers","maxBindingsPerBindGroup","maxDynamicUniformBuffersPerPipelineLayout","maxDynamicStorageBuffersPerPipelineLayout","maxSampledTexturesPerShaderStage","maxSamplersPerShaderStage","maxStorageBuffersPerShaderStage","maxStorageBuffersInVertexStage","maxStorageBuffersInFragmentStage","maxStorageTexturesPerShaderStage","maxStorageTexturesInVertexStage","maxStorageTexturesInFragmentStage","maxUniformBuffersPerShaderStage","maxUniformBufferBindingSize","maxStorageBufferBindingSize","minUniformBufferOffsetAlignment","minStorageBufferOffsetAlignment","maxVertexBuffers","maxBufferSize","maxVertexAttributes","maxVertexBufferArrayStride","maxInterStageShaderVariables","maxColorAttachments","maxColorAttachmentBytesPerSample","maxComputeWorkgroupStorageSize","maxComputeInvocationsPerWorkgroup","maxComputeWorkgroupSizeX","maxComputeWorkgroupSizeY","maxComputeWorkgroupSizeZ","maxComputeWorkgroupsPerDimension","maxImmediateSize"],gi=new WeakSet;function Dn(r){return r instanceof Error?r.message:String(r)}function Tn(r){return r.architecture==="software"||r.architecture==="swiftshader"||r.architecture==="warp"||r.isFallbackAdapter===!0}function Kt(r){const{info:e}=r,t=r.limits,s={};for(const i of pa){const n=t[i];typeof n=="number"&&(s[i]=n)}return Object.freeze({vendor:e.vendor,architecture:e.architecture,device:e.device,description:e.description,software:Tn(e),subgroupMinSize:e.subgroupMinSize??0,subgroupMaxSize:e.subgroupMaxSize??0,features:Object.freeze(Array.from(r.features).sort()),limits:Object.freeze(s)})}async function On(r,e){let t;try{t=await r.requestAdapter({powerPreference:e})}catch(s){const i=`requestAdapter() threw: ${Dn(s)}`;throw new h("E_NO_ADAPTER",i,{reason:i})}if(t===null){const s="requestAdapter() returned null: no usable WebGPU adapter";throw new h("E_NO_ADAPTER",s,{reason:s})}return t}function ga(r,e){const t={};if(e==="default")return t;if(e==="raise"){for(const s of pi)t[s]=r.limits[s];return t}for(const s of pi){const i=e[s];if(i===void 0)continue;const n=r.limits[s];if(i>n)throw new h("E_NO_DEVICE",`requested ${s} = ${i} exceeds the adapter's ${n}`,{reason:"limit",adapter:Kt(r),limit:s,requested:i,available:n});t[s]=i}return t}function ma(r,e,t){const s=[];for(const i of e){if(!r.features.has(i))throw new h("E_NO_DEVICE",`required feature "${i}" is not supported by the adapter`,{reason:"feature",adapter:Kt(r),requested:i});s.includes(i)||s.push(i)}for(const i of t)r.features.has(i)&&!s.includes(i)&&s.push(i);return s}function mi(r,e){return new h("E_NO_DEVICE",`the adapter already created a device (an adapter is consumed by one requestDevice, spec 2.2 step 1): ${e}`,{reason:"consumed",adapter:Kt(r)})}async function wa(r,e){if(gi.has(r))throw mi(r,"recorded by this package");let t;try{t=await r.requestDevice(e)}catch(s){const i=Dn(s);throw/consumed|already been used/i.test(i)?mi(r,i):new h("E_NO_DEVICE",`requestDevice() rejected: ${i}`,{reason:"requestDevice",adapter:Kt(r)})}return gi.add(r),t}function ba(r,e,t,s){const i=new Set(r.features),n=i.has("subgroups");return{limits:r.limits,features:i,wgslFeatures:new Set(s),subgroupMinSize:n?e.subgroupMinSize??0:0,subgroupMaxSize:n?e.subgroupMaxSize??0:0,software:Tn(e),runtime:t,vendor:e.vendor,architecture:e.architecture,device:e.device,description:e.description}}function wi(r,e){const t=new Set(r.features),s=t.has("subgroups");return{limits:r.limits,features:t,wgslFeatures:e?.wgslFeatures??new Set,subgroupMinSize:s?e?.subgroupMinSize??0:0,subgroupMaxSize:s?e?.subgroupMaxSize??0:0,software:e?.software??!1,runtime:e?.runtime??"unknown",vendor:e?.vendor??"",architecture:e?.architecture??"",device:e?.device??"",description:e?.description??""}}function Bs(r){const e=Math.min(Os,r.limits.maxComputeInvocationsPerWorkgroup);let t=1;for(;t*2<=e;)t*=2;return t}function ts(r){const e=r.limits.maxComputeWorkgroupsPerDimension;if(e!==Ct)throw new h("E_NO_DEVICE",`maxComputeWorkgroupsPerDimension is ${e}; the dispatch planner and the WGSL prelude bake ${Ct}`,{reason:"maxComputeWorkgroupsPerDimension",adapter:null,requested:Ct,available:e});const t=Bs(r);if(t<64)throw new h("E_NO_DEVICE",`the device allows a workgroup of ${t} invocations; the kernels need a power of two >= 64`,{reason:"limit",adapter:null,limit:"maxComputeInvocationsPerWorkgroup",requested:64,available:t})}function va(r,e){return r.messages.map(t=>{if(t.lineNum===0)return`${t.type} ${t.message}`;const s=t.lineNum-e;return s>=1?`${t.type} ${s}:${t.linePos} ${t.message}`:`${t.type} prelude:${t.lineNum}:${t.linePos} ${t.message}`})}class ya{constructor(e,t){this.live=new Map,this.residentBytes=0,this.pending=[],this.failure=null,this.serial=0,this.device=e,this.threshold=t??Sn}createBuffer(e){this.serial+=1;const t=e.label===void 0||e.label===""?`buffer-${this.serial}`:e.label,{size:s}=e,i=s>=this.threshold;i&&this.device.pushErrorScope("out-of-memory");const n=this.device.createBuffer({...e,label:t});if(this.live.set(n,s),this.residentBytes+=s,i){const o=this.device.popErrorScope().then(a=>{a!==null&&(this.live.has(n)&&(this.live.delete(n),this.residentBytes-=s),this.failure===null&&(this.failure=new h("E_OUT_OF_MEMORY",`out of memory creating "${t}" (${s} bytes, ${this.residentBytes} resident): ${a.message}`,{requested:s,resident:this.residentBytes,label:t})))},()=>{});this.pending.push(o)}return n}destroy(e){const t=this.live.get(e);t!==void 0&&(this.live.delete(e),this.residentBytes-=t),e.destroy()}async check(){for(;this.pending.length>0;){const e=this.pending.splice(0);await Promise.all(e)}if(this.failure!==null)throw this.failure}reset(){this.failure=null}get resident(){return this.residentBytes}get liveBuffers(){return this.live.size}}class _a{constructor(){this.queue=[]}set(e){this.queue.push(e)}take(){if(this.queue.length===0)return null;const e=this.queue.splice(0);let t=null;for(let s=e.length-1;s>=0;s-=1){const i=e[s];t=t===null?i:new h(i.code,i.message,{...i.details,next:t})}return t}get pending(){return this.queue.length>0}}function Pa(r,e){const{message:t}=r;return r.constructor.name==="GPUOutOfMemoryError"?new h("E_OUT_OF_MEMORY",`uncaptured out-of-memory error on "${e}": ${t}`,{requested:0,resident:0,label:e}):new h("E_VALIDATION",`uncaptured validation error on "${e}": ${t}`,{label:e,message:t})}function Sa(r,e,t){let s=!0;const i=r.label??"",n=o=>{if(!s)return;const a=Pa(o.error,i);t!==null?t(a):e.set(a)};return r.addEventListener("uncapturederror",n),()=>{s=!1,typeof r.removeEventListener=="function"&&r.removeEventListener("uncapturederror",n)}}function Ea(r,e){let t=!1;return r.lost.then(s=>(t||(t=!0,e(s)),s))}function Nn(r){return new h("E_DEVICE_LOST",`device lost (${r.reason}): ${r.message}`,{reason:r.reason,message:r.message})}const rs=16,Ia=32,bi=new WeakMap;let vi=1;function ka(r){let e=bi.get(r);return e===void 0&&(e=vi,vi+=1,bi.set(r,e)),e}function Aa(r,e){return r.offset<e.offset+e.size&&e.offset<r.offset+r.size}class xa{constructor(e,t,s,i,n){this.cache=new Map,this.device=e,this.spec=t,this.pipeline=i,this.layouts=n,this.workgroupSize=s.overrides.WG,this.entryPoint=s.entryPoint;const o=n.map(()=>[]);for(const a of t.bindings)o[a.group].push(a);for(const a of o)a.sort((c,l)=>c.binding-l.binding);this.groups=o,this.dynamicCounts=o.map(a=>a.filter(c=>c.kind==="uniform").length)}bind(e){const{id:t}=this.spec,s=new Map(this.spec.bindings.map(f=>[f.name,f]));for(const f of Object.keys(e))if(!s.has(f))throw new h("E_INVALID_ARGUMENT",`${t}: no binding named "${f}"`,{argument:"bindings",value:f,expected:[...s.keys()].join(", ")});const i=[];for(const f of this.spec.bindings){const p=e[f.name];if(p===void 0)throw new h("E_INVALID_ARGUMENT",`${t}: binding "${f.name}" is missing`,{argument:"bindings",value:f.name,expected:"a Binding for every declared name"});if(!(Number.isInteger(p.size)&&p.size>0))throw new h("E_INVALID_ARGUMENT",`${t}: binding "${f.name}" has size ${p.size}`,{argument:f.name,value:p.size,expected:"size > 0 (a zero-length buffer is never bound)"});if(!(Number.isInteger(p.offset)&&p.offset>=0&&p.offset%Ar===0))throw new h("E_INVALID_ARGUMENT",`${t}: binding "${f.name}" has offset ${p.offset}`,{argument:f.name,value:p.offset,expected:`a multiple of ${Ar} (spec 2.6: the offset alignment the package always honours)`});i.push({decl:f,binding:p})}for(let f=0;f<i.length;f++)for(let p=f+1;p<i.length;p++){const g=i[f],m=i[p];if(!(g.binding.buffer!==m.binding.buffer||!(g.decl.kind==="storage"||m.decl.kind==="storage"))){if(g.decl.kind!==m.decl.kind)throw new h("E_INVALID_ARGUMENT",`${t}: "${g.decl.name}" and "${m.decl.name}" bind one buffer with different access modes (writable usage next to another usage)`,{argument:"aliasing",value:[g.decl.name,m.decl.name],expected:"one access mode per buffer when a slot is read_write",reason:"usage"});if(Aa(g.binding,m.binding))throw new h("E_INVALID_ARGUMENT",`${t}: "${g.decl.name}" and "${m.decl.name}" bind intersecting ranges of one read_write buffer`,{argument:"aliasing",value:[g.decl.name,m.decl.name],expected:"disjoint ranges",reason:"range"})}}const n=i.map(({binding:f})=>`${ka(f.buffer)}:${f.offset}:${f.size}`).join("|"),o=this.cache.get(n);if(o!==void 0)return this.cache.delete(n),this.cache.set(n,o),o;const a=new Map(i.map(({decl:f,binding:p})=>[f.name,p])),c=this.layouts.map((f,p)=>this.device.createBindGroup({label:`${t}/${p}`,layout:f,entries:this.groups[p].map(g=>{const m=a.get(g.name);return{binding:g.binding,resource:{buffer:m.buffer,offset:m.offset,size:m.size}}})})),l=[];this.dynamicCounts.forEach((f,p)=>{f>0&&l.push(p)});const d=Object.freeze({kernel:this,bindGroups:Object.freeze(c),dynamicGroups:Object.freeze(l)});return this.cache.set(n,d),this.cache.size>Ia&&this.cache.delete(this.cache.keys().next().value),d}dispatch(e,t,s,i){this.check(t,i),s.x!==0&&(this.setUp(e,t,i),e.dispatchWorkgroups(s.x,s.y,s.z))}dispatchIndirect(e,t,s,i,n){if(this.check(t,n),!Number.isInteger(i)||i<0||(i+1)*rs>s.size)throw new h("E_INVALID_ARGUMENT",`${this.spec.id}: args slot ${i} is outside the binding`,{argument:"slot",value:i,expected:`0 <= slot < ${Math.floor(s.size/rs)}`});this.setUp(e,t,n),e.dispatchWorkgroupsIndirect(s.buffer,s.offset+rs*i)}check(e,t){const{id:s}=this.spec;if(e.kernel!==this)throw new h("E_INVALID_ARGUMENT",`${s}: the bound kernel belongs to "${e.kernel.spec.id}"`,{argument:"bound",value:e.kernel.spec.id,expected:s});if(t!==void 0&&t.length!==e.dynamicGroups.length)throw new h("E_INVALID_ARGUMENT",`${s}: ${t.length} dynamic offsets for ${e.dynamicGroups.length} dynamic groups`,{argument:"dynamicOffsets",value:t.length,expected:e.dynamicGroups.length})}setUp(e,t,s){e.setPipeline(this.pipeline);let i=0;t.bindGroups.forEach((n,o)=>{const a=this.dynamicCounts[o];if(a>0){const c=s?.[i]??0;i+=1;const l=[];for(let d=0;d<a;d++)l.push(c);e.setBindGroup(o,n,l)}else e.setBindGroup(o,n)})}invalidate(){this.cache.clear()}}const ie=Object.freeze({MAP_READ:1,MAP_WRITE:2,COPY_SRC:4,COPY_DST:8,INDEX:16,VERTEX:32,UNIFORM:64,STORAGE:128,INDIRECT:256,QUERY_RESOLVE:512}),yi=Object.freeze({READ:1,WRITE:2}),_i=Object.freeze({VERTEX:1,FRAGMENT:2,COMPUTE:4});function kt(r){if(!Number.isFinite(r))throw new h("E_INVALID_ARGUMENT",`wgslF32Literal: ${r} is not a finite number`,{argument:"value",value:r,expected:"a finite number"});const e=String(r);return/[.e]/.test(e)?e:`${e}.0`}const Bn=`// ---- prelude: constants, standard overrides, helpers (every module receives this text first)
|
|
2
2
|
const INVALID_INDEX: u32 = ${dt}u;
|
|
3
3
|
const U32_MAX: u32 = ${ye}u;
|
|
4
4
|
const F32_INF_BITS: u32 = ${Gt}u;
|