selva-compute 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (57) hide show
  1. package/LICENSE.md +21 -0
  2. package/README.md +110 -0
  3. package/dist/base-DbB0Ggdq.d.cts +118 -0
  4. package/dist/base-DbB0Ggdq.d.ts +118 -0
  5. package/dist/chunk-24EXIE4G.js +3 -0
  6. package/dist/chunk-24EXIE4G.js.map +1 -0
  7. package/dist/chunk-5DJRUPGI.cjs +2 -0
  8. package/dist/chunk-5DJRUPGI.cjs.map +1 -0
  9. package/dist/chunk-AEQTQHPY.js +2 -0
  10. package/dist/chunk-AEQTQHPY.js.map +1 -0
  11. package/dist/chunk-JJLRDYYP.js +2 -0
  12. package/dist/chunk-JJLRDYYP.js.map +1 -0
  13. package/dist/chunk-OXD76DAK.js +2 -0
  14. package/dist/chunk-OXD76DAK.js.map +1 -0
  15. package/dist/chunk-P57VU27W.cjs +3 -0
  16. package/dist/chunk-P57VU27W.cjs.map +1 -0
  17. package/dist/chunk-PNG3L5TM.cjs +2 -0
  18. package/dist/chunk-PNG3L5TM.cjs.map +1 -0
  19. package/dist/chunk-TVCJBLSW.cjs +2 -0
  20. package/dist/chunk-TVCJBLSW.cjs.map +1 -0
  21. package/dist/core.cjs +2 -0
  22. package/dist/core.cjs.map +1 -0
  23. package/dist/core.d.cts +114 -0
  24. package/dist/core.d.ts +114 -0
  25. package/dist/core.js +2 -0
  26. package/dist/core.js.map +1 -0
  27. package/dist/files.cjs +2 -0
  28. package/dist/files.cjs.map +1 -0
  29. package/dist/files.d.cts +34 -0
  30. package/dist/files.d.ts +34 -0
  31. package/dist/files.js +2 -0
  32. package/dist/files.js.map +1 -0
  33. package/dist/grasshopper.cjs +2 -0
  34. package/dist/grasshopper.cjs.map +1 -0
  35. package/dist/grasshopper.d.cts +741 -0
  36. package/dist/grasshopper.d.ts +741 -0
  37. package/dist/grasshopper.js +2 -0
  38. package/dist/grasshopper.js.map +1 -0
  39. package/dist/index.cjs +2 -0
  40. package/dist/index.cjs.map +1 -0
  41. package/dist/index.d.cts +8 -0
  42. package/dist/index.d.ts +8 -0
  43. package/dist/index.js +2 -0
  44. package/dist/index.js.map +1 -0
  45. package/dist/schemas-5LuPKgX2.d.cts +202 -0
  46. package/dist/schemas-5LuPKgX2.d.ts +202 -0
  47. package/dist/types-SwbLAMW8.d.cts +27 -0
  48. package/dist/types-SwbLAMW8.d.ts +27 -0
  49. package/dist/types-r00wVwfo.d.cts +77 -0
  50. package/dist/types-r00wVwfo.d.ts +77 -0
  51. package/dist/visualization.cjs +2 -0
  52. package/dist/visualization.cjs.map +1 -0
  53. package/dist/visualization.d.cts +202 -0
  54. package/dist/visualization.d.ts +202 -0
  55. package/dist/visualization.js +2 -0
  56. package/dist/visualization.js.map +1 -0
  57. package/package.json +117 -0
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["/Users/felix/coding/selva-compute/dist/chunk-PNG3L5TM.cjs","../src/features/grasshopper/client/grasshopper-client.ts","../src/features/grasshopper/io/output/rhino-decoder.ts","../src/features/grasshopper/io/output/response-processors.ts","../src/features/grasshopper/client/grasshopper-response-processor.ts","../src/core/utils/warnings.ts","../src/features/grasshopper/compute/solve.ts","../src/core/utils/camel-case.ts","../src/features/grasshopper/io/input/input-processors.ts","../src/core/errors/error-factory.ts"],"names":["init_errors","init_base","init_logger","GrasshopperClient","_GrasshopperClient","config","__publicField","ComputeServerStats","client","RhinoComputeError","ErrorCodes","definition","fetchParsedDefinitionIO","fetchDefinitionIO","dataTree","result","solveGrasshopperDefinition","error","getLogger","decoderRegistry","registerDecoder","typeName","decoder","rhino","data","d","findDecoder","rhinoType","key","dec","extractPayload","parsedData","decodeRhinoGeometry","payload","SYSTEM_TYPES","EXCLUDED_TYPES","RHINO_GEOMETRY_PREFIX","FILE_DATA_TYPE","isExcludedType","type","t","tryDecodeJSON","value","trimmed","first","decodeBySystemType","raw","extractItemValue","parseValues","forEachTreeItem","tree","handler","list","item","getValues","response","byId","options","stringOnly","param","extractFileData","output","parsed","getValue","parseOptions","targetParam","p","found","collected","v","GrasshopperResponseProcessor","debug","paramName","paramId","mergedOptions","getThreeMeshesFromComputeResponse","folderName","additionalFiles","files","downloadFileData","warnIfClientSide","functionName","suppress","args","prepareGrasshopperArgs","applyOptionalComputeSettings","fetchRhinoCompute","base64ByteArray","isBase64","encodeStringToBase64","arglist","toCamelCase","str","preserveSpaces","s","_","c","m","camelcaseKeys","obj","camelKey","init_error_codes","ValidationErrors","inputName","reason"],"mappings":"AAAA,2/BAAwC,wDAAuD,wDAAoH,iCCAnNA,CAAAA,CACAC,iCAAAA,CAAAA,CACAC,iCAAAA,CAAAA,CA8BA,IAAqBC,CAAAA,CAArB,MAAqBC,CAAkB,CAK9B,WAAA,CAAYC,CAAAA,CAAkC,CAJtDC,iCAAAA,IAAA,CAAiB,QAAA,CAAA,CACjBA,iCAAAA,IAAA,CAAgB,aAAA,CAAA,CAChBA,iCAAAA,IAAA,CAAQ,UAAA,CAAW,CAAA,CAAA,CAAA,CAGlB,IAAA,CAAK,MAAA,CAAS,IAAA,CAAK,sBAAA,CAAuBD,CAAM,CAAA,CAChD,IAAA,CAAK,WAAA,CAAc,IAAIE,wBAAAA,CAAmB,IAAA,CAAK,MAAA,CAAO,SAAA,CAAW,IAAA,CAAK,MAAA,CAAO,MAAM,CACpF,CAQA,OAAA,MAAa,MAAA,CAAOF,CAAAA,CAA8D,CACjF,IAAMG,CAAAA,CAAS,IAAIJ,CAAAA,CAAkBC,CAAM,CAAA,CAG3C,EAAA,CAAI,CAAE,MAAMG,CAAAA,CAAO,WAAA,CAAY,cAAA,CAAe,CAAA,CAC7C,MAAM,IAAIC,wBAAAA,CAAkB,oCAAA,CAAsCC,mBAAAA,CAAW,aAAA,CAAe,CAC3F,OAAA,CAAS,CAAE,SAAA,CAAWF,CAAAA,CAAO,MAAA,CAAO,SAAU,CAC/C,CAAC,CAAA,CAGF,OAAOA,CACR,CAMO,SAAA,CAAA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AWT,EAAAA,CAAY/D,CAAAA,CAAK,CAAE,cAAA,CAAgB6B,CAAAA,CAAQ,cAAe,CAAC,CAAA,CACtEf,CAAAA,CAASyD,CAAAA,CAAYvE,CAAG,CAAA,CAC9B,OAACb,CAAAA,CAAeqF,CAAQ,CAAA,CAAI3C,CAAAA,CAAQ,IAAA,CAAOyC,CAAAA,CAAcxD,CAAAA,CAAOe,CAAO,CAAA,CAAIf,CAAAA,CACpE3B,CACR,CAAA,CACA,CAAC,CACF,CACD,CCtDAf,iCAAAA,CAAAA,CCAAC,iCAAAA,CAAAA,CACAoG,iCAAAA,CAAAA,CAyBO,IAAMC,CAAAA,CAAmB,CAI/B,OAAA,CAAS,CAACC,CAAAA,CAAmBC,CAAAA,CAAgB/C,CAAAA,CAAAA,EAC5C,IAAIhD,wBAAAA,CAAkB,CAAA,OAAA,EAAU8F,CAAS,CAAA,GAAA,EAAMC,CAAM,CAAA,CAAA","file":"/Users/felix/coding/selva-compute/dist/chunk-PNG3L5TM.cjs","sourcesContent":[null,"import { ErrorCodes } from '@/core/errors';\nimport { RhinoComputeError } from '@/core/errors/base';\nimport { getLogger } from '@/core/utils/logger';\nimport ComputeServerStats from '@/core/server/compute-server-stats';\nimport { ComputeConfig } from '@/core/types';\n\nimport { fetchDefinitionIO, fetchParsedDefinitionIO, solveGrasshopperDefinition } from '..';\nimport { GrasshopperComputeConfig, GrasshopperComputeResponse, DataTree } from '../types';\n\n/**\n * GrasshopperClient provides a simple API for interacting with a Rhino Compute server and grasshopper.\n *\n * @public This is the recommended high-level API for Rhino Compute operations.\n *\n * **Security Warning:**\n * Using this client in a browser environment exposes your server URL and API key to users.\n * For production, use this library server-side or proxy requests through your own backend.\n *\n * @example\n * ```typescript\n * const client = await GrasshopperClient.create({\n * serverUrl: 'http://localhost:6500',\n * apiKey: 'your-api-key'\n * });\n *\n * try {\n * const result = await client.solve(definitionUrl, { x: 1, y: 2 });\n * } finally {\n * await client.dispose(); // Clean up resources\n * }\n * ```\n */\nexport default class GrasshopperClient {\n\tprivate readonly config: GrasshopperComputeConfig;\n\tpublic readonly serverStats: ComputeServerStats;\n\tprivate disposed = false;\n\n\tprivate constructor(config: GrasshopperComputeConfig) {\n\t\tthis.config = this.normalizeComputeConfig(config);\n\t\tthis.serverStats = new ComputeServerStats(this.config.serverUrl, this.config.apiKey);\n\t}\n\n\t/**\n\t * Creates and initializes a GrasshopperClient with server validation.\n\t *\n\t * @throws {RhinoComputeError} with code NETWORK_ERROR if server is offline\n\t * @throws {RhinoComputeError} with code INVALID_CONFIG if configuration is invalid\n\t */\n\tstatic async create(config: GrasshopperComputeConfig): Promise<GrasshopperClient> {\n\t\tconst client = new GrasshopperClient(config);\n\n\t\t// Check server is online before returning\n\t\tif (!(await client.serverStats.isServerOnline())) {\n\t\t\tthrow new RhinoComputeError('Rhino Compute server is not online', ErrorCodes.NETWORK_ERROR, {\n\t\t\t\tcontext: { serverUrl: client.config.serverUrl }\n\t\t\t});\n\t\t}\n\n\t\treturn client;\n\t}\n\n\t/**\n\t * Gets the client's configuration.\n\t * Useful for passing to lower-level functions.\n\t */\n\tpublic getConfig(): GrasshopperComputeConfig {\n\t\tthis.ensureNotDisposed();\n\t\treturn { ...this.config };\n\t}\n\n\t/**\n\t * Get input/output parameters of a Grasshopper definition.\n\t */\n\tpublic async getIO(definition: string | Uint8Array) {\n\t\tthis.ensureNotDisposed();\n\t\treturn fetchParsedDefinitionIO(definition, this.config);\n\t}\n\n\tpublic async getRawIO(definition: string | Uint8Array) {\n\t\tthis.ensureNotDisposed();\n\t\treturn fetchDefinitionIO(definition, this.config);\n\t}\n\n\t/**\n\t * Run a compute job with a Grasshopper definition.\n\t *\n\t * @throws {RhinoComputeError} with code INVALID_INPUT if definition is empty\n\t * @throws {RhinoComputeError} with code NETWORK_ERROR if server is offline\n\t * @throws {RhinoComputeError} with code COMPUTATION_ERROR if computation fails\n\t */\n\tpublic async solve(\n\t\tdefinition: string | Uint8Array,\n\t\tdataTree: DataTree[]\n\t): Promise<GrasshopperComputeResponse> {\n\t\tthis.ensureNotDisposed();\n\n\t\ttry {\n\t\t\t// Validate inputs\n\t\t\tif (typeof definition === 'string' && !definition?.trim()) {\n\t\t\t\tthrow new RhinoComputeError(\n\t\t\t\t\t'Definition URL/content is required',\n\t\t\t\t\tErrorCodes.INVALID_INPUT,\n\t\t\t\t\t{\n\t\t\t\t\t\tcontext: { receivedUrl: definition }\n\t\t\t\t\t}\n\t\t\t\t);\n\t\t\t} else if (definition instanceof Uint8Array && definition.length === 0) {\n\t\t\t\tthrow new RhinoComputeError('Definition content is empty', ErrorCodes.INVALID_INPUT);\n\t\t\t}\n\n\t\t\t// Check server\n\t\t\tif (!(await this.serverStats.isServerOnline())) {\n\t\t\t\tthrow new RhinoComputeError(\n\t\t\t\t\t'Rhino Compute server is not online',\n\t\t\t\t\tErrorCodes.NETWORK_ERROR,\n\t\t\t\t\t{ context: { serverUrl: this.config.serverUrl } }\n\t\t\t\t);\n\t\t\t}\n\n\t\t\t// Run computation\n\t\t\tconst result = await solveGrasshopperDefinition(dataTree, definition, this.config);\n\n\t\t\t// Check for errors\n\t\t\tif (result && typeof result === 'object' && 'message' in result && !('fileData' in result)) {\n\t\t\t\tthrow new RhinoComputeError(\n\t\t\t\t\t(result as { message: string }).message || 'Computation failed',\n\t\t\t\t\tErrorCodes.COMPUTATION_ERROR,\n\t\t\t\t\t{\n\t\t\t\t\t\tcontext: {\n\t\t\t\t\t\t\tdefinition:\n\t\t\t\t\t\t\t\ttypeof definition === 'string' && definition.length < 200\n\t\t\t\t\t\t\t\t\t? definition\n\t\t\t\t\t\t\t\t\t: '...content...',\n\t\t\t\t\t\t\tinputs: dataTree\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t);\n\t\t\t}\n\n\t\t\treturn result;\n\t\t} catch (error) {\n\t\t\tif (this.config.debug) {\n\t\t\t\tgetLogger().error('Compute failed:', error);\n\t\t\t}\n\n\t\t\tif (error instanceof RhinoComputeError) {\n\t\t\t\tthrow error;\n\t\t\t}\n\n\t\t\tthrow new RhinoComputeError(\n\t\t\t\terror instanceof Error ? error.message : String(error),\n\t\t\t\tErrorCodes.COMPUTATION_ERROR,\n\t\t\t\t{\n\t\t\t\t\tcontext: {\n\t\t\t\t\t\tdefinition:\n\t\t\t\t\t\t\ttypeof definition === 'string' && definition.length < 200\n\t\t\t\t\t\t\t\t? definition\n\t\t\t\t\t\t\t\t: '...content...',\n\t\t\t\t\t\tinputs: dataTree\n\t\t\t\t\t},\n\t\t\t\t\toriginalError: error instanceof Error ? error : new Error(String(error))\n\t\t\t\t}\n\t\t\t);\n\t\t}\n\t}\n\n\t/**\n\t * Disposes of client resources.\n\t * Call this when you're done using the client.\n\t */\n\tpublic async dispose(): Promise<void> {\n\t\tif (this.disposed) return;\n\n\t\tthis.disposed = true;\n\n\t\t// If serverStats has a dispose method, call it\n\t\tif ('dispose' in this.serverStats && typeof this.serverStats.dispose === 'function') {\n\t\t\tawait this.serverStats.dispose();\n\t\t}\n\n\t\t// Clear any cached data or connections if needed\n\t}\n\n\t/**\n\t * Ensures the client hasn't been disposed.\n\t */\n\tprivate ensureNotDisposed(): void {\n\t\tif (this.disposed) {\n\t\t\tthrow new RhinoComputeError(\n\t\t\t\t'GrasshopperClient has been disposed and cannot be used',\n\t\t\t\tErrorCodes.INVALID_STATE\n\t\t\t);\n\t\t}\n\t}\n\n\t/**\n\t * Validates and normalizes a compute configuration.\n\t *\n\t * @throws {RhinoComputeError} with code INVALID_CONFIG if configuration is invalid\n\t */\n\tprivate normalizeComputeConfig<T extends ComputeConfig | GrasshopperComputeConfig>(config: T): T {\n\t\tif (!config.serverUrl?.trim()) {\n\t\t\tthrow new RhinoComputeError('serverUrl is required', ErrorCodes.INVALID_CONFIG, {\n\t\t\t\tcontext: { receivedServerUrl: config.serverUrl }\n\t\t\t});\n\t\t}\n\n\t\t// Validate URL format\n\t\ttry {\n\t\t\tnew URL(config.serverUrl);\n\t\t} catch {\n\t\t\tthrow new RhinoComputeError('serverUrl must be a valid URL', ErrorCodes.INVALID_CONFIG, {\n\t\t\t\tcontext: { receivedServerUrl: config.serverUrl }\n\t\t\t});\n\t\t}\n\n\t\t// Validate that it's not the default public endpoint\n\t\tif (config.serverUrl === '' || config.serverUrl === 'https://compute.rhino3d.com/') {\n\t\t\tthrow new RhinoComputeError(\n\t\t\t\t'serverUrl must be set to your Compute server URL. The default public endpoint is not allowed.',\n\t\t\t\tErrorCodes.INVALID_CONFIG,\n\t\t\t\t{ context: { receivedServerUrl: config.serverUrl } }\n\t\t\t);\n\t\t}\n\n\t\treturn {\n\t\t\t...config,\n\t\t\tserverUrl: config.serverUrl.replace(/\\/+$/, ''), // Remove trailing slashes\n\t\t\tapiKey: config.apiKey,\n\t\t\tauthToken: config.authToken,\n\t\t\tdebug: config.debug ?? false,\n\t\t\tsuppressClientSideWarning: config.suppressClientSideWarning\n\t\t} as T;\n\t}\n}\n","import type { RhinoModule } from 'rhino3dm';\nimport { getLogger } from '@/core';\n\n// -----------------------------------------------------------------------------\n// Decoder Types\n// -----------------------------------------------------------------------------\n\ntype RhinoDecoder = (rhino: RhinoModule, data: unknown) => unknown;\n\nconst decoderRegistry = new Map<string, RhinoDecoder>();\n\n// -----------------------------------------------------------------------------\n// Registration\n// -----------------------------------------------------------------------------\n\nexport function registerDecoder(typeName: string, decoder: RhinoDecoder): void {\n\tdecoderRegistry.set(typeName, decoder);\n}\n\nregisterDecoder('Rhino.Geometry.Point3d', (rhino, data) => {\n\tconst d = data as any;\n\tif (!d || typeof d.X !== 'number') return null;\n\treturn new rhino.Point([d.X, d.Y, d.Z]);\n});\n\nregisterDecoder('Rhino.Geometry.Line', (rhino, data) => {\n\tconst d = data as any;\n\tif (!d || !d.From || !d.To) return null;\n\treturn new rhino.Line([d.From.X, d.From.Y, d.From.Z], [d.To.X, d.To.Y, d.To.Z]);\n});\n\n// -----------------------------------------------------------------------------\n// Utility Functions\n// -----------------------------------------------------------------------------\n\nfunction findDecoder(rhinoType: string): RhinoDecoder | undefined {\n\tif (decoderRegistry.has(rhinoType)) return decoderRegistry.get(rhinoType);\n\tfor (const [key, dec] of decoderRegistry) {\n\t\tif (rhinoType.startsWith(key)) return dec;\n\t}\n\treturn undefined;\n}\n\nfunction extractPayload(parsedData: any): any {\n\tif (!parsedData || typeof parsedData !== 'object') return null;\n\treturn (parsedData as any).data ?? (parsedData as any).value ?? null;\n}\n\n// -----------------------------------------------------------------------------\n// Geometry Decoding\n// -----------------------------------------------------------------------------\n\nexport function decodeRhinoGeometry(\n\tparsedData: unknown,\n\trhinoType: string,\n\trhino: RhinoModule\n): unknown {\n\tconst decoder = findDecoder(rhinoType);\n\tif (decoder) {\n\t\ttry {\n\t\t\treturn decoder(rhino, parsedData);\n\t\t} catch (error) {\n\t\t\tgetLogger().warn(`Failed to decode Rhino type ${rhinoType}:`, error);\n\t\t}\n\t}\n\n\t// Fallback using CommonObject.decode\n\ttry {\n\t\tconst payload = extractPayload(parsedData);\n\t\tif (payload) return rhino.CommonObject.decode(payload);\n\t} catch (error) {\n\t\tgetLogger().warn(`Failed to decode ${rhinoType} with CommonObject:`, error);\n\t\treturn { __decodeError: true, type: rhinoType, raw: parsedData };\n\t}\n\n\treturn parsedData;\n}\n\n// -----------------------------------------------------------------------------\n// Object Decoder\n// -----------------------------------------------------------------------------\n\nexport interface DecodeRhinoOptions {\n\tkeys?: string[];\n\tskipKeys?: string[];\n\tdeep?: boolean;\n}\n\nexport function decodeRhinoObject<T extends Record<string, unknown>>(\n\tobj: T,\n\trhino: RhinoModule,\n\toptions: DecodeRhinoOptions = {}\n): T {\n\tconst { keys, skipKeys, deep } = options;\n\tconst out: Record<string, unknown> = { ...obj };\n\n\tconst shouldProcessKey = (k: string) => {\n\t\tif (skipKeys?.includes(k)) return false;\n\t\tif (keys && !keys.includes(k)) return false;\n\t\treturn true;\n\t};\n\n\tfor (const [key, value] of Object.entries(obj)) {\n\t\tif (!shouldProcessKey(key)) continue;\n\t\tif (!value || typeof value !== 'object') continue;\n\n\t\tconst v: any = value;\n\t\tconst maybeType = typeof v.type === 'string' ? v.type : undefined;\n\n\t\tif (maybeType) {\n\t\t\tout[key] = decodeRhinoGeometry(v, maybeType, rhino);\n\t\t\tcontinue;\n\t\t}\n\n\t\tif (deep && typeof v === 'object') {\n\t\t\tout[key] = decodeRhinoObject(v as any, rhino, options);\n\t\t}\n\t}\n\n\treturn out as T;\n}\n","import { FileData } from '../../../file-handling/types';\nimport { GrasshopperComputeResponse, DataItem } from '../../types';\nimport { decodeRhinoGeometry } from './rhino-decoder';\n\nexport interface ParsedContext {\n\t[key: string]: any;\n}\n\nexport interface GetValuesOptions {\n\tparseValues?: boolean;\n\trhino?: any;\n\t/**\n\t * If true, only include values of type System.String in the result.\n\t * Non-string types are filtered out.\n\t */\n\tstringOnly?: boolean;\n}\n\nexport interface GetValuesResult<T = ParsedContext> {\n\tvalues: T;\n}\n\n// -----------------------------------------------------------------------------\n// Constants\n// -----------------------------------------------------------------------------\n\nconst SYSTEM_TYPES = {\n\tSTRING: 'System.String',\n\tINT: 'System.Int32',\n\tDOUBLE: 'System.Double',\n\tBOOL: 'System.Boolean'\n};\n\nconst EXCLUDED_TYPES = ['WebDisplay'];\nconst RHINO_GEOMETRY_PREFIX = 'Rhino.Geometry.';\nconst FILE_DATA_TYPE = 'FileData';\n\n// -----------------------------------------------------------------------------\n// Utilities\n// -----------------------------------------------------------------------------\n\nfunction isExcludedType(type: string): boolean {\n\treturn EXCLUDED_TYPES.some((t) => type.includes(t));\n}\n\nfunction tryDecodeJSON(value: string): any {\n\tif (typeof value !== 'string') return value;\n\n\tconst trimmed = value.trim();\n\tconst looksJson = trimmed.startsWith('{') || trimmed.startsWith('[') || trimmed.startsWith('\"');\n\tif (!looksJson) return value;\n\n\ttry {\n\t\tconst first = JSON.parse(trimmed);\n\t\tif (typeof first === 'string') {\n\t\t\ttry {\n\t\t\t\treturn JSON.parse(first);\n\t\t\t} catch {\n\t\t\t\treturn first;\n\t\t\t}\n\t\t}\n\t\treturn first;\n\t} catch {\n\t\treturn value;\n\t}\n}\n\nfunction decodeBySystemType(raw: any, type: string, rhino?: any): any {\n\tswitch (type) {\n\t\tcase SYSTEM_TYPES.STRING:\n\t\t\tif (typeof raw !== 'string') return raw;\n\t\t\treturn raw.replace(/^\"(.*)\"$/, '$1');\n\n\t\tcase SYSTEM_TYPES.INT:\n\t\t\treturn Number.parseInt(raw, 10);\n\n\t\tcase SYSTEM_TYPES.DOUBLE:\n\t\t\treturn Number.parseFloat(raw);\n\n\t\tcase SYSTEM_TYPES.BOOL: {\n\t\t\tconst str = String(raw).toLowerCase();\n\t\t\treturn str === 'true';\n\t\t}\n\n\t\tdefault:\n\t\t\tif (rhino && type.startsWith(RHINO_GEOMETRY_PREFIX)) {\n\t\t\t\treturn decodeRhinoGeometry(raw, type, rhino);\n\t\t\t}\n\t\t\treturn raw;\n\t}\n}\n\n// Main extractor\nfunction extractItemValue(data: any, type: string, parseValues: boolean, rhino?: any): any {\n\tif (isExcludedType(type)) return null;\n\n\tif (typeof data !== 'string') return data;\n\n\tconst raw = parseValues ? tryDecodeJSON(data) : data;\n\treturn decodeBySystemType(raw, type, rhino);\n}\n\n// Traversal helper\nfunction forEachTreeItem(\n\ttree: GrasshopperComputeResponse['values'][0]['InnerTree'],\n\thandler: (item: DataItem) => void\n) {\n\tfor (const list of Object.values(tree)) {\n\t\tif (Array.isArray(list)) {\n\t\t\tfor (const item of list) handler(item);\n\t\t}\n\t}\n}\n\n// -----------------------------------------------------------------------------\n// Public API\n// -----------------------------------------------------------------------------\n\nexport function getValues<T = ParsedContext>(\n\tresponse: GrasshopperComputeResponse,\n\tbyId: boolean = false,\n\toptions: GetValuesOptions = {}\n): GetValuesResult<T> {\n\tconst { parseValues = true, rhino, stringOnly = false } = options;\n\tconst result: ParsedContext = {};\n\n\tfor (const param of response.values) {\n\t\tforEachTreeItem(param.InnerTree, (item) => {\n\t\t\t// Skip non-string types if stringOnly is enabled\n\t\t\tif (stringOnly && item.type !== SYSTEM_TYPES.STRING) return;\n\n\t\t\tconst key = byId ? item.id : param.ParamName;\n\t\t\tif (!key) return;\n\n\t\t\tconst value = extractItemValue(item.data, item.type, parseValues, rhino);\n\n\t\t\tif (result[key] === undefined) {\n\t\t\t\tresult[key] = value;\n\t\t\t} else if (Array.isArray(result[key])) {\n\t\t\t\tresult[key].push(value);\n\t\t\t} else {\n\t\t\t\tresult[key] = [result[key], value];\n\t\t\t}\n\t\t});\n\t}\n\n\treturn { values: result as T };\n}\n\nexport function extractFileData(response: GrasshopperComputeResponse): FileData[] {\n\tconst output: FileData[] = [];\n\n\tfor (const param of response.values) {\n\t\tforEachTreeItem(param.InnerTree, (item) => {\n\t\t\tif (!item.type.includes(FILE_DATA_TYPE)) return;\n\n\t\t\tconst parsed = tryDecodeJSON(item.data);\n\t\t\tif (parsed && parsed.FileName && parsed.FileType && parsed.Data) {\n\t\t\t\toutput.push(parsed as FileData);\n\t\t\t}\n\t\t});\n\t}\n\n\treturn output;\n}\n\nexport function getValue(\n\tresponse: GrasshopperComputeResponse,\n\toptions: { byName: string } | { byId: string },\n\tparseOptions: GetValuesOptions = {}\n): any {\n\tconst { parseValues = true, rhino, stringOnly = false } = parseOptions;\n\n\tlet targetParam: GrasshopperComputeResponse['values'][0] | undefined;\n\n\tif ('byName' in options) {\n\t\ttargetParam = response.values.find((p) => p.ParamName === options.byName);\n\t} else {\n\t\ttargetParam = response.values.find((p) => {\n\t\t\tlet found = false;\n\t\t\tforEachTreeItem(p.InnerTree, (item) => {\n\t\t\t\tif (item.id === options.byId) found = true;\n\t\t\t});\n\t\t\treturn found;\n\t\t});\n\t}\n\n\tif (!targetParam) return undefined;\n\n\tconst collected: any[] = [];\n\n\tforEachTreeItem(targetParam.InnerTree, (item) => {\n\t\tif ('byId' in options && item.id !== options.byId) return;\n\t\t// Skip non-string types if stringOnly is enabled\n\t\tif (stringOnly && item.type !== SYSTEM_TYPES.STRING) return;\n\t\tconst v = extractItemValue(item.data, item.type, parseValues, rhino);\n\t\tcollected.push(v);\n\t});\n\n\tif (collected.length === 0) return undefined;\n\tif (collected.length === 1) return collected[0];\n\treturn collected;\n}\n","import { downloadFileData } from '@/features/file-handling';\nimport { FileBaseInfo, FileData } from '@/features/file-handling/types';\nimport type { MeshExtractionOptions } from '@/features/visualization/webdisplay/types';\n\nimport { GrasshopperComputeResponse } from '../types';\n\nimport {\n\textractFileData,\n\tgetValue,\n\tgetValues,\n\tGetValuesOptions,\n\tGetValuesResult,\n\tParsedContext\n} from '../io/output/response-processors';\n\n/**\n * High-level wrapper for interacting with Grasshopper Compute responses.\n *\n * This class exposes a clean, consistent API for accessing parsed values,\n * geometry, and produced files. It is designed to be the primary interface\n * when working with Grasshopper results in client applications.\n */\nexport default class GrasshopperResponseProcessor {\n\t/**\n\t * Store the compute response for reuse.\n\t */\n\tconstructor(\n\t\tprivate readonly response: GrasshopperComputeResponse,\n\t\tprivate readonly debug: boolean = false\n\t) { }\n\n\t/**\n\t * Extract all values in the response.\n\t *\n\t * @typeParam T - Expected structure of the return value. Defaults to a simple key/value map. (later cast as needed)\n\t * @param byId - If true, keys are parameter IDs; if false, keys are parameter names.\n\t * @param options - Controls parsing behavior such as Rhino geometry decoding.\n\t * @returns Parsed Grasshopper output values.\n\t *\n\t * @example\n\t * ```ts\n\t * const processor = new GrasshopperResponseProcessor(response);\n\t * const { values } = processor.getValues();\n\t * ```\n\t *\n\t * @example\n\t * ```ts\n\t * const { values } = processor.getValues(true); // keyed by param ID\n\t * ```\n\t */\n\tpublic getValues<T = ParsedContext>(\n\t\tbyId: boolean = false,\n\t\toptions: GetValuesOptions = {}\n\t): GetValuesResult<T> {\n\t\treturn getValues<T>(this.response, byId, options);\n\t}\n\n\t/**\n\t * Retrieve a specific value using the parameter name.\n\t *\n\t * @param paramName - Human-readable parameter name from the Grasshopper definition.\n\t * @param options - Parsing configuration (e.g. disable parsing or enable Rhino).\n\t * @returns Single parsed value, array of values, or undefined if the parameter is absent.\n\t *\n\t * @example\n\t * ```ts\n\t * const schema = processor.getValueByParamName('Schema');\n\t * ```\n\t */\n\tpublic getValueByParamName(paramName: string, options?: GetValuesOptions): any {\n\t\treturn getValue(this.response, { byName: paramName }, options);\n\t}\n\n\t/**\n\t * Retrieve a specific value using the parameter ID.\n\t *\n\t * @param paramId - Parameter GUID from the Grasshopper definition.\n\t * @param options - Parsing configuration (e.g. disable parsing or enable Rhino).\n\t * @returns Parsed value, array of values, or undefined if not present.\n\t *\n\t * @example\n\t * ```ts\n\t * const output = processor.getValueByParamId('a4be1c1e-23f9-4c27-b942-7f3bb2c45c6f');\n\t * ```\n\t */\n\tpublic getValueByParamId(paramId: string, options?: GetValuesOptions): any {\n\t\treturn getValue(this.response, { byId: paramId }, options);\n\t}\n\n\t/**\n\t * Convert all geometry results into Three.js mesh objects.\n\t *\n\t * This uses internal helpers to decode Rhino geometry into Three.js\n\t * primitives such as meshes and lines, making them ready for rendering.\n\t *\n\t * All processing options (scaling, positioning, compression, etc.) can be customized.\n\t * The processor's debug flag is merged with options - explicit options take precedence.\n\t *\n\t * **Note:** This method dynamically imports three.js visualization modules. Ensure\n\t * three.js is installed as a peer dependency if you use this feature.\n\t *\n\t * @param options - Configuration for mesh extraction and parsing. Overrides processor's debug flag if provided.\n\t * @returns Promise resolving to an array of Three.js mesh objects.\n\t * @throws {RhinoComputeError} If three.js visualization module cannot be loaded.\n\t *\n\t * @example\n\t * ```ts\n\t * const meshes = await processor.extractMeshesFromResponse();\n\t * scene.add(...meshes);\n\t * ```\n\t *\n\t * @example\n\t * ```ts\n\t * const meshes = await processor.extractMeshesFromResponse({\n\t * debug: true,\n\t * allowScaling: true,\n\t * allowAutoPosition: false,\n\t * parsing: {\n\t * mergeByMaterial: false,\n\t * applyTransforms: true,\n\t * debug: true,\n\t * },\n\t * });\n\t * ```\n\t */\n\tpublic async extractMeshesFromResponse(options?: MeshExtractionOptions) {\n\t\tconst mergedOptions: MeshExtractionOptions = {\n\t\t\tdebug: this.debug,\n\t\t\t...options\n\t\t};\n\n\t\t// Dynamically import visualization module to avoid coupling three.js at module load time\n\t\ttry {\n\t\t\tconst { getThreeMeshesFromComputeResponse } = await import('@/features/visualization');\n\t\t\treturn getThreeMeshesFromComputeResponse(this.response, mergedOptions);\n\t\t} catch (error) {\n\t\t\t// Import here to avoid circular dependencies at top level\n\t\t\t// eslint-disable-next-line @typescript-eslint/no-require-imports\n\t\t\tconst { RhinoComputeError, ErrorCodes } = require('@/core/errors');\n\t\t\tthrow new RhinoComputeError(\n\t\t\t\t'Failed to load three.js visualization module. Ensure three.js is installed as a peer dependency.',\n\t\t\t\tErrorCodes.INVALID_STATE,\n\t\t\t\t{\n\t\t\t\t\tcontext: { originalError: error instanceof Error ? error.message : String(error) }\n\t\t\t\t}\n\t\t\t);\n\t\t}\n\t}\n\n\t/**\n\t * Extract internal file data structures from the response.\n\t * This includes Grasshopper-generated textures, JSON exports,\n\t * CAD formats, or any file structure packaged in the response.\n\t *\n\t * @returns Raw file data entries.\n\t */\n\tprivate getFileData(): FileData[] {\n\t\treturn extractFileData(this.response);\n\t}\n\n\t/**\n\t * Download all files generated by Grasshopper, optionally including\n\t * additional user-provided files.\n\t *\n\t * Files are grouped under the specified folder name when downloaded.\n\t *\n\t * @param folderName - Name for the download directory.\n\t * @param additionalFiles - Extra files to package (single file, array, or null).\n\t *\n\t * @example\n\t * ```ts\n\t * processor.getAndDownloadFiles('gh-output');\n\t * ```\n\t *\n\t * @example\n\t * ```ts\n\t * const extra = { name: 'notes.txt', data: 'Example' };\n\t * processor.getAndDownloadFiles('project', extra);\n\t * ```\n\t */\n\tpublic getAndDownloadFiles(\n\t\tfolderName: string,\n\t\tadditionalFiles?: FileBaseInfo[] | FileBaseInfo | null\n\t) {\n\t\tconst files = this.getFileData();\n\t\tdownloadFileData(files, folderName, additionalFiles);\n\t}\n}\n","import { getLogger } from './logger';\n\nexport function warnIfClientSide(functionName: string, suppress?: boolean): void {\n\tif (suppress) {\n\t\treturn;\n\t}\n\n\tif (typeof window !== 'undefined') {\n\t\tgetLogger().warn(\n\t\t\t`Warning: ${functionName} is running on the client side. For better performance and security, consider running this on the server side.`\n\t\t);\n\t}\n}\n","import { fetchRhinoCompute } from '@/core';\nimport { base64ByteArray, encodeStringToBase64, isBase64 } from '@/core/utils/encoding';\nimport { warnIfClientSide } from '@/core/utils/warnings';\n\nimport {\n\tGrasshopperRequestSchema,\n\tGrasshopperComputeConfig,\n\tGrasshopperComputeResponse,\n\tDataTree\n} from '../types';\n\n/**\n * Runs a Rhino Compute job using the provided tree prototypes and Grasshopper definition.\n *\n * @public Use this for direct compute control. For high-level API, use `GrasshopperClient.solve()`.\n *\n * @param dataTree - An array of `DataTree` objects representing the input data for the compute job.\n * @param definition - The Grasshopper definition, which can be:\n * - A URL string (e.g., 'https://example.com/definition.gh')\n * - A base64-encoded string of the .gh file\n * - A plain string (will be base64-encoded)\n * - A Uint8Array of the .gh file (will be base64-encoded)\n * @param config - Compute configuration (server URL, API key, etc.)\n * @param options - Optional compute options (timeout, cachesolve, model units, tolerances, etc.).\n * @returns An object containing the compute result and extracted file data.\n *\n * @example\n * // Using a URL\n * await solveGrasshopperDefinition(trees, 'https://example.com/definition.gh', config);\n *\n * // Using a base64 string\n * await solveGrasshopperDefinition(trees, 'UEsDBBQAAAAIAL...', config);\n *\n * // Using binary data\n * const fileData = new Uint8Array([...]);\n * await solveGrasshopperDefinition(trees, fileData, config);\n */\nexport async function solveGrasshopperDefinition(\n\tdataTree: DataTree[],\n\tdefinition: string | Uint8Array,\n\tconfig: GrasshopperComputeConfig\n): Promise<GrasshopperComputeResponse> {\n\tif (config.debug) {\n\t\twarnIfClientSide('solveGrasshopperDefinition', config.suppressClientSideWarning);\n\t}\n\n\tconst args = prepareGrasshopperArgs(definition, dataTree);\n\tapplyOptionalComputeSettings(args, config);\n\n\tconst result = await fetchRhinoCompute('grasshopper', args, config);\n\n\tif ('pointer' in result) {\n\t\tdelete (result as any).pointer;\n\t}\n\n\treturn result;\n}\n\n// ============================================================================\n// Grasshopper Arguments\n// ============================================================================\n\n/**\n * Prepares Grasshopper arguments from a definition and data tree.\n * Automatically detects the definition format and converts it appropriately.\n *\n * @param definition - Can be a URL, base64 string, plain string, or Uint8Array\n * @param dataTree - Array of DataTree objects for compute inputs\n * @internal\n */\nexport function prepareGrasshopperArgs(\n\tdefinition: string | Uint8Array,\n\tdataTree: DataTree[]\n): GrasshopperRequestSchema {\n\tconst args: GrasshopperRequestSchema = {\n\t\talgo: null,\n\t\tpointer: null,\n\t\tvalues: dataTree\n\t};\n\n\tif (definition instanceof Uint8Array) {\n\t\t// Binary data → convert to base64\n\t\targs.algo = base64ByteArray(definition);\n\t} else if (definition.startsWith('http')) {\n\t\t// URL → use as pointer reference\n\t\targs.pointer = definition;\n\t} else if (isBase64(definition)) {\n\t\t// Already base64 → use as-is\n\t\targs.algo = definition;\n\t} else {\n\t\t// Plain string → encode to base64\n\t\targs.algo = encodeStringToBase64(definition);\n\t}\n\n\treturn args;\n}\n\n\n/**\n * @internal\n */\nexport function applyOptionalComputeSettings(\n\targlist: GrasshopperRequestSchema,\n\toptions: GrasshopperComputeConfig\n): void {\n\tif (options.cachesolve !== null) arglist.cachesolve = options.cachesolve;\n\tif (options.modelunits !== null) arglist.modelunits = options.modelunits;\n\tif (options.angletolerance !== null) arglist.angletolerance = options.angletolerance;\n\tif (options.absolutetolerance !== null) arglist.absolutetolerance = options.absolutetolerance;\n\tif (options.dataversion !== null) arglist.dataversion = options.dataversion;\n\tif (options.filename !== null) arglist.filename = options.filename;\n}\n","/**\n * Converts a string to camelCase.\n * @param str - The string to convert\n * @param options - Options object\n * - preserveSpaces: If true, spaces are preserved (default: false)\n */\nexport function toCamelCase(str: string, options: { preserveSpaces?: boolean } = {}): string {\n\tconst { preserveSpaces = false } = options;\n\tlet s = str.trim();\n\tif (!preserveSpaces) {\n\t\t// Remove spaces, dashes, and underscores, camelCase the next letter\n\t\ts = s\n\t\t\t.replace(/^[A-Z]/, (m) => m.toLowerCase())\n\t\t\t.replace(/[\\s-_]+(.)?/g, (_, c) => (c ? c.toUpperCase() : ''));\n\t\treturn s;\n\t} else {\n\t\t// Only camelCase after dashes/underscores, preserve spaces\n\t\ts =\n\t\t\ts.charAt(0).toLowerCase() +\n\t\t\ts.slice(1).replace(/[-_](.)/g, (_, c) => (c ? c.toUpperCase() : ''));\n\t\treturn s;\n\t}\n}\n\n/**\n * Recursively converts all object keys to camelCase.\n * @param obj - The object to process\n * @param options - Options object\n * - deep: If true, process deeply\n * - preserveSpaces: If true, spaces are preserved in keys\n * @returns The new object with camelCased keys\n * @internal\n */\nexport function camelcaseKeys(\n\tobj: unknown,\n\toptions: { deep?: boolean; preserveSpaces?: boolean } = {}\n): unknown {\n\tif (!obj || typeof obj !== 'object') {\n\t\treturn obj;\n\t}\n\n\tif (Array.isArray(obj)) {\n\t\treturn options.deep ? obj.map((item) => camelcaseKeys(item, options)) : obj;\n\t}\n\n\treturn Object.keys(obj).reduce(\n\t\t(result, key) => {\n\t\t\tconst camelKey = toCamelCase(key, { preserveSpaces: options.preserveSpaces });\n\t\t\tconst value = (obj as any)[key];\n\t\t\t(result as any)[camelKey] = options.deep ? camelcaseKeys(value, options) : value;\n\t\t\treturn result;\n\t\t},\n\t\t{} as Record<string, unknown>\n\t);\n}\n","import { RhinoComputeError } from '@/core/errors';\nimport { ValidationErrors } from '@/core/errors/error-factory';\n\nimport { preProcessInputDefault } from './input-validators';\nimport { PARSERS } from './input-parsers';\nimport { getLogger } from '@/core/utils/logger';\n\nimport type {\n\tBaseInputType,\n\tBooleanInputType,\n\tGeometryInputType,\n\tInputParam,\n\tNumericInputType,\n\tInputParamSchema,\n\tTextInputType,\n\tValueListInputType,\n\tFileInputType\n} from '../../types';\n\n/**\n * Creates a safe default InputType when processing fails\n */\nfunction createSafeDefault(rawInput: InputParamSchema, baseInput: BaseInputType): InputParam {\n\tswitch (rawInput.paramType) {\n\t\tcase 'Number':\n\t\tcase 'Integer':\n\t\t\treturn {\n\t\t\t\t...baseInput,\n\t\t\t\tparamType: rawInput.paramType,\n\t\t\t\tminimum: rawInput.minimum,\n\t\t\t\tmaximum: rawInput.maximum,\n\t\t\t\tatLeast: rawInput.atLeast,\n\t\t\t\tatMost: rawInput.atMost,\n\t\t\t\tdefault: rawInput.atMost > 1 ? [0] : 0\n\t\t\t} as NumericInputType;\n\t\tcase 'Boolean':\n\t\t\treturn {\n\t\t\t\t...baseInput,\n\t\t\t\tparamType: 'Boolean',\n\t\t\t\tdefault: rawInput.atMost > 1 ? [false] : false\n\t\t\t} as BooleanInputType;\n\t\tcase 'Text':\n\t\t\treturn {\n\t\t\t\t...baseInput,\n\t\t\t\tparamType: 'Text',\n\t\t\t\tdefault: rawInput.atMost > 1 ? [''] : ''\n\t\t\t} as TextInputType;\n\t\tcase 'ValueList':\n\t\t\treturn {\n\t\t\t\t...baseInput,\n\t\t\t\tparamType: 'ValueList',\n\t\t\t\tvalues: rawInput.values ?? {},\n\t\t\t\tdefault: rawInput.atMost > 1 ? [rawInput.default] : rawInput.default\n\t\t\t} as ValueListInputType;\n\t\tcase 'File':\n\t\t\treturn {\n\t\t\t\t...baseInput,\n\t\t\t\tparamType: 'File',\n\t\t\t\tdefault: rawInput.atMost > 1 ? [null] : null\n\t\t\t} as FileInputType;\n\t\tdefault:\n\t\t\treturn {\n\t\t\t\t...baseInput,\n\t\t\t\tparamType: 'Geometry',\n\t\t\t\tdefault: rawInput.atMost > 1 ? [null] : null\n\t\t\t} as GeometryInputType;\n\t}\n}\n\n/**\n * Processes a raw input parameter schema and converts it into a typed InputParam object.\n *\n * @internal This is an internal processor. Use `fetchParsedDefinitionIO()` to get processed inputs instead.\n *\n * This function handles the transformation of raw input parameter data from Grasshopper into\n * a structured, type-safe format. It performs validation, type-specific processing, and error\n * handling for various parameter types including numeric, boolean, text, geometry, point, and line inputs.\n *\n * @param rawInput - The raw input parameter schema to process\n * @returns A fully processed and typed InputParam object with appropriate type-specific properties\n *\n * @throws {RhinoComputeError} When an unknown paramType is encountered\n * @throws {Error} Re-throws any non-RhinoComputeError exceptions\n *\n * @remarks\n * The function performs the following operations:\n * - Extracts base properties common to all input types\n * - Preprocesses the raw input data\n * - Applies type-specific validation and transformation\n * - Handles errors gracefully by creating safe default values for validation errors\n *\n * Supported parameter types:\n * - `Number` and `Integer`: Numeric inputs with optional min/max constraints\n * - `Boolean`: Boolean flag inputs\n * - `Text`: String inputs\n * - `Geometry`: Generic geometry objects\n * - `Point`: 3D point objects\n * - `Line`: Line objects\n *\n * @example\n * ```typescript\n * const rawInput = {\n * name: 'Length',\n * paramType: 'Number',\n * minimum: 0,\n * maximum: 100,\n * default: 50\n * };\n * const processedInput = processInput(rawInput);\n * ```\n */\nexport function processInput(rawInput: InputParamSchema): InputParam {\n\t// Create base properties outside try-catch so it's accessible in catch block\n\tconst baseInput: BaseInputType = {\n\t\tdescription: rawInput.description,\n\t\tname: rawInput.name,\n\t\tnickname: rawInput.nickname,\n\t\ttreeAccess: rawInput.treeAccess,\n\t\tgroupName: rawInput.groupName ?? '',\n\t\tid: rawInput.id\n\t};\n\n\ttry {\n\t\t// Handle default object processing\n\t\tpreProcessInputDefault(rawInput);\n\n\t\t// Get parser for this type\n\t\tconst parser = PARSERS[rawInput.paramType];\n\t\tif (!parser) {\n\t\t\tthrow ValidationErrors.unknownParamType(rawInput.paramType, rawInput.name);\n\t\t}\n\n\t\t// Apply type-specific parsing\n\t\tparser(rawInput);\n\n\t\t// Return typed result based on paramType\n\t\tswitch (rawInput.paramType) {\n\t\t\tcase 'Number':\n\t\t\tcase 'Integer':\n\t\t\t\treturn {\n\t\t\t\t\t...baseInput,\n\t\t\t\t\tparamType: rawInput.paramType,\n\t\t\t\t\tminimum: rawInput.minimum,\n\t\t\t\t\tmaximum: rawInput.maximum,\n\t\t\t\t\tatLeast: rawInput.atLeast,\n\t\t\t\t\tatMost: rawInput.atMost,\n\t\t\t\t\tstepSize: rawInput.stepSize,\n\t\t\t\t\tdefault: rawInput.default as number | undefined\n\t\t\t\t} as NumericInputType;\n\t\t\tcase 'Boolean':\n\t\t\t\treturn {\n\t\t\t\t\t...baseInput,\n\t\t\t\t\tparamType: 'Boolean',\n\t\t\t\t\tdefault: rawInput.default as boolean | undefined\n\t\t\t\t} as BooleanInputType;\n\t\t\tcase 'Text':\n\t\t\t\treturn {\n\t\t\t\t\t...baseInput,\n\t\t\t\t\tparamType: 'Text',\n\t\t\t\t\tdefault: rawInput.default as string | undefined\n\t\t\t\t} as TextInputType;\n\t\t\tcase 'ValueList':\n\t\t\t\treturn {\n\t\t\t\t\t...baseInput,\n\t\t\t\t\tparamType: 'ValueList',\n\t\t\t\t\tvalues: rawInput.values as Record<string, string>,\n\t\t\t\t\tdefault: rawInput.default as string | undefined\n\t\t\t\t} as ValueListInputType;\n\t\t\tcase 'Geometry':\n\t\t\t\treturn {\n\t\t\t\t\t...baseInput,\n\t\t\t\t\tparamType: rawInput.paramType as 'Geometry',\n\t\t\t\t\tdefault: rawInput.default as object | string | undefined\n\t\t\t\t} as GeometryInputType;\n\t\t\tcase 'File':\n\t\t\t\treturn {\n\t\t\t\t\t...baseInput,\n\t\t\t\t\tparamType: rawInput.paramType as 'File',\n\t\t\t\t\tacceptedFormats: rawInput.acceptedFormats,\n\t\t\t\t\tdefault: rawInput.default as object | string | undefined\n\t\t\t\t} as FileInputType;\n\t\t\tdefault:\n\t\t\t\t// This should be unreachable due to parser registry check above\n\t\t\t\tthrow ValidationErrors.unknownParamType(rawInput.paramType, rawInput.name);\n\t\t}\n\t} catch (error) {\n\t\tif (error instanceof RhinoComputeError) {\n\t\t\tgetLogger().error(`Validation error for input ${rawInput.name || 'unknown'}:`, error.message);\n\t\t\t// Return a safe default based on paramType\n\t\t\treturn createSafeDefault(rawInput, baseInput);\n\t\t} else {\n\t\t\t// Transform unexpected errors\n\t\t\tthrow new RhinoComputeError(\n\t\t\t\terror instanceof Error ? error.message : String(error),\n\t\t\t\t'VALIDATION_ERROR',\n\t\t\t\t{\n\t\t\t\t\tcontext: { paramName: rawInput.name, paramType: rawInput.paramType },\n\t\t\t\t\toriginalError: error instanceof Error ? error : new Error(String(error))\n\t\t\t\t}\n\t\t\t);\n\t\t}\n\t}\n}\n\n/**\n * Processes raw Grasshopper input schemas into strongly-typed TypeScript interfaces.\n *\n * @internal This is an internal batch processor. Use `fetchParsedDefinitionIO()` to get processed inputs instead.\n *\n * Transforms each raw input parameter by:\n * - Normalizing default values (flattening data trees, parsing primitives)\n * - Applying type-specific parsing (Number, Text, Boolean, Geometry, etc.)\n * - Validating constraints (min/max, required fields)\n * - Converting to discriminated union types for type safety\n *\n * @param rawInputs - Array of raw input schemas from Rhino Compute API\n * @returns Array of processed, strongly-typed input parameters\n *\n * @remarks\n * - Empty data trees are converted to `undefined`\n * - Single values are extracted from arrays when appropriate\n * - Tree structures are preserved for list/tree access parameters\n * - Invalid inputs fall back to safe defaults with console warnings\n *\n * @example\n * ```typescript\n * const rawInputs = [\n * { paramType: 'Number', name: 'radius', minimum: 0, default: 10 },\n * { paramType: 'Text', name: 'label', default: 'Hello' }\n * ];\n *\n * const processed = processInputs(rawInputs);\n * // Result: [\n * // { paramType: 'Number', name: 'radius', minimum: 0, default: 10, ... },\n * // { paramType: 'Text', name: 'label', default: 'Hello', ... }\n * // ]\n *\n * // Now type-safe:\n * if (processed[0].paramType === 'Number') {\n * console.log(processed[0].minimum); // TypeScript knows this exists\n * }\n * ```\n *\n * @see {@link processInput} for individual input processing logic\n * @see {@link preProcessRawInput} for default value normalization\n */\nexport function processInputs(rawInputs: InputParamSchema[]): InputParam[] {\n\treturn rawInputs.map((rawInput) => processInput(rawInput));\n}\n","import { RhinoComputeError } from './base';\nimport { ErrorCodes } from './error-codes';\n\n/**\n * Factory functions for creating consistent error instances across the codebase.\n * Standardizes error creation patterns and reduces duplication.\n *\n * @internal This is an internal error factory module.\n */\n\nexport interface ValidationErrorOptions {\n\tinputName?: string;\n\tparamType?: string;\n\treceivedValue?: unknown;\n\treason?: string;\n}\n\nexport interface ErrorOptions {\n\tcontext?: Record<string, unknown>;\n\tstatusCode?: number;\n\toriginalError?: Error;\n}\n\n/**\n * Validation error factory - creates standardized validation errors\n */\nexport const ValidationErrors = {\n\t/**\n\t * Create a generic validation error with custom reason\n\t */\n\tinvalid: (inputName: string, reason: string, options?: ErrorOptions) =>\n\t\tnew RhinoComputeError(`Input \"${inputName}\": ${reason}`, ErrorCodes.VALIDATION_ERROR, {\n\t\t\tcontext: { inputName, reason, ...options?.context },\n\t\t\t...options\n\t\t}),\n\n\t/**\n\t * Create an error for missing/empty values\n\t */\n\tmissingValues: (inputName: string, expectedType?: string, options?: ErrorOptions) =>\n\t\tnew RhinoComputeError(\n\t\t\t`Input \"${inputName}\" has no values defined${expectedType ? ` (expected ${expectedType})` : ''}`,\n\t\t\tErrorCodes.INVALID_INPUT,\n\t\t\t{\n\t\t\t\tcontext: { inputName, expectedType, ...options?.context },\n\t\t\t\t...options\n\t\t\t}\n\t\t),\n\n\t/**\n\t * Create an error for invalid boolean value\n\t */\n\tinvalidBoolean: (value: unknown, inputName?: string, options?: ErrorOptions) =>\n\t\tnew RhinoComputeError(\n\t\t\t`Invalid boolean value: ${value}${inputName ? ` in input \"${inputName}\"` : ''}`,\n\t\t\tErrorCodes.VALIDATION_ERROR,\n\t\t\t{\n\t\t\t\tcontext: {\n\t\t\t\t\treceivedValue: value,\n\t\t\t\t\tinputName,\n\t\t\t\t\texpectedValues: ['true', 'false'],\n\t\t\t\t\t...options?.context\n\t\t\t\t},\n\t\t\t\t...options\n\t\t\t}\n\t\t),\n\n\t/**\n\t * Create an error for invalid default value in value list\n\t */\n\tinvalidDefault: (\n\t\tinputName: string,\n\t\tdefaultValue: unknown,\n\t\tavailableValues: unknown[],\n\t\toptions?: ErrorOptions\n\t) =>\n\t\tnew RhinoComputeError(\n\t\t\t`ValueList input \"${inputName}\" default value \"${defaultValue}\" is not in available values`,\n\t\t\tErrorCodes.VALIDATION_ERROR,\n\t\t\t{\n\t\t\t\tcontext: { inputName, defaultValue, availableValues, ...options?.context },\n\t\t\t\t...options\n\t\t\t}\n\t\t),\n\n\t/**\n\t * Create an error for unknown parameter type\n\t */\n\tunknownParamType: (paramType: string, paramName?: string, options?: ErrorOptions) =>\n\t\tnew RhinoComputeError(`Unknown paramType: ${paramType}`, ErrorCodes.VALIDATION_ERROR, {\n\t\t\tcontext: { receivedParamType: paramType, paramName, ...options?.context },\n\t\t\t...options\n\t\t}),\n\n\t/**\n\t * Create an error for invalid input structure\n\t */\n\tinvalidStructure: (inputName: string, expectedStructure: string, options?: ErrorOptions) =>\n\t\tnew RhinoComputeError(\n\t\t\t`Invalid input structure for \"${inputName}\" (expected ${expectedStructure})`,\n\t\t\tErrorCodes.INVALID_INPUT,\n\t\t\t{\n\t\t\t\tcontext: { inputName, expectedStructure, ...options?.context },\n\t\t\t\t...options\n\t\t\t}\n\t\t)\n};\n\n/**\n * Input processing error factory\n */\nexport const InputErrors = {\n\t/**\n\t * Create an error for failed input parsing\n\t */\n\tparseError: (inputName: string, inputType: string, reason: string, options?: ErrorOptions) =>\n\t\tnew RhinoComputeError(\n\t\t\t`Failed to parse ${inputType} input \"${inputName}\": ${reason}`,\n\t\t\tErrorCodes.INVALID_INPUT,\n\t\t\t{\n\t\t\t\tcontext: { inputName, inputType, reason, ...options?.context },\n\t\t\t\t...options\n\t\t\t}\n\t\t),\n\n\t/**\n\t * Create an error for invalid input structure\n\t */\n\tinvalidStructure: (inputName: string, expectedStructure: string, options?: ErrorOptions) =>\n\t\tnew RhinoComputeError(\n\t\t\t`Invalid input structure for \"${inputName}\" (expected ${expectedStructure})`,\n\t\t\tErrorCodes.INVALID_INPUT,\n\t\t\t{\n\t\t\t\tcontext: { inputName, expectedStructure, ...options?.context },\n\t\t\t\t...options\n\t\t\t}\n\t\t)\n};\n\n/**\n * Data transformation error factory\n */\nexport const DataErrors = {\n\t/**\n\t * Create an error for failed data transformation\n\t */\n\ttransformError: (dataType: string, reason: string, options?: ErrorOptions) =>\n\t\tnew RhinoComputeError(\n\t\t\t`Data transformation error for ${dataType}: ${reason}`,\n\t\t\tErrorCodes.COMPUTATION_ERROR,\n\t\t\t{\n\t\t\t\tcontext: { dataType, reason, ...options?.context },\n\t\t\t\t...options\n\t\t\t}\n\t\t),\n\n\t/**\n\t * Create an error for invalid data type\n\t */\n\tinvalidType: (expectedType: string, receivedType: string, options?: ErrorOptions) =>\n\t\tnew RhinoComputeError(\n\t\t\t`Invalid data type: expected ${expectedType}, received ${receivedType}`,\n\t\t\tErrorCodes.VALIDATION_ERROR,\n\t\t\t{\n\t\t\t\tcontext: { expectedType, receivedType, ...options?.context },\n\t\t\t\t...options\n\t\t\t}\n\t\t)\n};\n\n/**\n * Configuration error factory\n */\nexport const ConfigErrors = {\n\t/**\n\t * Create an error for invalid configuration\n\t */\n\tinvalid: (configName: string, reason: string, options?: ErrorOptions) =>\n\t\tnew RhinoComputeError(\n\t\t\t`Invalid configuration \"${configName}\": ${reason}`,\n\t\t\tErrorCodes.INVALID_CONFIG,\n\t\t\t{\n\t\t\t\tcontext: { configName, reason, ...options?.context },\n\t\t\t\t...options\n\t\t\t}\n\t\t),\n\n\t/**\n\t * Create an error for missing required config property\n\t */\n\tmissingRequired: (configName: string, propertyName: string, options?: ErrorOptions) =>\n\t\tnew RhinoComputeError(\n\t\t\t`Configuration \"${configName}\" is missing required property \"${propertyName}\"`,\n\t\t\tErrorCodes.INVALID_CONFIG,\n\t\t\t{\n\t\t\t\tcontext: { configName, propertyName, ...options?.context },\n\t\t\t\t...options\n\t\t\t}\n\t\t)\n};\n"]}
@@ -0,0 +1,2 @@
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { newObj[key] = obj[key]; } } } newObj.default = obj; return newObj; } }var _chunk5DJRUPGIcjs = require('./chunk-5DJRUPGI.cjs');var _chunkP57VU27Wcjs = require('./chunk-P57VU27W.cjs');var F=async(t,r=null)=>{try{return await p(t,r)}catch(o){throw new (0, _chunkP57VU27Wcjs.d)("Failed to extract files from compute response",_chunkP57VU27Wcjs.f.INVALID_STATE,{context:{originalError:o instanceof Error?o.message:String(o)},originalError:o instanceof Error?o:void 0})}},m= exports.b =async(t,r,o=null)=>{if(typeof document>"u"||typeof Blob>"u")throw new (0, _chunkP57VU27Wcjs.d)("File download functionality is only available in browser environments. This function requires the DOM API (document, Blob).",_chunkP57VU27Wcjs.f.BROWSER_ONLY,{context:{environment:typeof window<"u"?"browser (SSR)":"Node.js",documentAvailable:typeof document<"u",blobAvailable:typeof Blob<"u"}});try{let e=await p(t,o);await w(e,r)}catch(e){throw e instanceof _chunkP57VU27Wcjs.d?e:new (0, _chunkP57VU27Wcjs.d)("Failed to download files from compute response",_chunkP57VU27Wcjs.f.INVALID_STATE,{context:{originalError:e instanceof Error?e.message:String(e)},originalError:e instanceof Error?e:void 0})}},p=async(t,r)=>{let o=[];if(t.forEach(e=>{let a=`${e.FileName}${e.FileType}`;if(e.SubFolder&&e.SubFolder.trim()!==""&&(a=`${e.SubFolder}/${a}`),e.IsBase64Encoded===!0&&e.Data){let n=_chunk5DJRUPGIcjs.c.call(void 0, e.Data);o.push({fileName:`${e.FileName}${e.FileType}`,content:new Uint8Array(n.buffer),path:a})}else e.IsBase64Encoded===!1&&e.Data&&o.push({fileName:`${e.FileName}${e.FileType}`,content:e.Data,path:a})}),r){let e=Array.isArray(r)?r:[r],a=await Promise.all(e.map(async n=>{try{let i=await fetch(n.FilePath);if(!i.ok)return _chunkP57VU27Wcjs.j.call(void 0, ).warn(`Failed to fetch additional file from URL: ${n.FilePath}`),null;let u=await(await i.blob()).arrayBuffer();return{fileName:n.FileName,content:new Uint8Array(u),path:n.FileName}}catch(i){return _chunkP57VU27Wcjs.j.call(void 0, ).error(`Error fetching additional file from URL: ${n.FilePath}`,i),null}}));o.push(...a.filter(n=>n!==null))}return o};async function w(t,r){let{zipSync:o,strToU8:e}=await Promise.resolve().then(() => _interopRequireWildcard(require("fflate"))),a={};t.forEach(l=>{a[l.path]=typeof l.content=="string"?e(l.content):l.content});let n=o(a,{level:6}),i=new Blob([n],{type:"application/zip"});y(i,`${r}.zip`)}function y(t,r){if(typeof document>"u")throw new (0, _chunkP57VU27Wcjs.d)("saveFile requires a browser environment with DOM API access.",_chunkP57VU27Wcjs.f.BROWSER_ONLY,{context:{function:"saveFile",requiredAPI:"document"}});let o=document.createElement("a");o.href=URL.createObjectURL(t),o.download=r,o.click(),URL.revokeObjectURL(o.href)}exports.a = F; exports.b = m;
2
+ //# sourceMappingURL=chunk-TVCJBLSW.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["/Users/felix/coding/selva-compute/dist/chunk-TVCJBLSW.cjs","../src/features/file-handling/handle-files.ts"],"names":["extractFilesFromComputeResponse","downloadableFiles","additionalFiles","processFiles","err","RhinoComputeError","ErrorCodes","downloadFileData","fileFoldername","processedFiles","createAndDownloadZip","dataItems","item","filePath"],"mappings":"AAAA,mZAAwC,wDAAuD,ICoBlFA,CAAAA,CAAkC,KAAA,CAC9CC,CAAAA,CACAC,CAAAA,CAAwD,IAAA,CAAA,EAC1B,CAC9B,GAAI,CACH,OAAO,MAAMC,CAAAA,CAAaF,CAAAA,CAAmBC,CAAe,CAC7D,CAAA,KAAA,CAASE,CAAAA,CAAK,CACb,MAAM,IAAIC,wBAAAA,CACT,+CAAA,CACAC,mBAAAA,CAAW,aAAA,CACX,CACC,OAAA,CAAS,CAAE,aAAA,CAAeF,EAAAA,WAAe,KAAA,CAAQA,CAAAA,CAAI,OAAA,CAAU,MAAA,CAAOA,CAAG,CAAE,CAAA,CAC3E,aAAA,CAAeA,EAAAA,WAAe,KAAA,CAAQA,CAAAA,CAAM,KAAA,CAC7C,CACD,CACD,CACD,CAAA,CAeaG,CAAAA,aAAmB,KAAA,CAC/BN,CAAAA,CACAO,CAAAA,CACAN,CAAAA,CAAwD,IAAA,CAAA,EACrC,CAEnB,EAAA,CAAI,OAAO,QAAA,CAAa,GAAA,EAAe,OAAO,IAAA,CAAS,GAAA,CACtD,MAAM,IAAIG,wBAAAA,CACT,6HAAA,CACAC,mBAAAA,CAAW,YAAA,CACX,CACC,OAAA,CAAS,CACR,WAAA,CAAa,OAAO,MAAA,CAAW,GAAA,CAAc,eAAA,CAAkB,SAAA,CAC/D,iBAAA,CAAmB,OAAO,QAAA,CAAa,GAAA,CACvC,aAAA,CAAe,OAAO,IAAA,CAAS,GAChC,CACD,CACD,CAAA,CAGD,GAAI,CACH,IAAMG,CAAAA,CAAiB,MAAMN,CAAAA,CAAaF,CAAAA,CAAmBC,CAAe,CAAA,CAC5E,MAAMQ,CAAAA,CAAqBD,CAAAA,CAAgBD,CAAc,CAC1D,CAAA,KAAA,CAASJ,CAAAA,CAAK,CAEb,MAAIA,EAAAA,WAAeC,mBAAAA,CACZD,CAAAA,CAED,IAAIC,wBAAAA,CACT,gDAAA,CACAC,mBAAAA,CAAW,aAAA,CACX,CACC,OAAA,CAAS,CAAE,aAAA,CAAeF,EAAAA,WAAe,KAAA,CAAQA,CAAAA,CAAI,OAAA,CAAU,MAAA,CAAOA,CAAG,CAAE,CAAA,CAC3E,aAAA,CAAeA,EAAAA,WAAe,KAAA,CAAQA,CAAAA,CAAM,KAAA,CAC7C,CACD,CACD,CACD,CAAA,CAUMD,CAAAA,CAAe,KAAA,CACpBQ,CAAAA,CACAT,CAAAA,CAAAA,EAC8B,CAC9B,IAAMO,CAAAA,CAAkC,CAAC,CAAA,CA0BzC,EAAA,CAvBAE,CAAAA,CAAU,OAAA,CAASC,CAAAA,EAAS,CAC3B,IAAIC,CAAAA,CAAW,CAAA,EAAA","file":"/Users/felix/coding/selva-compute/dist/chunk-TVCJBLSW.cjs","sourcesContent":[null,"import { RhinoComputeError, ErrorCodes, getLogger } from '@/core';\nimport { decodeBase64ToBinary } from '@/core/utils/encoding';\n\nimport { FileBaseInfo, FileData, ProcessedFile } from './types';\n\n/**\n * Extracts and processes files from compute response data without downloading them.\n * Returns an array of ProcessedFile objects that can be used programmatically.\n *\n * @param downloadableFiles - An array of FileData items from the compute response.\n * @param additionalFiles - Optional additional files to include (fetched from URLs).\n * @returns A Promise resolving to an array of ProcessedFile objects.\n * @throws Will throw an error if file processing fails.\n *\n * @example\n * const files = await extractFilesFromComputeResponse(fileData);\n * files.forEach(file => {\n * console.log(`File: ${file.fileName}, Size: ${file.content.length}`);\n * });\n */\nexport const extractFilesFromComputeResponse = async (\n\tdownloadableFiles: FileData[],\n\tadditionalFiles: FileBaseInfo[] | FileBaseInfo | null = null\n): Promise<ProcessedFile[]> => {\n\ttry {\n\t\treturn await processFiles(downloadableFiles, additionalFiles);\n\t} catch (err) {\n\t\tthrow new RhinoComputeError(\n\t\t\t'Failed to extract files from compute response',\n\t\t\tErrorCodes.INVALID_STATE,\n\t\t\t{\n\t\t\t\tcontext: { originalError: err instanceof Error ? err.message : String(err) },\n\t\t\t\toriginalError: err instanceof Error ? err : undefined\n\t\t\t}\n\t\t);\n\t}\n};\n\n/**\n * Downloads files from a compute response as a ZIP archive.\n * Packages multiple files into a single ZIP file and triggers a browser download.\n *\n * @param downloadableFiles - An array of FileData items from the compute response.\n * @param additionalFiles - Optional additional files to include in the ZIP (fetched from URLs).\n * @param fileFoldername - The name of the ZIP file (without extension).\n * @throws Will throw an error if the file handling or download fails.\n *\n * @example\n * await downloadDataFromComputeResponse(fileData, null, 'my-export');\n * // Downloads 'my-export.zip'\n */\nexport const downloadFileData = async (\n\tdownloadableFiles: FileData[],\n\tfileFoldername: string,\n\tadditionalFiles: FileBaseInfo[] | FileBaseInfo | null = null\n): Promise<void> => {\n\t// Check if we're in a browser environment\n\tif (typeof document === 'undefined' || typeof Blob === 'undefined') {\n\t\tthrow new RhinoComputeError(\n\t\t\t'File download functionality is only available in browser environments. This function requires the DOM API (document, Blob).',\n\t\t\tErrorCodes.BROWSER_ONLY,\n\t\t\t{\n\t\t\t\tcontext: {\n\t\t\t\t\tenvironment: typeof window !== 'undefined' ? 'browser (SSR)' : 'Node.js',\n\t\t\t\t\tdocumentAvailable: typeof document !== 'undefined',\n\t\t\t\t\tblobAvailable: typeof Blob !== 'undefined'\n\t\t\t\t}\n\t\t\t}\n\t\t);\n\t}\n\n\ttry {\n\t\tconst processedFiles = await processFiles(downloadableFiles, additionalFiles);\n\t\tawait createAndDownloadZip(processedFiles, fileFoldername);\n\t} catch (err) {\n\t\t// Re-throw if it's already a RhinoComputeError\n\t\tif (err instanceof RhinoComputeError) {\n\t\t\tthrow err;\n\t\t}\n\t\tthrow new RhinoComputeError(\n\t\t\t'Failed to download files from compute response',\n\t\t\tErrorCodes.INVALID_STATE,\n\t\t\t{\n\t\t\t\tcontext: { originalError: err instanceof Error ? err.message : String(err) },\n\t\t\t\toriginalError: err instanceof Error ? err : undefined\n\t\t\t}\n\t\t);\n\t}\n};\n\n/**\n * Processes files from compute response data and additional files.\n * Converts base64-encoded data to binary and fetches additional files from URLs.\n *\n * @param dataItems - An array of FileData items to process.\n * @param additionalFiles - Optional additional files to fetch and include.\n * @returns A Promise resolving to an array of ProcessedFile objects.\n */\nconst processFiles = async (\n\tdataItems: FileData[],\n\tadditionalFiles: FileBaseInfo[] | FileBaseInfo | null\n): Promise<ProcessedFile[]> => {\n\tconst processedFiles: ProcessedFile[] = [];\n\n\t// Process compute response files\n\tdataItems.forEach((item) => {\n\t\tlet filePath = `${item.FileName}${item.FileType}`;\n\n\t\tif (item.SubFolder && item.SubFolder.trim() !== '') {\n\t\t\tfilePath = `${item.SubFolder}/${filePath}`;\n\t\t}\n\n\t\tif (item.IsBase64Encoded === true && item.Data) {\n\t\t\tconst bites = decodeBase64ToBinary(item.Data);\n\t\t\tprocessedFiles.push({\n\t\t\t\tfileName: `${item.FileName}${item.FileType}`,\n\t\t\t\tcontent: new Uint8Array(bites.buffer),\n\t\t\t\tpath: filePath\n\t\t\t});\n\t\t} else if (item.IsBase64Encoded === false && item.Data) {\n\t\t\tprocessedFiles.push({\n\t\t\t\tfileName: `${item.FileName}${item.FileType}`,\n\t\t\t\tcontent: item.Data,\n\t\t\t\tpath: filePath\n\t\t\t});\n\t\t}\n\t});\n\n\tif (additionalFiles) {\n\t\tconst filesArray = Array.isArray(additionalFiles) ? additionalFiles : [additionalFiles];\n\t\tconst additionalProcessed = await Promise.all(\n\t\t\tfilesArray.map(async (file) => {\n\t\t\t\ttry {\n\t\t\t\t\tconst response = await fetch(file.FilePath);\n\t\t\t\t\tif (!response.ok) {\n\t\t\t\t\t\tgetLogger().warn(`Failed to fetch additional file from URL: ${file.FilePath}`);\n\t\t\t\t\t\treturn null;\n\t\t\t\t\t}\n\t\t\t\t\tconst fileBlob = await response.blob();\n\t\t\t\t\tconst arrayBuffer = await fileBlob.arrayBuffer();\n\t\t\t\t\treturn {\n\t\t\t\t\t\tfileName: file.FileName,\n\t\t\t\t\t\tcontent: new Uint8Array(arrayBuffer),\n\t\t\t\t\t\tpath: file.FileName\n\t\t\t\t\t} as ProcessedFile;\n\t\t\t\t} catch (error) {\n\t\t\t\t\tgetLogger().error(`Error fetching additional file from URL: ${file.FilePath}`, error);\n\t\t\t\t\treturn null;\n\t\t\t\t}\n\t\t\t})\n\t\t);\n\n\t\tprocessedFiles.push(...additionalProcessed.filter((f): f is ProcessedFile => f !== null));\n\t}\n\n\treturn processedFiles;\n};\n\n/**\n * Creates a ZIP archive from processed files and triggers a browser download.\n *\n * @param files - An array of ProcessedFile objects to include in the ZIP.\n * @param zipName - The name of the ZIP file (without extension).\n * @returns A Promise that resolves when the ZIP is generated and download is triggered.\n */\nasync function createAndDownloadZip(files: ProcessedFile[], zipName: string): Promise<void> {\n\tconst { zipSync, strToU8 } = await import('fflate');\n\n\t// Convert files to fflate format\n\tconst zipData: Record<string, Uint8Array> = {};\n\tfiles.forEach((file) => {\n\t\tzipData[file.path] = typeof file.content === 'string' ? strToU8(file.content) : file.content;\n\t});\n\n\tconst zipped = zipSync(zipData, { level: 6 });\n\n\tconst blob = new Blob([zipped as BlobPart], { type: 'application/zip' });\n\tsaveFile(blob, `${zipName}.zip`);\n}\n\n/**\n * Saves a Blob object as a file in the user's browser.\n *\n * @param blob - The Blob object representing the file content.\n * @param filename - The name to give the downloaded file (including extension).\n * @throws {RhinoComputeError} If not running in a browser environment.\n */\nfunction saveFile(blob: Blob, filename: string) {\n\tif (typeof document === 'undefined') {\n\t\tthrow new RhinoComputeError(\n\t\t\t'saveFile requires a browser environment with DOM API access.',\n\t\t\tErrorCodes.BROWSER_ONLY,\n\t\t\t{\n\t\t\t\tcontext: { function: 'saveFile', requiredAPI: 'document' }\n\t\t\t}\n\t\t);\n\t}\n\n\tconst a = document.createElement('a');\n\ta.href = URL.createObjectURL(blob);\n\ta.download = filename;\n\ta.click();\n\tURL.revokeObjectURL(a.href);\n}\n"]}
package/dist/core.cjs ADDED
@@ -0,0 +1,2 @@
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunkP57VU27Wcjs = require('./chunk-P57VU27W.cjs');exports.ComputeServerStats = _chunkP57VU27Wcjs.o; exports.ErrorCodes = _chunkP57VU27Wcjs.f; exports.RhinoComputeError = _chunkP57VU27Wcjs.d; exports.enableDebugLogging = _chunkP57VU27Wcjs.l; exports.fetchRhinoCompute = _chunkP57VU27Wcjs.n; exports.getLogger = _chunkP57VU27Wcjs.j; exports.setLogger = _chunkP57VU27Wcjs.k;
2
+ //# sourceMappingURL=core.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["/Users/felix/coding/selva-compute/dist/core.cjs"],"names":[],"mappings":"AAAA,iIAAkF,iUAAoJ","file":"/Users/felix/coding/selva-compute/dist/core.cjs"}
@@ -0,0 +1,114 @@
1
+ import { C as ComputeConfig, c as GrasshopperComputeConfig, b as GrasshopperComputeResponse, f as IoResponseSchema } from './schemas-5LuPKgX2.cjs';
2
+ export { R as RhinoModelUnit } from './schemas-5LuPKgX2.cjs';
3
+ export { C as ComputeServerStats, R as RhinoComputeError } from './base-DbB0Ggdq.cjs';
4
+
5
+ /**
6
+ * Valid endpoints for Rhino Compute
7
+ */
8
+ type Endpoint = 'grasshopper' | 'io' | string;
9
+ type EndpointResponseMap = {
10
+ grasshopper: GrasshopperComputeResponse;
11
+ io: IoResponseSchema;
12
+ };
13
+ type ComputeResponseFor<E extends string> = E extends keyof EndpointResponseMap ? EndpointResponseMap[E] : unknown;
14
+ /**
15
+ * Generic Rhino Compute fetch function.
16
+ * Sends a POST request to any Compute endpoint with pre-prepared arguments.
17
+ *
18
+ * @public Use this for advanced low-level control over compute requests. For most use cases, prefer higher-level APIs.
19
+ *
20
+ * @param endpoint - The Compute API endpoint (e.g., 'grasshopper', 'io', 'mesh').
21
+ * @param args - Pre-prepared arguments for the request.
22
+ * @param config - Compute configuration (server URL, API key, timeout, debug).
23
+ * @returns The parsed JSON response from the server.
24
+ *
25
+ * @example
26
+ * ```typescript
27
+ * const response = await fetchRhinoCompute(
28
+ * 'grasshopper',
29
+ * {
30
+ * pointer: { url: 'https://example.com/definition.gh' },
31
+ * values: [{ ParamName: 'x', InnerTree: { '0': [{ type: 'System.Double', data: 10 }] } }]
32
+ * },
33
+ * { serverUrl: 'https://compute.rhino3d.com', debug: true, timeoutMs: 30000 }
34
+ * );
35
+ * ```
36
+ */
37
+ declare function fetchRhinoCompute<E extends Endpoint>(endpoint: E, args: Record<string, any>, config: ComputeConfig | GrasshopperComputeConfig): Promise<ComputeResponseFor<E>>;
38
+
39
+ declare const ErrorCodes: {
40
+ readonly NETWORK_ERROR: "NETWORK_ERROR";
41
+ readonly AUTH_ERROR: "AUTH_ERROR";
42
+ readonly VALIDATION_ERROR: "VALIDATION_ERROR";
43
+ readonly COMPUTATION_ERROR: "COMPUTATION_ERROR";
44
+ readonly TIMEOUT_ERROR: "TIMEOUT_ERROR";
45
+ readonly CORS_ERROR: "CORS_ERROR";
46
+ readonly UNKNOWN_ERROR: "UNKNOWN_ERROR";
47
+ readonly INVALID_STATE: "INVALID_STATE";
48
+ readonly INVALID_INPUT: "INVALID_INPUT";
49
+ readonly INVALID_CONFIG: "INVALID_CONFIG";
50
+ readonly BROWSER_ONLY: "BROWSER_ONLY";
51
+ readonly ENVIRONMENT_ERROR: "ENVIRONMENT_ERROR";
52
+ readonly ENCODING_ERROR: "ENCODING_ERROR";
53
+ };
54
+ type ErrorCode = (typeof ErrorCodes)[keyof typeof ErrorCodes];
55
+
56
+ /**
57
+ * Logger interface for structured logging
58
+ *
59
+ * @public Implement this interface to provide custom logging behavior.
60
+ */
61
+ interface Logger {
62
+ debug(message: string, ...args: unknown[]): void;
63
+ info(message: string, ...args: unknown[]): void;
64
+ warn(message: string, ...args: unknown[]): void;
65
+ error(message: string, ...args: unknown[]): void;
66
+ }
67
+ /**
68
+ * Get the current logger instance
69
+ *
70
+ * @returns The current logger instance
71
+ */
72
+ declare function getLogger(): Logger;
73
+ /**
74
+ * Set a custom logger instance
75
+ *
76
+ * @public Use this to configure custom logging behavior.
77
+ *
78
+ * @param logger - Custom logger implementation or null to disable logging
79
+ *
80
+ * @example
81
+ * ```typescript
82
+ * import { setLogger } from 'selva-compute';
83
+ *
84
+ * // Enable console logging
85
+ * setLogger(console);
86
+ *
87
+ * // Use a custom logger
88
+ * setLogger({
89
+ * debug: (msg, ...args) => myLogger.debug(msg, ...args),
90
+ * info: (msg, ...args) => myLogger.info(msg, ...args),
91
+ * warn: (msg, ...args) => myLogger.warn(msg, ...args),
92
+ * error: (msg, ...args) => myLogger.error(msg, ...args)
93
+ * });
94
+ *
95
+ * // Disable logging
96
+ * setLogger(null);
97
+ * ```
98
+ */
99
+ declare function setLogger(logger: Logger | Console | null): void;
100
+ /**
101
+ * Enable debug logging to console
102
+ *
103
+ * @public Convenience method to enable console logging.
104
+ *
105
+ * @example
106
+ * ```typescript
107
+ * import { enableDebugLogging } from 'selva-compute';
108
+ *
109
+ * enableDebugLogging();
110
+ * ```
111
+ */
112
+ declare function enableDebugLogging(): void;
113
+
114
+ export { ComputeConfig, type ErrorCode, ErrorCodes, type Logger, enableDebugLogging, fetchRhinoCompute, getLogger, setLogger };
package/dist/core.d.ts ADDED
@@ -0,0 +1,114 @@
1
+ import { C as ComputeConfig, c as GrasshopperComputeConfig, b as GrasshopperComputeResponse, f as IoResponseSchema } from './schemas-5LuPKgX2.js';
2
+ export { R as RhinoModelUnit } from './schemas-5LuPKgX2.js';
3
+ export { C as ComputeServerStats, R as RhinoComputeError } from './base-DbB0Ggdq.js';
4
+
5
+ /**
6
+ * Valid endpoints for Rhino Compute
7
+ */
8
+ type Endpoint = 'grasshopper' | 'io' | string;
9
+ type EndpointResponseMap = {
10
+ grasshopper: GrasshopperComputeResponse;
11
+ io: IoResponseSchema;
12
+ };
13
+ type ComputeResponseFor<E extends string> = E extends keyof EndpointResponseMap ? EndpointResponseMap[E] : unknown;
14
+ /**
15
+ * Generic Rhino Compute fetch function.
16
+ * Sends a POST request to any Compute endpoint with pre-prepared arguments.
17
+ *
18
+ * @public Use this for advanced low-level control over compute requests. For most use cases, prefer higher-level APIs.
19
+ *
20
+ * @param endpoint - The Compute API endpoint (e.g., 'grasshopper', 'io', 'mesh').
21
+ * @param args - Pre-prepared arguments for the request.
22
+ * @param config - Compute configuration (server URL, API key, timeout, debug).
23
+ * @returns The parsed JSON response from the server.
24
+ *
25
+ * @example
26
+ * ```typescript
27
+ * const response = await fetchRhinoCompute(
28
+ * 'grasshopper',
29
+ * {
30
+ * pointer: { url: 'https://example.com/definition.gh' },
31
+ * values: [{ ParamName: 'x', InnerTree: { '0': [{ type: 'System.Double', data: 10 }] } }]
32
+ * },
33
+ * { serverUrl: 'https://compute.rhino3d.com', debug: true, timeoutMs: 30000 }
34
+ * );
35
+ * ```
36
+ */
37
+ declare function fetchRhinoCompute<E extends Endpoint>(endpoint: E, args: Record<string, any>, config: ComputeConfig | GrasshopperComputeConfig): Promise<ComputeResponseFor<E>>;
38
+
39
+ declare const ErrorCodes: {
40
+ readonly NETWORK_ERROR: "NETWORK_ERROR";
41
+ readonly AUTH_ERROR: "AUTH_ERROR";
42
+ readonly VALIDATION_ERROR: "VALIDATION_ERROR";
43
+ readonly COMPUTATION_ERROR: "COMPUTATION_ERROR";
44
+ readonly TIMEOUT_ERROR: "TIMEOUT_ERROR";
45
+ readonly CORS_ERROR: "CORS_ERROR";
46
+ readonly UNKNOWN_ERROR: "UNKNOWN_ERROR";
47
+ readonly INVALID_STATE: "INVALID_STATE";
48
+ readonly INVALID_INPUT: "INVALID_INPUT";
49
+ readonly INVALID_CONFIG: "INVALID_CONFIG";
50
+ readonly BROWSER_ONLY: "BROWSER_ONLY";
51
+ readonly ENVIRONMENT_ERROR: "ENVIRONMENT_ERROR";
52
+ readonly ENCODING_ERROR: "ENCODING_ERROR";
53
+ };
54
+ type ErrorCode = (typeof ErrorCodes)[keyof typeof ErrorCodes];
55
+
56
+ /**
57
+ * Logger interface for structured logging
58
+ *
59
+ * @public Implement this interface to provide custom logging behavior.
60
+ */
61
+ interface Logger {
62
+ debug(message: string, ...args: unknown[]): void;
63
+ info(message: string, ...args: unknown[]): void;
64
+ warn(message: string, ...args: unknown[]): void;
65
+ error(message: string, ...args: unknown[]): void;
66
+ }
67
+ /**
68
+ * Get the current logger instance
69
+ *
70
+ * @returns The current logger instance
71
+ */
72
+ declare function getLogger(): Logger;
73
+ /**
74
+ * Set a custom logger instance
75
+ *
76
+ * @public Use this to configure custom logging behavior.
77
+ *
78
+ * @param logger - Custom logger implementation or null to disable logging
79
+ *
80
+ * @example
81
+ * ```typescript
82
+ * import { setLogger } from 'selva-compute';
83
+ *
84
+ * // Enable console logging
85
+ * setLogger(console);
86
+ *
87
+ * // Use a custom logger
88
+ * setLogger({
89
+ * debug: (msg, ...args) => myLogger.debug(msg, ...args),
90
+ * info: (msg, ...args) => myLogger.info(msg, ...args),
91
+ * warn: (msg, ...args) => myLogger.warn(msg, ...args),
92
+ * error: (msg, ...args) => myLogger.error(msg, ...args)
93
+ * });
94
+ *
95
+ * // Disable logging
96
+ * setLogger(null);
97
+ * ```
98
+ */
99
+ declare function setLogger(logger: Logger | Console | null): void;
100
+ /**
101
+ * Enable debug logging to console
102
+ *
103
+ * @public Convenience method to enable console logging.
104
+ *
105
+ * @example
106
+ * ```typescript
107
+ * import { enableDebugLogging } from 'selva-compute';
108
+ *
109
+ * enableDebugLogging();
110
+ * ```
111
+ */
112
+ declare function enableDebugLogging(): void;
113
+
114
+ export { ComputeConfig, type ErrorCode, ErrorCodes, type Logger, enableDebugLogging, fetchRhinoCompute, getLogger, setLogger };
package/dist/core.js ADDED
@@ -0,0 +1,2 @@
1
+ import{d as a,f as b,j as c,k as d,l as e,n as f,o as g}from"./chunk-24EXIE4G.js";export{g as ComputeServerStats,b as ErrorCodes,a as RhinoComputeError,e as enableDebugLogging,f as fetchRhinoCompute,c as getLogger,d as setLogger};
2
+ //# sourceMappingURL=core.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
package/dist/files.cjs ADDED
@@ -0,0 +1,2 @@
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunkTVCJBLSWcjs = require('./chunk-TVCJBLSW.cjs');require('./chunk-5DJRUPGI.cjs');require('./chunk-P57VU27W.cjs');exports.downloadFileData = _chunkTVCJBLSWcjs.b; exports.extractFilesFromComputeResponse = _chunkTVCJBLSWcjs.a;
2
+ //# sourceMappingURL=files.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["/Users/felix/coding/selva-compute/dist/files.cjs"],"names":[],"mappings":"AAAA,iIAAqC,gCAA6B,gCAA6B,8GAAmE","file":"/Users/felix/coding/selva-compute/dist/files.cjs"}
@@ -0,0 +1,34 @@
1
+ import { F as FileData, a as FileBaseInfo, P as ProcessedFile } from './types-SwbLAMW8.cjs';
2
+
3
+ /**
4
+ * Extracts and processes files from compute response data without downloading them.
5
+ * Returns an array of ProcessedFile objects that can be used programmatically.
6
+ *
7
+ * @param downloadableFiles - An array of FileData items from the compute response.
8
+ * @param additionalFiles - Optional additional files to include (fetched from URLs).
9
+ * @returns A Promise resolving to an array of ProcessedFile objects.
10
+ * @throws Will throw an error if file processing fails.
11
+ *
12
+ * @example
13
+ * const files = await extractFilesFromComputeResponse(fileData);
14
+ * files.forEach(file => {
15
+ * console.log(`File: ${file.fileName}, Size: ${file.content.length}`);
16
+ * });
17
+ */
18
+ declare const extractFilesFromComputeResponse: (downloadableFiles: FileData[], additionalFiles?: FileBaseInfo[] | FileBaseInfo | null) => Promise<ProcessedFile[]>;
19
+ /**
20
+ * Downloads files from a compute response as a ZIP archive.
21
+ * Packages multiple files into a single ZIP file and triggers a browser download.
22
+ *
23
+ * @param downloadableFiles - An array of FileData items from the compute response.
24
+ * @param additionalFiles - Optional additional files to include in the ZIP (fetched from URLs).
25
+ * @param fileFoldername - The name of the ZIP file (without extension).
26
+ * @throws Will throw an error if the file handling or download fails.
27
+ *
28
+ * @example
29
+ * await downloadDataFromComputeResponse(fileData, null, 'my-export');
30
+ * // Downloads 'my-export.zip'
31
+ */
32
+ declare const downloadFileData: (downloadableFiles: FileData[], fileFoldername: string, additionalFiles?: FileBaseInfo[] | FileBaseInfo | null) => Promise<void>;
33
+
34
+ export { FileBaseInfo, FileData, ProcessedFile, downloadFileData, extractFilesFromComputeResponse };
@@ -0,0 +1,34 @@
1
+ import { F as FileData, a as FileBaseInfo, P as ProcessedFile } from './types-SwbLAMW8.js';
2
+
3
+ /**
4
+ * Extracts and processes files from compute response data without downloading them.
5
+ * Returns an array of ProcessedFile objects that can be used programmatically.
6
+ *
7
+ * @param downloadableFiles - An array of FileData items from the compute response.
8
+ * @param additionalFiles - Optional additional files to include (fetched from URLs).
9
+ * @returns A Promise resolving to an array of ProcessedFile objects.
10
+ * @throws Will throw an error if file processing fails.
11
+ *
12
+ * @example
13
+ * const files = await extractFilesFromComputeResponse(fileData);
14
+ * files.forEach(file => {
15
+ * console.log(`File: ${file.fileName}, Size: ${file.content.length}`);
16
+ * });
17
+ */
18
+ declare const extractFilesFromComputeResponse: (downloadableFiles: FileData[], additionalFiles?: FileBaseInfo[] | FileBaseInfo | null) => Promise<ProcessedFile[]>;
19
+ /**
20
+ * Downloads files from a compute response as a ZIP archive.
21
+ * Packages multiple files into a single ZIP file and triggers a browser download.
22
+ *
23
+ * @param downloadableFiles - An array of FileData items from the compute response.
24
+ * @param additionalFiles - Optional additional files to include in the ZIP (fetched from URLs).
25
+ * @param fileFoldername - The name of the ZIP file (without extension).
26
+ * @throws Will throw an error if the file handling or download fails.
27
+ *
28
+ * @example
29
+ * await downloadDataFromComputeResponse(fileData, null, 'my-export');
30
+ * // Downloads 'my-export.zip'
31
+ */
32
+ declare const downloadFileData: (downloadableFiles: FileData[], fileFoldername: string, additionalFiles?: FileBaseInfo[] | FileBaseInfo | null) => Promise<void>;
33
+
34
+ export { FileBaseInfo, FileData, ProcessedFile, downloadFileData, extractFilesFromComputeResponse };
package/dist/files.js ADDED
@@ -0,0 +1,2 @@
1
+ import{a,b}from"./chunk-JJLRDYYP.js";import"./chunk-AEQTQHPY.js";import"./chunk-24EXIE4G.js";export{b as downloadFileData,a as extractFilesFromComputeResponse};
2
+ //# sourceMappingURL=files.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
@@ -0,0 +1,2 @@
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunkPNG3L5TMcjs = require('./chunk-PNG3L5TM.cjs');require('./chunk-TVCJBLSW.cjs');require('./chunk-5DJRUPGI.cjs');var _chunkP57VU27Wcjs = require('./chunk-P57VU27W.cjs');exports.GrasshopperClient = _chunkPNG3L5TMcjs.a; exports.GrasshopperResponseProcessor = _chunkPNG3L5TMcjs.b; exports.RhinoComputeError = _chunkP57VU27Wcjs.d; exports.TreeBuilder = _chunkPNG3L5TMcjs.h; exports.fetchDefinitionIO = _chunkPNG3L5TMcjs.f; exports.fetchParsedDefinitionIO = _chunkPNG3L5TMcjs.g; exports.processInput = _chunkPNG3L5TMcjs.d; exports.processInputs = _chunkPNG3L5TMcjs.e; exports.solveGrasshopperDefinition = _chunkPNG3L5TMcjs.c;
2
+ //# sourceMappingURL=grasshopper.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["/Users/felix/coding/selva-compute/dist/grasshopper.cjs"],"names":[],"mappings":"AAAA,iIAAyF,gCAA6B,gCAA6B,wDAAyC,mcAAkO","file":"/Users/felix/coding/selva-compute/dist/grasshopper.cjs"}