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.
- package/LICENSE.md +21 -0
- package/README.md +110 -0
- package/dist/base-DbB0Ggdq.d.cts +118 -0
- package/dist/base-DbB0Ggdq.d.ts +118 -0
- package/dist/chunk-24EXIE4G.js +3 -0
- package/dist/chunk-24EXIE4G.js.map +1 -0
- package/dist/chunk-5DJRUPGI.cjs +2 -0
- package/dist/chunk-5DJRUPGI.cjs.map +1 -0
- package/dist/chunk-AEQTQHPY.js +2 -0
- package/dist/chunk-AEQTQHPY.js.map +1 -0
- package/dist/chunk-JJLRDYYP.js +2 -0
- package/dist/chunk-JJLRDYYP.js.map +1 -0
- package/dist/chunk-OXD76DAK.js +2 -0
- package/dist/chunk-OXD76DAK.js.map +1 -0
- package/dist/chunk-P57VU27W.cjs +3 -0
- package/dist/chunk-P57VU27W.cjs.map +1 -0
- package/dist/chunk-PNG3L5TM.cjs +2 -0
- package/dist/chunk-PNG3L5TM.cjs.map +1 -0
- package/dist/chunk-TVCJBLSW.cjs +2 -0
- package/dist/chunk-TVCJBLSW.cjs.map +1 -0
- package/dist/core.cjs +2 -0
- package/dist/core.cjs.map +1 -0
- package/dist/core.d.cts +114 -0
- package/dist/core.d.ts +114 -0
- package/dist/core.js +2 -0
- package/dist/core.js.map +1 -0
- package/dist/files.cjs +2 -0
- package/dist/files.cjs.map +1 -0
- package/dist/files.d.cts +34 -0
- package/dist/files.d.ts +34 -0
- package/dist/files.js +2 -0
- package/dist/files.js.map +1 -0
- package/dist/grasshopper.cjs +2 -0
- package/dist/grasshopper.cjs.map +1 -0
- package/dist/grasshopper.d.cts +741 -0
- package/dist/grasshopper.d.ts +741 -0
- package/dist/grasshopper.js +2 -0
- package/dist/grasshopper.js.map +1 -0
- package/dist/index.cjs +2 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +8 -0
- package/dist/index.d.ts +8 -0
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -0
- package/dist/schemas-5LuPKgX2.d.cts +202 -0
- package/dist/schemas-5LuPKgX2.d.ts +202 -0
- package/dist/types-SwbLAMW8.d.cts +27 -0
- package/dist/types-SwbLAMW8.d.ts +27 -0
- package/dist/types-r00wVwfo.d.cts +77 -0
- package/dist/types-r00wVwfo.d.ts +77 -0
- package/dist/visualization.cjs +2 -0
- package/dist/visualization.cjs.map +1 -0
- package/dist/visualization.d.cts +202 -0
- package/dist/visualization.d.ts +202 -0
- package/dist/visualization.js +2 -0
- package/dist/visualization.js.map +1 -0
- package/package.json +117 -0
package/LICENSE.md
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 Selva FelixBrunold VektorNode
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
# selva-compute
|
|
2
|
+
|
|
3
|
+
A high-level TypeScript framework for building web applications with Rhino Compute and Grasshopper.
|
|
4
|
+
|
|
5
|
+
`selva-compute` simplifies the process of communicating with Rhino Compute, handling Grasshopper definitions, and visualizing results in the browser with Three.js.
|
|
6
|
+
|
|
7
|
+
## Installation
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
npm install selva-compute three
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
_(Note: `three` is a peer dependency if you use the visualization features)_
|
|
14
|
+
|
|
15
|
+
## Quick Start
|
|
16
|
+
|
|
17
|
+
### 1. Initialize the Client
|
|
18
|
+
|
|
19
|
+
```typescript
|
|
20
|
+
import { RhinoComputeApp } from 'selva-compute';
|
|
21
|
+
|
|
22
|
+
const app = new RhinoComputeApp({
|
|
23
|
+
url: 'http://localhost:6500/', // URL of your Rhino Compute instance
|
|
24
|
+
apiKey: 'your-auth-token', // Optional
|
|
25
|
+
debug: true // Enable logging
|
|
26
|
+
});
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
### 2. Solve a Grasshopper Definition
|
|
30
|
+
|
|
31
|
+
```typescript
|
|
32
|
+
// Define your inputs
|
|
33
|
+
const inputs = {
|
|
34
|
+
Length: 12.5,
|
|
35
|
+
Width: 5.0,
|
|
36
|
+
Count: 10
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
// Solve the definition
|
|
40
|
+
try {
|
|
41
|
+
const result = await app.solve('my_definition.gh', inputs);
|
|
42
|
+
|
|
43
|
+
// Access outputs
|
|
44
|
+
console.log('Results:', result.values);
|
|
45
|
+
console.log('Geometry:', result.geometry); // Decoded rhino3dm objects
|
|
46
|
+
} catch (error) {
|
|
47
|
+
console.error('Computation failed:', error);
|
|
48
|
+
}
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
## Comparison: selva-compute vs compute-rhino3d
|
|
52
|
+
|
|
53
|
+
| Feature | selva-compute | compute-rhino3d (Official) |
|
|
54
|
+
| :---------------------- | :--------------------------------------- | :----------------------------- |
|
|
55
|
+
| **Primary Goal** | Application Framework | API Wrapper |
|
|
56
|
+
| **Abstraction Level** | High (Apps, Definitions, UI) | Low (Geometry, Direct Calls) |
|
|
57
|
+
| **Grasshopper Solving** | Optimized, Schema-aware | Basic `solve` endpoint wrapper |
|
|
58
|
+
| **Geometry Handling** | Automatic decoding to `rhino3dm` | Returns raw JSON/base64 |
|
|
59
|
+
| **Visualization** | Includes `three.js` converters & helpers | Manual implementation required |
|
|
60
|
+
| **Typing** | TypeScript-first, handwritten for DX | Auto-generated from C# |
|
|
61
|
+
|
|
62
|
+
**Choose `selva-compute` if:**
|
|
63
|
+
|
|
64
|
+
- You are building a web app (Svelte, React, Vue, etc.) that interacts with Grasshopper.
|
|
65
|
+
- You want "batteries-included" features like geometry decoding and three.js visualization.
|
|
66
|
+
- You prefer a cleaner, more idiomatic TypeScript API for definition solving.
|
|
67
|
+
|
|
68
|
+
**Choose `compute-rhino3d` if:**
|
|
69
|
+
|
|
70
|
+
- You need to call specific low-level Rhino geometry functions (e.g. `Intersection.brepPlane`) directly from JS.
|
|
71
|
+
- You are building a complex script that chains geometry operations without a GH definition.
|
|
72
|
+
|
|
73
|
+
## Features
|
|
74
|
+
|
|
75
|
+
- **Robust Client**: Handles connection, retries, and error parsing.
|
|
76
|
+
- **Smart Solving**: Automatically formats inputs and parses output trees.
|
|
77
|
+
- **Visualization Tools**: Convert Rhino geometry to Three.js objects easily.
|
|
78
|
+
```typescript
|
|
79
|
+
import { toThreeJs } from 'selva-compute/visualization';
|
|
80
|
+
const mesh = toThreeJs(rhinoMesh);
|
|
81
|
+
scene.add(mesh);
|
|
82
|
+
```
|
|
83
|
+
- **File Utils**: Helpers for handling base64 encoding/decoding of Rhino files.
|
|
84
|
+
|
|
85
|
+
## Exports
|
|
86
|
+
|
|
87
|
+
- `selva-compute` - Main entry point (Client, App).
|
|
88
|
+
- `selva-compute/grasshopper` - Grasshopper client and types.
|
|
89
|
+
- `selva-compute/visualization` - Three.js conversion helpers.
|
|
90
|
+
- `selva-compute/files` - File utilities.
|
|
91
|
+
|
|
92
|
+
## Requirements
|
|
93
|
+
|
|
94
|
+
### Server Side
|
|
95
|
+
|
|
96
|
+
`selva-compute` is compatible with standard Rhino Compute, but to unlock its full potential, we recommend:
|
|
97
|
+
|
|
98
|
+
1. **Selva Rhino Plugin** (Recommended): Adds support for advanced display modes and optimized serialization. [Download from Food4Rhino](https://www.food4rhino.com/en/app/selva?lang=en).
|
|
99
|
+
2. **Custom Compute Server** (Optional): Standard Rhino Compute works for basic solving. However, our **[custom branch](https://github.com/VektorNode/compute.rhino3d)** is required if you want to use:
|
|
100
|
+
- **Input Grouping**: Support for the `groupName` property in parameters.
|
|
101
|
+
- **Persistent IDs**: Support for the `id` property to uniquely identify inputs across definition changes.
|
|
102
|
+
|
|
103
|
+
### Client Side
|
|
104
|
+
|
|
105
|
+
- Node.js >= 20
|
|
106
|
+
- Optional: `three` >= 0.160.0 for visualization features
|
|
107
|
+
|
|
108
|
+
## License
|
|
109
|
+
|
|
110
|
+
MIT
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ComputeServerStats provides methods to query Rhino Compute server statistics.
|
|
3
|
+
*
|
|
4
|
+
* @public Use this for server health monitoring and statistics.
|
|
5
|
+
*
|
|
6
|
+
* @example
|
|
7
|
+
* ```typescript
|
|
8
|
+
* const stats = new ComputeServerStats('http://localhost:6500', 'your-api-key');
|
|
9
|
+
*
|
|
10
|
+
* try {
|
|
11
|
+
* const isOnline = await stats.isServerOnline();
|
|
12
|
+
* const children = await stats.getActiveChildren();
|
|
13
|
+
* const version = await stats.getVersion();
|
|
14
|
+
*
|
|
15
|
+
* // Or get everything at once
|
|
16
|
+
* const allStats = await stats.getServerStats();
|
|
17
|
+
* } finally {
|
|
18
|
+
* await stats.dispose(); // Clean up resources
|
|
19
|
+
* }
|
|
20
|
+
* ```
|
|
21
|
+
*/
|
|
22
|
+
declare class ComputeServerStats {
|
|
23
|
+
private readonly serverUrl;
|
|
24
|
+
private readonly apiKey?;
|
|
25
|
+
private disposed;
|
|
26
|
+
private activeMonitors;
|
|
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
|
+
constructor(serverUrl: string, apiKey?: string);
|
|
33
|
+
/**
|
|
34
|
+
* Build request headers with optional API key.
|
|
35
|
+
*/
|
|
36
|
+
private buildHeaders;
|
|
37
|
+
/**
|
|
38
|
+
* Check if the server is online.
|
|
39
|
+
*/
|
|
40
|
+
isServerOnline(): Promise<boolean>;
|
|
41
|
+
/**
|
|
42
|
+
* Get the number of active child processes on the server.
|
|
43
|
+
*
|
|
44
|
+
* @returns Number of active children, or null if unavailable
|
|
45
|
+
*/
|
|
46
|
+
getActiveChildren(): Promise<number | null>;
|
|
47
|
+
/**
|
|
48
|
+
* Get the server version information.
|
|
49
|
+
*
|
|
50
|
+
* @returns Version object with rhino, compute, and git_sha, or null if unavailable
|
|
51
|
+
*/
|
|
52
|
+
getVersion(): Promise<{
|
|
53
|
+
rhino: string;
|
|
54
|
+
compute: string;
|
|
55
|
+
git_sha: string | null;
|
|
56
|
+
} | null>;
|
|
57
|
+
/**
|
|
58
|
+
* Get comprehensive server statistics.
|
|
59
|
+
* Fetches all available server information in parallel.
|
|
60
|
+
*
|
|
61
|
+
* @returns Object containing server status and available stats
|
|
62
|
+
*/
|
|
63
|
+
getServerStats(): Promise<{
|
|
64
|
+
isOnline: boolean;
|
|
65
|
+
version?: {
|
|
66
|
+
rhino: string;
|
|
67
|
+
compute: string;
|
|
68
|
+
git_sha: string | null;
|
|
69
|
+
};
|
|
70
|
+
activeChildren?: number;
|
|
71
|
+
}>;
|
|
72
|
+
/**
|
|
73
|
+
* Continuously monitor server stats at specified interval.
|
|
74
|
+
*
|
|
75
|
+
* @param callback - Function called with stats on each interval
|
|
76
|
+
* @param intervalMs - Milliseconds between checks (default: 5000)
|
|
77
|
+
* @returns Function to stop monitoring
|
|
78
|
+
*
|
|
79
|
+
* @example
|
|
80
|
+
* ```typescript
|
|
81
|
+
* const stopMonitoring = stats.monitor((data) => {
|
|
82
|
+
* console.log('Server stats:', data);
|
|
83
|
+
* }, 3000);
|
|
84
|
+
*
|
|
85
|
+
* // Later...
|
|
86
|
+
* stopMonitoring();
|
|
87
|
+
* ```
|
|
88
|
+
*/
|
|
89
|
+
monitor(callback: (stats: Awaited<ReturnType<typeof this.getServerStats>>) => void, intervalMs?: number): () => void;
|
|
90
|
+
/**
|
|
91
|
+
* Disposes of all resources and stops all active monitors.
|
|
92
|
+
* Call this when you're done using the stats instance.
|
|
93
|
+
*/
|
|
94
|
+
dispose(): Promise<void>;
|
|
95
|
+
/**
|
|
96
|
+
* Ensures the instance hasn't been disposed.
|
|
97
|
+
*/
|
|
98
|
+
private ensureNotDisposed;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
/**
|
|
102
|
+
* Simplified error for Rhino Compute operations
|
|
103
|
+
*
|
|
104
|
+
* @public Use this for error handling with error codes and context.
|
|
105
|
+
*/
|
|
106
|
+
declare class RhinoComputeError extends Error {
|
|
107
|
+
readonly code: string;
|
|
108
|
+
readonly statusCode?: number;
|
|
109
|
+
readonly context?: Record<string, unknown>;
|
|
110
|
+
readonly originalError?: Error;
|
|
111
|
+
constructor(message: string, code?: string, options?: {
|
|
112
|
+
statusCode?: number;
|
|
113
|
+
context?: Record<string, unknown>;
|
|
114
|
+
originalError?: Error;
|
|
115
|
+
});
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
export { ComputeServerStats as C, RhinoComputeError as R };
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ComputeServerStats provides methods to query Rhino Compute server statistics.
|
|
3
|
+
*
|
|
4
|
+
* @public Use this for server health monitoring and statistics.
|
|
5
|
+
*
|
|
6
|
+
* @example
|
|
7
|
+
* ```typescript
|
|
8
|
+
* const stats = new ComputeServerStats('http://localhost:6500', 'your-api-key');
|
|
9
|
+
*
|
|
10
|
+
* try {
|
|
11
|
+
* const isOnline = await stats.isServerOnline();
|
|
12
|
+
* const children = await stats.getActiveChildren();
|
|
13
|
+
* const version = await stats.getVersion();
|
|
14
|
+
*
|
|
15
|
+
* // Or get everything at once
|
|
16
|
+
* const allStats = await stats.getServerStats();
|
|
17
|
+
* } finally {
|
|
18
|
+
* await stats.dispose(); // Clean up resources
|
|
19
|
+
* }
|
|
20
|
+
* ```
|
|
21
|
+
*/
|
|
22
|
+
declare class ComputeServerStats {
|
|
23
|
+
private readonly serverUrl;
|
|
24
|
+
private readonly apiKey?;
|
|
25
|
+
private disposed;
|
|
26
|
+
private activeMonitors;
|
|
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
|
+
constructor(serverUrl: string, apiKey?: string);
|
|
33
|
+
/**
|
|
34
|
+
* Build request headers with optional API key.
|
|
35
|
+
*/
|
|
36
|
+
private buildHeaders;
|
|
37
|
+
/**
|
|
38
|
+
* Check if the server is online.
|
|
39
|
+
*/
|
|
40
|
+
isServerOnline(): Promise<boolean>;
|
|
41
|
+
/**
|
|
42
|
+
* Get the number of active child processes on the server.
|
|
43
|
+
*
|
|
44
|
+
* @returns Number of active children, or null if unavailable
|
|
45
|
+
*/
|
|
46
|
+
getActiveChildren(): Promise<number | null>;
|
|
47
|
+
/**
|
|
48
|
+
* Get the server version information.
|
|
49
|
+
*
|
|
50
|
+
* @returns Version object with rhino, compute, and git_sha, or null if unavailable
|
|
51
|
+
*/
|
|
52
|
+
getVersion(): Promise<{
|
|
53
|
+
rhino: string;
|
|
54
|
+
compute: string;
|
|
55
|
+
git_sha: string | null;
|
|
56
|
+
} | null>;
|
|
57
|
+
/**
|
|
58
|
+
* Get comprehensive server statistics.
|
|
59
|
+
* Fetches all available server information in parallel.
|
|
60
|
+
*
|
|
61
|
+
* @returns Object containing server status and available stats
|
|
62
|
+
*/
|
|
63
|
+
getServerStats(): Promise<{
|
|
64
|
+
isOnline: boolean;
|
|
65
|
+
version?: {
|
|
66
|
+
rhino: string;
|
|
67
|
+
compute: string;
|
|
68
|
+
git_sha: string | null;
|
|
69
|
+
};
|
|
70
|
+
activeChildren?: number;
|
|
71
|
+
}>;
|
|
72
|
+
/**
|
|
73
|
+
* Continuously monitor server stats at specified interval.
|
|
74
|
+
*
|
|
75
|
+
* @param callback - Function called with stats on each interval
|
|
76
|
+
* @param intervalMs - Milliseconds between checks (default: 5000)
|
|
77
|
+
* @returns Function to stop monitoring
|
|
78
|
+
*
|
|
79
|
+
* @example
|
|
80
|
+
* ```typescript
|
|
81
|
+
* const stopMonitoring = stats.monitor((data) => {
|
|
82
|
+
* console.log('Server stats:', data);
|
|
83
|
+
* }, 3000);
|
|
84
|
+
*
|
|
85
|
+
* // Later...
|
|
86
|
+
* stopMonitoring();
|
|
87
|
+
* ```
|
|
88
|
+
*/
|
|
89
|
+
monitor(callback: (stats: Awaited<ReturnType<typeof this.getServerStats>>) => void, intervalMs?: number): () => void;
|
|
90
|
+
/**
|
|
91
|
+
* Disposes of all resources and stops all active monitors.
|
|
92
|
+
* Call this when you're done using the stats instance.
|
|
93
|
+
*/
|
|
94
|
+
dispose(): Promise<void>;
|
|
95
|
+
/**
|
|
96
|
+
* Ensures the instance hasn't been disposed.
|
|
97
|
+
*/
|
|
98
|
+
private ensureNotDisposed;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
/**
|
|
102
|
+
* Simplified error for Rhino Compute operations
|
|
103
|
+
*
|
|
104
|
+
* @public Use this for error handling with error codes and context.
|
|
105
|
+
*/
|
|
106
|
+
declare class RhinoComputeError extends Error {
|
|
107
|
+
readonly code: string;
|
|
108
|
+
readonly statusCode?: number;
|
|
109
|
+
readonly context?: Record<string, unknown>;
|
|
110
|
+
readonly originalError?: Error;
|
|
111
|
+
constructor(message: string, code?: string, options?: {
|
|
112
|
+
statusCode?: number;
|
|
113
|
+
context?: Record<string, unknown>;
|
|
114
|
+
originalError?: Error;
|
|
115
|
+
});
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
export { ComputeServerStats as C, RhinoComputeError as R };
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
var E=Object.defineProperty;var S=Object.getOwnPropertyDescriptor;var I=Object.getOwnPropertyNames;var $=Object.prototype.hasOwnProperty;var x=(r,e,t)=>e in r?E(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t;var f=(r,e)=>()=>(r&&(e=r(r=0)),e);var _=(r,e)=>{for(var t in e)E(r,t,{get:e[t],enumerable:!0})},L=(r,e,t,o)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of I(e))!$.call(r,n)&&n!==t&&E(r,n,{get:()=>e[n],enumerable:!(o=S(e,n))||o.enumerable});return r};var F=r=>L(E({},"__esModule",{value:!0}),r);var d=(r,e,t)=>x(r,typeof e!="symbol"?e+"":e,t);var p,w=f(()=>{"use strict";p=class extends Error{constructor(t,o="UNKNOWN_ERROR",n){super(t);d(this,"code");d(this,"statusCode");d(this,"context");d(this,"originalError");this.name="RhinoComputeError",this.code=o,this.statusCode=n?.statusCode,this.context=n?.context,this.originalError=n?.originalError,"cause"in Error.prototype&&Object.defineProperty(this,"cause",{value:n?.originalError,enumerable:!0})}}});var i,N=f(()=>{"use strict";i={NETWORK_ERROR:"NETWORK_ERROR",AUTH_ERROR:"AUTH_ERROR",VALIDATION_ERROR:"VALIDATION_ERROR",COMPUTATION_ERROR:"COMPUTATION_ERROR",TIMEOUT_ERROR:"TIMEOUT_ERROR",CORS_ERROR:"CORS_ERROR",UNKNOWN_ERROR:"UNKNOWN_ERROR",INVALID_STATE:"INVALID_STATE",INVALID_INPUT:"INVALID_INPUT",INVALID_CONFIG:"INVALID_CONFIG",BROWSER_ONLY:"BROWSER_ONLY",ENVIRONMENT_ERROR:"ENVIRONMENT_ERROR",ENCODING_ERROR:"ENCODING_ERROR"}});var A={};_(A,{ErrorCodes:()=>i,RhinoComputeError:()=>p});var C=f(()=>{"use strict";w();N()});function l(){return v}function b(r){r===null?v=new O:"debug"in r&&"info"in r&&"warn"in r&&"error"in r?v=r:v=new T}function M(){b(new T)}var O,T,v,y=f(()=>{"use strict";O=class{debug(){}info(){}warn(){}error(){}},T=class{debug(e,...t){console.debug(e,...t)}info(e,...t){console.info(e,...t)}warn(e,...t){console.warn(e,...t)}error(e,...t){console.error(e,...t)}},v=new O});C();y();import U from"compute-rhino3d";function D(r,e,t,o,n,R){let{status:a,statusText:u}=r,c={url:e,requestId:t,method:"POST",requestSize:o,serverUrl:n},h={401:{message:`HTTP ${a}: ${u}`,code:i.AUTH_ERROR},403:{message:`HTTP ${a}: ${u}`,code:i.AUTH_ERROR},404:{message:`Endpoint not found: ${e}`,code:i.NETWORK_ERROR},413:{message:`Request too large: ${(o/1024).toFixed(2)}KB`,code:i.VALIDATION_ERROR},429:{message:"Rate limit exceeded",code:i.NETWORK_ERROR},500:{message:`Server error: ${R||u}`,code:i.COMPUTATION_ERROR},502:{message:`Service unavailable: ${u}`,code:i.NETWORK_ERROR},503:{message:`Service unavailable: ${u}`,code:i.NETWORK_ERROR},504:{message:`Service unavailable: ${u}`,code:i.NETWORK_ERROR}}[a]||{message:`HTTP ${a}: ${u}`,code:i.UNKNOWN_ERROR};throw new p(h.message,h.code,{statusCode:a,context:c})}function K(r,e){let t=e.replace(/\/+$/,""),o=r.replace(/^\/+/,"");return`${t}/${o}`}function k(r){try{let e=new URL(r).host;return/^(localhost|127\.0\.0\.1|::1)(:\d+)?$/i.test(e)}catch{return/(localhost|127\.0\.0\.1)/i.test(r)}}function P(r,e){let t={"User-Agent":`compute.rhino3d.js/${U.version}`,"X-Request-ID":r,"Content-Type":"application/json",...e.authToken&&{Authorization:e.authToken},...e.apiKey&&{RhinoComputeKey:e.apiKey}};return!e.apiKey&&!k(e.serverUrl)&&l().warn(`\u26A0\uFE0F [Rhino Compute] Request [${r}] targets remote server (${e.serverUrl}) but no API key is configured. Requests may fail or be rate-limited.`),t}function H(){return`${Date.now()}-${Math.random().toString(36).substring(2,11)}`}function m(r,e){e&&l().debug(r)}async function V(r,e,t,o,n,R,a){let u=Math.round(performance.now()-R);if(!r.ok){let c=await r.text();if(a&&(m(`\u274C Request [${t}] failed with HTTP ${r.status} in ${u}ms`,!0),m(` URL: ${e}`,!0),m(` Status: ${r.status} ${r.statusText}`,!0),c&&m(` Response body: ${c.substring(0,500)}${c.length>500?"...":""}`,!0)),r.status===500)try{let s=JSON.parse(c);if(s?.values&&(s.errors||s.warnings))return a&&(m(`\u26A0\uFE0F Request [${t}] completed with Grasshopper errors in ${u}ms`,!0),s.errors?.length>0&&m(` Errors: ${JSON.stringify(s.errors,null,2)}`,!0),s.warnings?.length>0&&m(` Warnings: ${JSON.stringify(s.warnings,null,2)}`,!0)),s;s?.Message?c=`${s.ExceptionType?s.ExceptionType+": ":""}${s.Message}
|
|
2
|
+
${s.StackTrace||""}`:s?.error&&(c=typeof s.error=="string"?s.error:JSON.stringify(s.error,null,2))}catch(s){a&&m(` Failed to parse error body as JSON: ${s}`,!0)}D(r,e,t,o,n,c)}m(`\u2705 Request [${t}] completed in ${u}ms`,a);try{return await r.json()}catch(c){throw new p("Failed to parse JSON response",i.NETWORK_ERROR,{statusCode:r.status,context:{url:e,requestId:t},originalError:c instanceof Error?c:new Error(String(c))})}}async function W(r,e,t){let o=H(),n=JSON.stringify(e),R=n.length,a=K(r,t.serverUrl);if(t.debug){let s=(R/1024).toFixed(2),h=R>1e5?"\u26A0\uFE0F":"\u{1F680}";m(`${h} Starting compute request [${o}]: ${r} (${s}KB)`,!0)}let u=new AbortController,c=t.timeoutMs?setTimeout(()=>u.abort(),t.timeoutMs):null;try{let s=performance.now(),h=await fetch(a,{method:"POST",body:n,headers:P(o,t),signal:u.signal});return await V(h,a,o,R,t.serverUrl,s,t.debug)}catch(s){throw s instanceof Error&&s.name==="AbortError"&&t.timeoutMs?new p(`Request timed out after ${t.timeoutMs}ms`,i.TIMEOUT_ERROR,{context:{serverUrl:t.serverUrl,timeoutMs:t.timeoutMs,url:a,requestId:o,args:e}}):s instanceof TypeError?new p(`Network error: ${s.message}`,i.NETWORK_ERROR,{context:{serverUrl:t.serverUrl,url:a,requestId:o,endpoint:r},originalError:s}):s}finally{c!==null&&clearTimeout(c)}}C();y();var g=class{constructor(e,t){d(this,"serverUrl");d(this,"apiKey");d(this,"disposed",!1);d(this,"activeMonitors",new Set);d(this,"activeTimeouts",new Set);if(!e?.trim())throw new p("serverUrl is required",i.INVALID_CONFIG,{context:{serverUrl:e}});if(!e.match(/^https?:\/\//))throw new p(`Invalid serverUrl: "${e}". Must start with "http://" or "https://". For example: "http://localhost:5000" or "https://example.com"`,i.INVALID_CONFIG,{context:{serverUrl:e}});try{new URL(e)}catch(o){throw new p(`Invalid serverUrl: "${e}". Must be a valid URL. Received error: ${o instanceof Error?o.message:String(o)}`,i.INVALID_CONFIG,{context:{serverUrl:e},originalError:o instanceof Error?o:void 0})}this.apiKey=t,this.serverUrl=e.replace(/\/+$/,"")}buildHeaders(){let e={"Content-Type":"application/json"};return this.apiKey&&(e.RhinoComputeKey=this.apiKey),e}async isServerOnline(){this.ensureNotDisposed();let e=`${this.serverUrl}/healthcheck`,t={headers:this.buildHeaders(),method:"GET"};try{return(await fetch(e,t)).ok}catch(o){return l().debug("[ComputeServerStats] Fetch error:",o),!1}}async getActiveChildren(){this.ensureNotDisposed();try{let e=await fetch(`${this.serverUrl}/activechildren`,{headers:this.buildHeaders()});if(!e.ok)return l().warn("[ComputeServerStats] Failed to fetch active children:",e.status),null;let t=await e.text(),o=parseInt(t.trim(),10);return isNaN(o)?(l().warn("[ComputeServerStats] Invalid active children response:",t),null):o}catch(e){return l().warn("[ComputeServerStats] Error fetching active children:",e),null}}async getVersion(){this.ensureNotDisposed();try{let e=await fetch(`${this.serverUrl}/version`,{headers:this.buildHeaders()});if(!e.ok)return l().warn("[ComputeServerStats] Failed to fetch version:",e.status),null;try{let t=await e.json();return{rhino:t.rhino??"",compute:t.compute??"",git_sha:t.git_sha??null}}catch{return{rhino:await e.text(),compute:"",git_sha:null}}}catch(e){return l().warn("[ComputeServerStats] Error fetching version:",e),null}}async getServerStats(){if(this.ensureNotDisposed(),!await this.isServerOnline())return{isOnline:!1};let[t,o]=await Promise.all([this.getVersion(),this.getActiveChildren()]);return{isOnline:!0,...t&&{version:t},...o!==null&&{activeChildren:o}}}monitor(e,t=5e3){this.ensureNotDisposed();let o=!0,n=null;l().info(`\u{1F504} Starting server stats monitoring every ${t}ms`);let R=async()=>{if(n!==null&&(this.activeTimeouts.delete(n),n=null),!o||this.disposed)return;let u=await this.getServerStats();!o||this.disposed||(e(u),o&&!this.disposed&&(n=setTimeout(()=>{R()},t),this.activeTimeouts.add(n)))},a=()=>{o=!1,n!==null&&(clearTimeout(n),this.activeTimeouts.delete(n),n=null),this.activeMonitors.delete(a)};return this.activeMonitors.add(a),R(),a}async dispose(){if(!this.disposed){this.disposed=!0;for(let e of this.activeMonitors)e();this.activeMonitors.clear();for(let e of this.activeTimeouts)clearTimeout(e);this.activeTimeouts.clear()}}ensureNotDisposed(){if(this.disposed)throw new p("ComputeServerStats has been disposed and cannot be used",i.INVALID_STATE,{context:{disposed:this.disposed}})}};w();N();y();export{_ as a,F as b,d as c,p as d,w as e,i as f,N as g,A as h,C as i,l as j,b as k,M as l,y as m,W as n,g as o};
|
|
3
|
+
//# sourceMappingURL=chunk-24EXIE4G.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/core/errors/base.ts","../src/core/errors/error-codes.ts","../src/core/errors/index.ts","../src/core/utils/logger.ts","../src/core/compute-fetch/compute-fetch.ts","../src/core/server/compute-server-stats.ts","../src/core/index.ts"],"sourcesContent":["/**\n * Simplified error for Rhino Compute operations\n *\n * @public Use this for error handling with error codes and context.\n */\nexport class RhinoComputeError extends Error {\n\tpublic readonly code: string;\n\tpublic readonly statusCode?: number;\n\tpublic readonly context?: Record<string, unknown>;\n\tpublic readonly originalError?: Error;\n\n\tconstructor(\n\t\tmessage: string,\n\t\tcode: string = 'UNKNOWN_ERROR',\n\t\toptions?: { statusCode?: number; context?: Record<string, unknown>; originalError?: Error }\n\t) {\n\t\tsuper(message);\n\t\tthis.name = 'RhinoComputeError';\n\t\tthis.code = code;\n\t\tthis.statusCode = options?.statusCode;\n\t\tthis.context = options?.context;\n\t\tthis.originalError = options?.originalError;\n\n\t\t// Support error chaining (Node.js 16.9+, TypeScript 4.6+)\n\t\tif ('cause' in Error.prototype) {\n\t\t\tObject.defineProperty(this, 'cause', {\n\t\t\t\tvalue: options?.originalError,\n\t\t\t\tenumerable: true\n\t\t\t});\n\t\t}\n\t}\n}\n","export const ErrorCodes = {\n\tNETWORK_ERROR: 'NETWORK_ERROR',\n\tAUTH_ERROR: 'AUTH_ERROR',\n\tVALIDATION_ERROR: 'VALIDATION_ERROR',\n\tCOMPUTATION_ERROR: 'COMPUTATION_ERROR',\n\tTIMEOUT_ERROR: 'TIMEOUT_ERROR',\n\tCORS_ERROR: 'CORS_ERROR',\n\tUNKNOWN_ERROR: 'UNKNOWN_ERROR',\n\tINVALID_STATE: 'INVALID_STATE',\n\tINVALID_INPUT: 'INVALID_INPUT',\n\tINVALID_CONFIG: 'INVALID_CONFIG',\n\tBROWSER_ONLY: 'BROWSER_ONLY',\n\tENVIRONMENT_ERROR: 'ENVIRONMENT_ERROR',\n\tENCODING_ERROR: 'ENCODING_ERROR'\n} as const;\n\nexport type ErrorCode = (typeof ErrorCodes)[keyof typeof ErrorCodes];\n","/**\n * Error handling - explicit public API\n */\n\nexport { RhinoComputeError } from './base';\nexport { ErrorCodes } from './error-codes';\nexport type { ErrorCode } from './error-codes';\n","/**\n * Logger interface for structured logging\n *\n * @public Implement this interface to provide custom logging behavior.\n */\nexport interface Logger {\n\tdebug(message: string, ...args: unknown[]): void;\n\tinfo(message: string, ...args: unknown[]): void;\n\twarn(message: string, ...args: unknown[]): void;\n\terror(message: string, ...args: unknown[]): void;\n}\n\n/**\n * No-op logger implementation (default)\n * @internal\n */\nclass NoOpLogger implements Logger {\n\tdebug(): void { }\n\tinfo(): void { }\n\twarn(): void { }\n\terror(): void { }\n}\n\n/**\n * Console logger implementation\n * @internal\n */\nclass ConsoleLogger implements Logger {\n\tdebug(message: string, ...args: unknown[]): void {\n\t\tconsole.debug(message, ...args);\n\t}\n\n\tinfo(message: string, ...args: unknown[]): void {\n\t\tconsole.info(message, ...args);\n\t}\n\n\twarn(message: string, ...args: unknown[]): void {\n\t\tconsole.warn(message, ...args);\n\t}\n\n\terror(message: string, ...args: unknown[]): void {\n\t\tconsole.error(message, ...args);\n\t}\n}\n\n/**\n * Internal logger instance\n * @internal\n */\nlet internalLogger: Logger = new NoOpLogger();\n\n/**\n * Get the current logger instance\n *\n * @returns The current logger instance\n */\nexport function getLogger(): Logger {\n\treturn internalLogger;\n}\n\n/**\n * Set a custom logger instance\n *\n * @public Use this to configure custom logging behavior.\n *\n * @param logger - Custom logger implementation or null to disable logging\n *\n * @example\n * ```typescript\n * import { setLogger } from 'selva-compute';\n *\n * // Enable console logging\n * setLogger(console);\n *\n * // Use a custom logger\n * setLogger({\n * debug: (msg, ...args) => myLogger.debug(msg, ...args),\n * info: (msg, ...args) => myLogger.info(msg, ...args),\n * warn: (msg, ...args) => myLogger.warn(msg, ...args),\n * error: (msg, ...args) => myLogger.error(msg, ...args)\n * });\n *\n * // Disable logging\n * setLogger(null);\n * ```\n */\nexport function setLogger(logger: Logger | Console | null): void {\n\tif (logger === null) {\n\t\tinternalLogger = new NoOpLogger();\n\t} else if ('debug' in logger && 'info' in logger && 'warn' in logger && 'error' in logger) {\n\t\tinternalLogger = logger as Logger;\n\t} else {\n\t\tinternalLogger = new ConsoleLogger();\n\t}\n}\n\n/**\n * Enable debug logging to console\n *\n * @public Convenience method to enable console logging.\n *\n * @example\n * ```typescript\n * import { enableDebugLogging } from 'selva-compute';\n *\n * enableDebugLogging();\n * ```\n */\nexport function enableDebugLogging(): void {\n\tsetLogger(new ConsoleLogger());\n}\n","import RhinoCompute from 'compute-rhino3d';\n\nimport { RhinoComputeError, ErrorCodes } from '../errors';\nimport { getLogger } from '../utils/logger';\n\nimport type { ComputeConfig } from '../types';\nimport type {\n\tGrasshopperComputeConfig,\n\tGrasshopperComputeResponse,\n\tIoResponseSchema\n} from '@/features/grasshopper/types';\n\n/**\n * Valid endpoints for Rhino Compute\n */\ntype Endpoint = 'grasshopper' | 'io' | string;\n\ntype EndpointResponseMap = {\n\tgrasshopper: GrasshopperComputeResponse;\n\tio: IoResponseSchema;\n};\n\ntype ComputeResponseFor<E extends string> = E extends keyof EndpointResponseMap\n\t? EndpointResponseMap[E]\n\t: unknown;\n\n// ============================================================================\n// Error Handling\n// ============================================================================\n\nfunction throwHttpError(\n\tresponse: Response,\n\tfullUrl: string,\n\trequestId: string,\n\trequestSize: number,\n\tserverUrl: string,\n\terrorBody: string\n): never {\n\tconst { status, statusText } = response;\n\tconst context = { url: fullUrl, requestId, method: 'POST', requestSize, serverUrl };\n\n\tconst errorMap: Record<number, { message: string; code: string }> = {\n\t\t401: { message: `HTTP ${status}: ${statusText}`, code: ErrorCodes.AUTH_ERROR },\n\t\t403: { message: `HTTP ${status}: ${statusText}`, code: ErrorCodes.AUTH_ERROR },\n\t\t404: { message: `Endpoint not found: ${fullUrl}`, code: ErrorCodes.NETWORK_ERROR },\n\t\t413: {\n\t\t\tmessage: `Request too large: ${(requestSize / 1024).toFixed(2)}KB`,\n\t\t\tcode: ErrorCodes.VALIDATION_ERROR\n\t\t},\n\t\t429: { message: 'Rate limit exceeded', code: ErrorCodes.NETWORK_ERROR },\n\t\t500: {\n\t\t\tmessage: `Server error: ${errorBody || statusText}`,\n\t\t\tcode: ErrorCodes.COMPUTATION_ERROR\n\t\t},\n\t\t502: { message: `Service unavailable: ${statusText}`, code: ErrorCodes.NETWORK_ERROR },\n\t\t503: { message: `Service unavailable: ${statusText}`, code: ErrorCodes.NETWORK_ERROR },\n\t\t504: { message: `Service unavailable: ${statusText}`, code: ErrorCodes.NETWORK_ERROR }\n\t};\n\n\tconst error = errorMap[status] || {\n\t\tmessage: `HTTP ${status}: ${statusText}`,\n\t\tcode: ErrorCodes.UNKNOWN_ERROR\n\t};\n\n\tthrow new RhinoComputeError(error.message, error.code, { statusCode: status, context });\n}\n\n// ============================================================================\n// Request Helpers\n// ============================================================================\n\nfunction buildUrl(endpoint: string, serverUrl: string): string {\n\tconst base = serverUrl.replace(/\\/+$/, '');\n\tconst path = endpoint.replace(/^\\/+/, '');\n\treturn `${base}/${path}`;\n}\n\nfunction isLocalhost(serverUrl: string): boolean {\n\ttry {\n\t\tconst host = new URL(serverUrl).host;\n\t\treturn /^(localhost|127\\.0\\.0\\.1|::1)(:\\d+)?$/i.test(host);\n\t} catch {\n\t\treturn /(localhost|127\\.0\\.0\\.1)/i.test(serverUrl);\n\t}\n}\n\nfunction buildHeaders(requestId: string, config: ComputeConfig): HeadersInit {\n\tconst headers: HeadersInit = {\n\t\t'User-Agent': `compute.rhino3d.js/${RhinoCompute.version}`,\n\t\t'X-Request-ID': requestId,\n\t\t'Content-Type': 'application/json',\n\t\t...(config.authToken && { Authorization: config.authToken }),\n\t\t...(config.apiKey && { RhinoComputeKey: config.apiKey })\n\t};\n\n\tif (!config.apiKey && !isLocalhost(config.serverUrl)) {\n\t\tgetLogger().warn(\n\t\t\t`⚠️ [Rhino Compute] Request [${requestId}] targets remote server (${config.serverUrl}) but no API key is configured. Requests may fail or be rate-limited.`\n\t\t);\n\t}\n\n\treturn headers;\n}\n\nfunction generateRequestId(): string {\n\treturn `${Date.now()}-${Math.random().toString(36).substring(2, 11)}`;\n}\n\nfunction log(message: string, debug?: boolean): void {\n\tif (debug) getLogger().debug(message);\n}\n\n// ============================================================================\n// Response Processing\n// ============================================================================\n\nasync function handleResponse(\n\tresponse: Response,\n\tfullUrl: string,\n\trequestId: string,\n\trequestSize: number,\n\tserverUrl: string,\n\tstartTime: number,\n\tdebug?: boolean\n): Promise<any> {\n\tconst responseTime = Math.round(performance.now() - startTime);\n\n\tif (!response.ok) {\n\t\t// Read body once and reuse\n\t\tlet errorBody = await response.text();\n\n\t\t// Enhanced logging for errors\n\t\tif (debug) {\n\t\t\tlog(\n\t\t\t\t`❌ Request [${requestId}] failed with HTTP ${response.status} in ${responseTime}ms`,\n\t\t\t\ttrue\n\t\t\t);\n\t\t\tlog(` URL: ${fullUrl}`, true);\n\t\t\tlog(` Status: ${response.status} ${response.statusText}`, true);\n\t\t\tif (errorBody) {\n\t\t\t\tlog(\n\t\t\t\t\t` Response body: ${errorBody.substring(0, 500)}${errorBody.length > 500 ? '...' : ''}`,\n\t\t\t\t\ttrue\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\n\t\t// Check if it's a valid compute response with errors/warnings\n\t\tif (response.status === 500) {\n\t\t\ttry {\n\t\t\t\tconst parsed = JSON.parse(errorBody);\n\t\t\t\t// If it has values, it's a partial success with errors\n\t\t\t\tif (parsed?.values && (parsed.errors || parsed.warnings)) {\n\t\t\t\t\tif (debug) {\n\t\t\t\t\t\tlog(\n\t\t\t\t\t\t\t`⚠️ Request [${requestId}] completed with Grasshopper errors in ${responseTime}ms`,\n\t\t\t\t\t\t\ttrue\n\t\t\t\t\t\t);\n\t\t\t\t\t\tif (parsed.errors?.length > 0) {\n\t\t\t\t\t\t\tlog(` Errors: ${JSON.stringify(parsed.errors, null, 2)}`, true);\n\t\t\t\t\t\t}\n\t\t\t\t\t\tif (parsed.warnings?.length > 0) {\n\t\t\t\t\t\t\tlog(` Warnings: ${JSON.stringify(parsed.warnings, null, 2)}`, true);\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\treturn parsed;\n\t\t\t\t}\n\n\t\t\t\t// If it's a raw exception from the server (like ArgumentException), include it in the error message\n\t\t\t\tif (parsed?.Message) {\n\t\t\t\t\terrorBody = `${parsed.ExceptionType ? parsed.ExceptionType + ': ' : ''}${parsed.Message}\\n${parsed.StackTrace || ''}`;\n\t\t\t\t} else if (parsed?.error) {\n\t\t\t\t\terrorBody =\n\t\t\t\t\t\ttypeof parsed.error === 'string' ? parsed.error : JSON.stringify(parsed.error, null, 2);\n\t\t\t\t}\n\t\t\t} catch (e) {\n\t\t\t\tif (debug) {\n\t\t\t\t\tlog(` Failed to parse error body as JSON: ${e}`, true);\n\t\t\t\t}\n\t\t\t\t// Not valid JSON, proceed with HTTP error\n\t\t\t}\n\t\t}\n\n\t\tthrowHttpError(response, fullUrl, requestId, requestSize, serverUrl, errorBody);\n\t}\n\n\tlog(`✅ Request [${requestId}] completed in ${responseTime}ms`, debug);\n\n\ttry {\n\t\treturn await response.json();\n\t} catch (error) {\n\t\tthrow new RhinoComputeError('Failed to parse JSON response', ErrorCodes.NETWORK_ERROR, {\n\t\t\tstatusCode: response.status,\n\t\t\tcontext: {\n\t\t\t\turl: fullUrl,\n\t\t\t\trequestId\n\t\t\t},\n\t\t\toriginalError: error instanceof Error ? error : new Error(String(error))\n\t\t});\n\t}\n}\n\n// ============================================================================\n// Main Function\n// ============================================================================\n\n/**\n * Generic Rhino Compute fetch function.\n * Sends a POST request to any Compute endpoint with pre-prepared arguments.\n *\n * @public Use this for advanced low-level control over compute requests. For most use cases, prefer higher-level APIs.\n *\n * @param endpoint - The Compute API endpoint (e.g., 'grasshopper', 'io', 'mesh').\n * @param args - Pre-prepared arguments for the request.\n * @param config - Compute configuration (server URL, API key, timeout, debug).\n * @returns The parsed JSON response from the server.\n *\n * @example\n * ```typescript\n * const response = await fetchRhinoCompute(\n * 'grasshopper',\n * {\n * pointer: { url: 'https://example.com/definition.gh' },\n * values: [{ ParamName: 'x', InnerTree: { '0': [{ type: 'System.Double', data: 10 }] } }]\n * },\n * { serverUrl: 'https://compute.rhino3d.com', debug: true, timeoutMs: 30000 }\n * );\n * ```\n */\nexport async function fetchRhinoCompute<E extends Endpoint>(\n\tendpoint: E,\n\targs: Record<string, any>,\n\tconfig: ComputeConfig | GrasshopperComputeConfig\n): Promise<ComputeResponseFor<E>> {\n\tconst requestId = generateRequestId();\n\tconst body = JSON.stringify(args);\n\tconst requestSize = body.length;\n\tconst fullUrl = buildUrl(endpoint, config.serverUrl);\n\n\tif (config.debug) {\n\t\tconst sizeKb = (requestSize / 1024).toFixed(2);\n\t\tconst emoji = requestSize > 100000 ? '⚠️' : '🚀';\n\t\tlog(`${emoji} Starting compute request [${requestId}]: ${endpoint} (${sizeKb}KB)`, true);\n\t}\n\n\tconst controller = new AbortController();\n\tconst timeoutId = config.timeoutMs\n\t\t? setTimeout(() => controller.abort(), config.timeoutMs)\n\t\t: null;\n\n\ttry {\n\t\tconst startTime = performance.now();\n\t\tconst response = await fetch(fullUrl, {\n\t\t\tmethod: 'POST',\n\t\t\tbody,\n\t\t\theaders: buildHeaders(requestId, config),\n\t\t\tsignal: controller.signal\n\t\t});\n\n\t\treturn await handleResponse(\n\t\t\tresponse,\n\t\t\tfullUrl,\n\t\t\trequestId,\n\t\t\trequestSize,\n\t\t\tconfig.serverUrl,\n\t\t\tstartTime,\n\t\t\tconfig.debug\n\t\t);\n\t} catch (error) {\n\t\tif (error instanceof Error && error.name === 'AbortError' && config.timeoutMs) {\n\t\t\tthrow new RhinoComputeError(\n\t\t\t\t`Request timed out after ${config.timeoutMs}ms`,\n\t\t\t\tErrorCodes.TIMEOUT_ERROR,\n\t\t\t\t{\n\t\t\t\t\tcontext: {\n\t\t\t\t\t\tserverUrl: config.serverUrl,\n\t\t\t\t\t\ttimeoutMs: config.timeoutMs,\n\t\t\t\t\t\turl: fullUrl,\n\t\t\t\t\t\trequestId,\n\t\t\t\t\t\targs\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t);\n\t\t}\n\n\t\t// Handle fetch errors (network issues, connection refused, etc.)\n\t\tif (error instanceof TypeError) {\n\t\t\tthrow new RhinoComputeError(`Network error: ${error.message}`, ErrorCodes.NETWORK_ERROR, {\n\t\t\t\tcontext: {\n\t\t\t\t\tserverUrl: config.serverUrl,\n\t\t\t\t\turl: fullUrl,\n\t\t\t\t\trequestId,\n\t\t\t\t\tendpoint\n\t\t\t\t},\n\t\t\t\toriginalError: error\n\t\t\t});\n\t\t}\n\n\t\tthrow error;\n\t} finally {\n\t\tif (timeoutId !== null) clearTimeout(timeoutId);\n\t}\n}\n","import { RhinoComputeError, ErrorCodes } from '../errors';\nimport { getLogger } from '../utils/logger';\n\n/**\n * ComputeServerStats provides methods to query Rhino Compute server statistics.\n *\n * @public Use this for server health monitoring and statistics.\n *\n * @example\n * ```typescript\n * const stats = new ComputeServerStats('http://localhost:6500', 'your-api-key');\n *\n * try {\n * const isOnline = await stats.isServerOnline();\n * const children = await stats.getActiveChildren();\n * const version = await stats.getVersion();\n *\n * // Or get everything at once\n * const allStats = await stats.getServerStats();\n * } finally {\n * await stats.dispose(); // Clean up resources\n * }\n * ```\n */\nexport default class ComputeServerStats {\n\tprivate readonly serverUrl: string;\n\tprivate readonly apiKey?: string;\n\tprivate disposed = false;\n\tprivate activeMonitors: Set<() => void> = new Set();\n\tprivate activeTimeouts: Set<ReturnType<typeof setTimeout>> = new Set();\n\n\t/**\n\t * @param serverUrl - Base URL of the Rhino Compute server with http:// or https:// scheme (e.g., 'http://localhost:6500')\n\t * @param apiKey - Optional API key for authentication\n\t */\n\tconstructor(serverUrl: string, apiKey?: string) {\n\t\tif (!serverUrl?.trim()) {\n\t\t\tthrow new RhinoComputeError(\n\t\t\t\t'serverUrl is required',\n\t\t\t\tErrorCodes.INVALID_CONFIG,\n\t\t\t\t{ context: { serverUrl } }\n\t\t\t);\n\t\t}\n\n\t\t// Validate URL has http:// or https:// scheme\n\t\tif (!serverUrl.match(/^https?:\\/\\//)) {\n\t\t\tthrow new RhinoComputeError(\n\t\t\t\t`Invalid serverUrl: \"${serverUrl}\". Must start with \"http://\" or \"https://\". ` +\n\t\t\t\t`For example: \"http://localhost:5000\" or \"https://example.com\"`,\n\t\t\t\tErrorCodes.INVALID_CONFIG,\n\t\t\t\t{ context: { serverUrl } }\n\t\t\t);\n\t\t}\n\n\t\ttry {\n\t\t\tnew URL(serverUrl);\n\t\t} catch (err) {\n\t\t\tthrow new RhinoComputeError(\n\t\t\t\t`Invalid serverUrl: \"${serverUrl}\". Must be a valid URL. ` +\n\t\t\t\t`Received error: ${err instanceof Error ? err.message : String(err)}`,\n\t\t\t\tErrorCodes.INVALID_CONFIG,\n\t\t\t\t{\n\t\t\t\t\tcontext: { serverUrl },\n\t\t\t\t\toriginalError: err instanceof Error ? err : undefined\n\t\t\t\t}\n\t\t\t);\n\t\t}\n\n\t\tthis.apiKey = apiKey;\n\t\tthis.serverUrl = serverUrl.replace(/\\/+$/, '');\n\t}\n\n\t/**\n\t * Build request headers with optional API key.\n\t */\n\tprivate buildHeaders(): HeadersInit {\n\t\tconst headers: HeadersInit = {\n\t\t\t'Content-Type': 'application/json'\n\t\t};\n\n\t\tif (this.apiKey) {\n\t\t\theaders['RhinoComputeKey'] = this.apiKey;\n\t\t}\n\n\t\treturn headers;\n\t}\n\n\t/**\n\t * Check if the server is online.\n\t */\n\tpublic async isServerOnline(): Promise<boolean> {\n\t\tthis.ensureNotDisposed();\n\n\t\tconst url = `${this.serverUrl}/healthcheck`;\n\t\tconst init: RequestInit = { headers: this.buildHeaders(), method: 'GET' };\n\n\t\ttry {\n\t\t\tconst response = await fetch(url, init);\n\n\t\t\treturn response.ok;\n\t\t} catch (err) {\n\t\t\tgetLogger().debug('[ComputeServerStats] Fetch error:', err);\n\t\t\treturn false;\n\t\t}\n\t}\n\n\t/**\n\t * Get the number of active child processes on the server.\n\t *\n\t * @returns Number of active children, or null if unavailable\n\t */\n\tpublic async getActiveChildren(): Promise<number | null> {\n\t\tthis.ensureNotDisposed();\n\n\t\ttry {\n\t\t\tconst response = await fetch(`${this.serverUrl}/activechildren`, {\n\t\t\t\theaders: this.buildHeaders()\n\t\t\t});\n\t\t\tif (!response.ok) {\n\t\t\t\tgetLogger().warn(\n\t\t\t\t\t'[ComputeServerStats] Failed to fetch active children:',\n\t\t\t\t\tresponse.status\n\t\t\t\t);\n\t\t\t\treturn null;\n\t\t\t}\n\n\t\t\tconst text = await response.text();\n\t\t\tconst count = parseInt(text.trim(), 10);\n\n\t\t\tif (isNaN(count)) {\n\t\t\t\tgetLogger().warn('[ComputeServerStats] Invalid active children response:', text);\n\t\t\t\treturn null;\n\t\t\t}\n\n\t\t\treturn count;\n\t\t} catch (err) {\n\t\t\tgetLogger().warn('[ComputeServerStats] Error fetching active children:', err);\n\t\t\treturn null;\n\t\t}\n\t}\n\n\t/**\n\t * Get the server version information.\n\t *\n\t * @returns Version object with rhino, compute, and git_sha, or null if unavailable\n\t */\n\tpublic async getVersion(): Promise<{\n\t\trhino: string;\n\t\tcompute: string;\n\t\tgit_sha: string | null;\n\t} | null> {\n\t\tthis.ensureNotDisposed();\n\n\t\ttry {\n\t\t\tconst response = await fetch(`${this.serverUrl}/version`, {\n\t\t\t\theaders: this.buildHeaders()\n\t\t\t});\n\n\t\t\tif (!response.ok) {\n\t\t\t\tgetLogger().warn('[ComputeServerStats] Failed to fetch version:', response.status);\n\t\t\t\treturn null;\n\t\t\t}\n\n\t\t\ttry {\n\t\t\t\tconst json = await response.json();\n\t\t\t\treturn {\n\t\t\t\t\trhino: json.rhino ?? '',\n\t\t\t\t\tcompute: json.compute ?? '',\n\t\t\t\t\tgit_sha: json.git_sha ?? null\n\t\t\t\t};\n\t\t\t} catch {\n\t\t\t\t// Fallback: parse as plain text\n\t\t\t\tconst text = await response.text();\n\t\t\t\treturn { rhino: text, compute: '', git_sha: null };\n\t\t\t}\n\t\t} catch (err) {\n\t\t\tgetLogger().warn('[ComputeServerStats] Error fetching version:', err);\n\t\t\treturn null;\n\t\t}\n\t}\n\n\t/**\n\t * Get comprehensive server statistics.\n\t * Fetches all available server information in parallel.\n\t *\n\t * @returns Object containing server status and available stats\n\t */\n\tpublic async getServerStats(): Promise<{\n\t\tisOnline: boolean;\n\t\tversion?: { rhino: string; compute: string; git_sha: string | null };\n\t\tactiveChildren?: number;\n\t}> {\n\t\tthis.ensureNotDisposed();\n\n\t\tconst isOnline = await this.isServerOnline();\n\n\t\tif (!isOnline) {\n\t\t\treturn { isOnline: false };\n\t\t}\n\n\t\tconst [version, activeChildren] = await Promise.all([\n\t\t\tthis.getVersion(),\n\t\t\tthis.getActiveChildren()\n\t\t]);\n\n\t\treturn {\n\t\t\tisOnline: true,\n\t\t\t...(version && { version }),\n\t\t\t...(activeChildren !== null && { activeChildren })\n\t\t};\n\t}\n\n\t/**\n\t * Continuously monitor server stats at specified interval.\n\t *\n\t * @param callback - Function called with stats on each interval\n\t * @param intervalMs - Milliseconds between checks (default: 5000)\n\t * @returns Function to stop monitoring\n\t *\n\t * @example\n\t * ```typescript\n\t * const stopMonitoring = stats.monitor((data) => {\n\t * console.log('Server stats:', data);\n\t * }, 3000);\n\t *\n\t * // Later...\n\t * stopMonitoring();\n\t * ```\n\t */\n\tpublic monitor(\n\t\tcallback: (stats: Awaited<ReturnType<typeof this.getServerStats>>) => void,\n\t\tintervalMs: number = 5000\n\t): () => void {\n\t\tthis.ensureNotDisposed();\n\n\t\tlet active = true;\n\t\tlet currentTimeoutId: ReturnType<typeof setTimeout> | null = null;\n\n\t\tgetLogger().info(`🔄 Starting server stats monitoring every ${intervalMs}ms`);\n\n\t\tconst check = async () => {\n\t\t\t// Clear current timeout from tracking since it has fired\n\t\t\tif (currentTimeoutId !== null) {\n\t\t\t\tthis.activeTimeouts.delete(currentTimeoutId);\n\t\t\t\tcurrentTimeoutId = null;\n\t\t\t}\n\n\t\t\tif (!active || this.disposed) return;\n\n\t\t\tconst _stats = await this.getServerStats();\n\n\t\t\t// Check again after async operation to prevent race condition\n\t\t\tif (!active || this.disposed) return;\n\n\t\t\tcallback(_stats);\n\n\t\t\tif (active && !this.disposed) {\n\t\t\t\tcurrentTimeoutId = setTimeout(() => void check(), intervalMs);\n\t\t\t\tthis.activeTimeouts.add(currentTimeoutId);\n\t\t\t}\n\t\t};\n\n\t\tconst stopMonitoring = () => {\n\t\t\tactive = false;\n\n\t\t\t// Clear any pending timeout\n\t\t\tif (currentTimeoutId !== null) {\n\t\t\t\tclearTimeout(currentTimeoutId);\n\t\t\t\tthis.activeTimeouts.delete(currentTimeoutId);\n\t\t\t\tcurrentTimeoutId = null;\n\t\t\t}\n\n\t\t\tthis.activeMonitors.delete(stopMonitoring);\n\t\t};\n\n\t\tthis.activeMonitors.add(stopMonitoring);\n\n\t\t// Explicitly mark as fire-and-forget since we don't need to await the initial call\n\t\tvoid check();\n\n\t\treturn stopMonitoring;\n\t}\n\n\t/**\n\t * Disposes of all resources and stops all active monitors.\n\t * Call this when you're done using the stats instance.\n\t */\n\tpublic async dispose(): Promise<void> {\n\t\tif (this.disposed) return;\n\n\t\tthis.disposed = true;\n\n\t\t// Stop all active monitors (this will also clear their timeouts)\n\t\tfor (const stopMonitor of this.activeMonitors) {\n\t\t\tstopMonitor();\n\t\t}\n\t\tthis.activeMonitors.clear();\n\n\t\t// Clear any remaining timeouts (defensive cleanup)\n\t\tfor (const timeoutId of this.activeTimeouts) {\n\t\t\tclearTimeout(timeoutId);\n\t\t}\n\t\tthis.activeTimeouts.clear();\n\t}\n\n\t/**\n\t * Ensures the instance 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'ComputeServerStats has been disposed and cannot be used',\n\t\t\t\tErrorCodes.INVALID_STATE,\n\t\t\t\t{ context: { disposed: this.disposed } }\n\t\t\t);\n\t\t}\n\t}\n}\n","/**\n * Core utilities and configuration for rhino-compute-core\n *\n * This module provides low-level utilities, error handling, and configuration management.\n *\n * @example\n * ```typescript\n * import { normalizeComputeConfig, RhinoComputeError, ErrorCodes } from 'rhino-compute-core/core';\n *\n * const config = normalizeComputeConfig({ serverUrl: 'http://localhost:8081' });\n *\n * try {\n * // ... some operation\n * } catch (error) {\n * if (error instanceof RhinoComputeError && error.code === ErrorCodes.AUTH_ERROR) {\n * console.error('Authentication failed');\n * }\n * }\n * ```\n *\n * @module core\n */\n\n// ============================================================================\n// COMPUTE FETCH (Low-level HTTP client)\n// ============================================================================\n\nexport { fetchRhinoCompute } from './compute-fetch/compute-fetch';\n\n// =========================\n// Server Stats\n// =========================\n\nexport { ComputeServerStats } from './server';\n\n// ============================================================================\n// ERROR HANDLING\n// ============================================================================\n\nexport { RhinoComputeError } from './errors/base';\nexport { ErrorCodes } from './errors/error-codes';\nexport type { ErrorCode } from './errors/error-codes';\n\n// ============================================================================\n// UTILITIES\n// ============================================================================\n\n// Logging\nexport type { Logger } from './utils/logger';\nexport { setLogger, enableDebugLogging, getLogger } from './utils/logger';\n\n// Configuration\nexport type { ComputeConfig, RhinoModelUnit } from './types';\n\n\n"],"mappings":"ukBAAA,IAKaA,EALbC,EAAAC,EAAA,kBAKaF,EAAN,cAAgC,KAAM,CAM5C,YACCG,EACAC,EAAe,gBACfC,EACC,CACD,MAAMF,CAAO,EAVdG,EAAA,KAAgB,QAChBA,EAAA,KAAgB,cAChBA,EAAA,KAAgB,WAChBA,EAAA,KAAgB,iBAQf,KAAK,KAAO,oBACZ,KAAK,KAAOF,EACZ,KAAK,WAAaC,GAAS,WAC3B,KAAK,QAAUA,GAAS,QACxB,KAAK,cAAgBA,GAAS,cAG1B,UAAW,MAAM,WACpB,OAAO,eAAe,KAAM,QAAS,CACpC,MAAOA,GAAS,cAChB,WAAY,EACb,CAAC,CAEH,CACD,IC/BA,IAAaE,EAAbC,EAAAC,EAAA,kBAAaF,EAAa,CACzB,cAAe,gBACf,WAAY,aACZ,iBAAkB,mBAClB,kBAAmB,oBACnB,cAA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AU,CAAC,KAAK,WACnBC,EAAmB,WAAW,IAAG,CAAQC,EAAM,GAAGH,CAAU,EAC5D,KAAK,eAAe,IAAIE,CAAgB,GAE1C,EAEMG,EAAiB,IAAM,CAC5BJ,EAAS,GAGLC,IAAqB,OACxB,aAAaA,CAAgB,EAC7B,KAAK,eAAe,OAAOA,CAAgB,EAC3CA,EAAmB,MAGpB,KAAK,eAAe,OAAOG,CAAc,CAC1C,EAEA,YAAK,eAAe,IAAIA,CAAc,EAGjCF,EAAM,EAEJE,CACR,CAMA,MAAa,SAAyB,CACrC,GAAI,MAAK,SAET,MAAK,SAAW,GAGhB,QAAWC,KAAe,KAAK,eAC9BA,EAAY,EAEb,KAAK,eAAe,MAAM,EAG1B,QAAWC,KAAa,KAAK,eAC5B,aAAaA,CAAS,EAEvB,KAAK,eAAe,MAAM,EAC3B,CAKQ,mBAA0B,CACjC,GAAI,KAAK,SACR,MAAM,IAAIrB,EACT,0DACAC,EAAW,cACX,CAAE,QAAS,CAAE,SAAU,KAAK,QAAS,CAAE,CACxC,CAEF,CACD,ECtRAqB,IACAC,IASAC","names":["RhinoComputeError","init_base","__esmMin","message","code","options","__publicField","ErrorCodes","init_error_codes","__esmMin","errors_exports","__export","ErrorCodes","RhinoComputeError","init_errors","__esmMin","init_base","init_error_codes","getLogger","internalLogger","setLogger","logger","NoOpLogger","ConsoleLogger","enableDebugLogging","init_logger","__esmMin","message","args","init_errors","init_logger","RhinoCompute","throwHttpError","response","fullUrl","requestId","requestSize","serverUrl","errorBody","status","statusText","context","error","ErrorCodes","RhinoComputeError","buildUrl","endpoint","base","path","isLocalhost","host","buildHeaders","config","headers","getLogger","generateRequestId","log","message","debug","handleResponse","startTime","responseTime","parsed","e","fetchRhinoCompute","args","body","sizeKb","emoji","controller","timeoutId","init_errors","init_logger","ComputeServerStats","serverUrl","apiKey","__publicField","RhinoComputeError","ErrorCodes","err","headers","url","init","getLogger","response","text","count","json","version","activeChildren","callback","intervalMs","active","currentTimeoutId","check","_stats","stopMonitoring","stopMonitor","timeoutId","init_base","init_error_codes","init_logger"]}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } }var _chunkP57VU27Wcjs = require('./chunk-P57VU27W.cjs');function v(t){return Buffer.from(t,"utf-8").toString("base64")}function A(t){if(!t||t.trim().length===0)return!1;try{return Buffer.from(t,"base64").toString("base64")===t}catch (e2){return!1}}function C(t){if(typeof globalThis.atob=="function")return Uint8Array.from(globalThis.atob(t),l=>l.charCodeAt(0));if(typeof globalThis.Buffer=="function")return globalThis.Buffer.from(t,"base64");let{RhinoComputeError:r,ErrorCodes:e}=(_chunkP57VU27Wcjs.i.call(void 0, ),_chunkP57VU27Wcjs.b.call(void 0, _chunkP57VU27Wcjs.h));throw new r("Base64 decoding not supported in this environment.",e.INVALID_STATE,{context:{environmentInfo:"atob or Buffer not available"}})}function S(t){if(t==null){let{RhinoComputeError:n,ErrorCodes:o}=(_chunkP57VU27Wcjs.i.call(void 0, ),_chunkP57VU27Wcjs.b.call(void 0, _chunkP57VU27Wcjs.h));throw new n("Input bytes must not be null or undefined",o.INVALID_INPUT,{context:{receivedValue:t}})}let r="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",e=t;e.length>=3&&e[0]===239&&e[1]===187&&e[2]===191&&(e=e.slice(3));let l=e.byteLength,y=l%3,s=l-y,h="",i,d,c,u,a;for(let n=0;n<s;n+=3){let o=e[n]!==void 0?e[n]:0,b=e[n+1]!==void 0?e[n+1]:0,g=e[n+2]!==void 0?e[n+2]:0,f=o<<16|b<<8|g;if(i=(f&16515072)>>18,d=(f&258048)>>12,c=(f&4032)>>6,u=f&63,typeof r!="string")throw new Error("encodings must be a string");if(typeof i!="number"||i<0||i>=r.length)throw new Error("Invalid index a");if(typeof d!="number"||d<0||d>=r.length)throw new Error("Invalid index b");if(typeof c!="number"||c<0||c>=r.length)throw new Error("Invalid index c");if(typeof u!="number"||u<0||u>=r.length)throw new Error("Invalid index d");let p=r[i],m=r[d],w=r[c],B=r[u];if(p===void 0||m===void 0||w===void 0||B===void 0)throw new Error("Invalid encoding index");h+=p+m+w+B}if(y===1){if(a=e[s],a===void 0)throw new Error("'chunk' must not be undefined");i=(a&252)>>2,d=(a&3)<<4;let n=r[i],o=r[d];if(n===void 0||o===void 0)throw new Error("Invalid encoding index");h+=`${n+o}==`}else if(y===2){let n=_nullishCoalesce(e[s], () => (0)),o=e[s+1]!==void 0?e[s+1]:0;if(typeof n!="number"||n<0||n>255||typeof o!="number"||o<0||o>255)throw new Error("Invalid byte1");a=n<<8|o,i=(a&64512)>>10,d=(a&1008)>>4,c=(a&15)<<2;let b=r[i],g=r[d],f=r[c];if(b===void 0||g===void 0||f===void 0)throw new Error("Invalid encoding index");h+=`${b+g+f}=`}return h}exports.a = v; exports.b = A; exports.c = C; exports.d = S;
|
|
2
|
+
//# sourceMappingURL=chunk-5DJRUPGI.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["/Users/felix/coding/selva-compute/dist/chunk-5DJRUPGI.cjs","../src/core/utils/encoding.ts"],"names":["encodeStringToBase64","str","isBase64","decodeBase64ToBinary","base64File","c","RhinoComputeError","ErrorCodes","base64ByteArray","bytes","encodings","inputBytes","byteLength","byteRemainder","mainLength","base64","a","b","d","chunk","i","byte1","byte2","byte3","innerChunk","charA","charB","charC","charD"],"mappings":"AAAA,qOAAsD,SCQtCA,CAAAA,CAAqBC,CAAAA,CAAqB,CACzD,OAAO,MAAA,CAAO,IAAA,CAAKA,CAAAA,CAAK,OAAO,CAAA,CAAE,QAAA,CAAS,QAAQ,CACnD,CAuBO,SAASC,CAAAA,CAASD,CAAAA,CAAsB,CAC9C,EAAA,CAAI,CAACA,CAAAA,EAAOA,CAAAA,CAAI,IAAA,CAAK,CAAA,CAAE,MAAA,GAAW,CA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AAAA,CAAQC,CACnC,CAGA,EAAA,CAAIf,CAAAA,GAAkB,CAAA,CAAG,CAGxB,EAAA,CAFAM,CAAAA,CAAQR,CAAAA,CAAWG,CAAU,CAAA,CAEzBK,CAAAA,GAAU,KAAA,CAAA,CACb,MAAM,IAAI,KAAA,CAAM,+BAA+B,CAAA,CAGhDH,CAAAA,CAAAA,CAAKG,CAAAA,CAAQ,GAAA,CAAA,EAAQ,CAAA,CACrBF,CAAAA,CAAAA,CAAKE,CAAAA,CAAQ,CAAA,CAAA,EAAM,CAAA,CAEnB,IAAMM,CAAAA,CAAQf,CAAAA,CAAUM,CAAC,CAAA,CACnBU,CAAAA,CAAQhB,CAAAA,CAAUO,CAAC,CAAA,CAEzB,EAAA,CAAIQ,CAAAA,GAAU,KAAA,CAAA,EAAaC,CAAAA,GAAU,KAAA,CAAA,CACpC,MAAM,IAAI,KAAA,CAAM,wBAAwB,CAAA,CAGzCX,CAAAA,EAAU,CAAA,EAAA","file":"/Users/felix/coding/selva-compute/dist/chunk-5DJRUPGI.cjs","sourcesContent":[null,"/**\n * Encodes a string to base64 (Node 20+ safe)\n *\n * @internal Internal encoding helper — kept internal to `selva-compute`.\n *\n * @param str - String to encode\n * @returns Base64 encoded string\n */\nexport function encodeStringToBase64(str: string): string {\n\treturn Buffer.from(str, 'utf-8').toString('base64');\n}\n\n/**\n * Decodes a base64 string to a UTF-8 string (Node 20+ safe)\n *\n * @internal Internal encoding helper — kept internal to `selva-compute`.\n *\n * @param base64Str - Base64 encoded string\n * @returns Decoded UTF-8 string\n */\nexport function decodeBase64ToString(base64Str: string): string {\n\treturn Buffer.from(base64Str, 'base64').toString('utf-8');\n}\n\n\n/**\n * Checks if a string is valid base64\n *\n * @internal Internal encoding helper — kept internal to `selva-compute`.\n *\n * @param str - String to check\n * @returns True if the string is valid base64\n */\nexport function isBase64(str: string): boolean {\n\tif (!str || str.trim().length === 0) return false;\n\ttry {\n\t\treturn Buffer.from(str, 'base64').toString('base64') === str;\n\t} catch {\n\t\treturn false;\n\t}\n}\n\n\n/**\n * Decodes a base64 string to binary data (Uint8Array)\n *\n * @internal Internal encoding helper — kept internal to `selva-compute`.\n *\n * @param base64File - Base64 encoded string\n * @returns Decoded binary data as Uint8Array\n * @throws {RhinoComputeError} If base64 decoding is not supported in this environment.\n */\nexport function decodeBase64ToBinary(base64File: string): Uint8Array {\n\tif (typeof globalThis.atob === 'function') {\n\t\treturn Uint8Array.from(globalThis.atob(base64File), (c) => c.charCodeAt(0));\n\t}\n\tif (typeof (globalThis as any).Buffer === 'function') {\n\t\t// Buffer.from returns a Uint8Array-compatible Buffer\n\t\treturn (globalThis as any).Buffer.from(base64File, 'base64');\n\t}\n\n\t// Import here to avoid circular dependencies at top level\n\t// eslint-disable-next-line @typescript-eslint/no-require-imports\n\tconst { RhinoComputeError, ErrorCodes } = require('./../../core/errors');\n\tthrow new RhinoComputeError(\n\t\t'Base64 decoding not supported in this environment.',\n\t\tErrorCodes.INVALID_STATE,\n\t\t{ context: { environmentInfo: 'atob or Buffer not available' } }\n\t);\n}\n\n/**\n * Encodes binary data (Uint8Array) to base64 string\n *\n * @internal Internal encoding helper — kept internal to `selva-compute`.\n *\n * Source: https://github.com/mcneel/compute.rhino3d.appserver/blob/92c95a3b1d076a4d4a5360214ffd27c46425ff03/src/examples/convert/scriptjs\n * https://gist.github.com/jonleighton/958841\n *\n * MIT LICENSE\n * Copyright 2011 Jon Leighton\n * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the \"Software\"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:\n * The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n */\nexport function base64ByteArray(bytes: Uint8Array | null | undefined): string {\n\tif (bytes === null || bytes === undefined) {\n\t\t// Import here to avoid circular dependencies at top level\n\t\t// eslint-disable-next-line @typescript-eslint/no-require-imports\n\t\tconst { RhinoComputeError, ErrorCodes } = require('./../../core/errors');\n\t\tthrow new RhinoComputeError(\n\t\t\t'Input bytes must not be null or undefined',\n\t\t\tErrorCodes.INVALID_INPUT,\n\t\t\t{ context: { receivedValue: bytes } }\n\t\t);\n\t}\n\n\tconst encodings = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/';\n\n\tlet inputBytes = bytes;\n\n\t// strip bom (Byte Order Mark)\n\tif (\n\t\tinputBytes.length >= 3 &&\n\t\tinputBytes[0] === 239 &&\n\t\tinputBytes[1] === 187 &&\n\t\tinputBytes[2] === 191\n\t) {\n\t\tinputBytes = inputBytes.slice(3);\n\t}\n\n\tconst byteLength = inputBytes.byteLength;\n\tconst byteRemainder = byteLength % 3;\n\tconst mainLength = byteLength - byteRemainder;\n\n\tlet base64 = '';\n\tlet a, b, c, d;\n\tlet chunk;\n\n\t// Main loop deals with bytes in chunks of 3\n\tfor (let i = 0; i < mainLength; i += 3) {\n\t\t// Combine the three bytes into a single integer\n\n\t\tconst byte1 = inputBytes[i] !== undefined ? inputBytes[i] : 0;\n\t\tconst byte2 = inputBytes[i + 1] !== undefined ? inputBytes[i + 1] : 0;\n\t\tconst byte3 = inputBytes[i + 2] !== undefined ? inputBytes[i + 2] : 0;\n\n\t\tconst innerChunk = (byte1 << 16) | (byte2 << 8) | byte3;\n\n\t\t// Use bitmasks to extract 6-bit segments from the triplet\n\t\ta = (innerChunk & 16515072) >> 18;\n\t\tb = (innerChunk & 258048) >> 12;\n\t\tc = (innerChunk & 4032) >> 6;\n\t\td = innerChunk & 63;\n\n\t\t// Convert the raw binary segments to the appropriate ASCII encoding\n\t\tif (typeof encodings !== 'string') {\n\t\t\tthrow new Error('encodings must be a string');\n\t\t}\n\n\t\tif (typeof a !== 'number' || a < 0 || a >= encodings.length) {\n\t\t\tthrow new Error('Invalid index a');\n\t\t}\n\n\t\tif (typeof b !== 'number' || b < 0 || b >= encodings.length) {\n\t\t\tthrow new Error('Invalid index b');\n\t\t}\n\n\t\tif (typeof c !== 'number' || c < 0 || c >= encodings.length) {\n\t\t\tthrow new Error('Invalid index c');\n\t\t}\n\n\t\tif (typeof d !== 'number' || d < 0 || d >= encodings.length) {\n\t\t\tthrow new Error('Invalid index d');\n\t\t}\n\n\t\tconst charA = encodings[a];\n\t\tconst charB = encodings[b];\n\t\tconst charC = encodings[c];\n\t\tconst charD = encodings[d];\n\n\t\tif (charA === undefined || charB === undefined || charC === undefined || charD === undefined) {\n\t\t\tthrow new Error('Invalid encoding index');\n\t\t}\n\n\t\tbase64 += charA + charB + charC + charD;\n\t}\n\n\t// Deal with the remaining bytes and padding\n\tif (byteRemainder === 1) {\n\t\tchunk = inputBytes[mainLength];\n\n\t\tif (chunk === undefined) {\n\t\t\tthrow new Error(\"'chunk' must not be undefined\");\n\t\t}\n\n\t\ta = (chunk & 252) >> 2;\n\t\tb = (chunk & 3) << 4;\n\n\t\tconst charA = encodings[a];\n\t\tconst charB = encodings[b];\n\n\t\tif (charA === undefined || charB === undefined) {\n\t\t\tthrow new Error('Invalid encoding index');\n\t\t}\n\n\t\tbase64 += `${charA + charB}==`;\n\t} else if (byteRemainder === 2) {\n\t\tconst byte1 = inputBytes[mainLength] ?? 0;\n\t\tconst byte2 = inputBytes[mainLength + 1] !== undefined ? inputBytes[mainLength + 1] : 0;\n\n\t\tif (\n\t\t\ttypeof byte1 !== 'number' ||\n\t\t\tbyte1 < 0 ||\n\t\t\tbyte1 > 255 ||\n\t\t\ttypeof byte2 !== 'number' ||\n\t\t\tbyte2 < 0 ||\n\t\t\tbyte2 > 255\n\t\t) {\n\t\t\tthrow new Error('Invalid byte1');\n\t\t}\n\n\t\tchunk = (byte1 << 8) | byte2;\n\n\t\ta = (chunk & 64512) >> 10;\n\t\tb = (chunk & 1008) >> 4;\n\t\tc = (chunk & 15) << 2;\n\n\t\tconst charA = encodings[a];\n\t\tconst charB = encodings[b];\n\t\tconst charC = encodings[c];\n\n\t\tif (charA === undefined || charB === undefined || charC === undefined) {\n\t\t\tthrow new Error('Invalid encoding index');\n\t\t}\n\n\t\tbase64 += `${charA + charB + charC}=`;\n\t}\n\n\treturn base64;\n}\n\n/**\n * Convert base64 string to rhino object\n *\n * @internal Internal helper for decoding Rhino objects — not public API.\n *\n * Source: https://github.com/mcneel/compute.rhino3d.appserver/blob/92c95a3b1d076a4d4a5360214ffd27c46425ff03/src/examples/convert/scriptjs\n * @param rhino is the rhino module form rhino3dm. Since not properly typed its not used here.\n * @param item\n * @returns\n */\nexport function base64ToRhinoObject(\n\trhino: any,\n\titem: {\n\t\ttype: string;\n\t\tdata: string;\n\t}\n) {\n\t// Import here to avoid circular dependencies at top level\n\t// eslint-disable-next-line @typescript-eslint/no-require-imports\n\tconst { getLogger } = require('./logger');\n\n\t//Make a type definition for this?\n\tlet decodata: null | object = null;\n\ttry {\n\t\tdecodata = JSON.parse(item.data);\n\t} catch (error) {\n\t\tdecodata = item;\n\t\tgetLogger().warn('Failed to parse JSON, returning original data:', error, item);\n\t}\n\tif (item.type === 'System.String') {\n\t\ttry {\n\t\t\treturn rhino.DracoCompression.decompressBase64String(decodata);\n\t\t} catch (error) {\n\t\t\tgetLogger().error('Failed to decompress Draco base64 string:', error);\n\t\t}\n\t} else if (\n\t\ttypeof decodata === 'object' &&\n\t\tObject.prototype.hasOwnProperty.call(decodata, 'opennurbs')\n\t) {\n\t\treturn rhino.CommonObject.decode(decodata);\n\t} else if (typeof decodata === 'object') {\n\t\ttry {\n\t\t\treturn rhino.CommonObject.decode(decodata);\n\t\t} catch (error) {\n\t\t\tgetLogger().error('Failed to decode Rhino object:', error);\n\t\t}\n\t}\n}\n"]}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{b as x,h as E,i as I}from"./chunk-24EXIE4G.js";function v(t){return Buffer.from(t,"utf-8").toString("base64")}function A(t){if(!t||t.trim().length===0)return!1;try{return Buffer.from(t,"base64").toString("base64")===t}catch{return!1}}function C(t){if(typeof globalThis.atob=="function")return Uint8Array.from(globalThis.atob(t),l=>l.charCodeAt(0));if(typeof globalThis.Buffer=="function")return globalThis.Buffer.from(t,"base64");let{RhinoComputeError:r,ErrorCodes:e}=(I(),x(E));throw new r("Base64 decoding not supported in this environment.",e.INVALID_STATE,{context:{environmentInfo:"atob or Buffer not available"}})}function S(t){if(t==null){let{RhinoComputeError:n,ErrorCodes:o}=(I(),x(E));throw new n("Input bytes must not be null or undefined",o.INVALID_INPUT,{context:{receivedValue:t}})}let r="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",e=t;e.length>=3&&e[0]===239&&e[1]===187&&e[2]===191&&(e=e.slice(3));let l=e.byteLength,y=l%3,s=l-y,h="",i,d,c,u,a;for(let n=0;n<s;n+=3){let o=e[n]!==void 0?e[n]:0,b=e[n+1]!==void 0?e[n+1]:0,g=e[n+2]!==void 0?e[n+2]:0,f=o<<16|b<<8|g;if(i=(f&16515072)>>18,d=(f&258048)>>12,c=(f&4032)>>6,u=f&63,typeof r!="string")throw new Error("encodings must be a string");if(typeof i!="number"||i<0||i>=r.length)throw new Error("Invalid index a");if(typeof d!="number"||d<0||d>=r.length)throw new Error("Invalid index b");if(typeof c!="number"||c<0||c>=r.length)throw new Error("Invalid index c");if(typeof u!="number"||u<0||u>=r.length)throw new Error("Invalid index d");let p=r[i],m=r[d],w=r[c],B=r[u];if(p===void 0||m===void 0||w===void 0||B===void 0)throw new Error("Invalid encoding index");h+=p+m+w+B}if(y===1){if(a=e[s],a===void 0)throw new Error("'chunk' must not be undefined");i=(a&252)>>2,d=(a&3)<<4;let n=r[i],o=r[d];if(n===void 0||o===void 0)throw new Error("Invalid encoding index");h+=`${n+o}==`}else if(y===2){let n=e[s]??0,o=e[s+1]!==void 0?e[s+1]:0;if(typeof n!="number"||n<0||n>255||typeof o!="number"||o<0||o>255)throw new Error("Invalid byte1");a=n<<8|o,i=(a&64512)>>10,d=(a&1008)>>4,c=(a&15)<<2;let b=r[i],g=r[d],f=r[c];if(b===void 0||g===void 0||f===void 0)throw new Error("Invalid encoding index");h+=`${b+g+f}=`}return h}export{v as a,A as b,C as c,S as d};
|
|
2
|
+
//# sourceMappingURL=chunk-AEQTQHPY.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/core/utils/encoding.ts"],"sourcesContent":["/**\n * Encodes a string to base64 (Node 20+ safe)\n *\n * @internal Internal encoding helper — kept internal to `selva-compute`.\n *\n * @param str - String to encode\n * @returns Base64 encoded string\n */\nexport function encodeStringToBase64(str: string): string {\n\treturn Buffer.from(str, 'utf-8').toString('base64');\n}\n\n/**\n * Decodes a base64 string to a UTF-8 string (Node 20+ safe)\n *\n * @internal Internal encoding helper — kept internal to `selva-compute`.\n *\n * @param base64Str - Base64 encoded string\n * @returns Decoded UTF-8 string\n */\nexport function decodeBase64ToString(base64Str: string): string {\n\treturn Buffer.from(base64Str, 'base64').toString('utf-8');\n}\n\n\n/**\n * Checks if a string is valid base64\n *\n * @internal Internal encoding helper — kept internal to `selva-compute`.\n *\n * @param str - String to check\n * @returns True if the string is valid base64\n */\nexport function isBase64(str: string): boolean {\n\tif (!str || str.trim().length === 0) return false;\n\ttry {\n\t\treturn Buffer.from(str, 'base64').toString('base64') === str;\n\t} catch {\n\t\treturn false;\n\t}\n}\n\n\n/**\n * Decodes a base64 string to binary data (Uint8Array)\n *\n * @internal Internal encoding helper — kept internal to `selva-compute`.\n *\n * @param base64File - Base64 encoded string\n * @returns Decoded binary data as Uint8Array\n * @throws {RhinoComputeError} If base64 decoding is not supported in this environment.\n */\nexport function decodeBase64ToBinary(base64File: string): Uint8Array {\n\tif (typeof globalThis.atob === 'function') {\n\t\treturn Uint8Array.from(globalThis.atob(base64File), (c) => c.charCodeAt(0));\n\t}\n\tif (typeof (globalThis as any).Buffer === 'function') {\n\t\t// Buffer.from returns a Uint8Array-compatible Buffer\n\t\treturn (globalThis as any).Buffer.from(base64File, 'base64');\n\t}\n\n\t// Import here to avoid circular dependencies at top level\n\t// eslint-disable-next-line @typescript-eslint/no-require-imports\n\tconst { RhinoComputeError, ErrorCodes } = require('./../../core/errors');\n\tthrow new RhinoComputeError(\n\t\t'Base64 decoding not supported in this environment.',\n\t\tErrorCodes.INVALID_STATE,\n\t\t{ context: { environmentInfo: 'atob or Buffer not available' } }\n\t);\n}\n\n/**\n * Encodes binary data (Uint8Array) to base64 string\n *\n * @internal Internal encoding helper — kept internal to `selva-compute`.\n *\n * Source: https://github.com/mcneel/compute.rhino3d.appserver/blob/92c95a3b1d076a4d4a5360214ffd27c46425ff03/src/examples/convert/scriptjs\n * https://gist.github.com/jonleighton/958841\n *\n * MIT LICENSE\n * Copyright 2011 Jon Leighton\n * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the \"Software\"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:\n * The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n */\nexport function base64ByteArray(bytes: Uint8Array | null | undefined): string {\n\tif (bytes === null || bytes === undefined) {\n\t\t// Import here to avoid circular dependencies at top level\n\t\t// eslint-disable-next-line @typescript-eslint/no-require-imports\n\t\tconst { RhinoComputeError, ErrorCodes } = require('./../../core/errors');\n\t\tthrow new RhinoComputeError(\n\t\t\t'Input bytes must not be null or undefined',\n\t\t\tErrorCodes.INVALID_INPUT,\n\t\t\t{ context: { receivedValue: bytes } }\n\t\t);\n\t}\n\n\tconst encodings = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/';\n\n\tlet inputBytes = bytes;\n\n\t// strip bom (Byte Order Mark)\n\tif (\n\t\tinputBytes.length >= 3 &&\n\t\tinputBytes[0] === 239 &&\n\t\tinputBytes[1] === 187 &&\n\t\tinputBytes[2] === 191\n\t) {\n\t\tinputBytes = inputBytes.slice(3);\n\t}\n\n\tconst byteLength = inputBytes.byteLength;\n\tconst byteRemainder = byteLength % 3;\n\tconst mainLength = byteLength - byteRemainder;\n\n\tlet base64 = '';\n\tlet a, b, c, d;\n\tlet chunk;\n\n\t// Main loop deals with bytes in chunks of 3\n\tfor (let i = 0; i < mainLength; i += 3) {\n\t\t// Combine the three bytes into a single integer\n\n\t\tconst byte1 = inputBytes[i] !== undefined ? inputBytes[i] : 0;\n\t\tconst byte2 = inputBytes[i + 1] !== undefined ? inputBytes[i + 1] : 0;\n\t\tconst byte3 = inputBytes[i + 2] !== undefined ? inputBytes[i + 2] : 0;\n\n\t\tconst innerChunk = (byte1 << 16) | (byte2 << 8) | byte3;\n\n\t\t// Use bitmasks to extract 6-bit segments from the triplet\n\t\ta = (innerChunk & 16515072) >> 18;\n\t\tb = (innerChunk & 258048) >> 12;\n\t\tc = (innerChunk & 4032) >> 6;\n\t\td = innerChunk & 63;\n\n\t\t// Convert the raw binary segments to the appropriate ASCII encoding\n\t\tif (typeof encodings !== 'string') {\n\t\t\tthrow new Error('encodings must be a string');\n\t\t}\n\n\t\tif (typeof a !== 'number' || a < 0 || a >= encodings.length) {\n\t\t\tthrow new Error('Invalid index a');\n\t\t}\n\n\t\tif (typeof b !== 'number' || b < 0 || b >= encodings.length) {\n\t\t\tthrow new Error('Invalid index b');\n\t\t}\n\n\t\tif (typeof c !== 'number' || c < 0 || c >= encodings.length) {\n\t\t\tthrow new Error('Invalid index c');\n\t\t}\n\n\t\tif (typeof d !== 'number' || d < 0 || d >= encodings.length) {\n\t\t\tthrow new Error('Invalid index d');\n\t\t}\n\n\t\tconst charA = encodings[a];\n\t\tconst charB = encodings[b];\n\t\tconst charC = encodings[c];\n\t\tconst charD = encodings[d];\n\n\t\tif (charA === undefined || charB === undefined || charC === undefined || charD === undefined) {\n\t\t\tthrow new Error('Invalid encoding index');\n\t\t}\n\n\t\tbase64 += charA + charB + charC + charD;\n\t}\n\n\t// Deal with the remaining bytes and padding\n\tif (byteRemainder === 1) {\n\t\tchunk = inputBytes[mainLength];\n\n\t\tif (chunk === undefined) {\n\t\t\tthrow new Error(\"'chunk' must not be undefined\");\n\t\t}\n\n\t\ta = (chunk & 252) >> 2;\n\t\tb = (chunk & 3) << 4;\n\n\t\tconst charA = encodings[a];\n\t\tconst charB = encodings[b];\n\n\t\tif (charA === undefined || charB === undefined) {\n\t\t\tthrow new Error('Invalid encoding index');\n\t\t}\n\n\t\tbase64 += `${charA + charB}==`;\n\t} else if (byteRemainder === 2) {\n\t\tconst byte1 = inputBytes[mainLength] ?? 0;\n\t\tconst byte2 = inputBytes[mainLength + 1] !== undefined ? inputBytes[mainLength + 1] : 0;\n\n\t\tif (\n\t\t\ttypeof byte1 !== 'number' ||\n\t\t\tbyte1 < 0 ||\n\t\t\tbyte1 > 255 ||\n\t\t\ttypeof byte2 !== 'number' ||\n\t\t\tbyte2 < 0 ||\n\t\t\tbyte2 > 255\n\t\t) {\n\t\t\tthrow new Error('Invalid byte1');\n\t\t}\n\n\t\tchunk = (byte1 << 8) | byte2;\n\n\t\ta = (chunk & 64512) >> 10;\n\t\tb = (chunk & 1008) >> 4;\n\t\tc = (chunk & 15) << 2;\n\n\t\tconst charA = encodings[a];\n\t\tconst charB = encodings[b];\n\t\tconst charC = encodings[c];\n\n\t\tif (charA === undefined || charB === undefined || charC === undefined) {\n\t\t\tthrow new Error('Invalid encoding index');\n\t\t}\n\n\t\tbase64 += `${charA + charB + charC}=`;\n\t}\n\n\treturn base64;\n}\n\n/**\n * Convert base64 string to rhino object\n *\n * @internal Internal helper for decoding Rhino objects — not public API.\n *\n * Source: https://github.com/mcneel/compute.rhino3d.appserver/blob/92c95a3b1d076a4d4a5360214ffd27c46425ff03/src/examples/convert/scriptjs\n * @param rhino is the rhino module form rhino3dm. Since not properly typed its not used here.\n * @param item\n * @returns\n */\nexport function base64ToRhinoObject(\n\trhino: any,\n\titem: {\n\t\ttype: string;\n\t\tdata: string;\n\t}\n) {\n\t// Import here to avoid circular dependencies at top level\n\t// eslint-disable-next-line @typescript-eslint/no-require-imports\n\tconst { getLogger } = require('./logger');\n\n\t//Make a type definition for this?\n\tlet decodata: null | object = null;\n\ttry {\n\t\tdecodata = JSON.parse(item.data);\n\t} catch (error) {\n\t\tdecodata = item;\n\t\tgetLogger().warn('Failed to parse JSON, returning original data:', error, item);\n\t}\n\tif (item.type === 'System.String') {\n\t\ttry {\n\t\t\treturn rhino.DracoCompression.decompressBase64String(decodata);\n\t\t} catch (error) {\n\t\t\tgetLogger().error('Failed to decompress Draco base64 string:', error);\n\t\t}\n\t} else if (\n\t\ttypeof decodata === 'object' &&\n\t\tObject.prototype.hasOwnProperty.call(decodata, 'opennurbs')\n\t) {\n\t\treturn rhino.CommonObject.decode(decodata);\n\t} else if (typeof decodata === 'object') {\n\t\ttry {\n\t\t\treturn rhino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,EAAQ,MAAQ,EACrBF,GAAKE,EAAQ,IAAM,EAEnB,IAAMM,EAAQf,EAAUM,CAAC,EACnBU,EAAQhB,EAAUO,CAAC,EAEzB,GAAIQ,IAAU,QAAaC,IAAU,OACpC,MAAM,IAAI,MAAM,wBAAwB,EAGzCX,GAAU,GAAGU,EAAQC,CAAK,IAC3B,SAAWb,IAAkB,EAAG,CAC/B,IAAMQ,EAAQV,EAAWG,CAAU,GAAK,EAClCQ,EAAQX,EAAWG,EAAa,CAAC,IAAM,OAAYH,EAAWG,EAAa,CAAC,EAAI,EAEtF,GACC,OAAOO,GAAU,UACjBA,EAAQ,GACRA,EAAQ,KACR,OAAOC,GAAU,UACjBA,EAAQ,GACRA,EAAQ,IAER,MAAM,IAAI,MAAM,eAAe,EAGhCH,EAASE,GAAS,EAAKC,EAEvBN,GAAKG,EAAQ,QAAU,GACvBF,GAAKE,EAAQ,OAAS,EACtB,GAAKA,EAAQ,KAAO,EAEpB,IAAMM,EAAQf,EAAUM,CAAC,EACnBU,EAAQhB,EAAUO,CAAC,EACnBU,EAAQjB,EAAU,CAAC,EAEzB,GAAIe,IAAU,QAAaC,IAAU,QAAaC,IAAU,OAC3D,MAAM,IAAI,MAAM,wBAAwB,EAGzCZ,GAAU,GAAGU,EAAQC,EAAQC,CAAK,GACnC,CAEA,OAAOZ,CACR","names":["encodeStringToBase64","str","isBase64","str","decodeBase64ToBinary","base64File","c","RhinoComputeError","ErrorCodes","base64ByteArray","bytes","encodings","inputBytes","byteLength","byteRemainder","mainLength","base64","a","b","d","chunk","i","byte1","byte2","byte3","innerChunk","charA","charB","charC","charD"]}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{c as d}from"./chunk-AEQTQHPY.js";import{d as s,f as c,j as f}from"./chunk-24EXIE4G.js";var F=async(t,r=null)=>{try{return await p(t,r)}catch(o){throw new s("Failed to extract files from compute response",c.INVALID_STATE,{context:{originalError:o instanceof Error?o.message:String(o)},originalError:o instanceof Error?o:void 0})}},m=async(t,r,o=null)=>{if(typeof document>"u"||typeof Blob>"u")throw new s("File download functionality is only available in browser environments. This function requires the DOM API (document, Blob).",c.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 s?e:new s("Failed to download files from compute response",c.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=d(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 f().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 f().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 import("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 s("saveFile requires a browser environment with DOM API access.",c.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)}export{F as a,m as b};
|
|
2
|
+
//# sourceMappingURL=chunk-JJLRDYYP.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/features/file-handling/handle-files.ts"],"sourcesContent":["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"],"mappings":"8FAoBO,IAAMA,EAAkC,MAC9CC,EACAC,EAAwD,OAC1B,CAC9B,GAAI,CACH,OAAO,MAAMC,EAAaF,EAAmBC,CAAe,CAC7D,OAASE,EAAK,CACb,MAAM,IAAIC,EACT,gDACAC,EAAW,cACX,CACC,QAAS,CAAE,cAAeF,aAAe,MAAQA,EAAI,QAAU,OAAOA,CAAG,CAAE,EAC3E,cAAeA,aAAe,MAAQA,EAAM,MAC7C,CACD,CACD,CACD,EAeaG,EAAmB,MAC/BN,EACAO,EACAN,EAAwD,OACrC,CAEnB,GAAI,OAAO,SAAa,KAAe,OAAO,KAAS,IACtD,MAAM,IAAIG,EACT,8HACAC,EAAW,aACX,CACC,QAAS,CACR,YAAa,OAAO,OAAW,IAAc,gBAAkB,UAC/D,kBAAmB,OAAO,SAAa,IACvC,cAAe,OAAO,KAAS,GAChC,CACD,CACD,EAGD,GAAI,CACH,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AAc,MADH,MAAMF,EAAS,KAAK,GACF,YAAY,EAC/C,MAAO,CACN,SAAUD,EAAK,SACf,QAAS,IAAI,WAAWG,CAAW,EACnC,KAAMH,EAAK,QACZ,CACD,OAASI,EAAO,CACf,OAAAF,EAAU,EAAE,MAAM,4CAA4CF,EAAK,QAAQ,GAAII,CAAK,EAC7E,IACR,CACD,CAAC,CACF,EAEAb,EAAe,KAAK,GAAGQ,EAAoB,OAAQM,GAA0BA,IAAM,IAAI,CAAC,CACzF,CAEA,OAAOd,CACR,EASA,eAAeC,EAAqBc,EAAwBC,EAAgC,CAC3F,GAAM,CAAE,QAAAC,EAAS,QAAAC,CAAQ,EAAI,KAAM,QAAO,QAAQ,EAG5CC,EAAsC,CAAC,EAC7CJ,EAAM,QAASN,GAAS,CACvBU,EAAQV,EAAK,IAAI,EAAI,OAAOA,EAAK,SAAY,SAAWS,EAAQT,EAAK,OAAO,EAAIA,EAAK,OACtF,CAAC,EAED,IAAMW,EAASH,EAAQE,EAAS,CAAE,MAAO,CAAE,CAAC,EAEtCE,EAAO,IAAI,KAAK,CAACD,CAAkB,EAAG,CAAE,KAAM,iBAAkB,CAAC,EACvEE,EAASD,EAAM,GAAGL,CAAO,MAAM,CAChC,CASA,SAASM,EAASD,EAAYE,EAAkB,CAC/C,GAAI,OAAO,SAAa,IACvB,MAAM,IAAI3B,EACT,+DACAC,EAAW,aACX,CACC,QAAS,CAAE,SAAU,WAAY,YAAa,UAAW,CAC1D,CACD,EAGD,IAAM2B,EAAI,SAAS,cAAc,GAAG,EACpCA,EAAE,KAAO,IAAI,gBAAgBH,CAAI,EACjCG,EAAE,SAAWD,EACbC,EAAE,MAAM,EACR,IAAI,gBAAgBA,EAAE,IAAI,CAC3B","names":["extractFilesFromComputeResponse","downloadableFiles","additionalFiles","processFiles","err","RhinoComputeError","ErrorCodes","downloadFileData","fileFoldername","processedFiles","createAndDownloadZip","dataItems","item","filePath","bites","decodeBase64ToBinary","filesArray","additionalProcessed","file","response","getLogger","arrayBuffer","error","f","files","zipName","zipSync","strToU8","zipData","zipped","blob","saveFile","filename","a"]}
|