@selvajs/compute 3.1.0-beta.1 → 3.1.0-beta.11

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 (61) hide show
  1. package/LICENSE +21 -0
  2. package/dist/chunk-7XMD5YXP.cjs +62 -0
  3. package/dist/chunk-7XMD5YXP.cjs.map +1 -0
  4. package/dist/chunk-C7P43VZF.js +2 -0
  5. package/dist/chunk-C7P43VZF.js.map +1 -0
  6. package/dist/chunk-CUQQ3ZBV.cjs +4 -0
  7. package/dist/chunk-CUQQ3ZBV.cjs.map +1 -0
  8. package/dist/chunk-PX2YTSHJ.js +62 -0
  9. package/dist/chunk-PX2YTSHJ.js.map +1 -0
  10. package/dist/chunk-QZECCPT3.cjs +2 -0
  11. package/dist/chunk-QZECCPT3.cjs.map +1 -0
  12. package/dist/chunk-WPB2LKCD.js +4 -0
  13. package/dist/chunk-WPB2LKCD.js.map +1 -0
  14. package/dist/core.cjs +1 -1
  15. package/dist/core.cjs.map +1 -1
  16. package/dist/core.d.cts +40 -3
  17. package/dist/core.d.ts +40 -3
  18. package/dist/core.js +1 -1
  19. package/dist/grasshopper.cjs +1 -1
  20. package/dist/grasshopper.cjs.map +1 -1
  21. package/dist/grasshopper.d.cts +222 -32
  22. package/dist/grasshopper.d.ts +222 -32
  23. package/dist/grasshopper.js +1 -1
  24. package/dist/{handle-files-9pkEgDIp.d.ts → handle-files-BISo_wob.d.cts} +51 -67
  25. package/dist/{handle-files-9pkEgDIp.d.cts → handle-files-BISo_wob.d.ts} +51 -67
  26. package/dist/index.cjs +1 -1
  27. package/dist/index.cjs.map +1 -1
  28. package/dist/index.d.cts +4 -4
  29. package/dist/index.d.ts +4 -4
  30. package/dist/index.js +1 -1
  31. package/dist/types-BGhtYxZ-.d.cts +45 -0
  32. package/dist/types-BGhtYxZ-.d.ts +45 -0
  33. package/dist/{types-DK2-skCK.d.cts → types-C8XWc4Ab.d.cts} +92 -67
  34. package/dist/{types-jb_K_a0s.d.ts → types-Dtok-mVq.d.ts} +92 -67
  35. package/dist/visualization-4RSUYQG2.cjs +2 -0
  36. package/dist/visualization-4RSUYQG2.cjs.map +1 -0
  37. package/dist/visualization-MOYO6MDN.js +2 -0
  38. package/dist/visualization.cjs +1 -1
  39. package/dist/visualization.cjs.map +1 -1
  40. package/dist/visualization.d.cts +200 -37
  41. package/dist/visualization.d.ts +200 -37
  42. package/dist/visualization.js +1 -1
  43. package/package.json +3 -3
  44. package/dist/chunk-C2HJB4MH.js +0 -55
  45. package/dist/chunk-C2HJB4MH.js.map +0 -1
  46. package/dist/chunk-DRG5SLIP.cjs +0 -4
  47. package/dist/chunk-DRG5SLIP.cjs.map +0 -1
  48. package/dist/chunk-ESPPM542.js +0 -2
  49. package/dist/chunk-ESPPM542.js.map +0 -1
  50. package/dist/chunk-J3MFKB33.js +0 -4
  51. package/dist/chunk-J3MFKB33.js.map +0 -1
  52. package/dist/chunk-LP7LO5PR.cjs +0 -2
  53. package/dist/chunk-LP7LO5PR.cjs.map +0 -1
  54. package/dist/chunk-QZ573TYU.cjs +0 -55
  55. package/dist/chunk-QZ573TYU.cjs.map +0 -1
  56. package/dist/types-ChF690kY.d.cts +0 -88
  57. package/dist/types-ChF690kY.d.ts +0 -88
  58. package/dist/visualization-3E3Q76VG.cjs +0 -2
  59. package/dist/visualization-3E3Q76VG.cjs.map +0 -1
  60. package/dist/visualization-XBMHHG6L.js +0 -2
  61. /package/dist/{visualization-XBMHHG6L.js.map → visualization-MOYO6MDN.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 _chunkLP7LO5PRcjs = require('./chunk-LP7LO5PR.cjs');var _chunkDRG5SLIPcjs = require('./chunk-DRG5SLIP.cjs');exports.ComputeServerStats = _chunkDRG5SLIPcjs.n; exports.ErrorCodes = _chunkDRG5SLIPcjs.c; exports.GrasshopperClient = _chunkLP7LO5PRcjs.c; exports.GrasshopperResponseProcessor = _chunkLP7LO5PRcjs.d; exports.RhinoComputeError = _chunkDRG5SLIPcjs.d; exports.SolveScheduler = _chunkLP7LO5PRcjs.b; exports.TreeBuilder = _chunkLP7LO5PRcjs.i; exports.camelcaseKeys = _chunkDRG5SLIPcjs.p; exports.downloadFileData = _chunkDRG5SLIPcjs.r; exports.enableDebugLogging = _chunkDRG5SLIPcjs.g; exports.extractFilesFromComputeResponse = _chunkDRG5SLIPcjs.q; exports.fetchDefinitionIO = _chunkLP7LO5PRcjs.g; exports.fetchParsedDefinitionIO = _chunkLP7LO5PRcjs.h; exports.fetchRhinoCompute = _chunkDRG5SLIPcjs.l; exports.getLogger = _chunkDRG5SLIPcjs.e; exports.processInput = _chunkLP7LO5PRcjs.e; exports.processInputs = _chunkLP7LO5PRcjs.f; exports.setLogger = _chunkDRG5SLIPcjs.f; exports.solveGrasshopperDefinition = _chunkLP7LO5PRcjs.a; exports.toCamelCase = _chunkDRG5SLIPcjs.o;
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunkQZECCPT3cjs = require('./chunk-QZECCPT3.cjs');var _chunkCUQQ3ZBVcjs = require('./chunk-CUQQ3ZBV.cjs');exports.ComputeServerStats = _chunkCUQQ3ZBVcjs.n; exports.ErrorCodes = _chunkCUQQ3ZBVcjs.c; exports.GrasshopperClient = _chunkQZECCPT3cjs.g; exports.GrasshopperResponseProcessor = _chunkQZECCPT3cjs.h; exports.RhinoComputeError = _chunkCUQQ3ZBVcjs.d; exports.SolveScheduler = _chunkQZECCPT3cjs.f; exports.TreeBuilder = _chunkQZECCPT3cjs.m; exports.camelcaseKeys = _chunkCUQQ3ZBVcjs.p; exports.downloadFileData = _chunkCUQQ3ZBVcjs.t; exports.enableDebugLogging = _chunkCUQQ3ZBVcjs.g; exports.extractFilesFromComputeResponse = _chunkCUQQ3ZBVcjs.s; exports.fetchDefinitionIO = _chunkQZECCPT3cjs.k; exports.fetchParsedDefinitionIO = _chunkQZECCPT3cjs.l; exports.fetchRhinoCompute = _chunkCUQQ3ZBVcjs.l; exports.getLogger = _chunkCUQQ3ZBVcjs.e; exports.hashDefinition = _chunkQZECCPT3cjs.e; exports.hashSolveInput = _chunkQZECCPT3cjs.d; exports.isDefinitionRef = _chunkQZECCPT3cjs.a; exports.processInput = _chunkQZECCPT3cjs.i; exports.processInputs = _chunkQZECCPT3cjs.j; exports.setLogger = _chunkCUQQ3ZBVcjs.f; exports.solveGrasshopperDefinition = _chunkQZECCPT3cjs.b; exports.stableStringify = _chunkQZECCPT3cjs.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/selva/packages/compute/dist/index.cjs"],"names":[],"mappings":"AAAA,iIAA4H,wDAAqG,moCAA4hB","file":"/home/runner/work/selva/selva/packages/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-ChF690kY.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-DK2-skCK.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-ChF690kY.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-jb_K_a0s.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-ESPPM542.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-J3MFKB33.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-C7P43VZF.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-ChF690kY.cjs';
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,18 +194,34 @@ 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
- /** Base64 encoded algorithm (always present in response) */
217
- algo: string;
216
+ /**
217
+ * The server echoes the request's full base64 definition back as `algo`, but the client strips
218
+ * it before returning — retaining it would pin a multi-MB copy of the definition per response,
219
+ * multiplied by every cache that holds responses. Always `undefined` on client-returned
220
+ * responses (inherited optional field from {@link GrasshopperDefinitionSource}).
221
+ */
222
+ algo?: string | null;
218
223
  /** Filename of the definition (always present in response) */
219
224
  filename: string | null;
220
- /** Data version */
221
- dataversion: 7 | 8;
222
225
  /** Recursion level used */
223
226
  recursionlevel?: number;
224
227
  /** Output values organized by parameter */
@@ -327,14 +330,9 @@ interface GrasshopperParsedIO {
327
330
  }
328
331
 
329
332
  /**
330
- * Non-mesh display items: curves, points, and later labels/icons.
331
- *
332
- * These ride as JSON inside a {@link DisplayBatch} alongside the binary mesh blob — they are a
333
- * separate pipeline from the SLVA mesh path in `../webdisplay`. Curves arrive as Rhino-native JSON
334
- * (decoded via rhino3dm and tessellated on the web); points arrive as raw `{X,Y,Z}` positions.
335
- *
336
- * The union is STRICT and discriminated on `kind`. The parser narrows on it and uses a
337
- * `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.
338
336
  */
339
337
  /**
340
338
  * Identity + tagging shared by every display thing — meshes (via an adapter over `MeshMetadata`)
@@ -362,7 +360,10 @@ interface DisplayItemBase extends DisplayIdentity {
362
360
  /** Opacity 0–1. Omitted means fully opaque. */
363
361
  opacity?: number;
364
362
  }
