@selvajs/compute 3.1.0-beta.4 → 3.1.0-beta.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (58) hide show
  1. package/dist/chunk-727SRM4E.cjs +62 -0
  2. package/dist/chunk-727SRM4E.cjs.map +1 -0
  3. package/dist/chunk-CUQQ3ZBV.cjs +4 -0
  4. package/dist/chunk-CUQQ3ZBV.cjs.map +1 -0
  5. package/dist/chunk-CWODTGNH.js +62 -0
  6. package/dist/chunk-CWODTGNH.js.map +1 -0
  7. package/dist/chunk-JNFNLKFO.js +2 -0
  8. package/dist/chunk-JNFNLKFO.js.map +1 -0
  9. package/dist/chunk-WPB2LKCD.js +4 -0
  10. package/dist/chunk-WPB2LKCD.js.map +1 -0
  11. package/dist/chunk-Y5E6RIEH.cjs +2 -0
  12. package/dist/chunk-Y5E6RIEH.cjs.map +1 -0
  13. package/dist/core.cjs +1 -1
  14. package/dist/core.d.cts +40 -3
  15. package/dist/core.d.ts +40 -3
  16. package/dist/core.js +1 -1
  17. package/dist/grasshopper.cjs +1 -1
  18. package/dist/grasshopper.cjs.map +1 -1
  19. package/dist/grasshopper.d.cts +222 -32
  20. package/dist/grasshopper.d.ts +222 -32
  21. package/dist/grasshopper.js +1 -1
  22. package/dist/{handle-files-9pkEgDIp.d.ts → handle-files-BISo_wob.d.cts} +51 -67
  23. package/dist/{handle-files-9pkEgDIp.d.cts → handle-files-BISo_wob.d.ts} +51 -67
  24. package/dist/index.cjs +1 -1
  25. package/dist/index.cjs.map +1 -1
  26. package/dist/index.d.cts +4 -4
  27. package/dist/index.d.ts +4 -4
  28. package/dist/index.js +1 -1
  29. package/dist/types-BGhtYxZ-.d.cts +45 -0
  30. package/dist/types-BGhtYxZ-.d.ts +45 -0
  31. package/dist/{types-BBSF_ISX.d.ts → types-C8XWc4Ab.d.cts} +62 -66
  32. package/dist/{types-DxPi5SEx.d.cts → types-Dtok-mVq.d.ts} +62 -66
  33. package/dist/visualization-36IV2CVU.cjs +2 -0
  34. package/dist/visualization-36IV2CVU.cjs.map +1 -0
  35. package/dist/visualization-QCI36RHC.js +2 -0
  36. package/dist/visualization.cjs +1 -1
  37. package/dist/visualization.d.cts +144 -48
  38. package/dist/visualization.d.ts +144 -48
  39. package/dist/visualization.js +1 -1
  40. package/package.json +1 -1
  41. package/dist/chunk-33753HSV.cjs +0 -2
  42. package/dist/chunk-33753HSV.cjs.map +0 -1
  43. package/dist/chunk-4JNRO7TX.cjs +0 -62
  44. package/dist/chunk-4JNRO7TX.cjs.map +0 -1
  45. package/dist/chunk-6V6SUB4V.js +0 -62
  46. package/dist/chunk-6V6SUB4V.js.map +0 -1
  47. package/dist/chunk-D7A3YIYD.cjs +0 -4
  48. package/dist/chunk-D7A3YIYD.cjs.map +0 -1
  49. package/dist/chunk-EMXDP7KY.js +0 -4
  50. package/dist/chunk-EMXDP7KY.js.map +0 -1
  51. package/dist/chunk-MDFVHHH6.js +0 -2
  52. package/dist/chunk-MDFVHHH6.js.map +0 -1
  53. package/dist/types-V7G83j5m.d.cts +0 -100
  54. package/dist/types-V7G83j5m.d.ts +0 -100
  55. package/dist/visualization-3XYZHAIV.js +0 -2
  56. package/dist/visualization-DEAMRV7R.cjs +0 -2
  57. package/dist/visualization-DEAMRV7R.cjs.map +0 -1
  58. /package/dist/{visualization-3XYZHAIV.js.map → visualization-QCI36RHC.js.map} +0 -0
