@selvajs/compute 2.1.0 → 2.2.0

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.
Files changed (44) hide show
  1. package/dist/chunk-4UOOVSGL.cjs +4 -0
  2. package/dist/{chunk-BTH6J34X.cjs.map → chunk-4UOOVSGL.cjs.map} +1 -1
  3. package/dist/{chunk-NFPYFIYS.cjs → chunk-5JXKIKSD.cjs} +3 -3
  4. package/dist/{chunk-NFPYFIYS.cjs.map → chunk-5JXKIKSD.cjs.map} +1 -1
  5. package/dist/{chunk-6L56B3Q3.js → chunk-6TJKWARC.js} +2 -2
  6. package/dist/chunk-6TJKWARC.js.map +1 -0
  7. package/dist/chunk-AXAMGKTJ.js +4 -0
  8. package/dist/chunk-AXAMGKTJ.js.map +1 -0
  9. package/dist/{chunk-HG24GZ3A.cjs → chunk-PWNJ3ZLS.cjs} +2 -2
  10. package/dist/{chunk-HG24GZ3A.cjs.map → chunk-PWNJ3ZLS.cjs.map} +1 -1
  11. package/dist/{chunk-UQ7TD57L.js → chunk-WJ2WV4TU.js} +2 -2
  12. package/dist/core.cjs +1 -1
  13. package/dist/core.d.cts +3 -3
  14. package/dist/core.d.ts +3 -3
  15. package/dist/core.js +1 -1
  16. package/dist/grasshopper.cjs +1 -1
  17. package/dist/grasshopper.d.cts +9 -8
  18. package/dist/grasshopper.d.ts +9 -8
  19. package/dist/grasshopper.js +1 -1
  20. package/dist/{handle-files-D-_fiXu4.d.cts → handle-files-VUQET1YU.d.cts} +162 -4
  21. package/dist/{handle-files-D-_fiXu4.d.ts → handle-files-VUQET1YU.d.ts} +162 -4
  22. package/dist/index.cjs +1 -1
  23. package/dist/index.d.cts +3 -3
  24. package/dist/index.d.ts +3 -3
  25. package/dist/index.js +1 -1
  26. package/dist/{types-jPuWWtnU.d.ts → types-CIsBR_xd.d.ts} +1 -1
  27. package/dist/{types-D1SkNje_.d.cts → types-ChF690kY.d.cts} +4 -3
  28. package/dist/{types-D1SkNje_.d.ts → types-ChF690kY.d.ts} +4 -3
  29. package/dist/{types-BuRCHPlb.d.cts → types-DqSisB8v.d.cts} +1 -1
  30. package/dist/visualization-BOBO73UZ.cjs +2 -0
  31. package/dist/{visualization-6ZLI4ANV.cjs.map → visualization-BOBO73UZ.cjs.map} +1 -1
  32. package/dist/{visualization-42QQ22YF.js → visualization-WUFY6TTQ.js} +2 -2
  33. package/dist/visualization.cjs +1 -1
  34. package/dist/visualization.d.cts +3 -3
  35. package/dist/visualization.d.ts +3 -3
  36. package/dist/visualization.js +1 -1
  37. package/package.json +2 -1
  38. package/dist/chunk-6L56B3Q3.js.map +0 -1
  39. package/dist/chunk-BTH6J34X.cjs +0 -4
  40. package/dist/chunk-H2FJSNMM.js +0 -4
  41. package/dist/chunk-H2FJSNMM.js.map +0 -1
  42. package/dist/visualization-6ZLI4ANV.cjs +0 -2
  43. /package/dist/{chunk-UQ7TD57L.js.map → chunk-WJ2WV4TU.js.map} +0 -0
  44. /package/dist/{visualization-42QQ22YF.js.map → visualization-WUFY6TTQ.js.map} +0 -0
