@selvajs/compute 1.5.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.
- package/LICENSE.md +21 -0
- package/README.md +106 -0
- package/dist/base-dtik4Dlu.d.cts +138 -0
- package/dist/base-dtik4Dlu.d.ts +138 -0
- package/dist/chunk-FRSLCR7G.cjs +2 -0
- package/dist/chunk-FRSLCR7G.cjs.map +1 -0
- package/dist/chunk-IJZNCO5X.cjs +3 -0
- package/dist/chunk-IJZNCO5X.cjs.map +1 -0
- package/dist/chunk-LNIUUPA5.cjs +2 -0
- package/dist/chunk-LNIUUPA5.cjs.map +1 -0
- package/dist/chunk-PZ4HZLFJ.js +2 -0
- package/dist/chunk-PZ4HZLFJ.js.map +1 -0
- package/dist/chunk-VK2TSW7S.js +3 -0
- package/dist/chunk-VK2TSW7S.js.map +1 -0
- package/dist/chunk-WXQGTKU6.js +2 -0
- package/dist/chunk-WXQGTKU6.js.map +1 -0
- package/dist/core.cjs +2 -0
- package/dist/core.cjs.map +1 -0
- package/dist/core.d.cts +140 -0
- package/dist/core.d.ts +140 -0
- package/dist/core.js +2 -0
- package/dist/core.js.map +1 -0
- package/dist/grasshopper.cjs +2 -0
- package/dist/grasshopper.cjs.map +1 -0
- package/dist/grasshopper.d.cts +1014 -0
- package/dist/grasshopper.d.ts +1014 -0
- package/dist/grasshopper.js +2 -0
- package/dist/grasshopper.js.map +1 -0
- package/dist/index.cjs +2 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +6 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -0
- package/dist/schemas-Ct7lU-IH.d.cts +247 -0
- package/dist/schemas-Ct7lU-IH.d.ts +247 -0
- package/dist/types-B24K2LG4.d.cts +85 -0
- package/dist/types-B24K2LG4.d.ts +85 -0
- package/dist/visualization.cjs +2 -0
- package/dist/visualization.cjs.map +1 -0
- package/dist/visualization.d.cts +205 -0
- package/dist/visualization.d.ts +205 -0
- package/dist/visualization.js +2 -0
- package/dist/visualization.js.map +1 -0
- package/package.json +122 -0
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{a as b,b as c,c as d,d as e,e as f,f as g,g as h,h as i,i as j,j as k,k as l,l as m}from"./chunk-WXQGTKU6.js";import"./chunk-PZ4HZLFJ.js";import{d as a}from"./chunk-VK2TSW7S.js";export{d as GrasshopperClient,g as GrasshopperResponseProcessor,a as RhinoComputeError,c as SolveScheduler,m as TreeBuilder,f as downloadFileData,e as extractFilesFromComputeResponse,k as fetchDefinitionIO,l as fetchParsedDefinitionIO,b as hashSolveInput,i as processInput,j as processInputs,h as solveGrasshopperDefinition};
|
|
2
|
+
//# sourceMappingURL=grasshopper.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
package/dist/index.cjs
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunkFRSLCR7Gcjs = require('./chunk-FRSLCR7G.cjs');require('./chunk-LNIUUPA5.cjs');var _chunkIJZNCO5Xcjs = require('./chunk-IJZNCO5X.cjs');exports.ComputeServerStats = _chunkIJZNCO5Xcjs.i; exports.ErrorCodes = _chunkIJZNCO5Xcjs.c; exports.GrasshopperClient = _chunkFRSLCR7Gcjs.c; exports.GrasshopperResponseProcessor = _chunkFRSLCR7Gcjs.f; exports.RhinoComputeError = _chunkIJZNCO5Xcjs.d; exports.SolveScheduler = _chunkFRSLCR7Gcjs.b; exports.TreeBuilder = _chunkFRSLCR7Gcjs.l; exports.camelcaseKeys = _chunkIJZNCO5Xcjs.k; exports.downloadFileData = _chunkFRSLCR7Gcjs.e; exports.enableDebugLogging = _chunkIJZNCO5Xcjs.g; exports.extractFilesFromComputeResponse = _chunkFRSLCR7Gcjs.d; exports.fetchDefinitionIO = _chunkFRSLCR7Gcjs.j; exports.fetchParsedDefinitionIO = _chunkFRSLCR7Gcjs.k; exports.fetchRhinoCompute = _chunkIJZNCO5Xcjs.h; exports.getLogger = _chunkIJZNCO5Xcjs.e; exports.hashSolveInput = _chunkFRSLCR7Gcjs.a; exports.processInput = _chunkFRSLCR7Gcjs.h; exports.processInputs = _chunkFRSLCR7Gcjs.i; exports.setLogger = _chunkIJZNCO5Xcjs.f; exports.solveGrasshopperDefinition = _chunkFRSLCR7Gcjs.g; exports.toCamelCase = _chunkIJZNCO5Xcjs.j;
|
|
2
|
+
//# sourceMappingURL=index.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["d:\\Coding\\selva-compute\\dist\\index.cjs"],"names":[],"mappings":"AAAA,iIAAqH,gCAA6B,wDAAuF,u/BAA8d","file":"D:\\Coding\\selva-compute\\dist\\index.cjs"}
|
package/dist/index.d.cts
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export { ErrorCode, ErrorCodes, Logger, camelcaseKeys, enableDebugLogging, fetchRhinoCompute, getLogger, setLogger, toCamelCase } from './core.cjs';
|
|
2
|
+
export { C as ComputeServerStats, R as RhinoComputeError } from './base-dtik4Dlu.cjs';
|
|
3
|
+
export { C as ComputeConfig, D as DataItem, a as DataTree, b as DataTreeDefault, c as DataTreePath, G as GrasshopperComputeConfig, d as GrasshopperComputeResponse, e as GrasshopperRequestSchema, I as InnerTreeData, f as InputParamSchema, O as OutputParamSchema, R as RetryPolicy, g as RhinoModelUnit } from './schemas-Ct7lU-IH.cjs';
|
|
4
|
+
export { BooleanInputType, CacheOptions, DataTreeValue, DefaultValue, FileBaseInfo, FileData, FileInputType, GeometryInputType, GetValuesOptions, GetValuesResult, GrasshopperClient, GrasshopperParsedIO, GrasshopperParsedIORaw, GrasshopperResponseProcessor, InputParam, NumericInputType, OutputType, ParsedContext, ProcessedFile, SchedulerMode, SolveContext, SolveExecutor, SolveOptions, SolveResult, SolveScheduler, SolveSchedulerOptions, TextInputType, TreeBuilder, ValueListInputType, downloadFileData, extractFilesFromComputeResponse, fetchDefinitionIO, fetchParsedDefinitionIO, hashSolveInput, processInput, processInputs, solveGrasshopperDefinition } from './grasshopper.cjs';
|
|
5
|
+
import 'three';
|
|
6
|
+
import './types-B24K2LG4.cjs';
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export { ErrorCode, ErrorCodes, Logger, camelcaseKeys, enableDebugLogging, fetchRhinoCompute, getLogger, setLogger, toCamelCase } from './core.js';
|
|
2
|
+
export { C as ComputeServerStats, R as RhinoComputeError } from './base-dtik4Dlu.js';
|
|
3
|
+
export { C as ComputeConfig, D as DataItem, a as DataTree, b as DataTreeDefault, c as DataTreePath, G as GrasshopperComputeConfig, d as GrasshopperComputeResponse, e as GrasshopperRequestSchema, I as InnerTreeData, f as InputParamSchema, O as OutputParamSchema, R as RetryPolicy, g as RhinoModelUnit } from './schemas-Ct7lU-IH.js';
|
|
4
|
+
export { BooleanInputType, CacheOptions, DataTreeValue, DefaultValue, FileBaseInfo, FileData, FileInputType, GeometryInputType, GetValuesOptions, GetValuesResult, GrasshopperClient, GrasshopperParsedIO, GrasshopperParsedIORaw, GrasshopperResponseProcessor, InputParam, NumericInputType, OutputType, ParsedContext, ProcessedFile, SchedulerMode, SolveContext, SolveExecutor, SolveOptions, SolveResult, SolveScheduler, SolveSchedulerOptions, TextInputType, TreeBuilder, ValueListInputType, downloadFileData, extractFilesFromComputeResponse, fetchDefinitionIO, fetchParsedDefinitionIO, hashSolveInput, processInput, processInputs, solveGrasshopperDefinition } from './grasshopper.js';
|
|
5
|
+
import 'three';
|
|
6
|
+
import './types-B24K2LG4.js';
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{a as b,b as c,c as d,d as g,e as h,f as i,g as j,h as k,i as l,j as n,k as q,l as s}from"./chunk-WXQGTKU6.js";import"./chunk-PZ4HZLFJ.js";import{c as o,d as r,e,f,g as m,h as p,i as t,j as x,k as a}from"./chunk-VK2TSW7S.js";export{t as ComputeServerStats,o as ErrorCodes,d as GrasshopperClient,i as GrasshopperResponseProcessor,r as RhinoComputeError,c as SolveScheduler,s as TreeBuilder,a as camelcaseKeys,h as downloadFileData,m as enableDebugLogging,g as extractFilesFromComputeResponse,n as fetchDefinitionIO,q as fetchParsedDefinitionIO,p as fetchRhinoCompute,e as getLogger,b as hashSolveInput,k as processInput,l as processInputs,f as setLogger,j as solveGrasshopperDefinition,x as toCamelCase};
|
|
2
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
|
@@ -0,0 +1,247 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Rhino model unit types supported by Rhino.Compute
|
|
3
|
+
*/
|
|
4
|
+
type RhinoModelUnit = 'None' | 'Microns' | 'Millimeters' | 'Centimeters' | 'Meters' | 'Kilometers' | 'Microinches' | 'Mils' | 'Inches' | 'Feet' | 'Miles' | 'CustomUnits' | 'Angstroms' | 'Nanometers' | 'Decimeters' | 'Dekameters' | 'Hectometers' | 'Megameters' | 'Gigameters' | 'Yards' | 'PrinterPoints' | 'PrinterPicas' | 'NauticalMiles' | 'AstronomicalUnits' | 'LightYears' | 'Parsecs' | 'Unset';
|
|
5
|
+
/**
|
|
6
|
+
* Retry policy for transient errors (network, 502, 503, 504, optionally 429).
|
|
7
|
+
*
|
|
8
|
+
* Retries use exponential backoff with jitter, capped at `maxDelayMs`.
|
|
9
|
+
* If the server returns `Retry-After`, that value is honored instead.
|
|
10
|
+
*/
|
|
11
|
+
interface RetryPolicy {
|
|
12
|
+
/** Maximum number of retry attempts after the initial request (default: 0). */
|
|
13
|
+
attempts?: number;
|
|
14
|
+
/** Base delay in milliseconds for exponential backoff (default: 500). */
|
|
15
|
+
baseDelayMs?: number;
|
|
16
|
+
/** Upper bound for backoff delay (default: 30_000). */
|
|
17
|
+
maxDelayMs?: number;
|
|
18
|
+
/** Whether to retry on 429 responses (default: true — honors Retry-After). */
|
|
19
|
+
retryOn429?: boolean;
|
|
20
|
+
}
|
|
21
|
+
interface ComputeConfig {
|
|
22
|
+
/** The base URL of the Rhino Compute server (e.g., http://localhost:6500) */
|
|
23
|
+
serverUrl: string;
|
|
24
|
+
/** Optional API key for authenticating with the server (RhinoComputeKey) */
|
|
25
|
+
apiKey?: string;
|
|
26
|
+
/** Optional Bearer token for authentication (e.g., when behind a proxy or API gateway) */
|
|
27
|
+
authToken?: string;
|
|
28
|
+
/** Enable debug logging to the console */
|
|
29
|
+
debug?: boolean;
|
|
30
|
+
/** Suppress browser security warnings in the console */
|
|
31
|
+
suppressClientSideWarning?: boolean;
|
|
32
|
+
/**
|
|
33
|
+
* Per-request timeout in milliseconds. Set to `0` to disable (useful for long
|
|
34
|
+
* solves where any timeout is the wrong answer). Default: no timeout.
|
|
35
|
+
*
|
|
36
|
+
* Uses `AbortSignal.timeout` so the timer is not throttled when the tab is hidden.
|
|
37
|
+
*/
|
|
38
|
+
timeoutMs?: number;
|
|
39
|
+
/**
|
|
40
|
+
* Retry policy for transient errors. Default: no retries.
|
|
41
|
+
*/
|
|
42
|
+
retry?: RetryPolicy;
|
|
43
|
+
/**
|
|
44
|
+
* Optional caller-supplied AbortSignal. Composes with the internal timeout —
|
|
45
|
+
* whichever fires first wins. Lets callers cancel in-flight requests
|
|
46
|
+
* (e.g. on component unmount or when superseding a stale solve).
|
|
47
|
+
*/
|
|
48
|
+
signal?: AbortSignal;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* Data tree types for Grasshopper parameter structures
|
|
53
|
+
*/
|
|
54
|
+
/**
|
|
55
|
+
* Grasshopper-style data tree branch path
|
|
56
|
+
* @example "{0}", "{0;0}", "{0;1;2}"
|
|
57
|
+
*/
|
|
58
|
+
type DataTreePath = `{${string}}`;
|
|
59
|
+
/**
|
|
60
|
+
* Represents a data item in a data tree
|
|
61
|
+
*/
|
|
62
|
+
interface DataItem {
|
|
63
|
+
/** The type of the data, inferred from the Grasshopper GOO class */
|
|
64
|
+
type: string;
|
|
65
|
+
/** The actual returned data as a string that may need to be parsed */
|
|
66
|
+
data: string;
|
|
67
|
+
/** The grasshopper refrence id of the output */
|
|
68
|
+
id: string;
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* Grasshopper-style data tree for input defaults
|
|
72
|
+
* @example
|
|
73
|
+
* ```typescript
|
|
74
|
+
* const numericTree: DataTreeDefault<number> = {
|
|
75
|
+
* "{0}": [1, 2, 3],
|
|
76
|
+
* "{0;0}": [4, 5],
|
|
77
|
+
* "{1}": [6]
|
|
78
|
+
* };
|
|
79
|
+
* ```
|
|
80
|
+
*/
|
|
81
|
+
type DataTreeDefault<T = any> = {
|
|
82
|
+
[K in DataTreePath]?: T[];
|
|
83
|
+
};
|
|
84
|
+
/**
|
|
85
|
+
* Data structure for InnerTreeData matching Rhino Compute responses
|
|
86
|
+
*/
|
|
87
|
+
type InnerTreeData = {
|
|
88
|
+
[path in DataTreePath]: DataItem[];
|
|
89
|
+
};
|
|
90
|
+
/**
|
|
91
|
+
* Tree with parameter metadata (used in compute responses)
|
|
92
|
+
*/
|
|
93
|
+
interface DataTree {
|
|
94
|
+
InnerTree: InnerTreeData;
|
|
95
|
+
ParamName: string;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
/**
|
|
99
|
+
* API request/response schemas for Grasshopper compute operations
|
|
100
|
+
*
|
|
101
|
+
* @important These types mirror the Rhino.Compute API schema (Resthopper.IO).
|
|
102
|
+
* When Rhino.Compute is updated or types change, these definitions must be
|
|
103
|
+
* adjusted to maintain compatibility with the Compute server API.
|
|
104
|
+
*
|
|
105
|
+
* Reference: https://github.com/mcneel/rhino-compute/tree/main/src/compute.sln/Resthopper.IO
|
|
106
|
+
*/
|
|
107
|
+
|
|
108
|
+
/**
|
|
109
|
+
* Base Grasshopper schema properties shared by config, args, and response
|
|
110
|
+
*/
|
|
111
|
+
interface GrasshopperBaseSchema {
|
|
112
|
+
/** Absolute tolerance used in computation */
|
|
113
|
+
absolutetolerance?: number | null;
|
|
114
|
+
/** Angular tolerance used in computation */
|
|
115
|
+
angletolerance?: number | null;
|
|
116
|
+
/** Model units used */
|
|
117
|
+
modelunits?: RhinoModelUnit | null;
|
|
118
|
+
/** Data version (7 or 8) */
|
|
119
|
+
dataversion?: 7 | 8 | null;
|
|
120
|
+
/** Whether to use cached solution */
|
|
121
|
+
cachesolve?: boolean | null;
|
|
122
|
+
}
|
|
123
|
+
/**
|
|
124
|
+
* Definition source (used in args and response)
|
|
125
|
+
*/
|
|
126
|
+
interface GrasshopperDefinitionSource {
|
|
127
|
+
/** Base64 encoded algorithm (if embedded) */
|
|
128
|
+
algo?: string | null;
|
|
129
|
+
/** URL pointer to definition file */
|
|
130
|
+
pointer?: string | null;
|
|
131
|
+
/** Filename of the definition */
|
|
132
|
+
filename?: string | null;
|
|
133
|
+
}
|
|
134
|
+
/**
|
|
135
|
+
* Configuration for Grasshopper compute operations
|
|
136
|
+
* Combines server config with optional Grasshopper-specific computation settings
|
|
137
|
+
*
|
|
138
|
+
* Note: The definition source (pointer/algo) is NOT part of config.
|
|
139
|
+
* Instead, pass the definition directly to methods like solve(), getIO(), etc.
|
|
140
|
+
*/
|
|
141
|
+
interface GrasshopperComputeConfig extends ComputeConfig {
|
|
142
|
+
/** Absolute tolerance used in computation */
|
|
143
|
+
absolutetolerance?: number | null;
|
|
144
|
+
/** Angular tolerance used in computation */
|
|
145
|
+
angletolerance?: number | null;
|
|
146
|
+
/** Model units used */
|
|
147
|
+
modelunits?: RhinoModelUnit | null;
|
|
148
|
+
/** Data version (7 or 8) */
|
|
149
|
+
dataversion?: 7 | 8 | null;
|
|
150
|
+
/** Whether to use cached solution */
|
|
151
|
+
cachesolve?: boolean | null;
|
|
152
|
+
}
|
|
153
|
+
/**
|
|
154
|
+
* Raw I/O response schema from API (PascalCase)
|
|
155
|
+
*
|
|
156
|
+
* This is the direct response format from the Rhino Compute server API.
|
|
157
|
+
* All property names are in PascalCase, which is typical for .NET APIs.
|
|
158
|
+
* This raw response is converted to camelCase by the camelcaseKeys() function
|
|
159
|
+
* in the fetchDefinitionIO() method.
|
|
160
|
+
*/
|
|
161
|
+
interface IoResponseSchema {
|
|
162
|
+
description: string;
|
|
163
|
+
filename: string;
|
|
164
|
+
cachekey: string;
|
|
165
|
+
inputnames: string[];
|
|
166
|
+
outputnames: string[];
|
|
167
|
+
icon: string | null;
|
|
168
|
+
inputs: InputParamSchema[];
|
|
169
|
+
outputs: OutputParamSchema[];
|
|
170
|
+
warnings: any[];
|
|
171
|
+
errors: any[];
|
|
172
|
+
}
|
|
173
|
+
/**
|
|
174
|
+
* Arguments sent to Grasshopper compute endpoint
|
|
175
|
+
* Includes config options + definition source + input values
|
|
176
|
+
*/
|
|
177
|
+
interface GrasshopperRequestSchema extends GrasshopperBaseSchema, GrasshopperDefinitionSource {
|
|
178
|
+
/** Input values organized by parameter */
|
|
179
|
+
values?: DataTree[];
|
|
180
|
+
}
|
|
181
|
+
/**
|
|
182
|
+
* Response from Grasshopper compute server
|
|
183
|
+
* Includes all schema fields + computed results
|
|
184
|
+
*/
|
|
185
|
+
interface GrasshopperComputeResponse extends GrasshopperBaseSchema, GrasshopperDefinitionSource {
|
|
186
|
+
/** Whether cache was used (always present in response) */
|
|
187
|
+
cachesolve: boolean;
|
|
188
|
+
/** Model units (always present in response) */
|
|
189
|
+
modelunits: RhinoModelUnit;
|
|
190
|
+
/** Base64 encoded algorithm (always present in response) */
|
|
191
|
+
algo: string;
|
|
192
|
+
/** Filename of the definition (always present in response) */
|
|
193
|
+
filename: string | null;
|
|
194
|
+
/** Data version */
|
|
195
|
+
dataversion: 7 | 8;
|
|
196
|
+
/** Recursion level used */
|
|
197
|
+
recursionlevel?: number;
|
|
198
|
+
/** Output values organized by parameter */
|
|
199
|
+
values: DataTree[];
|
|
200
|
+
/** Computation errors */
|
|
201
|
+
errors?: string[];
|
|
202
|
+
/** Computation warnings */
|
|
203
|
+
warnings?: string[];
|
|
204
|
+
}
|
|
205
|
+
/**
|
|
206
|
+
* Output parameter
|
|
207
|
+
*/
|
|
208
|
+
interface OutputParamSchema {
|
|
209
|
+
name: string;
|
|
210
|
+
nickname: string | null;
|
|
211
|
+
paramType: string;
|
|
212
|
+
/**
|
|
213
|
+
* Grasshopper parameter instance GUID
|
|
214
|
+
*/
|
|
215
|
+
id: string;
|
|
216
|
+
}
|
|
217
|
+
/**
|
|
218
|
+
* Input parameter
|
|
219
|
+
*/
|
|
220
|
+
interface InputParamSchema {
|
|
221
|
+
/**
|
|
222
|
+
* Grasshopper parameter instance GUID
|
|
223
|
+
*/
|
|
224
|
+
id: string;
|
|
225
|
+
name: string;
|
|
226
|
+
nickname: string | null;
|
|
227
|
+
description: string;
|
|
228
|
+
paramType: string;
|
|
229
|
+
treeAccess: boolean;
|
|
230
|
+
minimum: number | null;
|
|
231
|
+
maximum: number | null;
|
|
232
|
+
atLeast: number;
|
|
233
|
+
atMost: number;
|
|
234
|
+
stepSize?: number;
|
|
235
|
+
default: any;
|
|
236
|
+
/**
|
|
237
|
+
* Key-value pairs for dropdown options
|
|
238
|
+
*/
|
|
239
|
+
values?: Record<string, string>;
|
|
240
|
+
/**
|
|
241
|
+
* Accepted file formats for File input
|
|
242
|
+
*/
|
|
243
|
+
acceptedFormats?: string[];
|
|
244
|
+
groupName?: string | null;
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
export type { ComputeConfig as C, DataItem as D, GrasshopperComputeConfig as G, InnerTreeData as I, OutputParamSchema as O, RetryPolicy as R, DataTree as a, DataTreeDefault as b, DataTreePath as c, GrasshopperComputeResponse as d, GrasshopperRequestSchema as e, InputParamSchema as f, RhinoModelUnit as g, IoResponseSchema as h };
|
|
@@ -0,0 +1,247 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Rhino model unit types supported by Rhino.Compute
|
|
3
|
+
*/
|
|
4
|
+
type RhinoModelUnit = 'None' | 'Microns' | 'Millimeters' | 'Centimeters' | 'Meters' | 'Kilometers' | 'Microinches' | 'Mils' | 'Inches' | 'Feet' | 'Miles' | 'CustomUnits' | 'Angstroms' | 'Nanometers' | 'Decimeters' | 'Dekameters' | 'Hectometers' | 'Megameters' | 'Gigameters' | 'Yards' | 'PrinterPoints' | 'PrinterPicas' | 'NauticalMiles' | 'AstronomicalUnits' | 'LightYears' | 'Parsecs' | 'Unset';
|
|
5
|
+
/**
|
|
6
|
+
* Retry policy for transient errors (network, 502, 503, 504, optionally 429).
|
|
7
|
+
*
|
|
8
|
+
* Retries use exponential backoff with jitter, capped at `maxDelayMs`.
|
|
9
|
+
* If the server returns `Retry-After`, that value is honored instead.
|
|
10
|
+
*/
|
|
11
|
+
interface RetryPolicy {
|
|
12
|
+
/** Maximum number of retry attempts after the initial request (default: 0). */
|
|
13
|
+
attempts?: number;
|
|
14
|
+
/** Base delay in milliseconds for exponential backoff (default: 500). */
|
|
15
|
+
baseDelayMs?: number;
|
|
16
|
+
/** Upper bound for backoff delay (default: 30_000). */
|
|
17
|
+
maxDelayMs?: number;
|
|
18
|
+
/** Whether to retry on 429 responses (default: true — honors Retry-After). */
|
|
19
|
+
retryOn429?: boolean;
|
|
20
|
+
}
|
|
21
|
+
interface ComputeConfig {
|
|
22
|
+
/** The base URL of the Rhino Compute server (e.g., http://localhost:6500) */
|
|
23
|
+
serverUrl: string;
|
|
24
|
+
/** Optional API key for authenticating with the server (RhinoComputeKey) */
|
|
25
|
+
apiKey?: string;
|
|
26
|
+
/** Optional Bearer token for authentication (e.g., when behind a proxy or API gateway) */
|
|
27
|
+
authToken?: string;
|
|
28
|
+
/** Enable debug logging to the console */
|
|
29
|
+
debug?: boolean;
|
|
30
|
+
/** Suppress browser security warnings in the console */
|
|
31
|
+
suppressClientSideWarning?: boolean;
|
|
32
|
+
/**
|
|
33
|
+
* Per-request timeout in milliseconds. Set to `0` to disable (useful for long
|
|
34
|
+
* solves where any timeout is the wrong answer). Default: no timeout.
|
|
35
|
+
*
|
|
36
|
+
* Uses `AbortSignal.timeout` so the timer is not throttled when the tab is hidden.
|
|
37
|
+
*/
|
|
38
|
+
timeoutMs?: number;
|
|
39
|
+
/**
|
|
40
|
+
* Retry policy for transient errors. Default: no retries.
|
|
41
|
+
*/
|
|
42
|
+
retry?: RetryPolicy;
|
|
43
|
+
/**
|
|
44
|
+
* Optional caller-supplied AbortSignal. Composes with the internal timeout —
|
|
45
|
+
* whichever fires first wins. Lets callers cancel in-flight requests
|
|
46
|
+
* (e.g. on component unmount or when superseding a stale solve).
|
|
47
|
+
*/
|
|
48
|
+
signal?: AbortSignal;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* Data tree types for Grasshopper parameter structures
|
|
53
|
+
*/
|
|
54
|
+
/**
|
|
55
|
+
* Grasshopper-style data tree branch path
|
|
56
|
+
* @example "{0}", "{0;0}", "{0;1;2}"
|
|
57
|
+
*/
|
|
58
|
+
type DataTreePath = `{${string}}`;
|
|
59
|
+
/**
|
|
60
|
+
* Represents a data item in a data tree
|
|
61
|
+
*/
|
|
62
|
+
interface DataItem {
|
|
63
|
+
/** The type of the data, inferred from the Grasshopper GOO class */
|
|
64
|
+
type: string;
|
|
65
|
+
/** The actual returned data as a string that may need to be parsed */
|
|
66
|
+
data: string;
|
|
67
|
+
/** The grasshopper refrence id of the output */
|
|
68
|
+
id: string;
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* Grasshopper-style data tree for input defaults
|
|
72
|
+
* @example
|
|
73
|
+
* ```typescript
|
|
74
|
+
* const numericTree: DataTreeDefault<number> = {
|
|
75
|
+
* "{0}": [1, 2, 3],
|
|
76
|
+
* "{0;0}": [4, 5],
|
|
77
|
+
* "{1}": [6]
|
|
78
|
+
* };
|
|
79
|
+
* ```
|
|
80
|
+
*/
|
|
81
|
+
type DataTreeDefault<T = any> = {
|
|
82
|
+
[K in DataTreePath]?: T[];
|
|
83
|
+
};
|
|
84
|
+
/**
|
|
85
|
+
* Data structure for InnerTreeData matching Rhino Compute responses
|
|
86
|
+
*/
|
|
87
|
+
type InnerTreeData = {
|
|
88
|
+
[path in DataTreePath]: DataItem[];
|
|
89
|
+
};
|
|
90
|
+
/**
|
|
91
|
+
* Tree with parameter metadata (used in compute responses)
|
|
92
|
+
*/
|
|
93
|
+
interface DataTree {
|
|
94
|
+
InnerTree: InnerTreeData;
|
|
95
|
+
ParamName: string;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
/**
|
|
99
|
+
* API request/response schemas for Grasshopper compute operations
|
|
100
|
+
*
|
|
101
|
+
* @important These types mirror the Rhino.Compute API schema (Resthopper.IO).
|
|
102
|
+
* When Rhino.Compute is updated or types change, these definitions must be
|
|
103
|
+
* adjusted to maintain compatibility with the Compute server API.
|
|
104
|
+
*
|
|
105
|
+
* Reference: https://github.com/mcneel/rhino-compute/tree/main/src/compute.sln/Resthopper.IO
|
|
106
|
+
*/
|
|
107
|
+
|
|
108
|
+
/**
|
|
109
|
+
* Base Grasshopper schema properties shared by config, args, and response
|
|
110
|
+
*/
|
|
111
|
+
interface GrasshopperBaseSchema {
|
|
112
|
+
/** Absolute tolerance used in computation */
|
|
113
|
+
absolutetolerance?: number | null;
|
|
114
|
+
/** Angular tolerance used in computation */
|
|
115
|
+
angletolerance?: number | null;
|
|
116
|
+
/** Model units used */
|
|
117
|
+
modelunits?: RhinoModelUnit | null;
|
|
118
|
+
/** Data version (7 or 8) */
|
|
119
|
+
dataversion?: 7 | 8 | null;
|
|
120
|
+
/** Whether to use cached solution */
|
|
121
|
+
cachesolve?: boolean | null;
|
|
122
|
+
}
|
|
123
|
+
/**
|
|
124
|
+
* Definition source (used in args and response)
|
|
125
|
+
*/
|
|
126
|
+
interface GrasshopperDefinitionSource {
|
|
127
|
+
/** Base64 encoded algorithm (if embedded) */
|
|
128
|
+
algo?: string | null;
|
|
129
|
+
/** URL pointer to definition file */
|
|
130
|
+
pointer?: string | null;
|
|
131
|
+
/** Filename of the definition */
|
|
132
|
+
filename?: string | null;
|
|
133
|
+
}
|
|
134
|
+
/**
|
|
135
|
+
* Configuration for Grasshopper compute operations
|
|
136
|
+
* Combines server config with optional Grasshopper-specific computation settings
|
|
137
|
+
*
|
|
138
|
+
* Note: The definition source (pointer/algo) is NOT part of config.
|
|
139
|
+
* Instead, pass the definition directly to methods like solve(), getIO(), etc.
|
|
140
|
+
*/
|
|
141
|
+
interface GrasshopperComputeConfig extends ComputeConfig {
|
|
142
|
+
/** Absolute tolerance used in computation */
|
|
143
|
+
absolutetolerance?: number | null;
|
|
144
|
+
/** Angular tolerance used in computation */
|
|
145
|
+
angletolerance?: number | null;
|
|
146
|
+
/** Model units used */
|
|
147
|
+
modelunits?: RhinoModelUnit | null;
|
|
148
|
+
/** Data version (7 or 8) */
|
|
149
|
+
dataversion?: 7 | 8 | null;
|
|
150
|
+
/** Whether to use cached solution */
|
|
151
|
+
cachesolve?: boolean | null;
|
|
152
|
+
}
|
|
153
|
+
/**
|
|
154
|
+
* Raw I/O response schema from API (PascalCase)
|
|
155
|
+
*
|
|
156
|
+
* This is the direct response format from the Rhino Compute server API.
|
|
157
|
+
* All property names are in PascalCase, which is typical for .NET APIs.
|
|
158
|
+
* This raw response is converted to camelCase by the camelcaseKeys() function
|
|
159
|
+
* in the fetchDefinitionIO() method.
|
|
160
|
+
*/
|
|
161
|
+
interface IoResponseSchema {
|
|
162
|
+
description: string;
|
|
163
|
+
filename: string;
|
|
164
|
+
cachekey: string;
|
|
165
|
+
inputnames: string[];
|
|
166
|
+
outputnames: string[];
|
|
167
|
+
icon: string | null;
|
|
168
|
+
inputs: InputParamSchema[];
|
|
169
|
+
outputs: OutputParamSchema[];
|
|
170
|
+
warnings: any[];
|
|
171
|
+
errors: any[];
|
|
172
|
+
}
|
|
173
|
+
/**
|
|
174
|
+
* Arguments sent to Grasshopper compute endpoint
|
|
175
|
+
* Includes config options + definition source + input values
|
|
176
|
+
*/
|
|
177
|
+
interface GrasshopperRequestSchema extends GrasshopperBaseSchema, GrasshopperDefinitionSource {
|
|
178
|
+
/** Input values organized by parameter */
|
|
179
|
+
values?: DataTree[];
|
|
180
|
+
}
|
|
181
|
+
/**
|
|
182
|
+
* Response from Grasshopper compute server
|
|
183
|
+
* Includes all schema fields + computed results
|
|
184
|
+
*/
|
|
185
|
+
interface GrasshopperComputeResponse extends GrasshopperBaseSchema, GrasshopperDefinitionSource {
|
|
186
|
+
/** Whether cache was used (always present in response) */
|
|
187
|
+
cachesolve: boolean;
|
|
188
|
+
/** Model units (always present in response) */
|
|
189
|
+
modelunits: RhinoModelUnit;
|
|
190
|
+
/** Base64 encoded algorithm (always present in response) */
|
|
191
|
+
algo: string;
|
|
192
|
+
/** Filename of the definition (always present in response) */
|
|
193
|
+
filename: string | null;
|
|
194
|
+
/** Data version */
|
|
195
|
+
dataversion: 7 | 8;
|
|
196
|
+
/** Recursion level used */
|
|
197
|
+
recursionlevel?: number;
|
|
198
|
+
/** Output values organized by parameter */
|
|
199
|
+
values: DataTree[];
|
|
200
|
+
/** Computation errors */
|
|
201
|
+
errors?: string[];
|
|
202
|
+
/** Computation warnings */
|
|
203
|
+
warnings?: string[];
|
|
204
|
+
}
|
|
205
|
+
/**
|
|
206
|
+
* Output parameter
|
|
207
|
+
*/
|
|
208
|
+
interface OutputParamSchema {
|
|
209
|
+
name: string;
|
|
210
|
+
nickname: string | null;
|
|
211
|
+
paramType: string;
|
|
212
|
+
/**
|
|
213
|
+
* Grasshopper parameter instance GUID
|
|
214
|
+
*/
|
|
215
|
+
id: string;
|
|
216
|
+
}
|
|
217
|
+
/**
|
|
218
|
+
* Input parameter
|
|
219
|
+
*/
|
|
220
|
+
interface InputParamSchema {
|
|
221
|
+
/**
|
|
222
|
+
* Grasshopper parameter instance GUID
|
|
223
|
+
*/
|
|
224
|
+
id: string;
|
|
225
|
+
name: string;
|
|
226
|
+
nickname: string | null;
|
|
227
|
+
description: string;
|
|
228
|
+
paramType: string;
|
|
229
|
+
treeAccess: boolean;
|
|
230
|
+
minimum: number | null;
|
|
231
|
+
maximum: number | null;
|
|
232
|
+
atLeast: number;
|
|
233
|
+
atMost: number;
|
|
234
|
+
stepSize?: number;
|
|
235
|
+
default: any;
|
|
236
|
+
/**
|
|
237
|
+
* Key-value pairs for dropdown options
|
|
238
|
+
*/
|
|
239
|
+
values?: Record<string, string>;
|
|
240
|
+
/**
|
|
241
|
+
* Accepted file formats for File input
|
|
242
|
+
*/
|
|
243
|
+
acceptedFormats?: string[];
|
|
244
|
+
groupName?: string | null;
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
export type { ComputeConfig as C, DataItem as D, GrasshopperComputeConfig as G, InnerTreeData as I, OutputParamSchema as O, RetryPolicy as R, DataTree as a, DataTreeDefault as b, DataTreePath as c, GrasshopperComputeResponse as d, GrasshopperRequestSchema as e, InputParamSchema as f, RhinoModelUnit as g, IoResponseSchema as h };
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Material properties for Three.js rendering.
|
|
3
|
+
*/
|
|
4
|
+
interface SerializableMaterial {
|
|
5
|
+
color: string;
|
|
6
|
+
metalness: number;
|
|
7
|
+
roughness: number;
|
|
8
|
+
opacity: number;
|
|
9
|
+
transparent: boolean;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Metadata for a single mesh within a batch.
|
|
13
|
+
*/
|
|
14
|
+
interface MeshMetadata {
|
|
15
|
+
name: string;
|
|
16
|
+
/** Layer path for grouping in the scene manager (e.g. 'Structure/Walls') */
|
|
17
|
+
layer: string;
|
|
18
|
+
/** Original index in the GH input tree before material grouping. Combined with
|
|
19
|
+
* MeshBatch.sourceComponentId to uniquely identify the GH source geometry. */
|
|
20
|
+
originalIndex: number;
|
|
21
|
+
vertexCount: number;
|
|
22
|
+
faceCount: number;
|
|
23
|
+
/** Offset in the combined vertex array (in number of floats) */
|
|
24
|
+
vertexOffset: number;
|
|
25
|
+
/** Offset in the combined face index array (in number of integers) */
|
|
26
|
+
faceOffset: number;
|
|
27
|
+
/** Arbitrary key-value pairs from the GH Metadata input */
|
|
28
|
+
metadata?: Record<string, string>;
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* A group of meshes sharing the same material.
|
|
32
|
+
*/
|
|
33
|
+
interface MaterialGroup {
|
|
34
|
+
/** Reference to the material ID in the materials array */
|
|
35
|
+
materialId: number;
|
|
36
|
+
/** Individual meshes in this group */
|
|
37
|
+
meshes: MeshMetadata[];
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Batched mesh data optimized for Three.js rendering.
|
|
41
|
+
*/
|
|
42
|
+
interface MeshBatch {
|
|
43
|
+
/** Array of unique materials */
|
|
44
|
+
materials: SerializableMaterial[];
|
|
45
|
+
/** Groups of meshes organized by material */
|
|
46
|
+
groups: MaterialGroup[];
|
|
47
|
+
/** Compressed binary data containing all vertices and faces */
|
|
48
|
+
compressedData: string;
|
|
49
|
+
/** InstanceGuid of the WebDisplay GH component that produced this batch.
|
|
50
|
+
* Combined with MeshMetadata.originalIndex to backtrack any mesh to its GH source. */
|
|
51
|
+
sourceComponentId?: string;
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Decompressed mesh data.
|
|
55
|
+
*/
|
|
56
|
+
interface DecompressedMeshData {
|
|
57
|
+
vertices: Float32Array;
|
|
58
|
+
faces: Uint32Array;
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Options for parsing mesh batch data.
|
|
62
|
+
*/
|
|
63
|
+
interface MeshBatchParsingOptions {
|
|
64
|
+
/** Merge meshes with same material into single geometry (better performance). Defaults to true. */
|
|
65
|
+
mergeByMaterial?: boolean;
|
|
66
|
+
/** Apply coordinate system transformations (Rhino Z-up to Three.js Y-up). Defaults to true. */
|
|
67
|
+
applyTransforms?: boolean;
|
|
68
|
+
/** Enable performance monitoring in console. Defaults to false. */
|
|
69
|
+
debug?: boolean;
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* Options for extracting and processing meshes from compute responses.
|
|
73
|
+
*/
|
|
74
|
+
interface MeshExtractionOptions {
|
|
75
|
+
/** Configuration for parsing mesh batches. */
|
|
76
|
+
parsing?: MeshBatchParsingOptions;
|
|
77
|
+
/** Apply scaling based on model units. Defaults to true. */
|
|
78
|
+
allowScaling?: boolean;
|
|
79
|
+
/** Apply automatic ground offset positioning (Z=0). Defaults to true. */
|
|
80
|
+
allowAutoPosition?: boolean;
|
|
81
|
+
/** Enable verbose logging. Defaults to false. */
|
|
82
|
+
debug?: boolean;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
export type { DecompressedMeshData as D, MeshExtractionOptions as M, SerializableMaterial as S, MeshBatch as a, MaterialGroup as b, MeshBatchParsingOptions as c, MeshMetadata as d };
|