@@ -25,14 +25,16 @@ declare class ComputeServerStats {
25
25
  private disposed;
26
26
  private activeMonitors;
27
27
  private activeTimeouts;
28
- /**
29
- * @param serverUrl - Base URL of the Rhino Compute server with http:// or https:// scheme (e.g., 'http://localhost:6500')
30
- * @param apiKey - Optional API key for authentication
31
- */
32
28
  /** Timeout (ms) for the fast read/monitoring endpoints. */
33
29
  private static readonly DEFAULT_TIMEOUT_MS;
34
30
  /** Timeout (ms) for child-lifecycle POSTs — a cold Windows child can take ~30s to spawn. */
35
31
  private static readonly LIFECYCLE_TIMEOUT_MS;
32
+ /** Floor for `monitor()`'s `intervalMs` — anything lower hot-loops the server. */
33
+ private static readonly MIN_MONITOR_INTERVAL_MS;
34
+ /**
35
+ * @param serverUrl - Base URL of the Rhino Compute server with http:// or https:// scheme (e.g., 'http://localhost:6500')
36
+ * @param apiKey - Optional API key for authentication
37
+ */
36
38
  constructor(serverUrl: string, apiKey?: string);
37
39
  /**
38
40
  * Build request headers with optional API key.
@@ -273,8 +275,10 @@ declare class ComputeServerStats {
273
275
  * Continuously monitor server stats at specified interval.
274
276
  *
275
277
  * @param callback - Function called with stats on each interval
276
- * @param intervalMs - Milliseconds between checks (default: 5000)
278
+ * @param intervalMs - Milliseconds between checks (default: 5000). Must be a
279
+ * finite number of at least 100 ms — lower values would hot-loop the server.
277
280
  * @returns Function to stop monitoring
281
+ * @throws {RangeError} If `intervalMs` is not a finite number >= 100.
278
282
  *
279
283
  * @example
280
284
  * ```typescript
@@ -298,9 +302,6 @@ declare class ComputeServerStats {
298
302
  private ensureNotDisposed;
299
303
  }
300
304
 
301
- /**
302
- * Error types and codes for `@selvajs/compute`.
303
- */
304
305
  declare const ErrorCodes: {
305
306
  readonly NETWORK_ERROR: "NETWORK_ERROR";
306
307
  readonly AUTH_ERROR: "AUTH_ERROR";
@@ -308,6 +309,17 @@ declare const ErrorCodes: {
308
309
  readonly COMPUTATION_ERROR: "COMPUTATION_ERROR";
309
310
  readonly TIMEOUT_ERROR: "TIMEOUT_ERROR";
310
311
  readonly CORS_ERROR: "CORS_ERROR";
312
+ /** HTTP 404 — the endpoint path does not exist on the server (usually a typo'd route or wrong server). Never retried. */
313
+ readonly NOT_FOUND: "NOT_FOUND";
314
+ /** HTTP 429 — the server is rate-limiting requests. Retried by default (honors `Retry-After`); see `RetryPolicy.retryOn429`. */
315
+ readonly RATE_LIMIT: "RATE_LIMIT";
316
+ /**
317
+ * The server answered 2xx but the body is deterministically not JSON (the
318
+ * response declared a non-JSON `Content-Type`, e.g. an HTML captive-portal or
319
+ * proxy login page, or a misconfigured endpoint). Never retried — refetching
320
+ * returns the same page.
321
+ */
322
+ readonly INVALID_RESPONSE: "INVALID_RESPONSE";
311
323
  readonly UNKNOWN_ERROR: "UNKNOWN_ERROR";
312
324
  readonly INVALID_STATE: "INVALID_STATE";
313
325
  readonly INVALID_INPUT: "INVALID_INPUT";
@@ -321,6 +333,19 @@ declare const ErrorCodes: {
321
333
  readonly SUPERSEDED: "SUPERSEDED";
322
334
  /** Scheduler / caller-supplied AbortSignal: this call was aborted. */
323
335
  readonly ABORTED: "ABORTED";
336
+ /**
337
+ * Scheduler backpressure: the queue was already at `maxQueueDepth` when this
338
+ * call arrived, so it was shed immediately rather than queued. Retryable — the
339
+ * caller (or an HTTP layer, as 503 + Retry-After) should back off and retry.
340
+ * The error `context` carries `{ queueDepth, maxQueueDepth }`.
341
+ */
342
+ readonly QUEUE_FULL: "QUEUE_FULL";
343
+ /**
344
+ * Scheduler backpressure: this call sat queued longer than `queueWaitMs`
345
+ * without starting, so it was shed before wasting compute on a stale request.
346
+ * Retryable. The error `context` carries `{ waitedMs, queueWaitMs }`.
347
+ */
348
+ readonly QUEUE_TIMEOUT: "QUEUE_TIMEOUT";
324
349
  /**
325
350
  * A solve referenced a definition by `pointer` (server-side cache key), but the
326
351
  * server no longer holds that definition (evicted / GC'd / a different child in
@@ -357,94 +382,53 @@ declare class RhinoComputeError extends Error {
357
382
  }
358
383
 
359
384
  /**
360
- * Represents raw file data from Grasshopper/Rhino Compute response.
361
- *
362
- * This type encapsulates file output from compute operations, with metadata
363
- * for processing (decoding, naming, organization). Files are typically combined
364
- * with additional files and packaged into a ZIP archive for download.
365
- *
366
- * @see {@link ProcessedFile} for the normalized format after processing
385
+ * Raw file data from Grasshopper/Rhino Compute response, with metadata for processing.
386
+ * Files are typically combined with additional files and packaged into a ZIP archive.
367
387
  * @see {@link extractFilesFromComputeResponse} for extraction from compute responses
368
388
  */
369
389
  type FileData = {
370
390
  /** Base filename without extension (e.g., "model") */
371
391
  fileName: string;
372
- /** File content as a base64-encoded or plain string, depending on {@link IsBase64Encoded} */
392
+ /** File content, base64-encoded or plain string depending on isBase64Encoded flag */
373
393
  data: string;
374
- /** File extension including the dot (e.g., ".3dm", ".json"). Appended to {@link FileName} to create the full filename */
394
+ /** File extension including the dot (e.g., ".3dm", ".json"). Appended to fileName to create the full filename */
375
395
  fileType: string;
376
- /** Whether {@link Data} is base64-encoded. If true, must be decoded to binary before use. If false, can be used as a plain text string */
396
+ /** Whether data is base64-encoded. If true, must be decoded to binary before use */
377
397
  isBase64Encoded: boolean;
378
- /** Directory path for organizing the file in archive structures (e.g., ZIP). Typically empty string for root-level files, or a path like "subfolder/nested" */
398
+ /** Directory path for archive organization (e.g., "subfolder/nested"). Empty string for root-level files */
379
399
  subFolder: string;
380
- /** Arbitrary user-supplied metadata (e.g. tags, indexing keys) attached in Grasshopper. Not interpreted by compute; passed through for downstream consumers. May be absent on older payloads. */
400
+ /** Arbitrary metadata attached in Grasshopper. Not interpreted by compute; passed through for downstream consumers. May be absent on older payloads */
381
401
  metadata?: Record<string, string>;
382
402
  };
383
403
  /**
384
- * Represents a normalized, processed file ready for consumption or archival.
385
- *
386
- * This is the unified intermediate format produced by processing both {@link FileData}
387
- * and {@link FileBaseInfo}. Files in this format are ready to be packaged into archives
388
- * (e.g., ZIP files) or returned to callers for programmatic use.
389
- *
390
- * @see {@link FileData} for raw compute response files
391
- * @see {@link FileBaseInfo} for external file references
404
+ * Normalized file ready for consumption or archival.
405
+ * Unified intermediate format from FileData or FileBaseInfo, ready to be packaged into archives or returned to callers.
392
406
  */
393
407
  type ProcessedFile = {
394
408
  /** Full filename including extension (e.g., "model.3dm") */
395
409
  fileName: string;
396
- /** File content as either binary data or text. Binary format (Uint8Array) is used for decoded base64 or fetched binary files; text format is used for plain text content */
410
+ /** File content as binary data (Uint8Array for decoded base64 or fetched binary) or text */
397
411
  content: Uint8Array | string;
398
- /** File path for archive organization (e.g., "subfolder/model.3dm"). Used when creating ZIP archives or other hierarchical structures */
412
+ /** File path for archive organization (e.g., "subfolder/model.3dm") */
399
413
  path: string;
400
414
  };
401
415
  /**
402
- * Represents a reference to an external file to be included in file operations.
403
- *
404
- * This type is used to specify additional files (beyond compute response files)
405
- * that should be fetched and included when processing files. The file is fetched
406
- * from the provided URL and processed as a {@link ProcessedFile}.
407
- *
408
- *
409
- * @see {@link FileData} for files from compute responses
410
- * @see {@link fetchRemoteFiles} for how FileBaseInfo is processed (fetched and converted)
416
+ * Reference to an external file to be fetched and included in file operations.
417
+ * Specifies additional files (beyond compute response files) to fetch and process as ProcessedFile.
418
+ * @see {@link fetchRemoteFiles} for how FileBaseInfo is fetched and converted
411
419
  */
412
420
  type FileBaseInfo = {
413
421
  /** Destination filename for the file in the archive or result set (e.g., "additional-data.json") */
414
422
  fileName: string;
415
423
  /** URL to fetch the file from. Must be accessible from the runtime environment */
416
424
  filePath: string;
425
+ /** Optional directory path for archive organization (e.g., "extras/docs"). When omitted, file lands at archive root */
426
+ subFolder?: string;
417
427
  };
418
428
 
419
- /**
420
- * Extracts and processes files from compute response data without downloading them.
421
- * Returns an array of ProcessedFile objects that can be used programmatically.
422
- *
423
- * @param downloadableFiles - An array of FileData items from the compute response.
424
- * @param additionalFiles - Optional additional files to include (fetched from URLs).
425
- * @returns A Promise resolving to an array of ProcessedFile objects.
426
- * @throws Will throw an error if file processing fails.
427
- *
428
- * @example
429
- * const files = await extractFilesFromComputeResponse(fileData);
430
- * files.forEach(file => {
431
- * console.log(`File: ${file.fileName}, Size: ${file.content.length}`);
432
- * });
433
- */
429
+ /** Extracts and processes files from compute response data without downloading them. */
434
430
  declare const extractFilesFromComputeResponse: (downloadableFiles: FileData[], additionalFiles?: FileBaseInfo[] | FileBaseInfo | null) => Promise<ProcessedFile[]>;
435
- /**
436
- * Downloads files from a compute response as a ZIP archive.
437
- * Packages multiple files into a single ZIP file and triggers a browser download.
438
- *
439
- * @param downloadableFiles - An array of FileData items from the compute response.
440
- * @param additionalFiles - Optional additional files to include in the ZIP (fetched from URLs).
441
- * @param fileFoldername - The name of the ZIP file (without extension).
442
- * @throws Will throw an error if the file handling or download fails.
443
- *
444
- * @example
445
- * await downloadDataFromComputeResponse(fileData, null, 'my-export');
446
- * // Downloads 'my-export.zip'
447
- */
431
+ /** Downloads files from a compute response as a ZIP archive. */
448
432
  declare const downloadFileData: (downloadableFiles: FileData[], fileFoldername: string, additionalFiles?: FileBaseInfo[] | FileBaseInfo | null) => Promise<void>;
449
433
 
450
434
  export { ComputeServerStats as C, type ErrorCode as E, type FileBaseInfo as F, type ProcessedFile as P, RhinoComputeError as R, ErrorCodes as a, type FileData as b, downloadFileData as d, extractFilesFromComputeResponse as e };
package/dist/index.cjs CHANGED
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunk33753HSVcjs = require('./chunk-33753HSV.cjs');var _chunkD7A3YIYDcjs = require('./chunk-D7A3YIYD.cjs');exports.ComputeServerStats = _chunkD7A3YIYDcjs.n; exports.ErrorCodes = _chunkD7A3YIYDcjs.c; exports.GrasshopperClient = _chunk33753HSVcjs.c; exports.GrasshopperResponseProcessor = _chunk33753HSVcjs.d; exports.RhinoComputeError = _chunkD7A3YIYDcjs.d; exports.SolveScheduler = _chunk33753HSVcjs.b; exports.TreeBuilder = _chunk33753HSVcjs.i; exports.camelcaseKeys = _chunkD7A3YIYDcjs.p; exports.downloadFileData = _chunkD7A3YIYDcjs.r; exports.enableDebugLogging = _chunkD7A3YIYDcjs.g; exports.extractFilesFromComputeResponse = _chunkD7A3YIYDcjs.q; exports.fetchDefinitionIO = _chunk33753HSVcjs.g; exports.fetchParsedDefinitionIO = _chunk33753HSVcjs.h; exports.fetchRhinoCompute = _chunkD7A3YIYDcjs.l; exports.getLogger = _chunkD7A3YIYDcjs.e; exports.processInput = _chunk33753HSVcjs.e; exports.processInputs = _chunk33753HSVcjs.f; exports.setLogger = _chunkD7A3YIYDcjs.f; exports.solveGrasshopperDefinition = _chunk33753HSVcjs.a; exports.toCamelCase = _chunkD7A3YIYDcjs.o;
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunkY5E6RIEHcjs = require('./chunk-Y5E6RIEH.cjs');var _chunkCUQQ3ZBVcjs = require('./chunk-CUQQ3ZBV.cjs');exports.ComputeServerStats = _chunkCUQQ3ZBVcjs.n; exports.ErrorCodes = _chunkCUQQ3ZBVcjs.c; exports.GrasshopperClient = _chunkY5E6RIEHcjs.g; exports.GrasshopperResponseProcessor = _chunkY5E6RIEHcjs.h; exports.RhinoComputeError = _chunkCUQQ3ZBVcjs.d; exports.SolveScheduler = _chunkY5E6RIEHcjs.f; exports.TreeBuilder = _chunkY5E6RIEHcjs.m; exports.camelcaseKeys = _chunkCUQQ3ZBVcjs.p; exports.downloadFileData = _chunkCUQQ3ZBVcjs.t; exports.enableDebugLogging = _chunkCUQQ3ZBVcjs.g; exports.extractFilesFromComputeResponse = _chunkCUQQ3ZBVcjs.s; exports.fetchDefinitionIO = _chunkY5E6RIEHcjs.k; exports.fetchParsedDefinitionIO = _chunkY5E6RIEHcjs.l; exports.fetchRhinoCompute = _chunkCUQQ3ZBVcjs.l; exports.getLogger = _chunkCUQQ3ZBVcjs.e; exports.hashDefinition = _chunkY5E6RIEHcjs.e; exports.hashSolveInput = _chunkY5E6RIEHcjs.d; exports.isDefinitionRef = _chunkY5E6RIEHcjs.a; exports.processInput = _chunkY5E6RIEHcjs.i; exports.processInputs = _chunkY5E6RIEHcjs.j; exports.setLogger = _chunkCUQQ3ZBVcjs.f; exports.solveGrasshopperDefinition = _chunkY5E6RIEHcjs.b; exports.stableStringify = _chunkY5E6RIEHcjs.c; exports.toCamelCase = _chunkCUQQ3ZBVcjs.o;
2
2
  //# sourceMappingURL=index.cjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["/home/runner/work/selva-compute/selva-compute/dist/index.cjs"],"names":[],"mappings":"AAAA,iIAAgG,wDAAqG,y8BAA0c","file":"/home/runner/work/selva-compute/selva-compute/dist/index.cjs"}
1
+ {"version":3,"sources":["/home/runner/work/selva-compute/selva-compute/dist/index.cjs"],"names":[],"mappings":"AAAA,iIAA4H,wDAAqG,moCAA4hB","file":"/home/runner/work/selva-compute/selva-compute/dist/index.cjs"}
package/dist/index.d.cts CHANGED
@@ -1,7 +1,7 @@
1
1
  export { Logger, camelcaseKeys, enableDebugLogging, fetchRhinoCompute, getLogger, setLogger, toCamelCase } from './core.cjs';
2
- export { C as ComputeServerStats, E as ErrorCode, a as ErrorCodes, F as FileBaseInfo, b as FileData, P as ProcessedFile, R as RhinoComputeError, d as downloadFileData, e as extractFilesFromComputeResponse } from './handle-files-9pkEgDIp.cjs';
3
- export { C as ComputeConfig, R as RetryPolicy, a as RhinoModelUnit, S as ServerTiming } from './types-V7G83j5m.cjs';
4
- export { CacheOptions, DataTreeValue, GetValuesOptions, GetValuesResult, GrasshopperClient, GrasshopperResponseProcessor, ParsedContext, SchedulerMode, SolveContext, SolveOptions, SolveResult, SolveScheduler, SolveSchedulerOptions, TreeBuilder, fetchDefinitionIO, fetchParsedDefinitionIO, processInput, processInputs, solveGrasshopperDefinition } from './grasshopper.cjs';
5
- export { B as BooleanInputType, D as DataItem, a as DataTree, b as DataTreeDefault, c as DataTreePath, d as DefaultValue, F as FileInputType, G as GeometryInputType, e as GrasshopperComputeConfig, f as GrasshopperComputeResponse, g as GrasshopperParsedIO, h as GrasshopperParsedIORaw, i as GrasshopperRequestSchema, I as InnerTreeData, j as InputParam, k as InputParamSchema, N as NumericInputType, O as OutputParamSchema, l as OutputType, T as TextInputType, V as ValueListInputType } from './types-DxPi5SEx.cjs';
2
+ export { C as ComputeServerStats, E as ErrorCode, a as ErrorCodes, F as FileBaseInfo, b as FileData, P as ProcessedFile, R as RhinoComputeError, d as downloadFileData, e as extractFilesFromComputeResponse } from './handle-files-BISo_wob.cjs';
3
+ export { C as ComputeConfig, R as RetryPolicy, a as RhinoModelUnit, S as ServerTiming } from './types-BGhtYxZ-.cjs';
4
+ export { CacheOptions, DataTreeValue, DefinitionRef, GetValuesOptions, GetValuesResult, GrasshopperClient, GrasshopperResponseProcessor, ParsedContext, SchedulerMode, SolveContext, SolveDefinition, SolveOptions, SolveResult, SolveScheduler, SolveSchedulerOptions, TreeBuilder, fetchDefinitionIO, fetchParsedDefinitionIO, hashDefinition, hashSolveInput, isDefinitionRef, processInput, processInputs, solveGrasshopperDefinition, stableStringify } from './grasshopper.cjs';
5
+ export { B as BooleanInputType, D as DataItem, a as DataTree, b as DataTreeDefault, c as DataTreePath, d as DefaultValue, F as FileInputType, G as GeometryInputType, e as GrasshopperComputeConfig, f as GrasshopperComputeResponse, g as GrasshopperParsedIO, h as GrasshopperParsedIORaw, i as GrasshopperRequestSchema, I as InnerTreeData, j as InputParam, k as InputParamSchema, N as NumericInputType, O as OutputParamSchema, l as OutputType, T as TextInputType, V as ValueListInputType } from './types-C8XWc4Ab.cjs';
6
6
  import 'three';
7
7
  import 'rhino3dm';
package/dist/index.d.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  export { Logger, camelcaseKeys, enableDebugLogging, fetchRhinoCompute, getLogger, setLogger, toCamelCase } from './core.js';
2
- export { C as ComputeServerStats, E as ErrorCode, a as ErrorCodes, F as FileBaseInfo, b as FileData, P as ProcessedFile, R as RhinoComputeError, d as downloadFileData, e as extractFilesFromComputeResponse } from './handle-files-9pkEgDIp.js';
3
- export { C as ComputeConfig, R as RetryPolicy, a as RhinoModelUnit, S as ServerTiming } from './types-V7G83j5m.js';
4
- export { CacheOptions, DataTreeValue, GetValuesOptions, GetValuesResult, GrasshopperClient, GrasshopperResponseProcessor, ParsedContext, SchedulerMode, SolveContext, SolveOptions, SolveResult, SolveScheduler, SolveSchedulerOptions, TreeBuilder, fetchDefinitionIO, fetchParsedDefinitionIO, processInput, processInputs, solveGrasshopperDefinition } from './grasshopper.js';
5
- export { B as BooleanInputType, D as DataItem, a as DataTree, b as DataTreeDefault, c as DataTreePath, d as DefaultValue, F as FileInputType, G as GeometryInputType, e as GrasshopperComputeConfig, f as GrasshopperComputeResponse, g as GrasshopperParsedIO, h as GrasshopperParsedIORaw, i as GrasshopperRequestSchema, I as InnerTreeData, j as InputParam, k as InputParamSchema, N as NumericInputType, O as OutputParamSchema, l as OutputType, T as TextInputType, V as ValueListInputType } from './types-BBSF_ISX.js';
2
+ export { C as ComputeServerStats, E as ErrorCode, a as ErrorCodes, F as FileBaseInfo, b as FileData, P as ProcessedFile, R as RhinoComputeError, d as downloadFileData, e as extractFilesFromComputeResponse } from './handle-files-BISo_wob.js';
3
+ export { C as ComputeConfig, R as RetryPolicy, a as RhinoModelUnit, S as ServerTiming } from './types-BGhtYxZ-.js';
4
+ export { CacheOptions, DataTreeValue, DefinitionRef, GetValuesOptions, GetValuesResult, GrasshopperClient, GrasshopperResponseProcessor, ParsedContext, SchedulerMode, SolveContext, SolveDefinition, SolveOptions, SolveResult, SolveScheduler, SolveSchedulerOptions, TreeBuilder, fetchDefinitionIO, fetchParsedDefinitionIO, hashDefinition, hashSolveInput, isDefinitionRef, processInput, processInputs, solveGrasshopperDefinition, stableStringify } from './grasshopper.js';
5
+ export { B as BooleanInputType, D as DataItem, a as DataTree, b as DataTreeDefault, c as DataTreePath, d as DefaultValue, F as FileInputType, G as GeometryInputType, e as GrasshopperComputeConfig, f as GrasshopperComputeResponse, g as GrasshopperParsedIO, h as GrasshopperParsedIORaw, i as GrasshopperRequestSchema, I as InnerTreeData, j as InputParam, k as InputParamSchema, N as NumericInputType, O as OutputParamSchema, l as OutputType, T as TextInputType, V as ValueListInputType } from './types-Dtok-mVq.js';
6
6
  import 'three';
7
7
  import 'rhino3dm';
package/dist/index.js CHANGED
@@ -1,2 +1,2 @@
1
- import{a as d,b as g,c as h,d as i,e as j,f as k,g as l,h as n,i as q}from"./chunk-MDFVHHH6.js";import{c as o,d as r,e,f,g as m,l as p,n as t,o as x,p as a,q as b,r as c}from"./chunk-EMXDP7KY.js";export{t as ComputeServerStats,o as ErrorCodes,h as GrasshopperClient,i as GrasshopperResponseProcessor,r as RhinoComputeError,g as SolveScheduler,q as TreeBuilder,a as camelcaseKeys,c as downloadFileData,m as enableDebugLogging,b as extractFilesFromComputeResponse,l as fetchDefinitionIO,n as fetchParsedDefinitionIO,p as fetchRhinoCompute,e as getLogger,j as processInput,k as processInputs,f as setLogger,d as solveGrasshopperDefinition,x as toCamelCase};
1
+ import{a as d,b as g,c as h,d as i,e as j,f as k,g as l,h as n,i as q,j as s,k as u,l as v,m as w}from"./chunk-JNFNLKFO.js";import{c as o,d as r,e,f,g as m,l as p,n as t,o as x,p as a,s as b,t as c}from"./chunk-WPB2LKCD.js";export{t as ComputeServerStats,o as ErrorCodes,l as GrasshopperClient,n as GrasshopperResponseProcessor,r as RhinoComputeError,k as SolveScheduler,w as TreeBuilder,a as camelcaseKeys,c as downloadFileData,m as enableDebugLogging,b as extractFilesFromComputeResponse,u as fetchDefinitionIO,v as fetchParsedDefinitionIO,p as fetchRhinoCompute,e as getLogger,j as hashDefinition,i as hashSolveInput,d as isDefinitionRef,q as processInput,s as processInputs,f as setLogger,g as solveGrasshopperDefinition,h as stableStringify,x as toCamelCase};
2
2
  //# sourceMappingURL=index.js.map
@@ -0,0 +1,45 @@
1
+ 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';
2
+ interface RetryPolicy {
3
+ /** Maximum number of retry attempts after the initial request (default: 0). */
4
+ attempts?: number;
5
+ /** Base delay in milliseconds for exponential backoff (default: 500). */
6
+ baseDelayMs?: number;
7
+ /** Upper bound for backoff delay (default: 30_000). */
8
+ maxDelayMs?: number;
9
+ /** Whether to retry on 429 responses (default: true — honors Retry-After). */
10
+ retryOn429?: boolean;
11
+ }
12
+ interface ComputeConfig {
13
+ serverUrl: string;
14
+ /** Optional API key for authenticating with the server (RhinoComputeKey) */
15
+ apiKey?: string;
16
+ /** Optional Bearer token for authentication (e.g., when behind a proxy or API gateway) */
17
+ authToken?: string;
18
+ headers?: Record<string, string>;
19
+ /** Enable debug logging to the console */
20
+ debug?: boolean;
21
+ /** Suppress browser security warnings in the console */
22
+ suppressBrowserWarning?: boolean;
23
+ /** @deprecated Renamed to `suppressBrowserWarning`. */
24
+ suppressClientSideWarning?: boolean;
25
+ timeoutMs?: number;
26
+ /**
27
+ * Retry policy for transient errors. Default: no retries.
28
+ */
29
+ retry?: RetryPolicy;
30
+ /**
31
+ * Optional caller-supplied AbortSignal. Composes with the internal timeout —
32
+ * whichever fires first wins. Lets callers cancel in-flight requests
33
+ * (e.g. on component unmount or when superseding a stale solve).
34
+ */
35
+ signal?: AbortSignal;
36
+ onServerTiming?: (timing: ServerTiming, requestId: string) => void;
37
+ }
38
+ interface ServerTiming {
39
+ decode?: number;
40
+ solve?: number;
41
+ encode?: number;
42
+ raw: string;
43
+ }
44
+
45
+ export type { ComputeConfig as C, RetryPolicy as R, ServerTiming as S, RhinoModelUnit as a };
@@ -0,0 +1,45 @@
1
+ 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';
2
+ interface RetryPolicy {
3
+ /** Maximum number of retry attempts after the initial request (default: 0). */
4
+ attempts?: number;
5
+ /** Base delay in milliseconds for exponential backoff (default: 500). */
6
+ baseDelayMs?: number;
7
+ /** Upper bound for backoff delay (default: 30_000). */
8
+ maxDelayMs?: number;
9
+ /** Whether to retry on 429 responses (default: true — honors Retry-After). */
10
+ retryOn429?: boolean;
11
+ }
12
+ interface ComputeConfig {
13
+ serverUrl: string;
14
+ /** Optional API key for authenticating with the server (RhinoComputeKey) */
15
+ apiKey?: string;
16
+ /** Optional Bearer token for authentication (e.g., when behind a proxy or API gateway) */
17
+ authToken?: string;
18
+ headers?: Record<string, string>;
19
+ /** Enable debug logging to the console */
20
+ debug?: boolean;
21
+ /** Suppress browser security warnings in the console */
22
+ suppressBrowserWarning?: boolean;
23
+ /** @deprecated Renamed to `suppressBrowserWarning`. */
24
+ suppressClientSideWarning?: boolean;
25
+ timeoutMs?: number;
26
+ /**
27
+ * Retry policy for transient errors. Default: no retries.
28
+ */
29
+ retry?: RetryPolicy;
30
+ /**
31
+ * Optional caller-supplied AbortSignal. Composes with the internal timeout —
32
+ * whichever fires first wins. Lets callers cancel in-flight requests
33
+ * (e.g. on component unmount or when superseding a stale solve).
34
+ */
35
+ signal?: AbortSignal;
36
+ onServerTiming?: (timing: ServerTiming, requestId: string) => void;
37
+ }
38
+ interface ServerTiming {
39
+ decode?: number;
40
+ solve?: number;
41
+ encode?: number;
42
+ raw: string;
43
+ }
44
+
45
+ export type { ComputeConfig as C, RetryPolicy as R, ServerTiming as S, RhinoModelUnit as a };
@@ -1,57 +1,44 @@
1
- import { C as ComputeConfig, a as RhinoModelUnit } from './types-V7G83j5m.js';
1
+ import { C as ComputeConfig, a as RhinoModelUnit } from './types-BGhtYxZ-.cjs';
2
2
  import { RhinoModule } from 'rhino3dm';
3
3
 
4
- /**
5
- * Grasshopper types
6
- */
7
-
8
- /**
9
- * Grasshopper-style data tree branch path
10
- * @example "{0}", "{0;0}", "{0;1;2}"
11
- */
12
4
  type DataTreePath = `{${string}}`;
13
- /**
14
- * Represents a data item in a data tree
15
- */
16
5
  interface DataItem {
17
- /** The type of the data, inferred from the Grasshopper GOO class */
18
6
  type: string;
19
- /** The actual returned data as a string that may need to be parsed */
20
7
  data: string;
21
- /** The grasshopper refrence id of the output */
22
8
  id: string;
23
9
  }
24
- /**
25
- * Grasshopper-style data tree for input defaults
26
- * @example
27
- * ```typescript
28
- * const numericTree: DataTreeDefault<number> = {
29
- * "{0}": [1, 2, 3],
30
- * "{0;0}": [4, 5],
31
- * "{1}": [6]
32
- * };
33
- * ```
34
- */
35
10
  type DataTreeDefault<T = any> = {
36
11
  [K in DataTreePath]?: T[];
37
12
  };
38
- /**
39
- * Data structure for InnerTreeData matching Rhino Compute responses
40
- */
41
13
  type InnerTreeData = {
42
14
  [path in DataTreePath]: DataItem[];
43
15
  };
44
16
  /**
45
- * Tree with parameter metadata (used in compute responses)
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.
46
30
  */
47
31
  interface DataTree {
32
+ /** PascalCase — stock mcneel servers, and the request shape this client sends. */
48
33
  InnerTree: InnerTreeData;
34
+ /** PascalCase — stock mcneel servers, and the request shape this client sends. */
49
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;
50
40
  }
51
- /**
52
- * Output types supported from Grasshopper/Rhino Compute
53
- */
54
- 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;
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 & {});
55
42
  /**
56
43
  * Union type for all possible default value types
57
44
  */
@@ -207,11 +194,24 @@ interface GrasshopperRequestSchema extends GrasshopperBaseSchema, GrasshopperDef
207
194
  /**
208
195
  * Response from Grasshopper compute server
209
196
  * Includes all schema fields + computed results
197
+ *
198
+ * `pointer` is deliberately excluded (`Omit`): the solve layer (`runSolve` in
199
+ * `solve.ts`) splits the server's echoed `pointer` off as the solve's
200
+ * `cacheKey` and strips it from the returned response, so client-returned
201
+ * responses never carry it.
202
+ *
203
+ * The schema-echo fields (`cachesolve`/`modelunits`/`dataversion`) stay
204
+ * optional as inherited from {@link GrasshopperBaseSchema}: the server echoes
205
+ * them back when set, but nothing client-side enforces their presence — don't
206
+ * rely on them without a fallback.
210
207
  */
211
- interface GrasshopperComputeResponse extends GrasshopperBaseSchema, GrasshopperDefinitionSource {
212
- /** Whether cache was used (always present in response) */
213
- cachesolve: boolean;
214
- /** Model units (always present in response) */
208
+ interface GrasshopperComputeResponse extends GrasshopperBaseSchema, Omit<GrasshopperDefinitionSource, 'pointer'> {
209
+ /**
210
+ * Model units the definition was solved in. Every conforming server response
211
+ * carries this (it drives downstream scaling, e.g. the webdisplay parser),
212
+ * but note it is not validated client-side — a non-conforming server or
213
+ * hand-built mock may omit it at runtime.
214
+ */
215
215
  modelunits: RhinoModelUnit;
216
216
  /**
217
217
  * The server echoes the request's full base64 definition back as `algo`, but the client strips
@@ -222,8 +222,6 @@ interface GrasshopperComputeResponse extends GrasshopperBaseSchema, GrasshopperD
222
222
  algo?: string | null;
223
223
  /** Filename of the definition (always present in response) */
224
224
  filename: string | null;
225
- /** Data version */
226
- dataversion: 7 | 8;
227
225
  /** Recursion level used */
228
226
  recursionlevel?: number;
229
227
  /** Output values organized by parameter */
@@ -332,14 +330,9 @@ interface GrasshopperParsedIO {
332
330
  }
333
331
 
334
332
  /**
335
- * Non-mesh display items: curves, points, and later labels/icons.
336
- *
337
- * These ride as JSON inside a {@link DisplayBatch} alongside the binary mesh blob — they are a
338
- * separate pipeline from the SLVA mesh path in `../webdisplay`. Curves arrive as Rhino-native JSON
339
- * (decoded via rhino3dm and tessellated on the web); points arrive as raw `{X,Y,Z}` positions.
340
- *
341
- * The union is STRICT and discriminated on `kind`. The parser narrows on it and uses a
342
- * `never`-exhaustiveness check, so adding a new kind is a compile error until it is handled.
333
+ * Non-mesh display items: curves and points. Ride as JSON inside {@link DisplayBatch} alongside
334
+ * the binary mesh blob. The union is STRICT and discriminated on `kind`; the parser uses a
335
+ * `never`-exhaustiveness check, so adding a new kind is a compile error until handled.
343
336
  */
344
337
  /**
345
338
  * Identity + tagging shared by every display thing — meshes (via an adapter over `MeshMetadata`)
@@ -367,7 +360,10 @@ interface DisplayItemBase extends DisplayIdentity {
367
360
  /** Opacity 0–1. Omitted means fully opaque. */
368
361
  opacity?: number;
369
362
  }
370
- /** A world position in Rhino's Z-up frame, in Rhino's `{X,Y,Z}` casing. Rotated to Three on parse. */
363
+ /**
364
+ * A world position in Rhino's Z-up frame, in Rhino's `{X,Y,Z}` casing. Used unchanged on parse —
365
+ * the Three scene IS Rhino's Z-up frame, so no rotation is applied (see `../coordinate-transform.ts`).
366
+ */
371
367
  interface DisplayPosition {
372
368
  X: number;
373
369
  Y: number;
@@ -390,7 +386,7 @@ interface DisplayCurve extends DisplayItemBase {
390
386
  /** A single point, shipped raw (no rhino3dm decode), rendered as one vertex of a `THREE.Points`. */
391
387
  interface DisplayPoint extends DisplayItemBase {
392
388
  kind: 'point';
393
- /** World position in Rhino Z-up; the shared Rhino→Three transform is applied on parse. */
389
+ /** World position in Rhino Z-up, used directly — the Three scene shares Rhino's Z-up frame. */
394
390
  position: DisplayPosition;
395
391
  }
396
392
  /**
@@ -421,11 +417,17 @@ interface SerializableMaterial {
421
417
  * Metadata for a single mesh within a batch.
422
418
  *
423
419
  * Offsets and counts are expressed in **vertex-count units** (not float components) and
424
- * **index-count units**. To address the typed-array storage:
425
- * - vertex component offset = `vertexStart * 3`
426
- * - vertex component count = `vertexCount * 3`
427
- * - index byte offset = `indexStart * 4`
428
- * - index count = `indexCount`
420
+ * **index-count units** — i.e. element offsets into the decoded typed arrays, which is how
421
+ * consumers address them (`indices.subarray(indexStart, indexStart + indexCount)`). To address
422
+ * the typed-array storage:
423
+ * - vertex component offset = `vertexStart * 3`
424
+ * - vertex component count = `vertexCount * 3`
425
+ * - index element offset = `indexStart`
426
+ * - index count = `indexCount`
427
+ *
428
+ * If you need *byte* offsets, multiply by the element size, which depends on the blob's flags:
429
+ * indices are 2 bytes each for `FLAG_UINT16_INDICES` (wire v2+) blobs and 4 bytes for uint32
430
+ * blobs; vertex components are 2 bytes (int16 quantized) or 4 bytes (`FLAG_FLOAT32`).
429
431
  */
430
432
  interface MeshMetadata {
431
433
  name: string;
@@ -468,11 +470,8 @@ interface MaterialGroup {
468
470
  * later labels/icons) also travel — those ride as JSON alongside the mesh blob, not inside it.
469
471
  */
470
472
  interface DisplayBatch {
471
- /** Array of unique materials */
472
473
  materials: SerializableMaterial[];
473
- /** Groups of meshes organized by material */
474
474
  groups: MaterialGroup[];
475
- /** Base64-encoded binary blob (SLVA wire format). */
476
475
  compressedData: string;
477
476
  /** InstanceGuid of the WebDisplay GH component that produced this batch.
478
477
  * Combined with MeshMetadata.originalIndex to backtrack any mesh to its GH source. */
@@ -490,20 +489,17 @@ interface DisplayBatch {
490
489
  * This alias keeps existing imports compiling; remove it once consumers migrate.
491
490
  */
492
491
  type MeshBatch = DisplayBatch;
493
- /**
494
- * Options for parsing mesh batch data.
495
- */
496
492
  interface MeshBatchParsingOptions {
497
- /** Merge meshes with same material into single geometry (better performance). Defaults to true. */
493
+ /** Merge meshes with same material into single geometry. Defaults to true. */
498
494
  mergeByMaterial?: boolean;
499
- /** Apply coordinate system transformations (Rhino Z-up to Three.js Y-up). Defaults to true. */
495
+ /** Apply coordinate system transformations. Defaults to true. */
500
496
  applyTransforms?: boolean;
501
- /** Enable performance monitoring in console. Defaults to false. */
497
+ /** Enable performance monitoring. Defaults to false. */
502
498
  debug?: boolean;
503
499
  /**
504
- * Appearance dials applied to every material built from this batch. These drive how "rendered"
500
+ * Appearance dials applied to every material built from this batch. These drive how "studio"
505
501
  * 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`.
502
+ * per solve). Runtime restyling of an already-built scene lives in the viewer's `setLook`.
507
503
  */
508
504
  material?: MaterialAppearanceOptions;
509
505
  }