@@ -1,4 +1,4 @@
1
- import{a as De,c as ee,d as te,e as v,o as ce}from"./chunk-H2FJSNMM.js";import*as V from"three";var _={HUGE_THRESHOLD:1e4,LARGE_THRESHOLD:1e3,SCALE_RATIO_THRESHOLD:100,NEAR_PLANE_FACTOR:{TINY:1e-4,SMALL:.001,NORMAL:.01},FAR_PLANE_FACTOR:{HUGE:100,LARGE:50,NORMAL:20},INITIAL_DISTANCE_MULTIPLIER:4};function Hn(e,r,t,n,o){if(Pe(e),r.length===0)return;r.forEach(d=>{e.add(d)});let a=Y(r),i=a.getCenter(new V.Vector3),s=a.getSize(new V.Vector3),l=Math.max(s.x,s.y,s.z);if(l/Math.min(s.x||1,s.y||1,s.z||1)>_.SCALE_RATIO_THRESHOLD||l>_.HUGE_THRESHOLD?(t.near=l*_.NEAR_PLANE_FACTOR.TINY,t.far=l*_.FAR_PLANE_FACTOR.HUGE):l>_.LARGE_THRESHOLD?(t.near=l*_.NEAR_PLANE_FACTOR.SMALL,t.far=l*_.FAR_PLANE_FACTOR.LARGE):(t.near=Math.max(.01,l*_.NEAR_PLANE_FACTOR.NORMAL),t.far=Math.max(2e3,l*_.FAR_PLANE_FACTOR.NORMAL)),t.updateProjectionMatrix(),o)n.minDistance=t.near*2,n.maxDistance=t.far*.9;else{let d=l*_.INITIAL_DISTANCE_MULTIPLIER;t.position.set(i.x+d*.8,i.y+d,i.z+d*1.2),n.target.copy(i),n.minDistance=t.near*2,n.maxDistance=t.far*.9,n.update()}}function de(e){if(!e||typeof e!="string")return v().warn(`Invalid color input: ${e}, using white`),new V.Color(16777215);let r=e.trim();if(/^#?[0-9A-Fa-f]{6}$/.test(r))try{let t=r.startsWith("#")?r:`#${r}`;return new V.Color(t)}catch{return v().warn(`Invalid hex color: ${e}, using white`),new V.Color(16777215)}if(r.includes(",")){let t=r.split(",").map(n=>parseInt(n.trim(),10));if(t.length===3&&t.every(n=>!isNaN(n)&&n>=0&&n<=255))return new V.Color(t[0]/255,t[1]/255,t[2]/255)}try{return new V.Color(r.toLowerCase())}catch{return v().warn(`Invalid color string: ${e}, using white`),new V.Color(16777215)}}function ue(e,r,t="z"){e.forEach(n=>{n.position[t]-=r})}function Y(e){let r=new V.Box3;return e.length===0||e.forEach(t=>{t.updateMatrixWorld(!0);let n=new V.Box3().setFromObject(t);r.union(n)}),r}var Le=new Set(["floor","grid","label-layer"]);function Pe(e){[...e.children].forEach(t=>{Le.has(t.userData.id)||(t.traverse(n=>{let o=n;if(!o.geometry&&!o.material)return;o.geometry?.dispose();let a=o.material;if(!a)return;(Array.isArray(a)?a:[a]).forEach(s=>{for(let l of Object.values(s))l instanceof V.Texture&&l.dispose();s.dispose()})}),t.removeFromParent())})}import*as z from"three";function Oe(e){let r=e.clone().normalize(),t=new z.Vector3(0,0,1),n=new z.Vector3(0,1,0),o=Math.abs(r.dot(t))>.9?n:t,a=new z.Vector3().crossVectors(r,o).normalize(),i=new z.Vector3().crossVectors(a,r).normalize();return{top:r.clone(),bottom:r.clone().negate(),front:i.clone(),back:i.clone().negate(),right:a.clone(),left:a.clone().negate(),iso:i.clone().multiplyScalar(1.2).add(a.clone()).add(r.clone()).normalize()}}function me(e){let{scene:r,perspective:t,controls:n,onActiveCameraChange:o}=e,a=(e.up??t.up).clone().normalize(),i=Oe(a),s=new z.OrthographicCamera(-1,1,1,-1,t.near,t.far);s.up.copy(a);let l="perspective",c=t.aspect,d=()=>l==="perspective"?t:s,u=()=>{let g=t.position.distanceTo(n.target)*Math.tan(t.fov*Math.PI/360),R=g*c;s.left=-R,s.right=R,s.top=g,s.bottom=-g,s.near=t.near,s.far=t.far,s.updateProjectionMatrix()},m=b=>{b!==l&&(b==="orthographic"?(s.position.copy(t.position),s.up.copy(t.up),s.lookAt(n.target),u()):t.position.copy(s.position),l=b,n.object=d(),n.update(),o(d()))},E=(b,g=!0)=>{let R=Be(r),H=R.isEmpty()?n.target.clone():R.getCenter(new z.Vector3),P=R.isEmpty()?new z.Vector3(1,1,1):R.getSize(new z.Vector3),y=Math.max(P.x,P.y,P.z)||1,w=t.fov*(Math.PI/180),C=y/(2*Math.tan(w/2))*1.5,O=ze(b,a),h=H.clone().add(O.clone().multiplyScalar(C)),T=d();g?je(T,n,h,H,()=>{l==="orthographic"&&u()}):(T.position.copy(h),n.target.copy(H),l==="orthographic"&&u(),n.update())};return{getActiveCamera:d,getProjection:()=>l,setProjection:m,toggleProjection:()=>(m(l==="perspective"?"orthographic":"perspective"),l),setView:(b,g=!0)=>{E(i[b],g)},setViewDirection:E,setRotateEnabled:b=>{n.enableRotate=b},isRotateEnabled:()=>n.enableRotate,updateAspect:(b,g)=>{c=g===0?c:b/g,l==="orthographic"&&u()}}}var Ie=new Set(["grid","floor","label-layer","measure"]);function Ve(e){let r=e;for(;r;){if(typeof r.userData.id=="string"&&Ie.has(r.userData.id))return!0;r=r.parent}return!1}function Be(e){let r=[];return e.traverse(t=>{let n=t;t.visible&&!Ve(t)&&n.geometry&&r.push(t)}),Y(r)}function ze(e,r){let t=r.clone().normalize(),n=e.clone().normalize();if(Math.abs(n.dot(t))<.9999)return e;let o=Math.abs(t.dot(new z.Vector3(0,0,1)))>.9?new z.Vector3(0,1,0):new z.Vector3(0,0,1),a=new z.Vector3().crossVectors(t,o).normalize(),i=.5*Math.PI/180;return n.multiplyScalar(Math.cos(i)).add(a.multiplyScalar(Math.sin(i))).normalize()}var Fe=e=>1-Math.pow(1-e,3);function je(e,r,t,n,o,a=250){let i=e.position.clone(),s=r.target.clone(),l=performance.now(),c=()=>{let d=Fe(Math.min((performance.now()-l)/a,1));e.position.lerpVectors(i,t,d),r.target.lerpVectors(s,n,d),o(),r.update(),d<1&&requestAnimationFrame(c)};requestAnimationFrame(c)}import*as I from"three";var ke=`
1
+ import{a as De,c as ee,d as te,e as v,o as ce}from"./chunk-AXAMGKTJ.js";import*as V from"three";var _={HUGE_THRESHOLD:1e4,LARGE_THRESHOLD:1e3,SCALE_RATIO_THRESHOLD:100,NEAR_PLANE_FACTOR:{TINY:1e-4,SMALL:.001,NORMAL:.01},FAR_PLANE_FACTOR:{HUGE:100,LARGE:50,NORMAL:20},INITIAL_DISTANCE_MULTIPLIER:4};function Hn(e,r,t,n,o){if(Pe(e),r.length===0)return;r.forEach(d=>{e.add(d)});let a=Y(r),i=a.getCenter(new V.Vector3),s=a.getSize(new V.Vector3),l=Math.max(s.x,s.y,s.z);if(l/Math.min(s.x||1,s.y||1,s.z||1)>_.SCALE_RATIO_THRESHOLD||l>_.HUGE_THRESHOLD?(t.near=l*_.NEAR_PLANE_FACTOR.TINY,t.far=l*_.FAR_PLANE_FACTOR.HUGE):l>_.LARGE_THRESHOLD?(t.near=l*_.NEAR_PLANE_FACTOR.SMALL,t.far=l*_.FAR_PLANE_FACTOR.LARGE):(t.near=Math.max(.01,l*_.NEAR_PLANE_FACTOR.NORMAL),t.far=Math.max(2e3,l*_.FAR_PLANE_FACTOR.NORMAL)),t.updateProjectionMatrix(),o)n.minDistance=t.near*2,n.maxDistance=t.far*.9;else{let d=l*_.INITIAL_DISTANCE_MULTIPLIER;t.position.set(i.x+d*.8,i.y+d,i.z+d*1.2),n.target.copy(i),n.minDistance=t.near*2,n.maxDistance=t.far*.9,n.update()}}function de(e){if(!e||typeof e!="string")return v().warn(`Invalid color input: ${e}, using white`),new V.Color(16777215);let r=e.trim();if(/^#?[0-9A-Fa-f]{6}$/.test(r))try{let t=r.startsWith("#")?r:`#${r}`;return new V.Color(t)}catch{return v().warn(`Invalid hex color: ${e}, using white`),new V.Color(16777215)}if(r.includes(",")){let t=r.split(",").map(n=>parseInt(n.trim(),10));if(t.length===3&&t.every(n=>!isNaN(n)&&n>=0&&n<=255))return new V.Color(t[0]/255,t[1]/255,t[2]/255)}try{return new V.Color(r.toLowerCase())}catch{return v().warn(`Invalid color string: ${e}, using white`),new V.Color(16777215)}}function ue(e,r,t="z"){e.forEach(n=>{n.position[t]-=r})}function Y(e){let r=new V.Box3;return e.length===0||e.forEach(t=>{t.updateMatrixWorld(!0);let n=new V.Box3().setFromObject(t);r.union(n)}),r}var Le=new Set(["floor","grid","label-layer"]);function Pe(e){[...e.children].forEach(t=>{Le.has(t.userData.id)||(t.traverse(n=>{let o=n;if(!o.geometry&&!o.material)return;o.geometry?.dispose();let a=o.material;if(!a)return;(Array.isArray(a)?a:[a]).forEach(s=>{for(let l of Object.values(s))l instanceof V.Texture&&l.dispose();s.dispose()})}),t.removeFromParent())})}import*as z from"three";function Oe(e){let r=e.clone().normalize(),t=new z.Vector3(0,0,1),n=new z.Vector3(0,1,0),o=Math.abs(r.dot(t))>.9?n:t,a=new z.Vector3().crossVectors(r,o).normalize(),i=new z.Vector3().crossVectors(a,r).normalize();return{top:r.clone(),bottom:r.clone().negate(),front:i.clone(),back:i.clone().negate(),right:a.clone(),left:a.clone().negate(),iso:i.clone().multiplyScalar(1.2).add(a.clone()).add(r.clone()).normalize()}}function me(e){let{scene:r,perspective:t,controls:n,onActiveCameraChange:o}=e,a=(e.up??t.up).clone().normalize(),i=Oe(a),s=new z.OrthographicCamera(-1,1,1,-1,t.near,t.far);s.up.copy(a);let l="perspective",c=t.aspect,d=()=>l==="perspective"?t:s,u=()=>{let g=t.position.distanceTo(n.target)*Math.tan(t.fov*Math.PI/360),R=g*c;s.left=-R,s.right=R,s.top=g,s.bottom=-g,s.near=t.near,s.far=t.far,s.updateProjectionMatrix()},m=b=>{b!==l&&(b==="orthographic"?(s.position.copy(t.position),s.up.copy(t.up),s.lookAt(n.target),u()):t.position.copy(s.position),l=b,n.object=d(),n.update(),o(d()))},E=(b,g=!0)=>{let R=Be(r),H=R.isEmpty()?n.target.clone():R.getCenter(new z.Vector3),P=R.isEmpty()?new z.Vector3(1,1,1):R.getSize(new z.Vector3),y=Math.max(P.x,P.y,P.z)||1,w=t.fov*(Math.PI/180),C=y/(2*Math.tan(w/2))*1.5,O=ze(b,a),h=H.clone().add(O.clone().multiplyScalar(C)),T=d();g?je(T,n,h,H,()=>{l==="orthographic"&&u()}):(T.position.copy(h),n.target.copy(H),l==="orthographic"&&u(),n.update())};return{getActiveCamera:d,getProjection:()=>l,setProjection:m,toggleProjection:()=>(m(l==="perspective"?"orthographic":"perspective"),l),setView:(b,g=!0)=>{E(i[b],g)},setViewDirection:E,setRotateEnabled:b=>{n.enableRotate=b},isRotateEnabled:()=>n.enableRotate,updateAspect:(b,g)=>{c=g===0?c:b/g,l==="orthographic"&&u()}}}var Ie=new Set(["grid","floor","label-layer","measure"]);function Ve(e){let r=e;for(;r;){if(typeof r.userData.id=="string"&&Ie.has(r.userData.id))return!0;r=r.parent}return!1}function Be(e){let r=[];return e.traverse(t=>{let n=t;t.visible&&!Ve(t)&&n.geometry&&r.push(t)}),Y(r)}function ze(e,r){let t=r.clone().normalize(),n=e.clone().normalize();if(Math.abs(n.dot(t))<.9999)return e;let o=Math.abs(t.dot(new z.Vector3(0,0,1)))>.9?new z.Vector3(0,1,0):new z.Vector3(0,0,1),a=new z.Vector3().crossVectors(t,o).normalize(),i=.5*Math.PI/180;return n.multiplyScalar(Math.cos(i)).add(a.multiplyScalar(Math.sin(i))).normalize()}var Fe=e=>1-Math.pow(1-e,3);function je(e,r,t,n,o,a=250){let i=e.position.clone(),s=r.target.clone(),l=performance.now(),c=()=>{let d=Fe(Math.min((performance.now()-l)/a,1));e.position.lerpVectors(i,t,d),r.target.lerpVectors(s,n,d),o(),r.update(),d<1&&requestAnimationFrame(c)};requestAnimationFrame(c)}import*as I from"three";var ke=`
2
2
  varying vec3 vWorldPos;
3
3
  void main() {
4
4
  vec4 world = modelMatrix * vec4(position, 1.0);
@@ -52,4 +52,4 @@ import{a as De,c as ee,d as te,e as v,o as ce}from"./chunk-H2FJSNMM.js";import*a
52
52
  }
53
53
  `;function Ee(e={}){let{cellSize:r=1,majorEvery:t=10,cellColor:n=8947848,majorColor:o=4473924,fadeDistance:a=100,plane:i="y"}=e,s=i==="y"?new I.Vector2(0,2):i==="z"?new I.Vector2(0,1):new I.Vector2(1,2),l=a*2.5,c=new I.PlaneGeometry(l,l);i==="y"?c.rotateX(-Math.PI/2):i==="x"&&c.rotateY(Math.PI/2);let d=new I.ShaderMaterial({vertexShader:ke,fragmentShader:_e,transparent:!0,depthWrite:!1,side:I.DoubleSide,uniforms:{uAxes:{value:s},uCell:{value:r},uMajor:{value:t},uCellColor:{value:new I.Color(n)},uMajorColor:{value:new I.Color(o)},uCenter:{value:new I.Vector3},uFade:{value:a}}}),u=new I.Mesh(c,d);u.name="grid",u.userData.id="grid",u.renderOrder=-1;let m=new I.Vector3;return{object:u,update:E=>{i==="y"?(u.position.set(E.x,0,E.z),m.set(E.x,0,E.z)):i==="z"?(u.position.set(E.x,E.y,0),m.set(E.x,E.y,0)):(u.position.set(0,E.y,E.z),m.set(0,E.y,E.z)),d.uniforms.uCenter.value.copy(m)},setVisible:E=>{u.visible=E},dispose:()=>{c.dispose(),d.dispose()}}}import*as F from"three";import{ViewHelper as Ge}from"three/addons/helpers/ViewHelper.js";function pe(e){let{camera:r,domElement:t,controller:n}=e,o=new Ge(r,t);o.setLabels("X","Y","Z");let a=!0,i=128,s=new F.Raycaster,l=new F.OrthographicCamera(-2,2,2,-2,0,4);l.position.set(0,0,2);let c={posX:new F.Vector3(1,0,0),negX:new F.Vector3(-1,0,0),posY:new F.Vector3(0,1,0),negY:new F.Vector3(0,-1,0),posZ:new F.Vector3(0,0,1),negZ:new F.Vector3(0,0,-1)},d=m=>{let E=t.getBoundingClientRect(),f=E.left+t.offsetWidth-i-o.location.right,x=E.top+t.offsetHeight-i-o.location.bottom,S=new F.Vector2((m.clientX-f)/i*2-1,-((m.clientY-x)/i)*2+1);if(Math.abs(S.x)>1||Math.abs(S.y)>1)return null;o.quaternion.copy(r.quaternion).invert(),o.updateMatrixWorld(),s.setFromCamera(S,l);let b=s.intersectObjects(o.children,!1);for(let g of b){let R=g.object.userData?.type;if(typeof R=="string"&&R in c)return R}return null};return{render:m=>{if(!a)return;let E=m.autoClear;m.autoClear=!1,o.render(m),m.autoClear=E},update:m=>{o.animating&&o.update(m)},handleClick:m=>{if(!a)return!1;let E=d(m);return E?(n.getProjection()==="orthographic"&&n.setProjection("perspective"),n.setViewDirection(c[E],!1),!0):!1},get isAnimating(){return o.animating},setVisible:m=>{a=m},isVisible:()=>a,dispose:()=>o.dispose()}}import*as $ from"three";import{LineSegmentsGeometry as Ne}from"three/addons/lines/LineSegmentsGeometry.js";import{LineSegments2 as fe}from"three/addons/lines/LineSegments2.js";import{LineMaterial as Ue}from"three/addons/lines/LineMaterial.js";var X="edge-overlay",We=2236962,$e=1.5,Ye=30;function he(e,r={}){let t=new $.Color(r.color??We),n=r.width??$e,o=r.thresholdAngle??Ye,a=[];return e.traverse(i=>{if(!(i instanceof $.Mesh)||i.userData.id==="floor"||i.userData.id==="grid"||i.userData.kind===X||i.children.some(l=>l.userData?.kind===X)||!i.geometry)return;let s=Xe(i.geometry,t,n,o);i.add(s),a.push(s)}),a}function Xe(e,r,t,n){let o=new $.EdgesGeometry(e,n),a=new Ne;a.setPositions(Array.from(o.attributes.position.array)),o.dispose();let i=new Ue({color:r});i.linewidth=t,i.polygonOffset=!0,i.polygonOffsetFactor=-1,i.polygonOffsetUnits=-1;let s=new fe(a,i);return s.userData.kind=X,s.raycast=()=>{},s}function qe(e){return e.userData?.kind===X}function On(e){let r=[];e.traverse(t=>{t instanceof fe&&qe(t)&&r.push(t)});for(let t of r)t.geometry.dispose(),t.material.dispose(),t.removeFromParent();return r.length}import{EffectComposer as Ze}from"three/addons/postprocessing/EffectComposer.js";import{RenderPass as Je}from"three/addons/postprocessing/RenderPass.js";import{GTAOPass as Ke}from"three/addons/postprocessing/GTAOPass.js";import{OutputPass as Qe}from"three/addons/postprocessing/OutputPass.js";function ge(e,r,t,n,o,a){let i=new Ze(e),s=new Je(r,t);i.addPass(s);let l=new Ke(r,t,n,o);l.blendIntensity=a.aoIntensity??1,l.updateGtaoMaterial({screenSpaceRadius:!0}),i.addPass(l);let c=new Qe;return i.addPass(c),e.toneMapping=a.toneMapping,e.toneMappingExposure=a.toneMappingExposure,i.setSize(n,o),{render:d=>i.render(d),setSize:(d,u,m)=>{i.setPixelRatio(m),i.setSize(d,u),l.setSize(d,u)},setCamera:d=>{s.camera=d,l.camera=d},dispose:()=>i.dispose()}}import*as be from"three";import{CSS2DRenderer as et,CSS2DObject as tt}from"three/addons/renderers/CSS2DRenderer.js";function ye(e,r){let t=new et,n=t.domElement;n.style.position="absolute",n.style.top="0",n.style.left="0",n.style.width="100%",n.style.height="100%",n.style.overflow="hidden",n.style.pointerEvents="none",n.style.zIndex="30",getComputedStyle(e).position==="static"&&(e.style.position="relative"),e.appendChild(n);let o={width:e.clientWidth||1,height:e.clientHeight||1};t.setSize(o.width,o.height);let a=new be.Group;a.name="label-layer",a.userData.id="label-layer",r.add(a);let i=new Set;return{addLabel:(l,c,d)=>{let u=document.createElement("div");u.textContent=l,d?u.className=d:Object.assign(u.style,{padding:"2px 6px",borderRadius:"4px",background:"rgba(20, 20, 20, 0.78)",color:"#fff",font:"12px/1.3 system-ui, sans-serif",whiteSpace:"pre",textAlign:"center",userSelect:"none"}),u.style.pointerEvents="none";let m=new tt(u);return m.position.copy(c),a.add(m),i.add(m),{object:m,setPosition:E=>m.position.copy(E),setText:E=>{u.textContent=E},remove:()=>{m.removeFromParent(),u.remove(),i.delete(m)}}},render:(l,c)=>t.render(l,c),setSize:(l,c)=>t.setSize(l,c),dispose:()=>{i.forEach(l=>{l.removeFromParent(),l.element.remove()}),i.clear(),a.removeFromParent(),n.remove()}}}import*as A from"three";import{Line2 as nt}from"three/addons/lines/Line2.js";import{LineGeometry as rt}from"three/addons/lines/LineGeometry.js";import{LineMaterial as ot}from"three/addons/lines/LineMaterial.js";var at=12,it=16763904,Re=.015,q=e=>`${e.toPrecision(3)} m`,st=(e,r)=>`${q(e)}
54
54
  \u0394x ${q(r.x)} \u0394y ${q(r.y)} \u0394z ${q(r.z)}`;function lt(e){let r=e.object;return r instanceof A.Mesh?e.face?[e.face.a,e.face.b,e.face.c]:null:r instanceof A.Points?e.index!=null?[e.index]:null:r instanceof A.Line&&e.index!=null?[e.index,e.index+1]:null}function ct(e,r,t,n){let o=e.point.clone(),a=e.object,i=lt(e);if(!i||!a.geometry)return o;let s=a.geometry.attributes.position;if(!s)return o;let l=m=>{let E=m.clone().project(r);return new A.Vector2((E.x+1)/2*t.width,(1-E.y)/2*t.height)},c=l(o),d=o,u=n;for(let m of i){if(m>=s.count)continue;let f=new A.Vector3().fromBufferAttribute(s,m).applyMatrix4(a.matrixWorld),x=l(f).distanceTo(c);x<u&&(u=x,d=f)}return d}function Te(e){let{canvas:r,scene:t,getActiveCamera:n,labelLayer:o,options:a={}}=e,i=a.snapPixels??at,s=new A.Color(a.color??it),l=a.format??st,c=new A.Raycaster,d=new A.Vector2,u=!1,m=[],E=[],f=null,x=null,S=new A.PointsMaterial({color:s,size:8,sizeAttenuation:!1,depthTest:!1}),b=new A.PointsMaterial({color:s,size:11,sizeAttenuation:!1,depthTest:!1,transparent:!0,opacity:.5}),g=null,R=h=>{if(!h){g&&(g.visible=!1);return}if(!g){let T=new A.BufferGeometry;T.setAttribute("position",new A.Float32BufferAttribute([0,0,0],3)),g=new A.Points(T,b),g.renderOrder=1e3,g.userData.id="measure",g.raycast=()=>{},t.add(g)}g.position.copy(h),g.visible=!0},H=h=>{let T=new A.BufferGeometry;T.setAttribute("position",new A.Float32BufferAttribute([h.x,h.y,h.z],3));let M=new A.Points(T,S);return M.renderOrder=999,M.userData.id="measure",M.raycast=()=>{},t.add(M),M},P=()=>{m.length=0,E.forEach(h=>{h.geometry.dispose(),h.removeFromParent()}),E.length=0,f&&(f.geometry.dispose(),f.material.dispose(),f.removeFromParent(),f=null),x?.remove(),x=null},y=()=>{if(m.length!==2)return;let[h,T]=m,M=new rt;M.setPositions([h.x,h.y,h.z,T.x,T.y,T.z]);let k=new ot({color:s});k.linewidth=2,k.depthTest=!1,f=new nt(M,k),f.renderOrder=998,f.userData.id="measure",f.raycast=()=>{},t.add(f);let U=h.clone().add(T).multiplyScalar(.5),W=new A.Vector3(Math.abs(T.x-h.x),Math.abs(T.y-h.y),Math.abs(T.z-h.z));x=o.addLabel(l(h.distanceTo(T),W),U,a.labelClassName)},w=h=>{let T=r.getBoundingClientRect();d.x=(h.clientX-T.left)/T.width*2-1,d.y=-((h.clientY-T.top)/T.height)*2+1;let M=n();c.setFromCamera(d,M);let k=M.position.length();c.params.Line={threshold:k*Re},c.params.Points={threshold:k*Re};let U=c.intersectObjects(t.children,!0).filter(W=>W.object.userData.id!=="measure"&&W.object.userData.id!=="grid");return U.length===0?null:ct(U[0],M,{width:T.width,height:T.height},i)};return{setEnabled:h=>{u=h,h||(P(),R(null))},isEnabled:()=>u,handleClick:h=>{if(!u)return!1;m.length===2&&P();let T=w(h);return T===null||(m.push(T),E.push(H(T)),m.length===2&&y()),!0},handleMove:h=>{u&&R(w(h))},clear:P,dispose:()=>{P(),g&&(g.geometry.dispose(),g.removeFromParent(),g=null),S.dispose(),b.dispose()}}}import*as p from"three";import{OrbitControls as dt}from"three/addons/controls/OrbitControls.js";import{HDRLoader as ut}from"three/addons/loaders/HDRLoader.js";var Z=new p.Vector3(0,0,1);function mt(e){let r=Math.abs(e.x),t=Math.abs(e.y),n=Math.abs(e.z);return n>=r&&n>=t?"z":t>=r&&t>=n?"y":"x"}var nr=function(e,r){let t=Et(r||{}),n=t.environment?.sceneUp||Z,o=gt(t),a=Ht(t,e);a.up.copy(n);let i=vt(e,t),s=Ct(a,e,t),l=me({scene:o,perspective:a,controls:s,onActiveCameraChange:()=>{},up:n}),c=()=>l.getActiveCamera();Rt(o,t);let d=Tt(o,t),u=()=>{d&&ht(d,ne(o))};t.floor?.enabled&&wt(o,t);let m=t.grid.enabled?Ee({cellSize:t.grid.cellSize,majorEvery:t.grid.majorEvery,cellColor:t.grid.cellColor,majorColor:t.grid.majorColor,fadeDistance:t.grid.fadeDistance,plane:t.grid.plane}):null;m&&o.add(m.object);let E=t.gizmo.enabled?pe({camera:a,domElement:e,controller:l}):null,f=e.parentElement??e,x=t.measure.enabled?ye(f,o):null,S=t.measure.enabled&&x?Te({canvas:e,scene:o,getActiveCamera:c,labelLayer:x,options:{snapPixels:t.measure.snapPixels,color:t.measure.color,labelClassName:t.measure.labelClassName,format:t.measure.format}}):null,b=t.events.enableEventHandlers!==!1?Mt(e,o,c,a,s,t):{dispose:()=>{},fitToView:()=>{},clearSelection:()=>{}},g=5,R=0,H=0,P=D=>{R=D.clientX,H=D.clientY},y=D=>Math.hypot(D.clientX-R,D.clientY-H)>g,w=D=>{if(!y(D)){if(S?.handleClick(D)){D.stopImmediatePropagation();return}E?.handleClick(D)&&D.stopImmediatePropagation()}};(E||S)&&(e.addEventListener("mousedown",P,{capture:!0}),e.addEventListener("click",w,{capture:!0}));let C=D=>S?.handleMove(D);S&&e.addEventListener("mousemove",C,{passive:!0});let O=D=>{he(D,{color:t.edges.color,width:t.edges.width,thresholdAngle:t.edges.thresholdAngle})},h=e.parentElement,T=()=>h?{width:h.clientWidth,height:h.clientHeight}:{width:window.innerWidth,height:window.innerHeight},M=null,k=()=>{let{width:D,height:G}=T(),Q=Math.min(window.devicePixelRatio,2),le=ge(i,o,c(),Math.max(1,D),Math.max(1,G),{toneMapping:t.render.toneMapping??p.NeutralToneMapping,toneMappingExposure:t.render.toneMappingExposure??1,aoIntensity:t.render.aoIntensity});return le.setSize(Math.max(1,D),Math.max(1,G),Q),le},U=D=>{D&&!M?M=k():!D&&M&&(M.dispose(),M=null)};t.render.ambientOcclusion&&(M=k());let{animate:W,dispose:K}=yt(i,o,a,c,l,s,T,t.events.onFrame,m,E,()=>M,x);return W(),o.up.set(n.x,n.y,n.z),u(),{scene:o,camera:a,controls:s,renderer:i,cameraController:l,grid:m,gizmo:E,measureTool:S,applyEdges:O,setAmbientOcclusion:U,updateShadowBounds:u,dispose:()=>{K(),b.dispose(),(E||S)&&(e.removeEventListener("mousedown",P,{capture:!0}),e.removeEventListener("click",w,{capture:!0})),S&&e.removeEventListener("mousemove",C),S?.dispose(),x?.dispose(),E?.dispose(),m?.dispose(),M?.dispose(),s.dispose(),i.dispose(),o.traverse(D=>{let G=D;!G.geometry&&!G.material||(G.geometry?.dispose(),Array.isArray(G.material)?G.material.forEach(Q=>Q.dispose()):G.material?.dispose())})},fitToView:b.fitToView,clearSelection:b.clearSelection}};function Et(e){let r=e.sceneScale||"m",n={mm:{cameraDistance:20,near:.1,far:2e3,floorSize:100,lightDistance:10,lightHeight:20,minDistance:.1,shadowSize:100,scaleFactor:1e3},cm:{cameraDistance:20,near:.1,far:2e3,floorSize:100,lightDistance:25,lightHeight:50,minDistance:.1,shadowSize:100,scaleFactor:100},m:{cameraDistance:10,near:.01,far:2e3,floorSize:50,lightDistance:25,lightHeight:50,minDistance:.001,shadowSize:100,scaleFactor:1},inches:{cameraDistance:15,near:.1,far:2e3,floorSize:80,lightDistance:20,lightHeight:40,minDistance:.1,shadowSize:80,scaleFactor:39.37},feet:{cameraDistance:8,near:.1,far:2e3,floorSize:40,lightDistance:15,lightHeight:30,minDistance:.1,shadowSize:60,scaleFactor:3.28084}}[r];return{sceneScale:r,camera:{position:e.camera?.position||new p.Vector3(-n.cameraDistance,-n.cameraDistance,n.cameraDistance),fov:e.camera?.fov||20,near:e.camera?.near||n.near,far:e.camera?.far||n.far,target:e.camera?.target||new p.Vector3(0,0,0)},lighting:{enableSunlight:e.lighting?.enableSunlight??!0,sunlightIntensity:e.lighting?.sunlightIntensity||1,sunlightPosition:e.lighting?.sunlightPosition||new p.Vector3(n.lightDistance,n.lightDistance,n.lightHeight),ambientLightColor:e.lighting?.ambientLightColor||new p.Color(4210752),ambientLightIntensity:e.lighting?.ambientLightIntensity||1,sunlightColor:e.lighting?.sunlightColor||16777215},environment:{hdrPath:e.environment?.hdrPath||"/baseHDR.hdr",backgroundColor:e.environment?.backgroundColor||new p.Color(15790320),enableEnvironmentLighting:e.environment?.enableEnvironmentLighting??!0,sceneUp:e.environment?.sceneUp||Z,showEnvironment:e.environment?.showEnvironment??!1},floor:{enabled:e.floor?.enabled??!1,size:e.floor?.size||n.floorSize,color:e.floor?.color||new p.Color(8421504),roughness:e.floor?.roughness||.7,metalness:e.floor?.metalness||0,receiveShadow:e.floor?.receiveShadow??!0},render:{enableShadows:e.render?.enableShadows??!0,shadowMapSize:e.render?.shadowMapSize||2048,antialias:e.render?.antialias??!0,pixelRatio:e.render?.pixelRatio||Math.min(window.devicePixelRatio,2),toneMapping:e.render?.toneMapping||p.NeutralToneMapping,toneMappingExposure:e.render?.toneMappingExposure||1,preserveDrawingBuffer:e.render?.preserveDrawingBuffer??!1,ambientOcclusion:e.render?.ambientOcclusion??!1,aoIntensity:e.render?.aoIntensity??1},controls:{enableDamping:e.controls?.enableDamping??!1,dampingFactor:e.controls?.dampingFactor||.05,autoRotate:e.controls?.autoRotate??!1,autoRotateSpeed:e.controls?.autoRotateSpeed||.5,enableZoom:e.controls?.enableZoom??!0,enablePan:e.controls?.enablePan??!0,minDistance:e.controls?.minDistance||n.minDistance,maxDistance:e.controls?.maxDistance||1/0},grid:{enabled:e.grid?.enabled??!1,cellSize:e.grid?.cellSize??1,majorEvery:e.grid?.majorEvery??10,cellColor:e.grid?.cellColor??8947848,majorColor:e.grid?.majorColor??4473924,fadeDistance:e.grid?.fadeDistance??100,plane:e.grid?.plane??mt(e.environment?.sceneUp??Z)},gizmo:{enabled:e.gizmo?.enabled??!1},edges:{enabled:e.edges?.enabled??!1,color:e.edges?.color??2236962,width:e.edges?.width??1.5,thresholdAngle:e.edges?.thresholdAngle??30},measure:{enabled:e.measure?.enabled??!1,snapPixels:e.measure?.snapPixels,color:e.measure?.color,labelClassName:e.measure?.labelClassName,format:e.measure?.format},events:{onBackgroundClicked:e.events?.onBackgroundClicked,onObjectSelected:e.events?.onObjectSelected,onMeshMetadataClicked:e.events?.onMeshMetadataClicked,onMeshDoubleClicked:e.events?.onMeshDoubleClicked,selectionColor:e.events?.selectionColor||"#ff0000",enableEventHandlers:e.events?.enableEventHandlers??!0,enableKeyboardControls:e.events?.enableKeyboardControls??!0,enableClickToFocus:e.events?.enableClickToFocus??!0,enableDoubleClickZoom:e.events?.enableDoubleClickZoom??!0,onReady:e.events?.onReady,onFrame:e.events?.onFrame}}}var pt=new Set(["grid","floor","label-layer","measure"]);function ft(e){let r=e;for(;r;){if(typeof r.userData.id=="string"&&pt.has(r.userData.id))return!0;r=r.parent}return!1}function ne(e){let r=new p.Box3;return e.traverse(t=>{let n=t;t.visible&&!ft(t)&&n.geometry&&r.expandByObject(t)}),r}function ht(e,r){if(r.isEmpty())return;let t=r.getCenter(new p.Vector3),n=r.getSize(new p.Vector3).length()*.5*1.2,o=e.shadow.camera;o.left=-n,o.right=n,o.top=n,o.bottom=-n,e.target.position.copy(t),e.target.updateMatrixWorld();let a=e.position.distanceTo(t);o.near=Math.max(n*.01,a-n),o.far=a+n,o.updateProjectionMatrix()}function gt(e){let r=new p.Scene,t=typeof e.environment.backgroundColor=="string"?new p.Color(e.environment.backgroundColor):e.environment.backgroundColor;return r.background=t||null,r}function bt(e,r,t,n,o=200){let a=e.position.clone(),i=r.target.clone(),s=performance.now(),l=d=>1-Math.pow(1-d,3),c=()=>{let d=performance.now()-s,u=l(Math.min(d/o,1));e.position.lerpVectors(a,t,u),r.target.lerpVectors(i,n,u),r.update(),u<1&&requestAnimationFrame(c)};requestAnimationFrame(c)}function yt(e,r,t,n,o,a,i,s,l,c,d,u){let m=null,E=performance.now(),f=()=>{let{width:b,height:g}=i();if(b===0||g===0)return;let R=Math.min(window.devicePixelRatio,2),H=Math.round(b*R),P=Math.round(g*R);(e.domElement.width!==H||e.domElement.height!==P)&&(e.setPixelRatio(R),e.setSize(b,g,!1),t.aspect=b/g,t.updateProjectionMatrix(),o.updateAspect(b,g),d?.()?.setSize(b,g,R),u?.setSize(b,g))},x=function(){m=requestAnimationFrame(x);let b=performance.now(),g=(b-E)/1e3;E=b,f(),(a.enableDamping||a.autoRotate)&&a.update(),l&&l.update(n().position),c&&c.update(g),s?.(g);let R=n(),H=d?.();H?(H.setCamera(R),H.render(g)):e.render(r,R),u&&u.render(r,R),c&&c.render(e)};return{animate:x,dispose:()=>{m!==null&&(cancelAnimationFrame(m),m=null)}}}function Rt(e,r){r.environment.enableEnvironmentLighting?new ut().load(r.environment.hdrPath||"/baseHDR.hdr",function(t){if(!t?.image){v().warn("HDR loaded without image data; skipping environment map."),r.events.onReady?.();return}t.mapping=p.EquirectangularReflectionMapping,e.environment=t,r.environment.showEnvironment&&(e.background=t),r.events.onReady?.()},void 0,function(t){v().warn("HDR texture could not be loaded, falling back to basic lighting:",t),r.events.onReady?.()}):r.events.onReady?.()}function Tt(e,r){let t=new p.AmbientLight(r.lighting.ambientLightColor,r.lighting.ambientLightIntensity);if(e.add(t),!r.lighting.enableSunlight)return null;let n=new p.DirectionalLight(r.lighting.sunlightColor??16777215,r.lighting.sunlightIntensity),o=r.lighting.sunlightPosition;return o&&n.position.set(o.x,o.y,o.z),r.render.enableShadows?(n.castShadow=!0,n.shadow.mapSize.width=r.render.shadowMapSize||2048,n.shadow.mapSize.height=r.render.shadowMapSize||2048,n.shadow.bias=-1e-4,n.shadow.normalBias=.02,n.shadow.radius=4,e.add(n),e.add(n.target),n):(e.add(n),null)}function wt(e,r){let t=r.floor.size,n=new p.PlaneGeometry(t,t),o=typeof r.floor.color=="string"?new p.Color(r.floor.color):r.floor.color,a=new p.MeshStandardMaterial({color:o,roughness:r.floor.roughness,metalness:r.floor.metalness,side:p.DoubleSide}),i=new p.Mesh(n,a);i.userData.id="floor",i.name="floor";let s=(r.environment?.sceneUp||Z).clone().normalize();i.quaternion.setFromUnitVectors(new p.Vector3(0,0,1),s),i.position.set(0,0,0),r.floor.receiveShadow&&r.render.enableShadows&&(i.receiveShadow=!0),e.add(i)}function Ht(e,r){let t=r.parentElement,n=t?t.clientWidth:window.innerWidth,o=t?t.clientHeight:window.innerHeight,a=new p.PerspectiveCamera(e.camera.fov,n/o,e.camera.near,e.camera.far),i=e.camera.position;return i&&a.position.set(i.x,i.y,i.z),a}function vt(e,r){let t=new p.WebGLRenderer({antialias:r.render.antialias,canvas:e,alpha:!0,powerPreference:"high-performance",preserveDrawingBuffer:r.render.preserveDrawingBuffer,logarithmicDepthBuffer:!0}),n=e.parentElement,o=n?n.clientWidth:window.innerWidth,a=n?n.clientHeight:window.innerHeight;return n&&(e.style.width="100%",e.style.height="100%",e.style.display="block"),t.setSize(o,a,!1),t.setPixelRatio(r.render.pixelRatio||Math.min(window.devicePixelRatio,2)),r.render.enableShadows&&(t.shadowMap.enabled=!0,t.shadowMap.type=p.VSMShadowMap),t.toneMapping=r.render.toneMapping,t.toneMappingExposure=r.render.toneMappingExposure||1,t.outputColorSpace=p.SRGBColorSpace,t.sortObjects=!0,t}function Mt(e,r,t,n,o,a){let i=new Set,s=new Map,l=new p.Raycaster,c=new p.Vector2,d=new p.Vector2,u=y=>{let w=y;for(;w;){if(!w.visible)return!1;w=w.parent}return!0},m=()=>{let y=ne(r);if(y.isEmpty()){v().warn("No objects to fit to view");return}let w=y.getCenter(new p.Vector3),C=y.getSize(new p.Vector3),O=Math.max(C.x,C.y,C.z),h=n.fov*(Math.PI/180),T=O/(2*Math.tan(h/2));T*=1.5;let M=n.position.clone().sub(o.target);M.lengthSq()<1e-12&&M.set(.8,1,1.2),M.normalize(),n.position.copy(w.clone().add(M.multiplyScalar(T))),o.target.copy(w),o.update()},E=typeof a.events.selectionColor=="string"?new p.Color(a.events.selectionColor):a.events.selectionColor instanceof p.Color?a.events.selectionColor:new p.Color("#ff0000"),f=()=>{i.forEach(y=>{let w=y;if(s.has(y)){let C=s.get(y),O=w.material;O instanceof p.Material?O.dispose():Array.isArray(O)&&O.forEach(h=>h.dispose()),w.material=C,s.delete(y)}}),i.clear()},x=y=>{let w=y;if(!(w.material instanceof p.Material))return!1;s.set(y,w.material);let C=w.material.clone();return y instanceof p.Mesh&&"emissive"in C?C.emissive=E.clone():"color"in C&&(C.color=E.clone()),w.material=C,!0},S=()=>{let y=ne(r),w=y.isEmpty()?1:y.getSize(new p.Vector3).length();l.params.Points.threshold=w*.01},b=y=>{d.set(y.clientX,y.clientY)},g=y=>{let w=new p.Vector2(y.clientX,y.clientY);if(d.distanceTo(w)>5)return;let C=e.getBoundingClientRect();c.x=(y.clientX-C.left)/C.width*2-1,c.y=-((y.clientY-C.top)/C.height)*2+1,S(),l.setFromCamera(c,t());let O=l.intersectObjects(r.children,!0).filter(h=>u(h.object));if(O.length>0){let h=O[0].object;i.has(h)||(f(),i.add(h),x(h),a.events?.onObjectSelected?.(h),h instanceof p.Mesh&&Object.keys(h.userData).length>0&&a.events?.onMeshMetadataClicked?.(h.userData))}else f(),a.events?.onBackgroundClicked?.({x:c.x,y:c.y})},R=y=>{let w=e.getBoundingClientRect();c.x=(y.clientX-w.left)/w.width*2-1,c.y=-((y.clientY-w.top)/w.height)*2+1,S(),l.setFromCamera(c,t());let C=l.intersectObjects(r.children,!0).filter(D=>u(D.object));if(C.length===0)return;let O=C[0].object;if(a.events?.onMeshDoubleClicked?.(O),!a.events?.enableDoubleClickZoom)return;let h=new p.Box3().setFromObject(O);if(h.isEmpty())return;let T=h.getCenter(new p.Vector3),M=h.getSize(new p.Vector3),k=Math.max(M.x,M.y,M.z),U=n.fov*(Math.PI/180),W=k/(2*Math.tan(U/2))*1.5,K=n.position.clone().sub(o.target).normalize(),se=T.clone().add(K.multiplyScalar(W));bt(n,o,se,T)},H=y=>{if(a.events?.enableKeyboardControls)switch(y.key.toLowerCase()){case"f":y.preventDefault(),m();break;case"escape":y.preventDefault(),f();break;case" ":y.preventDefault(),m();break}};return a.events?.enableClickToFocus&&(e.addEventListener("mousedown",b),e.addEventListener("click",g),e.addEventListener("dblclick",R)),a.events?.enableKeyboardControls&&(e.setAttribute("tabindex","0"),e.addEventListener("keydown",H)),{dispose:()=>{e.removeEventListener("mousedown",b),e.removeEventListener("click",g),e.removeEventListener("dblclick",R),e.removeEventListener("keydown",H),f()},fitToView:m,clearSelection:f}}function Ct(e,r,t){let n=new dt(e,r),o=t.camera.target;return o&&n.target.set(o.x,o.y,o.z),n.enableDamping=t.controls.enableDamping||!1,n.dampingFactor=t.controls.dampingFactor||.05,n.autoRotate=t.controls.autoRotate||!1,n.autoRotateSpeed=t.controls.autoRotateSpeed||.5,n.enableZoom=t.controls.enableZoom??!0,n.enablePan=t.controls.enablePan??!0,n.minDistance=t.controls.minDistance||.001,n.maxDistance=t.controls.maxDistance||1/0,n.screenSpacePanning=!1,n.maxPolarAngle=Math.PI,n.update(),n}var It={};De(It,{CONCRETE_MATERIAL:()=>At,EMISSIVE_MATERIAL:()=>xt,GLASS_MATERIAL:()=>Lt,METAL_MATERIAL:()=>St,PLASTIC_MATERIAL:()=>Dt,RUBBER_MATERIAL:()=>Pt,WOOD_MATERIAL:()=>Ot});import*as L from"three";var xt=new L.MeshPhysicalMaterial({color:0,emissive:new L.Color(16777215),emissiveIntensity:5,metalness:0,roughness:.2,clearcoat:.3,clearcoatRoughness:.2,depthWrite:!0,depthTest:!0,transparent:!1,alphaTest:0,polygonOffset:!0,side:L.FrontSide,dithering:!0}),St=new L.MeshPhysicalMaterial({color:new L.Color(0),metalness:.9,roughness:.3,envMapIntensity:1.2,clearcoat:.3,clearcoatRoughness:.2,reflectivity:1,ior:2.5,thickness:1,depthWrite:!0,transparent:!1,alphaTest:0,depthTest:!0,polygonOffset:!0,side:L.FrontSide,dithering:!0}),At=new L.MeshPhysicalMaterial({color:new L.Color(13421772),metalness:0,roughness:.92,envMapIntensity:.15,clearcoat:.05,clearcoatRoughness:.9,reflectivity:.15,transmission:0,ior:1.45,thickness:0,depthWrite:!0,transparent:!1,alphaTest:.5,depthTest:!0,polygonOffset:!0,side:L.FrontSide,dithering:!0}),Dt=new L.MeshPhysicalMaterial({color:new L.Color(16777215),metalness:0,roughness:.3,envMapIntensity:.5,clearcoat:.5,clearcoatRoughness:.1,reflectivity:.5,ior:1.4,transmission:0,transparent:!1,depthWrite:!0,side:L.FrontSide,dithering:!0,polygonOffset:!0,polygonOffsetFactor:1,polygonOffsetUnits:1}),Lt=new L.MeshPhysicalMaterial({color:new L.Color(16777215),metalness:0,roughness:0,transmission:.95,transparent:!0,opacity:.3,envMapIntensity:1,clearcoat:1,clearcoatRoughness:0,ior:1.52,reflectivity:.9,thickness:1,side:L.DoubleSide,polygonOffset:!0,polygonOffsetFactor:1,polygonOffsetUnits:1}),Pt=new L.MeshPhysicalMaterial({color:new L.Color(1710618),metalness:0,roughness:.9,envMapIntensity:.2,clearcoat:.1,clearcoatRoughness:.8,reflectivity:.2,ior:1.3,transmission:0,depthWrite:!0,side:L.FrontSide,polygonOffset:!0,polygonOffsetFactor:1,polygonOffsetUnits:1}),Ot=new L.MeshPhysicalMaterial({color:new L.Color(8934707),metalness:0,roughness:.7,envMapIntensity:.3,clearcoat:.3,clearcoatRoughness:.4,reflectivity:.3,ior:1.3,transmission:0,depthWrite:!0,side:L.FrontSide,dithering:!0,polygonOffset:!0,polygonOffsetFactor:1,polygonOffsetUnits:1});import*as j from"three";import{Line2 as Vt}from"three/addons/lines/Line2.js";import{LineGeometry as Bt}from"three/addons/lines/LineGeometry.js";import{LineMaterial as zt}from"three/addons/lines/LineMaterial.js";function J(e,r,t,n=!0){return{x:e,y:r,z:t}}var Ft="#ffffff",re=12,jt=4e-4,kt=12,_t=.05;function we(e,r={}){if(!e||e.length===0)return[];let{rhino:t,applyTransforms:n=!0}=r,o=[];for(let a of e)switch(a.kind){case"curve":{let i=Nt(a,t,n);i&&o.push(i);break}case"point":{o.push(Ut(a,n));break}default:{let i=a;v().warn(`Skipping unknown display item kind: ${String(i.kind)}`);break}}return o}var Gt=2;function Nt(e,r,t){if(!r)return v().warn("No rhino3dm instance provided; skipping curve display item."),null;let n=Wt(e.json,r);if(!n)return null;let o=$t(n,t);if(o.length<2)return null;let a=[];for(let u of o)a.push(u.x,u.y,u.z);let i=new Bt;i.setPositions(a);let s=He(e.color,e.opacity),l=new zt({color:s.color}),c=l;c.linewidth=e.width??Gt,c.transparent=s.transparent,c.opacity=s.opacity;let d=new Vt(i,l);return d.computeLineDistances(),d.name=e.name,d.userData={id:e.id,layer:e.layer,kind:"curve",metadata:e.metadata},d}function Ut(e,r){let{x:t,y:n,z:o}=J(e.position.X,e.position.Y,e.position.Z,r),a=new j.BufferGeometry;a.setAttribute("position",new j.Float32BufferAttribute([t,n,o],3));let i=new j.PointsMaterial({...He(e.color,e.opacity),size:6,sizeAttenuation:!1}),s=new j.Points(a,i);return s.name=e.name,s.userData={id:e.id,layer:e.layer,kind:"point",metadata:e.metadata},s}function Wt(e,r){try{let t=JSON.parse(e),n=r.CommonObject.decode(t);return n&&typeof n.pointAt=="function"?n:(v().warn("Decoded display-item JSON is not a curve; skipping."),null)}catch(t){return v().warn("Failed to decode curve display item JSON:",t),null}}function $t(e,r){let t=Yt(e,r);return t||Xt(e,r)}function Yt(e,r){if(!e.isPolyline())return null;let t=e.tryGetPolyline(),n=Array.isArray(t)?t[1]:t;if(!n||typeof n.count!="number"||n.count<2)return null;let o=[];for(let a=0;a<n.count;a++){let i=n.get(a),{x:s,y:l,z:c}=J(i[0],i[1],i[2],r);o.push(new j.Vector3(s,l,c))}return o}function Xt(e,r){let t=e.domain,n=t[0],a=t[1]-n,i=c=>{let d=e.pointAt(c),{x:u,y:m,z:E}=J(d[0],d[1],d[2],r);return new j.Vector3(u,m,E)},s=qt(e),l=[i(n)];for(let c=0;c<re;c++){let d=n+a*c/re,u=n+a*(c+1)/re;oe(d,i(d),u,i(u),i,s,kt,l),l.push(i(u))}return l}function oe(e,r,t,n,o,a,i,s){if(i<=0)return;let l=(e+t)/2,c=o(l),d=Jt(c,r,n),u=Zt(r,c,n);d<=a&&u<=_t||(oe(e,r,l,c,o,a,i-1,s),s.push(c),oe(l,c,t,n,o,a,i-1,s))}function qt(e){let r=e.getBoundingBox(),t=r.min,n=r.max,o=Math.hypot(n[0]-t[0],n[1]-t[1],n[2]-t[2]);return Math.max(o*jt,1e-6)}function Zt(e,r,t){let n=r.clone().sub(e),o=t.clone().sub(r),a=n.length(),i=o.length();if(a===0||i===0)return 0;let s=Math.max(-1,Math.min(1,n.dot(o)/(a*i)));return Math.acos(s)}function Jt(e,r,t){let n=t.clone().sub(r),o=n.lengthSq();if(o===0)return e.distanceTo(r);let a=Math.max(0,Math.min(1,e.clone().sub(r).dot(n)/o)),i=r.clone().addScaledVector(n,a);return e.distanceTo(i)}function He(e,r){let t=r??1;return{color:new j.Color(e??Ft),transparent:t<1,opacity:t}}var ve=1096174675,Me=1,ae=1,Ce=12,xe=56;function ie(e){let r=Kt(e),t=new DataView(r.buffer,r.byteOffset,r.byteLength);if(r.byteLength<Ce)throw N("Blob too small to contain SLVA header.",{expectedBytes:Ce,availableBytes:r.byteLength});let n=0,o=t.getUint32(n,!0);if(n+=4,o!==ve)throw N(`Invalid SLVA magic: 0x${o.toString(16)}`,{expectedMagic:`0x${ve.toString(16)}`,actualMagic:`0x${o.toString(16)}`});let a=t.getUint32(n,!0);if(n+=4,a!==Me)throw N(`Unsupported SLVA version: ${a}`,{expectedVersion:Me,actualVersion:a});let i=t.getUint32(n,!0);if(n+=4,n+i>r.byteLength)throw N("Insufficient data to read metadata JSON.",{expectedBytes:i,availableBytes:r.byteLength-n,offset:n});let s=r.subarray(n,n+i);n+=i;let l;try{l=JSON.parse(Qt(s))}catch(h){throw N(`Failed to parse metadata JSON: ${h instanceof Error?h.message:String(h)}`,{metadataLen:i})}if(n+xe>r.byteLength)throw N("Insufficient data to read geometry header.",{expectedBytes:xe,availableBytes:r.byteLength-n,offset:n});let c=t.getUint32(n,!0);n+=4;let d=t.getFloat64(n,!0);n+=8;let u=t.getFloat64(n,!0);n+=8;let m=t.getFloat64(n,!0);n+=8;let E=t.getFloat64(n,!0);n+=8;let f=t.getFloat64(n,!0);n+=8;let x=t.getFloat64(n,!0);n+=8;let S=t.getUint32(n,!0);n+=4;let b=(c&ae)!==0,g=S*3,H=g*(b?4:2);if(n+H>r.byteLength)throw N("Insufficient data to read vertices.",{expectedBytes:H,availableBytes:r.byteLength-n,offset:n,useFloat32:b,vertexCount:S});let P=r.byteOffset+n,y=b?tn(r.buffer,P,g):en(r.buffer,P,g);if(n+=H,n+4>r.byteLength)throw N("Insufficient data to read index count.",{expectedBytes:4,availableBytes:r.byteLength-n,offset:n});let w=t.getUint32(n,!0);n+=4;let C=w*4;if(n+C>r.byteLength)throw N("Insufficient data to read indices.",{expectedBytes:C,availableBytes:r.byteLength-n,offset:n,indexCount:w});let O=nn(r.buffer,r.byteOffset+n,w);return{metadata:l,flags:c,vertices:y,indices:O,origin:[d,u,m],scale:[E,f,x]}}function Kt(e){return typeof e=="string"?ce(e):e instanceof Uint8Array?e:new Uint8Array(e)}function Qt(e){if(typeof TextDecoder<"u")return new TextDecoder("utf-8").decode(e);if(typeof globalThis.Buffer<"u")return globalThis.Buffer.from(e).toString("utf-8");throw new te("No UTF-8 decoder available in this environment.",ee.INVALID_STATE)}function en(e,r,t){if(t===0)return new Int16Array(0);if(r%2===0)return new Int16Array(e,r,t);let n=new Uint8Array(t*2);return n.set(new Uint8Array(e,r,t*2)),new Int16Array(n.buffer)}function tn(e,r,t){if(t===0)return new Float32Array(0);if(r%4===0)return new Float32Array(e,r,t);let n=new Uint8Array(t*4);return n.set(new Uint8Array(e,r,t*4)),new Float32Array(n.buffer)}function nn(e,r,t){if(t===0)return new Uint32Array(0);if(r%4===0)return new Uint32Array(e,r,t);let n=new Uint8Array(t*4);return n.set(new Uint8Array(e,r,t*4)),new Uint32Array(n.buffer)}function N(e,r){return new te(e,ee.VALIDATION_ERROR,{context:r})}import*as B from"three";async function Se(e,r){let{debug:t=!1}=r??{},n=t?performance.now():0;try{let o=performance.now(),a=JSON.parse(e),i=performance.now()-o;return await rn(a,r,{parseTime:i,perfStart:n})}catch(o){return v().error("Error parsing mesh batch:",o),[]}}async function rn(e,r,t){let{mergeByMaterial:n=!0,applyTransforms:o=!0,scaleFactor:a=1,debug:i=!1}=r??{},{parseTime:s=0,perfStart:l=i?performance.now():0}=t??{};try{let c=performance.now(),d=ie(e.compressedData),u=performance.now()-c,m=i?dn(e.compressedData):0;return Ae(d,{mergeByMaterial:n,applyTransforms:o,scaleFactor:a,debug:i,parseTime:s,decodeTime:u,perfStart:l,blobBytes:m,fallback:{materials:e.materials,groups:e.groups,sourceComponentId:e.sourceComponentId}})}catch(c){return v().error("Error parsing mesh batch object:",c),[]}}async function gr(e,r){let{mergeByMaterial:t=!0,applyTransforms:n=!0,scaleFactor:o=1,debug:a=!1}=r??{},i=a?performance.now():0;try{let s=performance.now(),l=ie(e),c=performance.now()-s,d=e.byteLength;return Ae(l,{mergeByMaterial:t,applyTransforms:n,scaleFactor:o,debug:a,parseTime:0,decodeTime:c,perfStart:i,blobBytes:d})}catch(s){return v().error("Error parsing mesh batch blob:",s),[]}}function Ae(e,r){let{mergeByMaterial:t,applyTransforms:n,scaleFactor:o,debug:a,parseTime:i,decodeTime:s,perfStart:l,blobBytes:c,fallback:d}=r,u=e.metadata.materials??d?.materials??[],m=e.metadata.groups??d?.groups??[],E=e.metadata.sourceComponentId??d?.sourceComponentId,f=(e.flags&ae)!==0,x=f?an(e.vertices,n):on(e.vertices,e.origin,e.scale,n);if(a){let H=e.vertices.byteLength+e.indices.byteLength;v().debug("Mesh Batch Stats:"),v().debug(` Materials: ${u.length} | Groups: ${m.length}`),v().debug(` Vertices: ${e.vertices.length/3} | Indices: ${e.indices.length}`),v().debug(` Format: ${f?"float32":"int16 quantized"}`),v().debug(` Blob: ${(c/1024/1024).toFixed(2)} MB | Geometry on wire: ${(H/1024/1024).toFixed(2)} MB`)}let S=performance.now(),b=u.map(sn),g=[];for(let H of m)if(t&&H.meshes.length>1){let P=ln(H,x,e.indices,b);P.userData.sourceComponentId=E??null,g.push(P)}else{let P=cn(H,x,e.indices,b);for(let y of P)y.userData.sourceComponentId=E??null;g.push(...P)}if(o!==1)for(let H of g)H.scale.set(o,o,o);let R=performance.now()-S;if(a){let H=performance.now()-l;v().debug("Performance:"),i>0&&v().debug(` Parse JSON: ${i.toFixed(2)}ms`),v().debug(` Decode binary: ${s.toFixed(2)}ms`),v().debug(` Create Meshes: ${R.toFixed(2)}ms`),v().debug(` Total: ${H.toFixed(2)}ms`)}return Promise.resolve(g)}function on(e,r,t,n){let o=new Float32Array(e.length),a=r[0],i=r[1],s=r[2],l=t[0],c=t[1],d=t[2];for(let u=0;u<e.length;u+=3)o[u]=a+(e[u]+32767)*l,o[u+1]=i+(e[u+1]+32767)*c,o[u+2]=s+(e[u+2]+32767)*d;return o}function an(e,r){return e}function sn(e){let r=de(e.color);return new B.MeshPhysicalMaterial({color:r,metalness:e.metalness,roughness:e.roughness,opacity:e.opacity,transparent:e.transparent,side:B.DoubleSide,polygonOffset:!0,polygonOffsetFactor:.5,polygonOffsetUnits:.5,depthWrite:!0,depthTest:!0})}function ln(e,r,t,n){let o=0,a=0;for(let f of e.meshes)o+=f.vertexCount,a+=f.indexCount;let i=new Float32Array(o*3),s=new Uint32Array(a),l=0,c=0;for(let f of e.meshes){let x=f.vertexStart*3,S=f.vertexCount*3;i.set(r.subarray(x,x+S),l*3);let b=t.subarray(f.indexStart,f.indexStart+f.indexCount),g=l-f.vertexStart;if(g===0)s.set(b,c);else for(let R=0;R<b.length;R++)s[c+R]=b[R]+g;l+=f.vertexCount,c+=f.indexCount}let d=new B.BufferGeometry;d.setAttribute("position",new B.BufferAttribute(i,3)),d.setIndex(new B.BufferAttribute(s,1)),d.computeVertexNormals();let u=new B.Mesh(d,n[e.materialId]),m=e.meshes[0],E=e.meshes.map(f=>f.name).filter(f=>f&&f.length>0);return u.name=E.length>0?E[0]:`merged_material_${e.materialId}`,u.castShadow=!0,u.receiveShadow=!0,u.userData={name:u.name,layer:m?.layer??"",originalIndex:m?.originalIndex??0,metadata:m?.metadata??{},mergedFrom:e.meshes.slice(1).map(f=>({name:f.name,layer:f.layer,originalIndex:f.originalIndex}))},u}function cn(e,r,t,n){let o=[];for(let a of e.meshes){let i=a.vertexStart*3,s=a.vertexCount*3,l=r.slice(i,i+s),c=t.subarray(a.indexStart,a.indexStart+a.indexCount),d=new Uint32Array(c.length),u=a.vertexStart;for(let f=0;f<c.length;f++)d[f]=c[f]-u;let m=new B.BufferGeometry;m.setAttribute("position",new B.BufferAttribute(l,3)),m.setIndex(new B.BufferAttribute(d,1)),m.computeVertexNormals();let E=new B.Mesh(m,n[e.materialId]);E.name=a.name,E.userData={name:a.name,layer:a.layer??"",originalIndex:a.originalIndex,metadata:a.metadata??{}},E.castShadow=!0,E.receiveShadow=!0,o.push(E)}return o}function dn(e){return Math.floor(e.length*3/4)}var un={Millimeters:1/1e3,Centimeters:1/100,Meters:1,Inches:1/39.37,Feet:1/3.28084},mn="Display";async function Hr(e,r){let t=performance.now(),n=[],{allowScaling:o=!0,allowAutoPosition:a=!0,rhino:i,debug:s=!1,parsing:l={}}=r??{};try{let c=o?En(e.modelunits):1;return await pn(e,n,c,l,i,s),a&&bn(n),n}catch(c){throw yn(c,n),c}finally{s&&Tn(t)}}function En(e){return un[e]??1}async function pn(e,r,t,n,o,a){for(let i of e.values){let s=i.InnerTree;for(let l in s){let c=s[l];c&&await fn(c,r,t,n,o,a)}}}async function fn(e,r,t,n,o,a){for(let i of e){if(!i.type.includes(mn))continue;let s={mergeByMaterial:!0,applyTransforms:!0,debug:!1,...n},l=await Se(i.data,s),c=we(hn(i.data),{rhino:o,applyTransforms:s.applyTransforms}),d=[...l,...c];if(t!==1)for(let u of d)u.scale.set(t,t,t);r.push(...d),a&&v().debug(`Extracted ${l.length} meshes and ${c.length} items from batch`)}}function hn(e){return(typeof e=="string"?gn(e):e)?.items}function gn(e){try{return JSON.parse(e)}catch{return}}function bn(e){if(e.length===0)return;let r=Y(e);ue(e,r.min.z,"z")}function yn(e,r){v().error("An unexpected error occurred:",e),Rn(r)}function Rn(e){for(let r of e){let t=r;t.geometry&&t.geometry.dispose(),t.material&&(Array.isArray(t.material)?t.material.forEach(n=>n.dispose()):t.material.dispose())}}function Tn(e){let r=performance.now()-e;v().info("Time to process meshes:",`${r.toFixed(2)}ms`)}export{Hn as a,de as b,ue as c,Y as d,me as e,Ee as f,pe as g,X as h,he as i,qe as j,On as k,ge as l,ye as m,ct as n,Te as o,nr as p,It as q,we as r,ve as s,Me as t,ae as u,ie as v,Se as w,rn as x,gr as y,un as z,Hr as A};
55
- //# sourceMappingURL=chunk-UQ7TD57L.js.map
55
+ //# sourceMappingURL=chunk-WJ2WV4TU.js.map
package/dist/core.cjs CHANGED
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunkBTH6J34Xcjs = require('./chunk-BTH6J34X.cjs');exports.ComputeServerStats = _chunkBTH6J34Xcjs.j; exports.ErrorCodes = _chunkBTH6J34Xcjs.c; exports.RhinoComputeError = _chunkBTH6J34Xcjs.d; exports.camelcaseKeys = _chunkBTH6J34Xcjs.l; exports.downloadFileData = _chunkBTH6J34Xcjs.r; exports.enableDebugLogging = _chunkBTH6J34Xcjs.g; exports.extractFilesFromComputeResponse = _chunkBTH6J34Xcjs.q; exports.fetchRhinoCompute = _chunkBTH6J34Xcjs.h; exports.getLogger = _chunkBTH6J34Xcjs.e; exports.setLogger = _chunkBTH6J34Xcjs.f; exports.toCamelCase = _chunkBTH6J34Xcjs.k;
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunk4UOOVSGLcjs = require('./chunk-4UOOVSGL.cjs');exports.ComputeServerStats = _chunk4UOOVSGLcjs.j; exports.ErrorCodes = _chunk4UOOVSGLcjs.c; exports.RhinoComputeError = _chunk4UOOVSGLcjs.d; exports.camelcaseKeys = _chunk4UOOVSGLcjs.l; exports.downloadFileData = _chunk4UOOVSGLcjs.r; exports.enableDebugLogging = _chunk4UOOVSGLcjs.g; exports.extractFilesFromComputeResponse = _chunk4UOOVSGLcjs.q; exports.fetchRhinoCompute = _chunk4UOOVSGLcjs.h; exports.getLogger = _chunk4UOOVSGLcjs.e; exports.setLogger = _chunk4UOOVSGLcjs.f; exports.toCamelCase = _chunk4UOOVSGLcjs.k;
2
2
  //# sourceMappingURL=core.cjs.map
package/dist/core.d.cts CHANGED
@@ -1,6 +1,6 @@
1
- import { C as ComputeConfig } from './types-D1SkNje_.cjs';
2
- export { R as RetryPolicy, a as RhinoModelUnit, S as ServerTiming } from './types-D1SkNje_.cjs';
3
- export { C as ComputeServerStats, E as ErrorCode, a as ErrorCodes, F as FileBaseInfo, b as FileData, P as ProcessedFile, R as RhinoComputeError, d as downloadFileData, e as extractFilesFromComputeResponse } from './handle-files-D-_fiXu4.cjs';
1
+ import { C as ComputeConfig } from './types-ChF690kY.cjs';
2
+ export { R as RetryPolicy, a as RhinoModelUnit, S as ServerTiming } from './types-ChF690kY.cjs';
3
+ export { C as ComputeServerStats, E as ErrorCode, a as ErrorCodes, F as FileBaseInfo, b as FileData, P as ProcessedFile, R as RhinoComputeError, d as downloadFileData, e as extractFilesFromComputeResponse } from './handle-files-VUQET1YU.cjs';
4
4
 
5
5
  /**
6
6
  * Generic Rhino Compute fetch function.
package/dist/core.d.ts CHANGED
@@ -1,6 +1,6 @@
1
- import { C as ComputeConfig } from './types-D1SkNje_.js';
2
- export { R as RetryPolicy, a as RhinoModelUnit, S as ServerTiming } from './types-D1SkNje_.js';
3
- export { C as ComputeServerStats, E as ErrorCode, a as ErrorCodes, F as FileBaseInfo, b as FileData, P as ProcessedFile, R as RhinoComputeError, d as downloadFileData, e as extractFilesFromComputeResponse } from './handle-files-D-_fiXu4.js';
1
+ import { C as ComputeConfig } from './types-ChF690kY.js';
2
+ export { R as RetryPolicy, a as RhinoModelUnit, S as ServerTiming } from './types-ChF690kY.js';
3
+ export { C as ComputeServerStats, E as ErrorCode, a as ErrorCodes, F as FileBaseInfo, b as FileData, P as ProcessedFile, R as RhinoComputeError, d as downloadFileData, e as extractFilesFromComputeResponse } from './handle-files-VUQET1YU.js';
4
4
 
5
5
  /**
6
6
  * Generic Rhino Compute fetch function.
package/dist/core.js CHANGED
@@ -1,2 +1,2 @@
1
- import{c as a,d as b,e as c,f as d,g as e,h as f,j as g,k as h,l as i,q as j,r as k}from"./chunk-H2FJSNMM.js";export{g as ComputeServerStats,a as ErrorCodes,b as RhinoComputeError,i as camelcaseKeys,k as downloadFileData,e as enableDebugLogging,j as extractFilesFromComputeResponse,f as fetchRhinoCompute,c as getLogger,d as setLogger,h as toCamelCase};
1
+ import{c as a,d as b,e as c,f as d,g as e,h as f,j as g,k as h,l as i,q as j,r as k}from"./chunk-AXAMGKTJ.js";export{g as ComputeServerStats,a as ErrorCodes,b as RhinoComputeError,i as camelcaseKeys,k as downloadFileData,e as enableDebugLogging,j as extractFilesFromComputeResponse,f as fetchRhinoCompute,c as getLogger,d as setLogger,h as toCamelCase};
2
2
  //# sourceMappingURL=core.js.map
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunkHG24GZ3Acjs = require('./chunk-HG24GZ3A.cjs');var _chunkBTH6J34Xcjs = require('./chunk-BTH6J34X.cjs');exports.GrasshopperClient = _chunkHG24GZ3Acjs.d; exports.GrasshopperResponseProcessor = _chunkHG24GZ3Acjs.e; exports.RhinoComputeError = _chunkBTH6J34Xcjs.d; exports.SolveScheduler = _chunkHG24GZ3Acjs.c; exports.TreeBuilder = _chunkHG24GZ3Acjs.j; exports.downloadFileData = _chunkBTH6J34Xcjs.r; exports.extractFilesFromComputeResponse = _chunkBTH6J34Xcjs.q; exports.fetchDefinitionIO = _chunkHG24GZ3Acjs.h; exports.fetchParsedDefinitionIO = _chunkHG24GZ3Acjs.i; exports.hashSolveInput = _chunkHG24GZ3Acjs.b; exports.processInput = _chunkHG24GZ3Acjs.f; exports.processInputs = _chunkHG24GZ3Acjs.g; exports.solveGrasshopperDefinition = _chunkHG24GZ3Acjs.a;
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunkPWNJ3ZLScjs = require('./chunk-PWNJ3ZLS.cjs');var _chunk4UOOVSGLcjs = require('./chunk-4UOOVSGL.cjs');exports.GrasshopperClient = _chunkPWNJ3ZLScjs.d; exports.GrasshopperResponseProcessor = _chunkPWNJ3ZLScjs.e; exports.RhinoComputeError = _chunk4UOOVSGLcjs.d; exports.SolveScheduler = _chunkPWNJ3ZLScjs.c; exports.TreeBuilder = _chunkPWNJ3ZLScjs.j; exports.downloadFileData = _chunk4UOOVSGLcjs.r; exports.extractFilesFromComputeResponse = _chunk4UOOVSGLcjs.q; exports.fetchDefinitionIO = _chunkPWNJ3ZLScjs.h; exports.fetchParsedDefinitionIO = _chunkPWNJ3ZLScjs.i; exports.hashSolveInput = _chunkPWNJ3ZLScjs.b; exports.processInput = _chunkPWNJ3ZLScjs.f; exports.processInputs = _chunkPWNJ3ZLScjs.g; exports.solveGrasshopperDefinition = _chunkPWNJ3ZLScjs.a;
2
2
  //# sourceMappingURL=grasshopper.cjs.map
@@ -1,9 +1,9 @@
1
- import { R as RhinoComputeError, C as ComputeServerStats, F as FileBaseInfo } from './handle-files-D-_fiXu4.cjs';
2
- export { b as FileData, P as ProcessedFile, d as downloadFileData, e as extractFilesFromComputeResponse } from './handle-files-D-_fiXu4.cjs';
3
- import { R as RetryPolicy, C as ComputeConfig } from './types-D1SkNje_.cjs';
4
- export { a as RhinoModelUnit } from './types-D1SkNje_.cjs';
5
- import { f as GrasshopperComputeResponse, a as DataTree, e as GrasshopperComputeConfig, g as GrasshopperParsedIO, h as GrasshopperParsedIORaw, M as MeshExtractionOptions, k as InputParamSchema, j as InputParam, b as DataTreeDefault, c as DataTreePath } from './types-BuRCHPlb.cjs';
6
- export { B as BooleanInputType, D as DataItem, d as DefaultValue, F as FileInputType, G as GeometryInputType, i as GrasshopperRequestSchema, I as InnerTreeData, N as NumericInputType, O as OutputParamSchema, l as OutputType, T as TextInputType, V as ValueListInputType } from './types-BuRCHPlb.cjs';
1
+ import { R as RhinoComputeError, C as ComputeServerStats, F as FileBaseInfo } from './handle-files-VUQET1YU.cjs';
2
+ export { b as FileData, P as ProcessedFile, d as downloadFileData, e as extractFilesFromComputeResponse } from './handle-files-VUQET1YU.cjs';
3
+ import { R as RetryPolicy, C as ComputeConfig } from './types-ChF690kY.cjs';
4
+ export { a as RhinoModelUnit } from './types-ChF690kY.cjs';
5
+ import { f as GrasshopperComputeResponse, a as DataTree, e as GrasshopperComputeConfig, g as GrasshopperParsedIO, h as GrasshopperParsedIORaw, M as MeshExtractionOptions, k as InputParamSchema, j as InputParam, b as DataTreeDefault, c as DataTreePath } from './types-DqSisB8v.cjs';
6
+ export { B as BooleanInputType, D as DataItem, d as DefaultValue, F as FileInputType, G as GeometryInputType, i as GrasshopperRequestSchema, I as InnerTreeData, N as NumericInputType, O as OutputParamSchema, l as OutputType, T as TextInputType, V as ValueListInputType } from './types-DqSisB8v.cjs';
7
7
  import * as THREE from 'three';
8
8
  import 'rhino3dm';
9
9
 
@@ -259,8 +259,9 @@ declare class GrasshopperClient {
259
259
  /**
260
260
  * Creates and initializes a GrasshopperClient with server validation.
261
261
  *
262
- * The pre-flight `/healthcheck` probe is a single-sample boolean gate that
263
- * reads a cold or briefly-busy-but-up server as offline. To avoid failing
262
+ * The pre-flight liveness probe (a GET on the proxy root `/`) is a
263
+ * single-sample boolean gate that reads a cold or briefly-busy-but-up server
264
+ * as offline. To avoid failing
264
265
  * construction on that transient class, the probe is retried with a short
265
266
  * exponential backoff before giving up. Each probe is also bounded by a
266
267
  * timeout so a hung connection can't stall construction.
@@ -1,9 +1,9 @@
1
- import { R as RhinoComputeError, C as ComputeServerStats, F as FileBaseInfo } from './handle-files-D-_fiXu4.js';
2
- export { b as FileData, P as ProcessedFile, d as downloadFileData, e as extractFilesFromComputeResponse } from './handle-files-D-_fiXu4.js';
3
- import { R as RetryPolicy, C as ComputeConfig } from './types-D1SkNje_.js';
4
- export { a as RhinoModelUnit } from './types-D1SkNje_.js';
5
- import { f as GrasshopperComputeResponse, a as DataTree, e as GrasshopperComputeConfig, g as GrasshopperParsedIO, h as GrasshopperParsedIORaw, M as MeshExtractionOptions, k as InputParamSchema, j as InputParam, b as DataTreeDefault, c as DataTreePath } from './types-jPuWWtnU.js';
6
- export { B as BooleanInputType, D as DataItem, d as DefaultValue, F as FileInputType, G as GeometryInputType, i as GrasshopperRequestSchema, I as InnerTreeData, N as NumericInputType, O as OutputParamSchema, l as OutputType, T as TextInputType, V as ValueListInputType } from './types-jPuWWtnU.js';
1
+ import { R as RhinoComputeError, C as ComputeServerStats, F as FileBaseInfo } from './handle-files-VUQET1YU.js';
2
+ export { b as FileData, P as ProcessedFile, d as downloadFileData, e as extractFilesFromComputeResponse } from './handle-files-VUQET1YU.js';
3
+ import { R as RetryPolicy, C as ComputeConfig } from './types-ChF690kY.js';
4
+ export { a as RhinoModelUnit } from './types-ChF690kY.js';
5
+ import { f as GrasshopperComputeResponse, a as DataTree, e as GrasshopperComputeConfig, g as GrasshopperParsedIO, h as GrasshopperParsedIORaw, M as MeshExtractionOptions, k as InputParamSchema, j as InputParam, b as DataTreeDefault, c as DataTreePath } from './types-CIsBR_xd.js';
6
+ export { B as BooleanInputType, D as DataItem, d as DefaultValue, F as FileInputType, G as GeometryInputType, i as GrasshopperRequestSchema, I as InnerTreeData, N as NumericInputType, O as OutputParamSchema, l as OutputType, T as TextInputType, V as ValueListInputType } from './types-CIsBR_xd.js';
7
7
  import * as THREE from 'three';
8
8
  import 'rhino3dm';
9
9
 
@@ -259,8 +259,9 @@ declare class GrasshopperClient {
259
259
  /**
260
260
  * Creates and initializes a GrasshopperClient with server validation.
261
261
  *
262
- * The pre-flight `/healthcheck` probe is a single-sample boolean gate that
263
- * reads a cold or briefly-busy-but-up server as offline. To avoid failing
262
+ * The pre-flight liveness probe (a GET on the proxy root `/`) is a
263
+ * single-sample boolean gate that reads a cold or briefly-busy-but-up server
264
+ * as offline. To avoid failing
264
265
  * construction on that transient class, the probe is retried with a short
265
266
  * exponential backoff before giving up. Each probe is also bounded by a
266
267
  * timeout so a hung connection can't stall construction.
@@ -1,2 +1,2 @@
1
- import{a as d,b as e,c as f,d as g,e as h,f as i,g as j,h as k,i as l,j as m}from"./chunk-6L56B3Q3.js";import{d as a,q as b,r as c}from"./chunk-H2FJSNMM.js";export{g as GrasshopperClient,h as GrasshopperResponseProcessor,a as RhinoComputeError,f as SolveScheduler,m as TreeBuilder,c as downloadFileData,b as extractFilesFromComputeResponse,k as fetchDefinitionIO,l as fetchParsedDefinitionIO,e as hashSolveInput,i as processInput,j as processInputs,d as solveGrasshopperDefinition};
1
+ import{a as d,b as e,c as f,d as g,e as h,f as i,g as j,h as k,i as l,j as m}from"./chunk-6TJKWARC.js";import{d as a,q as b,r as c}from"./chunk-AXAMGKTJ.js";export{g as GrasshopperClient,h as GrasshopperResponseProcessor,a as RhinoComputeError,f as SolveScheduler,m as TreeBuilder,c as downloadFileData,b as extractFilesFromComputeResponse,k as fetchDefinitionIO,l as fetchParsedDefinitionIO,e as hashSolveInput,i as processInput,j as processInputs,d as solveGrasshopperDefinition};
2
2
  //# sourceMappingURL=grasshopper.js.map
@@ -37,9 +37,9 @@ declare class ComputeServerStats {
37
37
  /**
38
38
  * Check if the server is online.
39
39
  *
40
- * This is a single-sample probe: it returns `true` only on a 2xx from
41
- * `/healthcheck`, and `false` for every other outcome (non-2xx, network
42
- * error, or timeout). A cold or briefly-busy-but-up server can therefore
40
+ * This is a single-sample probe: it returns `true` only on a 2xx from the
41
+ * proxy liveness root `/`, and `false` for every other outcome (non-2xx,
42
+ * network error, or timeout). A cold or briefly-busy-but-up server can therefore
43
43
  * read as offline — callers that gate on this (e.g. client construction)
44
44
  * should retry rather than treat a single `false` as authoritative.
45
45
  *
@@ -51,9 +51,19 @@ declare class ComputeServerStats {
51
51
  /**
52
52
  * Get the number of active child processes on the server.
53
53
  *
54
+ * By default the proxy's `/activechildren` endpoint will *spawn* children up
55
+ * to the configured count if none are running, then report the count — which
56
+ * wakes (and bills) an idle server. Pass `{ initialize: false }` for a passive
57
+ * read that reports the current count without spawning; use this for
58
+ * monitoring or before a purge/probe where you must not wake the server.
59
+ *
60
+ * @param options.initialize - When `false`, append `?initialize=false` so the
61
+ * server reports without spawning. Defaults to `true` (the server's default).
54
62
  * @returns Number of active children, or null if unavailable
55
63
  */
56
- getActiveChildren(): Promise<number | null>;
64
+ getActiveChildren(options?: {
65
+ initialize?: boolean;
66
+ }): Promise<number | null>;
57
67
  /**
58
68
  * Get the server version information.
59
69
  *
@@ -64,6 +74,26 @@ declare class ComputeServerStats {
64
74
  compute: string;
65
75
  git_sha: string | null;
66
76
  } | null>;
77
+ /**
78
+ * Get the plugins installed on the server.
79
+ *
80
+ * Returns a `name → version` map of non-core plugins the server has loaded,
81
+ * or `null` if the request failed. Pass `kind` to choose which inventory:
82
+ * `'gh'` (default) lists Grasshopper add-on assemblies via
83
+ * `/plugins/gh/installed`; `'rhino'` lists Rhino plugins via
84
+ * `/plugins/rhino/installed`. Plugins that ship with Rhino / are core
85
+ * libraries are excluded by the server.
86
+ *
87
+ * @param kind - `'gh'` for Grasshopper add-ons (default) or `'rhino'` for Rhino plugins.
88
+ * @returns Map of plugin name to version, or `null` on failure.
89
+ *
90
+ * @example
91
+ * ```ts
92
+ * const gh = await stats.getInstalledPlugins(); // Grasshopper add-ons
93
+ * const selvaVersion = gh?.['Selva'] ?? null;
94
+ * ```
95
+ */
96
+ getInstalledPlugins(kind?: 'gh' | 'rhino'): Promise<Record<string, string> | null>;
67
97
  /**
68
98
  * Get comprehensive server statistics.
69
99
  * Fetches all available server information in parallel.
@@ -101,6 +131,134 @@ declare class ComputeServerStats {
101
131
  * ```
102
132
  */
103
133
  purgeCache(): Promise<number | null>;
134
+ /**
135
+ * Best-effort fleet-wide cache purge across a multi-child deployment.
136
+ *
137
+ * A single {@link purgeCache} POST is forwarded by the rhino.compute proxy to
138
+ * just ONE round-robin-selected child, so the other children keep serving
139
+ * stale cached solves. There is no proxy endpoint that addresses children
140
+ * individually, so this method reads the active child count (passively, never
141
+ * spawning) and fires `2 × count` sequential purges, relying on the proxy's
142
+ * round-robin to spread the hits across the pool.
143
+ *
144
+ * **This is best-effort, not a guarantee.** Round-robin can revisit one child
145
+ * and skip another; under concurrent traffic the rotation drifts. The result's
146
+ * `confident` flag is `true` only when the server reports a single child (where
147
+ * one purge is exact) — surface it so callers don't over-promise. For a hard
148
+ * fleet-wide guarantee, run the deployment at `--childcount 1` or add a
149
+ * server-side fan-out endpoint.
150
+ *
151
+ * @returns `{ totalPurged, calls, children, confident }`, or `null` if the
152
+ * child count couldn't be read (server unreachable). `totalPurged` sums the
153
+ * per-call counts; `calls` is how many purges were issued; `children` is the
154
+ * reported pool size; `confident` is `true` only at a single-child pool.
155
+ *
156
+ * @example
157
+ * ```ts
158
+ * const r = await stats.purgeAllChildren();
159
+ * if (r && !r.confident) {
160
+ * console.warn(`Purged ~${r.totalPurged} across ${r.children} children (best-effort)`);
161
+ * }
162
+ * ```
163
+ */
164
+ purgeAllChildren(): Promise<{
165
+ totalPurged: number;
166
+ calls: number;
167
+ children: number;
168
+ confident: boolean;
169
+ } | null>;
170
+ /**
171
+ * Get the server's current UTC clock.
172
+ *
173
+ * GETs `/servertime`, which the server emits as a JSON-encoded ISO-8601
174
+ * timestamp (e.g. `"2026-06-18T08:30:00Z"`). Useful for detecting clock skew
175
+ * between caller and server. Returns `null` if the request failed or the body
176
+ * isn't a parseable date.
177
+ *
178
+ * @returns A `Date` for the server's UTC time, or `null` on failure.
179
+ */
180
+ getServerTime(): Promise<Date | null>;
181
+ /**
182
+ * Get how long the rhino.compute proxy has been idle.
183
+ *
184
+ * GETs `/idlespan` on the proxy, which returns the seconds elapsed since the
185
+ * last request was forwarded to a compute child. This is a proxy-level metric
186
+ * (not proxied to a child) used by autoscalers to decide when a node can be
187
+ * drained. Returns `null` if unavailable.
188
+ *
189
+ * @returns Idle time in seconds, or `null` on failure.
190
+ */
191
+ getIdleSpan(): Promise<number | null>;
192
+ /**
193
+ * Fill the compute child pool up to the server's configured baseline.
194
+ *
195
+ * POSTs `/launch-children`. No-op when the pool is already at or above the
196
+ * configured `--childcount`. Returns `{ spawned, active }` — how many children
197
+ * were started and the resulting child count — or `null` on failure.
198
+ *
199
+ * To raise capacity above the baseline use {@link launchChild}; the baseline
200
+ * itself can only be changed by restarting rhino.compute.
201
+ *
202
+ * @returns `{ spawned, active }`, or `null` on failure.
203
+ */
204
+ launchChildren(): Promise<{
205
+ spawned: number[];
206
+ active: number;
207
+ } | null>;
208
+ /**
209
+ * Add a single compute child to the pool, optionally on a specific port.
210
+ *
211
+ * POSTs `/launch-child` (with `?port=N` when `port` is given). Unlike
212
+ * {@link launchChildren}, this can push the pool above the baseline, up to the
213
+ * server's `MaxChildren` cap. Returns `{ spawned: [port] }` on success, or
214
+ * `null` on failure (server replies 400 for a bad port, 409 if the port is in
215
+ * use, 503 at the max-children cap).
216
+ *
217
+ * @param port - Optional specific port to launch on; otherwise the next free one.
218
+ * @returns `{ spawned }` listing the launched port, or `null` on failure.
219
+ */
220
+ launchChild(port?: number): Promise<{
221
+ spawned: number[];
222
+ } | null>;
223
+ /**
224
+ * Gracefully shut down compute children without respawning them.
225
+ *
226
+ * POSTs `/shutdown-children`. With no `port` it shuts down every child; with
227
+ * `port` it targets just that one. Children do not respawn, but the next
228
+ * `/grasshopper` request auto-spawns the pool back to the baseline. Returns
229
+ * `{ shutdown, active }` — how many were stopped and the remaining count — or
230
+ * `null` on failure.
231
+ *
232
+ * @param port - Optional port to target; omit to shut down all children.
233
+ * @returns `{ shutdown, active }`, or `null` on failure.
234
+ */
235
+ shutdownChildren(port?: number): Promise<{
236
+ shutdown: number;
237
+ active: number;
238
+ } | null>;
239
+ /**
240
+ * Shut down compute children and respawn replacements (rolling restart).
241
+ *
242
+ * POSTs `/recycle-children`. With no `port` it recycles every child; with
243
+ * `port` it recycles just that one. The server recycles sequentially (each
244
+ * replacement is serving before the next child is stopped) so the pool never
245
+ * drops to zero mid-recycle. Returns `{ shutdown, spawned, active }`, or
246
+ * `null` on failure.
247
+ *
248
+ * @param port - Optional port to target; omit to recycle all children.
249
+ * @returns `{ shutdown, spawned, active }`, or `null` on failure.
250
+ */
251
+ recycleChildren(port?: number): Promise<{
252
+ shutdown: number;
253
+ spawned: number[];
254
+ active: number;
255
+ } | null>;
256
+ /**
257
+ * POST a control endpoint that replies with a JSON object and return it,
258
+ * degrading to `null` on any non-2xx, non-JSON, or network failure. Shared by
259
+ * the child-lifecycle methods so their failure semantics stay identical.
260
+ */
261
+ private postJson;
104
262
  /**
105
263
  * Continuously monitor server stats at specified interval.
106
264
  *
@@ -37,9 +37,9 @@ declare class ComputeServerStats {
37
37
  /**
38
38
  * Check if the server is online.
39
39
  *
40
- * This is a single-sample probe: it returns `true` only on a 2xx from
41
- * `/healthcheck`, and `false` for every other outcome (non-2xx, network
42
- * error, or timeout). A cold or briefly-busy-but-up server can therefore
40
+ * This is a single-sample probe: it returns `true` only on a 2xx from the
41
+ * proxy liveness root `/`, and `false` for every other outcome (non-2xx,
42
+ * network error, or timeout). A cold or briefly-busy-but-up server can therefore
43
43
  * read as offline — callers that gate on this (e.g. client construction)
44
44
  * should retry rather than treat a single `false` as authoritative.
45
45
  *
@@ -51,9 +51,19 @@ declare class ComputeServerStats {
51
51
  /**
52
52
  * Get the number of active child processes on the server.
53
53
  *
54
+ * By default the proxy's `/activechildren` endpoint will *spawn* children up
55
+ * to the configured count if none are running, then report the count — which
56
+ * wakes (and bills) an idle server. Pass `{ initialize: false }` for a passive
57
+ * read that reports the current count without spawning; use this for
58
+ * monitoring or before a purge/probe where you must not wake the server.
59
+ *
60
+ * @param options.initialize - When `false`, append `?initialize=false` so the
61
+ * server reports without spawning. Defaults to `true` (the server's default).
54
62
  * @returns Number of active children, or null if unavailable
55
63
  */
56
- getActiveChildren(): Promise<number | null>;
64
+ getActiveChildren(options?: {
65
+ initialize?: boolean;
66
+ }): Promise<number | null>;
57
67
  /**
58
68
  * Get the server version information.
59
69
  *
@@ -64,6 +74,26 @@ declare class ComputeServerStats {
64
74
  compute: string;
65
75
  git_sha: string | null;
66
76
  } | null>;
77
+ /**
78
+ * Get the plugins installed on the server.
79
+ *
80
+ * Returns a `name → version` map of non-core plugins the server has loaded,
81
+ * or `null` if the request failed. Pass `kind` to choose which inventory:
82
+ * `'gh'` (default) lists Grasshopper add-on assemblies via
83
+ * `/plugins/gh/installed`; `'rhino'` lists Rhino plugins via
84
+ * `/plugins/rhino/installed`. Plugins that ship with Rhino / are core
85
+ * libraries are excluded by the server.
86
+ *
87
+ * @param kind - `'gh'` for Grasshopper add-ons (default) or `'rhino'` for Rhino plugins.
88
+ * @returns Map of plugin name to version, or `null` on failure.
89
+ *
90
+ * @example
91
+ * ```ts
92
+ * const gh = await stats.getInstalledPlugins(); // Grasshopper add-ons
93
+ * const selvaVersion = gh?.['Selva'] ?? null;
94
+ * ```
95
+ */
96
+ getInstalledPlugins(kind?: 'gh' | 'rhino'): Promise<Record<string, string> | null>;
67
97
  /**
68
98
  * Get comprehensive server statistics.
69
99
  * Fetches all available server information in parallel.
@@ -101,6 +131,134 @@ declare class ComputeServerStats {
101
131
  * ```
102
132
  */
103
133
  purgeCache(): Promise<number | null>;
134
+ /**
135
+ * Best-effort fleet-wide cache purge across a multi-child deployment.
136
+ *
137
+ * A single {@link purgeCache} POST is forwarded by the rhino.compute proxy to
138
+ * just ONE round-robin-selected child, so the other children keep serving
139
+ * stale cached solves. There is no proxy endpoint that addresses children
140
+ * individually, so this method reads the active child count (passively, never
141
+ * spawning) and fires `2 × count` sequential purges, relying on the proxy's
142
+ * round-robin to spread the hits across the pool.
143
+ *
144
+ * **This is best-effort, not a guarantee.** Round-robin can revisit one child
145
+ * and skip another; under concurrent traffic the rotation drifts. The result's
146
+ * `confident` flag is `true` only when the server reports a single child (where
147
+ * one purge is exact) — surface it so callers don't over-promise. For a hard
148
+ * fleet-wide guarantee, run the deployment at `--childcount 1` or add a
149
+ * server-side fan-out endpoint.
150
+ *
151
+ * @returns `{ totalPurged, calls, children, confident }`, or `null` if the
152
+ * child count couldn't be read (server unreachable). `totalPurged` sums the
153
+ * per-call counts; `calls` is how many purges were issued; `children` is the
154
+ * reported pool size; `confident` is `true` only at a single-child pool.
155
+ *
156
+ * @example
157
+ * ```ts
158
+ * const r = await stats.purgeAllChildren();
159
+ * if (r && !r.confident) {
160
+ * console.warn(`Purged ~${r.totalPurged} across ${r.children} children (best-effort)`);
161
+ * }
162
+ * ```
163
+ */
164
+ purgeAllChildren(): Promise<{
165
+ totalPurged: number;
166
+ calls: number;
167
+ children: number;
168
+ confident: boolean;
169
+ } | null>;
170
+ /**
171
+ * Get the server's current UTC clock.
172
+ *
173
+ * GETs `/servertime`, which the server emits as a JSON-encoded ISO-8601
174
+ * timestamp (e.g. `"2026-06-18T08:30:00Z"`). Useful for detecting clock skew
175
+ * between caller and server. Returns `null` if the request failed or the body
176
+ * isn't a parseable date.
177
+ *
178
+ * @returns A `Date` for the server's UTC time, or `null` on failure.
179
+ */
180
+ getServerTime(): Promise<Date | null>;
181
+ /**
182
+ * Get how long the rhino.compute proxy has been idle.
183
+ *
184
+ * GETs `/idlespan` on the proxy, which returns the seconds elapsed since the
185
+ * last request was forwarded to a compute child. This is a proxy-level metric
186
+ * (not proxied to a child) used by autoscalers to decide when a node can be
187
+ * drained. Returns `null` if unavailable.
188
+ *
189
+ * @returns Idle time in seconds, or `null` on failure.
190
+ */
191
+ getIdleSpan(): Promise<number | null>;
192
+ /**
193
+ * Fill the compute child pool up to the server's configured baseline.
194
+ *
195
+ * POSTs `/launch-children`. No-op when the pool is already at or above the
196
+ * configured `--childcount`. Returns `{ spawned, active }` — how many children
197
+ * were started and the resulting child count — or `null` on failure.
198
+ *
199
+ * To raise capacity above the baseline use {@link launchChild}; the baseline
200
+ * itself can only be changed by restarting rhino.compute.
201
+ *
202
+ * @returns `{ spawned, active }`, or `null` on failure.
203
+ */
204
+ launchChildren(): Promise<{
205
+ spawned: number[];
206
+ active: number;
207
+ } | null>;
208
+ /**
209
+ * Add a single compute child to the pool, optionally on a specific port.
210
+ *
211
+ * POSTs `/launch-child` (with `?port=N` when `port` is given). Unlike
212
+ * {@link launchChildren}, this can push the pool above the baseline, up to the
213
+ * server's `MaxChildren` cap. Returns `{ spawned: [port] }` on success, or
214
+ * `null` on failure (server replies 400 for a bad port, 409 if the port is in
215
+ * use, 503 at the max-children cap).
216
+ *
217
+ * @param port - Optional specific port to launch on; otherwise the next free one.
218
+ * @returns `{ spawned }` listing the launched port, or `null` on failure.
219
+ */
220
+ launchChild(port?: number): Promise<{
221
+ spawned: number[];
222
+ } | null>;
223
+ /**
224
+ * Gracefully shut down compute children without respawning them.
225
+ *
226
+ * POSTs `/shutdown-children`. With no `port` it shuts down every child; with
227
+ * `port` it targets just that one. Children do not respawn, but the next
228
+ * `/grasshopper` request auto-spawns the pool back to the baseline. Returns
229
+ * `{ shutdown, active }` — how many were stopped and the remaining count — or
230
+ * `null` on failure.
231
+ *
232
+ * @param port - Optional port to target; omit to shut down all children.
233
+ * @returns `{ shutdown, active }`, or `null` on failure.
234
+ */
235
+ shutdownChildren(port?: number): Promise<{
236
+ shutdown: number;
237
+ active: number;
238
+ } | null>;
239
+ /**
240
+ * Shut down compute children and respawn replacements (rolling restart).
241
+ *
242
+ * POSTs `/recycle-children`. With no `port` it recycles every child; with
243
+ * `port` it recycles just that one. The server recycles sequentially (each
244
+ * replacement is serving before the next child is stopped) so the pool never
245
+ * drops to zero mid-recycle. Returns `{ shutdown, spawned, active }`, or
246
+ * `null` on failure.
247
+ *
248
+ * @param port - Optional port to target; omit to recycle all children.
249
+ * @returns `{ shutdown, spawned, active }`, or `null` on failure.
250
+ */
251
+ recycleChildren(port?: number): Promise<{
252
+ shutdown: number;
253
+ spawned: number[];
254
+ active: number;
255
+ } | null>;
256
+ /**
257
+ * POST a control endpoint that replies with a JSON object and return it,
258
+ * degrading to `null` on any non-2xx, non-JSON, or network failure. Shared by
259
+ * the child-lifecycle methods so their failure semantics stay identical.
260
+ */
261
+ private postJson;
104
262
  /**
105
263
  * Continuously monitor server stats at specified interval.
106
264
  *
package/dist/index.cjs CHANGED
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunkHG24GZ3Acjs = require('./chunk-HG24GZ3A.cjs');var _chunkBTH6J34Xcjs = require('./chunk-BTH6J34X.cjs');exports.ComputeServerStats = _chunkBTH6J34Xcjs.j; exports.ErrorCodes = _chunkBTH6J34Xcjs.c; exports.GrasshopperClient = _chunkHG24GZ3Acjs.d; exports.GrasshopperResponseProcessor = _chunkHG24GZ3Acjs.e; exports.RhinoComputeError = _chunkBTH6J34Xcjs.d; exports.SolveScheduler = _chunkHG24GZ3Acjs.c; exports.TreeBuilder = _chunkHG24GZ3Acjs.j; exports.camelcaseKeys = _chunkBTH6J34Xcjs.l; exports.downloadFileData = _chunkBTH6J34Xcjs.r; exports.enableDebugLogging = _chunkBTH6J34Xcjs.g; exports.extractFilesFromComputeResponse = _chunkBTH6J34Xcjs.q; exports.fetchDefinitionIO = _chunkHG24GZ3Acjs.h; exports.fetchParsedDefinitionIO = _chunkHG24GZ3Acjs.i; exports.fetchRhinoCompute = _chunkBTH6J34Xcjs.h; exports.getLogger = _chunkBTH6J34Xcjs.e; exports.hashSolveInput = _chunkHG24GZ3Acjs.b; exports.processInput = _chunkHG24GZ3Acjs.f; exports.processInputs = _chunkHG24GZ3Acjs.g; exports.setLogger = _chunkBTH6J34Xcjs.f; exports.solveGrasshopperDefinition = _chunkHG24GZ3Acjs.a; exports.toCamelCase = _chunkBTH6J34Xcjs.k;
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunkPWNJ3ZLScjs = require('./chunk-PWNJ3ZLS.cjs');var _chunk4UOOVSGLcjs = require('./chunk-4UOOVSGL.cjs');exports.ComputeServerStats = _chunk4UOOVSGLcjs.j; exports.ErrorCodes = _chunk4UOOVSGLcjs.c; exports.GrasshopperClient = _chunkPWNJ3ZLScjs.d; exports.GrasshopperResponseProcessor = _chunkPWNJ3ZLScjs.e; exports.RhinoComputeError = _chunk4UOOVSGLcjs.d; exports.SolveScheduler = _chunkPWNJ3ZLScjs.c; exports.TreeBuilder = _chunkPWNJ3ZLScjs.j; exports.camelcaseKeys = _chunk4UOOVSGLcjs.l; exports.downloadFileData = _chunk4UOOVSGLcjs.r; exports.enableDebugLogging = _chunk4UOOVSGLcjs.g; exports.extractFilesFromComputeResponse = _chunk4UOOVSGLcjs.q; exports.fetchDefinitionIO = _chunkPWNJ3ZLScjs.h; exports.fetchParsedDefinitionIO = _chunkPWNJ3ZLScjs.i; exports.fetchRhinoCompute = _chunk4UOOVSGLcjs.h; exports.getLogger = _chunk4UOOVSGLcjs.e; exports.hashSolveInput = _chunkPWNJ3ZLScjs.b; exports.processInput = _chunkPWNJ3ZLScjs.f; exports.processInputs = _chunkPWNJ3ZLScjs.g; exports.setLogger = _chunk4UOOVSGLcjs.f; exports.solveGrasshopperDefinition = _chunkPWNJ3ZLScjs.a; exports.toCamelCase = _chunk4UOOVSGLcjs.k;
2
2
  //# sourceMappingURL=index.cjs.map