@selvajs/compute 3.1.0-beta.2 → 3.1.0-beta.4
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/chunk-33753HSV.cjs +2 -0
- package/dist/{chunk-6WCVFKOV.cjs.map → chunk-33753HSV.cjs.map} +1 -1
- package/dist/chunk-4JNRO7TX.cjs +62 -0
- package/dist/chunk-4JNRO7TX.cjs.map +1 -0
- package/dist/chunk-6V6SUB4V.js +62 -0
- package/dist/chunk-6V6SUB4V.js.map +1 -0
- package/dist/chunk-D7A3YIYD.cjs +4 -0
- package/dist/chunk-D7A3YIYD.cjs.map +1 -0
- package/dist/chunk-EMXDP7KY.js +4 -0
- package/dist/chunk-EMXDP7KY.js.map +1 -0
- package/dist/chunk-MDFVHHH6.js +2 -0
- package/dist/chunk-MDFVHHH6.js.map +1 -0
- package/dist/core.cjs +1 -1
- package/dist/core.d.cts +2 -2
- package/dist/core.d.ts +2 -2
- package/dist/core.js +1 -1
- package/dist/grasshopper.cjs +1 -1
- package/dist/grasshopper.d.cts +4 -4
- package/dist/grasshopper.d.ts +4 -4
- package/dist/grasshopper.js +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.d.cts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +1 -1
- package/dist/{types-DK2-skCK.d.cts → types-BBSF_ISX.d.ts} +33 -4
- package/dist/{types-jb_K_a0s.d.ts → types-DxPi5SEx.d.cts} +33 -4
- package/dist/{types-ChF690kY.d.cts → types-V7G83j5m.d.cts} +12 -0
- package/dist/{types-ChF690kY.d.ts → types-V7G83j5m.d.ts} +12 -0
- package/dist/visualization-3XYZHAIV.js +2 -0
- package/dist/visualization-DEAMRV7R.cjs +2 -0
- package/dist/visualization-DEAMRV7R.cjs.map +1 -0
- package/dist/visualization.cjs +1 -1
- package/dist/visualization.d.cts +45 -8
- package/dist/visualization.d.ts +45 -8
- package/dist/visualization.js +1 -1
- package/package.json +3 -3
- package/dist/chunk-6WCVFKOV.cjs +0 -2
- package/dist/chunk-DRG5SLIP.cjs +0 -4
- package/dist/chunk-DRG5SLIP.cjs.map +0 -1
- package/dist/chunk-GL3B6EDO.cjs +0 -55
- package/dist/chunk-GL3B6EDO.cjs.map +0 -1
- package/dist/chunk-H4QOWA4L.js +0 -2
- package/dist/chunk-H4QOWA4L.js.map +0 -1
- package/dist/chunk-J3MFKB33.js +0 -4
- package/dist/chunk-J3MFKB33.js.map +0 -1
- package/dist/chunk-YWMDSXXD.js +0 -55
- package/dist/chunk-YWMDSXXD.js.map +0 -1
- package/dist/visualization-5KESJOFC.js +0 -2
- package/dist/visualization-KNQ2NANO.cjs +0 -2
- package/dist/visualization-KNQ2NANO.cjs.map +0 -1
- /package/dist/{visualization-5KESJOFC.js.map → visualization-3XYZHAIV.js.map} +0 -0
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { C as ComputeConfig, a as RhinoModelUnit } from './types-
|
|
1
|
+
import { C as ComputeConfig, a as RhinoModelUnit } from './types-V7G83j5m.js';
|
|
2
2
|
import { RhinoModule } from 'rhino3dm';
|
|
3
3
|
|
|
4
4
|
/**
|
|
@@ -213,8 +213,13 @@ interface GrasshopperComputeResponse extends GrasshopperBaseSchema, GrasshopperD
|
|
|
213
213
|
cachesolve: boolean;
|
|
214
214
|
/** Model units (always present in response) */
|
|
215
215
|
modelunits: RhinoModelUnit;
|
|
216
|
-
/**
|
|
217
|
-
|
|
216
|
+
/**
|
|
217
|
+
* The server echoes the request's full base64 definition back as `algo`, but the client strips
|
|
218
|
+
* it before returning — retaining it would pin a multi-MB copy of the definition per response,
|
|
219
|
+
* multiplied by every cache that holds responses. Always `undefined` on client-returned
|
|
220
|
+
* responses (inherited optional field from {@link GrasshopperDefinitionSource}).
|
|
221
|
+
*/
|
|
222
|
+
algo?: string | null;
|
|
218
223
|
/** Filename of the definition (always present in response) */
|
|
219
224
|
filename: string | null;
|
|
220
225
|
/** Data version */
|
|
@@ -495,6 +500,30 @@ interface MeshBatchParsingOptions {
|
|
|
495
500
|
applyTransforms?: boolean;
|
|
496
501
|
/** Enable performance monitoring in console. Defaults to false. */
|
|
497
502
|
debug?: boolean;
|
|
503
|
+
/**
|
|
504
|
+
* Appearance dials applied to every material built from this batch. These drive how "rendered"
|
|
505
|
+
* vs "matte technical" the meshes look; they are set once at parse time (materials are rebuilt
|
|
506
|
+
* per solve). Runtime restyling of an already-built scene lives in the viewer's `setRenderStyle`.
|
|
507
|
+
*/
|
|
508
|
+
material?: MaterialAppearanceOptions;
|
|
509
|
+
}
|
|
510
|
+
/**
|
|
511
|
+
* How compute meshes read visually. Bundled so a caller can pick a coherent look ('technical' vs
|
|
512
|
+
* 'rendered') by setting all three together rather than dialing each in isolation.
|
|
513
|
+
*/
|
|
514
|
+
interface MaterialAppearanceOptions {
|
|
515
|
+
/**
|
|
516
|
+
* Multiplier on the HDR image-based-lighting reflection strength. ~0.5 reads matte/technical,
|
|
517
|
+
* ~1.3 reads glossy/presentation. Default 1 (three.js's own default — unchanged look).
|
|
518
|
+
*/
|
|
519
|
+
envMapIntensity?: number;
|
|
520
|
+
/**
|
|
521
|
+
* Cull back faces (`THREE.FrontSide`) instead of rendering both sides (`THREE.DoubleSide`).
|
|
522
|
+
* FrontSide gives cleaner interior shading, a crisper silhouette, and less overdraw on closed
|
|
523
|
+
* solids — but open surfaces (which Rhino also emits) then vanish when viewed from behind.
|
|
524
|
+
* Default false (keep DoubleSide) to stay safe for surface geometry.
|
|
525
|
+
*/
|
|
526
|
+
cullBackfaces?: boolean;
|
|
498
527
|
}
|
|
499
528
|
/**
|
|
500
529
|
* Options for extracting and processing meshes from compute responses.
|
|
@@ -515,4 +544,4 @@ interface MeshExtractionOptions {
|
|
|
515
544
|
debug?: boolean;
|
|
516
545
|
}
|
|
517
546
|
|
|
518
|
-
export type { BooleanInputType as B, DataItem as D, FileInputType as F, GeometryInputType as G, InnerTreeData as I,
|
|
547
|
+
export type { BooleanInputType as B, DataItem as D, FileInputType as F, GeometryInputType as G, InnerTreeData as I, MaterialAppearanceOptions as M, NumericInputType as N, OutputParamSchema as O, TextInputType as T, ValueListInputType as V, DataTree as a, DataTreeDefault as b, DataTreePath as c, DefaultValue as d, GrasshopperComputeConfig as e, GrasshopperComputeResponse as f, GrasshopperParsedIO as g, GrasshopperParsedIORaw as h, GrasshopperRequestSchema as i, InputParam as j, InputParamSchema as k, OutputType as l, MeshExtractionOptions as m, MeshBatchParsingOptions as n, DisplayBatch as o, DisplayItem as p, DisplayCurve as q, DisplayIdentity as r, DisplayItemBase as s, DisplayPoint as t, DisplayPosition as u, MeshBatch as v };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { C as ComputeConfig, a as RhinoModelUnit } from './types-
|
|
1
|
+
import { C as ComputeConfig, a as RhinoModelUnit } from './types-V7G83j5m.cjs';
|
|
2
2
|
import { RhinoModule } from 'rhino3dm';
|
|
3
3
|
|
|
4
4
|
/**
|
|
@@ -213,8 +213,13 @@ interface GrasshopperComputeResponse extends GrasshopperBaseSchema, GrasshopperD
|
|
|
213
213
|
cachesolve: boolean;
|
|
214
214
|
/** Model units (always present in response) */
|
|
215
215
|
modelunits: RhinoModelUnit;
|
|
216
|
-
/**
|
|
217
|
-
|
|
216
|
+
/**
|
|
217
|
+
* The server echoes the request's full base64 definition back as `algo`, but the client strips
|
|
218
|
+
* it before returning — retaining it would pin a multi-MB copy of the definition per response,
|
|
219
|
+
* multiplied by every cache that holds responses. Always `undefined` on client-returned
|
|
220
|
+
* responses (inherited optional field from {@link GrasshopperDefinitionSource}).
|
|
221
|
+
*/
|
|
222
|
+
algo?: string | null;
|
|
218
223
|
/** Filename of the definition (always present in response) */
|
|
219
224
|
filename: string | null;
|
|
220
225
|
/** Data version */
|
|
@@ -495,6 +500,30 @@ interface MeshBatchParsingOptions {
|
|
|
495
500
|
applyTransforms?: boolean;
|
|
496
501
|
/** Enable performance monitoring in console. Defaults to false. */
|
|
497
502
|
debug?: boolean;
|
|
503
|
+
/**
|
|
504
|
+
* Appearance dials applied to every material built from this batch. These drive how "rendered"
|
|
505
|
+
* vs "matte technical" the meshes look; they are set once at parse time (materials are rebuilt
|
|
506
|
+
* per solve). Runtime restyling of an already-built scene lives in the viewer's `setRenderStyle`.
|
|
507
|
+
*/
|
|
508
|
+
material?: MaterialAppearanceOptions;
|
|
509
|
+
}
|
|
510
|
+
/**
|
|
511
|
+
* How compute meshes read visually. Bundled so a caller can pick a coherent look ('technical' vs
|
|
512
|
+
* 'rendered') by setting all three together rather than dialing each in isolation.
|
|
513
|
+
*/
|
|
514
|
+
interface MaterialAppearanceOptions {
|
|
515
|
+
/**
|
|
516
|
+
* Multiplier on the HDR image-based-lighting reflection strength. ~0.5 reads matte/technical,
|
|
517
|
+
* ~1.3 reads glossy/presentation. Default 1 (three.js's own default — unchanged look).
|
|
518
|
+
*/
|
|
519
|
+
envMapIntensity?: number;
|
|
520
|
+
/**
|
|
521
|
+
* Cull back faces (`THREE.FrontSide`) instead of rendering both sides (`THREE.DoubleSide`).
|
|
522
|
+
* FrontSide gives cleaner interior shading, a crisper silhouette, and less overdraw on closed
|
|
523
|
+
* solids — but open surfaces (which Rhino also emits) then vanish when viewed from behind.
|
|
524
|
+
* Default false (keep DoubleSide) to stay safe for surface geometry.
|
|
525
|
+
*/
|
|
526
|
+
cullBackfaces?: boolean;
|
|
498
527
|
}
|
|
499
528
|
/**
|
|
500
529
|
* Options for extracting and processing meshes from compute responses.
|
|
@@ -515,4 +544,4 @@ interface MeshExtractionOptions {
|
|
|
515
544
|
debug?: boolean;
|
|
516
545
|
}
|
|
517
546
|
|
|
518
|
-
export type { BooleanInputType as B, DataItem as D, FileInputType as F, GeometryInputType as G, InnerTreeData as I,
|
|
547
|
+
export type { BooleanInputType as B, DataItem as D, FileInputType as F, GeometryInputType as G, InnerTreeData as I, MaterialAppearanceOptions as M, NumericInputType as N, OutputParamSchema as O, TextInputType as T, ValueListInputType as V, DataTree as a, DataTreeDefault as b, DataTreePath as c, DefaultValue as d, GrasshopperComputeConfig as e, GrasshopperComputeResponse as f, GrasshopperParsedIO as g, GrasshopperParsedIORaw as h, GrasshopperRequestSchema as i, InputParam as j, InputParamSchema as k, OutputType as l, MeshExtractionOptions as m, MeshBatchParsingOptions as n, DisplayBatch as o, DisplayItem as p, DisplayCurve as q, DisplayIdentity as r, DisplayItemBase as s, DisplayPoint as t, DisplayPosition as u, MeshBatch as v };
|
|
@@ -34,6 +34,18 @@ interface ComputeConfig {
|
|
|
34
34
|
apiKey?: string;
|
|
35
35
|
/** Optional Bearer token for authentication (e.g., when behind a proxy or API gateway) */
|
|
36
36
|
authToken?: string;
|
|
37
|
+
/**
|
|
38
|
+
* Extra headers sent on every solve / IO request to the compute server.
|
|
39
|
+
*
|
|
40
|
+
* Merged UNDER the transport's own headers (`X-Request-ID`, `Content-Type`,
|
|
41
|
+
* `Authorization`, `RhinoComputeKey`) so a caller can never accidentally
|
|
42
|
+
* override auth or the request id. Intended for routing/telemetry hints a
|
|
43
|
+
* reverse proxy or load balancer reads — e.g. a definition-affinity key so a
|
|
44
|
+
* pool routes repeat solves of one definition to the same VM (its per-VM
|
|
45
|
+
* definition/solve caches then hit). A single-node server ignores unknown
|
|
46
|
+
* headers, so this is inert until a router exists.
|
|
47
|
+
*/
|
|
48
|
+
headers?: Record<string, string>;
|
|
37
49
|
/** Enable debug logging to the console */
|
|
38
50
|
debug?: boolean;
|
|
39
51
|
/** Suppress browser security warnings in the console */
|
|
@@ -34,6 +34,18 @@ interface ComputeConfig {
|
|
|
34
34
|
apiKey?: string;
|
|
35
35
|
/** Optional Bearer token for authentication (e.g., when behind a proxy or API gateway) */
|
|
36
36
|
authToken?: string;
|
|
37
|
+
/**
|
|
38
|
+
* Extra headers sent on every solve / IO request to the compute server.
|
|
39
|
+
*
|
|
40
|
+
* Merged UNDER the transport's own headers (`X-Request-ID`, `Content-Type`,
|
|
41
|
+
* `Authorization`, `RhinoComputeKey`) so a caller can never accidentally
|
|
42
|
+
* override auth or the request id. Intended for routing/telemetry hints a
|
|
43
|
+
* reverse proxy or load balancer reads — e.g. a definition-affinity key so a
|
|
44
|
+
* pool routes repeat solves of one definition to the same VM (its per-VM
|
|
45
|
+
* definition/solve caches then hit). A single-node server ignores unknown
|
|
46
|
+
* headers, so this is inert until a router exists.
|
|
47
|
+
*/
|
|
48
|
+
headers?: Record<string, string>;
|
|
37
49
|
/** Enable debug logging to the console */
|
|
38
50
|
debug?: boolean;
|
|
39
51
|
/** Suppress browser security warnings in the console */
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{A as S,B as _,C as G,D as L,E as R,F as u,G as T,a as e,b as r,c as t,d as o,e as a,f as p,g as s,h as i,i as n,j as l,k as m,l as y,m as f,n as d,o as x,p as h,q as C,r as c,s as g,t as M,u as E,v as A,w as O,x as B,y as j,z as D}from"./chunk-6V6SUB4V.js";import"./chunk-EMXDP7KY.js";export{A as BINARY_MESH_MAGIC,O as BINARY_MESH_VERSION,i as EDGE_USERDATA_KIND,j as FLAG_DELTA_ENCODED,B as FLAG_FLOAT32,D as FLAG_HAS_UVS,S as FLAG_HAS_VERTEX_COLORS,M as Materials,u as SCALE_FACTORS,n as addEdges,t as applyOffset,C as clearTextureCache,o as computeCombinedBoundingBox,a as createCameraController,p as createGrid,f as createLabelLayer,x as createMeasureTool,y as createRenderPipeline,s as createViewGizmo,T as getThreeMeshesFromComputeResponse,g as initThree,l as isEdgeOverlay,c as materialAppearanceForStyle,_ as parseBinaryMeshBatch,r as parseColor,E as parseDisplayItems,G as parseMeshBatch,R as parseMeshBatchBlob,L as parseMeshBatchObject,m as removeEdges,h as setTextureAnisotropy,d as snapToVertex,e as updateScene};
|
|
2
|
+
//# sourceMappingURL=visualization-3XYZHAIV.js.map
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunk4JNRO7TXcjs = require('./chunk-4JNRO7TX.cjs');require('./chunk-D7A3YIYD.cjs');exports.BINARY_MESH_MAGIC = _chunk4JNRO7TXcjs.v; exports.BINARY_MESH_VERSION = _chunk4JNRO7TXcjs.w; exports.EDGE_USERDATA_KIND = _chunk4JNRO7TXcjs.h; exports.FLAG_DELTA_ENCODED = _chunk4JNRO7TXcjs.y; exports.FLAG_FLOAT32 = _chunk4JNRO7TXcjs.x; exports.FLAG_HAS_UVS = _chunk4JNRO7TXcjs.z; exports.FLAG_HAS_VERTEX_COLORS = _chunk4JNRO7TXcjs.A; exports.Materials = _chunk4JNRO7TXcjs.t; exports.SCALE_FACTORS = _chunk4JNRO7TXcjs.F; exports.addEdges = _chunk4JNRO7TXcjs.i; exports.applyOffset = _chunk4JNRO7TXcjs.c; exports.clearTextureCache = _chunk4JNRO7TXcjs.q; exports.computeCombinedBoundingBox = _chunk4JNRO7TXcjs.d; exports.createCameraController = _chunk4JNRO7TXcjs.e; exports.createGrid = _chunk4JNRO7TXcjs.f; exports.createLabelLayer = _chunk4JNRO7TXcjs.m; exports.createMeasureTool = _chunk4JNRO7TXcjs.o; exports.createRenderPipeline = _chunk4JNRO7TXcjs.l; exports.createViewGizmo = _chunk4JNRO7TXcjs.g; exports.getThreeMeshesFromComputeResponse = _chunk4JNRO7TXcjs.G; exports.initThree = _chunk4JNRO7TXcjs.s; exports.isEdgeOverlay = _chunk4JNRO7TXcjs.j; exports.materialAppearanceForStyle = _chunk4JNRO7TXcjs.r; exports.parseBinaryMeshBatch = _chunk4JNRO7TXcjs.B; exports.parseColor = _chunk4JNRO7TXcjs.b; exports.parseDisplayItems = _chunk4JNRO7TXcjs.u; exports.parseMeshBatch = _chunk4JNRO7TXcjs.C; exports.parseMeshBatchBlob = _chunk4JNRO7TXcjs.E; exports.parseMeshBatchObject = _chunk4JNRO7TXcjs.D; exports.removeEdges = _chunk4JNRO7TXcjs.k; exports.setTextureAnisotropy = _chunk4JNRO7TXcjs.p; exports.snapToVertex = _chunk4JNRO7TXcjs.n; exports.updateScene = _chunk4JNRO7TXcjs.a;
|
|
2
|
+
//# sourceMappingURL=visualization-DEAMRV7R.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["/home/runner/work/selva-compute/selva-compute/dist/visualization-DEAMRV7R.cjs"],"names":[],"mappings":"AAAA,iIAAwQ,gCAA6B,ujDAAsuB","file":"/home/runner/work/selva-compute/selva-compute/dist/visualization-DEAMRV7R.cjs"}
|
package/dist/visualization.cjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports, "__esModule", {value: true});var
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunk4JNRO7TXcjs = require('./chunk-4JNRO7TX.cjs');require('./chunk-D7A3YIYD.cjs');exports.EDGE_USERDATA_KIND = _chunk4JNRO7TXcjs.h; exports.Materials = _chunk4JNRO7TXcjs.t; exports.SCALE_FACTORS = _chunk4JNRO7TXcjs.F; exports.addEdges = _chunk4JNRO7TXcjs.i; exports.applyOffset = _chunk4JNRO7TXcjs.c; exports.computeCombinedBoundingBox = _chunk4JNRO7TXcjs.d; exports.createCameraController = _chunk4JNRO7TXcjs.e; exports.createGrid = _chunk4JNRO7TXcjs.f; exports.createLabelLayer = _chunk4JNRO7TXcjs.m; exports.createMeasureTool = _chunk4JNRO7TXcjs.o; exports.createRenderPipeline = _chunk4JNRO7TXcjs.l; exports.createViewGizmo = _chunk4JNRO7TXcjs.g; exports.getThreeMeshesFromComputeResponse = _chunk4JNRO7TXcjs.G; exports.initThree = _chunk4JNRO7TXcjs.s; exports.isEdgeOverlay = _chunk4JNRO7TXcjs.j; exports.parseColor = _chunk4JNRO7TXcjs.b; exports.parseDisplayItems = _chunk4JNRO7TXcjs.u; exports.parseMeshBatchBlob = _chunk4JNRO7TXcjs.E; exports.parseMeshBatchObject = _chunk4JNRO7TXcjs.D; exports.removeEdges = _chunk4JNRO7TXcjs.k; exports.snapToVertex = _chunk4JNRO7TXcjs.n; exports.updateScene = _chunk4JNRO7TXcjs.a;
|
|
2
2
|
//# sourceMappingURL=visualization.cjs.map
|
package/dist/visualization.d.cts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import * as THREE from 'three';
|
|
2
2
|
import { OrbitControls } from 'three/addons/controls/OrbitControls.js';
|
|
3
|
+
import { M as MaterialAppearanceOptions, f as GrasshopperComputeResponse, m as MeshExtractionOptions, n as MeshBatchParsingOptions, o as DisplayBatch, p as DisplayItem } from './types-DxPi5SEx.cjs';
|
|
4
|
+
export { q as DisplayCurve, r as DisplayIdentity, s as DisplayItemBase, t as DisplayPoint, u as DisplayPosition, v as MeshBatch } from './types-DxPi5SEx.cjs';
|
|
3
5
|
import { CSS2DObject } from 'three/addons/renderers/CSS2DRenderer.js';
|
|
4
6
|
import { LineSegments2 } from 'three/addons/lines/LineSegments2.js';
|
|
5
|
-
import { f as GrasshopperComputeResponse, M as MeshExtractionOptions, m as MeshBatchParsingOptions, n as DisplayBatch, o as DisplayItem } from './types-DK2-skCK.cjs';
|
|
6
|
-
export { p as DisplayCurve, q as DisplayIdentity, r as DisplayItemBase, s as DisplayPoint, t as DisplayPosition, u as MeshBatch } from './types-DK2-skCK.cjs';
|
|
7
7
|
import { RhinoModule } from 'rhino3dm';
|
|
8
|
-
import './types-
|
|
8
|
+
import './types-V7G83j5m.cjs';
|
|
9
9
|
|
|
10
10
|
type CameraConfig = {
|
|
11
11
|
position?: THREE.Vector3;
|
|
@@ -53,6 +53,16 @@ type RenderConfig = {
|
|
|
53
53
|
/** AO strength 0–1 when {@link RenderConfig.ambientOcclusion} is on. Default 1. */
|
|
54
54
|
aoIntensity?: number;
|
|
55
55
|
};
|
|
56
|
+
/**
|
|
57
|
+
* A coherent visual look. Seeds the initial render defaults (tone mapping, AO, edges, grid, IBL
|
|
58
|
+
* strength) at construction and can be re-applied live via `setRenderStyle`.
|
|
59
|
+
*
|
|
60
|
+
* - 'technical': matte, drawing-like — neutral tone mapping, low IBL, edges + grid on, AO on.
|
|
61
|
+
* Reads like a CAD shaded view (Rhino/Onshape).
|
|
62
|
+
* - 'rendered': presentation — ACES-filmic tone mapping, stronger IBL, edges off, AO on. Reads
|
|
63
|
+
* like a Keyshot/Fusion render.
|
|
64
|
+
*/
|
|
65
|
+
type RenderStyle = 'technical' | 'rendered';
|
|
56
66
|
/** Crisp boundary/crease edge overlays on meshes. See `addEdges`. */
|
|
57
67
|
type EdgesConfig = {
|
|
58
68
|
/** Auto-attach edge overlays to meshes as they load. Default false (opt-in). */
|
|
@@ -122,6 +132,13 @@ type MeasureConfig = {
|
|
|
122
132
|
};
|
|
123
133
|
type ThreeInitializerOptions = {
|
|
124
134
|
sceneScale?: 'mm' | 'cm' | 'm' | 'inches' | 'feet';
|
|
135
|
+
/**
|
|
136
|
+
* Pick a coherent look up front — seeds sensible defaults for tone mapping, AO, edges, grid, and
|
|
137
|
+
* IBL strength (see {@link RenderStyle}). Individual `render`/`edges`/`grid` options still win
|
|
138
|
+
* when set explicitly, so this only fills in what you leave unspecified. Omit for the plain
|
|
139
|
+
* per-field defaults (no style applied). Re-apply later via the init result's `setRenderStyle`.
|
|
140
|
+
*/
|
|
141
|
+
renderStyle?: RenderStyle;
|
|
125
142
|
camera?: CameraConfig;
|
|
126
143
|
lighting?: LightingConfig;
|
|
127
144
|
environment?: EnvironmentConfig;
|
|
@@ -412,6 +429,19 @@ declare const initThree: (canvas: HTMLCanvasElement, options?: ThreeInitializerO
|
|
|
412
429
|
applyEdges: (root: THREE.Object3D) => void;
|
|
413
430
|
/** Toggle ambient occlusion at runtime — builds or tears down the postprocessing pipeline. */
|
|
414
431
|
setAmbientOcclusion: (enabled: boolean) => void;
|
|
432
|
+
/**
|
|
433
|
+
* Apply a coherent look to the already-loaded scene: 'technical' (matte/CAD — edges, grid, low
|
|
434
|
+
* IBL, neutral tone mapping) or 'rendered' (presentation — stronger IBL, ACES tone mapping, no
|
|
435
|
+
* edges). Retunes viewer-owned dials only; per-material parse choices are set via the batch
|
|
436
|
+
* parser's `material` option. Handy for comparing the two looks in a live viewer.
|
|
437
|
+
*/
|
|
438
|
+
setRenderStyle: (style: "technical" | "rendered") => void;
|
|
439
|
+
/**
|
|
440
|
+
* The parse-time material options (backface culling, IBL strength) matching the active render
|
|
441
|
+
* style — feed into the batch parser's `material` option so freshly-loaded meshes are built to
|
|
442
|
+
* match the look. Returns undefined when no style is active. See `setRenderStyle`.
|
|
443
|
+
*/
|
|
444
|
+
getMaterialAppearance: () => MaterialAppearanceOptions | undefined;
|
|
415
445
|
/**
|
|
416
446
|
* Refit the sun's shadow frustum to the current scene content for crisp shadows. Call after
|
|
417
447
|
* loading or replacing geometry (e.g. after `updateScene`). No-op when sunlight/shadows are off.
|
|
@@ -526,11 +556,18 @@ declare function removeEdges(root: THREE.Object3D): number;
|
|
|
526
556
|
* this when `render.ambientOcclusion` is enabled, and otherwise renders with a plain
|
|
527
557
|
* `renderer.render` so the cheap path stays cheap (the chosen tradeoff — see cad-viewer-plan.md).
|
|
528
558
|
*
|
|
529
|
-
* Pipeline: RenderPass → GTAOPass → OutputPass. GTAO (ground-truth AO) is the modern
|
|
530
|
-
* SSAO/SAO — better contact shadows in crevices, the "engineered" depth cue.
|
|
531
|
-
* on so the AO radius is in screen space, which keeps it scale-robust across
|
|
532
|
-
* scenes without per-scene tuning.
|
|
533
|
-
*
|
|
559
|
+
* Pipeline: RenderPass → GTAOPass → SMAAPass → OutputPass. GTAO (ground-truth AO) is the modern
|
|
560
|
+
* replacement for SSAO/SAO — better contact shadows in crevices, the "engineered" depth cue.
|
|
561
|
+
* `screenSpaceRadius` is on so the AO radius is in screen space, which keeps it scale-robust across
|
|
562
|
+
* the viewer's mm→m scenes without per-scene tuning.
|
|
563
|
+
*
|
|
564
|
+
* SMAA restores antialiasing on this path. The EffectComposer renders into an offscreen target, so
|
|
565
|
+
* the WebGLRenderer's own MSAA (`antialias: true`) does nothing here — without a dedicated AA pass,
|
|
566
|
+
* enabling AO would visibly *worsen* edge quality. SMAA is chosen over TAA because TAA's temporal
|
|
567
|
+
* jitter smears during OrbitControls drags; SMAA is single-frame, cheap, and stable while orbiting.
|
|
568
|
+
*
|
|
569
|
+
* OutputPass applies tone mapping + color space last (taking over the roles the renderer did
|
|
570
|
+
* directly in the non-composer path), so SMAA operates on the pre-tonemapped image as intended.
|
|
534
571
|
*
|
|
535
572
|
* Camera swaps: the active camera can flip perspective↔ortho. Rather than rebuild the composer, we
|
|
536
573
|
* retarget the passes' `camera` each render via {@link setCamera}.
|
package/dist/visualization.d.ts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import * as THREE from 'three';
|
|
2
2
|
import { OrbitControls } from 'three/addons/controls/OrbitControls.js';
|
|
3
|
+
import { M as MaterialAppearanceOptions, f as GrasshopperComputeResponse, m as MeshExtractionOptions, n as MeshBatchParsingOptions, o as DisplayBatch, p as DisplayItem } from './types-BBSF_ISX.js';
|
|
4
|
+
export { q as DisplayCurve, r as DisplayIdentity, s as DisplayItemBase, t as DisplayPoint, u as DisplayPosition, v as MeshBatch } from './types-BBSF_ISX.js';
|
|
3
5
|
import { CSS2DObject } from 'three/addons/renderers/CSS2DRenderer.js';
|
|
4
6
|
import { LineSegments2 } from 'three/addons/lines/LineSegments2.js';
|
|
5
|
-
import { f as GrasshopperComputeResponse, M as MeshExtractionOptions, m as MeshBatchParsingOptions, n as DisplayBatch, o as DisplayItem } from './types-jb_K_a0s.js';
|
|
6
|
-
export { p as DisplayCurve, q as DisplayIdentity, r as DisplayItemBase, s as DisplayPoint, t as DisplayPosition, u as MeshBatch } from './types-jb_K_a0s.js';
|
|
7
7
|
import { RhinoModule } from 'rhino3dm';
|
|
8
|
-
import './types-
|
|
8
|
+
import './types-V7G83j5m.js';
|
|
9
9
|
|
|
10
10
|
type CameraConfig = {
|
|
11
11
|
position?: THREE.Vector3;
|
|
@@ -53,6 +53,16 @@ type RenderConfig = {
|
|
|
53
53
|
/** AO strength 0–1 when {@link RenderConfig.ambientOcclusion} is on. Default 1. */
|
|
54
54
|
aoIntensity?: number;
|
|
55
55
|
};
|
|
56
|
+
/**
|
|
57
|
+
* A coherent visual look. Seeds the initial render defaults (tone mapping, AO, edges, grid, IBL
|
|
58
|
+
* strength) at construction and can be re-applied live via `setRenderStyle`.
|
|
59
|
+
*
|
|
60
|
+
* - 'technical': matte, drawing-like — neutral tone mapping, low IBL, edges + grid on, AO on.
|
|
61
|
+
* Reads like a CAD shaded view (Rhino/Onshape).
|
|
62
|
+
* - 'rendered': presentation — ACES-filmic tone mapping, stronger IBL, edges off, AO on. Reads
|
|
63
|
+
* like a Keyshot/Fusion render.
|
|
64
|
+
*/
|
|
65
|
+
type RenderStyle = 'technical' | 'rendered';
|
|
56
66
|
/** Crisp boundary/crease edge overlays on meshes. See `addEdges`. */
|
|
57
67
|
type EdgesConfig = {
|
|
58
68
|
/** Auto-attach edge overlays to meshes as they load. Default false (opt-in). */
|
|
@@ -122,6 +132,13 @@ type MeasureConfig = {
|
|
|
122
132
|
};
|
|
123
133
|
type ThreeInitializerOptions = {
|
|
124
134
|
sceneScale?: 'mm' | 'cm' | 'm' | 'inches' | 'feet';
|
|
135
|
+
/**
|
|
136
|
+
* Pick a coherent look up front — seeds sensible defaults for tone mapping, AO, edges, grid, and
|
|
137
|
+
* IBL strength (see {@link RenderStyle}). Individual `render`/`edges`/`grid` options still win
|
|
138
|
+
* when set explicitly, so this only fills in what you leave unspecified. Omit for the plain
|
|
139
|
+
* per-field defaults (no style applied). Re-apply later via the init result's `setRenderStyle`.
|
|
140
|
+
*/
|
|
141
|
+
renderStyle?: RenderStyle;
|
|
125
142
|
camera?: CameraConfig;
|
|
126
143
|
lighting?: LightingConfig;
|
|
127
144
|
environment?: EnvironmentConfig;
|
|
@@ -412,6 +429,19 @@ declare const initThree: (canvas: HTMLCanvasElement, options?: ThreeInitializerO
|
|
|
412
429
|
applyEdges: (root: THREE.Object3D) => void;
|
|
413
430
|
/** Toggle ambient occlusion at runtime — builds or tears down the postprocessing pipeline. */
|
|
414
431
|
setAmbientOcclusion: (enabled: boolean) => void;
|
|
432
|
+
/**
|
|
433
|
+
* Apply a coherent look to the already-loaded scene: 'technical' (matte/CAD — edges, grid, low
|
|
434
|
+
* IBL, neutral tone mapping) or 'rendered' (presentation — stronger IBL, ACES tone mapping, no
|
|
435
|
+
* edges). Retunes viewer-owned dials only; per-material parse choices are set via the batch
|
|
436
|
+
* parser's `material` option. Handy for comparing the two looks in a live viewer.
|
|
437
|
+
*/
|
|
438
|
+
setRenderStyle: (style: "technical" | "rendered") => void;
|
|
439
|
+
/**
|
|
440
|
+
* The parse-time material options (backface culling, IBL strength) matching the active render
|
|
441
|
+
* style — feed into the batch parser's `material` option so freshly-loaded meshes are built to
|
|
442
|
+
* match the look. Returns undefined when no style is active. See `setRenderStyle`.
|
|
443
|
+
*/
|
|
444
|
+
getMaterialAppearance: () => MaterialAppearanceOptions | undefined;
|
|
415
445
|
/**
|
|
416
446
|
* Refit the sun's shadow frustum to the current scene content for crisp shadows. Call after
|
|
417
447
|
* loading or replacing geometry (e.g. after `updateScene`). No-op when sunlight/shadows are off.
|
|
@@ -526,11 +556,18 @@ declare function removeEdges(root: THREE.Object3D): number;
|
|
|
526
556
|
* this when `render.ambientOcclusion` is enabled, and otherwise renders with a plain
|
|
527
557
|
* `renderer.render` so the cheap path stays cheap (the chosen tradeoff — see cad-viewer-plan.md).
|
|
528
558
|
*
|
|
529
|
-
* Pipeline: RenderPass → GTAOPass → OutputPass. GTAO (ground-truth AO) is the modern
|
|
530
|
-
* SSAO/SAO — better contact shadows in crevices, the "engineered" depth cue.
|
|
531
|
-
* on so the AO radius is in screen space, which keeps it scale-robust across
|
|
532
|
-
* scenes without per-scene tuning.
|
|
533
|
-
*
|
|
559
|
+
* Pipeline: RenderPass → GTAOPass → SMAAPass → OutputPass. GTAO (ground-truth AO) is the modern
|
|
560
|
+
* replacement for SSAO/SAO — better contact shadows in crevices, the "engineered" depth cue.
|
|
561
|
+
* `screenSpaceRadius` is on so the AO radius is in screen space, which keeps it scale-robust across
|
|
562
|
+
* the viewer's mm→m scenes without per-scene tuning.
|
|
563
|
+
*
|
|
564
|
+
* SMAA restores antialiasing on this path. The EffectComposer renders into an offscreen target, so
|
|
565
|
+
* the WebGLRenderer's own MSAA (`antialias: true`) does nothing here — without a dedicated AA pass,
|
|
566
|
+
* enabling AO would visibly *worsen* edge quality. SMAA is chosen over TAA because TAA's temporal
|
|
567
|
+
* jitter smears during OrbitControls drags; SMAA is single-frame, cheap, and stable while orbiting.
|
|
568
|
+
*
|
|
569
|
+
* OutputPass applies tone mapping + color space last (taking over the roles the renderer did
|
|
570
|
+
* directly in the non-composer path), so SMAA operates on the pre-tonemapped image as intended.
|
|
534
571
|
*
|
|
535
572
|
* Camera swaps: the active camera can flip perspective↔ortho. Rather than rebuild the composer, we
|
|
536
573
|
* retarget the passes' `camera` each render via {@link setCamera}.
|
package/dist/visualization.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{D as h,E as c,F as v,G as j,a as e,b as r,c as t,d as o,e as i,f as a,g as s,h as p,i as n,j as l,k as f,l as m,m as y,n as u,o as d,s as x,t as C,u as g}from"./chunk-6V6SUB4V.js";import"./chunk-EMXDP7KY.js";export{p as EDGE_USERDATA_KIND,C as Materials,v as SCALE_FACTORS,n as addEdges,t as applyOffset,o as computeCombinedBoundingBox,i as createCameraController,a as createGrid,y as createLabelLayer,d as createMeasureTool,m as createRenderPipeline,s as createViewGizmo,j as getThreeMeshesFromComputeResponse,x as initThree,l as isEdgeOverlay,r as parseColor,g as parseDisplayItems,c as parseMeshBatchBlob,h as parseMeshBatchObject,f as removeEdges,u as snapToVertex,e as updateScene};
|
|
2
2
|
//# sourceMappingURL=visualization.js.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@selvajs/compute",
|
|
3
|
-
"version": "3.1.0-beta.
|
|
3
|
+
"version": "3.1.0-beta.4",
|
|
4
4
|
"description": "TypeScript library for Rhino Compute Server - Grasshopper and RhinoCommon",
|
|
5
5
|
"author": "VektorNode",
|
|
6
6
|
"license": "MIT",
|
|
@@ -84,7 +84,7 @@
|
|
|
84
84
|
"devDependencies": {
|
|
85
85
|
"@changesets/cli": "^2.30.0",
|
|
86
86
|
"@eslint/js": "^10.0.1",
|
|
87
|
-
"@types/node": "^
|
|
87
|
+
"@types/node": "^26.1.0",
|
|
88
88
|
"@types/three": "^0.184.1",
|
|
89
89
|
"@vitest/coverage-v8": "^3.2.4",
|
|
90
90
|
"eslint": "^10.4.1",
|
|
@@ -97,7 +97,7 @@
|
|
|
97
97
|
"prettier-plugin-svelte": "^4.1.0",
|
|
98
98
|
"prettier-plugin-tailwindcss": "^0.8.0",
|
|
99
99
|
"svelte": "^5.53.7",
|
|
100
|
-
"three": "^0.
|
|
100
|
+
"three": "^0.185.1",
|
|
101
101
|
"tsup": "^8.5.1",
|
|
102
102
|
"typedoc": "^0.28.17",
|
|
103
103
|
"typedoc-plugin-extras": "^4.0.1",
|
package/dist/chunk-6WCVFKOV.cjs
DELETED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { newObj[key] = obj[key]; } } } newObj.default = obj; return newObj; } } function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }var _chunkDRG5SLIPcjs = require('./chunk-DRG5SLIP.cjs');function p(t,e){if(!t||typeof t!="object")return;let r=t;if(e in r)return r[e];let n=J(r).get(e.toLowerCase());return n===void 0?void 0:r[n]}function L(t,e){if(!t||typeof t!="object")return!1;let r=t;return e in r?!0:J(r).has(e.toLowerCase())}var H=new WeakMap;function J(t){let e=H.get(t);if(!e){e=new Map;for(let r of Object.keys(t)){let n=r.toLowerCase();e.has(n)||e.set(n,r)}H.set(t,e)}return e}function C(t,e){e||typeof window<"u"&&_chunkDRG5SLIPcjs.e.call(void 0, ).warn(`Warning: ${t} is running on the client side. For better performance and security, consider running this on the server side.`)}var Ie="Unable to load grasshopper definition";function xe(t){return t instanceof _chunkDRG5SLIPcjs.d?t.code===_chunkDRG5SLIPcjs.c.DEFINITION_NOT_CACHED||t.message.includes(Ie):!1}function Y(t,e){if(!e)return;let r=p(t,"values");if(!Array.isArray(r)||r.length===0)return;let n=[];for(let o of r){let a=p(o,"innerTree");(!a||Object.keys(a).length===0)&&n.push(_nullishCoalesce(p(o,"paramName"), () => ("<unnamed>")))}if(n.length===0)return;let s=n.length===r.length?"all":`${n.length}/${r.length}`;_chunkDRG5SLIPcjs.e.call(void 0, ).warn(`Solve returned empty output(s) (${s}): ${n.join(", ")}. These parameters produced no data \u2014 check the definition's inputs and the branch feeding each.`)}async function D(t,e,r){r.debug&&C("solveGrasshopperDefinition",_nullishCoalesce(r.suppressBrowserWarning, () => (r.suppressClientSideWarning)));let{response:n}=await O(P(e,t),r);return n}async function Q(t,e,r){return r.debug&&C("solveGrasshopperDefinitionWithCacheKey",_nullishCoalesce(r.suppressBrowserWarning, () => (r.suppressClientSideWarning))),O(P(e,t),r)}async function X(t,e,r,n){n.debug&&C("solveByCacheKey",_nullishCoalesce(n.suppressBrowserWarning, () => (n.suppressClientSideWarning)));let s={algo:null,pointer:e,values:t};try{return{...await O(s,n),missed:!1}}catch(o){if(!xe(o))throw o;return{...await O(P(r,t),n),missed:!0}}}async function O(t,e){De(t,e);let r=await _chunkDRG5SLIPcjs.l.call(void 0, "grasshopper",t,e);if("pointer"in r){let{pointer:n,...s}=r,o=s;return Y(o,e.debug),{response:o,cacheKey:typeof n=="string"?n:null}}return Y(r,e.debug),{response:r,cacheKey:null}}function P(t,e){let r={algo:null,pointer:null,values:e};return t instanceof Uint8Array?r.algo=_chunkDRG5SLIPcjs.k.call(void 0, t):/^https?:\/\//i.test(t)?r.pointer=t:_chunkDRG5SLIPcjs.i.call(void 0, t)?r.algo=t:r.algo=_chunkDRG5SLIPcjs.h.call(void 0, t),r}function De(t,e){e.cachesolve!=null&&(t.cachesolve=e.cachesolve),e.cacheerroredsolves!=null&&(t.cacheerroredsolves=e.cacheerroredsolves),e.modelunits!=null&&(t.modelunits=e.modelunits),e.angletolerance!=null&&(t.angletolerance=e.angletolerance),e.absolutetolerance!=null&&(t.absolutetolerance=e.absolutetolerance),e.dataversion!=null&&(t.dataversion=e.dataversion)}function Pe(t){let e=new WeakSet,r=n=>{if(n==null)return JSON.stringify(n);if(typeof n=="number")return Number.isFinite(n)?String(n):JSON.stringify(null);if(typeof n=="string"||typeof n=="boolean")return JSON.stringify(n);if(typeof n=="bigint")return JSON.stringify(n.toString());if(n instanceof Uint8Array){let s=n.length>64?Array.from(n.slice(0,32)).concat(Array.from(n.slice(-32))):Array.from(n);return JSON.stringify({__u8:!0,len:n.length,sample:s})}return Array.isArray(n)?`[${n.map(r).join(",")}]`:typeof n=="object"?e.has(n)?JSON.stringify("[Circular]"):(e.add(n),`{${Object.keys(n).sort().map(a=>`${JSON.stringify(a)}:${r(n[a])}`).join(",")}}`):JSON.stringify(null)};return r(t)}function Z(t,e){let r=2166136261;for(let n=0;n<t;n++)r^=e(n),r=r+((r<<1)+(r<<4)+(r<<7)+(r<<8)+(r<<24))>>>0;return r.toString(16).padStart(8,"0")}function ee(t){return Z(t.length,e=>t.charCodeAt(e))}function Re(t){return Z(t.length,e=>t[e])}function te(t,e){return ee(`${W(t)}|${Pe(e)}`)}function W(t){return typeof t=="string"?`s:${t.length}:${ee(t)}`:`u8:${t.length}:${Re(t)}`}var we=100;function Ee(t){return t instanceof Uint8Array?!0:!/^https?:\/\//i.test(t)}var S=class{constructor(e,r,n={},s){_chunkDRG5SLIPcjs.b.call(void 0, this,"executor");_chunkDRG5SLIPcjs.b.call(void 0, this,"baseConfig");_chunkDRG5SLIPcjs.b.call(void 0, this,"mode");_chunkDRG5SLIPcjs.b.call(void 0, this,"maxConcurrent");_chunkDRG5SLIPcjs.b.call(void 0, this,"timeoutMs");_chunkDRG5SLIPcjs.b.call(void 0, this,"retry");_chunkDRG5SLIPcjs.b.call(void 0, this,"cacheEnabled");_chunkDRG5SLIPcjs.b.call(void 0, this,"cacheMax");_chunkDRG5SLIPcjs.b.call(void 0, this,"cacheTtl");_chunkDRG5SLIPcjs.b.call(void 0, this,"cache",new Map);_chunkDRG5SLIPcjs.b.call(void 0, this,"cacheKeyExecutor");_chunkDRG5SLIPcjs.b.call(void 0, this,"reuseServerDefinitionCache");_chunkDRG5SLIPcjs.b.call(void 0, this,"serverCacheKeys",new Map);_chunkDRG5SLIPcjs.b.call(void 0, this,"onStart");_chunkDRG5SLIPcjs.b.call(void 0, this,"onSettle");_chunkDRG5SLIPcjs.b.call(void 0, this,"onSuperseded");_chunkDRG5SLIPcjs.b.call(void 0, this,"subscribers",new Set);_chunkDRG5SLIPcjs.b.call(void 0, this,"inFlight",new Set);_chunkDRG5SLIPcjs.b.call(void 0, this,"pendingForLatestWins",null);_chunkDRG5SLIPcjs.b.call(void 0, this,"fifoQueue",[]);_chunkDRG5SLIPcjs.b.call(void 0, this,"_lastResult",null);_chunkDRG5SLIPcjs.b.call(void 0, this,"_lastError",null);_chunkDRG5SLIPcjs.b.call(void 0, this,"_lastDurationMs",null);_chunkDRG5SLIPcjs.b.call(void 0, this,"disposed",!1);this.executor=e,this.cacheKeyExecutor=s,this.baseConfig=r,this.mode=_nullishCoalesce(n.mode, () => ("latest-wins")),this.maxConcurrent=Math.max(1,_nullishCoalesce(n.maxConcurrent, () => ((this.mode==="parallel"?4:1)))),this.timeoutMs=n.timeoutMs,this.retry=n.retry;let o=n.cache;this.cacheEnabled=o!==void 0&&o!==!1;let a=typeof o=="object"?o:{};this.cacheMax=_nullishCoalesce(a.maxEntries, () => (50)),this.cacheTtl=_nullishCoalesce(a.ttlMs, () => (0)),this.reuseServerDefinitionCache=!!s&&(_nullishCoalesce(n.reuseServerDefinitionCache, () => (!0))),this.onStart=n.onStart,this.onSettle=n.onSettle,this.onSuperseded=n.onSuperseded}get isSolving(){return this.inFlight.size>0}get hasPending(){return this.pendingForLatestWins!==null||this.fifoQueue.length>0}get inFlightCount(){return this.inFlight.size}get queueDepth(){return this.fifoQueue.length+(this.pendingForLatestWins?1:0)}get lastResult(){return this._lastResult}get lastError(){return this._lastError}get lastDurationMs(){return this._lastDurationMs}subscribe(e){return this.subscribers.add(e),()=>this.subscribers.delete(e)}notify(){for(let e of this.subscribers)try{e()}catch(r){_chunkDRG5SLIPcjs.e.call(void 0, ).error("[SolveScheduler] subscriber threw:",r)}}solve(e,r,n){if(this.disposed)return Promise.reject(new (0, _chunkDRG5SLIPcjs.d)("SolveScheduler has been disposed and cannot be used",_chunkDRG5SLIPcjs.c.INVALID_STATE));let s=te(e,r),o={key:s,enqueuedAt:Date.now(),startedAt:null};if(this.cacheEnabled){let a=this.readCache(s);if(a){let i={status:"success",response:a,durationMs:0,fromCache:!0};return this._lastResult=a,this._lastError=null,this._lastDurationMs=0,this.runHook(this.onStart,o),this.runHook(this.onSettle,o,i),this.notify(),Promise.resolve(a)}}return new Promise((a,i)=>{let u={definition:e,dataTree:r,ctx:o,resolve:a,reject:i,externalSignal:_optionalChain([n, 'optionalAccess', _2 => _2.signal])};if(_optionalChain([u, 'access', _3 => _3.externalSignal, 'optionalAccess', _4 => _4.aborted])){this.settleError(u,this.makeAbortError(o));return}this.enqueue(u)})}enqueue(e){switch(this.mode){case"latest-wins":{this.pendingForLatestWins&&(this.supersede(this.pendingForLatestWins),this.pendingForLatestWins=null);for(let r of this.inFlight)this.supersede(r),r.controller.abort();this.inFlight.size===0?this.execute(e):this.pendingForLatestWins=e;break}case"queue":case"parallel":{this.inFlight.size<this.maxConcurrent?this.execute(e):this.fifoQueue.push(e);break}}this.notify()}async execute(e){let r=new AbortController,n=e;n.controller=r,this.inFlight.add(n),e.ctx.startedAt=Date.now();let s=()=>r.abort();_optionalChain([e, 'access', _5 => _5.externalSignal, 'optionalAccess', _6 => _6.addEventListener, 'call', _7 => _7("abort",s,{once:!0})]),this.runHook(this.onStart,e.ctx),this.notify();let o=performance.now();try{let a={...this.baseConfig,signal:r.signal,...this.timeoutMs!==void 0&&{timeoutMs:this.timeoutMs},...this.retry!==void 0&&{retry:this.retry}},{response:i,definitionReuploaded:u}=await this.runExecutor(e.definition,e.dataTree,a),c=performance.now()-o;if(this.cacheEnabled&&this.writeCache(e.ctx.key,i),!this.settleSuccess(e,i))return;this._lastResult=i,this._lastError=null,this._lastDurationMs=c,this.runHook(this.onSettle,e.ctx,{status:"success",response:i,durationMs:c,fromCache:!1,definitionReuploaded:u})}catch(a){let i=performance.now()-o,u=this.normalizeExecutionError(a,n);this._lastError=u,this._lastDurationMs=i,this.settleError(e,u)&&this.runHook(this.onSettle,e.ctx,{status:"error",error:u,durationMs:i})}finally{_optionalChain([e, 'access', _8 => _8.externalSignal, 'optionalAccess', _9 => _9.removeEventListener, 'call', _10 => _10("abort",s)]),this.inFlight.delete(n),this.drainNext(),this.notify()}}async runExecutor(e,r,n){if(!this.cacheKeyExecutor||!this.reuseServerDefinitionCache||!Ee(e))return{response:await this.executor(e,r,n)};let s=W(e),o=_nullishCoalesce(this.serverCacheKeys.get(s), () => (null)),a=await this.cacheKeyExecutor(e,r,o,n);if(a.cacheKey)for(this.serverCacheKeys.delete(s),this.serverCacheKeys.set(s,a.cacheKey);this.serverCacheKeys.size>we;){let i=this.serverCacheKeys.keys().next().value;if(i===void 0)break;this.serverCacheKeys.delete(i)}else this.serverCacheKeys.delete(s);return{response:a.response,definitionReuploaded:a.missed}}drainNext(){if(!this.disposed){if(this.mode==="latest-wins"){if(this.pendingForLatestWins&&this.inFlight.size===0){let e=this.pendingForLatestWins;this.pendingForLatestWins=null,this.execute(e)}return}for(;this.fifoQueue.length>0&&this.inFlight.size<this.maxConcurrent;){let e=this.fifoQueue.shift();this.execute(e)}}}supersede(e){let r=new (0, _chunkDRG5SLIPcjs.d)("Superseded by newer solve",_chunkDRG5SLIPcjs.c.SUPERSEDED,{context:{key:e.ctx.key,enqueuedAt:e.ctx.enqueuedAt}});this.settleError(e,r)&&this.runHook(this.onSuperseded,e.ctx)}makeAbortError(e){return new (0, _chunkDRG5SLIPcjs.d)("Request aborted by caller",_chunkDRG5SLIPcjs.c.ABORTED,{context:{key:e.key,enqueuedAt:e.enqueuedAt}})}settleError(e,r){return e.settled?!1:(e.settled={error:r},e.reject(r),!0)}settleSuccess(e,r){return e.settled?!1:(e.settled={ok:!0},e.resolve(r),!0)}isAbortLikeError(e){if(e instanceof Error){if(e.name==="AbortError")return!0;if(typeof DOMException<"u"&&e instanceof DOMException)return e.name==="AbortError"}return!1}normalizeExecutionError(e,r){return r.settled&&"error"in r.settled?r.settled.error:e instanceof _chunkDRG5SLIPcjs.d?e:this.isAbortLikeError(e)?this.makeAbortError(r.ctx):new (0, _chunkDRG5SLIPcjs.d)(e instanceof Error?e.message:String(e),_chunkDRG5SLIPcjs.c.UNKNOWN_ERROR,{originalError:e instanceof Error?e:new Error(String(e))})}cancelAll(){for(this.pendingForLatestWins&&(this.rejectAsAborted(this.pendingForLatestWins),this.pendingForLatestWins=null);this.fifoQueue.length>0;){let e=this.fifoQueue.shift();this.rejectAsAborted(e)}for(let e of this.inFlight){let r=this.makeAbortError(e.ctx);this.settleError(e,r)&&this.runHook(this.onSettle,e.ctx,{status:"error",error:r,durationMs:e.ctx.startedAt?performance.now()-e.ctx.startedAt:0}),e.controller.abort()}this.notify()}rejectAsAborted(e){this.settleError(e,this.makeAbortError(e.ctx))}readCache(e){if(!this.cacheEnabled)return null;let r=this.cache.get(e);return r?this.cacheTtl>0&&Date.now()-r.insertedAt>this.cacheTtl?(this.cache.delete(e),null):(this.cache.delete(e),this.cache.set(e,r),r.response):null}writeCache(e,r){if(this.cacheEnabled)for(this.cache.set(e,{response:r,insertedAt:Date.now()});this.cache.size>this.cacheMax;){let n=this.cache.keys().next().value;if(n===void 0)break;this.cache.delete(n)}}clearCache(){this.cache.clear()}dispose(){this.disposed||(this.disposed=!0,this.cancelAll(),this.subscribers.clear(),this.cache.clear())}runHook(e,...r){if(e)try{e(...r)}catch(n){_chunkDRG5SLIPcjs.e.call(void 0, ).error("[SolveScheduler] hook threw:",n)}}};var R=class t{constructor(e){_chunkDRG5SLIPcjs.b.call(void 0, this,"config");_chunkDRG5SLIPcjs.b.call(void 0, this,"serverStats");_chunkDRG5SLIPcjs.b.call(void 0, this,"disposed",!1);this.config=this.normalizeComputeConfig(e),this.serverStats=new (0, _chunkDRG5SLIPcjs.n)(this.config.serverUrl,this.config.apiKey)}static async create(e){let r=new t(e),n=Math.max(1,(_nullishCoalesce(_optionalChain([e, 'access', _11 => _11.retry, 'optionalAccess', _12 => _12.attempts]), () => (2)))+1),s=_nullishCoalesce(_optionalChain([e, 'access', _13 => _13.retry, 'optionalAccess', _14 => _14.baseDelayMs]), () => (250)),o=_nullishCoalesce(_optionalChain([e, 'access', _15 => _15.retry, 'optionalAccess', _16 => _16.maxDelayMs]), () => (1e3));for(let a=0;a<n;a++){if(await r.serverStats.isServerOnline())return r;if(a<n-1){let i=Math.min(s*2**a,o);await new Promise(u=>setTimeout(u,i))}}throw await r.dispose(),new (0, _chunkDRG5SLIPcjs.d)("Rhino Compute server is not online",_chunkDRG5SLIPcjs.c.NETWORK_ERROR,{context:{serverUrl:r.config.serverUrl,attempts:n}})}getConfig(){return this.ensureNotDisposed(),{...this.config}}async getIO(e){return this.ensureNotDisposed(),F(e,this.config)}async getRawIO(e){return this.ensureNotDisposed(),w(e,this.config)}async solve(e,r,n){this.ensureNotDisposed();try{if(typeof e=="string"&&!_optionalChain([e, 'optionalAccess', _17 => _17.trim, 'call', _18 => _18()]))throw new (0, _chunkDRG5SLIPcjs.d)("Definition URL/content is required",_chunkDRG5SLIPcjs.c.INVALID_INPUT,{context:{receivedUrl:e}});if(e instanceof Uint8Array&&e.length===0)throw new (0, _chunkDRG5SLIPcjs.d)("Definition content is empty",_chunkDRG5SLIPcjs.c.INVALID_INPUT);let s={...this.config,..._optionalChain([n, 'optionalAccess', _19 => _19.signal])!==void 0&&{signal:n.signal},..._optionalChain([n, 'optionalAccess', _20 => _20.timeoutMs])!==void 0&&{timeoutMs:n.timeoutMs},..._optionalChain([n, 'optionalAccess', _21 => _21.retry])!==void 0&&{retry:n.retry}},o=await D(r,e,s);if(_optionalChain([o, 'optionalAccess', _22 => _22.errors])&&o.errors.length>0)throw new (0, _chunkDRG5SLIPcjs.d)(o.errors.join("; ")||"Computation failed",_chunkDRG5SLIPcjs.c.COMPUTATION_ERROR,{context:{definition:typeof e=="string"&&e.length<200?e:"...content...",inputs:r,errors:o.errors,warnings:o.warnings}});return o}catch(s){throw this.config.debug&&_chunkDRG5SLIPcjs.e.call(void 0, ).error("Compute failed:",s),s instanceof _chunkDRG5SLIPcjs.d?s:new (0, _chunkDRG5SLIPcjs.d)(s instanceof Error?s.message:String(s),_chunkDRG5SLIPcjs.c.COMPUTATION_ERROR,{context:{definition:typeof e=="string"&&e.length<200?e:"...content...",inputs:r},originalError:s instanceof Error?s:new Error(String(s))})}}createScheduler(e){this.ensureNotDisposed();let r=(s,o,a)=>D(o,s,a),n=(s,o,a,i)=>a===null?Q(o,s,i).then(u=>({...u,missed:!1})):X(o,a,s,i);return new S(r,this.config,e,n)}async dispose(){this.disposed||(this.disposed=!0,await this.serverStats.dispose())}ensureNotDisposed(){if(this.disposed)throw new (0, _chunkDRG5SLIPcjs.d)("GrasshopperClient has been disposed and cannot be used",_chunkDRG5SLIPcjs.c.INVALID_STATE)}normalizeComputeConfig(e){return{...e,serverUrl:_chunkDRG5SLIPcjs.m.call(void 0, e.serverUrl),apiKey:e.apiKey,authToken:e.authToken,debug:_nullishCoalesce(e.debug, () => (!1)),suppressBrowserWarning:_nullishCoalesce(e.suppressBrowserWarning, () => (e.suppressClientSideWarning))}}};var G=new Map;function re(t,e){G.set(t,e)}re("Rhino.Geometry.Point3d",(t,e)=>{let r=e;return!r||typeof r.X!="number"?null:new t.Point([r.X,r.Y,r.Z])});re("Rhino.Geometry.Line",(t,e)=>{let r=e;return!r||!r.From||!r.To?null:new t.Line([r.From.X,r.From.Y,r.From.Z],[r.To.X,r.To.Y,r.To.Z])});function ve(t){if(G.has(t))return G.get(t);for(let[e,r]of G)if(t.startsWith(e))return r}function Ae(t){return!t||typeof t!="object"?null:_nullishCoalesce(_nullishCoalesce(t.data, () => (t.value)), () => (null))}function ne(t,e,r){let n=ve(e);if(n)try{return n(r,t)}catch(s){_chunkDRG5SLIPcjs.e.call(void 0, ).warn(`Failed to decode Rhino type ${e}:`,s)}try{let s=Ae(t);if(s)return r.CommonObject.decode(s)}catch(s){return _chunkDRG5SLIPcjs.e.call(void 0, ).warn(`Failed to decode ${e} with CommonObject:`,s),{__decodeError:!0,type:e,raw:t}}return t}var I={STRING:"System.String",INT:"System.Int32",DOUBLE:"System.Double",BOOL:"System.Boolean"},Ne="Rhino.Geometry.",Oe=["WebDisplay"],Fe="FileData";function se(t){return Oe.some(e=>t.includes(e))}function oe(t){if(typeof t!="string")return t;let e=t.trim();if(!(e.startsWith("{")||e.startsWith("[")||e.startsWith('"')))return t;try{let n=JSON.parse(e);if(typeof n=="string")try{return JSON.parse(n)}catch (e2){return n}return n}catch (e3){return t}}function Ge(t,e,r){switch(e){case I.STRING:return typeof t!="string"?t:t.replace(/^"(.*)"$/,"$1");case I.INT:return Number.parseInt(t,10);case I.DOUBLE:return Number.parseFloat(t);case I.BOOL:return String(t).toLowerCase()==="true";default:return r&&e.startsWith(Ne)?ne(t,e,r):t}}function ae(t,e,r,n){if(typeof t!="string")return t;let s=r?oe(t):t;return Ge(s,e,n)}function ke(t){if(!t||typeof t!="object")return!1;let e=t;return typeof e.fileName=="string"&&typeof e.fileType=="string"&&"data"in e&&typeof e.isBase64Encoded=="boolean"&&typeof e.subFolder=="string"}function k(t,e){for(let r of Object.values(t))if(Array.isArray(r))for(let n of r)e(n)}function ie(t,e=!1,r={}){let{parseValues:n=!0,rhino:s,stringOnly:o=!1}=r,a={},i=new Set;for(let u of t.values)k(u.InnerTree,c=>{if(se(c.type)||o&&c.type!==I.STRING)return;let m=e?c.id:u.ParamName;if(!m)return;let y=ae(c.data,c.type,n,s);m in a?i.has(m)?a[m].push(y):(a[m]=[a[m],y],i.add(m)):a[m]=y});return{values:a}}function ue(t){let e=[];for(let r of t.values)k(r.InnerTree,n=>{if(!n.type.includes(Fe))return;let s=oe(n.data);ke(s)&&e.push(s)});return e}function pe(t,e,r={}){let{parseValues:n=!0,rhino:s,stringOnly:o=!1}=r,a;if("byName"in e?a=t.values.find(u=>u.ParamName===e.byName):a=t.values.find(u=>{let c=!1;return k(u.InnerTree,m=>{m.id===e.byId&&(c=!0)}),c}),!a)return;let i=[];if(k(a.InnerTree,u=>{if("byId"in e&&u.id!==e.byId||se(u.type)||o&&u.type!==I.STRING)return;let c=ae(u.data,u.type,n,s);i.push(c)}),i.length!==0)return i.length===1?i[0]:i}var E=class{constructor(e,r=!1){this.response=e;this.debug=r}getValues(e=!1,r={}){return ie(this.response,e,r)}getValue(e,r){return pe(this.response,e,r)}async extractMeshesFromResponse(e){let r={debug:this.debug,...e},n;try{({getThreeMeshesFromComputeResponse:n}=await Promise.resolve().then(() => _interopRequireWildcard(require("./visualization-KNQ2NANO.cjs"))))}catch(s){throw new (0, _chunkDRG5SLIPcjs.d)("Failed to load three.js visualization module. Ensure three.js is installed as a peer dependency.",_chunkDRG5SLIPcjs.c.INVALID_STATE,{context:{originalError:s instanceof Error?s.message:String(s)}})}return n(this.response,r)}getFileData(){return ue(this.response)}async getAndDownloadFiles(e,r){let n=this.getFileData();await _chunkDRG5SLIPcjs.r.call(void 0, n,e,r)}};function le(t){return p(t,"data")}function Me(t){return p(t,"type")}function ce(t){if(typeof t.default!="object"||t.default===null)return{schema:t};if(!L(t.default,"innerTree")){let n=`Input "${_nullishCoalesce(t.name, () => ("unknown"))}" default had an unrecognized shape (no innerTree key); the default was dropped.`;return _chunkDRG5SLIPcjs.e.call(void 0, ).warn("Unexpected structure in input.default:",t.default),{schema:{...t,default:null},warning:{code:"MALFORMED_DEFAULT",message:n}}}let e=_nullishCoalesce(p(t.default,"innerTree"), () => ({}));if(Object.keys(e).length===0)return{schema:{...t,default:void 0}};if(t.treeAccess||t.atMost&&t.atMost>1){let n={};for(let[s,o]of Object.entries(e))n[s]=o.map(a=>{let i=le(a),u=Me(a);if(typeof i=="string"){if(u==="System.Double"||u==="System.Int32"){let c=Number(i);return Number.isNaN(c)?i:c}if(u==="System.Boolean")return i.toLowerCase()==="true";if(_optionalChain([u, 'optionalAccess', _23 => _23.startsWith, 'call', _24 => _24("Rhino.Geometry")]))try{return JSON.parse(i)}catch (e4){return i}}return i});return{schema:{...t,default:n}}}let r=[];for(let n of Object.values(e))Array.isArray(n)&&n.forEach(s=>{s&&typeof s=="object"&&L(s,"data")&&r.push(le(s))});return r.length===0?{schema:{...t,default:void 0}}:r.length===1?{schema:{...t,default:r[0]}}:{schema:{...t,default:r}}}var B=/^\{(\d+(?:;\d+)*)?\}$/;function v(t){if(typeof t!="object"||t===null||Array.isArray(t))return!1;let e=Object.entries(t);return e.length>0&&e.every(([r,n])=>B.test(r)&&Array.isArray(n))}function x(t,e,r){if(t==null)return t;if(Array.isArray(t)){let s=t.map(e).filter(o=>o!==null);return s.length>0?s:void 0}let n=e(t);return n!==null?n:r?void 0:t}var Ve=t=>{if(typeof t=="number")return t;if(typeof t=="string"){let e=t.trim();if(e==="")return null;let r=Number(e);return Number.isNaN(r)?null:r}return null},Le=t=>{if(typeof t=="boolean")return t;if(typeof t=="string"){let e=t.toLowerCase();if(e==="true")return!0;if(e==="false")return!1;throw new Error(`Invalid boolean string: "${t}"`)}return null},We=t=>typeof t=="string"?t.length>=2&&t.startsWith('"')&&t.endsWith('"')?t.slice(1,-1):t.startsWith('"')?t.slice(1):t:null,Be=t=>{if(typeof t=="string"){let e=t.trim();return e.startsWith('"')&&e.endsWith('"')&&(e=e.slice(1,-1).trim()),e}return null};function me(t){return e=>{if(typeof e=="object"&&e!==null)return e;if(typeof e=="string"&&e.trim()!=="")try{let r=JSON.parse(e);return typeof r=="object"&&r!==null?r:(_chunkDRG5SLIPcjs.e.call(void 0, ).warn(`Parsed value for input ${t} is not an object`),null)}catch(r){return _chunkDRG5SLIPcjs.e.call(void 0, ).warn(`Failed to parse object value "${e}" for input ${t}`,r),null}return null}}function fe(t,e,r){let n=Number(t.toFixed(e));return Math.abs(t-n)<r?n:t}function je(t,e){if(!Number.isFinite(t)||t===0)return .1;let r=Math.abs(t);if(r>=1){let g=String(t).split(".")[1];if(g&&g.length>0){let b=Math.min(g.length,12),T=Math.pow(10,-b),K=Number(T.toFixed(b));return Math.abs(K-T)<e?K:T}return 1}let n=String(t),s=n.toLowerCase().match(/e(-?\d+)/);if(s){let y=Number(s[1]);if(y<0||n.toLowerCase().includes("e-")){let g=Math.abs(y),b=Math.pow(10,-g),T=Number(b.toFixed(g));return Math.abs(T-b)<e?T:b}return .1}let o=12,i=r.toFixed(o).replace(/0+$/,""),u=Math.min((i.split(".")[1]||"").length,o);if(u===0)return .1;let c=Math.pow(10,-u),m=Number(c.toFixed(u));return Math.abs(m-c)<e?m:c}function Ke(t,e=1e-8){let r=t.paramType==="Integer";if(v(t.default))return{default:t.default,stepSize:r?1:.1};let n=x(t.default,Ve,!0);if(r)return Array.isArray(n)?n=n.map(m=>typeof m=="number"?Math.round(m):m):typeof n=="number"&&(n=Math.round(n)),{default:n,stepSize:1};let s=Array.isArray(n)?n[0]:n,o;typeof s=="number"&&Number.isFinite(s)&&s!==0?o=s:typeof t.minimum=="number"&&Number.isFinite(t.minimum)&&t.minimum!==0?o=t.minimum:typeof t.maximum=="number"&&Number.isFinite(t.maximum)&&t.maximum!==0&&(o=t.maximum);let a=o!==void 0?je(o,e):.1,i=0,u=String(a),c=u.toLowerCase().match(/e(-?\d+)/);if(c?i=Math.abs(Number(c[1])):i=_nullishCoalesce(_optionalChain([u, 'access', _25 => _25.split, 'call', _26 => _26("."), 'access', _27 => _27[1], 'optionalAccess', _28 => _28.length]), () => (0)),i===0&&typeof s=="number"&&s!==0&&Math.abs(s)<1){let m=Math.ceil(-Math.log10(Math.abs(s)));Number.isFinite(m)&&m>0&&(i=m)}return i=Math.min(Math.max(i,0),12),Array.isArray(n)?n=n.map(m=>typeof m=="number"?fe(m,i,e):m):typeof n=="number"&&(n=fe(n,i,e)),{default:n,stepSize:a}}var Ue={types:["Number","Integer"],parse(t,e){let{default:r,stepSize:n}=Ke(t);return{...e,paramType:t.paramType,minimum:t.minimum,maximum:t.maximum,atLeast:t.atLeast,atMost:t.atMost,stepSize:n,default:r}},fallback(t,e){let r=(_nullishCoalesce(t.atMost, () => (1)))>1;return{...e,paramType:t.paramType,minimum:t.minimum,maximum:t.maximum,atLeast:t.atLeast,atMost:t.atMost,default:r?[0]:0}}},ze={types:["Boolean"],parse(t,e){let r;try{r=x(t.default,Le,!1)}catch(n){throw n instanceof Error?new (0, _chunkDRG5SLIPcjs.d)(n.message):n}return{...e,paramType:"Boolean",default:r}},fallback(t,e){let r=(_nullishCoalesce(t.atMost, () => (1)))>1;return{...e,paramType:"Boolean",default:r?[!1]:!1}}},$e={types:["Text"],parse(t,e){let r=x(t.default,We,!1);return{...e,paramType:"Text",default:r}},fallback(t,e){let r=(_nullishCoalesce(t.atMost, () => (1)))>1;return{...e,paramType:"Text",default:r?[""]:""}}},_e={types:["ValueList"],parse(t,e){if(!t.values||typeof t.values!="object"||Object.keys(t.values).length===0)throw _chunkDRG5SLIPcjs.d.missingValues(t.nickname||"unnamed","ValueList");if(t.default!==void 0&&t.default!==null){let r=String(t.default).toLowerCase();Object.keys(t.values).some(s=>s.toLowerCase()===r)||_chunkDRG5SLIPcjs.e.call(void 0, ).warn(`ValueList input "${t.nickname||"unnamed"}" default value "${t.default}" is not in available values`)}return{...e,paramType:"ValueList",values:t.values,default:t.default}},fallback(t,e){let r=(_nullishCoalesce(t.atMost, () => (1)))>1;return{...e,paramType:"ValueList",values:_nullishCoalesce(t.values, () => ({})),default:r?[t.default]:t.default}}},de={types:["Geometry"],parse(t,e){let r=x(t.default,me(t.nickname||"unnamed"),!0);return{...e,paramType:"Geometry",default:r}},fallback(t,e){let r=(_nullishCoalesce(t.atMost, () => (1)))>1;return{...e,paramType:"Geometry",default:r?[null]:null}}},qe={types:["File"],parse(t,e){let r=x(t.default,me(t.nickname||"unnamed"),!0);return{...e,paramType:"File",acceptedFormats:t.acceptedFormats,default:r}},fallback(t,e){let r=(_nullishCoalesce(t.atMost, () => (1)))>1;return{...e,paramType:"File",default:r?[null]:null}}},He={types:["Color"],parse(t,e){let r=x(t.default,Be,!1);return{...e,paramType:"Color",default:r}},fallback(t,e){let r=(_nullishCoalesce(t.atMost, () => (1)))>1;return{...e,paramType:"Color",default:r?["0, 0, 0"]:"0, 0, 0"}}},Je=[Ue,ze,$e,_e,de,qe,He],j=new Map(Je.flatMap(t=>t.types.map(e=>[e,t]))),he=de;var Ye=new Map([...j.keys()].map(t=>[t.toLowerCase(),t]));function Qe(t){return _nullishCoalesce(Ye.get(_optionalChain([t, 'optionalAccess', _29 => _29.toLowerCase, 'call', _30 => _30()])), () => (t))}function ye(t){return ge(t).input}function ge(t){let e={description:t.description,name:t.name,nickname:t.nickname,treeAccess:t.treeAccess,groupName:_nullishCoalesce(t.groupName, () => ("")),id:t.id},r=Qe(t.paramType),{schema:n,warning:s}=ce({...t,paramType:r}),o=s&&{inputName:t.name||"unknown",paramType:r,message:s.message,code:s.code},a=j.get(r);try{if(!a)throw _chunkDRG5SLIPcjs.d.unknownParamType(r,t.name);return{input:a.parse(n,e),error:o}}catch(i){if(i instanceof _chunkDRG5SLIPcjs.d)return _chunkDRG5SLIPcjs.e.call(void 0, ).error(`Validation error for input ${t.name||"unknown"}:`,i.message),{input:(_nullishCoalesce(a, () => (he))).fallback(n,e),error:{inputName:t.name||"unknown",paramType:r,message:i.message,code:i.code}};throw new (0, _chunkDRG5SLIPcjs.d)(i instanceof Error?i.message:String(i),"VALIDATION_ERROR",{context:{paramName:t.name,paramType:r},originalError:i instanceof Error?i:new Error(String(i))})}}function be(t){return M(t).inputs}function M(t){let e=[],r=[];for(let n of t){let{input:s,error:o}=ge(n);e.push(s),o&&r.push(o)}return{inputs:e,parseErrors:r}}function Te(t){return{id:p(t,"id"),name:p(t,"name"),nickname:_nullishCoalesce(p(t,"nickname"), () => (null)),description:p(t,"description"),paramType:p(t,"paramType"),treeAccess:p(t,"treeAccess"),minimum:_nullishCoalesce(p(t,"minimum"), () => (null)),maximum:_nullishCoalesce(p(t,"maximum"), () => (null)),atLeast:p(t,"atLeast"),atMost:p(t,"atMost"),stepSize:p(t,"stepSize"),default:p(t,"default"),values:p(t,"values"),acceptedFormats:p(t,"acceptedFormats"),groupName:_nullishCoalesce(p(t,"groupName"), () => (""))}}function Ce(t){return{name:p(t,"name"),nickname:_nullishCoalesce(p(t,"nickname"), () => (null)),paramType:p(t,"paramType"),id:p(t,"id")}}async function w(t,e){let r=P(t,[]),n={};if(r.algo&&(n.algo=r.algo),r.pointer&&(n.pointer=r.pointer),!n.algo&&!n.pointer)throw new (0, _chunkDRG5SLIPcjs.d)("Definition must resolve to either a URL pointer or base64 algo",_chunkDRG5SLIPcjs.c.INVALID_INPUT,{context:{definition:t}});let s=await _chunkDRG5SLIPcjs.l.call(void 0, "io",n,e);if(!s||typeof s!="object")throw new (0, _chunkDRG5SLIPcjs.d)("Invalid IO response structure",_chunkDRG5SLIPcjs.c.INVALID_INPUT,{context:{response:s,definition:t}});let o=Se(p(s,"warnings")),a=Se(p(s,"errors")),i=p(s,"inputs"),u=p(s,"outputs");return{inputs:Array.isArray(i)?i.map(Te):[],outputs:Array.isArray(u)?u.map(Ce):[],...o&&{loadWarnings:o},...a&&{loadErrors:a}}}function Se(t){if(!Array.isArray(t))return;let e=t.filter(r=>typeof r=="string"&&r.trim().length>0);return e.length>0?e:void 0}async function F(t,e){C("fetchParsedDefinitionIO",_nullishCoalesce(e.suppressBrowserWarning, () => (e.suppressClientSideWarning)));let{inputs:r,outputs:n,loadWarnings:s,loadErrors:o}=await w(t,e),{inputs:a,parseErrors:i}=M(r);return{inputs:a,outputs:n,...i.length>0&&{parseErrors:i},...s&&{loadWarnings:s},...o&&{loadErrors:o}}}var V=class t{constructor(e){_chunkDRG5SLIPcjs.b.call(void 0, this,"innerTree");_chunkDRG5SLIPcjs.b.call(void 0, this,"paramName");this.paramName=e,this.innerTree={}}append(e,r){let n=t.formatPathString(e);this.innerTree[n]||(this.innerTree[n]=[]);let s=r.map(o=>({data:t.serializeValue(o)}));return this.innerTree[n].push(...s),this}appendSingle(e,r){return this.append(e,[r])}fromDataTreeDefault(e){this.innerTree={};for(let[r,n]of Object.entries(e)){if(!Array.isArray(n))continue;let s=t.parsePathString(r);this.append(s,n)}return this}appendFlat(e){let r=Array.isArray(e)?e:[e];return this.append([0],r)}flatten(){let e=[];for(let r of Object.values(this.innerTree))if(Array.isArray(r))for(let n of r)e.push(t.deserializeValue(n.data));return e}getPaths(){return Object.keys(this.innerTree)}getPath(e){let r=t.formatPathString(e),n=this.innerTree[r];if(n)return n.map(s=>t.deserializeValue(s.data))}toComputeFormat(){return{ParamName:this.paramName,InnerTree:this.innerTree}}getInnerTree(){return this.innerTree}getParamName(){return this.paramName}static fromInputParams(e){return e.filter(r=>t.hasValidValue(r.default)).map(r=>{let n=new t(r.nickname||"unnamed"),s=r.default;if(r.treeAccess&&v(s))n.fromDataTreeDefault(s),t.isNumericInput(r)&&n.applyNumericConstraints(r.minimum,r.maximum,r.nickname||"unnamed");else{let o=Array.isArray(s)?s:[s],a=t.processValues(o,r);n.appendFlat(a)}return n.toComputeFormat()})}static fromInputParam(e){return t.hasValidValue(e.default)?t.fromInputParams([e])[0]:void 0}static replaceTreeValue(e,r,n){let s=e.length>0&&e[0]instanceof t,o=t.buildFromValue(r,n);if(s){let c=e,m=c.findIndex(y=>y.getParamName()===r);return m!==-1?c[m]=o:c.push(o),c}let a=e,i=o.toComputeFormat(),u=a.findIndex(c=>c.ParamName===r);return u!==-1?a[u]=i:a.push(i),a}static buildFromValue(e,r){let n=new t(e);return v(r)?n.fromDataTreeDefault(r):n.appendFlat(r),n}static getTreeValue(e,r){let s=e.length>0&&e[0]instanceof t?t.readFromBuilders(e,r):t.readFromDataTrees(e,r);return s===null||s.length===0?null:s.length===1?s[0]:s}static readFromBuilders(e,r){let n=e.find(s=>s.getParamName()===r);return n?n.flatten():null}static readFromDataTrees(e,r){let n=e.find(a=>a.ParamName===r);if(!_optionalChain([n, 'optionalAccess', _31 => _31.InnerTree]))return null;let s=Object.keys(n.InnerTree)[0];if(!s)return null;let o=n.InnerTree[s];return Array.isArray(o)?o.map(a=>_optionalChain([a, 'optionalAccess', _32 => _32.data])!==void 0?t.deserializeValue(a.data):null).filter(a=>a!==null):_optionalChain([o, 'optionalAccess', _33 => _33.data])!==void 0?[t.deserializeValue(o.data)]:o!==void 0?[o]:null}static parsePathString(e){let r=e.match(B);return r?r[1]?r[1].split(";").map(Number):[]:(_chunkDRG5SLIPcjs.e.call(void 0, ).warn(`Invalid TreeBuilder path format: ${e}, using [0]`),[0])}static formatPathString(e){return`{${e.join(";")}}`}applyNumericConstraints(e,r,n){for(let s of Object.values(this.innerTree))if(Array.isArray(s))for(let o of s){let a=t.deserializeValue(o.data);if(typeof a=="number"){let i=t.clampValue(a,e,r,n);o.data=t.serializeValue(i)}}}static serializeValue(e){return typeof e=="boolean"||typeof e=="number"||typeof e=="string"?e:typeof e=="object"&&e!==null?JSON.stringify(e):String(e)}static deserializeValue(e){if(typeof e=="boolean"||typeof e=="number"||typeof e!="string")return e;if(e.startsWith("{")||e.startsWith("["))try{return JSON.parse(e)}catch (e5){return e}return e.trim()!==""&&!isNaN(Number(e))?Number(e):e==="true"?!0:e==="false"?!1:e}static hasValidValue(e){return e==null?!1:typeof e=="string"?!0:!(Array.isArray(e)&&e.length===0||typeof e=="object"&&!Array.isArray(e)&&Object.keys(e).length===0)}static isNumericInput(e){return e.paramType==="Number"||e.paramType==="Integer"}static processValues(e,r){return e.map(n=>t.isNumericInput(r)&&typeof n=="number"?t.clampValue(n,r.minimum,r.maximum,r.nickname||"unnamed"):n).filter(n=>n!=null)}static clampValue(e,r,n,s){let o=e;return r!=null&&o<r&&(_chunkDRG5SLIPcjs.e.call(void 0, ).warn(`${s}: ${e} below min ${r}, clamping`),o=r),n!=null&&o>n&&(_chunkDRG5SLIPcjs.e.call(void 0, ).warn(`${s}: ${e} above max ${n}, clamping`),o=n),o}};exports.a = D; exports.b = S; exports.c = R; exports.d = E; exports.e = ye; exports.f = be; exports.g = w; exports.h = F; exports.i = V;
|
|
2
|
-
//# sourceMappingURL=chunk-6WCVFKOV.cjs.map
|
package/dist/chunk-DRG5SLIP.cjs
DELETED
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { newObj[key] = obj[key]; } } } newObj.default = obj; return newObj; } } function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }var U=Object.defineProperty;var q=(t,e,r)=>e in t?U(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r;var pe=(t,e)=>{for(var r in e)U(t,r,{get:e[r],enumerable:!0})};var h=(t,e,r)=>q(t,typeof e!="symbol"?e+"":e,r);var u={NETWORK_ERROR:"NETWORK_ERROR",AUTH_ERROR:"AUTH_ERROR",VALIDATION_ERROR:"VALIDATION_ERROR",COMPUTATION_ERROR:"COMPUTATION_ERROR",TIMEOUT_ERROR:"TIMEOUT_ERROR",CORS_ERROR:"CORS_ERROR",UNKNOWN_ERROR:"UNKNOWN_ERROR",INVALID_STATE:"INVALID_STATE",INVALID_INPUT:"INVALID_INPUT",INVALID_CONFIG:"INVALID_CONFIG",BROWSER_ONLY:"BROWSER_ONLY",ENVIRONMENT_ERROR:"ENVIRONMENT_ERROR",ENCODING_ERROR:"ENCODING_ERROR",MALFORMED_DEFAULT:"MALFORMED_DEFAULT",SUPERSEDED:"SUPERSEDED",ABORTED:"ABORTED",DEFINITION_NOT_CACHED:"DEFINITION_NOT_CACHED"},f= exports.d =class t extends Error{constructor(r,n=u.UNKNOWN_ERROR,o){super(r);h(this,"code");h(this,"statusCode");h(this,"context");h(this,"originalError");this.name="RhinoComputeError",this.code=n,this.statusCode=_optionalChain([o, 'optionalAccess', _2 => _2.statusCode]),this.context=_optionalChain([o, 'optionalAccess', _3 => _3.context]),this.originalError=_optionalChain([o, 'optionalAccess', _4 => _4.originalError]),_optionalChain([o, 'optionalAccess', _5 => _5.originalError])&&(this.cause=o.originalError)}static missingValues(r,n,o){return new t(`Input "${r}" has no values defined${n?` (expected ${n})`:""}`,u.INVALID_INPUT,{context:{inputName:r,expectedType:n,...o}})}static unknownParamType(r,n,o){return new t(`Unknown paramType: ${r}`,u.VALIDATION_ERROR,{context:{receivedParamType:r,paramName:n,...o}})}};var T=class{debug(){}info(){}warn(){}error(){}},N=class{debug(e,...r){console.debug(e,...r)}info(e,...r){console.info(e,...r)}warn(e,...r){console.warn(e,...r)}error(e,...r){console.error(e,...r)}},A=new T;function p(){return A}function D(t){if(t===null){A=new T;return}let e=["debug","info","warn","error"].filter(r=>typeof t[r]!="function");if(e.length>0)throw new f(`Logger is missing required method(s): ${e.join(", ")}. A logger must implement debug, info, warn and error.`,u.INVALID_CONFIG,{context:{missingMethods:e}});A=t}function K(){D(new N)}function S(){let t=globalThis.Buffer;return typeof t=="function"?t:void 0}function Ee(t){let e=S();return e?e.from(t,"utf-8").toString("base64"):W(new TextEncoder().encode(t))}function ve(t){return!t||t.length<2||t.length%4!==0?!1:/^[A-Za-z0-9+/]+={0,2}$/.test(t)}function _(t){let e=t.replace(/[\t\n\f\r ]/g,"");if(e.length%4===0&&(e=e.replace(/={1,2}$/,"")),e.length%4===1||!/^[A-Za-z0-9+/]*$/.test(e))throw new f("Invalid base64 input.",u.ENCODING_ERROR,{context:{inputLength:t.length}});let r=S();if(r){let n=r.from(e,"base64");return new Uint8Array(n.buffer,n.byteOffset,n.byteLength)}if(typeof globalThis.atob=="function"){let n=globalThis.atob(e),o=new Uint8Array(n.length);for(let i=0;i<n.length;i++)o[i]=n.charCodeAt(i)&255;return o}throw new f("Base64 decoding not supported in this environment.",u.INVALID_STATE,{context:{environmentInfo:"atob or Buffer not available"}})}function F(t){let e=S();if(e)return e.byteLength(t,"utf-8");let r=0;for(let n=0;n<t.length;n++){let o=t.charCodeAt(n);o<128?r+=1:o<2048?r+=2:o>=55296&&o<=56319&&n+1<t.length&&(t.charCodeAt(n+1)&64512)===56320?(r+=4,n++):r+=3}return r}function W(t){let e=S();if(e)return e.from(t).toString("base64");if(typeof globalThis.btoa=="function"){let n="";for(let o=0;o<t.length;o+=32768)n+=String.fromCharCode.apply(null,t.subarray(o,o+32768));return globalThis.btoa(n)}throw new f("Base64 encoding not supported in this environment.",u.INVALID_STATE,{context:{environmentInfo:"btoa or Buffer not available"}})}function H(t){if(!t)return null;let e={raw:t},r=!1;for(let n of t.split(",")){let[o,...i]=n.trim().split(";"),d=i.find(c=>c.trim().toLowerCase().startsWith("dur"));if(!d)continue;let s=Number(d.split("=")[1]);if(!Number.isFinite(s))continue;let a=o.trim().toLowerCase();(a==="decode"||a==="solve"||a==="encode")&&(e[a]=s,r=!0)}return r?e:null}var v={attempts:0,baseDelayMs:500,maxDelayMs:3e4,retryOn429:!0},L=new Set([502,503,504]);function z(t){return t?{attempts:_nullishCoalesce(t.attempts, () => (v.attempts)),baseDelayMs:_nullishCoalesce(t.baseDelayMs, () => (v.baseDelayMs)),maxDelayMs:_nullishCoalesce(t.maxDelayMs, () => (v.maxDelayMs)),retryOn429:_nullishCoalesce(t.retryOn429, () => (v.retryOn429))}:v}function V(t){if(!t)return null;let e=Number(t);if(Number.isFinite(e)&&e>=0)return e*1e3;let r=Date.parse(t);if(Number.isFinite(r)){let n=r-Date.now();return n>0?n:0}return null}function O(t,e){let r=e.baseDelayMs*Math.pow(2,t),n=Math.random()*e.baseDelayMs;return Math.min(r+n,e.maxDelayMs)}function J(t,e){return new Promise((r,n)=>{if(_optionalChain([e, 'optionalAccess', _6 => _6.aborted])){n(new DOMException("Aborted","AbortError"));return}let o=setTimeout(()=>{_optionalChain([e, 'optionalAccess', _7 => _7.removeEventListener, 'call', _8 => _8("abort",i)]),r()},t),i=()=>{clearTimeout(o),n(new DOMException("Aborted","AbortError"))};_optionalChain([e, 'optionalAccess', _9 => _9.addEventListener, 'call', _10 => _10("abort",i,{once:!0})])})}function G(t,e,r,n,o,i,d){let{status:s,statusText:a}=t,c={};t.headers.forEach(($,B)=>{c[B]=$});let m=i.trim(),l=m?` \u2014 ${m.slice(0,200)}${m.length>200?"\u2026":""}`:"",y={url:e,requestId:r,method:"POST",requestSize:n,serverUrl:o,responseBody:i||void 0,responseHeaders:c},E={401:{message:`HTTP ${s}: ${a}${l}`,code:u.AUTH_ERROR},403:{message:`HTTP ${s}: ${a}${l}`,code:u.AUTH_ERROR},404:{message:`Endpoint not found: ${e}`,code:u.NETWORK_ERROR},413:{message:`Request too large: ${(n/1024).toFixed(2)}KB`,code:u.VALIDATION_ERROR},429:{message:`Rate limit exceeded${l}`,code:u.NETWORK_ERROR},500:{message:`Server error: ${a}${l}`,code:u.COMPUTATION_ERROR},502:{message:`Service unavailable: ${a}${l}`,code:u.NETWORK_ERROR},503:{message:`Service unavailable: ${a}${l}`,code:u.NETWORK_ERROR},504:{message:`Service unavailable: ${a}${l}`,code:u.NETWORK_ERROR}}[s]||{message:`HTTP ${s}: ${a}${l}`,code:u.UNKNOWN_ERROR},w=_nullishCoalesce(j(d), () => (E.code));throw new f(E.message,w,{statusCode:s,context:y})}function j(t){if(t==="definition_not_cached")return u.DEFINITION_NOT_CACHED}function Y(t,e){let r=e.replace(/\/+$/,""),n=t.replace(/^\/+/,"");return`${r}/${n}`}function Z(t){try{let e=new URL(t).hostname.toLowerCase();return e==="localhost"||e==="127.0.0.1"||e==="[::1]"}catch (e2){return/(localhost|127\.0\.0\.1|\[::1\])/i.test(t)}}var x=new Set;function X(t,e){let r={"X-Request-ID":t,"Content-Type":"application/json",...e.authToken&&{Authorization:e.authToken},...e.apiKey&&{RhinoComputeKey:e.apiKey}};return!e.apiKey&&!e.authToken&&!x.has(e.serverUrl)&&!Z(e.serverUrl)&&(x.add(e.serverUrl),p().warn(`\u26A0\uFE0F [Rhino Compute] Request [${t}] targets remote server (${e.serverUrl}) but no API key or auth token is configured. Requests may fail or be rate-limited. (warned once per server)`)),r}function Q(){return`${Date.now()}-${Math.random().toString(36).substring(2,11)}`}function R(t,e){e&&p().debug(t)}function ee(t,e){let r=[],n=()=>{};if(t&&r.push(t),e&&e>0)if(typeof AbortSignal<"u"&&typeof AbortSignal.timeout=="function")r.push(AbortSignal.timeout(e));else{let s=new AbortController,a=setTimeout(()=>s.abort(),e);n=()=>clearTimeout(a),r.push(s.signal)}if(r.length===0)return{signal:void 0,cleanup:n};if(r.length===1)return{signal:r[0],cleanup:n};if(typeof AbortSignal<"u"&&typeof AbortSignal.any=="function")return{signal:AbortSignal.any(r),cleanup:n};let o=new AbortController,i=()=>o.abort();for(let s of r){if(s.aborted){o.abort();break}s.addEventListener("abort",i,{once:!0})}let d=n;return n=()=>{d();for(let s of r)s.removeEventListener("abort",i)},{signal:o.signal,cleanup:n}}async function re(t,e,r,n,o,i,d,s){let a=Math.round(performance.now()-i);if(!t.ok){let c=await t.text();d&&(R(`\u274C Request [${r}] failed with HTTP ${t.status} in ${a}ms`,!0),R(` URL: ${e}`,!0),R(` Status: ${t.status} ${t.statusText}`,!0),c&&R(` Response body: ${c.substring(0,500)}${c.length>500?"...":""}`,!0));let m;try{let l=JSON.parse(c);typeof _optionalChain([l, 'optionalAccess', _11 => _11.code])=="string"&&(m=l.code)}catch (e3){}if(t.status===500)try{let l=JSON.parse(c);if(_optionalChain([l, 'optionalAccess', _12 => _12.values])&&(l.errors||l.warnings))return d&&(R(`\u26A0\uFE0F Request [${r}] completed with Grasshopper errors in ${a}ms`,!0),_optionalChain([l, 'access', _13 => _13.errors, 'optionalAccess', _14 => _14.length])>0&&R(` Errors: ${JSON.stringify(l.errors,null,2)}`,!0),_optionalChain([l, 'access', _15 => _15.warnings, 'optionalAccess', _16 => _16.length])>0&&R(` Warnings: ${JSON.stringify(l.warnings,null,2)}`,!0)),l;let y=typeof _optionalChain([l, 'optionalAccess', _17 => _17.message])=="string"&&l.message||typeof _optionalChain([l, 'optionalAccess', _18 => _18.Message])=="string"&&l.Message||"",g=typeof _optionalChain([l, 'optionalAccess', _19 => _19.ExceptionType])=="string"&&l.ExceptionType||"",E=_nullishCoalesce(_optionalChain([l, 'optionalAccess', _20 => _20.stackTrace]), () => (_optionalChain([l, 'optionalAccess', _21 => _21.StackTrace]))),w=Array.isArray(E)?E.join(`
|
|
2
|
-
`):E||"";y?c=`${g?`${g}: `:""}${y}${w?`
|
|
3
|
-
${w}`:""}`:_optionalChain([l, 'optionalAccess', _22 => _22.error])&&(c=typeof l.error=="string"?l.error:JSON.stringify(l.error,null,2))}catch(l){d&&R(` Failed to parse error body as JSON: ${l}`,!0)}G(t,e,r,n,o,c,m)}if(R(`\u2705 Request [${r}] completed in ${a}ms`,d),s){let c=H(t.headers.get("Server-Timing"));if(c)try{s(c)}catch(m){d&&R(` onServerTiming callback threw: ${m}`,!0)}}try{return await t.json()}catch(c){throw new f("Failed to parse JSON response",u.NETWORK_ERROR,{statusCode:t.status,context:{url:e,requestId:r},originalError:c instanceof Error?c:new Error(String(c))})}}async function te(t,e,r,n){let{signal:o,cleanup:i}=ee(t.config.signal,t.config.timeoutMs),d=performance.now();try{let s=await fetch(t.fullUrl,{method:"POST",body:t.body,headers:t.headers,signal:o});if((L.has(s.status)||e.retryOn429&&s.status===429)&&r<n-1){let m=V(s.headers.get("Retry-After")),l=m!==null?Math.min(m,e.maxDelayMs):O(r,e);return await s.text().catch(()=>{}),{ok:!1,retry:!0,delayMs:l,cause:new f(`HTTP ${s.status} ${s.statusText} (will retry)`,u.NETWORK_ERROR,{statusCode:s.status,context:{requestId:t.requestId}})}}return{ok:!0,value:await re(s,t.fullUrl,t.requestId,t.requestSize,t.config.serverUrl,d,t.config.debug,t.config.onServerTiming)}}catch(s){if(s instanceof Error&&(s.name==="AbortError"||s.name==="TimeoutError")){if(_optionalChain([t, 'access', _23 => _23.config, 'access', _24 => _24.signal, 'optionalAccess', _25 => _25.aborted])===!0)return{ok:!1,retry:!1,cause:new f("Request aborted by caller",u.ABORTED,{context:{endpoint:t.endpoint,requestId:t.requestId,requestSize:t.requestSize},originalError:s})};let c=new f(`Request timed out after ${t.config.timeoutMs}ms`,u.TIMEOUT_ERROR,{context:{serverUrl:t.config.serverUrl,timeoutMs:t.config.timeoutMs,url:t.fullUrl,requestId:t.requestId,endpoint:t.endpoint,requestSize:t.requestSize}});return r<n-1?{ok:!1,retry:!0,delayMs:O(r,e),cause:c}:{ok:!1,retry:!1,cause:c}}if(s instanceof TypeError){let a=new f(`Network error: ${s.message}`,u.NETWORK_ERROR,{context:{serverUrl:t.config.serverUrl,url:t.fullUrl,requestId:t.requestId,endpoint:t.endpoint,requestSize:t.requestSize},originalError:s});return r<n-1?{ok:!1,retry:!0,delayMs:O(r,e),cause:a}:{ok:!1,retry:!1,cause:a}}if(s instanceof f){let a=s.statusCode;return(s.code===u.NETWORK_ERROR&&a!==void 0&&a>=200&&a<300||a!==void 0&&(L.has(a)||e.retryOn429&&a===429))&&r<n-1?{ok:!1,retry:!0,delayMs:O(r,e),cause:s}:{ok:!1,retry:!1,cause:s}}return{ok:!1,retry:!1,cause:new f(s instanceof Error?s.message:String(s),u.UNKNOWN_ERROR,{context:{endpoint:t.endpoint,requestId:t.requestId},originalError:s instanceof Error?s:new Error(String(s))})}}finally{i()}}async function ne(t,e,r){let n=Q(),o=JSON.stringify(e),i=F(o),d=Y(t,r.serverUrl),s=X(n,r),a=z(r.retry),c=a.attempts+1;if(r.debug){let y=(i/1024).toFixed(2),g=i>1e5?"\u26A0\uFE0F":"\u{1F680}";R(`${g} Starting compute request [${n}]: ${t} (${y}KB)`,!0)}let m={endpoint:t,body:o,requestSize:i,fullUrl:d,requestId:n,headers:s,config:r},l=null;for(let y=0;y<c;y++){let g=await te(m,a,y,c);if(g.ok)return g.value;if(!g.retry)throw g.cause;l=g.cause,r.debug&&R(`\u{1F501} Request [${n}] retrying after ${g.delayMs}ms (attempt ${y+2}/${c}): ${g.cause.message}`,!0);try{await J(g.delayMs,r.signal)}catch (e4){throw new f("Request aborted by caller",u.ABORTED,{context:{endpoint:t,requestId:n,requestSize:i},originalError:l})}}throw _nullishCoalesce(l, () => (new f("Unknown error after retries",u.UNKNOWN_ERROR,{context:{endpoint:t,requestId:n,requestSize:i}})))}var oe="compute.rhino3d.com";function P(t){if(!_optionalChain([t, 'optionalAccess', _26 => _26.trim, 'call', _27 => _27()]))throw new f("serverUrl is required",u.INVALID_CONFIG,{context:{receivedServerUrl:t}});if(!t.match(/^https?:\/\//))throw new f(`Invalid serverUrl: "${t}". Must start with "http://" or "https://". For example: "http://localhost:5000" or "https://example.com"`,u.INVALID_CONFIG,{context:{receivedServerUrl:t}});let e;try{e=new URL(t)}catch(r){throw new f(`Invalid serverUrl: "${t}". Must be a valid URL. Received error: ${r instanceof Error?r.message:String(r)}`,u.INVALID_CONFIG,{context:{receivedServerUrl:t},originalError:r instanceof Error?r:void 0})}if(e.hostname.toLowerCase()===oe)throw new f("serverUrl must be set to your Compute server URL. The default public endpoint is not allowed.",u.INVALID_CONFIG,{context:{receivedServerUrl:t}});return t.replace(/\/+$/,"")}var b=class b{constructor(e,r){h(this,"serverUrl");h(this,"apiKey");h(this,"disposed",!1);h(this,"activeMonitors",new Set);h(this,"activeTimeouts",new Set);this.serverUrl=P(e),this.apiKey=r}buildHeaders(){let e={"Content-Type":"application/json"};return this.apiKey&&(e.RhinoComputeKey=this.apiKey),e}fetchWithTimeout(e,r={},n=b.DEFAULT_TIMEOUT_MS){let o=this.buildHeaders();r.headers&&new Headers(r.headers).forEach((d,s)=>{o[s]=d});let i={...r,headers:o};return n>0&&!i.signal&&(i.signal=AbortSignal.timeout(n)),fetch(e,i)}async isServerOnline(e=5e3){this.ensureNotDisposed();let r=`${this.serverUrl}/`;try{return(await this.fetchWithTimeout(r,{method:"GET"},e)).ok}catch(n){return p().debug("[ComputeServerStats] Fetch error:",n),!1}}async getActiveChildren(e={}){this.ensureNotDisposed();let{initialize:r=!0}=e,n=r?`${this.serverUrl}/activechildren`:`${this.serverUrl}/activechildren?initialize=false`,o=r?b.LIFECYCLE_TIMEOUT_MS:b.DEFAULT_TIMEOUT_MS;try{let i=await this.fetchWithTimeout(n,{},o);if(!i.ok)return p().warn("[ComputeServerStats] Failed to fetch active children:",i.status),null;let d=await i.text(),s=parseInt(d.trim(),10);return isNaN(s)?(p().warn("[ComputeServerStats] Invalid active children response:",d),null):s}catch(i){return p().warn("[ComputeServerStats] Error fetching active children:",i),null}}async getVersion(){this.ensureNotDisposed();try{let e=await this.fetchWithTimeout(`${this.serverUrl}/version`);if(!e.ok)return p().warn("[ComputeServerStats] Failed to fetch version:",e.status),null;let r=await e.text();try{let n=JSON.parse(r);return{rhino:_nullishCoalesce(n.rhino, () => ("")),compute:_nullishCoalesce(n.compute, () => ("")),git_sha:_nullishCoalesce(n.git_sha, () => (null))}}catch (e5){return{rhino:r,compute:"",git_sha:null}}}catch(e){return p().warn("[ComputeServerStats] Error fetching version:",e),null}}async getInstalledPlugins(e="gh"){this.ensureNotDisposed();try{let r=await this.fetchWithTimeout(`${this.serverUrl}/plugins/${e}/installed`);if(!r.ok)return p().warn(`[ComputeServerStats] Failed to fetch ${e} plugins:`,r.status),null;let n=await r.text();try{let o=JSON.parse(n);return o&&typeof o=="object"?o:null}catch (e6){return null}}catch(r){return p().warn(`[ComputeServerStats] Error fetching ${e} plugins:`,r),null}}async getServerStats(){if(this.ensureNotDisposed(),!await this.isServerOnline())return{isOnline:!1};let[r,n]=await Promise.all([this.getVersion(),this.getActiveChildren({initialize:!1})]);return{isOnline:!0,...r&&{version:r},...n!==null&&{activeChildren:n}}}async purgeCache(){this.ensureNotDisposed();try{let e=await this.fetchWithTimeout(`${this.serverUrl}/cache/purge`,{method:"POST"});if(!e.ok)return p().warn("[ComputeServerStats] Failed to purge cache:",e.status),null;let r=await e.text();try{let n=JSON.parse(r);return typeof n.purged=="number"?n.purged:null}catch (e7){return null}}catch(e){return p().warn("[ComputeServerStats] Error purging cache:",e),null}}async purgeAllChildren(){this.ensureNotDisposed();let e=await this.getActiveChildren({initialize:!1});if(e===null)return p().warn("[ComputeServerStats] purgeAllChildren: could not read child count"),null;if(e===0)return{totalPurged:0,calls:0,children:0,confident:!0};let r=e*2,n=0;for(let o=0;o<r;o++){let i=await this.purgeCache();i!==null&&(n+=i)}return{totalPurged:n,calls:r,children:e,confident:e===1}}async getServerTime(){this.ensureNotDisposed();try{let e=await this.fetchWithTimeout(`${this.serverUrl}/servertime`);if(!e.ok)return p().warn("[ComputeServerStats] Failed to fetch server time:",e.status),null;let r=(await e.text()).trim().replace(/^"|"$/g,""),n=new Date(r);return isNaN(n.getTime())?null:n}catch(e){return p().warn("[ComputeServerStats] Error fetching server time:",e),null}}async getIdleSpan(){this.ensureNotDisposed();try{let e=await this.fetchWithTimeout(`${this.serverUrl}/idlespan`);if(!e.ok)return p().warn("[ComputeServerStats] Failed to fetch idle span:",e.status),null;let r=parseFloat((await e.text()).trim());return isNaN(r)?null:r}catch(e){return p().warn("[ComputeServerStats] Error fetching idle span:",e),null}}async launchChildren(){return this.postJson("/launch-children")}async launchChild(e){let r=e===void 0?"/launch-child":`/launch-child?port=${e}`;return this.postJson(r)}async shutdownChildren(e){let r=e===void 0?"/shutdown-children":`/shutdown-children?port=${e}`;return this.postJson(r)}async recycleChildren(e){let r=e===void 0?"/recycle-children":`/recycle-children?port=${e}`;return this.postJson(r)}async postJson(e){this.ensureNotDisposed();try{let r=await this.fetchWithTimeout(`${this.serverUrl}${e}`,{method:"POST"},b.LIFECYCLE_TIMEOUT_MS);if(!r.ok)return p().warn(`[ComputeServerStats] POST ${e} failed:`,r.status),null;let n=await r.text();try{return JSON.parse(n)}catch (e8){return null}}catch(r){return p().warn(`[ComputeServerStats] Error on POST ${e}:`,r),null}}monitor(e,r=5e3){this.ensureNotDisposed();let n=!0,o=null;p().info(`\u{1F504} Starting server stats monitoring every ${r}ms`);let i=async()=>{if(o!==null&&(this.activeTimeouts.delete(o),o=null),!(!n||this.disposed)){try{let s=await this.getServerStats();if(!n||this.disposed)return;try{e(s)}catch(a){p().error("[ComputeServerStats] Monitor callback threw:",a)}}catch(s){p().error("[ComputeServerStats] Failed to fetch stats during monitor:",s)}n&&!this.disposed&&(o=setTimeout(()=>{i()},r),this.activeTimeouts.add(o))}},d=()=>{n=!1,o!==null&&(clearTimeout(o),this.activeTimeouts.delete(o),o=null),this.activeMonitors.delete(d)};return this.activeMonitors.add(d),i(),d}async dispose(){if(!this.disposed){this.disposed=!0;for(let e of this.activeMonitors)e();this.activeMonitors.clear();for(let e of this.activeTimeouts)clearTimeout(e);this.activeTimeouts.clear()}}ensureNotDisposed(){if(this.disposed)throw new f("ComputeServerStats has been disposed and cannot be used",u.INVALID_STATE,{context:{disposed:this.disposed}})}};h(b,"DEFAULT_TIMEOUT_MS",5e3),h(b,"LIFECYCLE_TIMEOUT_MS",6e4);var C=b;function M(t,e={}){let{preserveSpaces:r=!1}=e,n=r?/[-_]+(.)?/g:/[\s-_]+(.)?/g,o=t.trim();return o.charAt(0).toLowerCase()+o.slice(1).replace(n,(i,d)=>d?d.toUpperCase():"")}function I(t,e={}){return!t||typeof t!="object"?t:Array.isArray(t)?e.deep?t.map(r=>I(r,e)):t:Object.keys(t).reduce((r,n)=>{let o=M(n,{preserveSpaces:e.preserveSpaces}),i=t[n];return r[o]=e.deep?I(i,e):i,r},{})}var se=async(t,e=null)=>{try{return await k(t,e)}catch(r){throw new f("Failed to extract files from compute response",u.INVALID_STATE,{context:{originalError:r instanceof Error?r.message:String(r)},originalError:r instanceof Error?r:void 0})}},ie= exports.r =async(t,e,r=null)=>{if(typeof document>"u"||typeof Blob>"u")throw new f("File download functionality is only available in browser environments. This function requires the DOM API (document, Blob).",u.BROWSER_ONLY,{context:{environment:typeof window<"u"?"browser (SSR)":"Node.js",documentAvailable:typeof document<"u",blobAvailable:typeof Blob<"u"}});try{let n=await k(t,r);await ce(n,e)}catch(n){throw n instanceof f?n:new f("Failed to download files from compute response",u.INVALID_STATE,{context:{originalError:n instanceof Error?n.message:String(n)},originalError:n instanceof Error?n:void 0})}},ae=t=>{let e=[];return t.forEach(r=>{let n=`${r.fileName}${r.fileType}`,o=r.subFolder&&r.subFolder.trim()!==""?`${r.subFolder}/${n}`:n;if(r.isBase64Encoded===!0&&r.data)try{e.push({fileName:n,content:_(r.data),path:o})}catch(i){p().warn(`Skipping file "${o}": base64 decode failed.`,i)}else r.isBase64Encoded===!1&&r.data?e.push({fileName:n,content:r.data,path:o}):p().warn(`Skipping file "${o}": item carries no usable data.`)}),e},ue=3e4,le=async t=>(await Promise.all(t.map(async r=>{try{let n=typeof AbortSignal<"u"&&typeof AbortSignal.timeout=="function"?AbortSignal.timeout(ue):void 0,o=await fetch(r.filePath,{signal:n});if(!o.ok)return p().warn(`Failed to fetch additional file from URL: ${r.filePath}`),null;let d=await(await o.blob()).arrayBuffer();return{fileName:r.fileName,content:new Uint8Array(d),path:r.fileName}}catch(n){return p().error(`Error fetching additional file from URL: ${r.filePath}`,n),null}}))).filter(r=>r!==null),k=async(t,e)=>{let r=ae(t);if(e){let n=Array.isArray(e)?e:[e];r.push(...await le(n))}return r};async function ce(t,e){let{zip:r,strToU8:n}=await Promise.resolve().then(() => _interopRequireWildcard(require("fflate"))),o={};t.forEach(s=>{let a=de(s.path,o);a!==s.path&&p().warn(`Duplicate archive path "${s.path}" \u2014 storing as "${a}".`),o[a]=typeof s.content=="string"?n(s.content):s.content});let i=await new Promise((s,a)=>{r(o,{level:6},(c,m)=>c?a(c):s(m))}),d=new Blob([i],{type:"application/zip"});fe(d,`${e}.zip`)}function de(t,e){let r=a=>Object.prototype.hasOwnProperty.call(e,a);if(!r(t))return t;let n=t.lastIndexOf("/"),o=t.lastIndexOf("."),i=o>n?o:t.length,d=t.slice(0,i),s=t.slice(i);for(let a=2;;a++){let c=`${d}-${a}${s}`;if(!r(c))return c}}function fe(t,e){if(typeof document>"u")throw new f("saveFile requires a browser environment with DOM API access.",u.BROWSER_ONLY,{context:{function:"saveFile",requiredAPI:"document"}});let r=URL.createObjectURL(t),n=document.createElement("a");n.href=r,n.download=e,document.body.appendChild(n),n.click(),n.remove(),setTimeout(()=>URL.revokeObjectURL(r),1e4)}exports.a = pe; exports.b = h; exports.c = u; exports.d = f; exports.e = p; exports.f = D; exports.g = K; exports.h = Ee; exports.i = ve; exports.j = _; exports.k = W; exports.l = ne; exports.m = P; exports.n = C; exports.o = M; exports.p = I; exports.q = se; exports.r = ie;
|
|
4
|
-
//# sourceMappingURL=chunk-DRG5SLIP.cjs.map
|