365
- /** 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
+ */
366
367
  interface DisplayPosition {
367
368
  X: number;
368
369
  Y: number;
@@ -385,7 +386,7 @@ interface DisplayCurve extends DisplayItemBase {
385
386
  /** A single point, shipped raw (no rhino3dm decode), rendered as one vertex of a `THREE.Points`. */
386
387
  interface DisplayPoint extends DisplayItemBase {
387
388
  kind: 'point';
388
- /** 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. */
389
390
  position: DisplayPosition;
390
391
  }
391
392
  /**
@@ -416,11 +417,17 @@ interface SerializableMaterial {
416
417
  * Metadata for a single mesh within a batch.
417
418
  *
418
419
  * Offsets and counts are expressed in **vertex-count units** (not float components) and
419
- * **index-count units**. To address the typed-array storage:
420
- * - vertex component offset = `vertexStart * 3`
421
- * - vertex component count = `vertexCount * 3`
422
- * - index byte offset = `indexStart * 4`
423
- * - 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`).
424
431
  */
425
432
  interface MeshMetadata {
426
433
  name: string;
@@ -463,11 +470,8 @@ interface MaterialGroup {
463
470
  * later labels/icons) also travel — those ride as JSON alongside the mesh blob, not inside it.
464
471
  */
465
472
  interface DisplayBatch {
466
- /** Array of unique materials */
467
473
  materials: SerializableMaterial[];
468
- /** Groups of meshes organized by material */
469
474
  groups: MaterialGroup[];
470
- /** Base64-encoded binary blob (SLVA wire format). */
471
475
  compressedData: string;
472
476
  /** InstanceGuid of the WebDisplay GH component that produced this batch.
473
477
  * Combined with MeshMetadata.originalIndex to backtrack any mesh to its GH source. */
@@ -485,16 +489,37 @@ interface DisplayBatch {
485
489
  * This alias keeps existing imports compiling; remove it once consumers migrate.
486
490
  */
487
491
  type MeshBatch = DisplayBatch;
488
- /**
489
- * Options for parsing mesh batch data.
490
- */
491
492
  interface MeshBatchParsingOptions {
492
- /** 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. */
493
494
  mergeByMaterial?: boolean;
494
- /** Apply coordinate system transformations (Rhino Z-up to Three.js Y-up). Defaults to true. */
495
+ /** Apply coordinate system transformations. Defaults to true. */
495
496
  applyTransforms?: boolean;
496
- /** Enable performance monitoring in console. Defaults to false. */
497
+ /** Enable performance monitoring. Defaults to false. */
497
498
  debug?: boolean;
499
+ /**
500
+ * Appearance dials applied to every material built from this batch. These drive how "studio"
501
+ * vs "matte technical" the meshes look; they are set once at parse time (materials are rebuilt
502
+ * per solve). Runtime restyling of an already-built scene lives in the viewer's `setLook`.
503
+ */
504
+ material?: MaterialAppearanceOptions;
505
+ }
506
+ /**
507
+ * How compute meshes read visually. Bundled so a caller can pick a coherent look ('technical' vs
508
+ * 'rendered') by setting all three together rather than dialing each in isolation.
509
+ */
510
+ interface MaterialAppearanceOptions {
511
+ /**
512
+ * Multiplier on the HDR image-based-lighting reflection strength. ~0.5 reads matte/technical,
513
+ * ~1.3 reads glossy/presentation. Default 1 (three.js's own default — unchanged look).
514
+ */
515
+ envMapIntensity?: number;
516
+ /**
517
+ * Cull back faces (`THREE.FrontSide`) instead of rendering both sides (`THREE.DoubleSide`).
518
+ * FrontSide gives cleaner interior shading, a crisper silhouette, and less overdraw on closed
519
+ * solids — but open surfaces (which Rhino also emits) then vanish when viewed from behind.
520
+ * Default false (keep DoubleSide) to stay safe for surface geometry.
521
+ */
522
+ cullBackfaces?: boolean;
498
523
  }
499
524
  /**
500
525
  * Options for extracting and processing meshes from compute responses.
@@ -515,4 +540,4 @@ interface MeshExtractionOptions {
515
540
  debug?: boolean;
516
541
  }
517
542
 
518
- export type { BooleanInputType as B, DataItem as D, FileInputType as F, GeometryInputType as G, InnerTreeData as I, MeshExtractionOptions as M, NumericInputType as N, OutputParamSchema as O, TextInputType as T, ValueListInputType as V, DataTree as a, DataTreeDefault as b, DataTreePath as c, DefaultValue as d, GrasshopperComputeConfig as e, GrasshopperComputeResponse as f, GrasshopperParsedIO as g, GrasshopperParsedIORaw as h, GrasshopperRequestSchema as i, InputParam as j, InputParamSchema as k, OutputType as l, MeshBatchParsingOptions as m, DisplayBatch as n, DisplayItem as o, DisplayCurve as p, DisplayIdentity as q, DisplayItemBase as r, DisplayPoint as s, DisplayPosition as t, MeshBatch as u };
543
+ export type { BooleanInputType as B, DataItem as D, FileInputType as F, GeometryInputType as G, InnerTreeData as I, MaterialAppearanceOptions as M, NumericInputType as N, OutputParamSchema as O, TextInputType as T, ValueListInputType as V, DataTree as a, DataTreeDefault as b, DataTreePath as c, DefaultValue as d, GrasshopperComputeConfig as e, GrasshopperComputeResponse as f, GrasshopperParsedIO as g, GrasshopperParsedIORaw as h, GrasshopperRequestSchema as i, InputParam as j, InputParamSchema as k, OutputType as l, MeshExtractionOptions as m, MeshBatchParsingOptions as n, DisplayBatch as o, DisplayItem as p, DisplayCurve as q, DisplayIdentity as r, DisplayItemBase as s, DisplayPoint as t, DisplayPosition as u, MeshBatch as v };