@selvajs/compute 3.1.1 → 4.0.0-beta.1
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/README.md +4 -13
- package/dist/chunk-BCVDB6AE.js +2 -0
- package/dist/chunk-BCVDB6AE.js.map +1 -0
- package/dist/chunk-BVMGO7IG.cjs +2 -0
- package/dist/chunk-BVMGO7IG.cjs.map +1 -0
- package/dist/chunk-LLUNR66G.cjs +4 -0
- package/dist/chunk-LLUNR66G.cjs.map +1 -0
- package/dist/chunk-XT3XWDDV.js +4 -0
- package/dist/chunk-XT3XWDDV.js.map +1 -0
- package/dist/core.cjs +1 -1
- package/dist/core.cjs.map +1 -1
- package/dist/core.d.cts +13 -4
- package/dist/core.d.ts +13 -4
- package/dist/core.js +1 -1
- package/dist/grasshopper.cjs +1 -1
- package/dist/grasshopper.cjs.map +1 -1
- package/dist/grasshopper.d.cts +416 -50
- package/dist/grasshopper.d.ts +416 -50
- package/dist/grasshopper.js +1 -1
- package/dist/{handle-files-BISo_wob.d.cts → handle-files-DcA24IkS.d.cts} +45 -1
- package/dist/{handle-files-BISo_wob.d.ts → handle-files-DcA24IkS.d.ts} +45 -1
- package/dist/index.cjs +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +3 -7
- package/dist/index.d.ts +3 -7
- package/dist/index.js +1 -1
- package/package.json +8 -29
- package/dist/chunk-FQKQISPG.cjs +0 -2
- package/dist/chunk-FQKQISPG.cjs.map +0 -1
- package/dist/chunk-H3FZW6OX.cjs +0 -4
- package/dist/chunk-H3FZW6OX.cjs.map +0 -1
- package/dist/chunk-N2WCSETE.js +0 -120
- package/dist/chunk-N2WCSETE.js.map +0 -1
- package/dist/chunk-RFE763NG.cjs +0 -120
- package/dist/chunk-RFE763NG.cjs.map +0 -1
- package/dist/chunk-S3VUIIRE.js +0 -2
- package/dist/chunk-S3VUIIRE.js.map +0 -1
- package/dist/chunk-Y3M7P3BW.js +0 -4
- package/dist/chunk-Y3M7P3BW.js.map +0 -1
- package/dist/types-4FMvnx2j.d.ts +0 -556
- package/dist/types-BGhtYxZ-.d.cts +0 -45
- package/dist/types-BGhtYxZ-.d.ts +0 -45
- package/dist/types-BpOl6U02.d.cts +0 -556
- package/dist/visualization-E6BTQZCA.cjs +0 -2
- package/dist/visualization-E6BTQZCA.cjs.map +0 -1
- package/dist/visualization-HDBKPJGQ.js +0 -2
- package/dist/visualization-HDBKPJGQ.js.map +0 -1
- package/dist/visualization.cjs +0 -2
- package/dist/visualization.cjs.map +0 -1
- package/dist/visualization.d.cts +0 -1093
- package/dist/visualization.d.ts +0 -1093
- package/dist/visualization.js +0 -2
- package/dist/visualization.js.map +0 -1
package/dist/grasshopper.d.cts
CHANGED
|
@@ -1,11 +1,335 @@
|
|
|
1
|
-
import { R as RhinoComputeError,
|
|
2
|
-
export {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
1
|
+
import { C as ComputeConfig, e as RhinoModelUnit, R as RetryPolicy, d as RhinoComputeError, a as ComputeServerStats, F as FileBaseInfo } from './handle-files-DcA24IkS.cjs';
|
|
2
|
+
export { c as FileData, P as ProcessedFile, f as downloadFileData, g as extractFilesFromComputeResponse } from './handle-files-DcA24IkS.cjs';
|
|
3
|
+
|
|
4
|
+
type DataTreePath = `{${string}}`;
|
|
5
|
+
interface DataItem {
|
|
6
|
+
type: string;
|
|
7
|
+
data: string;
|
|
8
|
+
id: string;
|
|
9
|
+
}
|
|
10
|
+
type DataTreeDefault<T = any> = {
|
|
11
|
+
[K in DataTreePath]?: T[];
|
|
12
|
+
};
|
|
13
|
+
type InnerTreeData = {
|
|
14
|
+
[path in DataTreePath]: DataItem[];
|
|
15
|
+
};
|
|
16
|
+
/**
|
|
17
|
+
* Tree with parameter metadata (used in compute requests and responses).
|
|
18
|
+
*
|
|
19
|
+
* Field casing varies by server branch: stock mcneel compute (8.x/9.x)
|
|
20
|
+
* serializes `Resthopper.IO.DataTree` in PascalCase (`ParamName`/`InnerTree`
|
|
21
|
+
* — the C# class carries no `[JsonProperty]` attributes), while
|
|
22
|
+
* camelCase-serializing forks return `paramName`/`innerTree` instead. This
|
|
23
|
+
* client always *sends* PascalCase (see `DataTree.toCompute()` in
|
|
24
|
+
* `data-tree.ts`), so the PascalCase fields remain the canonical/required
|
|
25
|
+
* shape; the optional camelCase fields exist so responses from camelCase
|
|
26
|
+
* forks are representable without casts. Code that must read trees across
|
|
27
|
+
* both server families should use `readField`/`hasField`
|
|
28
|
+
* (`@/core/utils/read-field`, case-insensitive) rather than direct property
|
|
29
|
+
* access — `warnOnEmptyInnerTrees` in `solve.ts` is the reference example.
|
|
30
|
+
*/
|
|
31
|
+
interface DataTree {
|
|
32
|
+
/** PascalCase — stock mcneel servers, and the request shape this client sends. */
|
|
33
|
+
InnerTree: InnerTreeData;
|
|
34
|
+
/** PascalCase — stock mcneel servers, and the request shape this client sends. */
|
|
35
|
+
ParamName: string;
|
|
36
|
+
/** camelCase — sent instead of `InnerTree` by camelCase server forks. */
|
|
37
|
+
innerTree?: InnerTreeData;
|
|
38
|
+
/** camelCase — sent instead of `ParamName` by camelCase server forks. */
|
|
39
|
+
paramName?: string;
|
|
40
|
+
}
|
|
41
|
+
type OutputType = 'System.String' | 'System.Double' | 'System.Int32' | 'System.Boolean' | 'Rhino.Geometry.Point3d' | 'Rhino.Geometry.Line' | 'Rhino.Geometry.Circle' | 'Rhino.Geometry.Arc' | 'Rhino.Geometry.NurbsCurve' | 'Rhino.Geometry.Brep' | 'Rhino.Geometry.Mesh' | 'Rhino.Geometry.Vector3d' | 'Rhino.Geometry.Plane' | 'Rhino.Geometry.Box' | (string & {});
|
|
42
|
+
/**
|
|
43
|
+
* Union type for all possible default value types
|
|
44
|
+
*/
|
|
45
|
+
type DefaultValue<T> = T | T[] | DataTreeDefault<T> | undefined | null;
|
|
46
|
+
/**
|
|
47
|
+
* Base properties common to all processed input types.
|
|
48
|
+
* Note: `groupName` and `id` require the custom Rhino Compute branch.
|
|
49
|
+
*/
|
|
50
|
+
interface BaseInputType {
|
|
51
|
+
description: string;
|
|
52
|
+
name: string;
|
|
53
|
+
nickname: string | null;
|
|
54
|
+
treeAccess: boolean;
|
|
55
|
+
/**
|
|
56
|
+
* Name of the group this parameter belongs to.
|
|
57
|
+
* @requires Custom branch of compute.rhino3d
|
|
58
|
+
*/
|
|
59
|
+
groupName?: string;
|
|
60
|
+
/**
|
|
61
|
+
* Unique identifier for the parameter.
|
|
62
|
+
* @requires Custom branch of compute.rhino3d
|
|
63
|
+
*/
|
|
64
|
+
id?: string;
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* Numeric input type (Number or Integer)
|
|
68
|
+
*/
|
|
69
|
+
interface NumericInputType extends BaseInputType {
|
|
70
|
+
paramType: 'Number' | 'Integer';
|
|
71
|
+
minimum?: number | null;
|
|
72
|
+
maximum?: number | null;
|
|
73
|
+
atLeast?: number | null;
|
|
74
|
+
atMost?: number | null;
|
|
75
|
+
stepSize?: number | null;
|
|
76
|
+
default: DefaultValue<number>;
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* Text input type
|
|
80
|
+
*/
|
|
81
|
+
interface TextInputType extends BaseInputType {
|
|
82
|
+
paramType: 'Text';
|
|
83
|
+
default: DefaultValue<string>;
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* Boolean input type
|
|
87
|
+
*/
|
|
88
|
+
interface BooleanInputType extends BaseInputType {
|
|
89
|
+
paramType: 'Boolean';
|
|
90
|
+
default: DefaultValue<boolean>;
|
|
91
|
+
}
|
|
92
|
+
/**
|
|
93
|
+
* Geometry input type (generic geometry)
|
|
94
|
+
*/
|
|
95
|
+
interface GeometryInputType extends BaseInputType {
|
|
96
|
+
paramType: 'Geometry';
|
|
97
|
+
default: DefaultValue<object | string>;
|
|
98
|
+
}
|
|
99
|
+
/**
|
|
100
|
+
* ValueList input type (dropdown/select)
|
|
101
|
+
*/
|
|
102
|
+
interface ValueListInputType extends BaseInputType {
|
|
103
|
+
paramType: 'ValueList';
|
|
104
|
+
values: Record<string, string>;
|
|
105
|
+
default?: string;
|
|
106
|
+
}
|
|
107
|
+
/**
|
|
108
|
+
* File input type
|
|
109
|
+
*/
|
|
110
|
+
interface FileInputType extends BaseInputType {
|
|
111
|
+
paramType: 'File';
|
|
112
|
+
acceptedFormats?: string[];
|
|
113
|
+
default: DefaultValue<object | string>;
|
|
114
|
+
}
|
|
115
|
+
/**
|
|
116
|
+
* Color input type (stored as hex string)
|
|
117
|
+
*/
|
|
118
|
+
interface ColorInputType extends BaseInputType {
|
|
119
|
+
paramType: 'Color';
|
|
120
|
+
default: DefaultValue<string>;
|
|
121
|
+
}
|
|
122
|
+
/**
|
|
123
|
+
* Discriminated union of all input parameter types
|
|
124
|
+
*/
|
|
125
|
+
type InputParam = NumericInputType | BooleanInputType | TextInputType | ValueListInputType | GeometryInputType | FileInputType | ColorInputType;
|
|
126
|
+
|
|
127
|
+
/**
|
|
128
|
+
* Base Grasshopper schema properties shared by config, args, and response
|
|
129
|
+
*/
|
|
130
|
+
interface GrasshopperBaseSchema {
|
|
131
|
+
/** Absolute tolerance used in computation */
|
|
132
|
+
absolutetolerance?: number | null;
|
|
133
|
+
/** Angular tolerance used in computation */
|
|
134
|
+
angletolerance?: number | null;
|
|
135
|
+
/** Model units used */
|
|
136
|
+
modelunits?: RhinoModelUnit | null;
|
|
137
|
+
/** Data version (7 or 8) */
|
|
138
|
+
dataversion?: 7 | 8 | null;
|
|
139
|
+
/** Whether to use cached solution */
|
|
140
|
+
cachesolve?: boolean | null;
|
|
141
|
+
/**
|
|
142
|
+
* Opt-in: cache a solve even when the definition reported GH errors. Default
|
|
143
|
+
* (false/unset) means errored solves are never cached server-side. Some
|
|
144
|
+
* definitions throw GH errors by design (a guarded Python component, a
|
|
145
|
+
* filtered branch) while still producing correct geometry — set this so those
|
|
146
|
+
* still benefit from the server's solve cache. Only meaningful with
|
|
147
|
+
* `cachesolve`. Requires a server that honors it (VektorNode fork).
|
|
148
|
+
*/
|
|
149
|
+
cacheerroredsolves?: boolean | null;
|
|
150
|
+
}
|
|
151
|
+
/**
|
|
152
|
+
* Definition source (used in args and response)
|
|
153
|
+
*/
|
|
154
|
+
interface GrasshopperDefinitionSource {
|
|
155
|
+
/** Base64 encoded algorithm (if embedded) */
|
|
156
|
+
algo?: string | null;
|
|
157
|
+
/** URL pointer to definition file */
|
|
158
|
+
pointer?: string | null;
|
|
159
|
+
/** Filename of the definition */
|
|
160
|
+
filename?: string | null;
|
|
161
|
+
}
|
|
162
|
+
/**
|
|
163
|
+
* Configuration for Grasshopper compute operations
|
|
164
|
+
* Combines server config with optional Grasshopper-specific computation settings
|
|
165
|
+
*
|
|
166
|
+
* Note: The definition source (pointer/algo) is NOT part of config.
|
|
167
|
+
* Instead, pass the definition directly to methods like solve(), getIO(), etc.
|
|
168
|
+
*/
|
|
169
|
+
interface GrasshopperComputeConfig extends ComputeConfig {
|
|
170
|
+
/** Absolute tolerance used in computation */
|
|
171
|
+
absolutetolerance?: number | null;
|
|
172
|
+
/** Angular tolerance used in computation */
|
|
173
|
+
angletolerance?: number | null;
|
|
174
|
+
/** Model units used */
|
|
175
|
+
modelunits?: RhinoModelUnit | null;
|
|
176
|
+
/** Data version (7 or 8) */
|
|
177
|
+
dataversion?: 7 | 8 | null;
|
|
178
|
+
/** Whether to use cached solution */
|
|
179
|
+
cachesolve?: boolean | null;
|
|
180
|
+
/**
|
|
181
|
+
* Opt-in: cache a solve even when the definition reported GH errors. See
|
|
182
|
+
* {@link GrasshopperBaseSchema.cacheerroredsolves}. Only meaningful with
|
|
183
|
+
* `cachesolve`.
|
|
184
|
+
*/
|
|
185
|
+
cacheerroredsolves?: boolean | null;
|
|
186
|
+
}
|
|
187
|
+
/**
|
|
188
|
+
* Arguments sent to Grasshopper compute endpoint
|
|
189
|
+
* Includes config options + definition source + input values
|
|
190
|
+
*/
|
|
191
|
+
interface GrasshopperRequestSchema extends GrasshopperBaseSchema, GrasshopperDefinitionSource {
|
|
192
|
+
/** Input values organized by parameter */
|
|
193
|
+
values?: DataTree[];
|
|
194
|
+
}
|
|
195
|
+
/**
|
|
196
|
+
* Response from Grasshopper compute server
|
|
197
|
+
* Includes all schema fields + computed results
|
|
198
|
+
*
|
|
199
|
+
* `pointer` is deliberately excluded (`Omit`): the solve layer (`runSolve` in
|
|
200
|
+
* `solve.ts`) splits the server's echoed `pointer` off as the solve's
|
|
201
|
+
* `cacheKey` and strips it from the returned response, so client-returned
|
|
202
|
+
* responses never carry it.
|
|
203
|
+
*
|
|
204
|
+
* The schema-echo fields (`cachesolve`/`modelunits`/`dataversion`) stay
|
|
205
|
+
* optional as inherited from {@link GrasshopperBaseSchema}: the server echoes
|
|
206
|
+
* them back when set, but nothing client-side enforces their presence — don't
|
|
207
|
+
* rely on them without a fallback.
|
|
208
|
+
*/
|
|
209
|
+
interface GrasshopperComputeResponse extends GrasshopperBaseSchema, Omit<GrasshopperDefinitionSource, 'pointer'> {
|
|
210
|
+
/**
|
|
211
|
+
* Model units the definition was solved in. Every conforming server response
|
|
212
|
+
* carries this (it drives downstream scaling, e.g. the webdisplay parser),
|
|
213
|
+
* but note it is not validated client-side — a non-conforming server or
|
|
214
|
+
* hand-built mock may omit it at runtime.
|
|
215
|
+
*/
|
|
216
|
+
modelunits: RhinoModelUnit;
|
|
217
|
+
/**
|
|
218
|
+
* The server echoes the request's full base64 definition back as `algo`, but the client strips
|
|
219
|
+
* it before returning — retaining it would pin a multi-MB copy of the definition per response,
|
|
220
|
+
* multiplied by every cache that holds responses. Always `undefined` on client-returned
|
|
221
|
+
* responses (inherited optional field from {@link GrasshopperDefinitionSource}).
|
|
222
|
+
*/
|
|
223
|
+
algo?: string | null;
|
|
224
|
+
/** Filename of the definition (always present in response) */
|
|
225
|
+
filename: string | null;
|
|
226
|
+
/** Recursion level used */
|
|
227
|
+
recursionlevel?: number;
|
|
228
|
+
/** Output values organized by parameter */
|
|
229
|
+
values: DataTree[];
|
|
230
|
+
/** Computation errors */
|
|
231
|
+
errors?: string[];
|
|
232
|
+
/** Computation warnings */
|
|
233
|
+
warnings?: string[];
|
|
234
|
+
}
|
|
235
|
+
/**
|
|
236
|
+
* Output parameter
|
|
237
|
+
*/
|
|
238
|
+
interface OutputParamSchema {
|
|
239
|
+
name: string;
|
|
240
|
+
nickname: string | null;
|
|
241
|
+
paramType: string;
|
|
242
|
+
/**
|
|
243
|
+
* Grasshopper parameter instance GUID
|
|
244
|
+
*/
|
|
245
|
+
id: string;
|
|
246
|
+
}
|
|
247
|
+
/**
|
|
248
|
+
* Input parameter
|
|
249
|
+
*/
|
|
250
|
+
interface InputParamSchema {
|
|
251
|
+
/**
|
|
252
|
+
* Grasshopper parameter instance GUID
|
|
253
|
+
*/
|
|
254
|
+
id: string;
|
|
255
|
+
name: string;
|
|
256
|
+
nickname: string | null;
|
|
257
|
+
description: string;
|
|
258
|
+
paramType: string;
|
|
259
|
+
treeAccess: boolean;
|
|
260
|
+
minimum: number | null;
|
|
261
|
+
maximum: number | null;
|
|
262
|
+
atLeast: number;
|
|
263
|
+
atMost: number;
|
|
264
|
+
stepSize?: number;
|
|
265
|
+
default: any;
|
|
266
|
+
/**
|
|
267
|
+
* Key-value pairs for dropdown options
|
|
268
|
+
*/
|
|
269
|
+
values?: Record<string, string>;
|
|
270
|
+
/**
|
|
271
|
+
* Accepted file formats for File input
|
|
272
|
+
*/
|
|
273
|
+
acceptedFormats?: string[];
|
|
274
|
+
groupName?: string | null;
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
/**
|
|
278
|
+
* Parsed input/output structure with raw schemas.
|
|
279
|
+
*
|
|
280
|
+
* `loadWarnings` / `loadErrors` carry the server's definition-load diagnostics
|
|
281
|
+
* (missing plugin, broken component, etc.) from the `/io` response. They are
|
|
282
|
+
* distinct from per-input parse failures (`InputParseError`): these come from
|
|
283
|
+
* the server loading the definition, those from the client typing an input.
|
|
284
|
+
*/
|
|
285
|
+
interface GrasshopperParsedIORaw {
|
|
286
|
+
inputs: InputParamSchema[];
|
|
287
|
+
outputs: OutputParamSchema[];
|
|
288
|
+
/** Server-side definition-load warnings, if any. */
|
|
289
|
+
loadWarnings?: string[];
|
|
290
|
+
/** Server-side definition-load errors, if any (e.g. missing plugin). */
|
|
291
|
+
loadErrors?: string[];
|
|
292
|
+
}
|
|
293
|
+
/**
|
|
294
|
+
* Per-input parse failure. The corresponding entry in `inputs` was filled
|
|
295
|
+
* with a safe default so the rest of the pipeline can keep going — but the
|
|
296
|
+
* caller should surface this so the user knows their definition has a
|
|
297
|
+
* misconfigured parameter.
|
|
298
|
+
*/
|
|
299
|
+
interface InputParseError {
|
|
300
|
+
/** The input's `name` (or `'unknown'` if the schema didn't have one). */
|
|
301
|
+
inputName: string;
|
|
302
|
+
/** The declared paramType from the raw schema. */
|
|
303
|
+
paramType: string;
|
|
304
|
+
/** Human-readable reason from the underlying RhinoComputeError. */
|
|
305
|
+
message: string;
|
|
306
|
+
/** Error code from the underlying RhinoComputeError, if available. */
|
|
307
|
+
code?: string;
|
|
308
|
+
}
|
|
309
|
+
/**
|
|
310
|
+
* Parsed input/output structure with processed types.
|
|
311
|
+
*
|
|
312
|
+
* `parseErrors` is populated when one or more inputs failed validation and
|
|
313
|
+
* fell back to a safe default. The result is still usable, but the UI should
|
|
314
|
+
* surface these so the user can fix their definition.
|
|
315
|
+
*/
|
|
316
|
+
interface GrasshopperParsedIO {
|
|
317
|
+
inputs: InputParam[];
|
|
318
|
+
outputs: OutputParamSchema[];
|
|
319
|
+
parseErrors?: InputParseError[];
|
|
320
|
+
/**
|
|
321
|
+
* Server-side definition-load warnings from the `/io` response (e.g. an
|
|
322
|
+
* obsolete component). Surface these so the user understands a degraded IO
|
|
323
|
+
* list. Distinct from `parseErrors` (client-side input typing failures).
|
|
324
|
+
*/
|
|
325
|
+
loadWarnings?: string[];
|
|
326
|
+
/**
|
|
327
|
+
* Server-side definition-load errors from the `/io` response (e.g. a missing
|
|
328
|
+
* plugin that left inputs unresolved). When present, the inputs/outputs may
|
|
329
|
+
* be incomplete — the user needs to fix their server/definition.
|
|
330
|
+
*/
|
|
331
|
+
loadErrors?: string[];
|
|
332
|
+
}
|
|
9
333
|
|
|
10
334
|
/**
|
|
11
335
|
* By-reference definition form for solves.
|
|
@@ -63,19 +387,29 @@ declare function isDefinitionRef(definition: SolveDefinition): definition is Def
|
|
|
63
387
|
*/
|
|
64
388
|
type SchedulerMode = 'latest-wins' | 'queue' | 'parallel';
|
|
65
389
|
interface CacheOptions {
|
|
66
|
-
/**
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
*
|
|
70
|
-
*
|
|
71
|
-
*
|
|
72
|
-
*
|
|
73
|
-
*
|
|
74
|
-
*
|
|
75
|
-
*
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
390
|
+
/**
|
|
391
|
+
* Total byte budget for retained responses, evicted LRU. The only size bound
|
|
392
|
+
* there is: responses range KB→100s of MB, so memory is the constraint that
|
|
393
|
+
* matters and an entry count would only obscure it.
|
|
394
|
+
*
|
|
395
|
+
* Sizing uses the response's wire size (JSON text length, recorded at the
|
|
396
|
+
* fetch boundary — no re-serialization); a response without that hint
|
|
397
|
+
* (custom executor) is sized by a one-off `JSON.stringify`. A single
|
|
398
|
+
* response larger than the whole budget is served but never retained.
|
|
399
|
+
*
|
|
400
|
+
* Required and must be > 0 — to disable caching, pass `cache: false`.
|
|
401
|
+
*/
|
|
402
|
+
maxBytes: number;
|
|
403
|
+
/**
|
|
404
|
+
* Time-to-live in ms. Set to `0` for no expiry (default, and the right
|
|
405
|
+
* choice for a solve keyed by immutable definition+inputs — expiry there
|
|
406
|
+
* only buys a paid re-solve of an identical answer). Meaningful only when a
|
|
407
|
+
* definition reaches outside its inputs (external data source, clock), where
|
|
408
|
+
* a stale result is genuinely wrong rather than merely old.
|
|
409
|
+
*
|
|
410
|
+
* Expiry is evaluated lazily on read: an expired entry keeps its bytes
|
|
411
|
+
* counted against `maxBytes` until that exact key is next consulted.
|
|
412
|
+
*/
|
|
79
413
|
ttlMs?: number;
|
|
80
414
|
/**
|
|
81
415
|
* Cache responses that carry Grasshopper `errors`. Default `true`: an
|
|
@@ -109,8 +443,12 @@ interface SolveSchedulerOptions {
|
|
|
109
443
|
queueWaitMs?: number;
|
|
110
444
|
timeoutMs?: number;
|
|
111
445
|
retry?: RetryPolicy;
|
|
112
|
-
/**
|
|
113
|
-
|
|
446
|
+
/**
|
|
447
|
+
* Response caching keyed by hash of (definition, dataTree). Omit or pass
|
|
448
|
+
* `false` to disable; otherwise a byte budget is required, so an unbounded
|
|
449
|
+
* cache can't be enabled by accident.
|
|
450
|
+
*/
|
|
451
|
+
cache?: false | CacheOptions;
|
|
114
452
|
/**
|
|
115
453
|
* Reuse the server's definition cache key so a large (base64/binary)
|
|
116
454
|
* definition is uploaded once and subsequent solves reference it by
|
|
@@ -157,10 +495,6 @@ type SolveResult = {
|
|
|
157
495
|
} | {
|
|
158
496
|
status: 'superseded';
|
|
159
497
|
};
|
|
160
|
-
/**
|
|
161
|
-
* Adapter for the underlying solve function. Lets the scheduler be tested
|
|
162
|
-
* without a real Compute server, and decouples it from the client class.
|
|
163
|
-
*/
|
|
164
498
|
type SolveExecutor = (definition: SolveDefinition, dataTree: DataTree[], config: GrasshopperComputeConfig) => Promise<GrasshopperComputeResponse>;
|
|
165
499
|
/**
|
|
166
500
|
* Cache-key-aware executor. When `cacheKey` is provided, the executor solves by
|
|
@@ -178,6 +512,7 @@ type CacheKeyExecutor = (definition: SolveDefinition, dataTree: DataTree[], cach
|
|
|
178
512
|
cacheKey: string | null;
|
|
179
513
|
missed: boolean;
|
|
180
514
|
}>;
|
|
515
|
+
|
|
181
516
|
/**
|
|
182
517
|
* Robust scheduler for Grasshopper solves.
|
|
183
518
|
*
|
|
@@ -220,13 +555,21 @@ declare class SolveScheduler {
|
|
|
220
555
|
private readonly timeoutMs;
|
|
221
556
|
private readonly retry;
|
|
222
557
|
private readonly cacheEnabled;
|
|
223
|
-
private readonly cacheMax;
|
|
224
558
|
private readonly cacheMaxBytes;
|
|
225
559
|
private readonly cacheTtl;
|
|
226
560
|
private readonly cacheErroredSolves;
|
|
227
561
|
private readonly cache;
|
|
228
562
|
/** Sum of `sizeBytes` across retained cache entries. */
|
|
229
563
|
private cacheBytes;
|
|
564
|
+
/**
|
|
565
|
+
* Cumulative hit/miss/eviction counters for {@link cacheStats}. Deliberately
|
|
566
|
+
* NOT reset by `clearCache()` — they measure this scheduler's whole lifetime,
|
|
567
|
+
* so a hit rate stays comparable across a session rather than restarting at
|
|
568
|
+
* every clear.
|
|
569
|
+
*/
|
|
570
|
+
private cacheHits;
|
|
571
|
+
private cacheMisses;
|
|
572
|
+
private cacheEvictions;
|
|
230
573
|
/** Optional cache-key-aware executor and whether server-def-cache reuse is on. */
|
|
231
574
|
private readonly cacheKeyExecutor?;
|
|
232
575
|
private readonly reuseServerDefinitionCache;
|
|
@@ -357,10 +700,22 @@ declare class SolveScheduler {
|
|
|
357
700
|
/** Remove one cache entry and release its bytes from the running total. */
|
|
358
701
|
private dropCacheEntry;
|
|
359
702
|
clearCache(): void;
|
|
360
|
-
/**
|
|
703
|
+
/**
|
|
704
|
+
* Observability snapshot of the solve cache: current size plus lifetime
|
|
705
|
+
* hit/miss/eviction counters.
|
|
706
|
+
*
|
|
707
|
+
* `hits`/`misses` count cache CONSULTATIONS, so `hits / (hits + misses)` is the
|
|
708
|
+
* hit rate. A TTL-expired entry counts as a miss (the solve runs either way).
|
|
709
|
+
* `evictions` counts only entries dropped under size/byte pressure — not
|
|
710
|
+
* replace-in-place writes or TTL expiry, which are not capacity signals.
|
|
711
|
+
* Counters are cumulative and survive `clearCache()`.
|
|
712
|
+
*/
|
|
361
713
|
cacheStats(): {
|
|
362
714
|
entries: number;
|
|
363
715
|
bytes: number;
|
|
716
|
+
hits: number;
|
|
717
|
+
misses: number;
|
|
718
|
+
evictions: number;
|
|
364
719
|
};
|
|
365
720
|
dispose(): void;
|
|
366
721
|
private runHook;
|
|
@@ -509,9 +864,31 @@ interface GetValuesResult<T = ParsedContext> {
|
|
|
509
864
|
* when working with Grasshopper results in client applications.
|
|
510
865
|
*/
|
|
511
866
|
declare class GrasshopperResponseProcessor {
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
867
|
+
/**
|
|
868
|
+
* The raw compute response. Public so callers can hand it to a renderer-side parser — e.g.
|
|
869
|
+
* `getThreeMeshesFromComputeResponse` in `@selvajs/visualization/parse`, which replaced this
|
|
870
|
+
* class's former `extractMeshesFromResponse()`.
|
|
871
|
+
*/
|
|
872
|
+
readonly response: GrasshopperComputeResponse;
|
|
873
|
+
/**
|
|
874
|
+
* Retained for call-signature compatibility. Its only consumer was the removed
|
|
875
|
+
* `extractMeshesFromResponse()`, which merged it into the parse options; pass `debug`
|
|
876
|
+
* directly to the parser in `@selvajs/visualization/parse` instead.
|
|
877
|
+
*/
|
|
878
|
+
readonly debug: boolean;
|
|
879
|
+
constructor(
|
|
880
|
+
/**
|
|
881
|
+
* The raw compute response. Public so callers can hand it to a renderer-side parser — e.g.
|
|
882
|
+
* `getThreeMeshesFromComputeResponse` in `@selvajs/visualization/parse`, which replaced this
|
|
883
|
+
* class's former `extractMeshesFromResponse()`.
|
|
884
|
+
*/
|
|
885
|
+
response: GrasshopperComputeResponse,
|
|
886
|
+
/**
|
|
887
|
+
* Retained for call-signature compatibility. Its only consumer was the removed
|
|
888
|
+
* `extractMeshesFromResponse()`, which merged it into the parse options; pass `debug`
|
|
889
|
+
* directly to the parser in `@selvajs/visualization/parse` instead.
|
|
890
|
+
*/
|
|
891
|
+
debug?: boolean);
|
|
515
892
|
/**
|
|
516
893
|
* Extract all values in the response.
|
|
517
894
|
*
|
|
@@ -549,22 +926,17 @@ declare class GrasshopperResponseProcessor {
|
|
|
549
926
|
byId: string;
|
|
550
927
|
}, options?: GetValuesOptions): any;
|
|
551
928
|
/**
|
|
552
|
-
*
|
|
553
|
-
*
|
|
554
|
-
*
|
|
555
|
-
* Requires the **Selva Display** Grasshopper component and the VektorNode
|
|
556
|
-
* rhino.compute branch. Three.js is loaded dynamically, so install it as a
|
|
557
|
-
* peer dependency before calling this.
|
|
558
|
-
*
|
|
559
|
-
* @throws {RhinoComputeError} If the three.js visualization module can't load.
|
|
929
|
+
* REMOVED: `extractMeshesFromResponse()`. Mesh decoding lives in `@selvajs/visualization` now, so
|
|
930
|
+
* this package stays pure solve/data and carries no `three` dependency. Call the parser directly
|
|
931
|
+
* with the raw response:
|
|
560
932
|
*
|
|
561
|
-
* @example
|
|
562
933
|
* ```ts
|
|
563
|
-
*
|
|
934
|
+
* import { getThreeMeshesFromComputeResponse } from '@selvajs/visualization/parse';
|
|
935
|
+
*
|
|
936
|
+
* const meshes = await getThreeMeshesFromComputeResponse(processor.response, { rhino });
|
|
564
937
|
* scene.add(...meshes);
|
|
565
938
|
* ```
|
|
566
939
|
*/
|
|
567
|
-
extractMeshesFromResponse(options?: MeshExtractionOptions): Promise<THREE.Object3D<THREE.Object3DEventMap>[]>;
|
|
568
940
|
private getFileData;
|
|
569
941
|
/**
|
|
570
942
|
* Download all files generated by Grasshopper, optionally including
|
|
@@ -722,12 +1094,6 @@ declare function fetchParsedDefinitionIO(definition: string | Uint8Array, config
|
|
|
722
1094
|
* {@link processInputWithError} to receive them.
|
|
723
1095
|
*/
|
|
724
1096
|
declare function processInput(rawInput: InputParamSchema): InputParam;
|
|
725
|
-
/**
|
|
726
|
-
* Parse an array of raw input schemas into typed {@link InputParam}s, each via
|
|
727
|
-
* {@link processInput}. Use {@link processInputsWithErrors} to also collect the
|
|
728
|
-
* inputs that failed validation.
|
|
729
|
-
*/
|
|
730
|
-
declare function processInputs(rawInputs: InputParamSchema[]): InputParam[];
|
|
731
1097
|
|
|
732
1098
|
/**
|
|
733
1099
|
* Value types that can be stored in a DataTree
|
|
@@ -1003,4 +1369,4 @@ declare class TreeBuilder {
|
|
|
1003
1369
|
private static clampValue;
|
|
1004
1370
|
}
|
|
1005
1371
|
|
|
1006
|
-
export { type CacheOptions,
|
|
1372
|
+
export { type BooleanInputType, type CacheOptions, type DataItem, type DataTree, type DataTreeDefault, type DataTreePath, type DataTreeValue, type DefaultValue, type DefinitionRef, FileBaseInfo, type FileInputType, type GeometryInputType, type GetValuesOptions, type GetValuesResult, GrasshopperClient, type GrasshopperComputeConfig, type GrasshopperComputeResponse, type GrasshopperParsedIO, type GrasshopperParsedIORaw, type GrasshopperRequestSchema, GrasshopperResponseProcessor, type InnerTreeData, type InputParam, type InputParamSchema, type NumericInputType, type OutputParamSchema, type OutputType, type ParsedContext, type SchedulerMode, type SolveContext, type SolveDefinition, type SolveOptions, type SolveResult, SolveScheduler, type SolveSchedulerOptions, type TextInputType, TreeBuilder, type ValueListInputType, fetchDefinitionIO, fetchParsedDefinitionIO, hashDefinition, hashSolveInput, isDefinitionRef, processInput, solveGrasshopperDefinition, stableStringify };
|